@timardex/cluemart-server-shared 2.2.12 → 2.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, AdDailyPriceType, AdBookingType, EnumAdShowOn, AdSettingsType, ChatType, ParticipantType, ChatMessageType, NotificationType, CreateBulkNotificationInput, EnumUserRole, BillingCatalogEntryType, BillingCatalogPriceHistoryEntry, EnumBillingPeriod, EnumUserLicence, BILLING_CATALOG_KEYS, ReportChatUser, OwnerType, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, PushTokenType, RelationType, RelationDate, ResourceActivityType, StripeSubscription, UserActivityEvent, UserType, VendorType, VendorProductList, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, EventInfoType, StallType, RefundPolicy, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameDocType, GameType, SchoolType, AffiliateType, AffiliateResourceType, AffiliateRewardType, CouponType, CouponDataType, CouponParticipantUserType, PromoCodeType, EnumAffiliateRewardType, EventListItemType, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, EnumResourceType, LicenceExpiryDate } from '@timardex/cluemart-shared';
2
+ import { AdType, AdDailyPriceType, AdBookingType, EnumAdShowOn, AdSettingsType, ChatType, ParticipantType, ChatMessageType, NotificationType, CreateBulkNotificationInput, EnumUserRole, BillingCatalogEntryType, BillingCatalogPriceHistoryEntry, EnumBillingPeriod, EnumUserLicence, BILLING_CATALOG_KEYS, ReportChatUser, OwnerType, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, PushTokenType, RelationType, RelationDate, ResourceActivityType, StripeSubscription, UserActivityEvent, UserType, VendorType, VendorProductList, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, EventInfoType, StallType, RefundPolicy, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameDocType, GameType, SchoolType, AffiliateType, AffiliateResourceType, AffiliateRewardType, CouponType, CouponDataType, CouponParticipantUserType, EnumResourceType, PromoCodeType, EnumAffiliateRewardType, EventListItemType, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
3
3
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
4
4
  import * as mongoose from 'mongoose';
5
5
  import mongoose__default from 'mongoose';
@@ -116,6 +116,10 @@ interface AuthUser {
116
116
  email: string;
117
117
  roles: EnumUserRole[];
118
118
  userId: ObjectId;
119
+ /** Set when this token represents an impersonation session. */
120
+ impersonationSessionId?: string;
121
+ /** The SUPER_ADMIN who started the impersonation session. */
122
+ impersonatorUserId?: ObjectId;
119
123
  }
120
124
  interface SubscriptionPayload {
121
125
  getChatMessage?: SchemaChatType;
@@ -894,6 +898,36 @@ declare const CouponModel: mongoose__default.Model<CouponDocument, {}, {}, {}, m
894
898
  __v: number;
895
899
  }, any>;
896
900
 
901
+ type SchemaImpersonationSessionType = {
902
+ /** The SUPER_ADMIN who is impersonating. */
903
+ impersonatorUserId: ObjectId;
904
+ /** The resource owner being impersonated. */
905
+ impersonatedUserId: ObjectId;
906
+ /** Hashed impersonation refresh token (stored here, not on the User doc). */
907
+ refreshToken: string;
908
+ expiresAt: Date;
909
+ };
910
+ declare const ImpersonationSessionModel: mongoose__default.Model<SchemaImpersonationSessionType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaImpersonationSessionType, {}, {}> & SchemaImpersonationSessionType & {
911
+ _id: mongoose__default.Types.ObjectId;
912
+ } & {
913
+ __v: number;
914
+ }, any>;
915
+ type SchemaImpersonationAuditType = {
916
+ action: "start" | "end";
917
+ /** Reason for an `end` record (manual, logout, reuse_revoked, expired). */
918
+ endReason?: string | null;
919
+ impersonatedUserId: ObjectId;
920
+ impersonatorUserId: ObjectId;
921
+ resourceId?: ObjectId | null;
922
+ resourceType?: EnumResourceType | null;
923
+ sessionId: ObjectId;
924
+ };
925
+ declare const ImpersonationAuditModel: mongoose__default.Model<SchemaImpersonationAuditType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaImpersonationAuditType, {}, {}> & SchemaImpersonationAuditType & {
926
+ _id: mongoose__default.Types.ObjectId;
927
+ } & {
928
+ __v: number;
929
+ }, any>;
930
+
897
931
  /**
898
932
  * Checks whether an affiliate code is already taken by an active, non-deleted affiliate.
899
933
  *
@@ -1378,4 +1412,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1378
1412
  resourceType: EnumResourceType;
1379
1413
  }): Promise<void>;
1380
1414
 
1381
- export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, type AdImpressionEntry, AdImpressionModel, AdModel, AdSettingsModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, DEFAULT_AD_SETTINGS, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAppSettingsType, type SchemaBillingCatalogEntry, type SchemaBillingCatalogPriceHistoryEntry, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventDateArchiveType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
1415
+ export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, type AdImpressionEntry, AdImpressionModel, AdModel, AdSettingsModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, DEFAULT_AD_SETTINGS, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAppSettingsType, type SchemaBillingCatalogEntry, type SchemaBillingCatalogPriceHistoryEntry, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventDateArchiveType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaImpersonationAuditType, type SchemaImpersonationSessionType, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, AdDailyPriceType, AdBookingType, EnumAdShowOn, AdSettingsType, ChatType, ParticipantType, ChatMessageType, NotificationType, CreateBulkNotificationInput, EnumUserRole, BillingCatalogEntryType, BillingCatalogPriceHistoryEntry, EnumBillingPeriod, EnumUserLicence, BILLING_CATALOG_KEYS, ReportChatUser, OwnerType, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, PushTokenType, RelationType, RelationDate, ResourceActivityType, StripeSubscription, UserActivityEvent, UserType, VendorType, VendorProductList, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, EventInfoType, StallType, RefundPolicy, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameDocType, GameType, SchoolType, AffiliateType, AffiliateResourceType, AffiliateRewardType, CouponType, CouponDataType, CouponParticipantUserType, PromoCodeType, EnumAffiliateRewardType, EventListItemType, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, EnumResourceType, LicenceExpiryDate } from '@timardex/cluemart-shared';
2
+ import { AdType, AdDailyPriceType, AdBookingType, EnumAdShowOn, AdSettingsType, ChatType, ParticipantType, ChatMessageType, NotificationType, CreateBulkNotificationInput, EnumUserRole, BillingCatalogEntryType, BillingCatalogPriceHistoryEntry, EnumBillingPeriod, EnumUserLicence, BILLING_CATALOG_KEYS, ReportChatUser, OwnerType, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, PushTokenType, RelationType, RelationDate, ResourceActivityType, StripeSubscription, UserActivityEvent, UserType, VendorType, VendorProductList, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, EventInfoType, StallType, RefundPolicy, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameDocType, GameType, SchoolType, AffiliateType, AffiliateResourceType, AffiliateRewardType, CouponType, CouponDataType, CouponParticipantUserType, EnumResourceType, PromoCodeType, EnumAffiliateRewardType, EventListItemType, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
3
3
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
4
4
  import * as mongoose from 'mongoose';
5
5
  import mongoose__default from 'mongoose';
@@ -116,6 +116,10 @@ interface AuthUser {
116
116
  email: string;
117
117
  roles: EnumUserRole[];
118
118
  userId: ObjectId;
119
+ /** Set when this token represents an impersonation session. */
120
+ impersonationSessionId?: string;
121
+ /** The SUPER_ADMIN who started the impersonation session. */
122
+ impersonatorUserId?: ObjectId;
119
123
  }
120
124
  interface SubscriptionPayload {
121
125
  getChatMessage?: SchemaChatType;
@@ -894,6 +898,36 @@ declare const CouponModel: mongoose__default.Model<CouponDocument, {}, {}, {}, m
894
898
  __v: number;
895
899
  }, any>;
896
900
 
901
+ type SchemaImpersonationSessionType = {
902
+ /** The SUPER_ADMIN who is impersonating. */
903
+ impersonatorUserId: ObjectId;
904
+ /** The resource owner being impersonated. */
905
+ impersonatedUserId: ObjectId;
906
+ /** Hashed impersonation refresh token (stored here, not on the User doc). */
907
+ refreshToken: string;
908
+ expiresAt: Date;
909
+ };
910
+ declare const ImpersonationSessionModel: mongoose__default.Model<SchemaImpersonationSessionType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaImpersonationSessionType, {}, {}> & SchemaImpersonationSessionType & {
911
+ _id: mongoose__default.Types.ObjectId;
912
+ } & {
913
+ __v: number;
914
+ }, any>;
915
+ type SchemaImpersonationAuditType = {
916
+ action: "start" | "end";
917
+ /** Reason for an `end` record (manual, logout, reuse_revoked, expired). */
918
+ endReason?: string | null;
919
+ impersonatedUserId: ObjectId;
920
+ impersonatorUserId: ObjectId;
921
+ resourceId?: ObjectId | null;
922
+ resourceType?: EnumResourceType | null;
923
+ sessionId: ObjectId;
924
+ };
925
+ declare const ImpersonationAuditModel: mongoose__default.Model<SchemaImpersonationAuditType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaImpersonationAuditType, {}, {}> & SchemaImpersonationAuditType & {
926
+ _id: mongoose__default.Types.ObjectId;
927
+ } & {
928
+ __v: number;
929
+ }, any>;
930
+
897
931
  /**
898
932
  * Checks whether an affiliate code is already taken by an active, non-deleted affiliate.
899
933
  *
@@ -1378,4 +1412,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1378
1412
  resourceType: EnumResourceType;
1379
1413
  }): Promise<void>;
1380
1414
 
1381
- export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, type AdImpressionEntry, AdImpressionModel, AdModel, AdSettingsModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, DEFAULT_AD_SETTINGS, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAppSettingsType, type SchemaBillingCatalogEntry, type SchemaBillingCatalogPriceHistoryEntry, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventDateArchiveType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
1415
+ export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, type AdImpressionEntry, AdImpressionModel, AdModel, AdSettingsModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, DEFAULT_AD_SETTINGS, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAppSettingsType, type SchemaBillingCatalogEntry, type SchemaBillingCatalogPriceHistoryEntry, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventDateArchiveType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaImpersonationAuditType, type SchemaImpersonationSessionType, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
package/dist/index.mjs CHANGED
@@ -2521,6 +2521,62 @@ schema24.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2521
2521
  schema24.index({ "couponData.participantUsers.userId": 1 });
2522
2522
  var CouponModel = mongoose32.models.Coupon || mongoose32.model("Coupon", schema24);
2523
2523
 
2524
+ // src/mongoose/Impersonation.ts
2525
+ import { EnumResourceType as EnumResourceType8 } from "@timardex/cluemart-shared";
2526
+ import mongoose33 from "mongoose";
2527
+ var MongooseSchema28 = mongoose33.Schema;
2528
+ var impersonationSessionSchema = new MongooseSchema28(
2529
+ {
2530
+ expiresAt: { expires: 0, required: true, type: Date },
2531
+ impersonatedUserId: {
2532
+ index: true,
2533
+ ref: "User",
2534
+ required: true,
2535
+ type: mongoose33.Schema.Types.ObjectId
2536
+ },
2537
+ impersonatorUserId: {
2538
+ index: true,
2539
+ ref: "User",
2540
+ required: true,
2541
+ type: mongoose33.Schema.Types.ObjectId
2542
+ },
2543
+ refreshToken: { required: true, type: String }
2544
+ },
2545
+ { timestamps: true }
2546
+ );
2547
+ var ImpersonationSessionModel = mongoose33.models.ImpersonationSession || mongoose33.model(
2548
+ "ImpersonationSession",
2549
+ impersonationSessionSchema
2550
+ );
2551
+ var impersonationAuditSchema = new MongooseSchema28(
2552
+ {
2553
+ action: { enum: ["start", "end"], required: true, type: String },
2554
+ endReason: { type: String },
2555
+ impersonatedUserId: {
2556
+ ref: "User",
2557
+ required: true,
2558
+ type: mongoose33.Schema.Types.ObjectId
2559
+ },
2560
+ impersonatorUserId: {
2561
+ ref: "User",
2562
+ required: true,
2563
+ type: mongoose33.Schema.Types.ObjectId
2564
+ },
2565
+ resourceId: { type: mongoose33.Schema.Types.ObjectId },
2566
+ resourceType: { enum: Object.values(EnumResourceType8), type: String },
2567
+ sessionId: {
2568
+ ref: "ImpersonationSession",
2569
+ required: true,
2570
+ type: mongoose33.Schema.Types.ObjectId
2571
+ }
2572
+ },
2573
+ { timestamps: true }
2574
+ );
2575
+ var ImpersonationAuditModel = mongoose33.models.ImpersonationAudit || mongoose33.model(
2576
+ "ImpersonationAudit",
2577
+ impersonationAuditSchema
2578
+ );
2579
+
2524
2580
  // src/service/promoCode/constants.ts
2525
2581
  var ACTIVE_NOT_DELETED_FILTER = {
2526
2582
  active: true,
@@ -2540,7 +2596,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
2540
2596
  import {
2541
2597
  EnumNotificationResourceType as EnumNotificationResourceType3,
2542
2598
  EnumNotificationType as EnumNotificationType2,
2543
- EnumResourceType as EnumResourceType8
2599
+ EnumResourceType as EnumResourceType9
2544
2600
  } from "@timardex/cluemart-shared";
2545
2601
  import { createAffiliateReward } from "@timardex/cluemart-shared/utils";
2546
2602
 
@@ -2759,7 +2815,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
2759
2815
 
2760
2816
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2761
2817
  function isEligibleVendorResource(resource) {
2762
- return resource.resourceType === EnumResourceType8.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2818
+ return resource.resourceType === EnumResourceType9.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2763
2819
  }
2764
2820
  async function findAffiliatesWithActiveVendorReferrals() {
2765
2821
  return await AffiliateModel.find({
@@ -2768,7 +2824,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
2768
2824
  $elemMatch: {
2769
2825
  resourceActive: true,
2770
2826
  resourceDeletedAt: null,
2771
- resourceType: EnumResourceType8.VENDOR
2827
+ resourceType: EnumResourceType9.VENDOR
2772
2828
  }
2773
2829
  },
2774
2830
  deletedAt: null
@@ -2835,7 +2891,7 @@ async function tryAwardSubscriptionReward({
2835
2891
  resourceActive: true,
2836
2892
  resourceDeletedAt: null,
2837
2893
  resourceId: resource.resourceId,
2838
- resourceType: EnumResourceType8.VENDOR,
2894
+ resourceType: EnumResourceType9.VENDOR,
2839
2895
  rewards: {
2840
2896
  $not: {
2841
2897
  $elemMatch: {
@@ -2956,7 +3012,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
2956
3012
  }
2957
3013
 
2958
3014
  // src/service/database.ts
2959
- import mongoose33 from "mongoose";
3015
+ import mongoose34 from "mongoose";
2960
3016
  var connectToDatabase = async ({
2961
3017
  appName,
2962
3018
  dbName,
@@ -2969,7 +3025,7 @@ var connectToDatabase = async ({
2969
3025
  // Fallback to MongoDB Atlas connection string
2970
3026
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
2971
3027
  );
2972
- await mongoose33.connect(mongoUri);
3028
+ await mongoose34.connect(mongoUri);
2973
3029
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
2974
3030
  console.log(
2975
3031
  `${connectionType} connected from server/src/service/database.ts`
@@ -2982,7 +3038,7 @@ var connectToDatabase = async ({
2982
3038
 
2983
3039
  // src/types/index.ts
2984
3040
  import express from "express";
2985
- import mongoose34 from "mongoose";
3041
+ import mongoose35 from "mongoose";
2986
3042
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
2987
3043
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
2988
3044
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -3103,15 +3159,15 @@ async function updateAdStatuses() {
3103
3159
  }
3104
3160
 
3105
3161
  // src/service/objectIdToString.ts
3106
- import mongoose35 from "mongoose";
3162
+ import mongoose36 from "mongoose";
3107
3163
  function isValidObjectId(value) {
3108
- return mongoose35.Types.ObjectId.isValid(value);
3164
+ return mongoose36.Types.ObjectId.isValid(value);
3109
3165
  }
3110
3166
  function convertObjectIdsToStrings(obj) {
3111
3167
  if (obj === null || obj === void 0) {
3112
3168
  return obj;
3113
3169
  }
3114
- if (obj instanceof mongoose35.Types.ObjectId) {
3170
+ if (obj instanceof mongoose36.Types.ObjectId) {
3115
3171
  return obj.toString();
3116
3172
  }
3117
3173
  if (obj instanceof Date) {
@@ -3136,10 +3192,17 @@ import {
3136
3192
  filterDatesByFutureStatus,
3137
3193
  updateSingleDateTimeStatus
3138
3194
  } from "@timardex/cluemart-shared";
3139
- import dayjs2 from "dayjs";
3195
+ import dayjs3 from "dayjs";
3140
3196
 
3141
3197
  // src/service/event/archiveEndedEventDates.ts
3142
- import { EnumEventDateStatus as EnumEventDateStatus6 } from "@timardex/cluemart-shared";
3198
+ import {
3199
+ EnumEventDateStatus as EnumEventDateStatus6,
3200
+ dateFormat,
3201
+ timeFormat
3202
+ } from "@timardex/cluemart-shared";
3203
+ import dayjs2 from "dayjs";
3204
+ import customParseFormat from "dayjs/plugin/customParseFormat";
3205
+ dayjs2.extend(customParseFormat);
3143
3206
  var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
3144
3207
  EnumEventDateStatus6.ENDED
3145
3208
  ]);
@@ -3166,6 +3229,17 @@ function dedupeArchivedSlotsByStartDateTime(slots) {
3166
3229
  return true;
3167
3230
  });
3168
3231
  }
3232
+ function isPastCanceledEventDate(slot, now) {
3233
+ if (slot.dateStatus !== EnumEventDateStatus6.CANCELED) {
3234
+ return false;
3235
+ }
3236
+ const endDateTime = dayjs2(
3237
+ `${slot.endDate} ${slot.endTime}`,
3238
+ `${dateFormat} ${timeFormat}`,
3239
+ true
3240
+ );
3241
+ return endDateTime.isValid() && endDateTime.isBefore(now);
3242
+ }
3169
3243
  async function persistArchivedEventDates(eventId, slots) {
3170
3244
  if (slots.length === 0) {
3171
3245
  return;
@@ -3230,7 +3304,11 @@ async function updateModelDateTimeStatuses(model, now) {
3230
3304
  }
3231
3305
  var ARCHIVABLE_EVENT_FILTER = {
3232
3306
  "dateTime.dateStatus": {
3233
- $in: [EnumEventDateStatus7.ENDED, EnumEventDateStatus7.INVALID]
3307
+ $in: [
3308
+ EnumEventDateStatus7.ENDED,
3309
+ EnumEventDateStatus7.INVALID,
3310
+ EnumEventDateStatus7.CANCELED
3311
+ ]
3234
3312
  },
3235
3313
  deletedAt: null
3236
3314
  };
@@ -3245,7 +3323,9 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3245
3323
  archiveOps = [];
3246
3324
  }
3247
3325
  if (eventOps.length) {
3248
- await EventModel.bulkWrite(eventOps);
3326
+ await EventModel.bulkWrite(
3327
+ eventOps
3328
+ );
3249
3329
  eventOps = [];
3250
3330
  }
3251
3331
  };
@@ -3255,7 +3335,10 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3255
3335
  (slot) => updateSingleDateTimeStatus(slot, now)
3256
3336
  );
3257
3337
  const { archive, discard } = splitEventDatesForArchive(updated);
3258
- if (archive.length === 0 && discard.length === 0) {
3338
+ const pastCanceled = updated.filter(
3339
+ (slot) => isPastCanceledEventDate(slot, now)
3340
+ );
3341
+ if (archive.length === 0 && discard.length === 0 && pastCanceled.length === 0) {
3259
3342
  continue;
3260
3343
  }
3261
3344
  if (archive.length > 0) {
@@ -3269,16 +3352,27 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3269
3352
  });
3270
3353
  archivedCount += uniqueArchive.length;
3271
3354
  }
3355
+ const pullConditions = [];
3356
+ if (archive.length > 0 || discard.length > 0) {
3357
+ pullConditions.push({
3358
+ dateStatus: {
3359
+ $in: [EnumEventDateStatus7.ENDED, EnumEventDateStatus7.INVALID]
3360
+ }
3361
+ });
3362
+ }
3363
+ for (const slot of pastCanceled) {
3364
+ pullConditions.push({
3365
+ dateStatus: EnumEventDateStatus7.CANCELED,
3366
+ startDate: slot.startDate,
3367
+ startTime: slot.startTime
3368
+ });
3369
+ }
3272
3370
  eventOps.push({
3273
3371
  updateOne: {
3274
3372
  filter: { _id: doc._id },
3275
3373
  update: {
3276
3374
  $pull: {
3277
- dateTime: {
3278
- dateStatus: {
3279
- $in: [EnumEventDateStatus7.ENDED, EnumEventDateStatus7.INVALID]
3280
- }
3281
- }
3375
+ dateTime: { $or: pullConditions }
3282
3376
  }
3283
3377
  }
3284
3378
  }
@@ -3334,7 +3428,7 @@ async function cleanEventInfoDates(now) {
3334
3428
  return removedCount;
3335
3429
  }
3336
3430
  async function updateAllEventDateTimeStatuses() {
3337
- const now = dayjs2();
3431
+ const now = dayjs3();
3338
3432
  const [eventCount, marketCount] = await Promise.all([
3339
3433
  updateModelDateTimeStatuses(EventModel, now),
3340
3434
  updateModelDateTimeStatuses(
@@ -3400,13 +3494,13 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
3400
3494
  }
3401
3495
 
3402
3496
  // src/service/license/compliance/ensureUserLicenseCompliance.ts
3403
- import dayjs6 from "dayjs";
3497
+ import dayjs7 from "dayjs";
3404
3498
 
3405
3499
  // src/service/license/compliance/utils.ts
3406
3500
  import {
3407
3501
  EnumUserLicence as EnumUserLicence10
3408
3502
  } from "@timardex/cluemart-shared";
3409
- import dayjs5 from "dayjs";
3503
+ import dayjs6 from "dayjs";
3410
3504
 
3411
3505
  // src/service/license/compliance/event.ts
3412
3506
  import { EnumUserLicence as EnumUserLicence6 } from "@timardex/cluemart-shared";
@@ -3644,16 +3738,16 @@ import {
3644
3738
  EnumUserLicence as EnumUserLicence9,
3645
3739
  vendorLicences
3646
3740
  } from "@timardex/cluemart-shared";
3647
- import dayjs4 from "dayjs";
3741
+ import dayjs5 from "dayjs";
3648
3742
 
3649
3743
  // src/service/license/models.ts
3650
3744
  import {
3651
- EnumResourceType as EnumResourceType9,
3745
+ EnumResourceType as EnumResourceType10,
3652
3746
  EnumUserLicence as EnumUserLicence8,
3653
3747
  isNonVisitorResourceType,
3654
3748
  LicenceExpiryDate
3655
3749
  } from "@timardex/cluemart-shared";
3656
- import dayjs3 from "dayjs";
3750
+ import dayjs4 from "dayjs";
3657
3751
  import { GraphQLError } from "graphql";
3658
3752
  var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
3659
3753
  LicenceCategory2["EVENT"] = "event";
@@ -3734,7 +3828,7 @@ function getHighestLicenceForCategory(licences, category) {
3734
3828
  return highestLicence;
3735
3829
  }
3736
3830
  function createLicenceObject(expiryDate, licenceType) {
3737
- const today = dayjs3();
3831
+ const today = dayjs4();
3738
3832
  const expiryDateMapping = {
3739
3833
  [LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
3740
3834
  [LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
@@ -3844,11 +3938,11 @@ async function checkOwnerHasLicence({
3844
3938
  const owner = await UserModel.findById(userId);
3845
3939
  if (!owner) throw new GraphQLError("Owner not found");
3846
3940
  const categoryByResource = {
3847
- [EnumResourceType9.EVENT]: "event" /* EVENT */,
3848
- [EnumResourceType9.PARTNER]: "partner" /* PARTNER */,
3849
- [EnumResourceType9.VENDOR]: "vendor" /* VENDOR */,
3850
- [EnumResourceType9.AFFILIATE]: "affiliate" /* AFFILIATE */,
3851
- [EnumResourceType9.SCHOOL]: "school" /* SCHOOL */
3941
+ [EnumResourceType10.EVENT]: "event" /* EVENT */,
3942
+ [EnumResourceType10.PARTNER]: "partner" /* PARTNER */,
3943
+ [EnumResourceType10.VENDOR]: "vendor" /* VENDOR */,
3944
+ [EnumResourceType10.AFFILIATE]: "affiliate" /* AFFILIATE */,
3945
+ [EnumResourceType10.SCHOOL]: "school" /* SCHOOL */
3852
3946
  };
3853
3947
  if (!isNonVisitorResourceType(resourceType)) {
3854
3948
  throw new GraphQLError(`Invalid resource type: ${resourceType}.`);
@@ -3997,7 +4091,7 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
3997
4091
  if (!stripe || stripe.currentPlan !== licenceType) {
3998
4092
  return false;
3999
4093
  }
4000
- const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? dayjs4(stripe.paymentGracePeriodEndsAt) : null;
4094
+ const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? dayjs5(stripe.paymentGracePeriodEndsAt) : null;
4001
4095
  const hasActivePaymentGracePeriod = (stripe.status === EnumSubscriptionStatus3.PAST_DUE || stripe.status === EnumSubscriptionStatus3.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
4002
4096
  if (hasActivePaymentGracePeriod) {
4003
4097
  return true;
@@ -4011,7 +4105,7 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
4011
4105
  if (!stripe.endDate) {
4012
4106
  return false;
4013
4107
  }
4014
- const paidThrough = dayjs4(stripe.endDate);
4108
+ const paidThrough = dayjs5(stripe.endDate);
4015
4109
  return paidThrough.isValid() && paidThrough.isAfter(now);
4016
4110
  }
4017
4111
  async function handleVendorLicenceCompliance(user, now) {
@@ -4028,7 +4122,7 @@ async function handleVendorLicenceCompliance(user, now) {
4028
4122
  (licence) => licence.licenceType !== EnumUserLicence9.STANDARD_VENDOR
4029
4123
  );
4030
4124
  const expiredProLicences = proLicences.filter(
4031
- (licence) => !dayjs4(licence.expiryDate).isAfter(now)
4125
+ (licence) => !dayjs5(licence.expiryDate).isAfter(now)
4032
4126
  );
4033
4127
  const stripeProtectedLicenceTypes = new Set(
4034
4128
  expiredProLicences.filter(
@@ -4040,7 +4134,7 @@ async function handleVendorLicenceCompliance(user, now) {
4040
4134
  );
4041
4135
  const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, vendorLicences, now);
4042
4136
  const hasExpiredVendorLicence = vendorLicencesOfUser.some(
4043
- (licence) => !dayjs4(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
4137
+ (licence) => !dayjs5(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
4044
4138
  );
4045
4139
  if (!hasExpiredVendorLicence) {
4046
4140
  return;
@@ -4094,9 +4188,9 @@ async function vendorOwnerHasProLicence(vendorId) {
4094
4188
  if (!owner) {
4095
4189
  return false;
4096
4190
  }
4097
- const now = dayjs4();
4191
+ const now = dayjs5();
4098
4192
  const effectiveVendorLicences = owner.licences?.filter(
4099
- (licence) => licence?.licenceType && (dayjs4(licence.expiryDate).isAfter(now) || isProtectedByCurrentStripeSubscription(
4193
+ (licence) => licence?.licenceType && (dayjs5(licence.expiryDate).isAfter(now) || isProtectedByCurrentStripeSubscription(
4100
4194
  owner,
4101
4195
  licence.licenceType,
4102
4196
  now
@@ -4133,7 +4227,7 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
4133
4227
  }
4134
4228
  function hasValidLicence(licences, licenceTypes, now) {
4135
4229
  return licences.some(
4136
- (licence) => licenceTypes.includes(licence.licenceType) && dayjs5(licence.expiryDate).isAfter(now)
4230
+ (licence) => licenceTypes.includes(licence.licenceType) && dayjs6(licence.expiryDate).isAfter(now)
4137
4231
  );
4138
4232
  }
4139
4233
  async function sendDeactivationNotification(payload, userId, resourceName, resourceType) {
@@ -4160,7 +4254,7 @@ async function processUserCompliance(user, now) {
4160
4254
  }
4161
4255
 
4162
4256
  // src/service/license/compliance/ensureUserLicenseCompliance.ts
4163
- async function ensureUserLicenseComplianceForUser(userId, now = dayjs6()) {
4257
+ async function ensureUserLicenseComplianceForUser(userId, now = dayjs7()) {
4164
4258
  const user = await UserModel.findById(userId);
4165
4259
  if (!user) {
4166
4260
  return;
@@ -4168,7 +4262,7 @@ async function ensureUserLicenseComplianceForUser(userId, now = dayjs6()) {
4168
4262
  await processUserCompliance(user, now);
4169
4263
  }
4170
4264
  async function ensureUserLicenseCompliance() {
4171
- const now = dayjs6();
4265
+ const now = dayjs7();
4172
4266
  console.log(`\u{1F50D} Checking license compliance at ${now.format()}`);
4173
4267
  const nowDate = now.toDate();
4174
4268
  const users = await UserModel.find({
@@ -4243,7 +4337,7 @@ async function getPartnerResourceInfo(userId, partnerId) {
4243
4337
  }
4244
4338
 
4245
4339
  // src/service/license/reminder/remindUsersAboutLicenseExpiration.ts
4246
- import dayjs8 from "dayjs";
4340
+ import dayjs9 from "dayjs";
4247
4341
 
4248
4342
  // src/service/license/reminder/reminderWindow.ts
4249
4343
  var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
@@ -4251,7 +4345,7 @@ var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
4251
4345
 
4252
4346
  // src/service/license/reminder/utils.ts
4253
4347
  import {
4254
- dateFormat,
4348
+ dateFormat as dateFormat2,
4255
4349
  EnumNotificationResourceType as EnumNotificationResourceType6,
4256
4350
  EnumNotificationType as EnumNotificationType5,
4257
4351
  EnumUserLicence as EnumUserLicence11,
@@ -4259,7 +4353,7 @@ import {
4259
4353
  vendorLicences as vendorLicences2
4260
4354
  } from "@timardex/cluemart-shared";
4261
4355
  import { formatDate } from "@timardex/cluemart-shared/utils";
4262
- import dayjs7 from "dayjs";
4356
+ import dayjs8 from "dayjs";
4263
4357
 
4264
4358
  // src/service/license/reminder/vendor.ts
4265
4359
  async function getVendorResourceInfo(userId, vendorId) {
@@ -4318,7 +4412,7 @@ async function checkAndCreateNotification(payload) {
4318
4412
  }
4319
4413
  }
4320
4414
  function isLicenseExpiringIn7Days(expiryDate, now) {
4321
- const expiry = dayjs7(expiryDate);
4415
+ const expiry = dayjs8(expiryDate);
4322
4416
  const hoursUntilExpiry = expiry.diff(now, "hour", true);
4323
4417
  return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
4324
4418
  }
@@ -4396,7 +4490,7 @@ function getLicenceExpiryMode(licenceType) {
4396
4490
  }
4397
4491
  async function sendLicenseReminder(user, licence) {
4398
4492
  const licenceName = getLicenseName(licence.licenceType);
4399
- const expiryDate = dayjs7(licence.expiryDate).format(dateFormat);
4493
+ const expiryDate = dayjs8(licence.expiryDate).format(dateFormat2);
4400
4494
  const userId = String(user._id);
4401
4495
  const resourceInfo = await getLicenseResourceInfo(user, licence);
4402
4496
  if (!resourceInfo) {
@@ -4428,7 +4522,7 @@ async function sendLicenseReminder(user, licence) {
4428
4522
  console.log(`\u2705 Sent 7-day reminder to user ${userId} for ${licenceName}`);
4429
4523
  }
4430
4524
  async function processLicenseReminder(licence, now) {
4431
- if (dayjs7(licence.expiryDate).isBefore(now)) {
4525
+ if (dayjs8(licence.expiryDate).isBefore(now)) {
4432
4526
  return false;
4433
4527
  }
4434
4528
  if (!isLicenseExpiringIn7Days(licence.expiryDate, now)) {
@@ -4482,7 +4576,7 @@ async function processUserLicenseReminders(user, now) {
4482
4576
 
4483
4577
  // src/service/license/reminder/remindUsersAboutLicenseExpiration.ts
4484
4578
  async function remindUsersAboutLicenseExpiration() {
4485
- const now = dayjs8();
4579
+ const now = dayjs9();
4486
4580
  console.log(`\u{1F50D} Checking for licenses expiring in 7 days at ${now.format()}`);
4487
4581
  const minExpiryDate = now.add(REMINDER_WINDOW_MIN_HOURS, "hour").toDate();
4488
4582
  const maxExpiryDate = now.add(REMINDER_WINDOW_MAX_HOURS, "hour").toDate();
@@ -4544,6 +4638,8 @@ export {
4544
4638
  EventModel,
4545
4639
  GameModel,
4546
4640
  GoogleImportedMarketModel,
4641
+ ImpersonationAuditModel,
4642
+ ImpersonationSessionModel,
4547
4643
  LicenceCategory,
4548
4644
  NotificationModel,
4549
4645
  OwnerTypeSchema,
@@ -4606,7 +4702,7 @@ export {
4606
4702
  locationGeoSchema,
4607
4703
  locationsSchema,
4608
4704
  mapVendorLicenceToSubscriptionRewardType,
4609
- mongoose34 as mongoose,
4705
+ mongoose35 as mongoose,
4610
4706
  normalizeAffiliatePromoCodes,
4611
4707
  normalizePromoCode,
4612
4708
  notifyUsers,