@timardex/cluemart-server-shared 2.2.1 → 2.2.12

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.cjs CHANGED
@@ -145,7 +145,7 @@ __export(index_exports, {
145
145
  updateAdStatuses: () => updateAdStatuses,
146
146
  updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
147
147
  updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
148
- updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
148
+ updateSingleDateTimeStatus: () => import_cluemart_shared34.updateSingleDateTimeStatus,
149
149
  upgradeUserToLicence: () => upgradeUserToLicence,
150
150
  userLicenseSchema: () => userLicenseSchema,
151
151
  vendorOwnerHasProLicence: () => vendorOwnerHasProLicence,
@@ -3196,8 +3196,6 @@ function convertObjectIdsToStrings(obj) {
3196
3196
  // src/service/event/updateAllEventDateTimeStatuses.ts
3197
3197
  var import_cluemart_shared26 = require("@timardex/cluemart-shared");
3198
3198
  var import_dayjs2 = __toESM(require("dayjs"));
3199
- var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
3200
- var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
3201
3199
 
3202
3200
  // src/service/event/archiveEndedEventDates.ts
3203
3201
  var import_cluemart_shared25 = require("@timardex/cluemart-shared");
@@ -3240,73 +3238,6 @@ async function persistArchivedEventDates(eventId, slots) {
3240
3238
  }
3241
3239
 
3242
3240
  // src/service/event/updateAllEventDateTimeStatuses.ts
3243
- import_dayjs2.default.extend(import_customParseFormat.default);
3244
- import_dayjs2.default.extend(import_isoWeek.default);
3245
- var MANUAL_DATE_STATUSES = /* @__PURE__ */ new Set([
3246
- import_cluemart_shared26.EnumEventDateStatus.CANCELED,
3247
- import_cluemart_shared26.EnumEventDateStatus.RE_SCHEDULED
3248
- ]);
3249
- function getFutureEventStatus(startDateTime, now) {
3250
- const hoursUntilStart = startDateTime.diff(now, "hour", true);
3251
- if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
3252
- return import_cluemart_shared26.EnumEventDateStatus.STARTING_SOON;
3253
- }
3254
- if (startDateTime.isSame(now, "day")) {
3255
- return import_cluemart_shared26.EnumEventDateStatus.TODAY;
3256
- }
3257
- if (startDateTime.isSame(now.add(1, "day"), "day")) {
3258
- return import_cluemart_shared26.EnumEventDateStatus.TOMORROW;
3259
- }
3260
- if (startDateTime.isSame(now, "isoWeek")) {
3261
- return import_cluemart_shared26.EnumEventDateStatus.THIS_WEEK;
3262
- }
3263
- if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
3264
- return import_cluemart_shared26.EnumEventDateStatus.NEXT_WEEK;
3265
- }
3266
- return import_cluemart_shared26.EnumEventDateStatus.UPCOMING;
3267
- }
3268
- function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()) {
3269
- if (MANUAL_DATE_STATUSES.has(dateTime.dateStatus)) {
3270
- return dateTime;
3271
- }
3272
- const dateTimeFormat = `${import_cluemart_shared26.dateFormat} ${import_cluemart_shared26.timeFormat}`;
3273
- const startDateTime = (0, import_dayjs2.default)(
3274
- `${dateTime.startDate} ${dateTime.startTime}`,
3275
- dateTimeFormat,
3276
- true
3277
- );
3278
- const endDateTime = (0, import_dayjs2.default)(
3279
- `${dateTime.endDate} ${dateTime.endTime}`,
3280
- dateTimeFormat,
3281
- true
3282
- );
3283
- if (!startDateTime.isValid() || !endDateTime.isValid()) {
3284
- return {
3285
- ...dateTime,
3286
- dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
3287
- };
3288
- }
3289
- if (endDateTime.isBefore(startDateTime)) {
3290
- return {
3291
- ...dateTime,
3292
- dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
3293
- };
3294
- }
3295
- let dateStatus;
3296
- if (endDateTime.isAfter(now)) {
3297
- if (startDateTime.isAfter(now)) {
3298
- dateStatus = getFutureEventStatus(startDateTime, now);
3299
- } else {
3300
- dateStatus = import_cluemart_shared26.EnumEventDateStatus.STARTED;
3301
- }
3302
- } else {
3303
- dateStatus = import_cluemart_shared26.EnumEventDateStatus.ENDED;
3304
- }
3305
- return {
3306
- ...dateTime,
3307
- dateStatus
3308
- };
3309
- }
3310
3241
  var dateTimeStatusFilter = {
3311
3242
  dateTime: { $ne: [], $type: "array" },
3312
3243
  deletedAt: null
@@ -3335,7 +3266,7 @@ async function updateModelDateTimeStatuses(model, now) {
3335
3266
  try {
3336
3267
  for await (const doc of cursor) {
3337
3268
  const dateTime = doc.dateTime.map(
3338
- (slot) => updateSingleDateTimeStatus(slot, now)
3269
+ (slot) => (0, import_cluemart_shared26.updateSingleDateTimeStatus)(slot, now)
3339
3270
  );
3340
3271
  if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
3341
3272
  continue;
@@ -3380,7 +3311,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3380
3311
  try {
3381
3312
  for await (const doc of cursor) {
3382
3313
  const updated = doc.dateTime.map(
3383
- (slot) => updateSingleDateTimeStatus(slot, now)
3314
+ (slot) => (0, import_cluemart_shared26.updateSingleDateTimeStatus)(slot, now)
3384
3315
  );
3385
3316
  const { archive, discard } = splitEventDatesForArchive(updated);
3386
3317
  if (archive.length === 0 && discard.length === 0) {
@@ -3438,7 +3369,7 @@ async function cleanEventInfoDates(now) {
3438
3369
  try {
3439
3370
  for await (const doc of cursor) {
3440
3371
  const updated = doc.dateTime.map(
3441
- (slot) => updateSingleDateTimeStatus(slot, now)
3372
+ (slot) => (0, import_cluemart_shared26.updateSingleDateTimeStatus)(slot, now)
3442
3373
  );
3443
3374
  const kept = (0, import_cluemart_shared26.filterDatesByFutureStatus)(updated);
3444
3375
  if (kept.length === updated.length) {
@@ -3485,6 +3416,9 @@ async function updateAllEventDateTimeStatuses() {
3485
3416
  }
3486
3417
  }
3487
3418
 
3419
+ // src/service/index.ts
3420
+ var import_cluemart_shared34 = require("@timardex/cluemart-shared");
3421
+
3488
3422
  // src/service/event/findEventOrImportedMarketById.ts
3489
3423
  async function findEventOrImportedMarketById(resourceId) {
3490
3424
  if (!resourceId) {