@timardex/cluemart-server-shared 1.0.289 → 1.0.291

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, AffiliateRewardType, AffiliateResourceType, AffiliateType, EnumAffiliateRewardType, PromoCodeType, 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, SocialShareResourceType, PosterUsageType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, EnumAffiliateRewardType, PromoCodeType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
3
  import * as mongoose from 'mongoose';
4
4
  import mongoose__default from 'mongoose';
5
5
  export { default as mongoose } from 'mongoose';
@@ -257,6 +257,15 @@ declare const relatedPostSchema: mongoose__default.Schema<SchemaRelatedPostType,
257
257
  } & {
258
258
  __v: number;
259
259
  }>;
260
+ declare const socialShareResourceSchema: mongoose__default.Schema<SocialShareResourceType, mongoose__default.Model<SocialShareResourceType, any, any, any, mongoose__default.Document<unknown, any, SocialShareResourceType, any, {}> & SocialShareResourceType & {
261
+ _id: mongoose__default.Types.ObjectId;
262
+ } & {
263
+ __v: number;
264
+ }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, SocialShareResourceType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<SocialShareResourceType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<SocialShareResourceType> & {
265
+ _id: mongoose__default.Types.ObjectId;
266
+ } & {
267
+ __v: number;
268
+ }>;
260
269
  declare const baseResourceFields: {
261
270
  active: {
262
271
  default: boolean;
@@ -397,6 +406,18 @@ declare const baseResourceFields: {
397
406
  required: boolean;
398
407
  type: NumberConstructor;
399
408
  };
409
+ sharePublic: {
410
+ required: boolean;
411
+ type: mongoose__default.Schema<SocialShareResourceType, mongoose__default.Model<SocialShareResourceType, any, any, any, mongoose__default.Document<unknown, any, SocialShareResourceType, any, {}> & SocialShareResourceType & {
412
+ _id: mongoose__default.Types.ObjectId;
413
+ } & {
414
+ __v: number;
415
+ }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, SocialShareResourceType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<SocialShareResourceType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<SocialShareResourceType> & {
416
+ _id: mongoose__default.Types.ObjectId;
417
+ } & {
418
+ __v: number;
419
+ }>;
420
+ };
400
421
  slug: {
401
422
  required: boolean;
402
423
  type: StringConstructor;
@@ -428,15 +449,6 @@ declare const baseResourceFields: {
428
449
  }>;
429
450
  };
430
451
  };
431
- declare const socialShareResourceSchema: mongoose__default.Schema<SocialShareResourceType, mongoose__default.Model<SocialShareResourceType, any, any, any, mongoose__default.Document<unknown, any, SocialShareResourceType, any, {}> & SocialShareResourceType & {
432
- _id: mongoose__default.Types.ObjectId;
433
- } & {
434
- __v: number;
435
- }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, SocialShareResourceType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<SocialShareResourceType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<SocialShareResourceType> & {
436
- _id: mongoose__default.Types.ObjectId;
437
- } & {
438
- __v: number;
439
- }>;
440
452
 
441
453
  type SchemaGoogleImportedMarket = Omit<GoogleImportedMarket, "eventId" | "claimedByUserId"> & {
442
454
  eventId?: mongoose__default.Types.ObjectId;
@@ -878,6 +890,24 @@ declare const ACTIVE_NOT_DELETED_FILTER: {
878
890
 
879
891
  declare function normalizePromoCode(decoratedPromoCode: string | null | undefined): string | null;
880
892
 
893
+ /**
894
+ * Publish-only pubsub used to emit GraphQL subscription events. Optional in
895
+ * {@link notifyUsers} because non-GraphQL processes (e.g. the cron worker) have
896
+ * no subscribers to publish to.
897
+ */
898
+ type NotificationPubSub = Pick<GraphQLContext["pubsub"], "publish">;
899
+ /** Publishes notification list/count subscription events for a user. */
900
+ declare function publishNotificationEvents(userId: ObjectId, pubsub: NotificationPubSub): Promise<void>;
901
+ /**
902
+ * Sends push notifications, saves them in the database, and (when a `pubsub`
903
+ * is provided) publishes GraphQL subscription events for each affected user.
904
+ * Errors are logged and swallowed; this function never throws.
905
+ */
906
+ declare function notifyUsers({ payload, pubsub, }: {
907
+ payload: SchemaCreateBulkNotificationInput;
908
+ pubsub?: NotificationPubSub;
909
+ }): Promise<void>;
910
+
881
911
  /**
882
912
  * Create notifications in the database for multiple users
883
913
  * This is typically called when sending push notifications
@@ -933,4 +963,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
933
963
  */
934
964
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
935
965
 
936
- export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, 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, activeAffiliateCodeExists, associatesSchema, awardAffiliateVendorSubscriptionRewards, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
966
+ export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type NotificationPubSub, 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, activeAffiliateCodeExists, associatesSchema, awardAffiliateVendorSubscriptionRewards, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, 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, AffiliateRewardType, AffiliateResourceType, AffiliateType, EnumAffiliateRewardType, PromoCodeType, 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, SocialShareResourceType, PosterUsageType, GoogleImportedMarket, PushTokenType, RelationType, ResourceActivityType, UserActivityEvent, UserType, VendorType, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, StallType, RefundPolicy, EventInfoType, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameType, GameDocType, SchoolType, AffiliateRewardType, AffiliateResourceType, AffiliateType, EnumAffiliateRewardType, PromoCodeType, EnumUserLicence, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
3
3
  import * as mongoose from 'mongoose';
4
4
  import mongoose__default from 'mongoose';
5
5
  export { default as mongoose } from 'mongoose';
@@ -257,6 +257,15 @@ declare const relatedPostSchema: mongoose__default.Schema<SchemaRelatedPostType,
257
257
  } & {
258
258
  __v: number;
259
259
  }>;
260
+ declare const socialShareResourceSchema: mongoose__default.Schema<SocialShareResourceType, mongoose__default.Model<SocialShareResourceType, any, any, any, mongoose__default.Document<unknown, any, SocialShareResourceType, any, {}> & SocialShareResourceType & {
261
+ _id: mongoose__default.Types.ObjectId;
262
+ } & {
263
+ __v: number;
264
+ }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, SocialShareResourceType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<SocialShareResourceType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<SocialShareResourceType> & {
265
+ _id: mongoose__default.Types.ObjectId;
266
+ } & {
267
+ __v: number;
268
+ }>;
260
269
  declare const baseResourceFields: {
261
270
  active: {
262
271
  default: boolean;
@@ -397,6 +406,18 @@ declare const baseResourceFields: {
397
406
  required: boolean;
398
407
  type: NumberConstructor;
399
408
  };
409
+ sharePublic: {
410
+ required: boolean;
411
+ type: mongoose__default.Schema<SocialShareResourceType, mongoose__default.Model<SocialShareResourceType, any, any, any, mongoose__default.Document<unknown, any, SocialShareResourceType, any, {}> & SocialShareResourceType & {
412
+ _id: mongoose__default.Types.ObjectId;
413
+ } & {
414
+ __v: number;
415
+ }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, SocialShareResourceType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<SocialShareResourceType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<SocialShareResourceType> & {
416
+ _id: mongoose__default.Types.ObjectId;
417
+ } & {
418
+ __v: number;
419
+ }>;
420
+ };
400
421
  slug: {
401
422
  required: boolean;
402
423
  type: StringConstructor;
@@ -428,15 +449,6 @@ declare const baseResourceFields: {
428
449
  }>;
429
450
  };
430
451
  };
431
- declare const socialShareResourceSchema: mongoose__default.Schema<SocialShareResourceType, mongoose__default.Model<SocialShareResourceType, any, any, any, mongoose__default.Document<unknown, any, SocialShareResourceType, any, {}> & SocialShareResourceType & {
432
- _id: mongoose__default.Types.ObjectId;
433
- } & {
434
- __v: number;
435
- }, any>, {}, {}, {}, {}, mongoose__default.DefaultSchemaOptions, SocialShareResourceType, mongoose__default.Document<unknown, {}, mongoose__default.FlatRecord<SocialShareResourceType>, {}, mongoose__default.ResolveSchemaOptions<mongoose__default.DefaultSchemaOptions>> & mongoose__default.FlatRecord<SocialShareResourceType> & {
436
- _id: mongoose__default.Types.ObjectId;
437
- } & {
438
- __v: number;
439
- }>;
440
452
 
441
453
  type SchemaGoogleImportedMarket = Omit<GoogleImportedMarket, "eventId" | "claimedByUserId"> & {
442
454
  eventId?: mongoose__default.Types.ObjectId;
@@ -878,6 +890,24 @@ declare const ACTIVE_NOT_DELETED_FILTER: {
878
890
 
879
891
  declare function normalizePromoCode(decoratedPromoCode: string | null | undefined): string | null;
880
892
 
893
+ /**
894
+ * Publish-only pubsub used to emit GraphQL subscription events. Optional in
895
+ * {@link notifyUsers} because non-GraphQL processes (e.g. the cron worker) have
896
+ * no subscribers to publish to.
897
+ */
898
+ type NotificationPubSub = Pick<GraphQLContext["pubsub"], "publish">;
899
+ /** Publishes notification list/count subscription events for a user. */
900
+ declare function publishNotificationEvents(userId: ObjectId, pubsub: NotificationPubSub): Promise<void>;
901
+ /**
902
+ * Sends push notifications, saves them in the database, and (when a `pubsub`
903
+ * is provided) publishes GraphQL subscription events for each affected user.
904
+ * Errors are logged and swallowed; this function never throws.
905
+ */
906
+ declare function notifyUsers({ payload, pubsub, }: {
907
+ payload: SchemaCreateBulkNotificationInput;
908
+ pubsub?: NotificationPubSub;
909
+ }): Promise<void>;
910
+
881
911
  /**
882
912
  * Create notifications in the database for multiple users
883
913
  * This is typically called when sending push notifications
@@ -933,4 +963,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
933
963
  */
934
964
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
935
965
 
936
- export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, 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, activeAffiliateCodeExists, associatesSchema, awardAffiliateVendorSubscriptionRewards, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
966
+ export { ACTIVE_NOT_DELETED_FILTER, AFFILIATE_REWARDS, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type NotificationPubSub, 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, activeAffiliateCodeExists, associatesSchema, awardAffiliateVendorSubscriptionRewards, baseResourceFields, connectToDatabase, convertObjectIdsToStrings, createAffiliateReward, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getSubscriptionRewardPeriodBounds, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
package/dist/index.mjs CHANGED
@@ -8203,6 +8203,14 @@ var relatedPostSchema = new MongooseSchema6(
8203
8203
  { _id: false }
8204
8204
  // Prevents Mongoose from creating an additional _id field for subdocuments
8205
8205
  );
8206
+ var socialShareResourceSchema = new MongooseSchema6(
8207
+ {
8208
+ qrCode: { required: true, type: ResourceImageTypeSchema },
8209
+ socialImage: { required: true, type: ResourceImageTypeSchema }
8210
+ },
8211
+ { _id: false }
8212
+ // Prevents Mongoose from creating an additional _id field for subdocuments
8213
+ );
8206
8214
  var baseResourceFields = {
8207
8215
  active: { default: false, required: true, type: Boolean },
8208
8216
  adIds: {
@@ -8234,18 +8242,11 @@ var baseResourceFields = {
8234
8242
  region: { required: true, type: String },
8235
8243
  relatedPost: { required: false, type: relatedPostSchema },
8236
8244
  reviewCount: { required: false, type: Number },
8245
+ sharePublic: { required: false, type: socialShareResourceSchema },
8237
8246
  slug: { required: true, type: String },
8238
8247
  socialMedia: { required: false, type: [SocialMediaTypeSchema] },
8239
8248
  termsAgreement: { required: true, type: termsAgreementSchema }
8240
8249
  };
8241
- var socialShareResourceSchema = new MongooseSchema6(
8242
- {
8243
- qrCode: { required: true, type: ResourceImageTypeSchema },
8244
- socialImage: { required: true, type: ResourceImageTypeSchema }
8245
- },
8246
- { _id: false }
8247
- // Prevents Mongoose from creating an additional _id field for subdocuments
8248
- );
8249
8250
 
8250
8251
  // src/mongoose/GoogleImportedMarket.ts
8251
8252
  import mongoose7 from "mongoose";
@@ -8722,7 +8723,6 @@ var schema9 = new MongooseSchema13(
8722
8723
  required: false,
8723
8724
  type: [resourceRelationsSchema]
8724
8725
  },
8725
- sharePublic: { required: false, type: socialShareResourceSchema },
8726
8726
  shareRelation: { required: false, type: socialShareResourceSchema },
8727
8727
  unregisteredVendorId: {
8728
8728
  ref: "UnregisteredVendor",
@@ -8875,7 +8875,6 @@ var schema12 = new MongooseSchema16(
8875
8875
  required: false,
8876
8876
  type: [resourceRelationsSchema]
8877
8877
  },
8878
- sharePublic: { required: false, type: socialShareResourceSchema },
8879
8878
  shareRelation: { required: false, type: socialShareResourceSchema },
8880
8879
  tags: { required: true, type: [String] }
8881
8880
  },
@@ -8907,8 +8906,7 @@ var schema13 = new MongooseSchema17(
8907
8906
  enum: Object.values(EnumPartnerType),
8908
8907
  required: true,
8909
8908
  type: String
8910
- },
8911
- sharePublic: { required: false, type: socialShareResourceSchema }
8909
+ }
8912
8910
  },
8913
8911
  { timestamps: true }
8914
8912
  );
@@ -9761,6 +9759,60 @@ var connectToDatabase = async ({
9761
9759
  }
9762
9760
  };
9763
9761
 
9762
+ // src/types/index.ts
9763
+ import express from "express";
9764
+ import mongoose27 from "mongoose";
9765
+ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
9766
+ EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
9767
+ EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
9768
+ EnumPubSubEvents2["GET_NOTIFICATIONS_COUNT"] = "GET_NOTIFICATIONS_COUNT";
9769
+ EnumPubSubEvents2["USER_TYPING"] = "USER_TYPING";
9770
+ return EnumPubSubEvents2;
9771
+ })(EnumPubSubEvents || {});
9772
+
9773
+ // src/service/notifyUsers.ts
9774
+ async function publishNotificationEvents(userId, pubsub) {
9775
+ try {
9776
+ const userNotifications = await NotificationModel.find({
9777
+ userId
9778
+ }).sort({ createdAt: -1 });
9779
+ const [total, unread] = await Promise.all([
9780
+ NotificationModel.countDocuments({ userId }),
9781
+ NotificationModel.countDocuments({ isRead: false, userId })
9782
+ ]);
9783
+ pubsub.publish("GET_NOTIFICATIONS" /* GET_NOTIFICATIONS */, {
9784
+ getNotifications: userNotifications,
9785
+ getNotificationsUserId: userId
9786
+ });
9787
+ pubsub.publish("GET_NOTIFICATIONS_COUNT" /* GET_NOTIFICATIONS_COUNT */, {
9788
+ getNotificationsCount: { total, unread, userId }
9789
+ });
9790
+ console.log(`Published notification events for user: ${String(userId)}`);
9791
+ } catch (error) {
9792
+ console.error(
9793
+ `Failed to publish notification events for user ${String(userId)}:`,
9794
+ error
9795
+ );
9796
+ }
9797
+ }
9798
+ async function notifyUsers({
9799
+ payload,
9800
+ pubsub
9801
+ }) {
9802
+ try {
9803
+ await sendPushNotifications(payload);
9804
+ const uniqueUserIds = await saveNotificationsInDb(payload);
9805
+ if (!pubsub) {
9806
+ return;
9807
+ }
9808
+ for (const userId of uniqueUserIds) {
9809
+ await publishNotificationEvents(userId, pubsub);
9810
+ }
9811
+ } catch (error) {
9812
+ console.error("Error in notifyUsers:", error);
9813
+ }
9814
+ }
9815
+
9764
9816
  // src/service/updateAdStatus.ts
9765
9817
  async function updateAdStatuses() {
9766
9818
  const now = /* @__PURE__ */ new Date();
@@ -9797,9 +9849,9 @@ async function updateAdStatuses() {
9797
9849
  }
9798
9850
 
9799
9851
  // src/service/associate.ts
9800
- import mongoose27 from "mongoose";
9852
+ import mongoose28 from "mongoose";
9801
9853
  function normalizeObjectId(id) {
9802
- return typeof id === "string" ? new mongoose27.Types.ObjectId(id) : id;
9854
+ return typeof id === "string" ? new mongoose28.Types.ObjectId(id) : id;
9803
9855
  }
9804
9856
  async function getAssociateEmailsForResource({
9805
9857
  normalizedResourceId,
@@ -9951,12 +10003,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
9951
10003
  }
9952
10004
 
9953
10005
  // src/service/objectIdToString.ts
9954
- import mongoose28 from "mongoose";
10006
+ import mongoose29 from "mongoose";
9955
10007
  function convertObjectIdsToStrings(obj) {
9956
10008
  if (obj === null || obj === void 0) {
9957
10009
  return obj;
9958
10010
  }
9959
- if (obj instanceof mongoose28.Types.ObjectId) {
10011
+ if (obj instanceof mongoose29.Types.ObjectId) {
9960
10012
  return obj.toString();
9961
10013
  }
9962
10014
  if (obj instanceof Date) {
@@ -10137,17 +10189,6 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
10137
10189
  };
10138
10190
  });
10139
10191
  }
10140
-
10141
- // src/types/index.ts
10142
- import express from "express";
10143
- import mongoose29 from "mongoose";
10144
- var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
10145
- EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
10146
- EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
10147
- EnumPubSubEvents2["GET_NOTIFICATIONS_COUNT"] = "GET_NOTIFICATIONS_COUNT";
10148
- EnumPubSubEvents2["USER_TYPING"] = "USER_TYPING";
10149
- return EnumPubSubEvents2;
10150
- })(EnumPubSubEvents || {});
10151
10192
  export {
10152
10193
  ACTIVE_NOT_DELETED_FILTER,
10153
10194
  AFFILIATE_REWARDS,
@@ -10197,9 +10238,11 @@ export {
10197
10238
  locationGeoSchema,
10198
10239
  locationsSchema,
10199
10240
  mapVendorLicenceToSubscriptionRewardType,
10200
- mongoose29 as mongoose,
10241
+ mongoose27 as mongoose,
10201
10242
  normalizeAffiliatePromoCodes,
10202
10243
  normalizePromoCode,
10244
+ notifyUsers,
10245
+ publishNotificationEvents,
10203
10246
  refundPolicySchema,
10204
10247
  relatedPostSchema,
10205
10248
  relationDatesSchema,