@timardex/cluemart-server-shared 1.0.299 → 1.0.301

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, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, SocialShareResourceType, PosterUsageType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, EnumAffiliateRewardType, PromoCodeType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
2
+ import { AdType, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, SocialShareResourceType, PosterUsageType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, EnumAffiliateRewardType, PromoCodeType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
3
  import * as mongoose from 'mongoose';
4
4
  import mongoose__default from 'mongoose';
5
5
  export { default as mongoose } from 'mongoose';
@@ -160,15 +160,6 @@ declare const userLicenseSchema: mongoose__default.Schema<UserLicenceType, mongo
160
160
  } & {
161
161
  __v: number;
162
162
  }>;
163
- declare const associatesSchema: mongoose__default.Schema<AssociateType, mongoose__default.Model<AssociateType, any, any, any, mongoose__default.Document<unknown, any, AssociateType, any, {}> & AssociateType & {
164
- _id: mongoose__default.Types.ObjectId;
165
- } & {
166
- __v: number;
167
- }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, AssociateType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<AssociateType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<AssociateType> & {
168
- _id: mongoose__default.Types.ObjectId;
169
- } & {
170
- __v: number;
171
- }>;
172
163
  declare const ContactDetailsSchema: mongoose__default.Schema<ResourceContactDetailsType, mongoose__default.Model<ResourceContactDetailsType, any, any, any, mongoose__default.Document<unknown, any, ResourceContactDetailsType, any, {}> & ResourceContactDetailsType & {
173
164
  _id: mongoose__default.Types.ObjectId;
174
165
  } & {
@@ -282,18 +273,6 @@ declare const baseResourceFields: {
282
273
  required: boolean;
283
274
  type: DateConstructor;
284
275
  };
285
- associates: {
286
- required: boolean;
287
- type: mongoose__default.Schema<AssociateType, mongoose__default.Model<AssociateType, any, any, any, mongoose__default.Document<unknown, any, AssociateType, any, {}> & AssociateType & {
288
- _id: mongoose__default.Types.ObjectId;
289
- } & {
290
- __v: number;
291
- }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, AssociateType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<AssociateType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<AssociateType> & {
292
- _id: mongoose__default.Types.ObjectId;
293
- } & {
294
- __v: number;
295
- }>[];
296
- };
297
276
  contactDetails: {
298
277
  required: boolean;
299
278
  type: mongoose__default.Schema<ResourceContactDetailsType, mongoose__default.Model<ResourceContactDetailsType, any, any, any, mongoose__default.Document<unknown, any, ResourceContactDetailsType, any, {}> & ResourceContactDetailsType & {
@@ -785,8 +764,9 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
785
764
  * - Vendor is active, not deleted, and `promoCodes` includes the affiliate code
786
765
  * - Vendor owner has a non-expired Standard / Pro / Pro+ vendor licence
787
766
  *
788
- * Reward type follows the owner's highest valid licence:
789
- * - Pro / Pro+ → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
767
+ * Reward type follows the owner's highest valid licence + Stripe paying status:
768
+ * - Pro / Pro+ with active Stripe → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
769
+ * - Pro / Pro+ without paying Stripe → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
790
770
  * - Standard → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
791
771
  *
792
772
  * Idempotent per affiliate + vendor + reward type + calendar month.
@@ -867,9 +847,11 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
867
847
  * Maps a vendor owner's highest valid vendor licence to a monthly subscription reward.
868
848
  *
869
849
  * Prefer Pro / Pro+ over Standard when both are valid.
850
+ * Pro / Pro+ only yields the Pro reward when the owner has an active Stripe subscription;
851
+ * otherwise falls back to the Standard subscription reward.
870
852
  * Returns `null` when no non-expired vendor licence applies.
871
853
  */
872
- declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date): EnumAffiliateRewardType | null;
854
+ declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date, stripe?: UserType["stripe"] | null): EnumAffiliateRewardType | null;
873
855
  /** Inclusive start / exclusive end of the UTC calendar month containing `now`. */
874
856
  declare function getSubscriptionRewardPeriodBounds(now?: Date): {
875
857
  periodEnd: Date;
@@ -973,4 +955,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
973
955
  */
974
956
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
975
957
 
976
- export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, 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 SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, associatesSchema, awardAffiliateVendorSubscriptionRewards, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
958
+ export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, 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 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, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, SocialShareResourceType, PosterUsageType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, EnumAffiliateRewardType, PromoCodeType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
2
+ import { AdType, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, SocialShareResourceType, PosterUsageType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, EnumAffiliateRewardType, PromoCodeType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
3
  import * as mongoose from 'mongoose';
4
4
  import mongoose__default from 'mongoose';
5
5
  export { default as mongoose } from 'mongoose';
@@ -160,15 +160,6 @@ declare const userLicenseSchema: mongoose__default.Schema<UserLicenceType, mongo
160
160
  } & {
161
161
  __v: number;
162
162
  }>;
163
- declare const associatesSchema: mongoose__default.Schema<AssociateType, mongoose__default.Model<AssociateType, any, any, any, mongoose__default.Document<unknown, any, AssociateType, any, {}> & AssociateType & {
164
- _id: mongoose__default.Types.ObjectId;
165
- } & {
166
- __v: number;
167
- }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, AssociateType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<AssociateType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<AssociateType> & {
168
- _id: mongoose__default.Types.ObjectId;
169
- } & {
170
- __v: number;
171
- }>;
172
163
  declare const ContactDetailsSchema: mongoose__default.Schema<ResourceContactDetailsType, mongoose__default.Model<ResourceContactDetailsType, any, any, any, mongoose__default.Document<unknown, any, ResourceContactDetailsType, any, {}> & ResourceContactDetailsType & {
173
164
  _id: mongoose__default.Types.ObjectId;
174
165
  } & {
@@ -282,18 +273,6 @@ declare const baseResourceFields: {
282
273
  required: boolean;
283
274
  type: DateConstructor;
284
275
  };
285
- associates: {
286
- required: boolean;
287
- type: mongoose__default.Schema<AssociateType, mongoose__default.Model<AssociateType, any, any, any, mongoose__default.Document<unknown, any, AssociateType, any, {}> & AssociateType & {
288
- _id: mongoose__default.Types.ObjectId;
289
- } & {
290
- __v: number;
291
- }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, AssociateType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<AssociateType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<AssociateType> & {
292
- _id: mongoose__default.Types.ObjectId;
293
- } & {
294
- __v: number;
295
- }>[];
296
- };
297
276
  contactDetails: {
298
277
  required: boolean;
299
278
  type: mongoose__default.Schema<ResourceContactDetailsType, mongoose__default.Model<ResourceContactDetailsType, any, any, any, mongoose__default.Document<unknown, any, ResourceContactDetailsType, any, {}> & ResourceContactDetailsType & {
@@ -785,8 +764,9 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
785
764
  * - Vendor is active, not deleted, and `promoCodes` includes the affiliate code
786
765
  * - Vendor owner has a non-expired Standard / Pro / Pro+ vendor licence
787
766
  *
788
- * Reward type follows the owner's highest valid licence:
789
- * - Pro / Pro+ → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
767
+ * Reward type follows the owner's highest valid licence + Stripe paying status:
768
+ * - Pro / Pro+ with active Stripe → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
769
+ * - Pro / Pro+ without paying Stripe → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
790
770
  * - Standard → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
791
771
  *
792
772
  * Idempotent per affiliate + vendor + reward type + calendar month.
@@ -867,9 +847,11 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
867
847
  * Maps a vendor owner's highest valid vendor licence to a monthly subscription reward.
868
848
  *
869
849
  * Prefer Pro / Pro+ over Standard when both are valid.
850
+ * Pro / Pro+ only yields the Pro reward when the owner has an active Stripe subscription;
851
+ * otherwise falls back to the Standard subscription reward.
870
852
  * Returns `null` when no non-expired vendor licence applies.
871
853
  */
872
- declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date): EnumAffiliateRewardType | null;
854
+ declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date, stripe?: UserType["stripe"] | null): EnumAffiliateRewardType | null;
873
855
  /** Inclusive start / exclusive end of the UTC calendar month containing `now`. */
874
856
  declare function getSubscriptionRewardPeriodBounds(now?: Date): {
875
857
  periodEnd: Date;
@@ -973,4 +955,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
973
955
  */
974
956
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
975
957
 
976
- export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, 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 SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, associatesSchema, awardAffiliateVendorSubscriptionRewards, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
958
+ export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, 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 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, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
package/dist/index.mjs CHANGED
@@ -3278,9 +3278,6 @@ var EnumRelationResource = /* @__PURE__ */ ((EnumRelationResource22) => {
3278
3278
  return EnumRelationResource22;
3279
3279
  })(EnumRelationResource || {});
3280
3280
  var EnumNotificationResourceType = /* @__PURE__ */ ((EnumNotificationResourceType22) => {
3281
- EnumNotificationResourceType22["ADDED_AS_ASSOCIATE_EVENT"] = "added_as_associate_event";
3282
- EnumNotificationResourceType22["ADDED_AS_ASSOCIATE_PARTNER"] = "added_as_associate_partner";
3283
- EnumNotificationResourceType22["ADDED_AS_ASSOCIATE_VENDOR"] = "added_as_associate_vendor";
3284
3281
  EnumNotificationResourceType22["APPROVED_AFFILIATE"] = "approved_affiliate";
3285
3282
  EnumNotificationResourceType22["AFFILIATE_REWARD_RECEIVED"] = "affiliate_reward_received";
3286
3283
  EnumNotificationResourceType22["APPROVED_EVENT"] = "approved_event";
@@ -4944,17 +4941,6 @@ var LICENCE_FIELDS_FRAGMENT = gql`
4944
4941
  prevLicenceType
4945
4942
  }
4946
4943
  `;
4947
- var ASSOCIATES_FIELDS_FRAGMENT = gql`
4948
- fragment AssociatesFields on AssociateType {
4949
- email
4950
- resourceId
4951
- resourceType
4952
- licence {
4953
- ...LicenceFields
4954
- }
4955
- }
4956
- ${LICENCE_FIELDS_FRAGMENT}
4957
- `;
4958
4944
  var TERMS_AGREEMENT_FIELDS_FRAGMENT = gql`
4959
4945
  fragment TermsAgreementFields on TermsAgreementType {
4960
4946
  appBuildNumber
@@ -5045,9 +5031,6 @@ var USER_FIELDS_FRAGMENT = gql`
5045
5031
  fragment UserFields on UserType {
5046
5032
  _id
5047
5033
  active
5048
- associates {
5049
- ...AssociatesFields
5050
- }
5051
5034
  affiliate
5052
5035
  avatar {
5053
5036
  ...ResourceImageFields
@@ -5087,7 +5070,6 @@ var USER_FIELDS_FRAGMENT = gql`
5087
5070
  updatedAt
5088
5071
  }
5089
5072
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5090
- ${ASSOCIATES_FIELDS_FRAGMENT}
5091
5073
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
5092
5074
  ${USER_ACTIVITY_FIELDS_FRAGMENT}
5093
5075
  ${LICENCE_FIELDS_FRAGMENT}
@@ -5233,9 +5215,6 @@ var EVENT = gql`
5233
5215
  fragment EventFields on EventType {
5234
5216
  _id
5235
5217
  active
5236
- associates {
5237
- ...AssociatesFields
5238
- }
5239
5218
  adIds
5240
5219
  approvedAt
5241
5220
  cover {
@@ -5308,7 +5287,6 @@ var EVENT = gql`
5308
5287
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5309
5288
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
5310
5289
  ${POSTER_USAGE_FIELDS_FRAGMENT}
5311
- ${ASSOCIATES_FIELDS_FRAGMENT}
5312
5290
  ${CONTACT_DETAILS_FIELDS_FRAGMENT}
5313
5291
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
5314
5292
  ${RELATION_DATES_FRAGMENT}
@@ -5421,9 +5399,6 @@ var VENDOR = gql`
5421
5399
  fragment VendorFields on VendorType {
5422
5400
  _id
5423
5401
  active
5424
- associates {
5425
- ...AssociatesFields
5426
- }
5427
5402
  adIds
5428
5403
  approvedAt
5429
5404
  availability {
@@ -5514,7 +5489,6 @@ var VENDOR = gql`
5514
5489
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5515
5490
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
5516
5491
  ${POSTER_USAGE_FIELDS_FRAGMENT}
5517
- ${ASSOCIATES_FIELDS_FRAGMENT}
5518
5492
  ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
5519
5493
  ${CONTACT_DETAILS_FIELDS_FRAGMENT}
5520
5494
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
@@ -5667,9 +5641,6 @@ var PARTNER = gql`
5667
5641
  fragment PartnerFields on PartnerType {
5668
5642
  _id
5669
5643
  active
5670
- associates {
5671
- ...AssociatesFields
5672
- }
5673
5644
  adIds
5674
5645
  approvedAt
5675
5646
  cover {
@@ -5720,7 +5691,6 @@ var PARTNER = gql`
5720
5691
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
5721
5692
  ${LOCATION_FIELDS_FRAGMENT}
5722
5693
  ${OWNER_FIELDS_FRAGMENT}
5723
- ${ASSOCIATES_FIELDS_FRAGMENT}
5724
5694
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5725
5695
  ${POSTER_USAGE_FIELDS_FRAGMENT}
5726
5696
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
@@ -6167,7 +6137,6 @@ var CHAT_MESSAGE_FIELDS_FRAGMENT = gql`
6167
6137
  var CHAT_PARTICIPANT = gql`
6168
6138
  fragment ChatParticipantFields on ChatParticipantType {
6169
6139
  active
6170
- isAssociate
6171
6140
  userAvatar
6172
6141
  userEmail
6173
6142
  userId
@@ -7645,7 +7614,6 @@ var MessageSchema = new MongooseSchema2(
7645
7614
  var ParticipantSchema = new MongooseSchema2(
7646
7615
  {
7647
7616
  active: { default: true, required: true, type: Boolean },
7648
- isAssociate: { default: null, required: false, type: Boolean },
7649
7617
  userAvatar: { required: false, type: String },
7650
7618
  userEmail: { required: true, type: String },
7651
7619
  userId: {
@@ -7970,26 +7938,6 @@ var userLicenseSchema = new MongooseSchema6(
7970
7938
  },
7971
7939
  { _id: false, timestamps: false }
7972
7940
  );
7973
- var associatesSchema = new MongooseSchema6(
7974
- {
7975
- email: { required: true, type: String },
7976
- licence: {
7977
- required: true,
7978
- type: userLicenseSchema
7979
- },
7980
- resourceId: {
7981
- required: true,
7982
- type: String
7983
- },
7984
- resourceType: {
7985
- enum: Object.values(EnumResourceType),
7986
- required: true,
7987
- type: String
7988
- }
7989
- },
7990
- { _id: false }
7991
- // Prevents Mongoose from creating an additional _id field for subdocuments
7992
- );
7993
7941
  var ContactDetailsSchema = new MongooseSchema6(
7994
7942
  {
7995
7943
  email: { required: false, type: String },
@@ -8105,10 +8053,6 @@ var baseResourceFields = {
8105
8053
  type: [mongoose6.Schema.Types.ObjectId]
8106
8054
  },
8107
8055
  approvedAt: { default: null, required: false, type: Date },
8108
- associates: {
8109
- required: false,
8110
- type: [associatesSchema]
8111
- },
8112
8056
  contactDetails: { required: false, type: ContactDetailsSchema },
8113
8057
  cover: {
8114
8058
  required: true,
@@ -8252,7 +8196,7 @@ schema4.index({ isRead: 1, userId: 1 });
8252
8196
  schema4.index({ createdAt: -1, userId: 1 });
8253
8197
  var NotificationModel = mongoose8.models.Notification || mongoose8.model("Notification", schema4);
8254
8198
 
8255
- // node_modules/@timardex/cluemart-shared/dist/chunk-VR3TDBJL.mjs
8199
+ // node_modules/@timardex/cluemart-shared/dist/chunk-X3OLM35T.mjs
8256
8200
  var EnumOSPlatform2 = /* @__PURE__ */ ((EnumOSPlatform22) => {
8257
8201
  EnumOSPlatform22["ANDROID"] = "android";
8258
8202
  EnumOSPlatform22["IOS"] = "ios";
@@ -8413,10 +8357,6 @@ var schema7 = new MongooseSchema11(
8413
8357
  required: false,
8414
8358
  type: mongoose11.Schema.Types.ObjectId
8415
8359
  },
8416
- associates: {
8417
- required: false,
8418
- type: [associatesSchema]
8419
- },
8420
8360
  avatar: {
8421
8361
  required: false,
8422
8362
  type: ResourceImageTypeSchema
@@ -8516,7 +8456,6 @@ var schema7 = new MongooseSchema11(
8516
8456
  },
8517
8457
  { strict: false, timestamps: true }
8518
8458
  );
8519
- schema7.index({ "associates.email": 1 });
8520
8459
  schema7.index({ "licences.expiryDate": 1 });
8521
8460
  schema7.index({ "licences.licenceType": 1 });
8522
8461
  var UserModel = mongoose11.models.User || mongoose11.model("User", schema7);
@@ -8634,7 +8573,6 @@ schema9.index({ name: 1 });
8634
8573
  schema9.index({ description: 1 });
8635
8574
  schema9.index({ region: 1 });
8636
8575
  schema9.index({ "categories.name": 1 });
8637
- schema9.index({ "associates.email": 1 });
8638
8576
  schema9.index({ slug: 1 });
8639
8577
  var VendorModel = mongoose13.models.Vendor || mongoose13.model("Vendor", schema9);
8640
8578
 
@@ -8773,7 +8711,6 @@ schema12.index({ description: 1 });
8773
8711
  schema12.index({ region: 1 });
8774
8712
  schema12.index({ "location.geo": "2dsphere" });
8775
8713
  schema12.index({ tags: 1 });
8776
- schema12.index({ "associates.email": 1 });
8777
8714
  schema12.index({ deletedAt: 1 });
8778
8715
  schema12.index({ "dateTime.dateStatus": 1 });
8779
8716
  schema12.index({ slug: 1 });
@@ -8802,7 +8739,6 @@ schema13.index({ name: 1 });
8802
8739
  schema13.index({ description: 1 });
8803
8740
  schema13.index({ region: 1 });
8804
8741
  schema13.index({ "location.geo": "2dsphere" });
8805
- schema13.index({ "associates.email": 1 });
8806
8742
  schema13.index({ slug: 1 });
8807
8743
  var PartnerModel = mongoose17.models.Partner || mongoose17.model("Partner", schema13);
8808
8744
 
@@ -9420,14 +9356,21 @@ function createAffiliateReward(rewardType, createdAt) {
9420
9356
  }
9421
9357
 
9422
9358
  // src/service/affiliate/vendorSubscriptionRewards.ts
9423
- function mapVendorLicenceToSubscriptionRewardType(licences, now = /* @__PURE__ */ new Date()) {
9359
+ function isPayingStripeSubscription(stripe) {
9360
+ if (!stripe?.subscriptionId) return false;
9361
+ return stripe.status === EnumSubscriptionStatus.ACTIVE || stripe.status === EnumSubscriptionStatus.TRIALING;
9362
+ }
9363
+ function mapVendorLicenceToSubscriptionRewardType(licences, now = /* @__PURE__ */ new Date(), stripe) {
9424
9364
  const validTypes = new Set(
9425
9365
  (licences ?? []).filter(
9426
9366
  (licence) => new Date(licence.expiryDate).getTime() > now.getTime()
9427
9367
  ).map((licence) => licence.licenceType)
9428
9368
  );
9429
9369
  if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
9430
- return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
9370
+ if (isPayingStripeSubscription(stripe)) {
9371
+ return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
9372
+ }
9373
+ return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
9431
9374
  }
9432
9375
  if (validTypes.has(EnumUserLicence.STANDARD_VENDOR)) {
9433
9376
  return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
@@ -9469,8 +9412,12 @@ async function findEligibleReferredVendor(resourceId, affiliateCode) {
9469
9412
  }).select("_id name owner.userId").lean().exec();
9470
9413
  }
9471
9414
  async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
9472
- const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences").lean().exec();
9473
- return mapVendorLicenceToSubscriptionRewardType(vendorOwner?.licences, now);
9415
+ const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
9416
+ return mapVendorLicenceToSubscriptionRewardType(
9417
+ vendorOwner?.licences,
9418
+ now,
9419
+ vendorOwner?.stripe
9420
+ );
9474
9421
  }
9475
9422
  async function notifyAffiliateOwnerOfSubscriptionReward({
9476
9423
  affiliateId,
@@ -9751,112 +9698,6 @@ async function updateAdStatuses() {
9751
9698
  );
9752
9699
  }
9753
9700
 
9754
- // src/service/associate.ts
9755
- import mongoose28 from "mongoose";
9756
- function normalizeObjectId(id) {
9757
- return typeof id === "string" ? new mongoose28.Types.ObjectId(id) : id;
9758
- }
9759
- async function getAssociateEmailsForResource({
9760
- normalizedResourceId,
9761
- resourceType
9762
- }) {
9763
- const usersWithAssociates = await UserModel.find(
9764
- {
9765
- associates: {
9766
- $elemMatch: {
9767
- resourceId: normalizedResourceId,
9768
- resourceType
9769
- }
9770
- }
9771
- },
9772
- {
9773
- associates: 1
9774
- }
9775
- ).lean();
9776
- return [
9777
- ...new Set(
9778
- usersWithAssociates.flatMap(
9779
- (user) => (user.associates ?? []).filter(
9780
- (associate) => associate.resourceId === normalizedResourceId && associate.resourceType === resourceType
9781
- ).map((associate) => associate.email)
9782
- )
9783
- )
9784
- ];
9785
- }
9786
- async function pullAssociatesFromUsers({
9787
- normalizedResourceId,
9788
- resourceType
9789
- }) {
9790
- await UserModel.updateMany(
9791
- {
9792
- associates: {
9793
- $elemMatch: {
9794
- resourceId: normalizedResourceId,
9795
- resourceType
9796
- }
9797
- }
9798
- },
9799
- {
9800
- $pull: {
9801
- associates: {
9802
- resourceId: normalizedResourceId,
9803
- resourceType
9804
- }
9805
- }
9806
- }
9807
- );
9808
- }
9809
- async function pullAssociateParticipantsFromChats(resourceOwnerId, associateEmails) {
9810
- await ChatModel.updateMany(
9811
- {
9812
- active: true,
9813
- chatType: EnumChatType.RELATION,
9814
- deletedAt: null,
9815
- participants: {
9816
- $elemMatch: {
9817
- userId: resourceOwnerId
9818
- }
9819
- }
9820
- },
9821
- {
9822
- $pull: {
9823
- participants: {
9824
- isAssociate: true,
9825
- userEmail: {
9826
- $in: associateEmails
9827
- }
9828
- }
9829
- }
9830
- }
9831
- );
9832
- }
9833
- async function removeAssociateFromResource({
9834
- resourceId,
9835
- resourceOwnerId,
9836
- resourceType
9837
- }) {
9838
- try {
9839
- const scope = {
9840
- normalizedResourceId: resourceId.toString(),
9841
- resourceType
9842
- };
9843
- const associateEmails = await getAssociateEmailsForResource(scope);
9844
- if (associateEmails.length === 0) {
9845
- return;
9846
- }
9847
- await pullAssociatesFromUsers(scope);
9848
- await pullAssociateParticipantsFromChats(
9849
- normalizeObjectId(resourceOwnerId),
9850
- associateEmails
9851
- );
9852
- } catch (error) {
9853
- console.error(
9854
- `[removeAssociateFromResource] Failed for resourceId=${resourceId}, resourceType=${resourceType}`,
9855
- error
9856
- );
9857
- }
9858
- }
9859
-
9860
9701
  // src/service/vendor.ts
9861
9702
  async function updateVendorBasedOnUserLicense(userId, licenceType) {
9862
9703
  try {
@@ -9873,7 +9714,6 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
9873
9714
  const updateData = {};
9874
9715
  const isStandardVendor = licenceType === EnumUserLicence.STANDARD_VENDOR;
9875
9716
  if (isStandardVendor) {
9876
- updateData.associates = [];
9877
9717
  updateData.availability = {
9878
9718
  corporate: false,
9879
9719
  private: false,
@@ -9893,25 +9733,18 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
9893
9733
  active: isStandardVendor ? index < 6 : true
9894
9734
  }));
9895
9735
  await VendorModel.updateOne({ _id: vendor._id }, { $set: updateData });
9896
- if (isStandardVendor) {
9897
- await removeAssociateFromResource({
9898
- resourceId: vendor._id,
9899
- resourceOwnerId: vendor.owner.userId,
9900
- resourceType: EnumResourceType.VENDOR
9901
- });
9902
- }
9903
9736
  } catch (error) {
9904
9737
  console.error("[updateVendorBasedOnUserLicense] Failed:", error);
9905
9738
  }
9906
9739
  }
9907
9740
 
9908
9741
  // src/service/objectIdToString.ts
9909
- import mongoose29 from "mongoose";
9742
+ import mongoose28 from "mongoose";
9910
9743
  function convertObjectIdsToStrings(obj) {
9911
9744
  if (obj === null || obj === void 0) {
9912
9745
  return obj;
9913
9746
  }
9914
- if (obj instanceof mongoose29.Types.ObjectId) {
9747
+ if (obj instanceof mongoose28.Types.ObjectId) {
9915
9748
  return obj.toString();
9916
9749
  }
9917
9750
  if (obj instanceof Date) {
@@ -10126,7 +9959,6 @@ export {
10126
9959
  VendorModel,
10127
9960
  VerificationTokenModel,
10128
9961
  activeAffiliateCodeExists,
10129
- associatesSchema,
10130
9962
  awardAffiliateVendorSubscriptionRewards,
10131
9963
  baseResourceFields,
10132
9964
  connectToDatabase,