@timardex/cluemart-server-shared 1.0.280 → 1.0.284

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.mjs CHANGED
@@ -3610,6 +3610,7 @@ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
3610
3610
  })(EnumGameType || {});
3611
3611
  var EnumAffiliateRewardType = /* @__PURE__ */ ((EnumAffiliateRewardType2) => {
3612
3612
  EnumAffiliateRewardType2["ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS"] = "ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS";
3613
+ EnumAffiliateRewardType2["ACTIVE_VENDOR_BONUS_REWARD"] = "ACTIVE_VENDOR_BONUS_REWARD";
3613
3614
  EnumAffiliateRewardType2["ACTIVE_VENDOR_PRO_SUBSCRIPTION"] = "ACTIVE_VENDOR_PRO_SUBSCRIPTION";
3614
3615
  EnumAffiliateRewardType2["ACTIVE_VENDOR_STANDARD_SUBSCRIPTION"] = "ACTIVE_VENDOR_STANDARD_SUBSCRIPTION";
3615
3616
  EnumAffiliateRewardType2["NEW_EVENT_REGISTRATION"] = "NEW_EVENT_REGISTRATION";
@@ -7419,6 +7420,7 @@ var AFFILIATE_REWARD_FIELDS_FRAGMENT = gql`
7419
7420
  var AFFILIATE_RESOURCE_FIELDS_FRAGMENT = gql`
7420
7421
  fragment AffiliateResourceFields on AffiliateResourceType {
7421
7422
  resourceActive
7423
+ resourceDeletedAt
7422
7424
  resourceId
7423
7425
  resourceName
7424
7426
  resourceType
@@ -7458,6 +7460,9 @@ var AFFILIATE_FIELDS_FRAGMENT = gql`
7458
7460
  fragment AffiliateFields on AffiliateType {
7459
7461
  _id
7460
7462
  active
7463
+ affiliateBonusRewards {
7464
+ ...AffiliateRewardFields
7465
+ }
7461
7466
  affiliateCode
7462
7467
  affiliateDetails {
7463
7468
  ...AffiliateDetailsFields
@@ -9209,6 +9214,7 @@ var affiliateRewardSchema = new MongooseSchema25(
9209
9214
  var affiliateResourceSchema = new MongooseSchema25(
9210
9215
  {
9211
9216
  resourceActive: { default: true, required: true, type: Boolean },
9217
+ resourceDeletedAt: { default: null, required: false, type: Date },
9212
9218
  resourceId: {
9213
9219
  required: true,
9214
9220
  type: mongoose25.Schema.Types.ObjectId
@@ -9256,6 +9262,11 @@ var affiliateDetailsSchema = new MongooseSchema25(
9256
9262
  var schema17 = new MongooseSchema25(
9257
9263
  {
9258
9264
  active: { default: false, required: true, type: Boolean },
9265
+ affiliateBonusRewards: {
9266
+ default: [],
9267
+ required: false,
9268
+ type: [affiliateRewardSchema]
9269
+ },
9259
9270
  affiliateCode: { required: true, type: String },
9260
9271
  affiliateDetails: { required: false, type: affiliateDetailsSchema },
9261
9272
  affiliateResources: {
@@ -9287,6 +9298,79 @@ schema17.index(
9287
9298
  );
9288
9299
  var AffiliateModel = mongoose25.models.Affiliate || mongoose25.model("Affiliate", schema17);
9289
9300
 
9301
+ // src/service/promoCode/constants.ts
9302
+ var ACTIVE_NOT_DELETED_FILTER = {
9303
+ active: true,
9304
+ deletedAt: null
9305
+ };
9306
+
9307
+ // src/service/affiliate/activeAffiliateCodeExists.ts
9308
+ async function activeAffiliateCodeExists(affiliateCode) {
9309
+ const existing = await AffiliateModel.exists({
9310
+ ...ACTIVE_NOT_DELETED_FILTER,
9311
+ affiliateCode
9312
+ }).exec();
9313
+ return existing !== null;
9314
+ }
9315
+
9316
+ // src/service/affiliate/createAffiliateReward.ts
9317
+ var AFFILIATE_REWARDS = {
9318
+ [EnumAffiliateRewardType.NEW_EVENT_REGISTRATION]: {
9319
+ description: "10 points for new event registration (one-time reward)",
9320
+ value: 10
9321
+ },
9322
+ [EnumAffiliateRewardType.NEW_VENDOR_REGISTRATION]: {
9323
+ description: "5 points for new vendor registration (one-time reward)",
9324
+ value: 5
9325
+ },
9326
+ [EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION]: {
9327
+ description: "3 points for active vendor pro subscription (monthly reward)",
9328
+ value: 3
9329
+ },
9330
+ [EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION]: {
9331
+ description: "1 point for active vendor standard subscription (monthly reward)",
9332
+ value: 1
9333
+ },
9334
+ [EnumAffiliateRewardType.ACTIVE_VENDOR_BONUS_REWARD]: {
9335
+ description: "5 bonus points for every 10th active vendor (one-time reward)",
9336
+ value: 5
9337
+ },
9338
+ [EnumAffiliateRewardType.ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS]: {
9339
+ description: "50 points for active event with vendor registrations (one-time reward)",
9340
+ value: 50
9341
+ }
9342
+ };
9343
+ function createAffiliateReward(rewardType, createdAt) {
9344
+ const reward = AFFILIATE_REWARDS[rewardType];
9345
+ return {
9346
+ createdAt,
9347
+ redeemedAt: null,
9348
+ rewardDescription: reward.description,
9349
+ rewardType,
9350
+ rewardValue: reward.value
9351
+ };
9352
+ }
9353
+
9354
+ // src/service/affiliate/findAffiliateByPromoCode.ts
9355
+ async function findAffiliateByPromoCode(promoCode) {
9356
+ return AffiliateModel.findOne({
9357
+ affiliateCode: promoCode,
9358
+ deletedAt: null
9359
+ }).exec();
9360
+ }
9361
+
9362
+ // src/service/promoCode/normalizePromoCode.ts
9363
+ function normalizePromoCode(decoratedPromoCode) {
9364
+ const normalized = decoratedPromoCode?.trim().toUpperCase();
9365
+ return normalized || null;
9366
+ }
9367
+
9368
+ // src/service/affiliate/normalizeAffiliatePromoCodes.ts
9369
+ function normalizeAffiliatePromoCodes(promoCodes) {
9370
+ const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);
9371
+ return [...new Set(normalized)];
9372
+ }
9373
+
9290
9374
  // src/service/database.ts
9291
9375
  import mongoose26 from "mongoose";
9292
9376
  var connectToDatabase = async ({
@@ -9833,6 +9917,8 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
9833
9917
  return EnumPubSubEvents2;
9834
9918
  })(EnumPubSubEvents || {});
9835
9919
  export {
9920
+ ACTIVE_NOT_DELETED_FILTER,
9921
+ AFFILIATE_REWARDS,
9836
9922
  APP_SETTINGS_ID,
9837
9923
  AdModel,
9838
9924
  AffiliateModel,
@@ -9863,17 +9949,22 @@ export {
9863
9949
  VendorInfoModel,
9864
9950
  VendorModel,
9865
9951
  VerificationTokenModel,
9952
+ activeAffiliateCodeExists,
9866
9953
  associatesSchema,
9867
9954
  baseResourceFields,
9868
9955
  connectToDatabase,
9869
9956
  convertObjectIdsToStrings,
9957
+ createAffiliateReward,
9870
9958
  dateTimeSchema2 as dateTimeSchema,
9871
9959
  didRemoveAnyEventDates,
9872
9960
  express,
9961
+ findAffiliateByPromoCode,
9873
9962
  findEventOrImportedMarketById,
9874
9963
  locationGeoSchema,
9875
9964
  locationsSchema,
9876
9965
  mongoose29 as mongoose,
9966
+ normalizeAffiliatePromoCodes,
9967
+ normalizePromoCode,
9877
9968
  refundPolicySchema,
9878
9969
  relatedPostSchema,
9879
9970
  relationDatesSchema,