@timardex/cluemart-server-shared 1.0.207 → 1.0.208

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
@@ -721,6 +721,12 @@ type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
721
721
  * @returns A promise that resolves to either an Event or a Google Imported Market object containing _id and name, or null if not found.
722
722
  */
723
723
  declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
724
+ /**
725
+ * Updates the dateStatus field for a single DateTimeType object based on the current date/time
726
+ * @param dateTime The date-time object to update
727
+ * @returns A new object with updated dateStatus value
728
+ */
729
+ declare function updateSingleDateTimeStatus<T extends DateTimeType>(dateTime: T): T;
724
730
 
725
731
  type EventDateSlot = Pick<DateTimeType$1, "startDate" | "startTime">;
726
732
  /**
@@ -734,4 +740,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
734
740
  */
735
741
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
736
742
 
737
- 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 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, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateRelationDatesToUnavailable, updateVendorBasedOnUserLicense, userLicenseSchema };
743
+ 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 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, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
package/dist/index.d.ts CHANGED
@@ -721,6 +721,12 @@ type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
721
721
  * @returns A promise that resolves to either an Event or a Google Imported Market object containing _id and name, or null if not found.
722
722
  */
723
723
  declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
724
+ /**
725
+ * Updates the dateStatus field for a single DateTimeType object based on the current date/time
726
+ * @param dateTime The date-time object to update
727
+ * @returns A new object with updated dateStatus value
728
+ */
729
+ declare function updateSingleDateTimeStatus<T extends DateTimeType>(dateTime: T): T;
724
730
 
725
731
  type EventDateSlot = Pick<DateTimeType$1, "startDate" | "startTime">;
726
732
  /**
@@ -734,4 +740,4 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
734
740
  */
735
741
  declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
736
742
 
737
- 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 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, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateRelationDatesToUnavailable, updateVendorBasedOnUserLicense, userLicenseSchema };
743
+ 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 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, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, termsAgreementSchema, updateAdStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema };
package/dist/index.mjs CHANGED
@@ -3477,6 +3477,8 @@ var gameScreenIdentifierList = [
3477
3477
  match: "/visitors"
3478
3478
  }
3479
3479
  ];
3480
+ var dateFormat = "DD-MM-YYYY";
3481
+ var timeFormat = "HH:mm";
3480
3482
  dayjs.extend(customParseFormat);
3481
3483
  dayjs.extend(utc);
3482
3484
  dayjs.extend(timezone);
@@ -9086,6 +9088,15 @@ function convertObjectIdsToStrings(obj) {
9086
9088
  }
9087
9089
 
9088
9090
  // src/service/event.ts
9091
+ import dayjs2 from "dayjs";
9092
+ import customParseFormat2 from "dayjs/plugin/customParseFormat";
9093
+ import isoWeek from "dayjs/plugin/isoWeek";
9094
+ import isToday from "dayjs/plugin/isToday";
9095
+ import isTomorrow from "dayjs/plugin/isTomorrow";
9096
+ dayjs2.extend(customParseFormat2);
9097
+ dayjs2.extend(isToday);
9098
+ dayjs2.extend(isTomorrow);
9099
+ dayjs2.extend(isoWeek);
9089
9100
  async function findEventOrImportedMarketById(resourceId) {
9090
9101
  if (!resourceId) {
9091
9102
  return null;
@@ -9097,6 +9108,54 @@ async function findEventOrImportedMarketById(resourceId) {
9097
9108
  ]);
9098
9109
  return eventDoc ?? googleImportedDoc;
9099
9110
  }
9111
+ function getFutureEventStatus(startDateTime, now) {
9112
+ if (startDateTime.isToday()) {
9113
+ return EnumEventDateStatus.TODAY;
9114
+ }
9115
+ if (startDateTime.isTomorrow()) {
9116
+ return EnumEventDateStatus.TOMORROW;
9117
+ }
9118
+ if (startDateTime.isSame(now, "isoWeek")) {
9119
+ return EnumEventDateStatus.THIS_WEEK;
9120
+ }
9121
+ if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
9122
+ return EnumEventDateStatus.NEXT_WEEK;
9123
+ }
9124
+ const hoursUntilStart = startDateTime.diff(now, "hour", true);
9125
+ if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
9126
+ return EnumEventDateStatus.STARTING_SOON;
9127
+ }
9128
+ return EnumEventDateStatus.UPCOMING;
9129
+ }
9130
+ function updateSingleDateTimeStatus(dateTime) {
9131
+ const now = dayjs2();
9132
+ const startDateTime = dayjs2(
9133
+ `${dateTime.startDate} ${dateTime.startTime}`,
9134
+ `${dateFormat} ${timeFormat}`
9135
+ );
9136
+ const endDateTime = dayjs2(
9137
+ `${dateTime.endDate} ${dateTime.endTime}`,
9138
+ `${dateFormat} ${timeFormat}`
9139
+ );
9140
+ if (!startDateTime.isValid() || !endDateTime.isValid()) {
9141
+ return {
9142
+ ...dateTime,
9143
+ dateStatus: null
9144
+ };
9145
+ }
9146
+ let dateStatus = null;
9147
+ if (endDateTime.isBefore(now)) {
9148
+ dateStatus = EnumEventDateStatus.ENDED;
9149
+ } else if (startDateTime.isBefore(now) && endDateTime.isAfter(now)) {
9150
+ dateStatus = EnumEventDateStatus.STARTED;
9151
+ } else {
9152
+ dateStatus = getFutureEventStatus(startDateTime, now);
9153
+ }
9154
+ return {
9155
+ ...dateTime,
9156
+ dateStatus
9157
+ };
9158
+ }
9100
9159
 
9101
9160
  // src/service/relations.ts
9102
9161
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
@@ -9180,6 +9239,7 @@ export {
9180
9239
  termsAgreementSchema,
9181
9240
  updateAdStatuses,
9182
9241
  updateRelationDatesToUnavailable,
9242
+ updateSingleDateTimeStatus,
9183
9243
  updateVendorBasedOnUserLicense,
9184
9244
  userLicenseSchema
9185
9245
  };