@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/{chunk-3JRVRK2N.mjs → chunk-YILYRHDN.mjs} +63 -21
- package/dist/chunk-YILYRHDN.mjs.map +1 -0
- package/dist/index.cjs +117 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +30 -6
- package/dist/index.d.ts +30 -6
- package/dist/index.mjs +114 -41
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +39 -19
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +6 -4
- package/dist/mongoose/index.d.ts +6 -4
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +117 -41
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +26 -4
- package/dist/service/index.d.ts +26 -4
- package/dist/service/index.mjs +56 -23
- package/dist/service/index.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/chunk-3JRVRK2N.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
|
|
2
|
-
import { AdType, ReportChatUser, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorProductList, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, CouponType, CouponDataType,
|
|
2
|
+
import { AdType, ReportChatUser, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorProductList, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, CouponType, CouponDataType, CouponParticipantUserType, ProductCoupon } from '@timardex/cluemart-shared';
|
|
3
3
|
import mongoose__default from 'mongoose';
|
|
4
4
|
import { O as ObjectId } from '../Chat-Wn7yfc3v.mjs';
|
|
5
5
|
export { C as ChatModel, N as NotificationModel, a as SchemaChatMessageReactionType, S as SchemaChatMessageReplyPreviewType, b as SchemaChatMessageSeenType, c as SchemaChatMessageType, e as SchemaChatType, f as SchemaCreateBulkNotificationInput, g as SchemaNotificationType, d as SchemaParticipantType } from '../Chat-Wn7yfc3v.mjs';
|
|
@@ -296,12 +296,14 @@ declare const SchoolModel: mongoose__default.Model<SchoolDocument, {}, {}, {}, m
|
|
|
296
296
|
type SchemaCouponParticipantUserType = Omit<CouponParticipantUserType, "userId"> & {
|
|
297
297
|
userId: ObjectId;
|
|
298
298
|
};
|
|
299
|
-
type
|
|
299
|
+
type SchemaCouponVendorProductType = {
|
|
300
|
+
couponId: ObjectId;
|
|
300
301
|
productId: ObjectId;
|
|
302
|
+
vendorCouponId?: ObjectId;
|
|
301
303
|
vendorId: ObjectId;
|
|
302
304
|
};
|
|
303
|
-
type SchemaCouponDataType = Omit<CouponDataType, "participantUsers" | "
|
|
304
|
-
|
|
305
|
+
type SchemaCouponDataType = Omit<CouponDataType, "participantUsers" | "couponVendorProducts"> & {
|
|
306
|
+
couponVendorProducts?: SchemaCouponVendorProductType[];
|
|
305
307
|
participantUsers: SchemaCouponParticipantUserType[] | null;
|
|
306
308
|
};
|
|
307
309
|
type SchemaProductCouponType = Omit<ProductCoupon, "couponDocumentId" | "couponId"> & {
|
package/dist/mongoose/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
|
|
2
|
-
import { AdType, ReportChatUser, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorProductList, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, CouponType, CouponDataType,
|
|
2
|
+
import { AdType, ReportChatUser, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorProductList, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, CouponType, CouponDataType, CouponParticipantUserType, ProductCoupon } from '@timardex/cluemart-shared';
|
|
3
3
|
import mongoose__default from 'mongoose';
|
|
4
4
|
import { O as ObjectId } from '../Chat-Wn7yfc3v.js';
|
|
5
5
|
export { C as ChatModel, N as NotificationModel, a as SchemaChatMessageReactionType, S as SchemaChatMessageReplyPreviewType, b as SchemaChatMessageSeenType, c as SchemaChatMessageType, e as SchemaChatType, f as SchemaCreateBulkNotificationInput, g as SchemaNotificationType, d as SchemaParticipantType } from '../Chat-Wn7yfc3v.js';
|
|
@@ -296,12 +296,14 @@ declare const SchoolModel: mongoose__default.Model<SchoolDocument, {}, {}, {}, m
|
|
|
296
296
|
type SchemaCouponParticipantUserType = Omit<CouponParticipantUserType, "userId"> & {
|
|
297
297
|
userId: ObjectId;
|
|
298
298
|
};
|
|
299
|
-
type
|
|
299
|
+
type SchemaCouponVendorProductType = {
|
|
300
|
+
couponId: ObjectId;
|
|
300
301
|
productId: ObjectId;
|
|
302
|
+
vendorCouponId?: ObjectId;
|
|
301
303
|
vendorId: ObjectId;
|
|
302
304
|
};
|
|
303
|
-
type SchemaCouponDataType = Omit<CouponDataType, "participantUsers" | "
|
|
304
|
-
|
|
305
|
+
type SchemaCouponDataType = Omit<CouponDataType, "participantUsers" | "couponVendorProducts"> & {
|
|
306
|
+
couponVendorProducts?: SchemaCouponVendorProductType[];
|
|
305
307
|
participantUsers: SchemaCouponParticipantUserType[] | null;
|
|
306
308
|
};
|
|
307
309
|
type SchemaProductCouponType = Omit<ProductCoupon, "couponDocumentId" | "couponId"> & {
|
package/dist/mongoose/index.mjs
CHANGED
package/dist/service/index.cjs
CHANGED
|
@@ -38,6 +38,9 @@ __export(service_exports, {
|
|
|
38
38
|
didRemoveAnyEventDates: () => didRemoveAnyEventDates,
|
|
39
39
|
findAffiliateByPromoCode: () => findAffiliateByPromoCode,
|
|
40
40
|
findEventOrImportedMarketById: () => findEventOrImportedMarketById,
|
|
41
|
+
getPayingEventStripeSubscriptionPlan: () => getPayingEventStripeSubscriptionPlan,
|
|
42
|
+
getPayingStripeSubscriptionPlan: () => getPayingStripeSubscriptionPlan,
|
|
43
|
+
getPayingVendorStripeSubscriptionPlan: () => getPayingVendorStripeSubscriptionPlan,
|
|
41
44
|
getSubscriptionRewardPeriodBounds: () => getSubscriptionRewardPeriodBounds,
|
|
42
45
|
isValidObjectId: () => isValidObjectId,
|
|
43
46
|
mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
|
|
@@ -3450,17 +3453,17 @@ var gameScreenIdentifierList = [
|
|
|
3450
3453
|
{
|
|
3451
3454
|
clue: "Where your actions turn into a timeline.",
|
|
3452
3455
|
id: "activities",
|
|
3453
|
-
match: "/profile/
|
|
3456
|
+
match: "/profile/account/favourites"
|
|
3454
3457
|
},
|
|
3455
3458
|
{
|
|
3456
3459
|
clue: "Where conversations happen without speaking.",
|
|
3457
3460
|
id: "chat",
|
|
3458
|
-
match: "/
|
|
3461
|
+
match: "/chat"
|
|
3459
3462
|
},
|
|
3460
3463
|
{
|
|
3461
3464
|
clue: "The place to redefine who you are.",
|
|
3462
3465
|
id: "edit-profile",
|
|
3463
|
-
match: "/profile/
|
|
3466
|
+
match: "/profile/account"
|
|
3464
3467
|
},
|
|
3465
3468
|
{
|
|
3466
3469
|
clue: "A single moment worth showing up for.",
|
|
@@ -3638,8 +3641,8 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
|
|
|
3638
3641
|
return EnumActivity2;
|
|
3639
3642
|
})(EnumActivity || {});
|
|
3640
3643
|
var EnumPostType = /* @__PURE__ */ ((EnumPostType2) => {
|
|
3641
|
-
EnumPostType2["MARKET_FACES"] = "market_faces";
|
|
3642
3644
|
EnumPostType2["CLUE_BITES"] = "clue_bites";
|
|
3645
|
+
EnumPostType2["MARKET_FACES"] = "market_faces";
|
|
3643
3646
|
EnumPostType2["PLAY_AND_WIN"] = "play_and_win";
|
|
3644
3647
|
return EnumPostType2;
|
|
3645
3648
|
})(EnumPostType || {});
|
|
@@ -3682,6 +3685,7 @@ var EnumAffiliateRewardType = /* @__PURE__ */ ((EnumAffiliateRewardType22) => {
|
|
|
3682
3685
|
var EnumCouponQualificationType = /* @__PURE__ */ ((EnumCouponQualificationType2) => {
|
|
3683
3686
|
EnumCouponQualificationType2["PURCHASE"] = "PURCHASE";
|
|
3684
3687
|
EnumCouponQualificationType2["MARKET_VISIT"] = "MARKET_VISIT";
|
|
3688
|
+
EnumCouponQualificationType2["MARKET_PASSPORT"] = "MARKET_PASSPORT";
|
|
3685
3689
|
return EnumCouponQualificationType2;
|
|
3686
3690
|
})(EnumCouponQualificationType || {});
|
|
3687
3691
|
var statusOptions = [
|
|
@@ -7822,20 +7826,22 @@ var COUPON_OPTION_FIELDS_FRAGMENT = gql`
|
|
|
7822
7826
|
visits
|
|
7823
7827
|
}
|
|
7824
7828
|
`;
|
|
7825
|
-
var
|
|
7826
|
-
fragment
|
|
7829
|
+
var COUPON_VENDOR_PRODUCT_FIELDS_FRAGMENT = gql`
|
|
7830
|
+
fragment CouponVendorProductFields on CouponVendorProductType {
|
|
7831
|
+
couponId
|
|
7827
7832
|
vendorId
|
|
7828
7833
|
productId
|
|
7829
|
-
|
|
7830
|
-
unit
|
|
7834
|
+
vendorCouponId
|
|
7831
7835
|
}
|
|
7832
7836
|
`;
|
|
7833
7837
|
var COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT = gql`
|
|
7834
7838
|
fragment CouponDataProductsFields on CouponDataProductsType {
|
|
7835
7839
|
active
|
|
7840
|
+
couponId
|
|
7836
7841
|
productsList {
|
|
7837
7842
|
...VendorProductListFields
|
|
7838
7843
|
}
|
|
7844
|
+
vendorId
|
|
7839
7845
|
vendorLogo {
|
|
7840
7846
|
...ResourceImageFields
|
|
7841
7847
|
}
|
|
@@ -7855,8 +7861,8 @@ var COUPON_DATA_FIELDS_FRAGMENT = gql`
|
|
|
7855
7861
|
couponOption {
|
|
7856
7862
|
...CouponOptionFields
|
|
7857
7863
|
}
|
|
7858
|
-
|
|
7859
|
-
...
|
|
7864
|
+
couponVendorProducts {
|
|
7865
|
+
...CouponVendorProductFields
|
|
7860
7866
|
}
|
|
7861
7867
|
createdAt
|
|
7862
7868
|
endDate
|
|
@@ -7874,7 +7880,7 @@ var COUPON_DATA_FIELDS_FRAGMENT = gql`
|
|
|
7874
7880
|
${COUPON_CODE_FIELDS_FRAGMENT}
|
|
7875
7881
|
${COUPON_OPTION_FIELDS_FRAGMENT}
|
|
7876
7882
|
${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
|
|
7877
|
-
${
|
|
7883
|
+
${COUPON_VENDOR_PRODUCT_FIELDS_FRAGMENT}
|
|
7878
7884
|
${COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT}
|
|
7879
7885
|
`;
|
|
7880
7886
|
var COUPON = gql`
|
|
@@ -7895,8 +7901,8 @@ var COUPON = gql`
|
|
|
7895
7901
|
${COUPON_DATA_FIELDS_FRAGMENT}
|
|
7896
7902
|
`;
|
|
7897
7903
|
var GET_COUPONS = gql`
|
|
7898
|
-
query getCoupons {
|
|
7899
|
-
coupons {
|
|
7904
|
+
query getCoupons($region: String, $category: String) {
|
|
7905
|
+
coupons(region: $region, category: $category) {
|
|
7900
7906
|
active {
|
|
7901
7907
|
listName
|
|
7902
7908
|
data {
|
|
@@ -7958,8 +7964,16 @@ var UPDATE_COUPON_MUTATION = gql`
|
|
|
7958
7964
|
${COUPON}
|
|
7959
7965
|
`;
|
|
7960
7966
|
var DELETE_COUPON_MUTATION = gql`
|
|
7961
|
-
mutation deleteCoupon($
|
|
7962
|
-
deleteCoupon(
|
|
7967
|
+
mutation deleteCoupon($input: ProductCouponInputType!) {
|
|
7968
|
+
deleteCoupon(input: $input) {
|
|
7969
|
+
data
|
|
7970
|
+
message
|
|
7971
|
+
}
|
|
7972
|
+
}
|
|
7973
|
+
`;
|
|
7974
|
+
var SCAN_COUPON_MUTATION = gql`
|
|
7975
|
+
mutation scanCoupon($input: ProductCouponInputType!) {
|
|
7976
|
+
scanCoupon(input: $input) {
|
|
7963
7977
|
data
|
|
7964
7978
|
message
|
|
7965
7979
|
}
|
|
@@ -8807,6 +8821,18 @@ var EnumRegions2 = /* @__PURE__ */ ((EnumRegions22) => {
|
|
|
8807
8821
|
EnumRegions22["Wellington"] = "Wellington";
|
|
8808
8822
|
return EnumRegions22;
|
|
8809
8823
|
})(EnumRegions2 || {});
|
|
8824
|
+
var EnumUserLicence2 = /* @__PURE__ */ ((EnumUserLicence22) => {
|
|
8825
|
+
EnumUserLicence22["PRO_EVENT"] = "pro_event";
|
|
8826
|
+
EnumUserLicence22["PRO_PLUS_EVENT"] = "pro_plus_event";
|
|
8827
|
+
EnumUserLicence22["PRO_PLUS_VENDOR"] = "pro_plus_vendor";
|
|
8828
|
+
EnumUserLicence22["PRO_VENDOR"] = "pro_vendor";
|
|
8829
|
+
EnumUserLicence22["STANDARD_EVENT"] = "standard_event";
|
|
8830
|
+
EnumUserLicence22["STANDARD_VENDOR"] = "standard_vendor";
|
|
8831
|
+
EnumUserLicence22["STANDARD_PARTNER"] = "standard_partner";
|
|
8832
|
+
EnumUserLicence22["STANDARD_AFFILIATE"] = "standard_affiliate";
|
|
8833
|
+
EnumUserLicence22["STANDARD_SCHOOL"] = "standard_school";
|
|
8834
|
+
return EnumUserLicence22;
|
|
8835
|
+
})(EnumUserLicence2 || {});
|
|
8810
8836
|
var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
8811
8837
|
EnumEventDateStatus22["STARTING_SOON"] = "Starting_Soon";
|
|
8812
8838
|
EnumEventDateStatus22["STARTED"] = "Started";
|
|
@@ -8821,6 +8847,15 @@ var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
|
8821
8847
|
EnumEventDateStatus22["INVALID"] = "Invalid";
|
|
8822
8848
|
return EnumEventDateStatus22;
|
|
8823
8849
|
})(EnumEventDateStatus2 || {});
|
|
8850
|
+
var EnumSubscriptionStatus2 = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
|
|
8851
|
+
EnumSubscriptionStatus22["ACTIVE"] = "active";
|
|
8852
|
+
EnumSubscriptionStatus22["INACTIVE"] = "inactive";
|
|
8853
|
+
EnumSubscriptionStatus22["CANCELLED"] = "cancelled";
|
|
8854
|
+
EnumSubscriptionStatus22["NO_SUBSCRIPTION"] = "no_subscription";
|
|
8855
|
+
EnumSubscriptionStatus22["PAST_DUE"] = "past_due";
|
|
8856
|
+
EnumSubscriptionStatus22["TRIALING"] = "trialing";
|
|
8857
|
+
return EnumSubscriptionStatus22;
|
|
8858
|
+
})(EnumSubscriptionStatus2 || {});
|
|
8824
8859
|
|
|
8825
8860
|
// src/mongoose/PushToken.ts
|
|
8826
8861
|
var import_mongoose9 = __toESM(require("mongoose"));
|
|
@@ -9137,14 +9172,20 @@ var couponOptionSchema = new MongooseSchema13(
|
|
|
9137
9172
|
},
|
|
9138
9173
|
{ _id: false }
|
|
9139
9174
|
);
|
|
9140
|
-
var
|
|
9175
|
+
var couponVendorProductSchema = new MongooseSchema13(
|
|
9141
9176
|
{
|
|
9177
|
+
couponId: {
|
|
9178
|
+
required: true,
|
|
9179
|
+
type: import_mongoose13.default.Schema.Types.ObjectId
|
|
9180
|
+
},
|
|
9142
9181
|
productId: {
|
|
9143
9182
|
required: true,
|
|
9144
9183
|
type: import_mongoose13.default.Schema.Types.ObjectId
|
|
9145
9184
|
},
|
|
9146
|
-
|
|
9147
|
-
|
|
9185
|
+
vendorCouponId: {
|
|
9186
|
+
required: false,
|
|
9187
|
+
type: import_mongoose13.default.Schema.Types.ObjectId
|
|
9188
|
+
},
|
|
9148
9189
|
vendorId: {
|
|
9149
9190
|
ref: "Vendor",
|
|
9150
9191
|
required: true,
|
|
@@ -9179,7 +9220,10 @@ var couponDataSchema = new MongooseSchema13(
|
|
|
9179
9220
|
couponCode: { required: true, type: couponCodeSchema },
|
|
9180
9221
|
couponDescription: { required: true, type: String },
|
|
9181
9222
|
couponOption: { required: true, type: couponOptionSchema },
|
|
9182
|
-
|
|
9223
|
+
couponVendorProducts: {
|
|
9224
|
+
required: false,
|
|
9225
|
+
type: [couponVendorProductSchema]
|
|
9226
|
+
},
|
|
9183
9227
|
endDate: { required: true, type: Date },
|
|
9184
9228
|
participantUsers: {
|
|
9185
9229
|
default: null,
|
|
@@ -9976,7 +10020,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
9976
10020
|
school: "School"
|
|
9977
10021
|
};
|
|
9978
10022
|
|
|
9979
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10023
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-5D2JVHC2.mjs
|
|
9980
10024
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
9981
10025
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
9982
10026
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -9984,17 +10028,17 @@ var gameScreenIdentifierList2 = [
|
|
|
9984
10028
|
{
|
|
9985
10029
|
clue: "Where your actions turn into a timeline.",
|
|
9986
10030
|
id: "activities",
|
|
9987
|
-
match: "/profile/
|
|
10031
|
+
match: "/profile/account/favourites"
|
|
9988
10032
|
},
|
|
9989
10033
|
{
|
|
9990
10034
|
clue: "Where conversations happen without speaking.",
|
|
9991
10035
|
id: "chat",
|
|
9992
|
-
match: "/
|
|
10036
|
+
match: "/chat"
|
|
9993
10037
|
},
|
|
9994
10038
|
{
|
|
9995
10039
|
clue: "The place to redefine who you are.",
|
|
9996
10040
|
id: "edit-profile",
|
|
9997
|
-
match: "/profile/
|
|
10041
|
+
match: "/profile/account"
|
|
9998
10042
|
},
|
|
9999
10043
|
{
|
|
10000
10044
|
clue: "A single moment worth showing up for.",
|
|
@@ -10078,7 +10122,7 @@ var gameScreenIdentifierList2 = [
|
|
|
10078
10122
|
}
|
|
10079
10123
|
];
|
|
10080
10124
|
|
|
10081
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10125
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-P4JLZCWZ.mjs
|
|
10082
10126
|
var import_dayjs4 = __toESM(require("dayjs"), 1);
|
|
10083
10127
|
var statusOptions2 = [
|
|
10084
10128
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -11255,19 +11299,56 @@ async function sendPushNotifications({
|
|
|
11255
11299
|
}
|
|
11256
11300
|
}
|
|
11257
11301
|
|
|
11258
|
-
// src/service/
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11302
|
+
// src/service/license.ts
|
|
11303
|
+
var PRO_EVENT_PLANS = /* @__PURE__ */ new Set([
|
|
11304
|
+
EnumUserLicence2.PRO_EVENT,
|
|
11305
|
+
EnumUserLicence2.PRO_PLUS_EVENT
|
|
11306
|
+
]);
|
|
11307
|
+
var PRO_VENDOR_PLANS = /* @__PURE__ */ new Set([
|
|
11308
|
+
EnumUserLicence2.PRO_VENDOR,
|
|
11309
|
+
EnumUserLicence2.PRO_PLUS_VENDOR
|
|
11310
|
+
]);
|
|
11311
|
+
var PRO_PLANS = /* @__PURE__ */ new Set([
|
|
11312
|
+
...PRO_EVENT_PLANS,
|
|
11313
|
+
...PRO_VENDOR_PLANS
|
|
11314
|
+
]);
|
|
11315
|
+
async function getPayingStripePlanFor(userId, now, payingPlans) {
|
|
11316
|
+
const user = await UserModel.findById(userId).select("licences stripe").lean().exec();
|
|
11317
|
+
if (!user) {
|
|
11318
|
+
return { hasSubscription: false, plan: null, validTypes: /* @__PURE__ */ new Set() };
|
|
11319
|
+
}
|
|
11320
|
+
const stripe = user.stripe;
|
|
11321
|
+
const licences = user.licences ?? [];
|
|
11264
11322
|
const validTypes = new Set(
|
|
11265
|
-
|
|
11323
|
+
licences.filter(
|
|
11266
11324
|
(licence) => new Date(licence.expiryDate).getTime() > now.getTime()
|
|
11267
11325
|
).map((licence) => licence.licenceType)
|
|
11268
11326
|
);
|
|
11327
|
+
if (stripe == null || stripe.subscriptionId == null) {
|
|
11328
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11329
|
+
}
|
|
11330
|
+
const hasActiveStatus = stripe.status === EnumSubscriptionStatus2.ACTIVE || stripe.status === EnumSubscriptionStatus2.TRIALING;
|
|
11331
|
+
if (!hasActiveStatus || stripe.currentPlan == null) {
|
|
11332
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11333
|
+
}
|
|
11334
|
+
const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
|
|
11335
|
+
return { hasSubscription: plan != null, plan, validTypes };
|
|
11336
|
+
}
|
|
11337
|
+
async function getPayingStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11338
|
+
return getPayingStripePlanFor(userId, now, PRO_PLANS);
|
|
11339
|
+
}
|
|
11340
|
+
async function getPayingVendorStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11341
|
+
return getPayingStripePlanFor(userId, now, PRO_VENDOR_PLANS);
|
|
11342
|
+
}
|
|
11343
|
+
async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11344
|
+
return getPayingStripePlanFor(userId, now, PRO_EVENT_PLANS);
|
|
11345
|
+
}
|
|
11346
|
+
|
|
11347
|
+
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
11348
|
+
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
11349
|
+
const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
|
|
11269
11350
|
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
11270
|
-
if (
|
|
11351
|
+
if (hasSubscription) {
|
|
11271
11352
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
11272
11353
|
}
|
|
11273
11354
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
@@ -11315,14 +11396,6 @@ async function isEligibleReferredVendor({
|
|
|
11315
11396
|
}).exec();
|
|
11316
11397
|
return Boolean(match);
|
|
11317
11398
|
}
|
|
11318
|
-
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
11319
|
-
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
11320
|
-
return mapVendorLicenceToSubscriptionRewardType(
|
|
11321
|
-
vendorOwner?.licences,
|
|
11322
|
-
now,
|
|
11323
|
-
vendorOwner?.stripe
|
|
11324
|
-
);
|
|
11325
|
-
}
|
|
11326
11399
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
11327
11400
|
affiliateId,
|
|
11328
11401
|
affiliateOwnerUserId,
|
|
@@ -11412,7 +11485,7 @@ async function processAffiliateVendorReferral({
|
|
|
11412
11485
|
if (!vendorEligible) {
|
|
11413
11486
|
return "skipped";
|
|
11414
11487
|
}
|
|
11415
|
-
const rewardType = await
|
|
11488
|
+
const rewardType = await mapVendorLicenceToSubscriptionRewardType(
|
|
11416
11489
|
resource.resourceOwner.userId,
|
|
11417
11490
|
now
|
|
11418
11491
|
);
|
|
@@ -11830,6 +11903,9 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
11830
11903
|
didRemoveAnyEventDates,
|
|
11831
11904
|
findAffiliateByPromoCode,
|
|
11832
11905
|
findEventOrImportedMarketById,
|
|
11906
|
+
getPayingEventStripeSubscriptionPlan,
|
|
11907
|
+
getPayingStripeSubscriptionPlan,
|
|
11908
|
+
getPayingVendorStripeSubscriptionPlan,
|
|
11833
11909
|
getSubscriptionRewardPeriodBounds,
|
|
11834
11910
|
isValidObjectId,
|
|
11835
11911
|
mapVendorLicenceToSubscriptionRewardType,
|