@timardex/cluemart-server-shared 1.0.262 → 1.0.264

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, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, SocialShareResourceType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
2
+ import { AdType, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, SocialShareResourceType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateReward, AffiliateResourceType, AffiliateType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
3
  import mongoose from 'mongoose';
4
4
  export { default as mongoose } from 'mongoose';
5
5
  import { NotificationCount, DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
@@ -512,8 +512,9 @@ declare const ResourceActivityModel: mongoose.Model<ResourceActivityType, {}, {}
512
512
  type SchemaUserActivityEvent = Omit<UserActivityEvent, "resourceId"> & {
513
513
  resourceId: ObjectId;
514
514
  };
515
- type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school"> & {
515
+ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate"> & {
516
516
  _id: ObjectId;
517
+ affiliate: ObjectId;
517
518
  events: ObjectId[];
518
519
  game: ObjectId;
519
520
  partner: ObjectId;
@@ -536,8 +537,9 @@ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActi
536
537
  };
537
538
  };
538
539
  };
539
- declare const UserModel: mongoose.Model<SchemaUserType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school"> & {
540
+ declare const UserModel: mongoose.Model<SchemaUserType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate"> & {
540
541
  _id: ObjectId;
542
+ affiliate: ObjectId;
541
543
  events: ObjectId[];
542
544
  game: ObjectId;
543
545
  partner: ObjectId;
@@ -723,6 +725,23 @@ declare const SchoolModel: mongoose.Model<SchoolDocument, {}, {}, {}, mongoose.D
723
725
  __v: number;
724
726
  }, any>;
725
727
 
728
+ type SchemaAffiliateReward = AffiliateReward;
729
+ type SchemaAffiliateResourceType = Omit<AffiliateResourceType, "resourceId"> & {
730
+ resourceId: ObjectId;
731
+ };
732
+ type AffiliateDocument = Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
733
+ affiliateResources: SchemaAffiliateResourceType[];
734
+ owner: SchemaOwnerType;
735
+ };
736
+ declare const AffiliateModel: mongoose.Model<AffiliateDocument, {}, {}, {}, mongoose.Document<unknown, {}, AffiliateDocument, {}, {}> & Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
737
+ affiliateResources: SchemaAffiliateResourceType[];
738
+ owner: SchemaOwnerType;
739
+ } & {
740
+ _id: mongoose.Types.ObjectId;
741
+ } & {
742
+ __v: number;
743
+ }, any>;
744
+
726
745
  /**
727
746
  * Connect to MongoDB using Mongoose.
728
747
  * Supports both local MongoDB (via MONGODB_URI) and MongoDB Atlas (via individual env vars).
@@ -790,4 +809,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
790
809
  */
791
810
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
792
811
 
793
- export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, 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, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
812
+ export { APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, 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, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
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, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, SocialShareResourceType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
2
+ import { AdType, CreateBulkNotificationInput, NotificationType, EnumUserRole, ChatMessageType, ParticipantType, ChatType, ReportChatUser, RelatedPostType, OwnerType, SocialMediaType, ResourceImageType, Category, UserLicenceType, AssociateType, ResourceContactDetailsType, TermsAgreement, RelationDate, DateTimeType, LocationGeoType, LocationType, PosterUsageType, SocialShareResourceType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateReward, AffiliateResourceType, AffiliateType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
3
  import mongoose from 'mongoose';
4
4
  export { default as mongoose } from 'mongoose';
5
5
  import { NotificationCount, DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
@@ -512,8 +512,9 @@ declare const ResourceActivityModel: mongoose.Model<ResourceActivityType, {}, {}
512
512
  type SchemaUserActivityEvent = Omit<UserActivityEvent, "resourceId"> & {
513
513
  resourceId: ObjectId;
514
514
  };
515
- type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school"> & {
515
+ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate"> & {
516
516
  _id: ObjectId;
517
+ affiliate: ObjectId;
517
518
  events: ObjectId[];
518
519
  game: ObjectId;
519
520
  partner: ObjectId;
@@ -536,8 +537,9 @@ type SchemaUserType = Omit<UserType, "vendor" | "events" | "partner" | "userActi
536
537
  };
537
538
  };
538
539
  };
539
- declare const UserModel: mongoose.Model<SchemaUserType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school"> & {
540
+ declare const UserModel: mongoose.Model<SchemaUserType, {}, {}, {}, mongoose.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate"> & {
540
541
  _id: ObjectId;
542
+ affiliate: ObjectId;
541
543
  events: ObjectId[];
542
544
  game: ObjectId;
543
545
  partner: ObjectId;
@@ -723,6 +725,23 @@ declare const SchoolModel: mongoose.Model<SchoolDocument, {}, {}, {}, mongoose.D
723
725
  __v: number;
724
726
  }, any>;
725
727
 
728
+ type SchemaAffiliateReward = AffiliateReward;
729
+ type SchemaAffiliateResourceType = Omit<AffiliateResourceType, "resourceId"> & {
730
+ resourceId: ObjectId;
731
+ };
732
+ type AffiliateDocument = Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
733
+ affiliateResources: SchemaAffiliateResourceType[];
734
+ owner: SchemaOwnerType;
735
+ };
736
+ declare const AffiliateModel: mongoose.Model<AffiliateDocument, {}, {}, {}, mongoose.Document<unknown, {}, AffiliateDocument, {}, {}> & Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
737
+ affiliateResources: SchemaAffiliateResourceType[];
738
+ owner: SchemaOwnerType;
739
+ } & {
740
+ _id: mongoose.Types.ObjectId;
741
+ } & {
742
+ __v: number;
743
+ }, any>;
744
+
726
745
  /**
727
746
  * Connect to MongoDB using Mongoose.
728
747
  * Supports both local MongoDB (via MONGODB_URI) and MongoDB Atlas (via individual env vars).
@@ -790,4 +809,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
790
809
  */
791
810
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
792
811
 
793
- export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, 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, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
812
+ export { APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, 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, associatesSchema, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findEventOrImportedMarketById, locationGeoSchema, locationsSchema, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
package/dist/index.mjs CHANGED
@@ -3480,6 +3480,7 @@ var gameScreenIdentifierList = [
3480
3480
  match: "/visitors"
3481
3481
  }
3482
3482
  ];
3483
+ var PROMO_CODE_PREFIX = "CM-";
3483
3484
  var EnumAdShowOn = /* @__PURE__ */ ((EnumAdShowOn2) => {
3484
3485
  EnumAdShowOn2["EVENTS_PAGE"] = "Events_page";
3485
3486
  EnumAdShowOn2["FRONT_PAGE"] = "Front_page";
@@ -3538,6 +3539,12 @@ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
3538
3539
  EnumGameType2["ODD_ONE_OUT"] = "oddOneOut";
3539
3540
  return EnumGameType2;
3540
3541
  })(EnumGameType || {});
3542
+ var EnumAffiliateRewardType = /* @__PURE__ */ ((EnumAffiliateRewardType2) => {
3543
+ EnumAffiliateRewardType2["NEW_EVENT_REGISTRATION"] = "NEW_EVENT_REGISTRATION";
3544
+ EnumAffiliateRewardType2["NEW_VENDOR_REGISTRATION"] = "NEW_VENDOR_REGISTRATION";
3545
+ EnumAffiliateRewardType2["NEW_PARTNER_REGISTRATION"] = "NEW_PARTNER_REGISTRATION";
3546
+ return EnumAffiliateRewardType2;
3547
+ })(EnumAffiliateRewardType || {});
3541
3548
  var mapArrayToOptions = (items) => items.map((item) => ({
3542
3549
  label: item,
3543
3550
  value: item
@@ -3555,6 +3562,8 @@ var paymentMethodOptions = mapArrayToOptions(
3555
3562
  Object.values(EnumPaymentMethod)
3556
3563
  );
3557
3564
  var CLUEMART_MAIN_DOMAIN_URL = "https://cluemart.co.nz";
3565
+ var CM_SCHOOL_PROMO_CODE = `${PROMO_CODE_PREFIX}SCHOOL`;
3566
+ var CM_AFFILIATE_PROMO_CODE = `${PROMO_CODE_PREFIX}AFFILIATE`;
3558
3567
  var dateFormat = "DD-MM-YYYY";
3559
3568
  var timeFormat = "HH:mm";
3560
3569
  dayjs.extend(customParseFormat);
@@ -4950,12 +4959,6 @@ var REDEEMED_REWARD_FIELDS_FRAGMENT = gql`
4950
4959
  redeemedAt
4951
4960
  }
4952
4961
  `;
4953
- var AFFILIATE_FIELDS_FRAGMENT = gql`
4954
- fragment AffiliateFields on AffiliateType {
4955
- affiliateCode
4956
- pointsAvailable
4957
- }
4958
- `;
4959
4962
  var USER_FIELDS_FRAGMENT = gql`
4960
4963
  fragment UserFields on UserType {
4961
4964
  _id
@@ -4963,9 +4966,7 @@ var USER_FIELDS_FRAGMENT = gql`
4963
4966
  associates {
4964
4967
  ...AssociatesFields
4965
4968
  }
4966
- affiliate {
4967
- ...AffiliateFields
4968
- }
4969
+ affiliate
4969
4970
  avatar {
4970
4971
  ...ResourceImageFields
4971
4972
  }
@@ -5009,7 +5010,6 @@ var USER_FIELDS_FRAGMENT = gql`
5009
5010
  ${LICENCE_FIELDS_FRAGMENT}
5010
5011
  ${LOCATION_FIELDS_FRAGMENT}
5011
5012
  ${REDEEMED_REWARD_FIELDS_FRAGMENT}
5012
- ${AFFILIATE_FIELDS_FRAGMENT}
5013
5013
  `;
5014
5014
  var STALL_TYPE_FIELDS_FRAGMENT = gql`
5015
5015
  fragment StallTypeFields on StallTypeType {
@@ -7355,6 +7355,62 @@ var REQUEST_MARKETING_MATERIAL_MUTATION = gql`
7355
7355
  }
7356
7356
  }
7357
7357
  `;
7358
+ var AFFILIATE_REWARD_FIELDS_FRAGMENT = gql`
7359
+ fragment AffiliateRewardFields on AffiliateRewardType {
7360
+ createdAt
7361
+ deletedAt
7362
+ redeemedAt
7363
+ rewardDescription
7364
+ rewardType
7365
+ rewardValue
7366
+ updatedAt
7367
+ }
7368
+ `;
7369
+ var AFFILIATE_RESOURCE_FIELDS_FRAGMENT = gql`
7370
+ fragment AffiliateResourceFields on AffiliateResourceType {
7371
+ resourceActive
7372
+ resourceId
7373
+ resourceType
7374
+ rewards {
7375
+ ...AffiliateRewardFields
7376
+ }
7377
+ }
7378
+ ${AFFILIATE_REWARD_FIELDS_FRAGMENT}
7379
+ `;
7380
+ var AFFILIATE_FIELDS_FRAGMENT = gql`
7381
+ fragment AffiliateFields on AffiliateType {
7382
+ _id
7383
+ affiliateCode
7384
+ affiliateResources {
7385
+ ...AffiliateResourceFields
7386
+ }
7387
+ createdAt
7388
+ deletedAt
7389
+ overallPoints
7390
+ owner {
7391
+ ...OwnerFields
7392
+ }
7393
+ updatedAt
7394
+ }
7395
+ ${AFFILIATE_RESOURCE_FIELDS_FRAGMENT}
7396
+ ${OWNER_FIELDS_FRAGMENT}
7397
+ `;
7398
+ var GET_AFFILIATE = gql`
7399
+ query getAffiliate($_id: ID!) {
7400
+ affiliate(_id: $_id) {
7401
+ ...AffiliateFields
7402
+ }
7403
+ }
7404
+ ${AFFILIATE_FIELDS_FRAGMENT}
7405
+ `;
7406
+ var GET_AFFILIATES = gql`
7407
+ query getAffiliates {
7408
+ affiliates {
7409
+ ...AffiliateFields
7410
+ }
7411
+ }
7412
+ ${AFFILIATE_FIELDS_FRAGMENT}
7413
+ `;
7358
7414
  var PKG = "@timardex/cluemart-shared";
7359
7415
  var IMAGE_EXTENSION = ".webp";
7360
7416
  var posterIds = [
@@ -8369,19 +8425,13 @@ var redeemedRewardSchema = new MongooseSchema11(
8369
8425
  },
8370
8426
  { _id: false }
8371
8427
  );
8372
- var affiliateSchema = new MongooseSchema11(
8373
- {
8374
- affiliateCode: { required: true, type: String },
8375
- pointsAvailable: { required: true, type: Number }
8376
- },
8377
- { _id: false }
8378
- );
8379
8428
  var schema7 = new MongooseSchema11(
8380
8429
  {
8381
8430
  active: { default: false, required: true, type: Boolean },
8382
8431
  affiliate: {
8432
+ ref: "Affiliate",
8383
8433
  required: false,
8384
- type: affiliateSchema
8434
+ type: mongoose11.Schema.Types.ObjectId
8385
8435
  },
8386
8436
  associates: {
8387
8437
  required: false,
@@ -8481,7 +8531,6 @@ var schema7 = new MongooseSchema11(
8481
8531
  },
8482
8532
  { strict: false, timestamps: true }
8483
8533
  );
8484
- schema7.index({ "affiliate.affiliateCode": 1 }, { sparse: true, unique: true });
8485
8534
  schema7.index({ "associates.email": 1 });
8486
8535
  schema7.index({ "licences.expiryDate": 1 });
8487
8536
  schema7.index({ "licences.licenceType": 1 });
@@ -8972,9 +9021,9 @@ var gameDataSchemas = {
8972
9021
  [EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
8973
9022
  };
8974
9023
  var gameDataDefinition = Object.fromEntries(
8975
- Object.entries(gameDataSchemas).map(([key, schema17]) => [
9024
+ Object.entries(gameDataSchemas).map(([key, schema18]) => [
8976
9025
  key,
8977
- { default: null, required: false, type: schema17 }
9026
+ { default: null, required: false, type: schema18 }
8978
9027
  ])
8979
9028
  );
8980
9029
  var gameHistorySchema = new MongooseSchema23(
@@ -9064,11 +9113,82 @@ var schema16 = new MongooseSchema24(
9064
9113
  },
9065
9114
  { timestamps: true }
9066
9115
  );
9067
- schema16.index({ schoolCode: 1 }, { unique: true });
9116
+ schema16.index(
9117
+ { schoolCode: 1 },
9118
+ {
9119
+ partialFilterExpression: { active: true, deletedAt: null },
9120
+ unique: true
9121
+ }
9122
+ );
9068
9123
  var SchoolModel = mongoose24.models.School || mongoose24.model("School", schema16);
9069
9124
 
9070
- // src/service/database.ts
9125
+ // src/mongoose/Affiliate.ts
9071
9126
  import mongoose25 from "mongoose";
9127
+ var MongooseSchema25 = mongoose25.Schema;
9128
+ var affiliateRewardSchema = new MongooseSchema25(
9129
+ {
9130
+ createdAt: { required: true, type: Date },
9131
+ deletedAt: { default: null, required: false, type: Date },
9132
+ redeemedAt: { default: null, required: false, type: Date },
9133
+ rewardDescription: { required: true, type: String },
9134
+ rewardType: {
9135
+ enum: Object.values(EnumAffiliateRewardType),
9136
+ required: true,
9137
+ type: String
9138
+ },
9139
+ rewardValue: { required: true, type: Number },
9140
+ updatedAt: { default: null, required: false, type: Date }
9141
+ },
9142
+ { _id: false }
9143
+ );
9144
+ var affiliateResourceSchema = new MongooseSchema25(
9145
+ {
9146
+ resourceActive: { default: true, required: true, type: Boolean },
9147
+ resourceId: {
9148
+ required: true,
9149
+ type: mongoose25.Schema.Types.ObjectId
9150
+ },
9151
+ resourceType: {
9152
+ enum: Object.values(EnumResourceType),
9153
+ required: true,
9154
+ type: String
9155
+ },
9156
+ rewards: {
9157
+ default: [],
9158
+ required: false,
9159
+ type: [affiliateRewardSchema]
9160
+ }
9161
+ },
9162
+ { _id: false }
9163
+ );
9164
+ var schema17 = new MongooseSchema25(
9165
+ {
9166
+ affiliateCode: { required: true, type: String },
9167
+ affiliateResources: {
9168
+ default: [],
9169
+ required: false,
9170
+ type: [affiliateResourceSchema]
9171
+ },
9172
+ deletedAt: { default: null, required: false, type: Date },
9173
+ overallPoints: { default: 0, required: true, type: Number },
9174
+ owner: {
9175
+ required: true,
9176
+ type: OwnerTypeSchema
9177
+ }
9178
+ },
9179
+ { timestamps: true }
9180
+ );
9181
+ schema17.index(
9182
+ { affiliateCode: 1 },
9183
+ {
9184
+ partialFilterExpression: { deletedAt: null },
9185
+ unique: true
9186
+ }
9187
+ );
9188
+ var AffiliateModel = mongoose25.models.Affiliate || mongoose25.model("Affiliate", schema17);
9189
+
9190
+ // src/service/database.ts
9191
+ import mongoose26 from "mongoose";
9072
9192
  var connectToDatabase = async ({
9073
9193
  appName,
9074
9194
  dbName,
@@ -9081,7 +9201,7 @@ var connectToDatabase = async ({
9081
9201
  // Fallback to MongoDB Atlas connection string
9082
9202
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
9083
9203
  );
9084
- await mongoose25.connect(mongoUri);
9204
+ await mongoose26.connect(mongoUri);
9085
9205
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
9086
9206
  console.log(
9087
9207
  `${connectionType} connected from server/src/service/database.ts`
@@ -9261,9 +9381,9 @@ async function updateAdStatuses() {
9261
9381
  }
9262
9382
 
9263
9383
  // src/service/associate.ts
9264
- import mongoose26 from "mongoose";
9384
+ import mongoose27 from "mongoose";
9265
9385
  function normalizeObjectId(id) {
9266
- return typeof id === "string" ? new mongoose26.Types.ObjectId(id) : id;
9386
+ return typeof id === "string" ? new mongoose27.Types.ObjectId(id) : id;
9267
9387
  }
9268
9388
  async function getAssociateEmailsForResource({
9269
9389
  normalizedResourceId,
@@ -9415,12 +9535,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
9415
9535
  }
9416
9536
 
9417
9537
  // src/service/objectIdToString.ts
9418
- import mongoose27 from "mongoose";
9538
+ import mongoose28 from "mongoose";
9419
9539
  function convertObjectIdsToStrings(obj) {
9420
9540
  if (obj === null || obj === void 0) {
9421
9541
  return obj;
9422
9542
  }
9423
- if (obj instanceof mongoose27.Types.ObjectId) {
9543
+ if (obj instanceof mongoose28.Types.ObjectId) {
9424
9544
  return obj.toString();
9425
9545
  }
9426
9546
  if (obj instanceof Date) {
@@ -9604,7 +9724,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
9604
9724
 
9605
9725
  // src/types/index.ts
9606
9726
  import express from "express";
9607
- import mongoose28 from "mongoose";
9727
+ import mongoose29 from "mongoose";
9608
9728
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
9609
9729
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
9610
9730
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -9615,6 +9735,7 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
9615
9735
  export {
9616
9736
  APP_SETTINGS_ID,
9617
9737
  AdModel,
9738
+ AffiliateModel,
9618
9739
  AppSettingModel,
9619
9740
  CategorySchema,
9620
9741
  ChatModel,
@@ -9652,7 +9773,7 @@ export {
9652
9773
  findEventOrImportedMarketById,
9653
9774
  locationGeoSchema,
9654
9775
  locationsSchema,
9655
- mongoose28 as mongoose,
9776
+ mongoose29 as mongoose,
9656
9777
  refundPolicySchema,
9657
9778
  relatedPostSchema,
9658
9779
  relationDatesSchema,