@timardex/cluemart-server-shared 1.1.21 → 1.1.24

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, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, SocialShareResourceType, PosterUsageType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorProductList, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, CouponType, CouponDataType, CouponReward, CouponParticipantUserType, ProductCoupon, PromoCodeType, EnumAffiliateRewardType, 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, VendorProductList, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, CouponType, CouponDataType, CouponParticipantUserType, ProductCoupon, PromoCodeType, EnumAffiliateRewardType, 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';
@@ -7,6 +7,7 @@ import { NotificationCount, DateTimeType as DateTimeType$1 } from '@timardex/clu
7
7
  import express from 'express';
8
8
  export { default as express } from 'express';
9
9
  import dayjs from 'dayjs';
10
+ import { EnumUserLicence as EnumUserLicence$1 } from '@timardex/cluemart-shared/enums';
10
11
 
11
12
  declare const AdModel: mongoose__default.Model<AdType, {}, {}, {}, mongoose__default.Document<unknown, {}, AdType, {}, {}> & AdType & Required<{
12
13
  _id: string;
@@ -761,12 +762,14 @@ declare const AffiliateModel: mongoose__default.Model<AffiliateDocument, {}, {},
761
762
  type SchemaCouponParticipantUserType = Omit<CouponParticipantUserType, "userId"> & {
762
763
  userId: ObjectId;
763
764
  };
764
- type SchemaCouponRewardType = Omit<CouponReward, "productId" | "vendorId"> & {
765
+ type SchemaCouponVendorProductType = {
766
+ couponId: ObjectId;
765
767
  productId: ObjectId;
768
+ vendorCouponId?: ObjectId;
766
769
  vendorId: ObjectId;
767
770
  };
768
- type SchemaCouponDataType = Omit<CouponDataType, "participantUsers" | "couponRewards"> & {
769
- couponRewards?: SchemaCouponRewardType[];
771
+ type SchemaCouponDataType = Omit<CouponDataType, "participantUsers" | "couponVendorProducts"> & {
772
+ couponVendorProducts?: SchemaCouponVendorProductType[];
770
773
  participantUsers: SchemaCouponParticipantUserType[] | null;
771
774
  };
772
775
  type SchemaProductCouponType = Omit<ProductCoupon, "couponDocumentId" | "couponId"> & {
@@ -871,7 +874,7 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
871
874
  * otherwise falls back to the Standard subscription reward.
872
875
  * Returns `null` when no non-expired vendor licence applies.
873
876
  */
874
- declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date, stripe?: UserType["stripe"] | null): EnumAffiliateRewardType | null;
877
+ declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
875
878
  /** Inclusive start / exclusive end of the UTC calendar month containing `now`. */
876
879
  declare function getSubscriptionRewardPeriodBounds(now?: Date): {
877
880
  periodEnd: Date;
@@ -979,4 +982,25 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
979
982
  */
980
983
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
981
984
 
982
- export { ACTIVE_NOT_DELETED_FILTER, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, 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, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, isValidObjectId, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, productCouponSchema, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, vendorProductTypeSchema };
985
+ type PayingStripeSubscriptionPlanResult = {
986
+ hasSubscription: boolean;
987
+ plan: EnumUserLicence$1 | null;
988
+ validTypes: Set<EnumUserLicence$1>;
989
+ };
990
+ /**
991
+ * Returns the paying Stripe plan when `currentPlan` is any PRO plan
992
+ * (event or vendor) and the subscription is active/trialing.
993
+ */
994
+ declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
995
+ /**
996
+ * Like {@link getPayingStripeSubscriptionPlan} but only treats a vendor PRO
997
+ * plan (`PRO_VENDOR` / `PRO_PLUS_VENDOR`) as paying.
998
+ */
999
+ declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1000
+ /**
1001
+ * Like {@link getPayingStripeSubscriptionPlan} but only treats an event PRO
1002
+ * plan (`PRO_EVENT` / `PRO_PLUS_EVENT`) as paying.
1003
+ */
1004
+ declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1005
+
1006
+ export { ACTIVE_NOT_DELETED_FILTER, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, 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, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, isValidObjectId, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, productCouponSchema, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, 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, 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, VendorProductList, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, CouponType, CouponDataType, CouponReward, CouponParticipantUserType, ProductCoupon, PromoCodeType, EnumAffiliateRewardType, 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, VendorProductList, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, CouponType, CouponDataType, CouponParticipantUserType, ProductCoupon, PromoCodeType, EnumAffiliateRewardType, 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';
@@ -7,6 +7,7 @@ import { NotificationCount, DateTimeType as DateTimeType$1 } from '@timardex/clu
7
7
  import express from 'express';
8
8
  export { default as express } from 'express';
9
9
  import dayjs from 'dayjs';
10
+ import { EnumUserLicence as EnumUserLicence$1 } from '@timardex/cluemart-shared/enums';
10
11
 
11
12
  declare const AdModel: mongoose__default.Model<AdType, {}, {}, {}, mongoose__default.Document<unknown, {}, AdType, {}, {}> & AdType & Required<{
12
13
  _id: string;
@@ -761,12 +762,14 @@ declare const AffiliateModel: mongoose__default.Model<AffiliateDocument, {}, {},
761
762
  type SchemaCouponParticipantUserType = Omit<CouponParticipantUserType, "userId"> & {
762
763
  userId: ObjectId;
763
764
  };
764
- type SchemaCouponRewardType = Omit<CouponReward, "productId" | "vendorId"> & {
765
+ type SchemaCouponVendorProductType = {
766
+ couponId: ObjectId;
765
767
  productId: ObjectId;
768
+ vendorCouponId?: ObjectId;
766
769
  vendorId: ObjectId;
767
770
  };
768
- type SchemaCouponDataType = Omit<CouponDataType, "participantUsers" | "couponRewards"> & {
769
- couponRewards?: SchemaCouponRewardType[];
771
+ type SchemaCouponDataType = Omit<CouponDataType, "participantUsers" | "couponVendorProducts"> & {
772
+ couponVendorProducts?: SchemaCouponVendorProductType[];
770
773
  participantUsers: SchemaCouponParticipantUserType[] | null;
771
774
  };
772
775
  type SchemaProductCouponType = Omit<ProductCoupon, "couponDocumentId" | "couponId"> & {
@@ -871,7 +874,7 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
871
874
  * otherwise falls back to the Standard subscription reward.
872
875
  * Returns `null` when no non-expired vendor licence applies.
873
876
  */
874
- declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date, stripe?: UserType["stripe"] | null): EnumAffiliateRewardType | null;
877
+ declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
875
878
  /** Inclusive start / exclusive end of the UTC calendar month containing `now`. */
876
879
  declare function getSubscriptionRewardPeriodBounds(now?: Date): {
877
880
  periodEnd: Date;
@@ -979,4 +982,25 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
979
982
  */
980
983
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
981
984
 
982
- export { ACTIVE_NOT_DELETED_FILTER, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, 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, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, isValidObjectId, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, productCouponSchema, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, vendorProductTypeSchema };
985
+ type PayingStripeSubscriptionPlanResult = {
986
+ hasSubscription: boolean;
987
+ plan: EnumUserLicence$1 | null;
988
+ validTypes: Set<EnumUserLicence$1>;
989
+ };
990
+ /**
991
+ * Returns the paying Stripe plan when `currentPlan` is any PRO plan
992
+ * (event or vendor) and the subscription is active/trialing.
993
+ */
994
+ declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
995
+ /**
996
+ * Like {@link getPayingStripeSubscriptionPlan} but only treats a vendor PRO
997
+ * plan (`PRO_VENDOR` / `PRO_PLUS_VENDOR`) as paying.
998
+ */
999
+ declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1000
+ /**
1001
+ * Like {@link getPayingStripeSubscriptionPlan} but only treats an event PRO
1002
+ * plan (`PRO_EVENT` / `PRO_PLUS_EVENT`) as paying.
1003
+ */
1004
+ declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1005
+
1006
+ export { ACTIVE_NOT_DELETED_FILTER, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, 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, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, isValidObjectId, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, productCouponSchema, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, vendorProductTypeSchema };
package/dist/index.mjs CHANGED
@@ -3393,17 +3393,17 @@ var gameScreenIdentifierList = [
3393
3393
  {
3394
3394
  clue: "Where your actions turn into a timeline.",
3395
3395
  id: "activities",
3396
- match: "/profile/activities"
3396
+ match: "/profile/account/favourites"
3397
3397
  },
3398
3398
  {
3399
3399
  clue: "Where conversations happen without speaking.",
3400
3400
  id: "chat",
3401
- match: "/profile/chat"
3401
+ match: "/chat"
3402
3402
  },
3403
3403
  {
3404
3404
  clue: "The place to redefine who you are.",
3405
3405
  id: "edit-profile",
3406
- match: "/profile/edit-profile"
3406
+ match: "/profile/account"
3407
3407
  },
3408
3408
  {
3409
3409
  clue: "A single moment worth showing up for.",
@@ -3581,8 +3581,8 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
3581
3581
  return EnumActivity2;
3582
3582
  })(EnumActivity || {});
3583
3583
  var EnumPostType = /* @__PURE__ */ ((EnumPostType2) => {
3584
- EnumPostType2["MARKET_FACES"] = "market_faces";
3585
3584
  EnumPostType2["CLUE_BITES"] = "clue_bites";
3585
+ EnumPostType2["MARKET_FACES"] = "market_faces";
3586
3586
  EnumPostType2["PLAY_AND_WIN"] = "play_and_win";
3587
3587
  return EnumPostType2;
3588
3588
  })(EnumPostType || {});
@@ -3625,6 +3625,7 @@ var EnumAffiliateRewardType = /* @__PURE__ */ ((EnumAffiliateRewardType22) => {
3625
3625
  var EnumCouponQualificationType = /* @__PURE__ */ ((EnumCouponQualificationType2) => {
3626
3626
  EnumCouponQualificationType2["PURCHASE"] = "PURCHASE";
3627
3627
  EnumCouponQualificationType2["MARKET_VISIT"] = "MARKET_VISIT";
3628
+ EnumCouponQualificationType2["MARKET_PASSPORT"] = "MARKET_PASSPORT";
3628
3629
  return EnumCouponQualificationType2;
3629
3630
  })(EnumCouponQualificationType || {});
3630
3631
  var statusOptions = [
@@ -7765,20 +7766,22 @@ var COUPON_OPTION_FIELDS_FRAGMENT = gql`
7765
7766
  visits
7766
7767
  }
7767
7768
  `;
7768
- var COUPON_REWARD_FIELDS_FRAGMENT = gql`
7769
- fragment CouponRewardFields on CouponRewardType {
7769
+ var COUPON_VENDOR_PRODUCT_FIELDS_FRAGMENT = gql`
7770
+ fragment CouponVendorProductFields on CouponVendorProductType {
7771
+ couponId
7770
7772
  vendorId
7771
7773
  productId
7772
- quantity
7773
- unit
7774
+ vendorCouponId
7774
7775
  }
7775
7776
  `;
7776
7777
  var COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT = gql`
7777
7778
  fragment CouponDataProductsFields on CouponDataProductsType {
7778
7779
  active
7780
+ couponId
7779
7781
  productsList {
7780
7782
  ...VendorProductListFields
7781
7783
  }
7784
+ vendorId
7782
7785
  vendorLogo {
7783
7786
  ...ResourceImageFields
7784
7787
  }
@@ -7798,8 +7801,8 @@ var COUPON_DATA_FIELDS_FRAGMENT = gql`
7798
7801
  couponOption {
7799
7802
  ...CouponOptionFields
7800
7803
  }
7801
- couponRewards {
7802
- ...CouponRewardFields
7804
+ couponVendorProducts {
7805
+ ...CouponVendorProductFields
7803
7806
  }
7804
7807
  createdAt
7805
7808
  endDate
@@ -7817,7 +7820,7 @@ var COUPON_DATA_FIELDS_FRAGMENT = gql`
7817
7820
  ${COUPON_CODE_FIELDS_FRAGMENT}
7818
7821
  ${COUPON_OPTION_FIELDS_FRAGMENT}
7819
7822
  ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
7820
- ${COUPON_REWARD_FIELDS_FRAGMENT}
7823
+ ${COUPON_VENDOR_PRODUCT_FIELDS_FRAGMENT}
7821
7824
  ${COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT}
7822
7825
  `;
7823
7826
  var COUPON = gql`
@@ -7838,8 +7841,8 @@ var COUPON = gql`
7838
7841
  ${COUPON_DATA_FIELDS_FRAGMENT}
7839
7842
  `;
7840
7843
  var GET_COUPONS = gql`
7841
- query getCoupons {
7842
- coupons {
7844
+ query getCoupons($region: String, $category: String) {
7845
+ coupons(region: $region, category: $category) {
7843
7846
  active {
7844
7847
  listName
7845
7848
  data {
@@ -7901,8 +7904,16 @@ var UPDATE_COUPON_MUTATION = gql`
7901
7904
  ${COUPON}
7902
7905
  `;
7903
7906
  var DELETE_COUPON_MUTATION = gql`
7904
- mutation deleteCoupon($couponDocumentId: ID!, $couponId: ID!) {
7905
- deleteCoupon(couponDocumentId: $couponDocumentId, couponId: $couponId) {
7907
+ mutation deleteCoupon($input: ProductCouponInputType!) {
7908
+ deleteCoupon(input: $input) {
7909
+ data
7910
+ message
7911
+ }
7912
+ }
7913
+ `;
7914
+ var SCAN_COUPON_MUTATION = gql`
7915
+ mutation scanCoupon($input: ProductCouponInputType!) {
7916
+ scanCoupon(input: $input) {
7906
7917
  data
7907
7918
  message
7908
7919
  }
@@ -8750,6 +8761,18 @@ var EnumRegions2 = /* @__PURE__ */ ((EnumRegions22) => {
8750
8761
  EnumRegions22["Wellington"] = "Wellington";
8751
8762
  return EnumRegions22;
8752
8763
  })(EnumRegions2 || {});
8764
+ var EnumUserLicence2 = /* @__PURE__ */ ((EnumUserLicence22) => {
8765
+ EnumUserLicence22["PRO_EVENT"] = "pro_event";
8766
+ EnumUserLicence22["PRO_PLUS_EVENT"] = "pro_plus_event";
8767
+ EnumUserLicence22["PRO_PLUS_VENDOR"] = "pro_plus_vendor";
8768
+ EnumUserLicence22["PRO_VENDOR"] = "pro_vendor";
8769
+ EnumUserLicence22["STANDARD_EVENT"] = "standard_event";
8770
+ EnumUserLicence22["STANDARD_VENDOR"] = "standard_vendor";
8771
+ EnumUserLicence22["STANDARD_PARTNER"] = "standard_partner";
8772
+ EnumUserLicence22["STANDARD_AFFILIATE"] = "standard_affiliate";
8773
+ EnumUserLicence22["STANDARD_SCHOOL"] = "standard_school";
8774
+ return EnumUserLicence22;
8775
+ })(EnumUserLicence2 || {});
8753
8776
  var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
8754
8777
  EnumEventDateStatus22["STARTING_SOON"] = "Starting_Soon";
8755
8778
  EnumEventDateStatus22["STARTED"] = "Started";
@@ -8764,6 +8787,15 @@ var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
8764
8787
  EnumEventDateStatus22["INVALID"] = "Invalid";
8765
8788
  return EnumEventDateStatus22;
8766
8789
  })(EnumEventDateStatus2 || {});
8790
+ var EnumSubscriptionStatus2 = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
8791
+ EnumSubscriptionStatus22["ACTIVE"] = "active";
8792
+ EnumSubscriptionStatus22["INACTIVE"] = "inactive";
8793
+ EnumSubscriptionStatus22["CANCELLED"] = "cancelled";
8794
+ EnumSubscriptionStatus22["NO_SUBSCRIPTION"] = "no_subscription";
8795
+ EnumSubscriptionStatus22["PAST_DUE"] = "past_due";
8796
+ EnumSubscriptionStatus22["TRIALING"] = "trialing";
8797
+ return EnumSubscriptionStatus22;
8798
+ })(EnumSubscriptionStatus2 || {});
8767
8799
 
8768
8800
  // src/mongoose/PushToken.ts
8769
8801
  import mongoose9 from "mongoose";
@@ -9080,14 +9112,20 @@ var couponOptionSchema = new MongooseSchema13(
9080
9112
  },
9081
9113
  { _id: false }
9082
9114
  );
9083
- var couponRewardSchema = new MongooseSchema13(
9115
+ var couponVendorProductSchema = new MongooseSchema13(
9084
9116
  {
9117
+ couponId: {
9118
+ required: true,
9119
+ type: mongoose13.Schema.Types.ObjectId
9120
+ },
9085
9121
  productId: {
9086
9122
  required: true,
9087
9123
  type: mongoose13.Schema.Types.ObjectId
9088
9124
  },
9089
- quantity: { required: true, type: Number },
9090
- unit: { required: true, type: String },
9125
+ vendorCouponId: {
9126
+ required: false,
9127
+ type: mongoose13.Schema.Types.ObjectId
9128
+ },
9091
9129
  vendorId: {
9092
9130
  ref: "Vendor",
9093
9131
  required: true,
@@ -9122,7 +9160,10 @@ var couponDataSchema = new MongooseSchema13(
9122
9160
  couponCode: { required: true, type: couponCodeSchema },
9123
9161
  couponDescription: { required: true, type: String },
9124
9162
  couponOption: { required: true, type: couponOptionSchema },
9125
- couponRewards: { required: false, type: [couponRewardSchema] },
9163
+ couponVendorProducts: {
9164
+ required: false,
9165
+ type: [couponVendorProductSchema]
9166
+ },
9126
9167
  endDate: { required: true, type: Date },
9127
9168
  participantUsers: {
9128
9169
  default: null,
@@ -9919,7 +9960,7 @@ var SHARE_RESOURCE_LABEL2 = {
9919
9960
  school: "School"
9920
9961
  };
9921
9962
 
9922
- // node_modules/@timardex/cluemart-shared/dist/chunk-Q3X2EHHF.mjs
9963
+ // node_modules/@timardex/cluemart-shared/dist/chunk-5D2JVHC2.mjs
9923
9964
  var PROMO_CODE_PREFIX2 = "CM-";
9924
9965
  var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
9925
9966
  var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
@@ -9927,17 +9968,17 @@ var gameScreenIdentifierList2 = [
9927
9968
  {
9928
9969
  clue: "Where your actions turn into a timeline.",
9929
9970
  id: "activities",
9930
- match: "/profile/activities"
9971
+ match: "/profile/account/favourites"
9931
9972
  },
9932
9973
  {
9933
9974
  clue: "Where conversations happen without speaking.",
9934
9975
  id: "chat",
9935
- match: "/profile/chat"
9976
+ match: "/chat"
9936
9977
  },
9937
9978
  {
9938
9979
  clue: "The place to redefine who you are.",
9939
9980
  id: "edit-profile",
9940
- match: "/profile/edit-profile"
9981
+ match: "/profile/account"
9941
9982
  },
9942
9983
  {
9943
9984
  clue: "A single moment worth showing up for.",
@@ -10021,7 +10062,7 @@ var gameScreenIdentifierList2 = [
10021
10062
  }
10022
10063
  ];
10023
10064
 
10024
- // node_modules/@timardex/cluemart-shared/dist/chunk-UGWEWOUM.mjs
10065
+ // node_modules/@timardex/cluemart-shared/dist/chunk-P4JLZCWZ.mjs
10025
10066
  import dayjs4 from "dayjs";
10026
10067
  var statusOptions2 = [
10027
10068
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -11198,19 +11239,56 @@ async function sendPushNotifications({
11198
11239
  }
11199
11240
  }
11200
11241
 
11201
- // src/service/affiliate/vendorSubscriptionRewards.ts
11202
- function isPayingStripeSubscription(stripe) {
11203
- if (!stripe?.subscriptionId) return false;
11204
- return (stripe.status === EnumSubscriptionStatus.ACTIVE || stripe.status === EnumSubscriptionStatus.TRIALING) && (stripe.currentPlan === EnumUserLicence.PRO_VENDOR || stripe.currentPlan === EnumUserLicence.PRO_PLUS_VENDOR);
11205
- }
11206
- function mapVendorLicenceToSubscriptionRewardType(licences, now = /* @__PURE__ */ new Date(), stripe) {
11242
+ // src/service/license.ts
11243
+ var PRO_EVENT_PLANS = /* @__PURE__ */ new Set([
11244
+ EnumUserLicence2.PRO_EVENT,
11245
+ EnumUserLicence2.PRO_PLUS_EVENT
11246
+ ]);
11247
+ var PRO_VENDOR_PLANS = /* @__PURE__ */ new Set([
11248
+ EnumUserLicence2.PRO_VENDOR,
11249
+ EnumUserLicence2.PRO_PLUS_VENDOR
11250
+ ]);
11251
+ var PRO_PLANS = /* @__PURE__ */ new Set([
11252
+ ...PRO_EVENT_PLANS,
11253
+ ...PRO_VENDOR_PLANS
11254
+ ]);
11255
+ async function getPayingStripePlanFor(userId, now, payingPlans) {
11256
+ const user = await UserModel.findById(userId).select("licences stripe").lean().exec();
11257
+ if (!user) {
11258
+ return { hasSubscription: false, plan: null, validTypes: /* @__PURE__ */ new Set() };
11259
+ }
11260
+ const stripe = user.stripe;
11261
+ const licences = user.licences ?? [];
11207
11262
  const validTypes = new Set(
11208
- (licences ?? []).filter(
11263
+ licences.filter(
11209
11264
  (licence) => new Date(licence.expiryDate).getTime() > now.getTime()
11210
11265
  ).map((licence) => licence.licenceType)
11211
11266
  );
11267
+ if (stripe == null || stripe.subscriptionId == null) {
11268
+ return { hasSubscription: false, plan: null, validTypes };
11269
+ }
11270
+ const hasActiveStatus = stripe.status === EnumSubscriptionStatus2.ACTIVE || stripe.status === EnumSubscriptionStatus2.TRIALING;
11271
+ if (!hasActiveStatus || stripe.currentPlan == null) {
11272
+ return { hasSubscription: false, plan: null, validTypes };
11273
+ }
11274
+ const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
11275
+ return { hasSubscription: plan != null, plan, validTypes };
11276
+ }
11277
+ async function getPayingStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
11278
+ return getPayingStripePlanFor(userId, now, PRO_PLANS);
11279
+ }
11280
+ async function getPayingVendorStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
11281
+ return getPayingStripePlanFor(userId, now, PRO_VENDOR_PLANS);
11282
+ }
11283
+ async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
11284
+ return getPayingStripePlanFor(userId, now, PRO_EVENT_PLANS);
11285
+ }
11286
+
11287
+ // src/service/affiliate/vendorSubscriptionRewards.ts
11288
+ async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
11289
+ const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
11212
11290
  if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
11213
- if (isPayingStripeSubscription(stripe)) {
11291
+ if (hasSubscription) {
11214
11292
  return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
11215
11293
  }
11216
11294
  return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
@@ -11258,14 +11336,6 @@ async function isEligibleReferredVendor({
11258
11336
  }).exec();
11259
11337
  return Boolean(match);
11260
11338
  }
11261
- async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
11262
- const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
11263
- return mapVendorLicenceToSubscriptionRewardType(
11264
- vendorOwner?.licences,
11265
- now,
11266
- vendorOwner?.stripe
11267
- );
11268
- }
11269
11339
  async function notifyAffiliateOwnerOfSubscriptionReward({
11270
11340
  affiliateId,
11271
11341
  affiliateOwnerUserId,
@@ -11355,7 +11425,7 @@ async function processAffiliateVendorReferral({
11355
11425
  if (!vendorEligible) {
11356
11426
  return "skipped";
11357
11427
  }
11358
- const rewardType = await resolveSubscriptionRewardTypeForVendorOwner(
11428
+ const rewardType = await mapVendorLicenceToSubscriptionRewardType(
11359
11429
  resource.resourceOwner.userId,
11360
11430
  now
11361
11431
  );
@@ -11813,6 +11883,9 @@ export {
11813
11883
  express,
11814
11884
  findAffiliateByPromoCode,
11815
11885
  findEventOrImportedMarketById,
11886
+ getPayingEventStripeSubscriptionPlan,
11887
+ getPayingStripeSubscriptionPlan,
11888
+ getPayingVendorStripeSubscriptionPlan,
11816
11889
  getSubscriptionRewardPeriodBounds,
11817
11890
  isValidObjectId,
11818
11891
  locationGeoSchema,