@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 +7 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -10
- package/dist/index.d.ts +3 -10
- package/dist/index.mjs +7 -74
- package/dist/index.mjs.map +1 -1
- package/dist/service/index.cjs +7 -73
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +3 -10
- package/dist/service/index.d.ts +3 -10
- package/dist/service/index.mjs +7 -74
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/service/index.cjs
CHANGED
|
@@ -91,7 +91,7 @@ __export(service_exports, {
|
|
|
91
91
|
updateAdStatuses: () => updateAdStatuses,
|
|
92
92
|
updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
|
|
93
93
|
updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
|
|
94
|
-
updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
|
|
94
|
+
updateSingleDateTimeStatus: () => import_cluemart_shared34.updateSingleDateTimeStatus,
|
|
95
95
|
upgradeUserToLicence: () => upgradeUserToLicence,
|
|
96
96
|
vendorOwnerHasProLicence: () => vendorOwnerHasProLicence
|
|
97
97
|
});
|
|
@@ -3105,8 +3105,6 @@ function convertObjectIdsToStrings(obj) {
|
|
|
3105
3105
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
3106
3106
|
var import_cluemart_shared26 = require("@timardex/cluemart-shared");
|
|
3107
3107
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
3108
|
-
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
3109
|
-
var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
|
|
3110
3108
|
|
|
3111
3109
|
// src/service/event/archiveEndedEventDates.ts
|
|
3112
3110
|
var import_cluemart_shared25 = require("@timardex/cluemart-shared");
|
|
@@ -3149,73 +3147,6 @@ async function persistArchivedEventDates(eventId, slots) {
|
|
|
3149
3147
|
}
|
|
3150
3148
|
|
|
3151
3149
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
3152
|
-
import_dayjs2.default.extend(import_customParseFormat.default);
|
|
3153
|
-
import_dayjs2.default.extend(import_isoWeek.default);
|
|
3154
|
-
var MANUAL_DATE_STATUSES = /* @__PURE__ */ new Set([
|
|
3155
|
-
import_cluemart_shared26.EnumEventDateStatus.CANCELED,
|
|
3156
|
-
import_cluemart_shared26.EnumEventDateStatus.RE_SCHEDULED
|
|
3157
|
-
]);
|
|
3158
|
-
function getFutureEventStatus(startDateTime, now) {
|
|
3159
|
-
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
3160
|
-
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
3161
|
-
return import_cluemart_shared26.EnumEventDateStatus.STARTING_SOON;
|
|
3162
|
-
}
|
|
3163
|
-
if (startDateTime.isSame(now, "day")) {
|
|
3164
|
-
return import_cluemart_shared26.EnumEventDateStatus.TODAY;
|
|
3165
|
-
}
|
|
3166
|
-
if (startDateTime.isSame(now.add(1, "day"), "day")) {
|
|
3167
|
-
return import_cluemart_shared26.EnumEventDateStatus.TOMORROW;
|
|
3168
|
-
}
|
|
3169
|
-
if (startDateTime.isSame(now, "isoWeek")) {
|
|
3170
|
-
return import_cluemart_shared26.EnumEventDateStatus.THIS_WEEK;
|
|
3171
|
-
}
|
|
3172
|
-
if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
|
|
3173
|
-
return import_cluemart_shared26.EnumEventDateStatus.NEXT_WEEK;
|
|
3174
|
-
}
|
|
3175
|
-
return import_cluemart_shared26.EnumEventDateStatus.UPCOMING;
|
|
3176
|
-
}
|
|
3177
|
-
function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()) {
|
|
3178
|
-
if (MANUAL_DATE_STATUSES.has(dateTime.dateStatus)) {
|
|
3179
|
-
return dateTime;
|
|
3180
|
-
}
|
|
3181
|
-
const dateTimeFormat = `${import_cluemart_shared26.dateFormat} ${import_cluemart_shared26.timeFormat}`;
|
|
3182
|
-
const startDateTime = (0, import_dayjs2.default)(
|
|
3183
|
-
`${dateTime.startDate} ${dateTime.startTime}`,
|
|
3184
|
-
dateTimeFormat,
|
|
3185
|
-
true
|
|
3186
|
-
);
|
|
3187
|
-
const endDateTime = (0, import_dayjs2.default)(
|
|
3188
|
-
`${dateTime.endDate} ${dateTime.endTime}`,
|
|
3189
|
-
dateTimeFormat,
|
|
3190
|
-
true
|
|
3191
|
-
);
|
|
3192
|
-
if (!startDateTime.isValid() || !endDateTime.isValid()) {
|
|
3193
|
-
return {
|
|
3194
|
-
...dateTime,
|
|
3195
|
-
dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
|
|
3196
|
-
};
|
|
3197
|
-
}
|
|
3198
|
-
if (endDateTime.isBefore(startDateTime)) {
|
|
3199
|
-
return {
|
|
3200
|
-
...dateTime,
|
|
3201
|
-
dateStatus: import_cluemart_shared26.EnumEventDateStatus.INVALID
|
|
3202
|
-
};
|
|
3203
|
-
}
|
|
3204
|
-
let dateStatus;
|
|
3205
|
-
if (endDateTime.isAfter(now)) {
|
|
3206
|
-
if (startDateTime.isAfter(now)) {
|
|
3207
|
-
dateStatus = getFutureEventStatus(startDateTime, now);
|
|
3208
|
-
} else {
|
|
3209
|
-
dateStatus = import_cluemart_shared26.EnumEventDateStatus.STARTED;
|
|
3210
|
-
}
|
|
3211
|
-
} else {
|
|
3212
|
-
dateStatus = import_cluemart_shared26.EnumEventDateStatus.ENDED;
|
|
3213
|
-
}
|
|
3214
|
-
return {
|
|
3215
|
-
...dateTime,
|
|
3216
|
-
dateStatus
|
|
3217
|
-
};
|
|
3218
|
-
}
|
|
3219
3150
|
var dateTimeStatusFilter = {
|
|
3220
3151
|
dateTime: { $ne: [], $type: "array" },
|
|
3221
3152
|
deletedAt: null
|
|
@@ -3244,7 +3175,7 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3244
3175
|
try {
|
|
3245
3176
|
for await (const doc of cursor) {
|
|
3246
3177
|
const dateTime = doc.dateTime.map(
|
|
3247
|
-
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3178
|
+
(slot) => (0, import_cluemart_shared26.updateSingleDateTimeStatus)(slot, now)
|
|
3248
3179
|
);
|
|
3249
3180
|
if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
|
|
3250
3181
|
continue;
|
|
@@ -3289,7 +3220,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
|
3289
3220
|
try {
|
|
3290
3221
|
for await (const doc of cursor) {
|
|
3291
3222
|
const updated = doc.dateTime.map(
|
|
3292
|
-
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3223
|
+
(slot) => (0, import_cluemart_shared26.updateSingleDateTimeStatus)(slot, now)
|
|
3293
3224
|
);
|
|
3294
3225
|
const { archive, discard } = splitEventDatesForArchive(updated);
|
|
3295
3226
|
if (archive.length === 0 && discard.length === 0) {
|
|
@@ -3347,7 +3278,7 @@ async function cleanEventInfoDates(now) {
|
|
|
3347
3278
|
try {
|
|
3348
3279
|
for await (const doc of cursor) {
|
|
3349
3280
|
const updated = doc.dateTime.map(
|
|
3350
|
-
(slot) => updateSingleDateTimeStatus(slot, now)
|
|
3281
|
+
(slot) => (0, import_cluemart_shared26.updateSingleDateTimeStatus)(slot, now)
|
|
3351
3282
|
);
|
|
3352
3283
|
const kept = (0, import_cluemart_shared26.filterDatesByFutureStatus)(updated);
|
|
3353
3284
|
if (kept.length === updated.length) {
|
|
@@ -3394,6 +3325,9 @@ async function updateAllEventDateTimeStatuses() {
|
|
|
3394
3325
|
}
|
|
3395
3326
|
}
|
|
3396
3327
|
|
|
3328
|
+
// src/service/index.ts
|
|
3329
|
+
var import_cluemart_shared34 = require("@timardex/cluemart-shared");
|
|
3330
|
+
|
|
3397
3331
|
// src/service/event/findEventOrImportedMarketById.ts
|
|
3398
3332
|
async function findEventOrImportedMarketById(resourceId) {
|
|
3399
3333
|
if (!resourceId) {
|