@timardex/cluemart-server-shared 1.0.96 → 1.0.97

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
@@ -647,4 +647,16 @@ declare function sendPushNotifications({ data, message, title, userIds, }: Schem
647
647
  */
648
648
  declare function updateAdStatuses(): Promise<void>;
649
649
 
650
- export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, EnumPubSubEvents, EventInfoModel, EventModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, ParticipantSchema, 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 SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, dateTimeSchema, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, userLicenseSchema };
650
+ /**
651
+ *
652
+ * This function updates the vendor's features based on the user's license.
653
+ * It checks the type of license and updates the vendor's associates and availability accordingly.
654
+ * If the user has a Pro Vendor license, they can have multiple associates and access to all availability types.
655
+ * If they have a Standard Vendor license, their associates are removed and availability is restricted.
656
+ * @param userId
657
+ * @param licenceObject
658
+ * @returns
659
+ */
660
+ declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceObject: UserLicenceType): Promise<null>;
661
+
662
+ export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, EnumPubSubEvents, EventInfoModel, EventModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, ParticipantSchema, 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 SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, dateTimeSchema, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateVendorBasedOnUserLicense, userLicenseSchema };
package/dist/index.d.ts CHANGED
@@ -647,4 +647,16 @@ declare function sendPushNotifications({ data, message, title, userIds, }: Schem
647
647
  */
648
648
  declare function updateAdStatuses(): Promise<void>;
649
649
 
650
- export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, EnumPubSubEvents, EventInfoModel, EventModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, ParticipantSchema, 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 SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, dateTimeSchema, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, userLicenseSchema };
650
+ /**
651
+ *
652
+ * This function updates the vendor's features based on the user's license.
653
+ * It checks the type of license and updates the vendor's associates and availability accordingly.
654
+ * If the user has a Pro Vendor license, they can have multiple associates and access to all availability types.
655
+ * If they have a Standard Vendor license, their associates are removed and availability is restricted.
656
+ * @param userId
657
+ * @param licenceObject
658
+ * @returns
659
+ */
660
+ declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceObject: UserLicenceType): Promise<null>;
661
+
662
+ export { APP_SETTINGS_ID, AdModel, AppSettingModel, type AuthUser, CategorySchema, ChatModel, ChatReportModel, EnumPubSubEvents, EventInfoModel, EventModel, GoogleImportedMarketModel, type GraphQLContext, NotificationModel, type ObjectId, ParticipantSchema, 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 SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelationType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, associatesSchema, baseResourceFields, connectToDatabase, dateTimeSchema, locationGeoSchema, locationsSchema, refundPolicySchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateVendorBasedOnUserLicense, userLicenseSchema };
package/dist/index.mjs CHANGED
@@ -12020,6 +12020,63 @@ async function updateAdStatuses() {
12020
12020
  );
12021
12021
  }
12022
12022
 
12023
+ // src/service/vendor.ts
12024
+ async function updateVendorBasedOnUserLicense(userId, licenceObject) {
12025
+ try {
12026
+ const user = await UserModel.findById(userId).exec();
12027
+ if (!user) {
12028
+ return null;
12029
+ }
12030
+ const userVendor = await VendorModel.findById(user.vendor).exec();
12031
+ if (!userVendor) {
12032
+ return null;
12033
+ }
12034
+ const selectedLicence = licenceObject.licenceType;
12035
+ if (selectedLicence === void 0) {
12036
+ return null;
12037
+ }
12038
+ const vendorUpdateData = {
12039
+ owner: {
12040
+ email: user.email,
12041
+ userId
12042
+ }
12043
+ };
12044
+ if (selectedLicence === EnumUserLicence.STANDARD_VENDOR) {
12045
+ vendorUpdateData.associates = [];
12046
+ vendorUpdateData.availability = {
12047
+ corporate: false,
12048
+ private: false,
12049
+ school: false
12050
+ };
12051
+ vendorUpdateData.products = {
12052
+ active: false,
12053
+ productsList: userVendor.products?.productsList || []
12054
+ };
12055
+ vendorUpdateData.calendar = {
12056
+ active: false,
12057
+ calendarData: userVendor.calendar?.calendarData || []
12058
+ };
12059
+ vendorUpdateData.images = (userVendor.images || []).map((img, index) => ({
12060
+ active: index < 6,
12061
+ // first 6 will be true, the rest false
12062
+ source: img.source,
12063
+ title: img.title
12064
+ }));
12065
+ }
12066
+ await VendorModel.findByIdAndUpdate(
12067
+ userVendor._id,
12068
+ {
12069
+ $set: vendorUpdateData
12070
+ },
12071
+ { new: true }
12072
+ );
12073
+ return null;
12074
+ } catch (error) {
12075
+ console.error("Error updating vendor based on user license:", error);
12076
+ return null;
12077
+ }
12078
+ }
12079
+
12023
12080
  // src/types/index.ts
12024
12081
  import express from "express";
12025
12082
  import mongoose20 from "mongoose";
@@ -12071,6 +12128,7 @@ export {
12071
12128
  sendPushNotifications,
12072
12129
  termsAgreementSchema,
12073
12130
  updateAdStatuses,
12131
+ updateVendorBasedOnUserLicense,
12074
12132
  userLicenseSchema
12075
12133
  };
12076
12134
  /*! Bundled license information: