@timardex/cluemart-server-shared 1.1.19 → 1.1.20
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-XOFBUTNJ.mjs → chunk-WDKTIULG.mjs} +158 -109
- package/dist/chunk-WDKTIULG.mjs.map +1 -0
- package/dist/index.cjs +167 -127
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +167 -127
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +157 -108
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +167 -127
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +2 -2
- package/dist/service/index.d.ts +2 -2
- package/dist/service/index.mjs +11 -20
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-XOFBUTNJ.mjs.map +0 -1
package/dist/mongoose/index.mjs
CHANGED
package/dist/service/index.cjs
CHANGED
|
@@ -4981,6 +4981,12 @@ var OWNER_FIELDS_FRAGMENT = gql`
|
|
|
4981
4981
|
userId
|
|
4982
4982
|
}
|
|
4983
4983
|
`;
|
|
4984
|
+
var PRODUCT_COUPON_FIELDS_FRAGMENT = gql`
|
|
4985
|
+
fragment ProductCouponFields on ProductCouponType {
|
|
4986
|
+
couponDocumentId
|
|
4987
|
+
couponId
|
|
4988
|
+
}
|
|
4989
|
+
`;
|
|
4984
4990
|
var CATEGORY_FIELDS_FRAGMENT = gql`
|
|
4985
4991
|
fragment CategoryFields on CategoryType {
|
|
4986
4992
|
id
|
|
@@ -5454,109 +5460,6 @@ var GET_EVENT_INFO = gql`
|
|
|
5454
5460
|
}
|
|
5455
5461
|
${EVENT_INFO}
|
|
5456
5462
|
`;
|
|
5457
|
-
var PRODUCT_COUPON_FIELDS_FRAGMENT = gql`
|
|
5458
|
-
fragment ProductCouponFields on ProductCouponType {
|
|
5459
|
-
couponDocumentId
|
|
5460
|
-
couponId
|
|
5461
|
-
}
|
|
5462
|
-
`;
|
|
5463
|
-
var COUPON_CODE_FIELDS_FRAGMENT = gql`
|
|
5464
|
-
fragment CouponCodeFields on CouponCodeType {
|
|
5465
|
-
code
|
|
5466
|
-
qrCode {
|
|
5467
|
-
...ResourceImageFields
|
|
5468
|
-
}
|
|
5469
|
-
}
|
|
5470
|
-
${RESOURCE_IMAGE_FIELDS_FRAGMENT}
|
|
5471
|
-
`;
|
|
5472
|
-
var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
|
|
5473
|
-
fragment CouponParticipantUserFields on CouponParticipantUserType {
|
|
5474
|
-
couponCollectedCount
|
|
5475
|
-
couponRedeemedAt
|
|
5476
|
-
createdAt
|
|
5477
|
-
updatedAt
|
|
5478
|
-
userId
|
|
5479
|
-
}
|
|
5480
|
-
`;
|
|
5481
|
-
var COUPON_OPTION_FIELDS_FRAGMENT = gql`
|
|
5482
|
-
fragment CouponOptionFields on CouponOptionType {
|
|
5483
|
-
type
|
|
5484
|
-
buy
|
|
5485
|
-
get
|
|
5486
|
-
unit
|
|
5487
|
-
visits
|
|
5488
|
-
}
|
|
5489
|
-
`;
|
|
5490
|
-
var COUPON_REWARD_FIELDS_FRAGMENT = gql`
|
|
5491
|
-
fragment CouponRewardFields on CouponRewardType {
|
|
5492
|
-
vendorId
|
|
5493
|
-
productId
|
|
5494
|
-
quantity
|
|
5495
|
-
unit
|
|
5496
|
-
}
|
|
5497
|
-
`;
|
|
5498
|
-
var COUPON_DATA_FIELDS_FRAGMENT = gql`
|
|
5499
|
-
fragment CouponDataFields on CouponDataType {
|
|
5500
|
-
_id
|
|
5501
|
-
active
|
|
5502
|
-
couponCode {
|
|
5503
|
-
...CouponCodeFields
|
|
5504
|
-
}
|
|
5505
|
-
couponDescription
|
|
5506
|
-
couponOption {
|
|
5507
|
-
...CouponOptionFields
|
|
5508
|
-
}
|
|
5509
|
-
couponRewards {
|
|
5510
|
-
...CouponRewardFields
|
|
5511
|
-
}
|
|
5512
|
-
createdAt
|
|
5513
|
-
endDate
|
|
5514
|
-
participantUsers {
|
|
5515
|
-
...CouponParticipantUserFields
|
|
5516
|
-
}
|
|
5517
|
-
resourceId
|
|
5518
|
-
resourceType
|
|
5519
|
-
startDate
|
|
5520
|
-
updatedAt
|
|
5521
|
-
}
|
|
5522
|
-
${COUPON_CODE_FIELDS_FRAGMENT}
|
|
5523
|
-
${COUPON_OPTION_FIELDS_FRAGMENT}
|
|
5524
|
-
${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
|
|
5525
|
-
${COUPON_REWARD_FIELDS_FRAGMENT}
|
|
5526
|
-
`;
|
|
5527
|
-
var COUPON = gql`
|
|
5528
|
-
fragment CouponFields on CouponType {
|
|
5529
|
-
_id
|
|
5530
|
-
active
|
|
5531
|
-
couponData {
|
|
5532
|
-
...CouponDataFields
|
|
5533
|
-
}
|
|
5534
|
-
createdAt
|
|
5535
|
-
deletedAt
|
|
5536
|
-
owner {
|
|
5537
|
-
...OwnerFields
|
|
5538
|
-
}
|
|
5539
|
-
updatedAt
|
|
5540
|
-
}
|
|
5541
|
-
${OWNER_FIELDS_FRAGMENT}
|
|
5542
|
-
${COUPON_DATA_FIELDS_FRAGMENT}
|
|
5543
|
-
`;
|
|
5544
|
-
var GET_COUPONS = gql`
|
|
5545
|
-
query getCoupons {
|
|
5546
|
-
coupons {
|
|
5547
|
-
...CouponFields
|
|
5548
|
-
}
|
|
5549
|
-
}
|
|
5550
|
-
${COUPON}
|
|
5551
|
-
`;
|
|
5552
|
-
var GET_COUPON = gql`
|
|
5553
|
-
query getCoupon($_id: ID!) {
|
|
5554
|
-
coupon(_id: $_id) {
|
|
5555
|
-
...CouponFields
|
|
5556
|
-
}
|
|
5557
|
-
}
|
|
5558
|
-
${COUPON}
|
|
5559
|
-
`;
|
|
5560
5463
|
var VENDOR_DATETIME_FIELDS_FRAGMENT = gql`
|
|
5561
5464
|
fragment VendorDateTimeFields on VendorDateTimeType {
|
|
5562
5465
|
dateStatus
|
|
@@ -5583,6 +5486,15 @@ var VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT = gql`
|
|
|
5583
5486
|
}
|
|
5584
5487
|
${PRODUCT_COUPON_FIELDS_FRAGMENT}
|
|
5585
5488
|
`;
|
|
5489
|
+
var VENDOR_PRODUCTS_FIELDS_FRAGMENT = gql`
|
|
5490
|
+
fragment VendorProductsFields on VendorProductsType {
|
|
5491
|
+
active
|
|
5492
|
+
productsList {
|
|
5493
|
+
...VendorProductListFields
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
|
|
5497
|
+
`;
|
|
5586
5498
|
var VENDOR = gql`
|
|
5587
5499
|
fragment VendorFields on VendorType {
|
|
5588
5500
|
_id
|
|
@@ -5632,10 +5544,7 @@ var VENDOR = gql`
|
|
|
5632
5544
|
...OwnerFields
|
|
5633
5545
|
}
|
|
5634
5546
|
products {
|
|
5635
|
-
|
|
5636
|
-
productsList {
|
|
5637
|
-
...VendorProductListFields
|
|
5638
|
-
}
|
|
5547
|
+
...VendorProductsFields
|
|
5639
5548
|
}
|
|
5640
5549
|
promoCodes
|
|
5641
5550
|
posterUsage {
|
|
@@ -5677,7 +5586,7 @@ var VENDOR = gql`
|
|
|
5677
5586
|
${RESOURCE_IMAGE_FIELDS_FRAGMENT}
|
|
5678
5587
|
${SOCIAL_MEDIA_FIELDS_FRAGMENT}
|
|
5679
5588
|
${POSTER_USAGE_FIELDS_FRAGMENT}
|
|
5680
|
-
${
|
|
5589
|
+
${VENDOR_PRODUCTS_FIELDS_FRAGMENT}
|
|
5681
5590
|
${CONTACT_DETAILS_FIELDS_FRAGMENT}
|
|
5682
5591
|
${TERMS_AGREEMENT_FIELDS_FRAGMENT}
|
|
5683
5592
|
${RELATION_DATES_FRAGMENT}
|
|
@@ -7883,6 +7792,146 @@ var ASSIGN_AFFILIATE_BONUS_REWARD_MUTATION = gql`
|
|
|
7883
7792
|
}
|
|
7884
7793
|
${AFFILIATE_FIELDS_FRAGMENT}
|
|
7885
7794
|
`;
|
|
7795
|
+
var COUPON_CODE_FIELDS_FRAGMENT = gql`
|
|
7796
|
+
fragment CouponCodeFields on CouponCodeType {
|
|
7797
|
+
code
|
|
7798
|
+
qrCode {
|
|
7799
|
+
...ResourceImageFields
|
|
7800
|
+
}
|
|
7801
|
+
}
|
|
7802
|
+
${RESOURCE_IMAGE_FIELDS_FRAGMENT}
|
|
7803
|
+
`;
|
|
7804
|
+
var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
|
|
7805
|
+
fragment CouponParticipantUserFields on CouponParticipantUserType {
|
|
7806
|
+
couponCollectedCount
|
|
7807
|
+
couponRedeemedAt
|
|
7808
|
+
createdAt
|
|
7809
|
+
updatedAt
|
|
7810
|
+
userId
|
|
7811
|
+
}
|
|
7812
|
+
`;
|
|
7813
|
+
var COUPON_OPTION_FIELDS_FRAGMENT = gql`
|
|
7814
|
+
fragment CouponOptionFields on CouponOptionType {
|
|
7815
|
+
type
|
|
7816
|
+
buy
|
|
7817
|
+
get
|
|
7818
|
+
unit
|
|
7819
|
+
visits
|
|
7820
|
+
}
|
|
7821
|
+
`;
|
|
7822
|
+
var COUPON_REWARD_FIELDS_FRAGMENT = gql`
|
|
7823
|
+
fragment CouponRewardFields on CouponRewardType {
|
|
7824
|
+
vendorId
|
|
7825
|
+
productId
|
|
7826
|
+
quantity
|
|
7827
|
+
unit
|
|
7828
|
+
}
|
|
7829
|
+
`;
|
|
7830
|
+
var COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT = gql`
|
|
7831
|
+
fragment CouponDataProductsFields on CouponDataProductsType {
|
|
7832
|
+
active
|
|
7833
|
+
productsList {
|
|
7834
|
+
...VendorProductListFields
|
|
7835
|
+
}
|
|
7836
|
+
vendorLogo {
|
|
7837
|
+
...ResourceImageFields
|
|
7838
|
+
}
|
|
7839
|
+
vendorName
|
|
7840
|
+
}
|
|
7841
|
+
${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
|
|
7842
|
+
${RESOURCE_IMAGE_FIELDS_FRAGMENT}
|
|
7843
|
+
`;
|
|
7844
|
+
var COUPON_DATA_FIELDS_FRAGMENT = gql`
|
|
7845
|
+
fragment CouponDataFields on CouponDataType {
|
|
7846
|
+
_id
|
|
7847
|
+
active
|
|
7848
|
+
couponCode {
|
|
7849
|
+
...CouponCodeFields
|
|
7850
|
+
}
|
|
7851
|
+
couponDescription
|
|
7852
|
+
couponOption {
|
|
7853
|
+
...CouponOptionFields
|
|
7854
|
+
}
|
|
7855
|
+
couponRewards {
|
|
7856
|
+
...CouponRewardFields
|
|
7857
|
+
}
|
|
7858
|
+
createdAt
|
|
7859
|
+
endDate
|
|
7860
|
+
participantUsers {
|
|
7861
|
+
...CouponParticipantUserFields
|
|
7862
|
+
}
|
|
7863
|
+
products {
|
|
7864
|
+
...CouponDataProductsFields
|
|
7865
|
+
}
|
|
7866
|
+
resourceId
|
|
7867
|
+
resourceType
|
|
7868
|
+
startDate
|
|
7869
|
+
updatedAt
|
|
7870
|
+
}
|
|
7871
|
+
${COUPON_CODE_FIELDS_FRAGMENT}
|
|
7872
|
+
${COUPON_OPTION_FIELDS_FRAGMENT}
|
|
7873
|
+
${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
|
|
7874
|
+
${COUPON_REWARD_FIELDS_FRAGMENT}
|
|
7875
|
+
${COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT}
|
|
7876
|
+
`;
|
|
7877
|
+
var COUPON = gql`
|
|
7878
|
+
fragment CouponFields on CouponType {
|
|
7879
|
+
_id
|
|
7880
|
+
active
|
|
7881
|
+
couponData {
|
|
7882
|
+
...CouponDataFields
|
|
7883
|
+
}
|
|
7884
|
+
createdAt
|
|
7885
|
+
deletedAt
|
|
7886
|
+
owner {
|
|
7887
|
+
...OwnerFields
|
|
7888
|
+
}
|
|
7889
|
+
updatedAt
|
|
7890
|
+
}
|
|
7891
|
+
${OWNER_FIELDS_FRAGMENT}
|
|
7892
|
+
${COUPON_DATA_FIELDS_FRAGMENT}
|
|
7893
|
+
`;
|
|
7894
|
+
var GET_COUPONS = gql`
|
|
7895
|
+
query getCoupons {
|
|
7896
|
+
coupons {
|
|
7897
|
+
active {
|
|
7898
|
+
listName
|
|
7899
|
+
data {
|
|
7900
|
+
...CouponFields
|
|
7901
|
+
}
|
|
7902
|
+
}
|
|
7903
|
+
owned {
|
|
7904
|
+
listName
|
|
7905
|
+
data {
|
|
7906
|
+
...CouponFields
|
|
7907
|
+
}
|
|
7908
|
+
}
|
|
7909
|
+
scanned {
|
|
7910
|
+
listName
|
|
7911
|
+
data {
|
|
7912
|
+
...CouponFields
|
|
7913
|
+
}
|
|
7914
|
+
}
|
|
7915
|
+
}
|
|
7916
|
+
}
|
|
7917
|
+
${COUPON}
|
|
7918
|
+
`;
|
|
7919
|
+
var GET_COUPON = gql`
|
|
7920
|
+
query getCoupon($_id: ID!) {
|
|
7921
|
+
coupon(_id: $_id) {
|
|
7922
|
+
...CouponFields
|
|
7923
|
+
}
|
|
7924
|
+
}
|
|
7925
|
+
${COUPON}
|
|
7926
|
+
`;
|
|
7927
|
+
var GET_RESOURCE_COUPONS = gql`
|
|
7928
|
+
query getResourceCoupons($resourceId: ID!, $resourceType: ResourceTypeEnum!) {
|
|
7929
|
+
resourceCoupons(resourceId: $resourceId, resourceType: $resourceType) {
|
|
7930
|
+
...CouponFields
|
|
7931
|
+
}
|
|
7932
|
+
}
|
|
7933
|
+
${COUPON}
|
|
7934
|
+
`;
|
|
7886
7935
|
var CREATE_COUPON_MUTATION = gql`
|
|
7887
7936
|
mutation createCoupon($input: CouponInputType!) {
|
|
7888
7937
|
createCoupon(input: $input) {
|
|
@@ -9931,7 +9980,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
9931
9980
|
school: "School"
|
|
9932
9981
|
};
|
|
9933
9982
|
|
|
9934
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
9983
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-3HRC67D3.mjs
|
|
9935
9984
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
9936
9985
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
9937
9986
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -10033,7 +10082,7 @@ var gameScreenIdentifierList2 = [
|
|
|
10033
10082
|
}
|
|
10034
10083
|
];
|
|
10035
10084
|
|
|
10036
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10085
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-E7KKXQDI.mjs
|
|
10037
10086
|
var import_dayjs4 = __toESM(require("dayjs"), 1);
|
|
10038
10087
|
var statusOptions2 = [
|
|
10039
10088
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -11077,12 +11126,6 @@ function createAffiliateReward(rewardType, createdAt) {
|
|
|
11077
11126
|
};
|
|
11078
11127
|
}
|
|
11079
11128
|
|
|
11080
|
-
// src/service/promoCode/normalizePromoCode.ts
|
|
11081
|
-
function normalizePromoCode(decoratedPromoCode) {
|
|
11082
|
-
const normalized = decoratedPromoCode?.trim().toUpperCase();
|
|
11083
|
-
return normalized || null;
|
|
11084
|
-
}
|
|
11085
|
-
|
|
11086
11129
|
// src/service/saveNotificationsInDb.ts
|
|
11087
11130
|
async function saveNotificationsInDb(payload) {
|
|
11088
11131
|
const { data, message, title, type, userIds } = payload;
|
|
@@ -11262,10 +11305,9 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
11262
11305
|
}
|
|
11263
11306
|
},
|
|
11264
11307
|
deletedAt: null
|
|
11265
|
-
}).select("_id
|
|
11308
|
+
}).select("_id affiliateResources owner").lean().exec();
|
|
11266
11309
|
}
|
|
11267
11310
|
async function isEligibleReferredVendor({
|
|
11268
|
-
affiliateCode,
|
|
11269
11311
|
resourceId,
|
|
11270
11312
|
resourceOwnerUserId
|
|
11271
11313
|
}) {
|
|
@@ -11273,8 +11315,7 @@ async function isEligibleReferredVendor({
|
|
|
11273
11315
|
_id: resourceId,
|
|
11274
11316
|
active: true,
|
|
11275
11317
|
deletedAt: null,
|
|
11276
|
-
"owner.userId": resourceOwnerUserId
|
|
11277
|
-
promoCodes: affiliateCode
|
|
11318
|
+
"owner.userId": resourceOwnerUserId
|
|
11278
11319
|
}).exec();
|
|
11279
11320
|
return Boolean(match);
|
|
11280
11321
|
}
|
|
@@ -11363,14 +11404,12 @@ async function tryAwardSubscriptionReward({
|
|
|
11363
11404
|
}
|
|
11364
11405
|
async function processAffiliateVendorReferral({
|
|
11365
11406
|
affiliate,
|
|
11366
|
-
affiliateCode,
|
|
11367
11407
|
createdAt,
|
|
11368
11408
|
now,
|
|
11369
11409
|
period,
|
|
11370
11410
|
resource
|
|
11371
11411
|
}) {
|
|
11372
11412
|
const vendorEligible = await isEligibleReferredVendor({
|
|
11373
|
-
affiliateCode,
|
|
11374
11413
|
resourceId: resource.resourceId,
|
|
11375
11414
|
resourceOwnerUserId: resource.resourceOwner.userId
|
|
11376
11415
|
});
|
|
@@ -11400,10 +11439,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
|
|
|
11400
11439
|
let skipped = 0;
|
|
11401
11440
|
const seenPairs = /* @__PURE__ */ new Set();
|
|
11402
11441
|
for (const affiliate of affiliates) {
|
|
11403
|
-
const affiliateCode = normalizePromoCode(affiliate.affiliateCode);
|
|
11404
|
-
if (!affiliateCode) {
|
|
11405
|
-
continue;
|
|
11406
|
-
}
|
|
11407
11442
|
for (const resource of affiliate.affiliateResources) {
|
|
11408
11443
|
if (!isEligibleVendorResource(resource)) {
|
|
11409
11444
|
continue;
|
|
@@ -11415,7 +11450,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
|
|
|
11415
11450
|
seenPairs.add(pairKey);
|
|
11416
11451
|
const outcome = await processAffiliateVendorReferral({
|
|
11417
11452
|
affiliate,
|
|
11418
|
-
affiliateCode,
|
|
11419
11453
|
createdAt,
|
|
11420
11454
|
now,
|
|
11421
11455
|
period,
|
|
@@ -11439,6 +11473,12 @@ async function findAffiliateByPromoCode(promoCode) {
|
|
|
11439
11473
|
}).exec();
|
|
11440
11474
|
}
|
|
11441
11475
|
|
|
11476
|
+
// src/service/promoCode/normalizePromoCode.ts
|
|
11477
|
+
function normalizePromoCode(decoratedPromoCode) {
|
|
11478
|
+
const normalized = decoratedPromoCode?.trim().toUpperCase();
|
|
11479
|
+
return normalized || null;
|
|
11480
|
+
}
|
|
11481
|
+
|
|
11442
11482
|
// src/service/affiliate/normalizeAffiliatePromoCodes.ts
|
|
11443
11483
|
function normalizeAffiliatePromoCodes(promoCodes) {
|
|
11444
11484
|
const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);
|