@timardex/cluemart-server-shared 3.0.1 → 4.0.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/{chunk-GDXPPYDN.mjs → chunk-MVQMMXGY.mjs} +444 -286
- package/dist/chunk-MVQMMXGY.mjs.map +1 -0
- package/dist/index.cjs +641 -478
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +40 -7
- package/dist/index.d.ts +40 -7
- package/dist/index.mjs +460 -297
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +501 -343
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +34 -2
- package/dist/mongoose/index.d.ts +34 -2
- package/dist/mongoose/index.mjs +7 -1
- package/dist/service/index.cjs +634 -477
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +6 -5
- package/dist/service/index.d.ts +6 -5
- package/dist/service/index.mjs +12 -6
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-GDXPPYDN.mjs.map +0 -1
package/dist/service/index.cjs
CHANGED
|
@@ -97,7 +97,7 @@ __export(service_exports, {
|
|
|
97
97
|
updateAdStatuses: () => updateAdStatuses,
|
|
98
98
|
updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
|
|
99
99
|
updateRelationDatesToCanceled: () => updateRelationDatesToCanceled,
|
|
100
|
-
updateSingleDateTimeStatus: () =>
|
|
100
|
+
updateSingleDateTimeStatus: () => import_cluemart_shared37.updateSingleDateTimeStatus,
|
|
101
101
|
upgradeUserToLicence: () => upgradeUserToLicence,
|
|
102
102
|
vendorOwnerHasProLicence: () => vendorOwnerHasProLicence
|
|
103
103
|
});
|
|
@@ -369,10 +369,49 @@ schema3.index(
|
|
|
369
369
|
);
|
|
370
370
|
var AdBookingModel = import_mongoose3.default.models.AdBooking || import_mongoose3.default.model("AdBooking", schema3);
|
|
371
371
|
|
|
372
|
+
// src/mongoose/ad/AdPurchase.ts
|
|
373
|
+
var import_mongoose4 = __toESM(require("mongoose"));
|
|
374
|
+
var schema4 = new import_mongoose4.default.Schema(
|
|
375
|
+
{
|
|
376
|
+
_id: { required: true, type: String },
|
|
377
|
+
approvalRequired: { type: Boolean },
|
|
378
|
+
bookingIds: { required: true, type: [String] },
|
|
379
|
+
checkoutAttemptId: { required: true, type: String },
|
|
380
|
+
checkoutLeaseUntil: { type: Date },
|
|
381
|
+
checkoutLeaseToken: { type: String },
|
|
382
|
+
createdAt: { default: Date.now, required: true, type: Date },
|
|
383
|
+
expiresAt: { required: true, type: Date },
|
|
384
|
+
holdsReleased: { type: Boolean },
|
|
385
|
+
quote: { required: true, type: import_mongoose4.default.Schema.Types.Mixed },
|
|
386
|
+
resource: { required: true, type: schemaAdresource },
|
|
387
|
+
selectionKey: { required: true, type: String },
|
|
388
|
+
state: {
|
|
389
|
+
enum: ["reserving", "checkout", "paid", "failed", "cancelled"],
|
|
390
|
+
required: true,
|
|
391
|
+
type: String
|
|
392
|
+
},
|
|
393
|
+
stripeCheckoutSessionId: { default: null, type: String },
|
|
394
|
+
stripePaymentIntentId: { default: null, type: String },
|
|
395
|
+
stripeRequestStartedAt: { type: Date },
|
|
396
|
+
userId: { required: true, type: String }
|
|
397
|
+
},
|
|
398
|
+
{ collection: "adPurchases" }
|
|
399
|
+
);
|
|
400
|
+
schema4.index({ userId: 1, checkoutAttemptId: 1 }, { unique: true });
|
|
401
|
+
schema4.index(
|
|
402
|
+
{ stripeCheckoutSessionId: 1 },
|
|
403
|
+
{
|
|
404
|
+
unique: true,
|
|
405
|
+
partialFilterExpression: { stripeCheckoutSessionId: { $type: "string" } }
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
schema4.index({ state: 1, expiresAt: 1 });
|
|
409
|
+
var AdPurchaseModel = import_mongoose4.default.models.AdPurchase || import_mongoose4.default.model("AdPurchase", schema4);
|
|
410
|
+
|
|
372
411
|
// src/mongoose/ad/AdMetrics.ts
|
|
373
412
|
var import_cluemart_shared4 = require("@timardex/cluemart-shared");
|
|
374
|
-
var
|
|
375
|
-
var ResourceMetricsSchema = new
|
|
413
|
+
var import_mongoose5 = __toESM(require("mongoose"));
|
|
414
|
+
var ResourceMetricsSchema = new import_mongoose5.default.Schema(
|
|
376
415
|
{
|
|
377
416
|
clicks: { default: 0, required: true, type: Number },
|
|
378
417
|
date: {
|
|
@@ -400,15 +439,15 @@ var ResourceMetricsSchema = new import_mongoose4.default.Schema(
|
|
|
400
439
|
},
|
|
401
440
|
{ _id: false }
|
|
402
441
|
);
|
|
403
|
-
var
|
|
442
|
+
var schema5 = new import_mongoose5.default.Schema(
|
|
404
443
|
{
|
|
405
444
|
adId: { ref: "Ad", required: true, type: String },
|
|
406
445
|
resource: { default: [], type: [ResourceMetricsSchema] }
|
|
407
446
|
},
|
|
408
447
|
{ timestamps: true }
|
|
409
448
|
);
|
|
410
|
-
|
|
411
|
-
|
|
449
|
+
schema5.index({ adId: 1 }, { unique: true });
|
|
450
|
+
schema5.index(
|
|
412
451
|
{
|
|
413
452
|
adId: 1,
|
|
414
453
|
"resource.date": 1,
|
|
@@ -417,12 +456,12 @@ schema4.index(
|
|
|
417
456
|
},
|
|
418
457
|
{ unique: true }
|
|
419
458
|
);
|
|
420
|
-
var AdMetricsModel =
|
|
459
|
+
var AdMetricsModel = import_mongoose5.default.models.AdMetrics || import_mongoose5.default.model("AdMetrics", schema5);
|
|
421
460
|
|
|
422
461
|
// src/mongoose/BillingCatalog.ts
|
|
423
462
|
var import_cluemart_shared5 = require("@timardex/cluemart-shared");
|
|
424
|
-
var
|
|
425
|
-
var MongooseSchema2 =
|
|
463
|
+
var import_mongoose6 = __toESM(require("mongoose"));
|
|
464
|
+
var MongooseSchema2 = import_mongoose6.default.Schema;
|
|
426
465
|
var BILLING_CATALOG_COLLECTION_NAME = "billingCatalog";
|
|
427
466
|
var paidVendorLicences = [
|
|
428
467
|
import_cluemart_shared5.EnumUserLicence.PRO_VENDOR,
|
|
@@ -469,7 +508,7 @@ var priceHistorySchema = new MongooseSchema2(
|
|
|
469
508
|
default: null,
|
|
470
509
|
ref: "User",
|
|
471
510
|
required: false,
|
|
472
|
-
type:
|
|
511
|
+
type: import_mongoose6.default.Schema.Types.ObjectId
|
|
473
512
|
},
|
|
474
513
|
currency: currencyField,
|
|
475
514
|
effectiveFrom: { required: true, type: Date },
|
|
@@ -480,7 +519,7 @@ var priceHistorySchema = new MongooseSchema2(
|
|
|
480
519
|
},
|
|
481
520
|
{ _id: false }
|
|
482
521
|
);
|
|
483
|
-
var
|
|
522
|
+
var schema6 = new MongooseSchema2(
|
|
484
523
|
{
|
|
485
524
|
active: { default: true, required: true, type: Boolean },
|
|
486
525
|
billingPeriod: {
|
|
@@ -536,7 +575,7 @@ var schema5 = new MongooseSchema2(
|
|
|
536
575
|
default: null,
|
|
537
576
|
ref: "User",
|
|
538
577
|
required: false,
|
|
539
|
-
type:
|
|
578
|
+
type: import_mongoose6.default.Schema.Types.ObjectId
|
|
540
579
|
}
|
|
541
580
|
},
|
|
542
581
|
{
|
|
@@ -545,7 +584,7 @@ var schema5 = new MongooseSchema2(
|
|
|
545
584
|
timestamps: true
|
|
546
585
|
}
|
|
547
586
|
);
|
|
548
|
-
|
|
587
|
+
schema6.pre("validate", function validateDefinition() {
|
|
549
588
|
if (!(0, import_cluemart_shared5.billingCatalogDefinitionMatches)(this)) {
|
|
550
589
|
this.invalidate(
|
|
551
590
|
"key",
|
|
@@ -553,32 +592,32 @@ schema5.pre("validate", function validateDefinition() {
|
|
|
553
592
|
);
|
|
554
593
|
}
|
|
555
594
|
});
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
595
|
+
schema6.index({ billingPeriod: 1, licenceType: 1 }, { unique: true });
|
|
596
|
+
schema6.index({ active: 1, licenceType: 1 });
|
|
597
|
+
schema6.index(
|
|
559
598
|
{ stripePriceId: 1 },
|
|
560
599
|
{
|
|
561
600
|
partialFilterExpression: { stripePriceId: { $type: "string" } },
|
|
562
601
|
unique: true
|
|
563
602
|
}
|
|
564
603
|
);
|
|
565
|
-
var BillingCatalogModel =
|
|
604
|
+
var BillingCatalogModel = import_mongoose6.default.models.BillingCatalogEntry || import_mongoose6.default.model(
|
|
566
605
|
"BillingCatalogEntry",
|
|
567
|
-
|
|
606
|
+
schema6,
|
|
568
607
|
BILLING_CATALOG_COLLECTION_NAME
|
|
569
608
|
);
|
|
570
609
|
|
|
571
610
|
// src/mongoose/chat/Chat.ts
|
|
572
611
|
var import_cluemart_shared6 = require("@timardex/cluemart-shared");
|
|
573
|
-
var
|
|
574
|
-
var MongooseSchema3 =
|
|
612
|
+
var import_mongoose7 = __toESM(require("mongoose"));
|
|
613
|
+
var MongooseSchema3 = import_mongoose7.default.Schema;
|
|
575
614
|
var MessageReplyPreviewSchema = new MongooseSchema3(
|
|
576
615
|
{
|
|
577
616
|
contentPreview: { required: true, type: String },
|
|
578
617
|
senderId: {
|
|
579
618
|
ref: "User",
|
|
580
619
|
required: true,
|
|
581
|
-
type:
|
|
620
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
582
621
|
},
|
|
583
622
|
senderName: { required: true, type: String }
|
|
584
623
|
},
|
|
@@ -590,7 +629,7 @@ var MessageReactionSchema = new MongooseSchema3(
|
|
|
590
629
|
userId: {
|
|
591
630
|
ref: "User",
|
|
592
631
|
required: true,
|
|
593
|
-
type:
|
|
632
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
594
633
|
}
|
|
595
634
|
},
|
|
596
635
|
{ _id: false }
|
|
@@ -601,7 +640,7 @@ var MessageSeenSchema = new MongooseSchema3(
|
|
|
601
640
|
userId: {
|
|
602
641
|
ref: "User",
|
|
603
642
|
required: true,
|
|
604
|
-
type:
|
|
643
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
605
644
|
}
|
|
606
645
|
},
|
|
607
646
|
{ _id: false }
|
|
@@ -617,13 +656,13 @@ var MessageSchema = new MongooseSchema3(
|
|
|
617
656
|
replyToMessageId: {
|
|
618
657
|
ref: "Chat.messages",
|
|
619
658
|
required: false,
|
|
620
|
-
type:
|
|
659
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
621
660
|
},
|
|
622
661
|
seenBy: { default: [], required: false, type: [MessageSeenSchema] },
|
|
623
662
|
senderId: {
|
|
624
663
|
ref: "User",
|
|
625
664
|
required: true,
|
|
626
|
-
type:
|
|
665
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
627
666
|
}
|
|
628
667
|
},
|
|
629
668
|
{ timestamps: true }
|
|
@@ -636,7 +675,7 @@ var ParticipantSchema = new MongooseSchema3(
|
|
|
636
675
|
userId: {
|
|
637
676
|
ref: "User",
|
|
638
677
|
required: true,
|
|
639
|
-
type:
|
|
678
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
640
679
|
},
|
|
641
680
|
userName: { required: true, type: String }
|
|
642
681
|
},
|
|
@@ -667,12 +706,12 @@ ChatSchema.index({
|
|
|
667
706
|
"participants.userId": 1,
|
|
668
707
|
updatedAt: -1
|
|
669
708
|
});
|
|
670
|
-
var ChatModel =
|
|
709
|
+
var ChatModel = import_mongoose7.default.models.Chat || import_mongoose7.default.model("Chat", ChatSchema);
|
|
671
710
|
|
|
672
711
|
// src/mongoose/chat/ChatReport.ts
|
|
673
712
|
var import_cluemart_shared7 = require("@timardex/cluemart-shared");
|
|
674
|
-
var
|
|
675
|
-
var MongooseSchema4 =
|
|
713
|
+
var import_mongoose8 = __toESM(require("mongoose"));
|
|
714
|
+
var MongooseSchema4 = import_mongoose8.default.Schema;
|
|
676
715
|
var ReasonSchema = new MongooseSchema4(
|
|
677
716
|
{
|
|
678
717
|
details: { default: null, required: false, type: String },
|
|
@@ -689,18 +728,18 @@ var ChatReportSchema = new MongooseSchema4(
|
|
|
689
728
|
chatId: {
|
|
690
729
|
ref: "Chat",
|
|
691
730
|
required: true,
|
|
692
|
-
type:
|
|
731
|
+
type: import_mongoose8.default.Schema.Types.ObjectId
|
|
693
732
|
},
|
|
694
733
|
reason: { required: true, type: ReasonSchema },
|
|
695
734
|
reportedUserId: {
|
|
696
735
|
ref: "User",
|
|
697
736
|
required: true,
|
|
698
|
-
type:
|
|
737
|
+
type: import_mongoose8.default.Schema.Types.ObjectId
|
|
699
738
|
},
|
|
700
739
|
reporterUserId: {
|
|
701
740
|
ref: "User",
|
|
702
741
|
required: true,
|
|
703
|
-
type:
|
|
742
|
+
type: import_mongoose8.default.Schema.Types.ObjectId
|
|
704
743
|
},
|
|
705
744
|
resolved: { default: false, required: true, type: Boolean }
|
|
706
745
|
},
|
|
@@ -708,19 +747,19 @@ var ChatReportSchema = new MongooseSchema4(
|
|
|
708
747
|
);
|
|
709
748
|
ChatReportSchema.index({ chatId: 1, reportedUserId: 1 });
|
|
710
749
|
ChatReportSchema.index({ createdAt: -1, reporterUserId: 1 });
|
|
711
|
-
var ChatReportModel =
|
|
750
|
+
var ChatReportModel = import_mongoose8.default.models.ChatReport || import_mongoose8.default.model("ChatReport", ChatReportSchema);
|
|
712
751
|
|
|
713
752
|
// src/mongoose/global.ts
|
|
714
753
|
var import_cluemart_shared8 = require("@timardex/cluemart-shared");
|
|
715
|
-
var
|
|
716
|
-
var MongooseSchema5 =
|
|
754
|
+
var import_mongoose9 = __toESM(require("mongoose"));
|
|
755
|
+
var MongooseSchema5 = import_mongoose9.default.Schema;
|
|
717
756
|
var OwnerTypeSchema = new MongooseSchema5(
|
|
718
757
|
{
|
|
719
758
|
email: { required: true, type: String },
|
|
720
759
|
userId: {
|
|
721
760
|
ref: "User",
|
|
722
761
|
required: true,
|
|
723
|
-
type:
|
|
762
|
+
type: import_mongoose9.default.Schema.Types.ObjectId
|
|
724
763
|
}
|
|
725
764
|
},
|
|
726
765
|
{ _id: false }
|
|
@@ -863,7 +902,7 @@ var relatedPostSchema = new MongooseSchema5(
|
|
|
863
902
|
postId: {
|
|
864
903
|
ref: "Post",
|
|
865
904
|
required: true,
|
|
866
|
-
type:
|
|
905
|
+
type: import_mongoose9.default.Schema.Types.ObjectId
|
|
867
906
|
},
|
|
868
907
|
postSlug: { required: true, type: String },
|
|
869
908
|
postType: {
|
|
@@ -888,7 +927,7 @@ var baseResourceFields = {
|
|
|
888
927
|
adIds: {
|
|
889
928
|
ref: "Ad",
|
|
890
929
|
required: false,
|
|
891
|
-
type: [
|
|
930
|
+
type: [import_mongoose9.default.Schema.Types.ObjectId]
|
|
892
931
|
},
|
|
893
932
|
approvedAt: { default: null, required: false, type: Date },
|
|
894
933
|
contactDetails: { required: false, type: ContactDetailsSchema },
|
|
@@ -919,7 +958,7 @@ var baseResourceFields = {
|
|
|
919
958
|
|
|
920
959
|
// src/mongoose/GoogleImportedMarket.ts
|
|
921
960
|
var import_cluemart_shared9 = require("@timardex/cluemart-shared");
|
|
922
|
-
var
|
|
961
|
+
var import_mongoose10 = __toESM(require("mongoose"));
|
|
923
962
|
|
|
924
963
|
// src/mongoose/searchNamePlugin.ts
|
|
925
964
|
function deriveSearchName(name) {
|
|
@@ -965,15 +1004,15 @@ function syncSearchNameInUpdate(update) {
|
|
|
965
1004
|
}
|
|
966
1005
|
return null;
|
|
967
1006
|
}
|
|
968
|
-
function searchNamePlugin(
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1007
|
+
function searchNamePlugin(schema28) {
|
|
1008
|
+
schema28.add({ searchName: { default: "", required: false, type: String } });
|
|
1009
|
+
schema28.index({ searchName: 1 });
|
|
1010
|
+
schema28.pre("save", function syncSearchNameOnSave(next) {
|
|
972
1011
|
const doc = this;
|
|
973
1012
|
doc.searchName = deriveSearchName(doc.name);
|
|
974
1013
|
next();
|
|
975
1014
|
});
|
|
976
|
-
|
|
1015
|
+
schema28.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
|
|
977
1016
|
const list = Array.isArray(docs) ? docs : [docs];
|
|
978
1017
|
for (const doc of list) {
|
|
979
1018
|
if (doc && typeof doc.name === "string") {
|
|
@@ -982,7 +1021,7 @@ function searchNamePlugin(schema25) {
|
|
|
982
1021
|
}
|
|
983
1022
|
next();
|
|
984
1023
|
});
|
|
985
|
-
|
|
1024
|
+
schema28.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
|
|
986
1025
|
for (const op of ops) {
|
|
987
1026
|
const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
|
|
988
1027
|
if (doc && typeof doc.name === "string") {
|
|
@@ -1008,14 +1047,14 @@ function searchNamePlugin(schema25) {
|
|
|
1008
1047
|
}
|
|
1009
1048
|
next();
|
|
1010
1049
|
};
|
|
1011
|
-
|
|
1050
|
+
schema28.pre(
|
|
1012
1051
|
["findOneAndUpdate", "updateOne", "updateMany"],
|
|
1013
1052
|
syncSearchNameOnUpdate
|
|
1014
1053
|
);
|
|
1015
1054
|
}
|
|
1016
1055
|
|
|
1017
1056
|
// src/mongoose/GoogleImportedMarket.ts
|
|
1018
|
-
var MongooseSchema6 =
|
|
1057
|
+
var MongooseSchema6 = import_mongoose10.default.Schema;
|
|
1019
1058
|
var addressComponentSchema = new MongooseSchema6(
|
|
1020
1059
|
{
|
|
1021
1060
|
longName: { required: false, type: String },
|
|
@@ -1024,7 +1063,7 @@ var addressComponentSchema = new MongooseSchema6(
|
|
|
1024
1063
|
},
|
|
1025
1064
|
{ _id: false }
|
|
1026
1065
|
);
|
|
1027
|
-
var
|
|
1066
|
+
var schema7 = new MongooseSchema6(
|
|
1028
1067
|
{
|
|
1029
1068
|
active: { default: false, required: true, type: Boolean },
|
|
1030
1069
|
address: { required: true, type: String },
|
|
@@ -1036,7 +1075,7 @@ var schema6 = new MongooseSchema6(
|
|
|
1036
1075
|
claimedByUserId: {
|
|
1037
1076
|
ref: "User",
|
|
1038
1077
|
required: false,
|
|
1039
|
-
type:
|
|
1078
|
+
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
1040
1079
|
},
|
|
1041
1080
|
cover: {
|
|
1042
1081
|
required: false,
|
|
@@ -1048,7 +1087,7 @@ var schema6 = new MongooseSchema6(
|
|
|
1048
1087
|
eventId: {
|
|
1049
1088
|
ref: "Event",
|
|
1050
1089
|
required: false,
|
|
1051
|
-
type:
|
|
1090
|
+
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
1052
1091
|
},
|
|
1053
1092
|
eventType: {
|
|
1054
1093
|
enum: Object.values(import_cluemart_shared9.EnumEventType),
|
|
@@ -1082,33 +1121,144 @@ var schema6 = new MongooseSchema6(
|
|
|
1082
1121
|
},
|
|
1083
1122
|
{ timestamps: true }
|
|
1084
1123
|
);
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
var GoogleImportedMarketModel =
|
|
1124
|
+
schema7.index({ "location.geo": "2dsphere" });
|
|
1125
|
+
schema7.index({ name: 1 });
|
|
1126
|
+
schema7.index({ region: 1 });
|
|
1127
|
+
schema7.index({ deletedAt: 1 });
|
|
1128
|
+
schema7.index({ "dateTime.dateStatus": 1 });
|
|
1129
|
+
schema7.index({ slug: 1 });
|
|
1130
|
+
schema7.index({ description: "text", name: "text" });
|
|
1131
|
+
schema7.plugin(searchNamePlugin);
|
|
1132
|
+
var GoogleImportedMarketModel = import_mongoose10.default.models.GoogleImportedMarket || import_mongoose10.default.model("GoogleImportedMarket", schema7);
|
|
1094
1133
|
|
|
1095
|
-
// src/mongoose/
|
|
1134
|
+
// src/mongoose/AiImportedMarket.ts
|
|
1096
1135
|
var import_cluemart_shared10 = require("@timardex/cluemart-shared");
|
|
1097
|
-
var
|
|
1098
|
-
var MongooseSchema7 =
|
|
1099
|
-
var
|
|
1136
|
+
var import_mongoose11 = __toESM(require("mongoose"));
|
|
1137
|
+
var MongooseSchema7 = import_mongoose11.default.Schema;
|
|
1138
|
+
var addressComponentSchema2 = new MongooseSchema7(
|
|
1139
|
+
{
|
|
1140
|
+
longName: { required: false, type: String },
|
|
1141
|
+
shortName: { required: false, type: String },
|
|
1142
|
+
types: { required: false, type: [String] }
|
|
1143
|
+
},
|
|
1144
|
+
{ _id: false }
|
|
1145
|
+
);
|
|
1146
|
+
var schema8 = new MongooseSchema7(
|
|
1147
|
+
{
|
|
1148
|
+
active: { default: false, required: true, type: Boolean },
|
|
1149
|
+
address: { required: true, type: String },
|
|
1150
|
+
addressComponents: { required: false, type: [addressComponentSchema2] },
|
|
1151
|
+
approvedAt: { default: null, required: false, type: Date },
|
|
1152
|
+
claimed: { default: false, required: true, type: Boolean },
|
|
1153
|
+
claimedAt: { default: null, required: false, type: Date },
|
|
1154
|
+
claimedByUserId: {
|
|
1155
|
+
ref: "User",
|
|
1156
|
+
required: false,
|
|
1157
|
+
type: import_mongoose11.default.Schema.Types.ObjectId
|
|
1158
|
+
},
|
|
1159
|
+
cover: {
|
|
1160
|
+
required: false,
|
|
1161
|
+
type: ResourceImageTypeSchema
|
|
1162
|
+
},
|
|
1163
|
+
dateTime: [dateTimeSchema],
|
|
1164
|
+
deletedAt: { default: null, required: false, type: Date },
|
|
1165
|
+
description: { required: true, type: String },
|
|
1166
|
+
eventId: {
|
|
1167
|
+
ref: "Event",
|
|
1168
|
+
required: false,
|
|
1169
|
+
type: import_mongoose11.default.Schema.Types.ObjectId
|
|
1170
|
+
},
|
|
1171
|
+
eventType: {
|
|
1172
|
+
enum: Object.values(import_cluemart_shared10.EnumEventType),
|
|
1173
|
+
required: true,
|
|
1174
|
+
type: String
|
|
1175
|
+
},
|
|
1176
|
+
images: { required: false, type: [ResourceImageTypeSchema] },
|
|
1177
|
+
location: {
|
|
1178
|
+
required: true,
|
|
1179
|
+
type: locationsSchema
|
|
1180
|
+
},
|
|
1181
|
+
logo: { required: false, type: ResourceImageTypeSchema },
|
|
1182
|
+
name: { required: true, type: String },
|
|
1183
|
+
openingHours: { required: false, type: [String] },
|
|
1184
|
+
rainOrShine: { required: true, type: Boolean },
|
|
1185
|
+
rating: { required: false, type: Number },
|
|
1186
|
+
region: { required: false, type: String },
|
|
1187
|
+
rejectReason: { required: false, type: String },
|
|
1188
|
+
reviewCount: { required: false, type: Number },
|
|
1189
|
+
reviewedAt: { default: null, required: false, type: Date },
|
|
1190
|
+
reviewedByUserId: {
|
|
1191
|
+
ref: "User",
|
|
1192
|
+
required: false,
|
|
1193
|
+
type: import_mongoose11.default.Schema.Types.ObjectId
|
|
1194
|
+
},
|
|
1195
|
+
reviewStatus: {
|
|
1196
|
+
default: import_cluemart_shared10.EnumImportedMarketReviewStatus.PENDING,
|
|
1197
|
+
enum: Object.values(import_cluemart_shared10.EnumImportedMarketReviewStatus),
|
|
1198
|
+
required: true,
|
|
1199
|
+
type: String
|
|
1200
|
+
},
|
|
1201
|
+
scrapedAt: { default: () => /* @__PURE__ */ new Date(), required: true, type: Date },
|
|
1202
|
+
slug: { required: true, type: String },
|
|
1203
|
+
sourceKey: {
|
|
1204
|
+
required: true,
|
|
1205
|
+
type: String,
|
|
1206
|
+
unique: true
|
|
1207
|
+
// unique, indexed
|
|
1208
|
+
},
|
|
1209
|
+
sourceName: { required: true, type: String },
|
|
1210
|
+
sourceUrl: { required: true, type: String },
|
|
1211
|
+
website: { required: false, type: String }
|
|
1212
|
+
},
|
|
1213
|
+
{ timestamps: true }
|
|
1214
|
+
);
|
|
1215
|
+
schema8.index({ "location.geo": "2dsphere" });
|
|
1216
|
+
schema8.index({ name: 1 });
|
|
1217
|
+
schema8.index({ region: 1 });
|
|
1218
|
+
schema8.index({ deletedAt: 1 });
|
|
1219
|
+
schema8.index({ "dateTime.dateStatus": 1 });
|
|
1220
|
+
schema8.index({ slug: 1 });
|
|
1221
|
+
schema8.index({ reviewStatus: 1 });
|
|
1222
|
+
schema8.index({ description: "text", name: "text" });
|
|
1223
|
+
schema8.plugin(searchNamePlugin);
|
|
1224
|
+
var AiImportedMarketModel = import_mongoose11.default.models.AiImportedMarket || import_mongoose11.default.model("AiImportedMarket", schema8);
|
|
1225
|
+
|
|
1226
|
+
// src/mongoose/ScrapeSite.ts
|
|
1227
|
+
var import_mongoose12 = __toESM(require("mongoose"));
|
|
1228
|
+
var MongooseSchema8 = import_mongoose12.default.Schema;
|
|
1229
|
+
var schema9 = new MongooseSchema8(
|
|
1230
|
+
{
|
|
1231
|
+
enabled: { default: true, required: true, type: Boolean },
|
|
1232
|
+
lastError: { required: false, type: String },
|
|
1233
|
+
lastScrapedAt: { required: false, type: Date },
|
|
1234
|
+
lastScrapeStatus: { required: false, type: String },
|
|
1235
|
+
name: { required: true, type: String },
|
|
1236
|
+
regionHint: { required: false, type: String },
|
|
1237
|
+
url: { required: true, type: String }
|
|
1238
|
+
},
|
|
1239
|
+
{ timestamps: true }
|
|
1240
|
+
);
|
|
1241
|
+
schema9.index({ url: 1 }, { unique: true });
|
|
1242
|
+
schema9.index({ enabled: 1 });
|
|
1243
|
+
var ScrapeSiteModel = import_mongoose12.default.models.ScrapeSite || import_mongoose12.default.model("ScrapeSite", schema9);
|
|
1244
|
+
|
|
1245
|
+
// src/mongoose/Notification.ts
|
|
1246
|
+
var import_cluemart_shared11 = require("@timardex/cluemart-shared");
|
|
1247
|
+
var import_mongoose13 = __toESM(require("mongoose"));
|
|
1248
|
+
var MongooseSchema9 = import_mongoose13.default.Schema;
|
|
1249
|
+
var notificationDataSchema = new MongooseSchema9(
|
|
1100
1250
|
{
|
|
1101
1251
|
resourceId: { required: true, type: String },
|
|
1102
1252
|
resourceName: { required: true, type: String },
|
|
1103
1253
|
resourceType: {
|
|
1104
|
-
enum: Object.values(
|
|
1254
|
+
enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
|
|
1105
1255
|
required: true,
|
|
1106
1256
|
type: String
|
|
1107
1257
|
}
|
|
1108
1258
|
},
|
|
1109
1259
|
{ _id: false }
|
|
1110
1260
|
);
|
|
1111
|
-
var
|
|
1261
|
+
var schema10 = new MongooseSchema9(
|
|
1112
1262
|
{
|
|
1113
1263
|
data: {
|
|
1114
1264
|
default: null,
|
|
@@ -1119,28 +1269,28 @@ var schema7 = new MongooseSchema7(
|
|
|
1119
1269
|
message: { required: true, type: String },
|
|
1120
1270
|
title: { required: true, type: String },
|
|
1121
1271
|
type: {
|
|
1122
|
-
default:
|
|
1123
|
-
enum: Object.values(
|
|
1272
|
+
default: import_cluemart_shared11.EnumNotificationType.SYSTEM,
|
|
1273
|
+
enum: Object.values(import_cluemart_shared11.EnumNotificationType),
|
|
1124
1274
|
required: true,
|
|
1125
1275
|
type: String
|
|
1126
1276
|
},
|
|
1127
1277
|
userId: {
|
|
1128
1278
|
ref: "User",
|
|
1129
1279
|
required: true,
|
|
1130
|
-
type:
|
|
1280
|
+
type: import_mongoose13.default.Schema.Types.ObjectId
|
|
1131
1281
|
}
|
|
1132
1282
|
},
|
|
1133
1283
|
{ timestamps: true }
|
|
1134
1284
|
);
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
var NotificationModel =
|
|
1285
|
+
schema10.index({ isRead: 1, userId: 1 });
|
|
1286
|
+
schema10.index({ createdAt: -1, userId: 1 });
|
|
1287
|
+
var NotificationModel = import_mongoose13.default.models.Notification || import_mongoose13.default.model("Notification", schema10);
|
|
1138
1288
|
|
|
1139
1289
|
// src/mongoose/PushToken.ts
|
|
1140
1290
|
var import_enums = require("@timardex/cluemart-shared/enums");
|
|
1141
|
-
var
|
|
1142
|
-
var
|
|
1143
|
-
var
|
|
1291
|
+
var import_mongoose14 = __toESM(require("mongoose"));
|
|
1292
|
+
var MongooseSchema10 = import_mongoose14.default.Schema;
|
|
1293
|
+
var schema11 = new MongooseSchema10(
|
|
1144
1294
|
{
|
|
1145
1295
|
platform: {
|
|
1146
1296
|
enum: Object.values(import_enums.EnumOSPlatform),
|
|
@@ -1151,22 +1301,22 @@ var schema8 = new MongooseSchema8(
|
|
|
1151
1301
|
userId: {
|
|
1152
1302
|
ref: "User",
|
|
1153
1303
|
required: true,
|
|
1154
|
-
type:
|
|
1304
|
+
type: import_mongoose14.default.Schema.Types.ObjectId
|
|
1155
1305
|
}
|
|
1156
1306
|
},
|
|
1157
1307
|
{ timestamps: true }
|
|
1158
1308
|
);
|
|
1159
|
-
var PushTokenModel =
|
|
1309
|
+
var PushTokenModel = import_mongoose14.default.models.PushToken || import_mongoose14.default.model("PushToken", schema11);
|
|
1160
1310
|
|
|
1161
1311
|
// src/mongoose/Relation.ts
|
|
1162
|
-
var
|
|
1163
|
-
var
|
|
1312
|
+
var import_cluemart_shared13 = require("@timardex/cluemart-shared");
|
|
1313
|
+
var import_mongoose16 = __toESM(require("mongoose"));
|
|
1164
1314
|
|
|
1165
1315
|
// src/mongoose/event/EventInfo.ts
|
|
1166
|
-
var
|
|
1167
|
-
var
|
|
1168
|
-
var
|
|
1169
|
-
var StallTypeSchema = new
|
|
1316
|
+
var import_cluemart_shared12 = require("@timardex/cluemart-shared");
|
|
1317
|
+
var import_mongoose15 = __toESM(require("mongoose"));
|
|
1318
|
+
var MongooseSchema11 = import_mongoose15.default.Schema;
|
|
1319
|
+
var StallTypeSchema = new MongooseSchema11(
|
|
1170
1320
|
{
|
|
1171
1321
|
label: { required: false, type: String },
|
|
1172
1322
|
price: { required: false, type: Number },
|
|
@@ -1177,10 +1327,10 @@ var StallTypeSchema = new MongooseSchema9(
|
|
|
1177
1327
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1178
1328
|
}
|
|
1179
1329
|
);
|
|
1180
|
-
var dateTimeSchema2 = new
|
|
1330
|
+
var dateTimeSchema2 = new MongooseSchema11(
|
|
1181
1331
|
{
|
|
1182
1332
|
dateStatus: {
|
|
1183
|
-
enum: Object.values(
|
|
1333
|
+
enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
|
|
1184
1334
|
required: false,
|
|
1185
1335
|
type: String
|
|
1186
1336
|
},
|
|
@@ -1193,13 +1343,13 @@ var dateTimeSchema2 = new MongooseSchema9(
|
|
|
1193
1343
|
{ _id: false }
|
|
1194
1344
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1195
1345
|
);
|
|
1196
|
-
var paymentInfoSchema = new
|
|
1346
|
+
var paymentInfoSchema = new MongooseSchema11(
|
|
1197
1347
|
{
|
|
1198
1348
|
accountHolderName: { required: false, type: String },
|
|
1199
1349
|
accountNumber: { required: false, type: String },
|
|
1200
1350
|
link: { required: false, type: String },
|
|
1201
1351
|
paymentMethod: {
|
|
1202
|
-
enum: Object.values(
|
|
1352
|
+
enum: Object.values(import_cluemart_shared12.EnumPaymentMethod),
|
|
1203
1353
|
required: true,
|
|
1204
1354
|
type: String
|
|
1205
1355
|
}
|
|
@@ -1207,7 +1357,7 @@ var paymentInfoSchema = new MongooseSchema9(
|
|
|
1207
1357
|
{ _id: false }
|
|
1208
1358
|
// Prevents Mongoose from creating an additional _id field
|
|
1209
1359
|
);
|
|
1210
|
-
var requirementsSchema = new
|
|
1360
|
+
var requirementsSchema = new MongooseSchema11(
|
|
1211
1361
|
{
|
|
1212
1362
|
category: { required: true, type: String },
|
|
1213
1363
|
label: { required: true, type: String },
|
|
@@ -1218,7 +1368,7 @@ var requirementsSchema = new MongooseSchema9(
|
|
|
1218
1368
|
// Prevents Mongoose from creating an additional _id field for
|
|
1219
1369
|
}
|
|
1220
1370
|
);
|
|
1221
|
-
var refundPolicySchema = new
|
|
1371
|
+
var refundPolicySchema = new MongooseSchema11(
|
|
1222
1372
|
{
|
|
1223
1373
|
category: { required: true, type: String },
|
|
1224
1374
|
label: { required: true, type: String },
|
|
@@ -1226,7 +1376,7 @@ var refundPolicySchema = new MongooseSchema9(
|
|
|
1226
1376
|
},
|
|
1227
1377
|
{ _id: false }
|
|
1228
1378
|
);
|
|
1229
|
-
var
|
|
1379
|
+
var schema12 = new MongooseSchema11(
|
|
1230
1380
|
{
|
|
1231
1381
|
active: { default: true, type: Boolean },
|
|
1232
1382
|
applicationDeadlineHours: { required: true, type: Number },
|
|
@@ -1234,7 +1384,7 @@ var schema9 = new MongooseSchema9(
|
|
|
1234
1384
|
eventId: {
|
|
1235
1385
|
ref: "Event",
|
|
1236
1386
|
required: true,
|
|
1237
|
-
type:
|
|
1387
|
+
type: import_mongoose15.default.Schema.Types.ObjectId
|
|
1238
1388
|
},
|
|
1239
1389
|
packInTime: { required: true, type: Number },
|
|
1240
1390
|
paymentDueHours: { required: true, type: Number },
|
|
@@ -1244,15 +1394,15 @@ var schema9 = new MongooseSchema9(
|
|
|
1244
1394
|
},
|
|
1245
1395
|
{ timestamps: true }
|
|
1246
1396
|
);
|
|
1247
|
-
|
|
1248
|
-
var EventInfoModel =
|
|
1397
|
+
schema12.index({ eventId: 1 });
|
|
1398
|
+
var EventInfoModel = import_mongoose15.default.models.EventInfo || import_mongoose15.default.model("EventInfo", schema12);
|
|
1249
1399
|
|
|
1250
1400
|
// src/mongoose/Relation.ts
|
|
1251
|
-
var
|
|
1252
|
-
var relationDateTimeSchema = new
|
|
1401
|
+
var MongooseSchema12 = import_mongoose16.default.Schema;
|
|
1402
|
+
var relationDateTimeSchema = new MongooseSchema12(
|
|
1253
1403
|
{
|
|
1254
1404
|
dateStatus: {
|
|
1255
|
-
enum: Object.values(
|
|
1405
|
+
enum: Object.values(import_cluemart_shared13.EnumEventDateStatus),
|
|
1256
1406
|
required: true,
|
|
1257
1407
|
type: String
|
|
1258
1408
|
},
|
|
@@ -1264,7 +1414,7 @@ var relationDateTimeSchema = new MongooseSchema10(
|
|
|
1264
1414
|
},
|
|
1265
1415
|
{ _id: false }
|
|
1266
1416
|
);
|
|
1267
|
-
var relationDatesSchema = new
|
|
1417
|
+
var relationDatesSchema = new MongooseSchema12(
|
|
1268
1418
|
{
|
|
1269
1419
|
dateTime: {
|
|
1270
1420
|
required: true,
|
|
@@ -1276,42 +1426,42 @@ var relationDatesSchema = new MongooseSchema10(
|
|
|
1276
1426
|
},
|
|
1277
1427
|
paymentReference: { required: false, type: String },
|
|
1278
1428
|
status: {
|
|
1279
|
-
enum: Object.values(
|
|
1429
|
+
enum: Object.values(import_cluemart_shared13.EnumInviteStatus),
|
|
1280
1430
|
required: false,
|
|
1281
1431
|
type: String
|
|
1282
1432
|
}
|
|
1283
1433
|
},
|
|
1284
1434
|
{ _id: false }
|
|
1285
1435
|
);
|
|
1286
|
-
var RelationTypeSchema = new
|
|
1436
|
+
var RelationTypeSchema = new MongooseSchema12(
|
|
1287
1437
|
{
|
|
1288
1438
|
active: { default: true, required: true, type: Boolean },
|
|
1289
1439
|
chatId: {
|
|
1290
1440
|
ref: "Chat",
|
|
1291
1441
|
required: true,
|
|
1292
|
-
type:
|
|
1442
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1293
1443
|
},
|
|
1294
1444
|
deletedAt: { default: null, required: false, type: Date },
|
|
1295
1445
|
eventId: {
|
|
1296
1446
|
ref: "Event",
|
|
1297
1447
|
required: true,
|
|
1298
|
-
type:
|
|
1448
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1299
1449
|
},
|
|
1300
1450
|
lastUpdateBy: {
|
|
1301
|
-
enum: Object.values(
|
|
1451
|
+
enum: Object.values(import_cluemart_shared13.EnumResourceType),
|
|
1302
1452
|
required: true,
|
|
1303
1453
|
type: String
|
|
1304
1454
|
},
|
|
1305
1455
|
relationDates: [relationDatesSchema],
|
|
1306
1456
|
relationType: {
|
|
1307
|
-
enum: Object.values(
|
|
1457
|
+
enum: Object.values(import_cluemart_shared13.EnumRelationResource),
|
|
1308
1458
|
required: true,
|
|
1309
1459
|
type: String
|
|
1310
1460
|
},
|
|
1311
1461
|
vendorId: {
|
|
1312
1462
|
ref: "Vendor",
|
|
1313
1463
|
required: true,
|
|
1314
|
-
type:
|
|
1464
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1315
1465
|
}
|
|
1316
1466
|
},
|
|
1317
1467
|
{ timestamps: true }
|
|
@@ -1323,21 +1473,21 @@ RelationTypeSchema.index({
|
|
|
1323
1473
|
"relationDates.status": 1,
|
|
1324
1474
|
vendorId: 1
|
|
1325
1475
|
});
|
|
1326
|
-
var RelationModel =
|
|
1476
|
+
var RelationModel = import_mongoose16.default.models.Relation || import_mongoose16.default.model("Relation", RelationTypeSchema);
|
|
1327
1477
|
|
|
1328
1478
|
// src/mongoose/ResourceActivity.ts
|
|
1329
|
-
var
|
|
1330
|
-
var
|
|
1331
|
-
var
|
|
1332
|
-
var ActivitySchema = new
|
|
1479
|
+
var import_cluemart_shared14 = require("@timardex/cluemart-shared");
|
|
1480
|
+
var import_mongoose17 = __toESM(require("mongoose"));
|
|
1481
|
+
var MongooseSchema13 = import_mongoose17.default.Schema;
|
|
1482
|
+
var ActivitySchema = new MongooseSchema13(
|
|
1333
1483
|
{
|
|
1334
1484
|
activityType: {
|
|
1335
|
-
enum: Object.values(
|
|
1485
|
+
enum: Object.values(import_cluemart_shared14.EnumActivity),
|
|
1336
1486
|
required: true,
|
|
1337
1487
|
type: String
|
|
1338
1488
|
},
|
|
1339
1489
|
dateStatus: {
|
|
1340
|
-
enum: Object.values(
|
|
1490
|
+
enum: Object.values(import_cluemart_shared14.EnumEventDateStatus),
|
|
1341
1491
|
required: false,
|
|
1342
1492
|
type: String
|
|
1343
1493
|
},
|
|
@@ -1349,7 +1499,7 @@ var ActivitySchema = new MongooseSchema11(
|
|
|
1349
1499
|
startTime: { required: false, type: String },
|
|
1350
1500
|
timestamp: { default: Date.now, type: Date },
|
|
1351
1501
|
userAgent: {
|
|
1352
|
-
enum: Object.values(
|
|
1502
|
+
enum: Object.values(import_cluemart_shared14.EnumOSPlatform),
|
|
1353
1503
|
required: true,
|
|
1354
1504
|
type: String
|
|
1355
1505
|
},
|
|
@@ -1357,61 +1507,61 @@ var ActivitySchema = new MongooseSchema11(
|
|
|
1357
1507
|
},
|
|
1358
1508
|
{ _id: false }
|
|
1359
1509
|
);
|
|
1360
|
-
var
|
|
1510
|
+
var schema13 = new MongooseSchema13(
|
|
1361
1511
|
{
|
|
1362
1512
|
activity: { default: [], type: [ActivitySchema] },
|
|
1363
1513
|
resourceId: { required: true, type: String },
|
|
1364
1514
|
resourceType: {
|
|
1365
|
-
enum: Object.values(
|
|
1515
|
+
enum: Object.values(import_cluemart_shared14.EnumResourceType),
|
|
1366
1516
|
required: true,
|
|
1367
1517
|
type: String
|
|
1368
1518
|
}
|
|
1369
1519
|
},
|
|
1370
1520
|
{ timestamps: true }
|
|
1371
1521
|
);
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
var ResourceActivityModel =
|
|
1522
|
+
schema13.index({ resourceId: 1, resourceType: 1 }, { unique: true });
|
|
1523
|
+
schema13.index({ "views.location": "2dsphere" });
|
|
1524
|
+
var ResourceActivityModel = import_mongoose17.default.models.ResourceActivity || import_mongoose17.default.model("ResourceActivity", schema13);
|
|
1375
1525
|
|
|
1376
1526
|
// src/mongoose/User.ts
|
|
1377
|
-
var
|
|
1378
|
-
var
|
|
1379
|
-
var
|
|
1380
|
-
var userActivityEventSchema = new
|
|
1527
|
+
var import_cluemart_shared15 = require("@timardex/cluemart-shared");
|
|
1528
|
+
var import_mongoose18 = __toESM(require("mongoose"));
|
|
1529
|
+
var MongooseSchema14 = import_mongoose18.default.Schema;
|
|
1530
|
+
var userActivityEventSchema = new MongooseSchema14(
|
|
1381
1531
|
{
|
|
1382
1532
|
dateTime: dateTimeSchema,
|
|
1383
1533
|
resourceId: {
|
|
1384
1534
|
ref: "Event",
|
|
1385
1535
|
required: false,
|
|
1386
|
-
type:
|
|
1536
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1387
1537
|
}
|
|
1388
1538
|
},
|
|
1389
1539
|
{ _id: false }
|
|
1390
1540
|
);
|
|
1391
|
-
var userActivityFavouritesSchema = new
|
|
1541
|
+
var userActivityFavouritesSchema = new MongooseSchema14(
|
|
1392
1542
|
{
|
|
1393
1543
|
events: {
|
|
1394
1544
|
ref: "Event",
|
|
1395
1545
|
required: false,
|
|
1396
|
-
type: [
|
|
1546
|
+
type: [import_mongoose18.default.Schema.Types.ObjectId]
|
|
1397
1547
|
},
|
|
1398
1548
|
partners: {
|
|
1399
1549
|
ref: "Partner",
|
|
1400
1550
|
required: false,
|
|
1401
|
-
type: [
|
|
1551
|
+
type: [import_mongoose18.default.Schema.Types.ObjectId]
|
|
1402
1552
|
},
|
|
1403
1553
|
vendors: {
|
|
1404
1554
|
ref: "Vendor",
|
|
1405
1555
|
required: false,
|
|
1406
|
-
type: [
|
|
1556
|
+
type: [import_mongoose18.default.Schema.Types.ObjectId]
|
|
1407
1557
|
}
|
|
1408
1558
|
},
|
|
1409
1559
|
{ _id: false }
|
|
1410
1560
|
);
|
|
1411
|
-
var stripeSchema = new
|
|
1561
|
+
var stripeSchema = new MongooseSchema14(
|
|
1412
1562
|
{
|
|
1413
1563
|
billingPeriod: {
|
|
1414
|
-
enum: Object.values(
|
|
1564
|
+
enum: Object.values(import_cluemart_shared15.EnumBillingPeriod),
|
|
1415
1565
|
required: false,
|
|
1416
1566
|
type: String
|
|
1417
1567
|
},
|
|
@@ -1420,7 +1570,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1420
1570
|
type: Boolean
|
|
1421
1571
|
},
|
|
1422
1572
|
currentPlan: {
|
|
1423
|
-
enum: Object.values(
|
|
1573
|
+
enum: Object.values(import_cluemart_shared15.EnumUserLicence),
|
|
1424
1574
|
required: false,
|
|
1425
1575
|
type: String
|
|
1426
1576
|
},
|
|
@@ -1445,7 +1595,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1445
1595
|
type: String
|
|
1446
1596
|
},
|
|
1447
1597
|
pendingBillingPeriod: {
|
|
1448
|
-
enum: Object.values(
|
|
1598
|
+
enum: Object.values(import_cluemart_shared15.EnumBillingPeriod),
|
|
1449
1599
|
required: false,
|
|
1450
1600
|
type: String
|
|
1451
1601
|
},
|
|
@@ -1454,7 +1604,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1454
1604
|
type: Date
|
|
1455
1605
|
},
|
|
1456
1606
|
pendingPlan: {
|
|
1457
|
-
enum: Object.values(
|
|
1607
|
+
enum: Object.values(import_cluemart_shared15.EnumUserLicence),
|
|
1458
1608
|
required: false,
|
|
1459
1609
|
type: String
|
|
1460
1610
|
},
|
|
@@ -1471,7 +1621,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1471
1621
|
type: Date
|
|
1472
1622
|
},
|
|
1473
1623
|
status: {
|
|
1474
|
-
enum: Object.values(
|
|
1624
|
+
enum: Object.values(import_cluemart_shared15.EnumSubscriptionStatus),
|
|
1475
1625
|
required: false,
|
|
1476
1626
|
type: String
|
|
1477
1627
|
},
|
|
@@ -1490,10 +1640,10 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1490
1640
|
},
|
|
1491
1641
|
{ _id: false }
|
|
1492
1642
|
);
|
|
1493
|
-
var redeemedRewardSchema = new
|
|
1643
|
+
var redeemedRewardSchema = new MongooseSchema14(
|
|
1494
1644
|
{
|
|
1495
1645
|
name: {
|
|
1496
|
-
enum: Object.values(
|
|
1646
|
+
enum: Object.values(import_cluemart_shared15.EnumReward),
|
|
1497
1647
|
required: true,
|
|
1498
1648
|
type: String
|
|
1499
1649
|
},
|
|
@@ -1502,12 +1652,12 @@ var redeemedRewardSchema = new MongooseSchema12(
|
|
|
1502
1652
|
},
|
|
1503
1653
|
{ _id: false }
|
|
1504
1654
|
);
|
|
1505
|
-
var userOverallPointsSchema = new
|
|
1655
|
+
var userOverallPointsSchema = new MongooseSchema14(
|
|
1506
1656
|
{
|
|
1507
1657
|
createdAt: { required: true, type: Date },
|
|
1508
1658
|
points: { default: 0, required: true, type: Number },
|
|
1509
1659
|
pointType: {
|
|
1510
|
-
enum: Object.values(
|
|
1660
|
+
enum: Object.values(import_cluemart_shared15.EnumPointType),
|
|
1511
1661
|
required: true,
|
|
1512
1662
|
type: String
|
|
1513
1663
|
},
|
|
@@ -1515,13 +1665,13 @@ var userOverallPointsSchema = new MongooseSchema12(
|
|
|
1515
1665
|
},
|
|
1516
1666
|
{ _id: false }
|
|
1517
1667
|
);
|
|
1518
|
-
var
|
|
1668
|
+
var schema14 = new MongooseSchema14(
|
|
1519
1669
|
{
|
|
1520
1670
|
active: { default: false, required: true, type: Boolean },
|
|
1521
1671
|
affiliate: {
|
|
1522
1672
|
ref: "Affiliate",
|
|
1523
1673
|
required: false,
|
|
1524
|
-
type:
|
|
1674
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1525
1675
|
},
|
|
1526
1676
|
avatar: {
|
|
1527
1677
|
required: false,
|
|
@@ -1530,28 +1680,28 @@ var schema11 = new MongooseSchema12(
|
|
|
1530
1680
|
coupon: {
|
|
1531
1681
|
ref: "Coupon",
|
|
1532
1682
|
required: false,
|
|
1533
|
-
type:
|
|
1683
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1534
1684
|
},
|
|
1535
1685
|
deletedAt: { default: null, required: false, type: Date },
|
|
1536
1686
|
email: { required: true, type: String },
|
|
1537
1687
|
emailSentFor: {
|
|
1538
|
-
enum: Object.values(
|
|
1688
|
+
enum: Object.values(import_cluemart_shared15.EnumNotificationResourceType),
|
|
1539
1689
|
required: false,
|
|
1540
1690
|
type: [String]
|
|
1541
1691
|
},
|
|
1542
1692
|
events: {
|
|
1543
1693
|
ref: "Event",
|
|
1544
1694
|
required: false,
|
|
1545
|
-
type: [
|
|
1695
|
+
type: [import_mongoose18.default.Schema.Types.ObjectId]
|
|
1546
1696
|
},
|
|
1547
1697
|
firstName: { required: true, type: String },
|
|
1548
1698
|
game: {
|
|
1549
1699
|
ref: "Game",
|
|
1550
1700
|
required: false,
|
|
1551
|
-
type:
|
|
1701
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1552
1702
|
},
|
|
1553
1703
|
interests: {
|
|
1554
|
-
enum: Object.values(
|
|
1704
|
+
enum: Object.values(import_cluemart_shared15.EnumResourceType),
|
|
1555
1705
|
required: false,
|
|
1556
1706
|
type: [String]
|
|
1557
1707
|
},
|
|
@@ -1574,11 +1724,11 @@ var schema11 = new MongooseSchema12(
|
|
|
1574
1724
|
partner: {
|
|
1575
1725
|
ref: "Partner",
|
|
1576
1726
|
required: false,
|
|
1577
|
-
type:
|
|
1727
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1578
1728
|
},
|
|
1579
1729
|
password: { required: true, type: String },
|
|
1580
1730
|
platform: {
|
|
1581
|
-
enum: Object.values(
|
|
1731
|
+
enum: Object.values(import_cluemart_shared15.EnumOSPlatform),
|
|
1582
1732
|
required: false,
|
|
1583
1733
|
type: String
|
|
1584
1734
|
},
|
|
@@ -1607,15 +1757,15 @@ var schema11 = new MongooseSchema12(
|
|
|
1607
1757
|
type: String
|
|
1608
1758
|
},
|
|
1609
1759
|
roles: {
|
|
1610
|
-
default: [
|
|
1611
|
-
enum: Object.values(
|
|
1760
|
+
default: [import_cluemart_shared15.EnumUserRole.CUSTOMER],
|
|
1761
|
+
enum: Object.values(import_cluemart_shared15.EnumUserRole),
|
|
1612
1762
|
required: true,
|
|
1613
1763
|
type: [String]
|
|
1614
1764
|
},
|
|
1615
1765
|
school: {
|
|
1616
1766
|
ref: "School",
|
|
1617
1767
|
required: false,
|
|
1618
|
-
type:
|
|
1768
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1619
1769
|
},
|
|
1620
1770
|
stripe: {
|
|
1621
1771
|
required: false,
|
|
@@ -1640,21 +1790,21 @@ var schema11 = new MongooseSchema12(
|
|
|
1640
1790
|
vendor: {
|
|
1641
1791
|
ref: "Vendor",
|
|
1642
1792
|
required: false,
|
|
1643
|
-
type:
|
|
1793
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1644
1794
|
}
|
|
1645
1795
|
},
|
|
1646
1796
|
{ strict: false, timestamps: true }
|
|
1647
1797
|
);
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
var UserModel =
|
|
1798
|
+
schema14.index({ "licences.expiryDate": 1 });
|
|
1799
|
+
schema14.index({ "licences.licenceType": 1 });
|
|
1800
|
+
schema14.index({ promoCodes: 1, active: 1, deletedAt: 1 });
|
|
1801
|
+
schema14.index({ email: "text", firstName: "text", lastName: "text" });
|
|
1802
|
+
var UserModel = import_mongoose18.default.models.User || import_mongoose18.default.model("User", schema14);
|
|
1653
1803
|
|
|
1654
1804
|
// src/mongoose/VerificationToken.ts
|
|
1655
|
-
var
|
|
1656
|
-
var
|
|
1657
|
-
var
|
|
1805
|
+
var import_mongoose19 = __toESM(require("mongoose"));
|
|
1806
|
+
var MongooseSchema15 = import_mongoose19.default.Schema;
|
|
1807
|
+
var schema15 = new MongooseSchema15(
|
|
1658
1808
|
{
|
|
1659
1809
|
createdAt: {
|
|
1660
1810
|
default: Date.now,
|
|
@@ -1669,13 +1819,13 @@ var schema12 = new MongooseSchema13(
|
|
|
1669
1819
|
},
|
|
1670
1820
|
{ timestamps: true }
|
|
1671
1821
|
);
|
|
1672
|
-
var VerificationTokenModel =
|
|
1822
|
+
var VerificationTokenModel = import_mongoose19.default.models.VerificationToken || import_mongoose19.default.model("VerificationToken", schema15);
|
|
1673
1823
|
|
|
1674
1824
|
// src/mongoose/vendor/Vendor.ts
|
|
1675
|
-
var
|
|
1676
|
-
var
|
|
1677
|
-
var
|
|
1678
|
-
var vendorProductTypeSchema = new
|
|
1825
|
+
var import_cluemart_shared16 = require("@timardex/cluemart-shared");
|
|
1826
|
+
var import_mongoose20 = __toESM(require("mongoose"));
|
|
1827
|
+
var MongooseSchema16 = import_mongoose20.default.Schema;
|
|
1828
|
+
var vendorProductTypeSchema = new MongooseSchema16(
|
|
1679
1829
|
{
|
|
1680
1830
|
description: { required: false, type: String },
|
|
1681
1831
|
name: { required: true, type: String },
|
|
@@ -1686,18 +1836,18 @@ var vendorProductTypeSchema = new MongooseSchema14(
|
|
|
1686
1836
|
},
|
|
1687
1837
|
{ timestamps: true }
|
|
1688
1838
|
);
|
|
1689
|
-
var productWrapperSchema = new
|
|
1839
|
+
var productWrapperSchema = new MongooseSchema16(
|
|
1690
1840
|
{
|
|
1691
1841
|
active: { default: false, required: false, type: Boolean },
|
|
1692
1842
|
productsList: { required: false, type: [vendorProductTypeSchema] }
|
|
1693
1843
|
},
|
|
1694
1844
|
{ _id: false }
|
|
1695
1845
|
);
|
|
1696
|
-
var calendarSchema = new
|
|
1846
|
+
var calendarSchema = new MongooseSchema16(
|
|
1697
1847
|
{
|
|
1698
1848
|
dateTime: {
|
|
1699
1849
|
dateStatus: {
|
|
1700
|
-
enum: Object.values(
|
|
1850
|
+
enum: Object.values(import_cluemart_shared16.EnumEventDateStatus),
|
|
1701
1851
|
required: false,
|
|
1702
1852
|
type: String
|
|
1703
1853
|
},
|
|
@@ -1714,14 +1864,14 @@ var calendarSchema = new MongooseSchema14(
|
|
|
1714
1864
|
},
|
|
1715
1865
|
{ _id: false }
|
|
1716
1866
|
);
|
|
1717
|
-
var calendarWrapperSchema = new
|
|
1867
|
+
var calendarWrapperSchema = new MongooseSchema16(
|
|
1718
1868
|
{
|
|
1719
1869
|
active: { default: false, required: true, type: Boolean },
|
|
1720
1870
|
calendarData: { required: false, type: [calendarSchema] }
|
|
1721
1871
|
},
|
|
1722
1872
|
{ _id: false }
|
|
1723
1873
|
);
|
|
1724
|
-
var vendorAvailabilitySchema = new
|
|
1874
|
+
var vendorAvailabilitySchema = new MongooseSchema16(
|
|
1725
1875
|
{
|
|
1726
1876
|
corporate: { default: false, required: false, type: Boolean },
|
|
1727
1877
|
private: { default: false, required: false, type: Boolean },
|
|
@@ -1729,7 +1879,7 @@ var vendorAvailabilitySchema = new MongooseSchema14(
|
|
|
1729
1879
|
},
|
|
1730
1880
|
{ _id: false }
|
|
1731
1881
|
);
|
|
1732
|
-
var downgradeSnapshotSchema = new
|
|
1882
|
+
var downgradeSnapshotSchema = new MongooseSchema16(
|
|
1733
1883
|
{
|
|
1734
1884
|
availability: { required: false, type: vendorAvailabilitySchema },
|
|
1735
1885
|
calendarActive: { required: false, type: Boolean },
|
|
@@ -1737,7 +1887,7 @@ var downgradeSnapshotSchema = new MongooseSchema14(
|
|
|
1737
1887
|
},
|
|
1738
1888
|
{ _id: false }
|
|
1739
1889
|
);
|
|
1740
|
-
var
|
|
1890
|
+
var schema16 = new MongooseSchema16(
|
|
1741
1891
|
{
|
|
1742
1892
|
...baseResourceFields,
|
|
1743
1893
|
// Importing base resource fields from global.ts
|
|
@@ -1756,47 +1906,47 @@ var schema13 = new MongooseSchema14(
|
|
|
1756
1906
|
unregisteredVendorId: {
|
|
1757
1907
|
ref: "UnregisteredVendor",
|
|
1758
1908
|
required: false,
|
|
1759
|
-
type:
|
|
1909
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1760
1910
|
},
|
|
1761
1911
|
vendorInfoId: {
|
|
1762
1912
|
ref: "VendorInfo",
|
|
1763
1913
|
required: false,
|
|
1764
|
-
type:
|
|
1914
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1765
1915
|
},
|
|
1766
1916
|
vendorType: {
|
|
1767
|
-
enum: Object.values(
|
|
1917
|
+
enum: Object.values(import_cluemart_shared16.EnumVendorType),
|
|
1768
1918
|
required: true,
|
|
1769
1919
|
type: String
|
|
1770
1920
|
}
|
|
1771
1921
|
},
|
|
1772
1922
|
{ timestamps: true }
|
|
1773
1923
|
);
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1924
|
+
schema16.index({ name: 1 });
|
|
1925
|
+
schema16.index({ description: 1 });
|
|
1926
|
+
schema16.index({ region: 1 });
|
|
1927
|
+
schema16.index({ "categories.name": 1 });
|
|
1928
|
+
schema16.index({ slug: 1 });
|
|
1929
|
+
schema16.index({
|
|
1780
1930
|
categoriesNames: "text",
|
|
1781
1931
|
description: "text",
|
|
1782
1932
|
name: "text"
|
|
1783
1933
|
});
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
var VendorModel =
|
|
1934
|
+
schema16.index({ deletedAt: 1, "owner.userId": 1 });
|
|
1935
|
+
schema16.plugin(searchNamePlugin);
|
|
1936
|
+
var VendorModel = import_mongoose20.default.models.Vendor || import_mongoose20.default.model("Vendor", schema16);
|
|
1787
1937
|
|
|
1788
1938
|
// src/mongoose/vendor/VendorInfo.ts
|
|
1789
|
-
var
|
|
1790
|
-
var
|
|
1791
|
-
var
|
|
1792
|
-
var AttributesSchema = new
|
|
1939
|
+
var import_cluemart_shared17 = require("@timardex/cluemart-shared");
|
|
1940
|
+
var import_mongoose21 = __toESM(require("mongoose"));
|
|
1941
|
+
var MongooseSchema17 = import_mongoose21.default.Schema;
|
|
1942
|
+
var AttributesSchema = new MongooseSchema17(
|
|
1793
1943
|
{
|
|
1794
1944
|
details: { required: false, type: String },
|
|
1795
1945
|
isRequired: { default: false, required: true, type: Boolean }
|
|
1796
1946
|
},
|
|
1797
1947
|
{ _id: false }
|
|
1798
1948
|
);
|
|
1799
|
-
var
|
|
1949
|
+
var schema17 = new MongooseSchema17(
|
|
1800
1950
|
{
|
|
1801
1951
|
active: { default: true, type: Boolean },
|
|
1802
1952
|
compliance: {
|
|
@@ -1806,7 +1956,7 @@ var schema14 = new MongooseSchema15(
|
|
|
1806
1956
|
documents: [ResourceImageTypeSchema],
|
|
1807
1957
|
product: {
|
|
1808
1958
|
foodFlavors: {
|
|
1809
|
-
enum: Object.values(
|
|
1959
|
+
enum: Object.values(import_cluemart_shared17.EnumFoodFlavor),
|
|
1810
1960
|
required: true,
|
|
1811
1961
|
type: [String]
|
|
1812
1962
|
},
|
|
@@ -1831,29 +1981,29 @@ var schema14 = new MongooseSchema15(
|
|
|
1831
1981
|
vendorId: {
|
|
1832
1982
|
ref: "Vendor",
|
|
1833
1983
|
required: true,
|
|
1834
|
-
type:
|
|
1984
|
+
type: import_mongoose21.default.Schema.Types.ObjectId
|
|
1835
1985
|
}
|
|
1836
1986
|
},
|
|
1837
1987
|
{ timestamps: true }
|
|
1838
1988
|
);
|
|
1839
|
-
|
|
1840
|
-
var VendorInfoModel =
|
|
1989
|
+
schema17.index({ vendorId: 1 });
|
|
1990
|
+
var VendorInfoModel = import_mongoose21.default.models.VendorInfo || import_mongoose21.default.model("VendorInfo", schema17);
|
|
1841
1991
|
|
|
1842
1992
|
// src/mongoose/vendor/UnregisteredVendor.ts
|
|
1843
|
-
var
|
|
1844
|
-
var
|
|
1845
|
-
var invitationSchema = new
|
|
1993
|
+
var import_mongoose22 = __toESM(require("mongoose"));
|
|
1994
|
+
var MongooseSchema18 = import_mongoose22.default.Schema;
|
|
1995
|
+
var invitationSchema = new MongooseSchema18(
|
|
1846
1996
|
{
|
|
1847
1997
|
dateTime: { required: true, type: [dateTimeSchema] },
|
|
1848
1998
|
inviterId: {
|
|
1849
1999
|
ref: "Event",
|
|
1850
2000
|
required: true,
|
|
1851
|
-
type:
|
|
2001
|
+
type: import_mongoose22.default.Schema.Types.ObjectId
|
|
1852
2002
|
}
|
|
1853
2003
|
},
|
|
1854
2004
|
{ _id: false }
|
|
1855
2005
|
);
|
|
1856
|
-
var
|
|
2006
|
+
var schema18 = new MongooseSchema18(
|
|
1857
2007
|
{
|
|
1858
2008
|
active: { default: true, required: true, type: Boolean },
|
|
1859
2009
|
categoryIds: { required: true, type: [String] },
|
|
@@ -1862,7 +2012,7 @@ var schema15 = new MongooseSchema16(
|
|
|
1862
2012
|
claimedByUserId: {
|
|
1863
2013
|
ref: "User",
|
|
1864
2014
|
required: false,
|
|
1865
|
-
type:
|
|
2015
|
+
type: import_mongoose22.default.Schema.Types.ObjectId
|
|
1866
2016
|
},
|
|
1867
2017
|
claimInitiatedAt: { default: null, required: false, type: Date },
|
|
1868
2018
|
claimToken: { default: null, required: false, type: String },
|
|
@@ -1875,15 +2025,15 @@ var schema15 = new MongooseSchema16(
|
|
|
1875
2025
|
},
|
|
1876
2026
|
{ timestamps: true }
|
|
1877
2027
|
);
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
var UnregisteredVendorModel =
|
|
2028
|
+
schema18.index({ name: 1 });
|
|
2029
|
+
schema18.index({ email: 1 });
|
|
2030
|
+
var UnregisteredVendorModel = import_mongoose22.default.models.UnregisteredVendor || import_mongoose22.default.model("UnregisteredVendor", schema18);
|
|
1881
2031
|
|
|
1882
2032
|
// src/mongoose/event/Event.ts
|
|
1883
|
-
var
|
|
1884
|
-
var
|
|
1885
|
-
var
|
|
1886
|
-
var
|
|
2033
|
+
var import_cluemart_shared18 = require("@timardex/cluemart-shared");
|
|
2034
|
+
var import_mongoose23 = __toESM(require("mongoose"));
|
|
2035
|
+
var MongooseSchema19 = import_mongoose23.default.Schema;
|
|
2036
|
+
var schema19 = new MongooseSchema19(
|
|
1887
2037
|
{
|
|
1888
2038
|
...baseResourceFields,
|
|
1889
2039
|
// Importing base resource fields from global.ts
|
|
@@ -1892,10 +2042,10 @@ var schema16 = new MongooseSchema17(
|
|
|
1892
2042
|
eventInfoId: {
|
|
1893
2043
|
ref: "EventInfo",
|
|
1894
2044
|
required: false,
|
|
1895
|
-
type:
|
|
2045
|
+
type: import_mongoose23.default.Schema.Types.ObjectId
|
|
1896
2046
|
},
|
|
1897
2047
|
eventType: {
|
|
1898
|
-
enum: Object.values(
|
|
2048
|
+
enum: Object.values(import_cluemart_shared18.EnumEventType),
|
|
1899
2049
|
required: true,
|
|
1900
2050
|
type: String
|
|
1901
2051
|
},
|
|
@@ -1916,40 +2066,40 @@ var schema16 = new MongooseSchema17(
|
|
|
1916
2066
|
},
|
|
1917
2067
|
{ timestamps: true }
|
|
1918
2068
|
);
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
var EventModel =
|
|
2069
|
+
schema19.index({ name: 1 });
|
|
2070
|
+
schema19.index({ description: 1 });
|
|
2071
|
+
schema19.index({ region: 1 });
|
|
2072
|
+
schema19.index({ "location.geo": "2dsphere" });
|
|
2073
|
+
schema19.index({ tags: 1 });
|
|
2074
|
+
schema19.index({ deletedAt: 1 });
|
|
2075
|
+
schema19.index({ "dateTime.dateStatus": 1 });
|
|
2076
|
+
schema19.index({ slug: 1 });
|
|
2077
|
+
schema19.index({ description: "text", name: "text", tags: "text" });
|
|
2078
|
+
schema19.index({ deletedAt: 1, "owner.userId": 1 });
|
|
2079
|
+
schema19.plugin(searchNamePlugin);
|
|
2080
|
+
var EventModel = import_mongoose23.default.models.Event || import_mongoose23.default.model("Event", schema19);
|
|
1931
2081
|
|
|
1932
2082
|
// src/mongoose/event/EventDateArchive.ts
|
|
1933
|
-
var
|
|
1934
|
-
var
|
|
2083
|
+
var import_mongoose24 = __toESM(require("mongoose"));
|
|
2084
|
+
var schema20 = new import_mongoose24.default.Schema(
|
|
1935
2085
|
{
|
|
1936
2086
|
dateTime: { required: true, type: [dateTimeSchema] },
|
|
1937
2087
|
eventId: {
|
|
1938
2088
|
ref: "Event",
|
|
1939
2089
|
required: true,
|
|
1940
|
-
type:
|
|
2090
|
+
type: import_mongoose24.default.Schema.Types.ObjectId
|
|
1941
2091
|
}
|
|
1942
2092
|
},
|
|
1943
2093
|
{ timestamps: true }
|
|
1944
2094
|
);
|
|
1945
|
-
|
|
1946
|
-
var EventDateArchiveModel =
|
|
2095
|
+
schema20.index({ eventId: 1 }, { unique: true });
|
|
2096
|
+
var EventDateArchiveModel = import_mongoose24.default.models.EventDateArchive || import_mongoose24.default.model("EventDateArchive", schema20);
|
|
1947
2097
|
|
|
1948
2098
|
// src/mongoose/Partner.ts
|
|
1949
|
-
var
|
|
1950
|
-
var
|
|
1951
|
-
var
|
|
1952
|
-
var
|
|
2099
|
+
var import_cluemart_shared19 = require("@timardex/cluemart-shared");
|
|
2100
|
+
var import_mongoose25 = __toESM(require("mongoose"));
|
|
2101
|
+
var MongooseSchema20 = import_mongoose25.default.Schema;
|
|
2102
|
+
var schema21 = new MongooseSchema20(
|
|
1953
2103
|
{
|
|
1954
2104
|
...baseResourceFields,
|
|
1955
2105
|
location: {
|
|
@@ -1958,53 +2108,53 @@ var schema18 = new MongooseSchema18(
|
|
|
1958
2108
|
},
|
|
1959
2109
|
nzbn: { required: true, type: String },
|
|
1960
2110
|
partnerType: {
|
|
1961
|
-
enum: Object.values(
|
|
2111
|
+
enum: Object.values(import_cluemart_shared19.EnumPartnerType),
|
|
1962
2112
|
required: true,
|
|
1963
2113
|
type: String
|
|
1964
2114
|
}
|
|
1965
2115
|
},
|
|
1966
2116
|
{ timestamps: true }
|
|
1967
2117
|
);
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
var PartnerModel =
|
|
2118
|
+
schema21.index({ name: 1 });
|
|
2119
|
+
schema21.index({ description: 1 });
|
|
2120
|
+
schema21.index({ region: 1 });
|
|
2121
|
+
schema21.index({ "location.geo": "2dsphere" });
|
|
2122
|
+
schema21.index({ slug: 1 });
|
|
2123
|
+
schema21.index({ name: "text", description: "text" });
|
|
2124
|
+
schema21.index({ "owner.userId": 1, deletedAt: 1 });
|
|
2125
|
+
schema21.plugin(searchNamePlugin);
|
|
2126
|
+
var PartnerModel = import_mongoose25.default.models.Partner || import_mongoose25.default.model("Partner", schema21);
|
|
1977
2127
|
|
|
1978
2128
|
// src/mongoose/Post.ts
|
|
1979
|
-
var
|
|
1980
|
-
var
|
|
1981
|
-
var
|
|
1982
|
-
var contentSchema = new
|
|
2129
|
+
var import_cluemart_shared20 = require("@timardex/cluemart-shared");
|
|
2130
|
+
var import_mongoose26 = __toESM(require("mongoose"));
|
|
2131
|
+
var MongooseSchema21 = import_mongoose26.default.Schema;
|
|
2132
|
+
var contentSchema = new MongooseSchema21(
|
|
1983
2133
|
{
|
|
1984
|
-
contentData:
|
|
2134
|
+
contentData: import_mongoose26.Schema.Types.Mixed,
|
|
1985
2135
|
contentOrder: { required: true, type: Number },
|
|
1986
2136
|
contentType: {
|
|
1987
|
-
enum: Object.values(
|
|
2137
|
+
enum: Object.values(import_cluemart_shared20.EnumPostContentType),
|
|
1988
2138
|
required: true,
|
|
1989
2139
|
type: String
|
|
1990
2140
|
}
|
|
1991
2141
|
},
|
|
1992
2142
|
{ _id: false }
|
|
1993
2143
|
);
|
|
1994
|
-
var resourceSchema = new
|
|
2144
|
+
var resourceSchema = new MongooseSchema21(
|
|
1995
2145
|
{
|
|
1996
2146
|
resourceId: { required: true, type: String },
|
|
1997
2147
|
resourceRegion: { required: true, type: String },
|
|
1998
2148
|
resourceSlug: { required: true, type: String },
|
|
1999
2149
|
resourceType: {
|
|
2000
|
-
enum: Object.values(
|
|
2150
|
+
enum: Object.values(import_cluemart_shared20.EnumResourceType),
|
|
2001
2151
|
required: true,
|
|
2002
2152
|
type: String
|
|
2003
2153
|
}
|
|
2004
2154
|
},
|
|
2005
2155
|
{ _id: false }
|
|
2006
2156
|
);
|
|
2007
|
-
var
|
|
2157
|
+
var schema22 = new MongooseSchema21(
|
|
2008
2158
|
{
|
|
2009
2159
|
active: { default: false, required: true, type: Boolean },
|
|
2010
2160
|
approvedAt: { default: null, required: false, type: Date },
|
|
@@ -2020,7 +2170,7 @@ var schema19 = new MongooseSchema19(
|
|
|
2020
2170
|
},
|
|
2021
2171
|
deletedAt: { default: null, required: false, type: Date },
|
|
2022
2172
|
postType: {
|
|
2023
|
-
enum: Object.values(
|
|
2173
|
+
enum: Object.values(import_cluemart_shared20.EnumPostType),
|
|
2024
2174
|
required: true,
|
|
2025
2175
|
type: String
|
|
2026
2176
|
},
|
|
@@ -2035,16 +2185,16 @@ var schema19 = new MongooseSchema19(
|
|
|
2035
2185
|
},
|
|
2036
2186
|
{ timestamps: true }
|
|
2037
2187
|
);
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
var PostModel =
|
|
2188
|
+
schema22.index({ title: 1 });
|
|
2189
|
+
schema22.index({ tags: 1 });
|
|
2190
|
+
schema22.index({ postType: 1, slug: 1 }, { unique: true });
|
|
2191
|
+
var PostModel = import_mongoose26.default.models.Post || import_mongoose26.default.model("Post", schema22);
|
|
2042
2192
|
|
|
2043
2193
|
// src/mongoose/AppSetting.ts
|
|
2044
|
-
var
|
|
2045
|
-
var
|
|
2194
|
+
var import_mongoose27 = __toESM(require("mongoose"));
|
|
2195
|
+
var MongooseSchema22 = import_mongoose27.default.Schema;
|
|
2046
2196
|
var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
|
|
2047
|
-
var AppSettingSchema = new
|
|
2197
|
+
var AppSettingSchema = new MongooseSchema22(
|
|
2048
2198
|
{
|
|
2049
2199
|
activeSchoolsStudentCountTotal: {
|
|
2050
2200
|
default: 0,
|
|
@@ -2066,6 +2216,8 @@ var AppSettingSchema = new MongooseSchema20(
|
|
|
2066
2216
|
validate: Number.isInteger
|
|
2067
2217
|
},
|
|
2068
2218
|
mobileDisplayEnabled: { default: false, required: true, type: Boolean },
|
|
2219
|
+
purchasePricing: { type: MongooseSchema22.Types.Mixed },
|
|
2220
|
+
regionPricing: { type: MongooseSchema22.Types.Mixed },
|
|
2069
2221
|
paidSlotsPerPlacement: { enum: [30], type: Number },
|
|
2070
2222
|
reservedSlotsPerPlacement: { enum: [7], type: Number },
|
|
2071
2223
|
rotationSeconds: { enum: [8], type: Number },
|
|
@@ -2090,12 +2242,12 @@ var AppSettingSchema = new MongooseSchema20(
|
|
|
2090
2242
|
},
|
|
2091
2243
|
{ timestamps: true }
|
|
2092
2244
|
);
|
|
2093
|
-
var AppSettingModel =
|
|
2245
|
+
var AppSettingModel = import_mongoose27.default.models.AppSetting || import_mongoose27.default.model("AppSetting", AppSettingSchema);
|
|
2094
2246
|
|
|
2095
2247
|
// src/mongoose/AuthHandoffToken.ts
|
|
2096
|
-
var
|
|
2097
|
-
var
|
|
2098
|
-
var
|
|
2248
|
+
var import_mongoose28 = __toESM(require("mongoose"));
|
|
2249
|
+
var MongooseSchema23 = import_mongoose28.default.Schema;
|
|
2250
|
+
var schema23 = new MongooseSchema23(
|
|
2099
2251
|
{
|
|
2100
2252
|
expiresAt: { required: true, type: Date },
|
|
2101
2253
|
jti: { index: true, required: true, type: String, unique: true },
|
|
@@ -2104,25 +2256,25 @@ var schema20 = new MongooseSchema21(
|
|
|
2104
2256
|
index: true,
|
|
2105
2257
|
ref: "User",
|
|
2106
2258
|
required: true,
|
|
2107
|
-
type:
|
|
2259
|
+
type: import_mongoose28.default.Schema.Types.ObjectId
|
|
2108
2260
|
}
|
|
2109
2261
|
},
|
|
2110
2262
|
{ timestamps: true }
|
|
2111
2263
|
);
|
|
2112
|
-
|
|
2113
|
-
var AuthHandoffTokenModel =
|
|
2264
|
+
schema23.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
|
2265
|
+
var AuthHandoffTokenModel = import_mongoose28.default.models.AuthHandoffToken || import_mongoose28.default.model("AuthHandoffToken", schema23);
|
|
2114
2266
|
|
|
2115
2267
|
// src/mongoose/game/Game.ts
|
|
2116
|
-
var
|
|
2117
|
-
var
|
|
2268
|
+
var import_cluemart_shared21 = require("@timardex/cluemart-shared");
|
|
2269
|
+
var import_mongoose32 = __toESM(require("mongoose"));
|
|
2118
2270
|
|
|
2119
2271
|
// src/mongoose/game/DailyClue.ts
|
|
2120
|
-
var
|
|
2272
|
+
var import_mongoose30 = __toESM(require("mongoose"));
|
|
2121
2273
|
|
|
2122
2274
|
// src/mongoose/game/utils.ts
|
|
2123
|
-
var
|
|
2124
|
-
var
|
|
2125
|
-
var schemaGameDate = new
|
|
2275
|
+
var import_mongoose29 = __toESM(require("mongoose"));
|
|
2276
|
+
var MongooseSchema24 = import_mongoose29.default.Schema;
|
|
2277
|
+
var schemaGameDate = new MongooseSchema24(
|
|
2126
2278
|
{
|
|
2127
2279
|
endDate: { required: true, type: Date },
|
|
2128
2280
|
startDate: { required: true, type: Date }
|
|
@@ -2131,8 +2283,8 @@ var schemaGameDate = new MongooseSchema22(
|
|
|
2131
2283
|
);
|
|
2132
2284
|
|
|
2133
2285
|
// src/mongoose/game/DailyClue.ts
|
|
2134
|
-
var
|
|
2135
|
-
var schemaLetters = new
|
|
2286
|
+
var MongooseSchema25 = import_mongoose30.default.Schema;
|
|
2287
|
+
var schemaLetters = new MongooseSchema25(
|
|
2136
2288
|
{
|
|
2137
2289
|
collected: { required: false, type: [String] },
|
|
2138
2290
|
solutionShuffled: { required: true, type: [String] }
|
|
@@ -2140,14 +2292,14 @@ var schemaLetters = new MongooseSchema23(
|
|
|
2140
2292
|
},
|
|
2141
2293
|
{ _id: false }
|
|
2142
2294
|
);
|
|
2143
|
-
var schemaDailyClueBaseGame = new
|
|
2295
|
+
var schemaDailyClueBaseGame = new MongooseSchema25(
|
|
2144
2296
|
{
|
|
2145
2297
|
gameDate: { required: true, type: schemaGameDate },
|
|
2146
2298
|
gameSolution: { required: true, type: String }
|
|
2147
2299
|
},
|
|
2148
2300
|
{ _id: false }
|
|
2149
2301
|
);
|
|
2150
|
-
var schemaDailyClueGameData = new
|
|
2302
|
+
var schemaDailyClueGameData = new MongooseSchema25(
|
|
2151
2303
|
{
|
|
2152
2304
|
gameFields: { required: true, type: schemaDailyClueBaseGame },
|
|
2153
2305
|
lastFoundDate: { default: null, required: false, type: Date },
|
|
@@ -2162,9 +2314,9 @@ var schemaDailyClueGameData = new MongooseSchema23(
|
|
|
2162
2314
|
);
|
|
2163
2315
|
|
|
2164
2316
|
// src/mongoose/game/PuzzleGame.ts
|
|
2165
|
-
var
|
|
2166
|
-
var
|
|
2167
|
-
var schemaPuzzleAnswer = new
|
|
2317
|
+
var import_mongoose31 = __toESM(require("mongoose"));
|
|
2318
|
+
var MongooseSchema26 = import_mongoose31.default.Schema;
|
|
2319
|
+
var schemaPuzzleAnswer = new MongooseSchema26(
|
|
2168
2320
|
{
|
|
2169
2321
|
answer: { required: true, type: String },
|
|
2170
2322
|
answerId: { required: true, type: String },
|
|
@@ -2172,7 +2324,7 @@ var schemaPuzzleAnswer = new MongooseSchema24(
|
|
|
2172
2324
|
},
|
|
2173
2325
|
{ _id: false }
|
|
2174
2326
|
);
|
|
2175
|
-
var schemaPuzzleQuestion = new
|
|
2327
|
+
var schemaPuzzleQuestion = new MongooseSchema26(
|
|
2176
2328
|
{
|
|
2177
2329
|
answers: { required: true, type: [schemaPuzzleAnswer] },
|
|
2178
2330
|
question: { required: true, type: String },
|
|
@@ -2180,20 +2332,20 @@ var schemaPuzzleQuestion = new MongooseSchema24(
|
|
|
2180
2332
|
},
|
|
2181
2333
|
{ _id: false }
|
|
2182
2334
|
);
|
|
2183
|
-
var schemaPuzzleBaseGame = new
|
|
2335
|
+
var schemaPuzzleBaseGame = new MongooseSchema26(
|
|
2184
2336
|
{
|
|
2185
2337
|
questions: { required: true, type: [schemaPuzzleQuestion] }
|
|
2186
2338
|
},
|
|
2187
2339
|
{ _id: false }
|
|
2188
2340
|
);
|
|
2189
|
-
var schemaPuzzleAnsweredQuestion = new
|
|
2341
|
+
var schemaPuzzleAnsweredQuestion = new MongooseSchema26(
|
|
2190
2342
|
{
|
|
2191
2343
|
questionId: { required: true, type: String },
|
|
2192
2344
|
selectedAnswerId: { required: true, type: String }
|
|
2193
2345
|
},
|
|
2194
2346
|
{ _id: false }
|
|
2195
2347
|
);
|
|
2196
|
-
var schemaPuzzleGameData = new
|
|
2348
|
+
var schemaPuzzleGameData = new MongooseSchema26(
|
|
2197
2349
|
{
|
|
2198
2350
|
answeredQuestions: {
|
|
2199
2351
|
default: null,
|
|
@@ -2208,30 +2360,30 @@ var schemaPuzzleGameData = new MongooseSchema24(
|
|
|
2208
2360
|
);
|
|
2209
2361
|
|
|
2210
2362
|
// src/mongoose/game/Game.ts
|
|
2211
|
-
var
|
|
2363
|
+
var MongooseSchema27 = import_mongoose32.default.Schema;
|
|
2212
2364
|
var gameDataSchemas = {
|
|
2213
|
-
[
|
|
2214
|
-
[
|
|
2215
|
-
[
|
|
2365
|
+
[import_cluemart_shared21.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
|
|
2366
|
+
[import_cluemart_shared21.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
|
|
2367
|
+
[import_cluemart_shared21.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
|
|
2216
2368
|
};
|
|
2217
2369
|
var gameDataDefinition = Object.fromEntries(
|
|
2218
|
-
Object.entries(gameDataSchemas).map(([key,
|
|
2370
|
+
Object.entries(gameDataSchemas).map(([key, schema28]) => [
|
|
2219
2371
|
key,
|
|
2220
|
-
{ default: null, required: false, type:
|
|
2372
|
+
{ default: null, required: false, type: schema28 }
|
|
2221
2373
|
])
|
|
2222
2374
|
);
|
|
2223
|
-
var gameHistorySchema = new
|
|
2375
|
+
var gameHistorySchema = new MongooseSchema27(
|
|
2224
2376
|
{
|
|
2225
2377
|
createdAt: { required: true, type: Date },
|
|
2226
2378
|
gameDate: { required: true, type: schemaGameDate },
|
|
2227
2379
|
gameStatus: {
|
|
2228
|
-
enum: Object.values(
|
|
2380
|
+
enum: Object.values(import_cluemart_shared21.EnumGameStatus),
|
|
2229
2381
|
required: true,
|
|
2230
2382
|
type: String
|
|
2231
2383
|
},
|
|
2232
2384
|
gameTitle: { required: true, type: String },
|
|
2233
2385
|
gameType: {
|
|
2234
|
-
enum: Object.values(
|
|
2386
|
+
enum: Object.values(import_cluemart_shared21.EnumGameType),
|
|
2235
2387
|
required: true,
|
|
2236
2388
|
type: String
|
|
2237
2389
|
},
|
|
@@ -2240,14 +2392,14 @@ var gameHistorySchema = new MongooseSchema25(
|
|
|
2240
2392
|
},
|
|
2241
2393
|
{ _id: false }
|
|
2242
2394
|
);
|
|
2243
|
-
var gameTypeSchema = new
|
|
2395
|
+
var gameTypeSchema = new MongooseSchema27(
|
|
2244
2396
|
{
|
|
2245
2397
|
active: { default: true, required: true, type: Boolean },
|
|
2246
2398
|
gameData: gameDataDefinition,
|
|
2247
2399
|
gameHistory: { default: [], required: true, type: [gameHistorySchema] },
|
|
2248
2400
|
gameTitle: { required: true, type: String },
|
|
2249
2401
|
gameType: {
|
|
2250
|
-
enum: Object.values(
|
|
2402
|
+
enum: Object.values(import_cluemart_shared21.EnumGameType),
|
|
2251
2403
|
required: true,
|
|
2252
2404
|
type: String
|
|
2253
2405
|
},
|
|
@@ -2258,7 +2410,7 @@ var gameTypeSchema = new MongooseSchema25(
|
|
|
2258
2410
|
},
|
|
2259
2411
|
{ timestamps: true }
|
|
2260
2412
|
);
|
|
2261
|
-
var
|
|
2413
|
+
var schema24 = new MongooseSchema27(
|
|
2262
2414
|
{
|
|
2263
2415
|
active: { default: false, required: true, type: Boolean },
|
|
2264
2416
|
deletedAt: { default: null, required: false, type: Date },
|
|
@@ -2271,12 +2423,12 @@ var schema21 = new MongooseSchema25(
|
|
|
2271
2423
|
},
|
|
2272
2424
|
{ timestamps: true }
|
|
2273
2425
|
);
|
|
2274
|
-
var GameModel =
|
|
2426
|
+
var GameModel = import_mongoose32.default.models.Game || import_mongoose32.default.model("Game", schema24);
|
|
2275
2427
|
|
|
2276
2428
|
// src/mongoose/School.ts
|
|
2277
|
-
var
|
|
2278
|
-
var
|
|
2279
|
-
var campaignsSchema = new
|
|
2429
|
+
var import_mongoose33 = __toESM(require("mongoose"));
|
|
2430
|
+
var MongooseSchema28 = import_mongoose33.default.Schema;
|
|
2431
|
+
var campaignsSchema = new MongooseSchema28(
|
|
2280
2432
|
{
|
|
2281
2433
|
endDate: { required: true, type: Date },
|
|
2282
2434
|
name: { required: true, type: String },
|
|
@@ -2284,7 +2436,7 @@ var campaignsSchema = new MongooseSchema26(
|
|
|
2284
2436
|
},
|
|
2285
2437
|
{ _id: false }
|
|
2286
2438
|
);
|
|
2287
|
-
var
|
|
2439
|
+
var schema25 = new MongooseSchema28(
|
|
2288
2440
|
{
|
|
2289
2441
|
// New schools are active by default
|
|
2290
2442
|
active: { default: false, required: true, type: Boolean },
|
|
@@ -2311,26 +2463,26 @@ var schema22 = new MongooseSchema26(
|
|
|
2311
2463
|
},
|
|
2312
2464
|
{ timestamps: true }
|
|
2313
2465
|
);
|
|
2314
|
-
|
|
2466
|
+
schema25.index(
|
|
2315
2467
|
{ schoolCode: 1 },
|
|
2316
2468
|
{
|
|
2317
2469
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
2318
2470
|
unique: true
|
|
2319
2471
|
}
|
|
2320
2472
|
);
|
|
2321
|
-
var SchoolModel =
|
|
2473
|
+
var SchoolModel = import_mongoose33.default.models.School || import_mongoose33.default.model("School", schema25);
|
|
2322
2474
|
|
|
2323
2475
|
// src/mongoose/Affiliate.ts
|
|
2324
|
-
var
|
|
2325
|
-
var
|
|
2326
|
-
var
|
|
2327
|
-
var affiliateRewardSchema = new
|
|
2476
|
+
var import_cluemart_shared22 = require("@timardex/cluemart-shared");
|
|
2477
|
+
var import_mongoose34 = __toESM(require("mongoose"));
|
|
2478
|
+
var MongooseSchema29 = import_mongoose34.default.Schema;
|
|
2479
|
+
var affiliateRewardSchema = new MongooseSchema29(
|
|
2328
2480
|
{
|
|
2329
2481
|
createdAt: { required: true, type: Date },
|
|
2330
2482
|
redeemedAt: { default: null, required: false, type: Date },
|
|
2331
2483
|
rewardDescription: { required: true, type: String },
|
|
2332
2484
|
rewardType: {
|
|
2333
|
-
enum: Object.values(
|
|
2485
|
+
enum: Object.values(import_cluemart_shared22.EnumAffiliateRewardType),
|
|
2334
2486
|
required: true,
|
|
2335
2487
|
type: String
|
|
2336
2488
|
},
|
|
@@ -2338,13 +2490,13 @@ var affiliateRewardSchema = new MongooseSchema27(
|
|
|
2338
2490
|
},
|
|
2339
2491
|
{ _id: false }
|
|
2340
2492
|
);
|
|
2341
|
-
var affiliateResourceSchema = new
|
|
2493
|
+
var affiliateResourceSchema = new MongooseSchema29(
|
|
2342
2494
|
{
|
|
2343
2495
|
resourceActive: { default: true, required: true, type: Boolean },
|
|
2344
2496
|
resourceDeletedAt: { default: null, required: false, type: Date },
|
|
2345
2497
|
resourceId: {
|
|
2346
2498
|
required: true,
|
|
2347
|
-
type:
|
|
2499
|
+
type: import_mongoose34.default.Schema.Types.ObjectId
|
|
2348
2500
|
},
|
|
2349
2501
|
resourceName: { required: true, type: String },
|
|
2350
2502
|
resourceOwner: {
|
|
@@ -2352,7 +2504,7 @@ var affiliateResourceSchema = new MongooseSchema27(
|
|
|
2352
2504
|
type: OwnerTypeSchema
|
|
2353
2505
|
},
|
|
2354
2506
|
resourceType: {
|
|
2355
|
-
enum: Object.values(
|
|
2507
|
+
enum: Object.values(import_cluemart_shared22.EnumResourceType),
|
|
2356
2508
|
required: true,
|
|
2357
2509
|
type: String
|
|
2358
2510
|
},
|
|
@@ -2364,20 +2516,20 @@ var affiliateResourceSchema = new MongooseSchema27(
|
|
|
2364
2516
|
},
|
|
2365
2517
|
{ _id: false }
|
|
2366
2518
|
);
|
|
2367
|
-
var affiliateContactDetailsSchema = new
|
|
2519
|
+
var affiliateContactDetailsSchema = new MongooseSchema29(
|
|
2368
2520
|
{
|
|
2369
2521
|
mobilePhone: { required: true, type: String }
|
|
2370
2522
|
},
|
|
2371
2523
|
{ _id: false }
|
|
2372
2524
|
);
|
|
2373
|
-
var affiliateBankAccountDetailsSchema = new
|
|
2525
|
+
var affiliateBankAccountDetailsSchema = new MongooseSchema29(
|
|
2374
2526
|
{
|
|
2375
2527
|
accountHolderName: { required: true, type: String },
|
|
2376
2528
|
accountNumber: { required: true, type: String }
|
|
2377
2529
|
},
|
|
2378
2530
|
{ _id: false }
|
|
2379
2531
|
);
|
|
2380
|
-
var affiliateDetailsSchema = new
|
|
2532
|
+
var affiliateDetailsSchema = new MongooseSchema29(
|
|
2381
2533
|
{
|
|
2382
2534
|
bankAccountDetails: {
|
|
2383
2535
|
required: true,
|
|
@@ -2390,7 +2542,7 @@ var affiliateDetailsSchema = new MongooseSchema27(
|
|
|
2390
2542
|
lastName: { required: true, type: String },
|
|
2391
2543
|
location: { required: true, type: locationsSchema },
|
|
2392
2544
|
participantType: {
|
|
2393
|
-
enum: Object.values(
|
|
2545
|
+
enum: Object.values(import_cluemart_shared22.EnumAffiliateParticipantType),
|
|
2394
2546
|
required: true,
|
|
2395
2547
|
type: String
|
|
2396
2548
|
},
|
|
@@ -2399,7 +2551,7 @@ var affiliateDetailsSchema = new MongooseSchema27(
|
|
|
2399
2551
|
},
|
|
2400
2552
|
{ _id: false }
|
|
2401
2553
|
);
|
|
2402
|
-
var redeemHistorySchema = new
|
|
2554
|
+
var redeemHistorySchema = new MongooseSchema29(
|
|
2403
2555
|
{
|
|
2404
2556
|
paidAt: { default: null, required: false, type: Date },
|
|
2405
2557
|
redeemedAt: { required: true, type: Date },
|
|
@@ -2407,7 +2559,7 @@ var redeemHistorySchema = new MongooseSchema27(
|
|
|
2407
2559
|
},
|
|
2408
2560
|
{ _id: false }
|
|
2409
2561
|
);
|
|
2410
|
-
var
|
|
2562
|
+
var schema26 = new MongooseSchema29(
|
|
2411
2563
|
{
|
|
2412
2564
|
active: { default: false, required: true, type: Boolean },
|
|
2413
2565
|
affiliateBonusRewards: {
|
|
@@ -2437,26 +2589,26 @@ var schema23 = new MongooseSchema27(
|
|
|
2437
2589
|
},
|
|
2438
2590
|
{ timestamps: true }
|
|
2439
2591
|
);
|
|
2440
|
-
|
|
2592
|
+
schema26.index(
|
|
2441
2593
|
{ affiliateCode: 1 },
|
|
2442
2594
|
{
|
|
2443
2595
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
2444
2596
|
unique: true
|
|
2445
2597
|
}
|
|
2446
2598
|
);
|
|
2447
|
-
var AffiliateModel =
|
|
2599
|
+
var AffiliateModel = import_mongoose34.default.models.Affiliate || import_mongoose34.default.model("Affiliate", schema26);
|
|
2448
2600
|
|
|
2449
2601
|
// src/mongoose/Coupon.ts
|
|
2450
|
-
var
|
|
2451
|
-
var
|
|
2452
|
-
var
|
|
2453
|
-
var couponOptionSchema = new
|
|
2602
|
+
var import_cluemart_shared23 = require("@timardex/cluemart-shared");
|
|
2603
|
+
var import_mongoose35 = __toESM(require("mongoose"));
|
|
2604
|
+
var MongooseSchema30 = import_mongoose35.default.Schema;
|
|
2605
|
+
var couponOptionSchema = new MongooseSchema30(
|
|
2454
2606
|
{
|
|
2455
2607
|
buy: { required: false, type: Number },
|
|
2456
2608
|
get: { required: false, type: Number },
|
|
2457
2609
|
maxRewardCount: { required: false, type: Number },
|
|
2458
2610
|
type: {
|
|
2459
|
-
enum: Object.values(
|
|
2611
|
+
enum: Object.values(import_cluemart_shared23.EnumCouponQualificationType),
|
|
2460
2612
|
required: true,
|
|
2461
2613
|
type: String
|
|
2462
2614
|
},
|
|
@@ -2465,29 +2617,29 @@ var couponOptionSchema = new MongooseSchema28(
|
|
|
2465
2617
|
},
|
|
2466
2618
|
{ _id: false }
|
|
2467
2619
|
);
|
|
2468
|
-
var couponVendorProductSchema = new
|
|
2620
|
+
var couponVendorProductSchema = new MongooseSchema30(
|
|
2469
2621
|
{
|
|
2470
2622
|
couponId: {
|
|
2471
2623
|
required: true,
|
|
2472
|
-
type:
|
|
2624
|
+
type: import_mongoose35.default.Schema.Types.ObjectId
|
|
2473
2625
|
},
|
|
2474
2626
|
productId: {
|
|
2475
2627
|
required: true,
|
|
2476
|
-
type:
|
|
2628
|
+
type: import_mongoose35.default.Schema.Types.ObjectId
|
|
2477
2629
|
},
|
|
2478
2630
|
vendorCouponId: {
|
|
2479
2631
|
required: false,
|
|
2480
|
-
type:
|
|
2632
|
+
type: import_mongoose35.default.Schema.Types.ObjectId
|
|
2481
2633
|
},
|
|
2482
2634
|
vendorId: {
|
|
2483
2635
|
ref: "Vendor",
|
|
2484
2636
|
required: true,
|
|
2485
|
-
type:
|
|
2637
|
+
type: import_mongoose35.default.Schema.Types.ObjectId
|
|
2486
2638
|
}
|
|
2487
2639
|
},
|
|
2488
2640
|
{ _id: false }
|
|
2489
2641
|
);
|
|
2490
|
-
var couponCodeSchema = new
|
|
2642
|
+
var couponCodeSchema = new MongooseSchema30(
|
|
2491
2643
|
{
|
|
2492
2644
|
code: { required: true, type: String },
|
|
2493
2645
|
qrCode: { required: true, type: ResourceImageTypeSchema },
|
|
@@ -2495,7 +2647,7 @@ var couponCodeSchema = new MongooseSchema28(
|
|
|
2495
2647
|
},
|
|
2496
2648
|
{ _id: false }
|
|
2497
2649
|
);
|
|
2498
|
-
var couponParticipantUserSchema = new
|
|
2650
|
+
var couponParticipantUserSchema = new MongooseSchema30(
|
|
2499
2651
|
{
|
|
2500
2652
|
couponCollectedCount: { default: 0, required: true, type: Number },
|
|
2501
2653
|
couponCycleRedeemed: { default: false, required: true, type: Boolean },
|
|
@@ -2504,12 +2656,12 @@ var couponParticipantUserSchema = new MongooseSchema28(
|
|
|
2504
2656
|
userId: {
|
|
2505
2657
|
ref: "User",
|
|
2506
2658
|
required: true,
|
|
2507
|
-
type:
|
|
2659
|
+
type: import_mongoose35.default.Schema.Types.ObjectId
|
|
2508
2660
|
}
|
|
2509
2661
|
},
|
|
2510
2662
|
{ timestamps: true }
|
|
2511
2663
|
);
|
|
2512
|
-
var couponDataSchema = new
|
|
2664
|
+
var couponDataSchema = new MongooseSchema30(
|
|
2513
2665
|
{
|
|
2514
2666
|
active: { default: true, required: true, type: Boolean },
|
|
2515
2667
|
couponCode: { required: false, type: couponCodeSchema },
|
|
@@ -2528,7 +2680,7 @@ var couponDataSchema = new MongooseSchema28(
|
|
|
2528
2680
|
},
|
|
2529
2681
|
resourceId: { required: true, type: String },
|
|
2530
2682
|
resourceType: {
|
|
2531
|
-
enum: Object.values(
|
|
2683
|
+
enum: Object.values(import_cluemart_shared23.EnumResourceType),
|
|
2532
2684
|
required: true,
|
|
2533
2685
|
type: String
|
|
2534
2686
|
},
|
|
@@ -2536,7 +2688,7 @@ var couponDataSchema = new MongooseSchema28(
|
|
|
2536
2688
|
},
|
|
2537
2689
|
{ timestamps: true }
|
|
2538
2690
|
);
|
|
2539
|
-
var
|
|
2691
|
+
var schema27 = new MongooseSchema30(
|
|
2540
2692
|
{
|
|
2541
2693
|
active: { default: true, required: true, type: Boolean },
|
|
2542
2694
|
couponData: { default: [], required: false, type: [couponDataSchema] },
|
|
@@ -2548,62 +2700,62 @@ var schema24 = new MongooseSchema28(
|
|
|
2548
2700
|
},
|
|
2549
2701
|
{ timestamps: true }
|
|
2550
2702
|
);
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
var CouponModel =
|
|
2703
|
+
schema27.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
|
|
2704
|
+
schema27.index({ "couponData.participantUsers.userId": 1 });
|
|
2705
|
+
var CouponModel = import_mongoose35.default.models.Coupon || import_mongoose35.default.model("Coupon", schema27);
|
|
2554
2706
|
|
|
2555
2707
|
// src/mongoose/Impersonation.ts
|
|
2556
|
-
var
|
|
2557
|
-
var
|
|
2558
|
-
var
|
|
2559
|
-
var impersonationSessionSchema = new
|
|
2708
|
+
var import_cluemart_shared24 = require("@timardex/cluemart-shared");
|
|
2709
|
+
var import_mongoose36 = __toESM(require("mongoose"));
|
|
2710
|
+
var MongooseSchema31 = import_mongoose36.default.Schema;
|
|
2711
|
+
var impersonationSessionSchema = new MongooseSchema31(
|
|
2560
2712
|
{
|
|
2561
2713
|
expiresAt: { expires: 0, required: true, type: Date },
|
|
2562
2714
|
impersonatedUserId: {
|
|
2563
2715
|
index: true,
|
|
2564
2716
|
ref: "User",
|
|
2565
2717
|
required: true,
|
|
2566
|
-
type:
|
|
2718
|
+
type: import_mongoose36.default.Schema.Types.ObjectId
|
|
2567
2719
|
},
|
|
2568
2720
|
impersonatorUserId: {
|
|
2569
2721
|
index: true,
|
|
2570
2722
|
ref: "User",
|
|
2571
2723
|
required: true,
|
|
2572
|
-
type:
|
|
2724
|
+
type: import_mongoose36.default.Schema.Types.ObjectId
|
|
2573
2725
|
},
|
|
2574
2726
|
refreshToken: { required: true, type: String }
|
|
2575
2727
|
},
|
|
2576
2728
|
{ timestamps: true }
|
|
2577
2729
|
);
|
|
2578
|
-
var ImpersonationSessionModel =
|
|
2730
|
+
var ImpersonationSessionModel = import_mongoose36.default.models.ImpersonationSession || import_mongoose36.default.model(
|
|
2579
2731
|
"ImpersonationSession",
|
|
2580
2732
|
impersonationSessionSchema
|
|
2581
2733
|
);
|
|
2582
|
-
var impersonationAuditSchema = new
|
|
2734
|
+
var impersonationAuditSchema = new MongooseSchema31(
|
|
2583
2735
|
{
|
|
2584
2736
|
action: { enum: ["start", "end"], required: true, type: String },
|
|
2585
2737
|
endReason: { type: String },
|
|
2586
2738
|
impersonatedUserId: {
|
|
2587
2739
|
ref: "User",
|
|
2588
2740
|
required: true,
|
|
2589
|
-
type:
|
|
2741
|
+
type: import_mongoose36.default.Schema.Types.ObjectId
|
|
2590
2742
|
},
|
|
2591
2743
|
impersonatorUserId: {
|
|
2592
2744
|
ref: "User",
|
|
2593
2745
|
required: true,
|
|
2594
|
-
type:
|
|
2746
|
+
type: import_mongoose36.default.Schema.Types.ObjectId
|
|
2595
2747
|
},
|
|
2596
|
-
resourceId: { type:
|
|
2597
|
-
resourceType: { enum: Object.values(
|
|
2748
|
+
resourceId: { type: import_mongoose36.default.Schema.Types.ObjectId },
|
|
2749
|
+
resourceType: { enum: Object.values(import_cluemart_shared24.EnumResourceType), type: String },
|
|
2598
2750
|
sessionId: {
|
|
2599
2751
|
ref: "ImpersonationSession",
|
|
2600
2752
|
required: true,
|
|
2601
|
-
type:
|
|
2753
|
+
type: import_mongoose36.default.Schema.Types.ObjectId
|
|
2602
2754
|
}
|
|
2603
2755
|
},
|
|
2604
2756
|
{ timestamps: true }
|
|
2605
2757
|
);
|
|
2606
|
-
var ImpersonationAuditModel =
|
|
2758
|
+
var ImpersonationAuditModel = import_mongoose36.default.models.ImpersonationAudit || import_mongoose36.default.model(
|
|
2607
2759
|
"ImpersonationAudit",
|
|
2608
2760
|
impersonationAuditSchema
|
|
2609
2761
|
);
|
|
@@ -2624,7 +2776,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
|
|
|
2624
2776
|
}
|
|
2625
2777
|
|
|
2626
2778
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
2627
|
-
var
|
|
2779
|
+
var import_cluemart_shared26 = require("@timardex/cluemart-shared");
|
|
2628
2780
|
var import_utils3 = require("@timardex/cluemart-shared/utils");
|
|
2629
2781
|
|
|
2630
2782
|
// src/service/saveNotificationsInDb.ts
|
|
@@ -2759,7 +2911,7 @@ async function sendPushNotifications({
|
|
|
2759
2911
|
}
|
|
2760
2912
|
|
|
2761
2913
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
2762
|
-
var
|
|
2914
|
+
var import_cluemart_shared25 = require("@timardex/cluemart-shared");
|
|
2763
2915
|
var import_dayjs = __toESM(require("dayjs"));
|
|
2764
2916
|
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
|
|
2765
2917
|
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
@@ -2817,17 +2969,17 @@ async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ *
|
|
|
2817
2969
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
2818
2970
|
import_dayjs.default.extend(import_utc.default);
|
|
2819
2971
|
import_dayjs.default.extend(import_timezone.default);
|
|
2820
|
-
var SUBSCRIPTION_REWARD_TIMEZONE =
|
|
2972
|
+
var SUBSCRIPTION_REWARD_TIMEZONE = import_cluemart_shared25.NZ_TZ;
|
|
2821
2973
|
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
2822
2974
|
const { hasSubscription, validTypes } = await getVendorStripeSubscriptionPlanForRewards(userId, now);
|
|
2823
|
-
if (validTypes.has(
|
|
2975
|
+
if (validTypes.has(import_cluemart_shared25.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared25.EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
2824
2976
|
if (hasSubscription) {
|
|
2825
|
-
return
|
|
2977
|
+
return import_cluemart_shared25.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
2826
2978
|
}
|
|
2827
|
-
return
|
|
2979
|
+
return import_cluemart_shared25.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2828
2980
|
}
|
|
2829
|
-
if (validTypes.has(
|
|
2830
|
-
return
|
|
2981
|
+
if (validTypes.has(import_cluemart_shared25.EnumUserLicence.STANDARD_VENDOR)) {
|
|
2982
|
+
return import_cluemart_shared25.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2831
2983
|
}
|
|
2832
2984
|
return null;
|
|
2833
2985
|
}
|
|
@@ -2839,7 +2991,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
|
|
|
2839
2991
|
|
|
2840
2992
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
2841
2993
|
function isEligibleVendorResource(resource) {
|
|
2842
|
-
return resource.resourceType ===
|
|
2994
|
+
return resource.resourceType === import_cluemart_shared26.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
|
|
2843
2995
|
}
|
|
2844
2996
|
async function findAffiliatesWithActiveVendorReferrals() {
|
|
2845
2997
|
return await AffiliateModel.find({
|
|
@@ -2848,7 +3000,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
2848
3000
|
$elemMatch: {
|
|
2849
3001
|
resourceActive: true,
|
|
2850
3002
|
resourceDeletedAt: null,
|
|
2851
|
-
resourceType:
|
|
3003
|
+
resourceType: import_cluemart_shared26.EnumResourceType.VENDOR
|
|
2852
3004
|
}
|
|
2853
3005
|
},
|
|
2854
3006
|
deletedAt: null
|
|
@@ -2882,11 +3034,11 @@ async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
|
2882
3034
|
data: {
|
|
2883
3035
|
resourceId: String(affiliateId),
|
|
2884
3036
|
resourceName: resourceNames.join(", "),
|
|
2885
|
-
resourceType:
|
|
3037
|
+
resourceType: import_cluemart_shared26.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
|
|
2886
3038
|
},
|
|
2887
3039
|
message,
|
|
2888
3040
|
title: "Affiliate points earned",
|
|
2889
|
-
type:
|
|
3041
|
+
type: import_cluemart_shared26.EnumNotificationType.SYSTEM,
|
|
2890
3042
|
userIds: [affiliateOwnerUserId]
|
|
2891
3043
|
};
|
|
2892
3044
|
try {
|
|
@@ -2915,7 +3067,7 @@ async function tryAwardSubscriptionReward({
|
|
|
2915
3067
|
resourceActive: true,
|
|
2916
3068
|
resourceDeletedAt: null,
|
|
2917
3069
|
resourceId: resource.resourceId,
|
|
2918
|
-
resourceType:
|
|
3070
|
+
resourceType: import_cluemart_shared26.EnumResourceType.VENDOR,
|
|
2919
3071
|
rewards: {
|
|
2920
3072
|
$not: {
|
|
2921
3073
|
$elemMatch: {
|
|
@@ -3036,7 +3188,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
|
|
|
3036
3188
|
}
|
|
3037
3189
|
|
|
3038
3190
|
// src/service/database.ts
|
|
3039
|
-
var
|
|
3191
|
+
var import_mongoose40 = __toESM(require("mongoose"));
|
|
3040
3192
|
var connectToDatabase = async ({
|
|
3041
3193
|
appName,
|
|
3042
3194
|
dbName,
|
|
@@ -3049,7 +3201,7 @@ var connectToDatabase = async ({
|
|
|
3049
3201
|
// Fallback to MongoDB Atlas connection string
|
|
3050
3202
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
3051
3203
|
);
|
|
3052
|
-
await
|
|
3204
|
+
await import_mongoose40.default.connect(mongoUri);
|
|
3053
3205
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
3054
3206
|
console.log(
|
|
3055
3207
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -3062,7 +3214,7 @@ var connectToDatabase = async ({
|
|
|
3062
3214
|
|
|
3063
3215
|
// src/types/index.ts
|
|
3064
3216
|
var import_express = __toESM(require("express"));
|
|
3065
|
-
var
|
|
3217
|
+
var import_mongoose41 = __toESM(require("mongoose"));
|
|
3066
3218
|
|
|
3067
3219
|
// src/service/notifyUsers.ts
|
|
3068
3220
|
async function publishNotificationEvents(userId, pubsub) {
|
|
@@ -3110,9 +3262,9 @@ async function notifyUsers({
|
|
|
3110
3262
|
}
|
|
3111
3263
|
|
|
3112
3264
|
// src/service/updateAdStatus.ts
|
|
3113
|
-
var
|
|
3265
|
+
var import_cluemart_shared27 = require("@timardex/cluemart-shared");
|
|
3114
3266
|
async function updateAdStatuses() {
|
|
3115
|
-
const now = (0,
|
|
3267
|
+
const now = (0, import_cluemart_shared27.nzDayKey)();
|
|
3116
3268
|
const invalidResult = await AdModel.updateMany(
|
|
3117
3269
|
{
|
|
3118
3270
|
$or: [
|
|
@@ -3120,50 +3272,50 @@ async function updateAdStatuses() {
|
|
|
3120
3272
|
{ end: { $exists: false } },
|
|
3121
3273
|
{ $expr: { $gt: ["$start", "$end"] } }
|
|
3122
3274
|
],
|
|
3123
|
-
status: { $ne:
|
|
3275
|
+
status: { $ne: import_cluemart_shared27.EnumAdStatus.PAUSED }
|
|
3124
3276
|
},
|
|
3125
|
-
{ $set: { status:
|
|
3277
|
+
{ $set: { status: import_cluemart_shared27.EnumAdStatus.PAUSED } }
|
|
3126
3278
|
);
|
|
3127
3279
|
const expiredResult = await AdModel.updateMany(
|
|
3128
|
-
{ end: { $lte: now }, status: { $ne:
|
|
3129
|
-
{ $set: { status:
|
|
3280
|
+
{ end: { $lte: now }, status: { $ne: import_cluemart_shared27.EnumAdStatus.EXPIRED } },
|
|
3281
|
+
{ $set: { status: import_cluemart_shared27.EnumAdStatus.EXPIRED } }
|
|
3130
3282
|
);
|
|
3131
3283
|
const eligibleBooking = {
|
|
3132
3284
|
$or: [
|
|
3133
3285
|
{ bookingKind: { $exists: false } },
|
|
3134
3286
|
{ bookingKind: null },
|
|
3135
3287
|
{
|
|
3136
|
-
approvalStatus:
|
|
3137
|
-
bookingKind:
|
|
3288
|
+
approvalStatus: import_cluemart_shared27.EnumAdApprovalStatus.APPROVED,
|
|
3289
|
+
bookingKind: import_cluemart_shared27.EnumAdBookingSlotKind.RESERVED
|
|
3138
3290
|
},
|
|
3139
3291
|
{
|
|
3140
|
-
approvalStatus:
|
|
3141
|
-
bookingKind:
|
|
3142
|
-
paymentStatus:
|
|
3292
|
+
approvalStatus: import_cluemart_shared27.EnumAdApprovalStatus.APPROVED,
|
|
3293
|
+
bookingKind: import_cluemart_shared27.EnumAdBookingSlotKind.PAID,
|
|
3294
|
+
paymentStatus: import_cluemart_shared27.EnumAdPaymentStatus.PAID
|
|
3143
3295
|
}
|
|
3144
3296
|
]
|
|
3145
3297
|
};
|
|
3146
3298
|
const awaitingApprovalResult = await AdModel.updateMany(
|
|
3147
3299
|
{
|
|
3148
3300
|
$nor: eligibleBooking.$or,
|
|
3149
|
-
bookingKind: { $in: Object.values(
|
|
3301
|
+
bookingKind: { $in: Object.values(import_cluemart_shared27.EnumAdBookingSlotKind) },
|
|
3150
3302
|
end: { $gt: now },
|
|
3151
|
-
status:
|
|
3303
|
+
status: import_cluemart_shared27.EnumAdStatus.ACTIVE
|
|
3152
3304
|
},
|
|
3153
|
-
{ $set: { status:
|
|
3305
|
+
{ $set: { status: import_cluemart_shared27.EnumAdStatus.PAUSED } }
|
|
3154
3306
|
);
|
|
3155
3307
|
const activeResult = await AdModel.updateMany(
|
|
3156
3308
|
{
|
|
3157
3309
|
end: { $gt: now },
|
|
3158
3310
|
start: { $lte: now },
|
|
3159
|
-
status: { $ne:
|
|
3311
|
+
status: { $ne: import_cluemart_shared27.EnumAdStatus.ACTIVE },
|
|
3160
3312
|
...eligibleBooking
|
|
3161
3313
|
},
|
|
3162
|
-
{ $set: { status:
|
|
3314
|
+
{ $set: { status: import_cluemart_shared27.EnumAdStatus.ACTIVE } }
|
|
3163
3315
|
);
|
|
3164
3316
|
const pausedResult = await AdModel.updateMany(
|
|
3165
|
-
{ start: { $gt: now }, status: { $ne:
|
|
3166
|
-
{ $set: { status:
|
|
3317
|
+
{ start: { $gt: now }, status: { $ne: import_cluemart_shared27.EnumAdStatus.PAUSED } },
|
|
3318
|
+
{ $set: { status: import_cluemart_shared27.EnumAdStatus.PAUSED } }
|
|
3167
3319
|
);
|
|
3168
3320
|
console.log(
|
|
3169
3321
|
`\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
|
|
@@ -3171,15 +3323,15 @@ async function updateAdStatuses() {
|
|
|
3171
3323
|
}
|
|
3172
3324
|
|
|
3173
3325
|
// src/service/objectIdToString.ts
|
|
3174
|
-
var
|
|
3326
|
+
var import_mongoose43 = __toESM(require("mongoose"));
|
|
3175
3327
|
function isValidObjectId(value) {
|
|
3176
|
-
return
|
|
3328
|
+
return import_mongoose43.default.Types.ObjectId.isValid(value);
|
|
3177
3329
|
}
|
|
3178
3330
|
function convertObjectIdsToStrings(obj) {
|
|
3179
3331
|
if (obj === null || obj === void 0) {
|
|
3180
3332
|
return obj;
|
|
3181
3333
|
}
|
|
3182
|
-
if (obj instanceof
|
|
3334
|
+
if (obj instanceof import_mongoose43.default.Types.ObjectId) {
|
|
3183
3335
|
return obj.toString();
|
|
3184
3336
|
}
|
|
3185
3337
|
if (obj instanceof Date) {
|
|
@@ -3373,19 +3525,19 @@ function buildUserPointEntryRemovalPipeline(pointType, sourceId) {
|
|
|
3373
3525
|
}
|
|
3374
3526
|
|
|
3375
3527
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
3376
|
-
var
|
|
3528
|
+
var import_cluemart_shared29 = require("@timardex/cluemart-shared");
|
|
3377
3529
|
var import_dayjs4 = __toESM(require("dayjs"));
|
|
3378
3530
|
|
|
3379
3531
|
// src/service/event/archiveEndedEventDates.ts
|
|
3380
|
-
var
|
|
3532
|
+
var import_cluemart_shared28 = require("@timardex/cluemart-shared");
|
|
3381
3533
|
var import_dayjs3 = __toESM(require("dayjs"));
|
|
3382
3534
|
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
3383
3535
|
import_dayjs3.default.extend(import_customParseFormat.default);
|
|
3384
3536
|
var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
|
|
3385
|
-
|
|
3537
|
+
import_cluemart_shared28.EnumEventDateStatus.ENDED
|
|
3386
3538
|
]);
|
|
3387
3539
|
var DISCARDED_STATUSES = /* @__PURE__ */ new Set([
|
|
3388
|
-
|
|
3540
|
+
import_cluemart_shared28.EnumEventDateStatus.INVALID
|
|
3389
3541
|
]);
|
|
3390
3542
|
function splitEventDatesForArchive(dateTime) {
|
|
3391
3543
|
return {
|
|
@@ -3408,12 +3560,12 @@ function dedupeArchivedSlotsByStartDateTime(slots) {
|
|
|
3408
3560
|
});
|
|
3409
3561
|
}
|
|
3410
3562
|
function isPastCanceledEventDate(slot, now) {
|
|
3411
|
-
if (slot.dateStatus !==
|
|
3563
|
+
if (slot.dateStatus !== import_cluemart_shared28.EnumEventDateStatus.CANCELED) {
|
|
3412
3564
|
return false;
|
|
3413
3565
|
}
|
|
3414
3566
|
const endDateTime = (0, import_dayjs3.default)(
|
|
3415
3567
|
`${slot.endDate} ${slot.endTime}`,
|
|
3416
|
-
`${
|
|
3568
|
+
`${import_cluemart_shared28.dateFormat} ${import_cluemart_shared28.timeFormat}`,
|
|
3417
3569
|
true
|
|
3418
3570
|
);
|
|
3419
3571
|
return endDateTime.isValid() && endDateTime.isBefore(now);
|
|
@@ -3459,7 +3611,7 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3459
3611
|
try {
|
|
3460
3612
|
for await (const doc of cursor) {
|
|
3461
3613
|
const dateTime = doc.dateTime.map(
|
|
3462
|
-
(slot) => (0,
|
|
3614
|
+
(slot) => (0, import_cluemart_shared29.updateSingleDateTimeStatus)(slot, now)
|
|
3463
3615
|
);
|
|
3464
3616
|
if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
|
|
3465
3617
|
continue;
|
|
@@ -3483,9 +3635,9 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3483
3635
|
var ARCHIVABLE_EVENT_FILTER = {
|
|
3484
3636
|
"dateTime.dateStatus": {
|
|
3485
3637
|
$in: [
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3638
|
+
import_cluemart_shared29.EnumEventDateStatus.ENDED,
|
|
3639
|
+
import_cluemart_shared29.EnumEventDateStatus.INVALID,
|
|
3640
|
+
import_cluemart_shared29.EnumEventDateStatus.CANCELED
|
|
3489
3641
|
]
|
|
3490
3642
|
},
|
|
3491
3643
|
deletedAt: null
|
|
@@ -3510,7 +3662,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
|
3510
3662
|
try {
|
|
3511
3663
|
for await (const doc of cursor) {
|
|
3512
3664
|
const updated = doc.dateTime.map(
|
|
3513
|
-
(slot) => (0,
|
|
3665
|
+
(slot) => (0, import_cluemart_shared29.updateSingleDateTimeStatus)(slot, now)
|
|
3514
3666
|
);
|
|
3515
3667
|
const { archive, discard } = splitEventDatesForArchive(updated);
|
|
3516
3668
|
const pastCanceled = updated.filter(
|
|
@@ -3534,13 +3686,13 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
|
3534
3686
|
if (archive.length > 0 || discard.length > 0) {
|
|
3535
3687
|
pullConditions.push({
|
|
3536
3688
|
dateStatus: {
|
|
3537
|
-
$in: [
|
|
3689
|
+
$in: [import_cluemart_shared29.EnumEventDateStatus.ENDED, import_cluemart_shared29.EnumEventDateStatus.INVALID]
|
|
3538
3690
|
}
|
|
3539
3691
|
});
|
|
3540
3692
|
}
|
|
3541
3693
|
for (const slot of pastCanceled) {
|
|
3542
3694
|
pullConditions.push({
|
|
3543
|
-
dateStatus:
|
|
3695
|
+
dateStatus: import_cluemart_shared29.EnumEventDateStatus.CANCELED,
|
|
3544
3696
|
startDate: slot.startDate,
|
|
3545
3697
|
startTime: slot.startTime
|
|
3546
3698
|
});
|
|
@@ -3582,9 +3734,9 @@ async function cleanEventInfoDates(now) {
|
|
|
3582
3734
|
try {
|
|
3583
3735
|
for await (const doc of cursor) {
|
|
3584
3736
|
const updated = doc.dateTime.map(
|
|
3585
|
-
(slot) => (0,
|
|
3737
|
+
(slot) => (0, import_cluemart_shared29.updateSingleDateTimeStatus)(slot, now)
|
|
3586
3738
|
);
|
|
3587
|
-
const kept = (0,
|
|
3739
|
+
const kept = (0, import_cluemart_shared29.filterDatesByFutureStatus)(updated);
|
|
3588
3740
|
if (kept.length === updated.length) {
|
|
3589
3741
|
continue;
|
|
3590
3742
|
}
|
|
@@ -3607,15 +3759,19 @@ async function cleanEventInfoDates(now) {
|
|
|
3607
3759
|
}
|
|
3608
3760
|
async function updateAllEventDateTimeStatuses() {
|
|
3609
3761
|
const now = (0, import_dayjs4.default)();
|
|
3610
|
-
const [eventCount, marketCount] = await Promise.all([
|
|
3762
|
+
const [eventCount, marketCount, aiMarketCount] = await Promise.all([
|
|
3611
3763
|
updateModelDateTimeStatuses(EventModel, now),
|
|
3612
3764
|
updateModelDateTimeStatuses(
|
|
3613
3765
|
GoogleImportedMarketModel,
|
|
3614
3766
|
now
|
|
3767
|
+
),
|
|
3768
|
+
updateModelDateTimeStatuses(
|
|
3769
|
+
AiImportedMarketModel,
|
|
3770
|
+
now
|
|
3615
3771
|
)
|
|
3616
3772
|
]);
|
|
3617
3773
|
console.log(
|
|
3618
|
-
`\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`
|
|
3774
|
+
`\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed, ai imported markets=${aiMarketCount} changed`
|
|
3619
3775
|
);
|
|
3620
3776
|
const archivedCount = await archiveEndedAndDiscardInvalidEventDates(now);
|
|
3621
3777
|
if (archivedCount > 0) {
|
|
@@ -3630,7 +3786,7 @@ async function updateAllEventDateTimeStatuses() {
|
|
|
3630
3786
|
}
|
|
3631
3787
|
|
|
3632
3788
|
// src/service/index.ts
|
|
3633
|
-
var
|
|
3789
|
+
var import_cluemart_shared37 = require("@timardex/cluemart-shared");
|
|
3634
3790
|
|
|
3635
3791
|
// src/service/event/findEventOrImportedMarketById.ts
|
|
3636
3792
|
async function findEventOrImportedMarketById(resourceId) {
|
|
@@ -3638,15 +3794,16 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
3638
3794
|
return null;
|
|
3639
3795
|
}
|
|
3640
3796
|
const normalizedId = convertObjectIdsToStrings(resourceId);
|
|
3641
|
-
const [eventDoc, googleImportedDoc] = await Promise.all([
|
|
3797
|
+
const [eventDoc, googleImportedDoc, aiImportedDoc] = await Promise.all([
|
|
3642
3798
|
EventModel.findById(normalizedId).select("_id name dateTime owner").lean().exec(),
|
|
3643
|
-
GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
|
|
3799
|
+
GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec(),
|
|
3800
|
+
AiImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
|
|
3644
3801
|
]);
|
|
3645
|
-
return eventDoc ?? googleImportedDoc;
|
|
3802
|
+
return eventDoc ?? googleImportedDoc ?? aiImportedDoc;
|
|
3646
3803
|
}
|
|
3647
3804
|
|
|
3648
3805
|
// src/service/relations.ts
|
|
3649
|
-
var
|
|
3806
|
+
var import_cluemart_shared30 = require("@timardex/cluemart-shared");
|
|
3650
3807
|
function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
|
|
3651
3808
|
if (!previousDateTime?.length) {
|
|
3652
3809
|
return false;
|
|
@@ -3662,8 +3819,8 @@ function didRemoveAnyStartedDates(previousDateTime, nextDateTime) {
|
|
|
3662
3819
|
return false;
|
|
3663
3820
|
}
|
|
3664
3821
|
return previousDateTime.some(
|
|
3665
|
-
(prev) => prev.dateStatus ===
|
|
3666
|
-
(next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus ===
|
|
3822
|
+
(prev) => prev.dateStatus === import_cluemart_shared30.EnumEventDateStatus.STARTED && !nextDateTime?.some(
|
|
3823
|
+
(next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus === import_cluemart_shared30.EnumEventDateStatus.STARTED
|
|
3667
3824
|
)
|
|
3668
3825
|
);
|
|
3669
3826
|
}
|
|
@@ -3674,7 +3831,7 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
|
|
|
3674
3831
|
) ?? false;
|
|
3675
3832
|
return {
|
|
3676
3833
|
...relationDate,
|
|
3677
|
-
status: existsInEvent ? relationDate.status :
|
|
3834
|
+
status: existsInEvent ? relationDate.status : import_cluemart_shared30.EnumInviteStatus.CANCELED
|
|
3678
3835
|
};
|
|
3679
3836
|
});
|
|
3680
3837
|
}
|
|
@@ -3683,15 +3840,15 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
|
|
|
3683
3840
|
var import_dayjs8 = __toESM(require("dayjs"));
|
|
3684
3841
|
|
|
3685
3842
|
// src/service/license/compliance/utils.ts
|
|
3686
|
-
var
|
|
3843
|
+
var import_cluemart_shared35 = require("@timardex/cluemart-shared");
|
|
3687
3844
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
3688
3845
|
|
|
3689
3846
|
// src/service/license/compliance/event.ts
|
|
3690
|
-
var
|
|
3847
|
+
var import_cluemart_shared31 = require("@timardex/cluemart-shared");
|
|
3691
3848
|
var eventLicences = [
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3849
|
+
import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT,
|
|
3850
|
+
import_cluemart_shared31.EnumUserLicence.PRO_EVENT,
|
|
3851
|
+
import_cluemart_shared31.EnumUserLicence.PRO_PLUS_EVENT
|
|
3695
3852
|
];
|
|
3696
3853
|
async function handleEventLicenceCompliance(user, now) {
|
|
3697
3854
|
if (!user.licences || !user.events?.length) {
|
|
@@ -3903,9 +4060,9 @@ function buildLicenceExpiryPipeline(params) {
|
|
|
3903
4060
|
}
|
|
3904
4061
|
|
|
3905
4062
|
// src/service/license/compliance/partner.ts
|
|
3906
|
-
var
|
|
4063
|
+
var import_cluemart_shared32 = require("@timardex/cluemart-shared");
|
|
3907
4064
|
var partnerLicences = [
|
|
3908
|
-
|
|
4065
|
+
import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER
|
|
3909
4066
|
];
|
|
3910
4067
|
async function handlePartnerLicenceCompliance(user, now) {
|
|
3911
4068
|
if (!user.licences || !user.partner) {
|
|
@@ -3915,11 +4072,11 @@ async function handlePartnerLicenceCompliance(user, now) {
|
|
|
3915
4072
|
}
|
|
3916
4073
|
|
|
3917
4074
|
// src/service/license/compliance/vendor.ts
|
|
3918
|
-
var
|
|
4075
|
+
var import_cluemart_shared34 = require("@timardex/cluemart-shared");
|
|
3919
4076
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
3920
4077
|
|
|
3921
4078
|
// src/service/license/models.ts
|
|
3922
|
-
var
|
|
4079
|
+
var import_cluemart_shared33 = require("@timardex/cluemart-shared");
|
|
3923
4080
|
var import_dayjs5 = __toESM(require("dayjs"));
|
|
3924
4081
|
var import_graphql = require("graphql");
|
|
3925
4082
|
var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
@@ -3931,31 +4088,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
|
3931
4088
|
return LicenceCategory2;
|
|
3932
4089
|
})(LicenceCategory || {});
|
|
3933
4090
|
var licenceCategoryMapping = {
|
|
3934
|
-
[
|
|
3935
|
-
[
|
|
3936
|
-
[
|
|
3937
|
-
[
|
|
3938
|
-
[
|
|
3939
|
-
[
|
|
3940
|
-
[
|
|
3941
|
-
[
|
|
3942
|
-
[
|
|
4091
|
+
[import_cluemart_shared33.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
|
|
4092
|
+
[import_cluemart_shared33.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
|
|
4093
|
+
[import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
|
|
4094
|
+
[import_cluemart_shared33.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
|
|
4095
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
|
|
4096
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
|
|
4097
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
|
|
4098
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
4099
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
|
|
3943
4100
|
};
|
|
3944
4101
|
var licencePriority = {
|
|
3945
|
-
[
|
|
3946
|
-
[
|
|
3947
|
-
[
|
|
3948
|
-
[
|
|
3949
|
-
[
|
|
3950
|
-
[
|
|
3951
|
-
[
|
|
3952
|
-
[
|
|
3953
|
-
[
|
|
4102
|
+
[import_cluemart_shared33.EnumUserLicence.PRO_PLUS_EVENT]: 3,
|
|
4103
|
+
[import_cluemart_shared33.EnumUserLicence.PRO_EVENT]: 2,
|
|
4104
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT]: 1,
|
|
4105
|
+
[import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
|
|
4106
|
+
[import_cluemart_shared33.EnumUserLicence.PRO_VENDOR]: 2,
|
|
4107
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR]: 1,
|
|
4108
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER]: 1,
|
|
4109
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_AFFILIATE]: 1,
|
|
4110
|
+
[import_cluemart_shared33.EnumUserLicence.STANDARD_SCHOOL]: 1
|
|
3954
4111
|
};
|
|
3955
4112
|
var standardLicences = [
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
4113
|
+
import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR,
|
|
4114
|
+
import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT,
|
|
4115
|
+
import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER
|
|
3959
4116
|
];
|
|
3960
4117
|
var standardLicenceSet = new Set(standardLicences);
|
|
3961
4118
|
function isStandardLicence(licence) {
|
|
@@ -3969,11 +4126,11 @@ var categoryRegexMapping = {
|
|
|
3969
4126
|
["school" /* SCHOOL */]: /_school$/
|
|
3970
4127
|
};
|
|
3971
4128
|
var categoryFallbackLicence = {
|
|
3972
|
-
["event" /* EVENT */]:
|
|
3973
|
-
["partner" /* PARTNER */]:
|
|
3974
|
-
["vendor" /* VENDOR */]:
|
|
3975
|
-
["affiliate" /* AFFILIATE */]:
|
|
3976
|
-
["school" /* SCHOOL */]:
|
|
4129
|
+
["event" /* EVENT */]: import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT,
|
|
4130
|
+
["partner" /* PARTNER */]: import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER,
|
|
4131
|
+
["vendor" /* VENDOR */]: import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR,
|
|
4132
|
+
["affiliate" /* AFFILIATE */]: import_cluemart_shared33.EnumUserLicence.STANDARD_AFFILIATE,
|
|
4133
|
+
["school" /* SCHOOL */]: import_cluemart_shared33.EnumUserLicence.STANDARD_SCHOOL
|
|
3977
4134
|
};
|
|
3978
4135
|
var LicenceFilterInput = {
|
|
3979
4136
|
INPUT_USER_LICENCES: "$licences"
|
|
@@ -4003,11 +4160,11 @@ function getHighestLicenceForCategory(licences, category) {
|
|
|
4003
4160
|
function createLicenceObject(expiryDate, licenceType) {
|
|
4004
4161
|
const today = (0, import_dayjs5.default)();
|
|
4005
4162
|
const expiryDateMapping = {
|
|
4006
|
-
[
|
|
4007
|
-
[
|
|
4008
|
-
[
|
|
4009
|
-
[
|
|
4010
|
-
[
|
|
4163
|
+
[import_cluemart_shared33.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
|
|
4164
|
+
[import_cluemart_shared33.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
|
|
4165
|
+
[import_cluemart_shared33.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
|
|
4166
|
+
[import_cluemart_shared33.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
|
|
4167
|
+
[import_cluemart_shared33.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
|
|
4011
4168
|
};
|
|
4012
4169
|
const licenceObject = {
|
|
4013
4170
|
expiryDate: expiryDateMapping[expiryDate],
|
|
@@ -4111,13 +4268,13 @@ async function checkOwnerHasLicence({
|
|
|
4111
4268
|
const owner = await UserModel.findById(userId);
|
|
4112
4269
|
if (!owner) throw new import_graphql.GraphQLError("Owner not found");
|
|
4113
4270
|
const categoryByResource = {
|
|
4114
|
-
[
|
|
4115
|
-
[
|
|
4116
|
-
[
|
|
4117
|
-
[
|
|
4118
|
-
[
|
|
4271
|
+
[import_cluemart_shared33.EnumResourceType.EVENT]: "event" /* EVENT */,
|
|
4272
|
+
[import_cluemart_shared33.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
|
|
4273
|
+
[import_cluemart_shared33.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
|
|
4274
|
+
[import_cluemart_shared33.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
4275
|
+
[import_cluemart_shared33.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
|
|
4119
4276
|
};
|
|
4120
|
-
if (!(0,
|
|
4277
|
+
if (!(0, import_cluemart_shared33.isNonVisitorResourceType)(resourceType)) {
|
|
4121
4278
|
throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
|
|
4122
4279
|
}
|
|
4123
4280
|
const requiredCategory = categoryByResource[resourceType];
|
|
@@ -4197,7 +4354,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
|
|
|
4197
4354
|
return (result?.matchedCount ?? 0) > 0;
|
|
4198
4355
|
}
|
|
4199
4356
|
async function downgradeVendorProFeatures(userId, licenceType) {
|
|
4200
|
-
const isStandardVendor = licenceType ===
|
|
4357
|
+
const isStandardVendor = licenceType === import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR;
|
|
4201
4358
|
if (!isStandardVendor) {
|
|
4202
4359
|
return;
|
|
4203
4360
|
}
|
|
@@ -4244,7 +4401,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
|
|
|
4244
4401
|
return (result?.matchedCount ?? 0) > 0;
|
|
4245
4402
|
}
|
|
4246
4403
|
async function restoreVendorProFeatures(userId, licenceType) {
|
|
4247
|
-
const isProVendor = licenceType ===
|
|
4404
|
+
const isProVendor = licenceType === import_cluemart_shared34.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR;
|
|
4248
4405
|
if (!isProVendor) {
|
|
4249
4406
|
return;
|
|
4250
4407
|
}
|
|
@@ -4265,14 +4422,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
|
|
|
4265
4422
|
return false;
|
|
4266
4423
|
}
|
|
4267
4424
|
const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs6.default)(stripe.paymentGracePeriodEndsAt) : null;
|
|
4268
|
-
const hasActivePaymentGracePeriod = (stripe.status ===
|
|
4425
|
+
const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared34.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared34.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
|
|
4269
4426
|
if (hasActivePaymentGracePeriod) {
|
|
4270
4427
|
return true;
|
|
4271
4428
|
}
|
|
4272
4429
|
if (!stripe.subscriptionId) {
|
|
4273
4430
|
return false;
|
|
4274
4431
|
}
|
|
4275
|
-
if (stripe.status !==
|
|
4432
|
+
if (stripe.status !== import_cluemart_shared34.EnumSubscriptionStatus.ACTIVE) {
|
|
4276
4433
|
return false;
|
|
4277
4434
|
}
|
|
4278
4435
|
if (!stripe.endDate) {
|
|
@@ -4292,7 +4449,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4292
4449
|
return;
|
|
4293
4450
|
}
|
|
4294
4451
|
const proLicences = vendorLicencesOfUser.filter(
|
|
4295
|
-
(licence) => licence.licenceType !==
|
|
4452
|
+
(licence) => licence.licenceType !== import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR
|
|
4296
4453
|
);
|
|
4297
4454
|
const expiredProLicences = proLicences.filter(
|
|
4298
4455
|
(licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now)
|
|
@@ -4305,7 +4462,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4305
4462
|
const expiredProLicence = expiredProLicences.some(
|
|
4306
4463
|
(licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
4307
4464
|
);
|
|
4308
|
-
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences,
|
|
4465
|
+
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared34.vendorLicences, now);
|
|
4309
4466
|
const hasExpiredVendorLicence = vendorLicencesOfUser.some(
|
|
4310
4467
|
(licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
4311
4468
|
);
|
|
@@ -4321,7 +4478,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4321
4478
|
"owner.userId": user._id
|
|
4322
4479
|
}).lean().exec();
|
|
4323
4480
|
}
|
|
4324
|
-
const licencesToSync =
|
|
4481
|
+
const licencesToSync = import_cluemart_shared34.vendorLicences.filter(
|
|
4325
4482
|
(licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
|
|
4326
4483
|
);
|
|
4327
4484
|
await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
|
|
@@ -4336,11 +4493,11 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4336
4493
|
data: {
|
|
4337
4494
|
resourceId: String(vendor._id),
|
|
4338
4495
|
resourceName: vendor.name,
|
|
4339
|
-
resourceType:
|
|
4496
|
+
resourceType: import_cluemart_shared34.EnumNotificationResourceType.DOWNGRADED_VENDOR
|
|
4340
4497
|
},
|
|
4341
4498
|
message: `Your Vendor licence has been downgraded due to licence expiration.`,
|
|
4342
4499
|
title: `Vendor Licence Downgraded`,
|
|
4343
|
-
type:
|
|
4500
|
+
type: import_cluemart_shared34.EnumNotificationType.SYSTEM,
|
|
4344
4501
|
userIds: [user._id]
|
|
4345
4502
|
};
|
|
4346
4503
|
await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
|
|
@@ -4373,7 +4530,7 @@ async function vendorOwnerHasProLicence(vendorId) {
|
|
|
4373
4530
|
effectiveVendorLicences,
|
|
4374
4531
|
"vendor" /* VENDOR */
|
|
4375
4532
|
);
|
|
4376
|
-
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[
|
|
4533
|
+
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared34.EnumUserLicence.PRO_VENDOR];
|
|
4377
4534
|
}
|
|
4378
4535
|
|
|
4379
4536
|
// src/service/license/compliance/utils.ts
|
|
@@ -4383,12 +4540,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
|
|
|
4383
4540
|
const pipeline = buildLicenceExpiryPipeline({
|
|
4384
4541
|
downgradeBranches: [
|
|
4385
4542
|
{
|
|
4386
|
-
case:
|
|
4387
|
-
then:
|
|
4543
|
+
case: import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR,
|
|
4544
|
+
then: import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR
|
|
4388
4545
|
},
|
|
4389
4546
|
{
|
|
4390
|
-
case:
|
|
4391
|
-
then:
|
|
4547
|
+
case: import_cluemart_shared35.EnumUserLicence.PRO_VENDOR,
|
|
4548
|
+
then: import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR
|
|
4392
4549
|
}
|
|
4393
4550
|
],
|
|
4394
4551
|
licenceTypes,
|
|
@@ -4517,7 +4674,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
|
|
|
4517
4674
|
var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
|
|
4518
4675
|
|
|
4519
4676
|
// src/service/license/reminder/utils.ts
|
|
4520
|
-
var
|
|
4677
|
+
var import_cluemart_shared36 = require("@timardex/cluemart-shared");
|
|
4521
4678
|
var import_utils8 = require("@timardex/cluemart-shared/utils");
|
|
4522
4679
|
var import_dayjs9 = __toESM(require("dayjs"));
|
|
4523
4680
|
|
|
@@ -4583,28 +4740,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
|
|
|
4583
4740
|
return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
|
|
4584
4741
|
}
|
|
4585
4742
|
function getLicenseName(licenceType) {
|
|
4586
|
-
return
|
|
4743
|
+
return import_cluemart_shared36.licenseNiceNames[licenceType] || licenceType;
|
|
4587
4744
|
}
|
|
4588
4745
|
function getNotificationTypes(isVendorLicense, isPartnerLicense) {
|
|
4589
4746
|
if (isVendorLicense) {
|
|
4590
4747
|
return {
|
|
4591
|
-
notificationType:
|
|
4592
|
-
resourceType:
|
|
4748
|
+
notificationType: import_cluemart_shared36.EnumNotificationType.SYSTEM,
|
|
4749
|
+
resourceType: import_cluemart_shared36.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
|
|
4593
4750
|
};
|
|
4594
4751
|
}
|
|
4595
4752
|
if (isPartnerLicense) {
|
|
4596
4753
|
return {
|
|
4597
|
-
notificationType:
|
|
4598
|
-
resourceType:
|
|
4754
|
+
notificationType: import_cluemart_shared36.EnumNotificationType.SYSTEM,
|
|
4755
|
+
resourceType: import_cluemart_shared36.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
|
|
4599
4756
|
};
|
|
4600
4757
|
}
|
|
4601
4758
|
return {
|
|
4602
|
-
notificationType:
|
|
4603
|
-
resourceType:
|
|
4759
|
+
notificationType: import_cluemart_shared36.EnumNotificationType.SYSTEM,
|
|
4760
|
+
resourceType: import_cluemart_shared36.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
|
|
4604
4761
|
};
|
|
4605
4762
|
}
|
|
4606
4763
|
async function getLicenseResourceInfo(user, licence) {
|
|
4607
|
-
const isVendorLicense =
|
|
4764
|
+
const isVendorLicense = import_cluemart_shared36.vendorLicences.includes(licence.licenceType);
|
|
4608
4765
|
const isPartnerLicense = partnerLicences.includes(licence.licenceType);
|
|
4609
4766
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4610
4767
|
const { notificationType, resourceType } = getNotificationTypes(
|
|
@@ -4652,11 +4809,11 @@ async function getLicenseResourceInfo(user, licence) {
|
|
|
4652
4809
|
};
|
|
4653
4810
|
}
|
|
4654
4811
|
function getLicenceExpiryMode(licenceType) {
|
|
4655
|
-
return licenceType ===
|
|
4812
|
+
return licenceType === import_cluemart_shared36.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared36.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
|
|
4656
4813
|
}
|
|
4657
4814
|
async function sendLicenseReminder(user, licence) {
|
|
4658
4815
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4659
|
-
const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(
|
|
4816
|
+
const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(import_cluemart_shared36.dateFormat);
|
|
4660
4817
|
const userId = String(user._id);
|
|
4661
4818
|
const resourceInfo = await getLicenseResourceInfo(user, licence);
|
|
4662
4819
|
if (!resourceInfo) {
|