@timardex/cluemart-server-shared 3.0.2 → 4.0.1

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.
@@ -290,12 +290,13 @@ type EventOrMarket = (Pick<EventListItemType, "_id" | "name" | "dateTime"> & {
290
290
  owner?: SchemaOwnerType;
291
291
  }) | null;
292
292
  /**
293
- * This function attempts to find an Event or a Google Imported Market by the given resource ID.
294
- * It first normalizes the resource ID to a string format, then performs parallel queries to both collections.
295
- * If an Event is found, it returns that; otherwise, it checks for a Google Imported Market and returns it if found.
296
- * If neither is found, it returns null.
293
+ * This function attempts to find an Event, Google Imported Market, or AI
294
+ * Imported Market by the given resource ID.
295
+ * It first normalizes the resource ID to a string format, then performs parallel queries to all three collections.
296
+ * If an Event is found, it returns that; otherwise it checks the imported-market collections and returns the first match.
297
+ * If none is found, it returns null.
297
298
  * @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.
298
- * @returns A promise that resolves to either an Event or a Google Imported Market object containing _id, name, dateTime, and owner (events only), or null if not found.
299
+ * @returns A promise that resolves to either an Event or an Imported Market object containing _id, name, dateTime, and owner (events only), or null if not found.
299
300
  */
300
301
  declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
301
302
 
@@ -290,12 +290,13 @@ type EventOrMarket = (Pick<EventListItemType, "_id" | "name" | "dateTime"> & {
290
290
  owner?: SchemaOwnerType;
291
291
  }) | null;
292
292
  /**
293
- * This function attempts to find an Event or a Google Imported Market by the given resource ID.
294
- * It first normalizes the resource ID to a string format, then performs parallel queries to both collections.
295
- * If an Event is found, it returns that; otherwise, it checks for a Google Imported Market and returns it if found.
296
- * If neither is found, it returns null.
293
+ * This function attempts to find an Event, Google Imported Market, or AI
294
+ * Imported Market by the given resource ID.
295
+ * It first normalizes the resource ID to a string format, then performs parallel queries to all three collections.
296
+ * If an Event is found, it returns that; otherwise it checks the imported-market collections and returns the first match.
297
+ * If none is found, it returns null.
297
298
  * @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.
298
- * @returns A promise that resolves to either an Event or a Google Imported Market object containing _id, name, dateTime, and owner (events only), or null if not found.
299
+ * @returns A promise that resolves to either an Event or an Imported Market object containing _id, name, dateTime, and owner (events only), or null if not found.
299
300
  */
300
301
  declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
301
302
 
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  AdModel,
3
3
  AffiliateModel,
4
+ AiImportedMarketModel,
4
5
  EventDateArchiveModel,
5
6
  EventInfoModel,
6
7
  EventModel,
@@ -10,7 +11,7 @@ import {
10
11
  PushTokenModel,
11
12
  UserModel,
12
13
  VendorModel
13
- } from "../chunk-7JWQ7WKJ.mjs";
14
+ } from "../chunk-J7ZINA3I.mjs";
14
15
  import "../chunk-F54NB7VH.mjs";
15
16
 
16
17
  // src/service/promoCode/constants.ts
@@ -1033,15 +1034,19 @@ async function cleanEventInfoDates(now) {
1033
1034
  }
1034
1035
  async function updateAllEventDateTimeStatuses() {
1035
1036
  const now = dayjs4();
1036
- const [eventCount, marketCount] = await Promise.all([
1037
+ const [eventCount, marketCount, aiMarketCount] = await Promise.all([
1037
1038
  updateModelDateTimeStatuses(EventModel, now),
1038
1039
  updateModelDateTimeStatuses(
1039
1040
  GoogleImportedMarketModel,
1040
1041
  now
1042
+ ),
1043
+ updateModelDateTimeStatuses(
1044
+ AiImportedMarketModel,
1045
+ now
1041
1046
  )
1042
1047
  ]);
1043
1048
  console.log(
1044
- `\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed`
1049
+ `\u2705 Event dateTime statuses updated: events=${eventCount} changed, google imported markets=${marketCount} changed, ai imported markets=${aiMarketCount} changed`
1045
1050
  );
1046
1051
  const archivedCount = await archiveEndedAndDiscardInvalidEventDates(now);
1047
1052
  if (archivedCount > 0) {
@@ -1064,11 +1069,12 @@ async function findEventOrImportedMarketById(resourceId) {
1064
1069
  return null;
1065
1070
  }
1066
1071
  const normalizedId = convertObjectIdsToStrings(resourceId);
1067
- const [eventDoc, googleImportedDoc] = await Promise.all([
1072
+ const [eventDoc, googleImportedDoc, aiImportedDoc] = await Promise.all([
1068
1073
  EventModel.findById(normalizedId).select("_id name dateTime owner").lean().exec(),
1069
- GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
1074
+ GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec(),
1075
+ AiImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
1070
1076
  ]);
1071
- return eventDoc ?? googleImportedDoc;
1077
+ return eventDoc ?? googleImportedDoc ?? aiImportedDoc;
1072
1078
  }
1073
1079
 
1074
1080
  // src/service/relations.ts