@timardex/cluemart-server-shared 1.0.263 → 1.0.265

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.
@@ -1,5 +1,5 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, SocialShareResourceType, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType } from '@timardex/cluemart-shared';
2
+ import { AdType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, SocialShareResourceType, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateReward, AffiliateResourceType, AffiliateType } from '@timardex/cluemart-shared';
3
3
  import mongoose from 'mongoose';
4
4
  import { O as ObjectId } from '../Chat-DYkhie3G.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-DYkhie3G.mjs';
@@ -392,8 +392,9 @@ declare const ResourceActivityModel: mongoose.Model<ResourceActivityType, {}, {}
392
392
  type SchemaUserActivityEvent = Omit<UserActivityEvent, "resourceId"> & {
393
393
  resourceId: ObjectId;
394
394
  };
395
- type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school"> & {
395
+ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate"> & {
396
396
  _id: ObjectId;
397
+ affiliate: ObjectId;
397
398
  events: ObjectId[];
398
399
  game: ObjectId;
399
400
  partner: ObjectId;
@@ -416,8 +417,9 @@ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActi
416
417
  };
417
418
  };
418
419
  };
419
- declare const UserModel: mongoose.Model<SchemaUserType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school"> & {
420
+ declare const UserModel: mongoose.Model<SchemaUserType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate"> & {
420
421
  _id: ObjectId;
422
+ affiliate: ObjectId;
421
423
  events: ObjectId[];
422
424
  game: ObjectId;
423
425
  partner: ObjectId;
@@ -603,4 +605,21 @@ declare const SchoolModel: mongoose.Model<SchoolDocument, {}, {}, {}, mongoose.D
603
605
  __v: number;
604
606
  }, any>;
605
607
 
606
- export { APP_SETTINGS_ID, AdModel, AppSettingModel, CategorySchema, ChatReportModel, ContactDetailsSchema, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, ResourceActivityModel, ResourceImageTypeSchema, type SchemaChatReportType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaOwnerType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, dateTimeSchema, locationGeoSchema, locationsSchema, refundPolicySchema, relatedPostSchema, resourceRelationsSchema, socialShareResourceSchema, termsAgreementSchema, userLicenseSchema };
608
+ type SchemaAffiliateReward = AffiliateReward;
609
+ type SchemaAffiliateResourceType = Omit<AffiliateResourceType, "resourceId"> & {
610
+ resourceId: ObjectId;
611
+ };
612
+ type AffiliateDocument = Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
613
+ affiliateResources: SchemaAffiliateResourceType[];
614
+ owner: SchemaOwnerType;
615
+ };
616
+ declare const AffiliateModel: mongoose.Model<AffiliateDocument, {}, {}, {}, mongoose.Document<unknown, {}, AffiliateDocument, {}, {}> & Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
617
+ affiliateResources: SchemaAffiliateResourceType[];
618
+ owner: SchemaOwnerType;
619
+ } & {
620
+ _id: mongoose.Types.ObjectId;
621
+ } & {
622
+ __v: number;
623
+ }, any>;
624
+
625
+ export { APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, CategorySchema, ChatReportModel, ContactDetailsSchema, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, ResourceActivityModel, ResourceImageTypeSchema, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatReportType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaOwnerType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, dateTimeSchema, locationGeoSchema, locationsSchema, refundPolicySchema, relatedPostSchema, resourceRelationsSchema, socialShareResourceSchema, termsAgreementSchema, userLicenseSchema };
@@ -1,5 +1,5 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, SocialShareResourceType, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType } from '@timardex/cluemart-shared';
2
+ import { AdType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, SocialShareResourceType, GoogleImportedMarket, PushTokenType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateReward, AffiliateResourceType, AffiliateType } from '@timardex/cluemart-shared';
3
3
  import mongoose from 'mongoose';
4
4
  import { O as ObjectId } from '../Chat-DYkhie3G.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-DYkhie3G.js';
@@ -392,8 +392,9 @@ declare const ResourceActivityModel: mongoose.Model<ResourceActivityType, {}, {}
392
392
  type SchemaUserActivityEvent = Omit<UserActivityEvent, "resourceId"> & {
393
393
  resourceId: ObjectId;
394
394
  };
395
- type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school"> & {
395
+ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate"> & {
396
396
  _id: ObjectId;
397
+ affiliate: ObjectId;
397
398
  events: ObjectId[];
398
399
  game: ObjectId;
399
400
  partner: ObjectId;
@@ -416,8 +417,9 @@ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActi
416
417
  };
417
418
  };
418
419
  };
419
- declare const UserModel: mongoose.Model<SchemaUserType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school"> & {
420
+ declare const UserModel: mongoose.Model<SchemaUserType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate"> & {
420
421
  _id: ObjectId;
422
+ affiliate: ObjectId;
421
423
  events: ObjectId[];
422
424
  game: ObjectId;
423
425
  partner: ObjectId;
@@ -603,4 +605,21 @@ declare const SchoolModel: mongoose.Model<SchoolDocument, {}, {}, {}, mongoose.D
603
605
  __v: number;
604
606
  }, any>;
605
607
 
606
- export { APP_SETTINGS_ID, AdModel, AppSettingModel, CategorySchema, ChatReportModel, ContactDetailsSchema, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, ResourceActivityModel, ResourceImageTypeSchema, type SchemaChatReportType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaOwnerType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, dateTimeSchema, locationGeoSchema, locationsSchema, refundPolicySchema, relatedPostSchema, resourceRelationsSchema, socialShareResourceSchema, termsAgreementSchema, userLicenseSchema };
608
+ type SchemaAffiliateReward = AffiliateReward;
609
+ type SchemaAffiliateResourceType = Omit<AffiliateResourceType, "resourceId"> & {
610
+ resourceId: ObjectId;
611
+ };
612
+ type AffiliateDocument = Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
613
+ affiliateResources: SchemaAffiliateResourceType[];
614
+ owner: SchemaOwnerType;
615
+ };
616
+ declare const AffiliateModel: mongoose.Model<AffiliateDocument, {}, {}, {}, mongoose.Document<unknown, {}, AffiliateDocument, {}, {}> & Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
617
+ affiliateResources: SchemaAffiliateResourceType[];
618
+ owner: SchemaOwnerType;
619
+ } & {
620
+ _id: mongoose.Types.ObjectId;
621
+ } & {
622
+ __v: number;
623
+ }, any>;
624
+
625
+ export { APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, CategorySchema, ChatReportModel, ContactDetailsSchema, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, ResourceActivityModel, ResourceImageTypeSchema, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatReportType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaOwnerType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, dateTimeSchema, locationGeoSchema, locationsSchema, refundPolicySchema, relatedPostSchema, resourceRelationsSchema, socialShareResourceSchema, termsAgreementSchema, userLicenseSchema };
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  APP_SETTINGS_ID,
3
3
  AdModel,
4
+ AffiliateModel,
4
5
  AppSettingModel,
5
6
  CategorySchema,
6
7
  ChatModel,
@@ -39,10 +40,11 @@ import {
39
40
  socialShareResourceSchema,
40
41
  termsAgreementSchema,
41
42
  userLicenseSchema
42
- } from "../chunk-BDHZYR65.mjs";
43
+ } from "../chunk-SHBCW7T5.mjs";
43
44
  export {
44
45
  APP_SETTINGS_ID,
45
46
  AdModel,
47
+ AffiliateModel,
46
48
  AppSettingModel,
47
49
  CategorySchema,
48
50
  ChatModel,
@@ -3551,6 +3551,7 @@ var gameScreenIdentifierList = [
3551
3551
  match: "/visitors"
3552
3552
  }
3553
3553
  ];
3554
+ var PROMO_CODE_PREFIX = "CM-";
3554
3555
  var EnumAdShowOn = /* @__PURE__ */ ((EnumAdShowOn2) => {
3555
3556
  EnumAdShowOn2["EVENTS_PAGE"] = "Events_page";
3556
3557
  EnumAdShowOn2["FRONT_PAGE"] = "Front_page";
@@ -3609,6 +3610,12 @@ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
3609
3610
  EnumGameType2["ODD_ONE_OUT"] = "oddOneOut";
3610
3611
  return EnumGameType2;
3611
3612
  })(EnumGameType || {});
3613
+ var EnumAffiliateRewardType = /* @__PURE__ */ ((EnumAffiliateRewardType2) => {
3614
+ EnumAffiliateRewardType2["NEW_EVENT_REGISTRATION"] = "NEW_EVENT_REGISTRATION";
3615
+ EnumAffiliateRewardType2["NEW_VENDOR_REGISTRATION"] = "NEW_VENDOR_REGISTRATION";
3616
+ EnumAffiliateRewardType2["NEW_PARTNER_REGISTRATION"] = "NEW_PARTNER_REGISTRATION";
3617
+ return EnumAffiliateRewardType2;
3618
+ })(EnumAffiliateRewardType || {});
3612
3619
  var mapArrayToOptions = (items) => items.map((item) => ({
3613
3620
  label: item,
3614
3621
  value: item
@@ -3626,6 +3633,8 @@ var paymentMethodOptions = mapArrayToOptions(
3626
3633
  Object.values(EnumPaymentMethod)
3627
3634
  );
3628
3635
  var CLUEMART_MAIN_DOMAIN_URL = "https://cluemart.co.nz";
3636
+ var CM_SCHOOL_PROMO_CODE = `${PROMO_CODE_PREFIX}SCHOOL`;
3637
+ var CM_AFFILIATE_PROMO_CODE = `${PROMO_CODE_PREFIX}AFFILIATE`;
3629
3638
  var dateFormat = "DD-MM-YYYY";
3630
3639
  var timeFormat = "HH:mm";
3631
3640
  import_dayjs.default.extend(import_customParseFormat.default);
@@ -5021,12 +5030,6 @@ var REDEEMED_REWARD_FIELDS_FRAGMENT = gql`
5021
5030
  redeemedAt
5022
5031
  }
5023
5032
  `;
5024
- var AFFILIATE_FIELDS_FRAGMENT = gql`
5025
- fragment AffiliateFields on AffiliateType {
5026
- affiliateCode
5027
- pointsAvailable
5028
- }
5029
- `;
5030
5033
  var USER_FIELDS_FRAGMENT = gql`
5031
5034
  fragment UserFields on UserType {
5032
5035
  _id
@@ -5034,9 +5037,7 @@ var USER_FIELDS_FRAGMENT = gql`
5034
5037
  associates {
5035
5038
  ...AssociatesFields
5036
5039
  }
5037
- affiliate {
5038
- ...AffiliateFields
5039
- }
5040
+ affiliate
5040
5041
  avatar {
5041
5042
  ...ResourceImageFields
5042
5043
  }
@@ -5080,7 +5081,6 @@ var USER_FIELDS_FRAGMENT = gql`
5080
5081
  ${LICENCE_FIELDS_FRAGMENT}
5081
5082
  ${LOCATION_FIELDS_FRAGMENT}
5082
5083
  ${REDEEMED_REWARD_FIELDS_FRAGMENT}
5083
- ${AFFILIATE_FIELDS_FRAGMENT}
5084
5084
  `;
5085
5085
  var STALL_TYPE_FIELDS_FRAGMENT = gql`
5086
5086
  fragment StallTypeFields on StallTypeType {
@@ -7426,6 +7426,63 @@ var REQUEST_MARKETING_MATERIAL_MUTATION = gql`
7426
7426
  }
7427
7427
  }
7428
7428
  `;
7429
+ var AFFILIATE_REWARD_FIELDS_FRAGMENT = gql`
7430
+ fragment AffiliateRewardFields on AffiliateRewardType {
7431
+ createdAt
7432
+ deletedAt
7433
+ redeemedAt
7434
+ rewardDescription
7435
+ rewardType
7436
+ rewardValue
7437
+ updatedAt
7438
+ }
7439
+ `;
7440
+ var AFFILIATE_RESOURCE_FIELDS_FRAGMENT = gql`
7441
+ fragment AffiliateResourceFields on AffiliateResourceType {
7442
+ resourceActive
7443
+ resourceId
7444
+ resourceType
7445
+ rewards {
7446
+ ...AffiliateRewardFields
7447
+ }
7448
+ }
7449
+ ${AFFILIATE_REWARD_FIELDS_FRAGMENT}
7450
+ `;
7451
+ var AFFILIATE_FIELDS_FRAGMENT = gql`
7452
+ fragment AffiliateFields on AffiliateType {
7453
+ _id
7454
+ active
7455
+ affiliateCode
7456
+ affiliateResources {
7457
+ ...AffiliateResourceFields
7458
+ }
7459
+ createdAt
7460
+ deletedAt
7461
+ overallPoints
7462
+ owner {
7463
+ ...OwnerFields
7464
+ }
7465
+ updatedAt
7466
+ }
7467
+ ${AFFILIATE_RESOURCE_FIELDS_FRAGMENT}
7468
+ ${OWNER_FIELDS_FRAGMENT}
7469
+ `;
7470
+ var GET_AFFILIATE = gql`
7471
+ query getAffiliate($_id: ID!) {
7472
+ affiliate(_id: $_id) {
7473
+ ...AffiliateFields
7474
+ }
7475
+ }
7476
+ ${AFFILIATE_FIELDS_FRAGMENT}
7477
+ `;
7478
+ var GET_AFFILIATES = gql`
7479
+ query getAffiliates {
7480
+ affiliates {
7481
+ ...AffiliateFields
7482
+ }
7483
+ }
7484
+ ${AFFILIATE_FIELDS_FRAGMENT}
7485
+ `;
7429
7486
  var PKG = "@timardex/cluemart-shared";
7430
7487
  var IMAGE_EXTENSION = ".webp";
7431
7488
  var posterIds = [
@@ -8575,19 +8632,13 @@ var redeemedRewardSchema = new MongooseSchema11(
8575
8632
  },
8576
8633
  { _id: false }
8577
8634
  );
8578
- var affiliateSchema = new MongooseSchema11(
8579
- {
8580
- affiliateCode: { required: true, type: String },
8581
- pointsAvailable: { required: true, type: Number }
8582
- },
8583
- { _id: false }
8584
- );
8585
8635
  var schema7 = new MongooseSchema11(
8586
8636
  {
8587
8637
  active: { default: false, required: true, type: Boolean },
8588
8638
  affiliate: {
8639
+ ref: "Affiliate",
8589
8640
  required: false,
8590
- type: affiliateSchema
8641
+ type: import_mongoose12.default.Schema.Types.ObjectId
8591
8642
  },
8592
8643
  associates: {
8593
8644
  required: false,
@@ -8687,13 +8738,6 @@ var schema7 = new MongooseSchema11(
8687
8738
  },
8688
8739
  { strict: false, timestamps: true }
8689
8740
  );
8690
- schema7.index(
8691
- { "affiliate.affiliateCode": 1 },
8692
- {
8693
- partialFilterExpression: { active: true, deletedAt: null },
8694
- unique: true
8695
- }
8696
- );
8697
8741
  schema7.index({ "associates.email": 1 });
8698
8742
  schema7.index({ "licences.expiryDate": 1 });
8699
8743
  schema7.index({ "licences.licenceType": 1 });
@@ -9184,9 +9228,9 @@ var gameDataSchemas = {
9184
9228
  [EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
9185
9229
  };
9186
9230
  var gameDataDefinition = Object.fromEntries(
9187
- Object.entries(gameDataSchemas).map(([key, schema17]) => [
9231
+ Object.entries(gameDataSchemas).map(([key, schema18]) => [
9188
9232
  key,
9189
- { default: null, required: false, type: schema17 }
9233
+ { default: null, required: false, type: schema18 }
9190
9234
  ])
9191
9235
  );
9192
9236
  var gameHistorySchema = new MongooseSchema23(
@@ -9285,6 +9329,72 @@ schema16.index(
9285
9329
  );
9286
9330
  var SchoolModel = import_mongoose25.default.models.School || import_mongoose25.default.model("School", schema16);
9287
9331
 
9332
+ // src/mongoose/Affiliate.ts
9333
+ var import_mongoose26 = __toESM(require("mongoose"));
9334
+ var MongooseSchema25 = import_mongoose26.default.Schema;
9335
+ var affiliateRewardSchema = new MongooseSchema25(
9336
+ {
9337
+ createdAt: { required: true, type: Date },
9338
+ deletedAt: { default: null, required: false, type: Date },
9339
+ redeemedAt: { default: null, required: false, type: Date },
9340
+ rewardDescription: { required: true, type: String },
9341
+ rewardType: {
9342
+ enum: Object.values(EnumAffiliateRewardType),
9343
+ required: true,
9344
+ type: String
9345
+ },
9346
+ rewardValue: { required: true, type: Number },
9347
+ updatedAt: { default: null, required: false, type: Date }
9348
+ },
9349
+ { _id: false }
9350
+ );
9351
+ var affiliateResourceSchema = new MongooseSchema25(
9352
+ {
9353
+ resourceActive: { default: true, required: true, type: Boolean },
9354
+ resourceId: {
9355
+ required: true,
9356
+ type: import_mongoose26.default.Schema.Types.ObjectId
9357
+ },
9358
+ resourceType: {
9359
+ enum: Object.values(EnumResourceType),
9360
+ required: true,
9361
+ type: String
9362
+ },
9363
+ rewards: {
9364
+ default: [],
9365
+ required: false,
9366
+ type: [affiliateRewardSchema]
9367
+ }
9368
+ },
9369
+ { _id: false }
9370
+ );
9371
+ var schema17 = new MongooseSchema25(
9372
+ {
9373
+ active: { default: true, required: true, type: Boolean },
9374
+ affiliateCode: { required: true, type: String },
9375
+ affiliateResources: {
9376
+ default: [],
9377
+ required: false,
9378
+ type: [affiliateResourceSchema]
9379
+ },
9380
+ deletedAt: { default: null, required: false, type: Date },
9381
+ overallPoints: { default: 0, required: true, type: Number },
9382
+ owner: {
9383
+ required: true,
9384
+ type: OwnerTypeSchema
9385
+ }
9386
+ },
9387
+ { timestamps: true }
9388
+ );
9389
+ schema17.index(
9390
+ { affiliateCode: 1 },
9391
+ {
9392
+ partialFilterExpression: { deletedAt: null },
9393
+ unique: true
9394
+ }
9395
+ );
9396
+ var AffiliateModel = import_mongoose26.default.models.Affiliate || import_mongoose26.default.model("Affiliate", schema17);
9397
+
9288
9398
  // src/service/updateAdStatus.ts
9289
9399
  async function updateAdStatuses() {
9290
9400
  const now = /* @__PURE__ */ new Date();
@@ -9321,9 +9431,9 @@ async function updateAdStatuses() {
9321
9431
  }
9322
9432
 
9323
9433
  // src/service/associate.ts
9324
- var import_mongoose27 = __toESM(require("mongoose"));
9434
+ var import_mongoose28 = __toESM(require("mongoose"));
9325
9435
  function normalizeObjectId(id) {
9326
- return typeof id === "string" ? new import_mongoose27.default.Types.ObjectId(id) : id;
9436
+ return typeof id === "string" ? new import_mongoose28.default.Types.ObjectId(id) : id;
9327
9437
  }
9328
9438
  async function getAssociateEmailsForResource({
9329
9439
  normalizedResourceId,
@@ -9475,12 +9585,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
9475
9585
  }
9476
9586
 
9477
9587
  // src/service/objectIdToString.ts
9478
- var import_mongoose30 = __toESM(require("mongoose"));
9588
+ var import_mongoose31 = __toESM(require("mongoose"));
9479
9589
  function convertObjectIdsToStrings(obj) {
9480
9590
  if (obj === null || obj === void 0) {
9481
9591
  return obj;
9482
9592
  }
9483
- if (obj instanceof import_mongoose30.default.Types.ObjectId) {
9593
+ if (obj instanceof import_mongoose31.default.Types.ObjectId) {
9484
9594
  return obj.toString();
9485
9595
  }
9486
9596
  if (obj instanceof Date) {