@timardex/cluemart-server-shared 1.0.95 → 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
@@ -8553,8 +8553,8 @@ var VENDOR_DATETIME_FIELDS_FRAGMENT = gql`
8553
8553
  startTime
8554
8554
  }
8555
8555
  `;
8556
- var VENDOR_PRODUCT_FIELDS_FRAGMENT = gql`
8557
- fragment VendorProductFields on VendorProductType {
8556
+ var VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT = gql`
8557
+ fragment VendorProductListFields on VendorProductListType {
8558
8558
  description
8559
8559
  name
8560
8560
  price
@@ -8612,8 +8612,8 @@ var VENDOR = gql`
8612
8612
  }
8613
8613
  products {
8614
8614
  active
8615
- productsData {
8616
- ...VendorProductFields
8615
+ productsList {
8616
+ ...VendorProductListFields
8617
8617
  }
8618
8618
  }
8619
8619
  promoCodes
@@ -8646,7 +8646,7 @@ var VENDOR = gql`
8646
8646
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
8647
8647
  ${POSTER_USAGE_FIELDS_FRAGMENT}
8648
8648
  ${ASSOCIATES_FIELDS_FRAGMENT}
8649
- ${VENDOR_PRODUCT_FIELDS_FRAGMENT}
8649
+ ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
8650
8650
  ${CONTACT_DETAILS_FIELDS_FRAGMENT}
8651
8651
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
8652
8652
  ${RELATION_DATES_FRAGMENT}
@@ -10249,7 +10249,7 @@ var vendorSchema = globalResourceSchema.shape({
10249
10249
  categories: categorySchema.min(1, "Category list must contain at least one item").required("Categories are required"),
10250
10250
  foodTruck: create$7().label("Food Truck").required("Please specify if the vendor is a food truck"),
10251
10251
  products: create$3().shape({
10252
- productsData: create$2().of(vendroMenuSchema).nullable().optional()
10252
+ productsList: create$2().of(vendroMenuSchema).nullable().optional()
10253
10253
  }).nullable().optional(),
10254
10254
  vendorType: create$8().oneOf(Object.values(EnumVendorType)).required("Please select a Vendor type")
10255
10255
  });
@@ -11555,7 +11555,7 @@ var productTypeSchema = new MongooseSchema13(
11555
11555
  var productWrapperSchema = new MongooseSchema13(
11556
11556
  {
11557
11557
  active: { default: false, type: Boolean },
11558
- productData: { required: false, type: [productTypeSchema] }
11558
+ productsList: { required: false, type: [productTypeSchema] }
11559
11559
  },
11560
11560
  { _id: false }
11561
11561
  );
@@ -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: