@timardex/cluemart-server-shared 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Affiliate-i11rkfv5.d.mts → Affiliate-6AEy-gNx.d.mts} +1 -1
- package/dist/{Affiliate-BSF7Wm6O.d.ts → Affiliate-D40kRxO_.d.ts} +1 -1
- package/dist/{chunk-ZKHRT2PV.mjs → chunk-TIGQ6F5T.mjs} +60 -2
- package/dist/chunk-TIGQ6F5T.mjs.map +1 -0
- package/dist/{chunk-6PNG5BI5.mjs → chunk-TMPPPLIW.mjs} +1 -1
- package/dist/chunk-TMPPPLIW.mjs.map +1 -0
- package/dist/{index-Bq-lT7a2.d.mts → index-CmtBYjpi.d.mts} +4 -0
- package/dist/{index-Bq-lT7a2.d.ts → index-CmtBYjpi.d.ts} +4 -0
- package/dist/index.cjs +183 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +38 -11
- package/dist/index.d.ts +38 -11
- package/dist/index.mjs +82 -91
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +60 -0
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +36 -6
- package/dist/mongoose/index.d.ts +36 -6
- package/dist/mongoose/index.mjs +5 -1
- package/dist/service/index.cjs +178 -188
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +5 -12
- package/dist/service/index.d.ts +5 -12
- package/dist/service/index.mjs +9 -76
- package/dist/service/index.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-6PNG5BI5.mjs.map +0 -1
- package/dist/chunk-ZKHRT2PV.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -54,6 +54,8 @@ __export(index_exports, {
|
|
|
54
54
|
EventModel: () => EventModel,
|
|
55
55
|
GameModel: () => GameModel,
|
|
56
56
|
GoogleImportedMarketModel: () => GoogleImportedMarketModel,
|
|
57
|
+
ImpersonationAuditModel: () => ImpersonationAuditModel,
|
|
58
|
+
ImpersonationSessionModel: () => ImpersonationSessionModel,
|
|
57
59
|
LicenceCategory: () => LicenceCategory,
|
|
58
60
|
NotificationModel: () => NotificationModel,
|
|
59
61
|
OwnerTypeSchema: () => OwnerTypeSchema,
|
|
@@ -116,7 +118,7 @@ __export(index_exports, {
|
|
|
116
118
|
locationGeoSchema: () => locationGeoSchema,
|
|
117
119
|
locationsSchema: () => locationsSchema,
|
|
118
120
|
mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
|
|
119
|
-
mongoose: () =>
|
|
121
|
+
mongoose: () => import_mongoose38.default,
|
|
120
122
|
normalizeAffiliatePromoCodes: () => normalizeAffiliatePromoCodes,
|
|
121
123
|
normalizePromoCode: () => normalizePromoCode,
|
|
122
124
|
notifyUsers: () => notifyUsers,
|
|
@@ -145,7 +147,7 @@ __export(index_exports, {
|
|
|
145
147
|
updateAdStatuses: () => updateAdStatuses,
|
|
146
148
|
updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
|
|
147
149
|
updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
|
|
148
|
-
updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
|
|
150
|
+
updateSingleDateTimeStatus: () => import_cluemart_shared35.updateSingleDateTimeStatus,
|
|
149
151
|
upgradeUserToLicence: () => upgradeUserToLicence,
|
|
150
152
|
userLicenseSchema: () => userLicenseSchema,
|
|
151
153
|
vendorOwnerHasProLicence: () => vendorOwnerHasProLicence,
|
|
@@ -2599,6 +2601,62 @@ schema24.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
|
|
|
2599
2601
|
schema24.index({ "couponData.participantUsers.userId": 1 });
|
|
2600
2602
|
var CouponModel = import_mongoose32.default.models.Coupon || import_mongoose32.default.model("Coupon", schema24);
|
|
2601
2603
|
|
|
2604
|
+
// src/mongoose/Impersonation.ts
|
|
2605
|
+
var import_cluemart_shared22 = require("@timardex/cluemart-shared");
|
|
2606
|
+
var import_mongoose33 = __toESM(require("mongoose"));
|
|
2607
|
+
var MongooseSchema28 = import_mongoose33.default.Schema;
|
|
2608
|
+
var impersonationSessionSchema = new MongooseSchema28(
|
|
2609
|
+
{
|
|
2610
|
+
expiresAt: { expires: 0, required: true, type: Date },
|
|
2611
|
+
impersonatedUserId: {
|
|
2612
|
+
index: true,
|
|
2613
|
+
ref: "User",
|
|
2614
|
+
required: true,
|
|
2615
|
+
type: import_mongoose33.default.Schema.Types.ObjectId
|
|
2616
|
+
},
|
|
2617
|
+
impersonatorUserId: {
|
|
2618
|
+
index: true,
|
|
2619
|
+
ref: "User",
|
|
2620
|
+
required: true,
|
|
2621
|
+
type: import_mongoose33.default.Schema.Types.ObjectId
|
|
2622
|
+
},
|
|
2623
|
+
refreshToken: { required: true, type: String }
|
|
2624
|
+
},
|
|
2625
|
+
{ timestamps: true }
|
|
2626
|
+
);
|
|
2627
|
+
var ImpersonationSessionModel = import_mongoose33.default.models.ImpersonationSession || import_mongoose33.default.model(
|
|
2628
|
+
"ImpersonationSession",
|
|
2629
|
+
impersonationSessionSchema
|
|
2630
|
+
);
|
|
2631
|
+
var impersonationAuditSchema = new MongooseSchema28(
|
|
2632
|
+
{
|
|
2633
|
+
action: { enum: ["start", "end"], required: true, type: String },
|
|
2634
|
+
endReason: { type: String },
|
|
2635
|
+
impersonatedUserId: {
|
|
2636
|
+
ref: "User",
|
|
2637
|
+
required: true,
|
|
2638
|
+
type: import_mongoose33.default.Schema.Types.ObjectId
|
|
2639
|
+
},
|
|
2640
|
+
impersonatorUserId: {
|
|
2641
|
+
ref: "User",
|
|
2642
|
+
required: true,
|
|
2643
|
+
type: import_mongoose33.default.Schema.Types.ObjectId
|
|
2644
|
+
},
|
|
2645
|
+
resourceId: { type: import_mongoose33.default.Schema.Types.ObjectId },
|
|
2646
|
+
resourceType: { enum: Object.values(import_cluemart_shared22.EnumResourceType), type: String },
|
|
2647
|
+
sessionId: {
|
|
2648
|
+
ref: "ImpersonationSession",
|
|
2649
|
+
required: true,
|
|
2650
|
+
type: import_mongoose33.default.Schema.Types.ObjectId
|
|
2651
|
+
}
|
|
2652
|
+
},
|
|
2653
|
+
{ timestamps: true }
|
|
2654
|
+
);
|
|
2655
|
+
var ImpersonationAuditModel = import_mongoose33.default.models.ImpersonationAudit || import_mongoose33.default.model(
|
|
2656
|
+
"ImpersonationAudit",
|
|
2657
|
+
impersonationAuditSchema
|
|
2658
|
+
);
|
|
2659
|
+
|
|
2602
2660
|
// src/service/promoCode/constants.ts
|
|
2603
2661
|
var ACTIVE_NOT_DELETED_FILTER = {
|
|
2604
2662
|
active: true,
|
|
@@ -2615,7 +2673,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
|
|
|
2615
2673
|
}
|
|
2616
2674
|
|
|
2617
2675
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
2618
|
-
var
|
|
2676
|
+
var import_cluemart_shared24 = require("@timardex/cluemart-shared");
|
|
2619
2677
|
var import_utils3 = require("@timardex/cluemart-shared/utils");
|
|
2620
2678
|
|
|
2621
2679
|
// src/service/saveNotificationsInDb.ts
|
|
@@ -2750,7 +2808,7 @@ async function sendPushNotifications({
|
|
|
2750
2808
|
}
|
|
2751
2809
|
|
|
2752
2810
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
2753
|
-
var
|
|
2811
|
+
var import_cluemart_shared23 = require("@timardex/cluemart-shared");
|
|
2754
2812
|
var import_dayjs = __toESM(require("dayjs"));
|
|
2755
2813
|
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
|
|
2756
2814
|
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
@@ -2808,14 +2866,14 @@ import_dayjs.default.extend(import_timezone.default);
|
|
|
2808
2866
|
var SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
|
|
2809
2867
|
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
2810
2868
|
const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
|
|
2811
|
-
if (validTypes.has(
|
|
2869
|
+
if (validTypes.has(import_cluemart_shared23.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared23.EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
2812
2870
|
if (hasSubscription) {
|
|
2813
|
-
return
|
|
2871
|
+
return import_cluemart_shared23.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
2814
2872
|
}
|
|
2815
|
-
return
|
|
2873
|
+
return import_cluemart_shared23.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2816
2874
|
}
|
|
2817
|
-
if (validTypes.has(
|
|
2818
|
-
return
|
|
2875
|
+
if (validTypes.has(import_cluemart_shared23.EnumUserLicence.STANDARD_VENDOR)) {
|
|
2876
|
+
return import_cluemart_shared23.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2819
2877
|
}
|
|
2820
2878
|
return null;
|
|
2821
2879
|
}
|
|
@@ -2827,7 +2885,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
|
|
|
2827
2885
|
|
|
2828
2886
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
2829
2887
|
function isEligibleVendorResource(resource) {
|
|
2830
|
-
return resource.resourceType ===
|
|
2888
|
+
return resource.resourceType === import_cluemart_shared24.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
|
|
2831
2889
|
}
|
|
2832
2890
|
async function findAffiliatesWithActiveVendorReferrals() {
|
|
2833
2891
|
return await AffiliateModel.find({
|
|
@@ -2836,7 +2894,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
2836
2894
|
$elemMatch: {
|
|
2837
2895
|
resourceActive: true,
|
|
2838
2896
|
resourceDeletedAt: null,
|
|
2839
|
-
resourceType:
|
|
2897
|
+
resourceType: import_cluemart_shared24.EnumResourceType.VENDOR
|
|
2840
2898
|
}
|
|
2841
2899
|
},
|
|
2842
2900
|
deletedAt: null
|
|
@@ -2870,11 +2928,11 @@ async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
|
2870
2928
|
data: {
|
|
2871
2929
|
resourceId: String(affiliateId),
|
|
2872
2930
|
resourceName: resourceNames.join(", "),
|
|
2873
|
-
resourceType:
|
|
2931
|
+
resourceType: import_cluemart_shared24.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
|
|
2874
2932
|
},
|
|
2875
2933
|
message,
|
|
2876
2934
|
title: "Affiliate points earned",
|
|
2877
|
-
type:
|
|
2935
|
+
type: import_cluemart_shared24.EnumNotificationType.SYSTEM,
|
|
2878
2936
|
userIds: [affiliateOwnerUserId]
|
|
2879
2937
|
};
|
|
2880
2938
|
try {
|
|
@@ -2903,7 +2961,7 @@ async function tryAwardSubscriptionReward({
|
|
|
2903
2961
|
resourceActive: true,
|
|
2904
2962
|
resourceDeletedAt: null,
|
|
2905
2963
|
resourceId: resource.resourceId,
|
|
2906
|
-
resourceType:
|
|
2964
|
+
resourceType: import_cluemart_shared24.EnumResourceType.VENDOR,
|
|
2907
2965
|
rewards: {
|
|
2908
2966
|
$not: {
|
|
2909
2967
|
$elemMatch: {
|
|
@@ -3024,7 +3082,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
|
|
|
3024
3082
|
}
|
|
3025
3083
|
|
|
3026
3084
|
// src/service/database.ts
|
|
3027
|
-
var
|
|
3085
|
+
var import_mongoose37 = __toESM(require("mongoose"));
|
|
3028
3086
|
var connectToDatabase = async ({
|
|
3029
3087
|
appName,
|
|
3030
3088
|
dbName,
|
|
@@ -3037,7 +3095,7 @@ var connectToDatabase = async ({
|
|
|
3037
3095
|
// Fallback to MongoDB Atlas connection string
|
|
3038
3096
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
3039
3097
|
);
|
|
3040
|
-
await
|
|
3098
|
+
await import_mongoose37.default.connect(mongoUri);
|
|
3041
3099
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
3042
3100
|
console.log(
|
|
3043
3101
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -3050,7 +3108,7 @@ var connectToDatabase = async ({
|
|
|
3050
3108
|
|
|
3051
3109
|
// src/types/index.ts
|
|
3052
3110
|
var import_express = __toESM(require("express"));
|
|
3053
|
-
var
|
|
3111
|
+
var import_mongoose38 = __toESM(require("mongoose"));
|
|
3054
3112
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
3055
3113
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
3056
3114
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
@@ -3105,7 +3163,7 @@ async function notifyUsers({
|
|
|
3105
3163
|
}
|
|
3106
3164
|
|
|
3107
3165
|
// src/service/updateAdStatus.ts
|
|
3108
|
-
var
|
|
3166
|
+
var import_cluemart_shared25 = require("@timardex/cluemart-shared");
|
|
3109
3167
|
async function updateAdStatuses() {
|
|
3110
3168
|
const now = /* @__PURE__ */ new Date();
|
|
3111
3169
|
const invalidResult = await AdModel.updateMany(
|
|
@@ -3115,50 +3173,50 @@ async function updateAdStatuses() {
|
|
|
3115
3173
|
{ end: { $exists: false } },
|
|
3116
3174
|
{ $expr: { $gt: ["$start", "$end"] } }
|
|
3117
3175
|
],
|
|
3118
|
-
status: { $ne:
|
|
3176
|
+
status: { $ne: import_cluemart_shared25.EnumAdStatus.PAUSED }
|
|
3119
3177
|
},
|
|
3120
|
-
{ $set: { status:
|
|
3178
|
+
{ $set: { status: import_cluemart_shared25.EnumAdStatus.PAUSED } }
|
|
3121
3179
|
);
|
|
3122
3180
|
const expiredResult = await AdModel.updateMany(
|
|
3123
|
-
{ end: { $lte: now }, status: { $ne:
|
|
3124
|
-
{ $set: { status:
|
|
3181
|
+
{ end: { $lte: now }, status: { $ne: import_cluemart_shared25.EnumAdStatus.EXPIRED } },
|
|
3182
|
+
{ $set: { status: import_cluemart_shared25.EnumAdStatus.EXPIRED } }
|
|
3125
3183
|
);
|
|
3126
3184
|
const eligibleBooking = {
|
|
3127
3185
|
$or: [
|
|
3128
3186
|
{ bookingKind: { $exists: false } },
|
|
3129
3187
|
{ bookingKind: null },
|
|
3130
3188
|
{
|
|
3131
|
-
approvalStatus:
|
|
3132
|
-
bookingKind:
|
|
3189
|
+
approvalStatus: import_cluemart_shared25.EnumAdApprovalStatus.APPROVED,
|
|
3190
|
+
bookingKind: import_cluemart_shared25.EnumAdBookingSlotKind.RESERVED
|
|
3133
3191
|
},
|
|
3134
3192
|
{
|
|
3135
|
-
approvalStatus:
|
|
3136
|
-
bookingKind:
|
|
3137
|
-
paymentStatus:
|
|
3193
|
+
approvalStatus: import_cluemart_shared25.EnumAdApprovalStatus.APPROVED,
|
|
3194
|
+
bookingKind: import_cluemart_shared25.EnumAdBookingSlotKind.PAID,
|
|
3195
|
+
paymentStatus: import_cluemart_shared25.EnumAdPaymentStatus.PAID
|
|
3138
3196
|
}
|
|
3139
3197
|
]
|
|
3140
3198
|
};
|
|
3141
3199
|
const awaitingApprovalResult = await AdModel.updateMany(
|
|
3142
3200
|
{
|
|
3143
3201
|
$nor: eligibleBooking.$or,
|
|
3144
|
-
bookingKind: { $in: Object.values(
|
|
3202
|
+
bookingKind: { $in: Object.values(import_cluemart_shared25.EnumAdBookingSlotKind) },
|
|
3145
3203
|
end: { $gt: now },
|
|
3146
|
-
status:
|
|
3204
|
+
status: import_cluemart_shared25.EnumAdStatus.ACTIVE
|
|
3147
3205
|
},
|
|
3148
|
-
{ $set: { status:
|
|
3206
|
+
{ $set: { status: import_cluemart_shared25.EnumAdStatus.PAUSED } }
|
|
3149
3207
|
);
|
|
3150
3208
|
const activeResult = await AdModel.updateMany(
|
|
3151
3209
|
{
|
|
3152
3210
|
end: { $gt: now },
|
|
3153
3211
|
start: { $lte: now },
|
|
3154
|
-
status: { $ne:
|
|
3212
|
+
status: { $ne: import_cluemart_shared25.EnumAdStatus.ACTIVE },
|
|
3155
3213
|
...eligibleBooking
|
|
3156
3214
|
},
|
|
3157
|
-
{ $set: { status:
|
|
3215
|
+
{ $set: { status: import_cluemart_shared25.EnumAdStatus.ACTIVE } }
|
|
3158
3216
|
);
|
|
3159
3217
|
const pausedResult = await AdModel.updateMany(
|
|
3160
|
-
{ start: { $gt: now }, status: { $ne:
|
|
3161
|
-
{ $set: { status:
|
|
3218
|
+
{ start: { $gt: now }, status: { $ne: import_cluemart_shared25.EnumAdStatus.PAUSED } },
|
|
3219
|
+
{ $set: { status: import_cluemart_shared25.EnumAdStatus.PAUSED } }
|
|
3162
3220
|
);
|
|
3163
3221
|
console.log(
|
|
3164
3222
|
`\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
|
|
@@ -3166,15 +3224,15 @@ async function updateAdStatuses() {
|
|
|
3166
3224
|
}
|
|
3167
3225
|
|
|
3168
3226
|
// src/service/objectIdToString.ts
|
|
3169
|
-
var
|
|
3227
|
+
var import_mongoose40 = __toESM(require("mongoose"));
|
|
3170
3228
|
function isValidObjectId(value) {
|
|
3171
|
-
return
|
|
3229
|
+
return import_mongoose40.default.Types.ObjectId.isValid(value);
|
|
3172
3230
|
}
|
|
3173
3231
|
function convertObjectIdsToStrings(obj) {
|
|
3174
3232
|
if (obj === null || obj === void 0) {
|
|
3175
3233
|
return obj;
|
|
3176
3234
|
}
|
|
3177
|
-
if (obj instanceof
|
|
3235
|
+
if (obj instanceof import_mongoose40.default.Types.ObjectId) {
|
|
3178
3236
|
return obj.toString();
|
|
3179
3237
|
}
|
|
3180
3238
|
if (obj instanceof Date) {
|
|
@@ -3194,18 +3252,16 @@ function convertObjectIdsToStrings(obj) {
|
|
|
3194
3252
|
}
|
|
3195
3253
|
|
|
3196
3254
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
3197
|
-
var
|
|
3255
|
+
var import_cluemart_shared27 = require("@timardex/cluemart-shared");
|
|
3198
3256
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
3199
|
-
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
3200
|
-
var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
|
|
3201
3257
|
|
|
3202
3258
|
// src/service/event/archiveEndedEventDates.ts
|
|
3203
|
-
var
|
|
3259
|
+
var import_cluemart_shared26 = require("@timardex/cluemart-shared");
|
|
3204
3260
|
var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
|
|
3205
|
-
|
|
3261
|
+
import_cluemart_shared26.EnumEventDateStatus.ENDED
|
|
3206
3262
|
]);
|
|
3207
3263
|
var DISCARDED_STATUSES = /* @__PURE__ */ new Set([
|
|
3208
|
-
|
|
3264
|
+
import_cluemart_shared26.EnumEventDateStatus.INVALID
|
|
3209
3265
|
]);
|
|
3210
3266
|
function splitEventDatesForArchive(dateTime) {
|
|
3211
3267
|
return {
|
|
@@ -3240,73 +3296,6 @@ async function persistArchivedEventDates(eventId, slots) {
|
|
|
3240
3296
|
}
|
|
3241
3297
|
|
|
3242
3298
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
3243
|
-
import_dayjs2.default.extend(import_customParseFormat.default);
|
|
3244
|
-
import_dayjs2.default.extend(import_isoWeek.default);
|
|
3245
|
-
var MANUAL_DATE_STATUSES = /* @__PURE__ */ new Set([
|
|
3246
|
-
import_cluemart_shared26.EnumEventDateStatus.CANCELED,
|
|
3247
|
-
import_cluemart_shared26.EnumEventDateStatus.RE_SCHEDULED
|
|
3248
|
-
]);
|
|
3249
|
-
function getFutureEventStatus(startDateTime, now) {
|
|
3250
|
-
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
3251
|
-
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
3252
|
-
return import_cluemart_shared26.EnumEventDateStatus.STARTING_SOON;
|
|
3253
|
-
}
|
|
3254
|
-
if (startDateTime.isSame(now, "day")) {
|
|
3255
|
-
return import_cluemart_shared26.EnumEventDateStatus.TODAY;
|
|
3256
|
-
}
|
|
3257
|
-
if (startDateTime.isSame(now.add(1, "day"), "day")) {
|
|
3258
|
-
return import_cluemart_shared26.EnumEventDateStatus.TOMORROW;
|
|
3259
|
-
}
|
|
3260
|
-
if (startDateTime.isSame(now, "isoWeek")) {
|
|
3261
|
-
return import_cluemart_shared26.EnumEventDateStatus.THIS_WEEK;
|
|
3262
|
-
}
|
|
3263
|
-
if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
|
|
3264
|
-
return import_cluemart_shared26.EnumEventDateStatus.NEXT_WEEK;
|
|
3265
|
-
}
|
|
3266
|
-
return import_cluemart_shared26.EnumEventDateStatus.UPCOMING;
|
|
3267
|
-
}
|
|
3268
|
-
function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()) {
|
|
3269
|
-
if (MANUAL_DATE_STATUSES.has(dateTime.dateStatus)) {
|
|
3270
|
-
return dateTime;
|
|
3271
|
-
}
|
|
3272
|
-
const dateTimeFormat = `${import_cluemart_shared26.dateFormat} ${import_cluemart_shared26.timeFormat}`;
|
|
3273
|
-
const startDateTime = (0, import_dayjs2.default)(
|
|
3274
|
-
`${dateTime.startDate} ${dateTime.startTime}`,
|
|
3275
|
-
dateTimeFormat,
|
|
3276
|
-
true
|
|
3277
|
-
);
|
|
3278
|
-
const endDateTime = (0, import_dayjs2.default)(
|
|
3279
|
-
`${dateTime.endDate} ${dateTime.endTime}`,
|
|
3280
|
-
dateTimeFormat,
|
|
3281
|
-
true
|
|
3282
|
-
);
|
|
3283
|
-
if (!startDateTime.isValid() || !endDateTime.isValid()) {
|
|
3284
|
-
return {
|
|
3285
|
-
...dateTime,
|
|
3286
|
-
dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
|
|
3287
|
-
};
|
|
3288
|
-
}
|
|
3289
|
-
if (endDateTime.isBefore(startDateTime)) {
|
|
3290
|
-
return {
|
|
3291
|
-
...dateTime,
|
|
3292
|
-
dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
|
|
3293
|
-
};
|
|
3294
|
-
}
|
|
3295
|
-
let dateStatus;
|
|
3296
|
-
if (endDateTime.isAfter(now)) {
|
|
3297
|
-
if (startDateTime.isAfter(now)) {
|
|
3298
|
-
dateStatus = getFutureEventStatus(startDateTime, now);
|
|
3299
|
-
} else {
|
|
3300
|
-
dateStatus = import_cluemart_shared26.EnumEventDateStatus.STARTED;
|
|
3301
|
-
}
|
|
3302
|
-
} else {
|
|
3303
|
-
dateStatus = import_cluemart_shared26.EnumEventDateStatus.ENDED;
|
|
3304
|
-
}
|
|
3305
|
-
return {
|
|
3306
|
-
...dateTime,
|
|
3307
|
-
dateStatus
|
|
3308
|
-
};
|
|
3309
|
-
}
|
|
3310
3299
|
var dateTimeStatusFilter = {
|
|
3311
3300
|
dateTime: { $ne: [], $type: "array" },
|
|
3312
3301
|
deletedAt: null
|
|
@@ -3335,7 +3324,7 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3335
3324
|
try {
|
|
3336
3325
|
for await (const doc of cursor) {
|
|
3337
3326
|
const dateTime = doc.dateTime.map(
|
|
3338
|
-
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3327
|
+
(slot) => (0, import_cluemart_shared27.updateSingleDateTimeStatus)(slot, now)
|
|
3339
3328
|
);
|
|
3340
3329
|
if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
|
|
3341
3330
|
continue;
|
|
@@ -3358,7 +3347,7 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3358
3347
|
}
|
|
3359
3348
|
var ARCHIVABLE_EVENT_FILTER = {
|
|
3360
3349
|
"dateTime.dateStatus": {
|
|
3361
|
-
$in: [
|
|
3350
|
+
$in: [import_cluemart_shared27.EnumEventDateStatus.ENDED, import_cluemart_shared27.EnumEventDateStatus.INVALID]
|
|
3362
3351
|
},
|
|
3363
3352
|
deletedAt: null
|
|
3364
3353
|
};
|
|
@@ -3380,7 +3369,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
|
3380
3369
|
try {
|
|
3381
3370
|
for await (const doc of cursor) {
|
|
3382
3371
|
const updated = doc.dateTime.map(
|
|
3383
|
-
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3372
|
+
(slot) => (0, import_cluemart_shared27.updateSingleDateTimeStatus)(slot, now)
|
|
3384
3373
|
);
|
|
3385
3374
|
const { archive, discard } = splitEventDatesForArchive(updated);
|
|
3386
3375
|
if (archive.length === 0 && discard.length === 0) {
|
|
@@ -3404,7 +3393,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
|
3404
3393
|
$pull: {
|
|
3405
3394
|
dateTime: {
|
|
3406
3395
|
dateStatus: {
|
|
3407
|
-
$in: [
|
|
3396
|
+
$in: [import_cluemart_shared27.EnumEventDateStatus.ENDED, import_cluemart_shared27.EnumEventDateStatus.INVALID]
|
|
3408
3397
|
}
|
|
3409
3398
|
}
|
|
3410
3399
|
}
|
|
@@ -3438,9 +3427,9 @@ async function cleanEventInfoDates(now) {
|
|
|
3438
3427
|
try {
|
|
3439
3428
|
for await (const doc of cursor) {
|
|
3440
3429
|
const updated = doc.dateTime.map(
|
|
3441
|
-
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3430
|
+
(slot) => (0, import_cluemart_shared27.updateSingleDateTimeStatus)(slot, now)
|
|
3442
3431
|
);
|
|
3443
|
-
const kept = (0,
|
|
3432
|
+
const kept = (0, import_cluemart_shared27.filterDatesByFutureStatus)(updated);
|
|
3444
3433
|
if (kept.length === updated.length) {
|
|
3445
3434
|
continue;
|
|
3446
3435
|
}
|
|
@@ -3485,6 +3474,9 @@ async function updateAllEventDateTimeStatuses() {
|
|
|
3485
3474
|
}
|
|
3486
3475
|
}
|
|
3487
3476
|
|
|
3477
|
+
// src/service/index.ts
|
|
3478
|
+
var import_cluemart_shared35 = require("@timardex/cluemart-shared");
|
|
3479
|
+
|
|
3488
3480
|
// src/service/event/findEventOrImportedMarketById.ts
|
|
3489
3481
|
async function findEventOrImportedMarketById(resourceId) {
|
|
3490
3482
|
if (!resourceId) {
|
|
@@ -3499,7 +3491,7 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
3499
3491
|
}
|
|
3500
3492
|
|
|
3501
3493
|
// src/service/relations.ts
|
|
3502
|
-
var
|
|
3494
|
+
var import_cluemart_shared28 = require("@timardex/cluemart-shared");
|
|
3503
3495
|
function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
|
|
3504
3496
|
if (!previousDateTime?.length) {
|
|
3505
3497
|
return false;
|
|
@@ -3517,7 +3509,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
3517
3509
|
) ?? false;
|
|
3518
3510
|
return {
|
|
3519
3511
|
...relationDate,
|
|
3520
|
-
status: existsInEvent ? relationDate.status :
|
|
3512
|
+
status: existsInEvent ? relationDate.status : import_cluemart_shared28.EnumInviteStatus.UNAVAILABLE
|
|
3521
3513
|
};
|
|
3522
3514
|
});
|
|
3523
3515
|
}
|
|
@@ -3526,15 +3518,15 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
3526
3518
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
3527
3519
|
|
|
3528
3520
|
// src/service/license/compliance/utils.ts
|
|
3529
|
-
var
|
|
3521
|
+
var import_cluemart_shared33 = require("@timardex/cluemart-shared");
|
|
3530
3522
|
var import_dayjs5 = __toESM(require("dayjs"));
|
|
3531
3523
|
|
|
3532
3524
|
// src/service/license/compliance/event.ts
|
|
3533
|
-
var
|
|
3525
|
+
var import_cluemart_shared29 = require("@timardex/cluemart-shared");
|
|
3534
3526
|
var eventLicences = [
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3527
|
+
import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT,
|
|
3528
|
+
import_cluemart_shared29.EnumUserLicence.PRO_EVENT,
|
|
3529
|
+
import_cluemart_shared29.EnumUserLicence.PRO_PLUS_EVENT
|
|
3538
3530
|
];
|
|
3539
3531
|
async function handleEventLicenceCompliance(user, now) {
|
|
3540
3532
|
if (!user.licences || !user.events?.length) {
|
|
@@ -3746,9 +3738,9 @@ function buildLicenceExpiryPipeline(params) {
|
|
|
3746
3738
|
}
|
|
3747
3739
|
|
|
3748
3740
|
// src/service/license/compliance/partner.ts
|
|
3749
|
-
var
|
|
3741
|
+
var import_cluemart_shared30 = require("@timardex/cluemart-shared");
|
|
3750
3742
|
var partnerLicences = [
|
|
3751
|
-
|
|
3743
|
+
import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER
|
|
3752
3744
|
];
|
|
3753
3745
|
async function handlePartnerLicenceCompliance(user, now) {
|
|
3754
3746
|
if (!user.licences || !user.partner) {
|
|
@@ -3758,11 +3750,11 @@ async function handlePartnerLicenceCompliance(user, now) {
|
|
|
3758
3750
|
}
|
|
3759
3751
|
|
|
3760
3752
|
// src/service/license/compliance/vendor.ts
|
|
3761
|
-
var
|
|
3753
|
+
var import_cluemart_shared32 = require("@timardex/cluemart-shared");
|
|
3762
3754
|
var import_dayjs4 = __toESM(require("dayjs"));
|
|
3763
3755
|
|
|
3764
3756
|
// src/service/license/models.ts
|
|
3765
|
-
var
|
|
3757
|
+
var import_cluemart_shared31 = require("@timardex/cluemart-shared");
|
|
3766
3758
|
var import_dayjs3 = __toESM(require("dayjs"));
|
|
3767
3759
|
var import_graphql = require("graphql");
|
|
3768
3760
|
var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
@@ -3774,31 +3766,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
|
3774
3766
|
return LicenceCategory2;
|
|
3775
3767
|
})(LicenceCategory || {});
|
|
3776
3768
|
var licenceCategoryMapping = {
|
|
3777
|
-
[
|
|
3778
|
-
[
|
|
3779
|
-
[
|
|
3780
|
-
[
|
|
3781
|
-
[
|
|
3782
|
-
[
|
|
3783
|
-
[
|
|
3784
|
-
[
|
|
3785
|
-
[
|
|
3769
|
+
[import_cluemart_shared31.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
|
|
3770
|
+
[import_cluemart_shared31.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
|
|
3771
|
+
[import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
|
|
3772
|
+
[import_cluemart_shared31.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
|
|
3773
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
|
|
3774
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
|
|
3775
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
|
|
3776
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
3777
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
|
|
3786
3778
|
};
|
|
3787
3779
|
var licencePriority = {
|
|
3788
|
-
[
|
|
3789
|
-
[
|
|
3790
|
-
[
|
|
3791
|
-
[
|
|
3792
|
-
[
|
|
3793
|
-
[
|
|
3794
|
-
[
|
|
3795
|
-
[
|
|
3796
|
-
[
|
|
3780
|
+
[import_cluemart_shared31.EnumUserLicence.PRO_PLUS_EVENT]: 3,
|
|
3781
|
+
[import_cluemart_shared31.EnumUserLicence.PRO_EVENT]: 2,
|
|
3782
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT]: 1,
|
|
3783
|
+
[import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
|
|
3784
|
+
[import_cluemart_shared31.EnumUserLicence.PRO_VENDOR]: 2,
|
|
3785
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR]: 1,
|
|
3786
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER]: 1,
|
|
3787
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_AFFILIATE]: 1,
|
|
3788
|
+
[import_cluemart_shared31.EnumUserLicence.STANDARD_SCHOOL]: 1
|
|
3797
3789
|
};
|
|
3798
3790
|
var standardLicences = [
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3791
|
+
import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR,
|
|
3792
|
+
import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT,
|
|
3793
|
+
import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER
|
|
3802
3794
|
];
|
|
3803
3795
|
var standardLicenceSet = new Set(standardLicences);
|
|
3804
3796
|
function isStandardLicence(licence) {
|
|
@@ -3812,11 +3804,11 @@ var categoryRegexMapping = {
|
|
|
3812
3804
|
["school" /* SCHOOL */]: /_school$/
|
|
3813
3805
|
};
|
|
3814
3806
|
var categoryFallbackLicence = {
|
|
3815
|
-
["event" /* EVENT */]:
|
|
3816
|
-
["partner" /* PARTNER */]:
|
|
3817
|
-
["vendor" /* VENDOR */]:
|
|
3818
|
-
["affiliate" /* AFFILIATE */]:
|
|
3819
|
-
["school" /* SCHOOL */]:
|
|
3807
|
+
["event" /* EVENT */]: import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT,
|
|
3808
|
+
["partner" /* PARTNER */]: import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER,
|
|
3809
|
+
["vendor" /* VENDOR */]: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR,
|
|
3810
|
+
["affiliate" /* AFFILIATE */]: import_cluemart_shared31.EnumUserLicence.STANDARD_AFFILIATE,
|
|
3811
|
+
["school" /* SCHOOL */]: import_cluemart_shared31.EnumUserLicence.STANDARD_SCHOOL
|
|
3820
3812
|
};
|
|
3821
3813
|
var LicenceFilterInput = {
|
|
3822
3814
|
INPUT_USER_LICENCES: "$licences"
|
|
@@ -3846,11 +3838,11 @@ function getHighestLicenceForCategory(licences, category) {
|
|
|
3846
3838
|
function createLicenceObject(expiryDate, licenceType) {
|
|
3847
3839
|
const today = (0, import_dayjs3.default)();
|
|
3848
3840
|
const expiryDateMapping = {
|
|
3849
|
-
[
|
|
3850
|
-
[
|
|
3851
|
-
[
|
|
3852
|
-
[
|
|
3853
|
-
[
|
|
3841
|
+
[import_cluemart_shared31.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
|
|
3842
|
+
[import_cluemart_shared31.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
|
|
3843
|
+
[import_cluemart_shared31.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
|
|
3844
|
+
[import_cluemart_shared31.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
|
|
3845
|
+
[import_cluemart_shared31.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
|
|
3854
3846
|
};
|
|
3855
3847
|
const licenceObject = {
|
|
3856
3848
|
expiryDate: expiryDateMapping[expiryDate],
|
|
@@ -3954,13 +3946,13 @@ async function checkOwnerHasLicence({
|
|
|
3954
3946
|
const owner = await UserModel.findById(userId);
|
|
3955
3947
|
if (!owner) throw new import_graphql.GraphQLError("Owner not found");
|
|
3956
3948
|
const categoryByResource = {
|
|
3957
|
-
[
|
|
3958
|
-
[
|
|
3959
|
-
[
|
|
3960
|
-
[
|
|
3961
|
-
[
|
|
3949
|
+
[import_cluemart_shared31.EnumResourceType.EVENT]: "event" /* EVENT */,
|
|
3950
|
+
[import_cluemart_shared31.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
|
|
3951
|
+
[import_cluemart_shared31.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
|
|
3952
|
+
[import_cluemart_shared31.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
3953
|
+
[import_cluemart_shared31.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
|
|
3962
3954
|
};
|
|
3963
|
-
if (!(0,
|
|
3955
|
+
if (!(0, import_cluemart_shared31.isNonVisitorResourceType)(resourceType)) {
|
|
3964
3956
|
throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
|
|
3965
3957
|
}
|
|
3966
3958
|
const requiredCategory = categoryByResource[resourceType];
|
|
@@ -4040,7 +4032,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
|
|
|
4040
4032
|
return (result?.matchedCount ?? 0) > 0;
|
|
4041
4033
|
}
|
|
4042
4034
|
async function downgradeVendorProFeatures(userId, licenceType) {
|
|
4043
|
-
const isStandardVendor = licenceType ===
|
|
4035
|
+
const isStandardVendor = licenceType === import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR;
|
|
4044
4036
|
if (!isStandardVendor) {
|
|
4045
4037
|
return;
|
|
4046
4038
|
}
|
|
@@ -4087,7 +4079,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
|
|
|
4087
4079
|
return (result?.matchedCount ?? 0) > 0;
|
|
4088
4080
|
}
|
|
4089
4081
|
async function restoreVendorProFeatures(userId, licenceType) {
|
|
4090
|
-
const isProVendor = licenceType ===
|
|
4082
|
+
const isProVendor = licenceType === import_cluemart_shared32.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR;
|
|
4091
4083
|
if (!isProVendor) {
|
|
4092
4084
|
return;
|
|
4093
4085
|
}
|
|
@@ -4108,14 +4100,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
|
|
|
4108
4100
|
return false;
|
|
4109
4101
|
}
|
|
4110
4102
|
const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs4.default)(stripe.paymentGracePeriodEndsAt) : null;
|
|
4111
|
-
const hasActivePaymentGracePeriod = (stripe.status ===
|
|
4103
|
+
const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared32.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared32.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
|
|
4112
4104
|
if (hasActivePaymentGracePeriod) {
|
|
4113
4105
|
return true;
|
|
4114
4106
|
}
|
|
4115
4107
|
if (!stripe.subscriptionId) {
|
|
4116
4108
|
return false;
|
|
4117
4109
|
}
|
|
4118
|
-
if (stripe.status !==
|
|
4110
|
+
if (stripe.status !== import_cluemart_shared32.EnumSubscriptionStatus.ACTIVE) {
|
|
4119
4111
|
return false;
|
|
4120
4112
|
}
|
|
4121
4113
|
if (!stripe.endDate) {
|
|
@@ -4135,7 +4127,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4135
4127
|
return;
|
|
4136
4128
|
}
|
|
4137
4129
|
const proLicences = vendorLicencesOfUser.filter(
|
|
4138
|
-
(licence) => licence.licenceType !==
|
|
4130
|
+
(licence) => licence.licenceType !== import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR
|
|
4139
4131
|
);
|
|
4140
4132
|
const expiredProLicences = proLicences.filter(
|
|
4141
4133
|
(licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now)
|
|
@@ -4148,7 +4140,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4148
4140
|
const expiredProLicence = expiredProLicences.some(
|
|
4149
4141
|
(licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
4150
4142
|
);
|
|
4151
|
-
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences,
|
|
4143
|
+
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared32.vendorLicences, now);
|
|
4152
4144
|
const hasExpiredVendorLicence = vendorLicencesOfUser.some(
|
|
4153
4145
|
(licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
4154
4146
|
);
|
|
@@ -4164,7 +4156,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4164
4156
|
"owner.userId": user._id
|
|
4165
4157
|
}).lean().exec();
|
|
4166
4158
|
}
|
|
4167
|
-
const licencesToSync =
|
|
4159
|
+
const licencesToSync = import_cluemart_shared32.vendorLicences.filter(
|
|
4168
4160
|
(licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
|
|
4169
4161
|
);
|
|
4170
4162
|
await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
|
|
@@ -4179,11 +4171,11 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4179
4171
|
data: {
|
|
4180
4172
|
resourceId: String(vendor._id),
|
|
4181
4173
|
resourceName: vendor.name,
|
|
4182
|
-
resourceType:
|
|
4174
|
+
resourceType: import_cluemart_shared32.EnumNotificationResourceType.DOWNGRADED_VENDOR
|
|
4183
4175
|
},
|
|
4184
4176
|
message: `Your Vendor licence has been downgraded due to licence expiration.`,
|
|
4185
4177
|
title: `Vendor Licence Downgraded`,
|
|
4186
|
-
type:
|
|
4178
|
+
type: import_cluemart_shared32.EnumNotificationType.SYSTEM,
|
|
4187
4179
|
userIds: [user._id]
|
|
4188
4180
|
};
|
|
4189
4181
|
await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
|
|
@@ -4216,7 +4208,7 @@ async function vendorOwnerHasProLicence(vendorId) {
|
|
|
4216
4208
|
effectiveVendorLicences,
|
|
4217
4209
|
"vendor" /* VENDOR */
|
|
4218
4210
|
);
|
|
4219
|
-
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[
|
|
4211
|
+
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared32.EnumUserLicence.PRO_VENDOR];
|
|
4220
4212
|
}
|
|
4221
4213
|
|
|
4222
4214
|
// src/service/license/compliance/utils.ts
|
|
@@ -4226,12 +4218,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
|
|
|
4226
4218
|
const pipeline = buildLicenceExpiryPipeline({
|
|
4227
4219
|
downgradeBranches: [
|
|
4228
4220
|
{
|
|
4229
|
-
case:
|
|
4230
|
-
then:
|
|
4221
|
+
case: import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR,
|
|
4222
|
+
then: import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR
|
|
4231
4223
|
},
|
|
4232
4224
|
{
|
|
4233
|
-
case:
|
|
4234
|
-
then:
|
|
4225
|
+
case: import_cluemart_shared33.EnumUserLicence.PRO_VENDOR,
|
|
4226
|
+
then: import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR
|
|
4235
4227
|
}
|
|
4236
4228
|
],
|
|
4237
4229
|
licenceTypes,
|
|
@@ -4360,7 +4352,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
|
|
|
4360
4352
|
var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
|
|
4361
4353
|
|
|
4362
4354
|
// src/service/license/reminder/utils.ts
|
|
4363
|
-
var
|
|
4355
|
+
var import_cluemart_shared34 = require("@timardex/cluemart-shared");
|
|
4364
4356
|
var import_utils8 = require("@timardex/cluemart-shared/utils");
|
|
4365
4357
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
4366
4358
|
|
|
@@ -4426,28 +4418,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
|
|
|
4426
4418
|
return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
|
|
4427
4419
|
}
|
|
4428
4420
|
function getLicenseName(licenceType) {
|
|
4429
|
-
return
|
|
4421
|
+
return import_cluemart_shared34.licenseNiceNames[licenceType] || licenceType;
|
|
4430
4422
|
}
|
|
4431
4423
|
function getNotificationTypes(isVendorLicense, isPartnerLicense) {
|
|
4432
4424
|
if (isVendorLicense) {
|
|
4433
4425
|
return {
|
|
4434
|
-
notificationType:
|
|
4435
|
-
resourceType:
|
|
4426
|
+
notificationType: import_cluemart_shared34.EnumNotificationType.SYSTEM,
|
|
4427
|
+
resourceType: import_cluemart_shared34.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
|
|
4436
4428
|
};
|
|
4437
4429
|
}
|
|
4438
4430
|
if (isPartnerLicense) {
|
|
4439
4431
|
return {
|
|
4440
|
-
notificationType:
|
|
4441
|
-
resourceType:
|
|
4432
|
+
notificationType: import_cluemart_shared34.EnumNotificationType.SYSTEM,
|
|
4433
|
+
resourceType: import_cluemart_shared34.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
|
|
4442
4434
|
};
|
|
4443
4435
|
}
|
|
4444
4436
|
return {
|
|
4445
|
-
notificationType:
|
|
4446
|
-
resourceType:
|
|
4437
|
+
notificationType: import_cluemart_shared34.EnumNotificationType.SYSTEM,
|
|
4438
|
+
resourceType: import_cluemart_shared34.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
|
|
4447
4439
|
};
|
|
4448
4440
|
}
|
|
4449
4441
|
async function getLicenseResourceInfo(user, licence) {
|
|
4450
|
-
const isVendorLicense =
|
|
4442
|
+
const isVendorLicense = import_cluemart_shared34.vendorLicences.includes(licence.licenceType);
|
|
4451
4443
|
const isPartnerLicense = partnerLicences.includes(licence.licenceType);
|
|
4452
4444
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4453
4445
|
const { notificationType, resourceType } = getNotificationTypes(
|
|
@@ -4495,11 +4487,11 @@ async function getLicenseResourceInfo(user, licence) {
|
|
|
4495
4487
|
};
|
|
4496
4488
|
}
|
|
4497
4489
|
function getLicenceExpiryMode(licenceType) {
|
|
4498
|
-
return licenceType ===
|
|
4490
|
+
return licenceType === import_cluemart_shared34.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
|
|
4499
4491
|
}
|
|
4500
4492
|
async function sendLicenseReminder(user, licence) {
|
|
4501
4493
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4502
|
-
const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(
|
|
4494
|
+
const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared34.dateFormat);
|
|
4503
4495
|
const userId = String(user._id);
|
|
4504
4496
|
const resourceInfo = await getLicenseResourceInfo(user, licence);
|
|
4505
4497
|
if (!resourceInfo) {
|
|
@@ -4648,6 +4640,8 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4648
4640
|
EventModel,
|
|
4649
4641
|
GameModel,
|
|
4650
4642
|
GoogleImportedMarketModel,
|
|
4643
|
+
ImpersonationAuditModel,
|
|
4644
|
+
ImpersonationSessionModel,
|
|
4651
4645
|
LicenceCategory,
|
|
4652
4646
|
NotificationModel,
|
|
4653
4647
|
OwnerTypeSchema,
|