@timardex/cluemart-server-shared 4.2.0 → 5.0.0

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.
@@ -1,8 +1,8 @@
1
1
  import * as mongoose from 'mongoose';
2
2
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
3
- import { PromoCodeType, EnumAffiliateRewardType, EnumResourceType, EnumUserRole, EnumPointType, UserOverallPointsEntry, DateTimeType, EventListItemType, DateTimeWithPriceType, EnumUserLicence as EnumUserLicence$1, UserLicenceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
3
+ import { PromoCodeType, EnumAffiliateRewardType, EnumResourceType, EnumUserRole, EnumPointType, UserOverallPointsEntry, DateTimeType, DateTimeWithPriceType, EnumUserLicence as EnumUserLicence$1, UserLicenceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
4
4
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
5
- import { f as SchemaAffiliateResourceType, a as SchemaOwnerType, S as SchemaAssociateType, i as SchemaRelationType, m as SchemaUserType } from '../Affiliate-Bilg9mgw.mjs';
5
+ import { g as SchemaAffiliateResourceType, a as SchemaOwnerType, S as SchemaAssociateType, k as SchemaGoogleImportedMarket, i as SchemaAiImportedMarket, j as SchemaEventType, m as SchemaRelationType, q as SchemaUserType } from '../Affiliate-DfBYlDtn.mjs';
6
6
  import { O as ObjectId, G as GraphQLContext, e as SchemaCreateBulkNotificationInput } from '../index-BptxBl9x.mjs';
7
7
  import { DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
8
8
  import { EnumUserLicence } from '@timardex/cluemart-shared/enums';
@@ -464,20 +464,109 @@ declare function dedupeArchivedSlotsByStartDateTime(slots: DateTimeType[]): Date
464
464
  */
465
465
  declare function persistArchivedEventDates(eventId: ObjectId | string, slots: DateTimeType[]): Promise<void>;
466
466
 
467
- type EventOrMarket = (Pick<EventListItemType, "_id" | "name" | "dateTime"> & {
468
- /** Present on owned EventModel docs; absent on Google-imported markets. */
467
+ /** Which collection an `EVENT`-typed id resolved to, together with its document. */
468
+ type EventOrImportedMarketMatch = {
469
+ doc: SchemaAiImportedMarket;
470
+ kind: "ai";
471
+ } | {
472
+ doc: SchemaEventType;
473
+ kind: "event";
474
+ } | {
475
+ doc: SchemaGoogleImportedMarket;
476
+ kind: "google";
477
+ };
478
+ /**
479
+ * What an ordinary caller reads off an Event: its identity, the visibility
480
+ * flags, the name a notification needs, the owner the "no activity on your own
481
+ * resource" guard needs, and the slots a check-in is validated against.
482
+ */
483
+ type EventReference = Pick<SchemaEventType, "_id" | "active" | "dateTime" | "deletedAt" | "name"> & {
469
484
  owner?: SchemaOwnerType;
470
- }) | null;
485
+ };
486
+ /** The same subset for an imported market, which has no owner. */
487
+ type ImportedMarketReference = Pick<SchemaGoogleImportedMarket, "_id" | "active" | "dateTime" | "deletedAt" | "name">;
488
+ type AiImportedMarketReference = ImportedMarketReference & {
489
+ reviewStatus: SchemaAiImportedMarket["reviewStatus"];
490
+ };
491
+ /** Which collection an `EVENT`-typed id resolved to, with the fields an ordinary caller reads. */
492
+ type EventOrImportedMarketReferenceMatch = {
493
+ doc: AiImportedMarketReference;
494
+ kind: "ai";
495
+ } | {
496
+ doc: EventReference;
497
+ kind: "event";
498
+ } | {
499
+ doc: ImportedMarketReference;
500
+ kind: "google";
501
+ };
502
+ type EventOrImportedMarketLookupOptions = {
503
+ /**
504
+ * Also return markets the public can no longer reach: inactive and/or
505
+ * soft-deleted ones.
506
+ *
507
+ * Reserved for the admin flows that have to see them, because every admin
508
+ * action starts from a market in one of those states: the detail screen
509
+ * renders activation for an inactive market, the soft delete is only offered
510
+ * once a market is inactive, and the hard delete only runs on a soft-deleted
511
+ * one. Every ordinary lookup (check-ins, favourites, interest/going, activity)
512
+ * must keep the default, otherwise a user could act on a market that has been
513
+ * taken down or switched off.
514
+ */
515
+ includeDeleted?: boolean;
516
+ };
471
517
  /**
472
- * This function attempts to find an Event, Google Imported Market, or AI
473
- * Imported Market by the given resource ID.
474
- * It first normalizes the resource ID to a string format, then performs parallel queries to all three collections.
475
- * If an Event is found, it returns that; otherwise it checks the imported-market collections and returns the first match.
476
- * If none is found, it returns null.
477
- * @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.
478
- * @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.
518
+ * Resolves an `EVENT`-typed id for the frequent ordinary flows: check-ins,
519
+ * favourites, interest/going, resource activity and the cron notifications.
520
+ *
521
+ * This is the single definition of that lookup **and** of its visibility rule:
522
+ * by default it only returns live rows (active and not soft-deleted, the same
523
+ * pair the public lists and the activity feeds filter on), and the admin flows
524
+ * that must see an inactive or retired market pass `includeDeleted`.
525
+ *
526
+ * It returns only the `EventReference` fields. These run on every user action, so
527
+ * hydrating descriptions, images, locations or association metadata would
528
+ * transfer and retain whole documents just to read an id and a date list. The
529
+ * screens and admin flows that render a market use
530
+ * `findEventOrImportedMarketDetailsById`.
531
+ *
532
+ * @param resourceId - The id to resolve: ObjectId, string, or nothing.
533
+ * @param options - `includeDeleted` for the admin hard-delete/detail flows.
534
+ * @returns The matched collection plus the fields an ordinary caller reads, or null.
535
+ */
536
+ declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined, options?: EventOrImportedMarketLookupOptions): Promise<EventOrImportedMarketReferenceMatch | null>;
537
+ /**
538
+ * Resolves an `EVENT`-typed id to the whole document, for the flows that render
539
+ * it: the market detail screen (which returns it to the client) and the admin
540
+ * mutations (activation, soft delete, hard delete with its asset folder).
541
+ *
542
+ * Same collections and same visibility rule as
543
+ * `findEventOrImportedMarketById`; only the projection differs, so anything that
544
+ * resolves there resolves here too. The caller still decides what its own
545
+ * audience may see (e.g. `getEvent` runs `canUserViewResourceById`).
546
+ */
547
+ declare function findEventOrImportedMarketDetailsById(resourceId: ObjectId | string | null | undefined, options?: EventOrImportedMarketLookupOptions): Promise<EventOrImportedMarketMatch | null>;
548
+
549
+ /**
550
+ * What "the public may still see this resource" means, as a Mongo filter.
551
+ *
552
+ * Events, Google imports and AI imports all carry the same `active` +
553
+ * `deletedAt` pair, so the public lists, the user activity feeds and the
554
+ * by-id lookup all reuse this one definition instead of restating the pair.
555
+ */
556
+ declare const LIVE_RESOURCE_FILTER: {
557
+ readonly active: true;
558
+ readonly deletedAt: null;
559
+ };
560
+ /**
561
+ * The JavaScript form of `LIVE_RESOURCE_FILTER`, for rows already loaded.
562
+ *
563
+ * A missing `active` counts as inactive: the Mongo filter does not match absent
564
+ * fields either, so the two forms agree.
479
565
  */
480
- declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
566
+ declare function isLiveResource(resource: {
567
+ active?: boolean | null;
568
+ deletedAt?: Date | null;
569
+ }): boolean;
481
570
 
482
571
  type EventDateSlot = Pick<DateTimeType$1, "startDate" | "startTime">;
483
572
  type StartedDateSlot = Pick<DateTimeType$1, "dateStatus" | "startDate" | "startTime">;
@@ -831,4 +920,4 @@ declare function hasActiveProLicenceForResource({ includeStripeProtected, userId
831
920
  resourceType: EnumResourceType;
832
921
  }): Promise<boolean>;
833
922
 
834
- export { ACTIVE_NOT_DELETED_FILTER, type ActiveLicenceOptions, type AssociableResourceType, type AwardAffiliateVendorSubscriptionRewardsResult, type DetachedAssociateGrants, type IndexBuildFailure, type IndexableModel, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, SUBSCRIPTION_REWARD_TIMEZONE, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getActiveLicenceForResource, getAssociateAccessMeta, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
923
+ export { ACTIVE_NOT_DELETED_FILTER, type ActiveLicenceOptions, type AiImportedMarketReference, type AssociableResourceType, type AwardAffiliateVendorSubscriptionRewardsResult, type DetachedAssociateGrants, type EventOrImportedMarketLookupOptions, type EventOrImportedMarketMatch, type EventOrImportedMarketReferenceMatch, type EventReference, type ImportedMarketReference, type IndexBuildFailure, type IndexableModel, LIVE_RESOURCE_FILTER, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, SUBSCRIPTION_REWARD_TIMEZONE, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, findEventOrImportedMarketDetailsById, getActiveLicenceForResource, getAssociateAccessMeta, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isLiveResource, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
@@ -1,8 +1,8 @@
1
1
  import * as mongoose from 'mongoose';
2
2
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
3
- import { PromoCodeType, EnumAffiliateRewardType, EnumResourceType, EnumUserRole, EnumPointType, UserOverallPointsEntry, DateTimeType, EventListItemType, DateTimeWithPriceType, EnumUserLicence as EnumUserLicence$1, UserLicenceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
3
+ import { PromoCodeType, EnumAffiliateRewardType, EnumResourceType, EnumUserRole, EnumPointType, UserOverallPointsEntry, DateTimeType, DateTimeWithPriceType, EnumUserLicence as EnumUserLicence$1, UserLicenceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
4
4
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
5
- import { f as SchemaAffiliateResourceType, a as SchemaOwnerType, S as SchemaAssociateType, i as SchemaRelationType, m as SchemaUserType } from '../Affiliate-CfG8ctIo.js';
5
+ import { g as SchemaAffiliateResourceType, a as SchemaOwnerType, S as SchemaAssociateType, k as SchemaGoogleImportedMarket, i as SchemaAiImportedMarket, j as SchemaEventType, m as SchemaRelationType, q as SchemaUserType } from '../Affiliate-CisCDggv.js';
6
6
  import { O as ObjectId, G as GraphQLContext, e as SchemaCreateBulkNotificationInput } from '../index-BptxBl9x.js';
7
7
  import { DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
8
8
  import { EnumUserLicence } from '@timardex/cluemart-shared/enums';
@@ -464,20 +464,109 @@ declare function dedupeArchivedSlotsByStartDateTime(slots: DateTimeType[]): Date
464
464
  */
465
465
  declare function persistArchivedEventDates(eventId: ObjectId | string, slots: DateTimeType[]): Promise<void>;
466
466
 
467
- type EventOrMarket = (Pick<EventListItemType, "_id" | "name" | "dateTime"> & {
468
- /** Present on owned EventModel docs; absent on Google-imported markets. */
467
+ /** Which collection an `EVENT`-typed id resolved to, together with its document. */
468
+ type EventOrImportedMarketMatch = {
469
+ doc: SchemaAiImportedMarket;
470
+ kind: "ai";
471
+ } | {
472
+ doc: SchemaEventType;
473
+ kind: "event";
474
+ } | {
475
+ doc: SchemaGoogleImportedMarket;
476
+ kind: "google";
477
+ };
478
+ /**
479
+ * What an ordinary caller reads off an Event: its identity, the visibility
480
+ * flags, the name a notification needs, the owner the "no activity on your own
481
+ * resource" guard needs, and the slots a check-in is validated against.
482
+ */
483
+ type EventReference = Pick<SchemaEventType, "_id" | "active" | "dateTime" | "deletedAt" | "name"> & {
469
484
  owner?: SchemaOwnerType;
470
- }) | null;
485
+ };
486
+ /** The same subset for an imported market, which has no owner. */
487
+ type ImportedMarketReference = Pick<SchemaGoogleImportedMarket, "_id" | "active" | "dateTime" | "deletedAt" | "name">;
488
+ type AiImportedMarketReference = ImportedMarketReference & {
489
+ reviewStatus: SchemaAiImportedMarket["reviewStatus"];
490
+ };
491
+ /** Which collection an `EVENT`-typed id resolved to, with the fields an ordinary caller reads. */
492
+ type EventOrImportedMarketReferenceMatch = {
493
+ doc: AiImportedMarketReference;
494
+ kind: "ai";
495
+ } | {
496
+ doc: EventReference;
497
+ kind: "event";
498
+ } | {
499
+ doc: ImportedMarketReference;
500
+ kind: "google";
501
+ };
502
+ type EventOrImportedMarketLookupOptions = {
503
+ /**
504
+ * Also return markets the public can no longer reach: inactive and/or
505
+ * soft-deleted ones.
506
+ *
507
+ * Reserved for the admin flows that have to see them, because every admin
508
+ * action starts from a market in one of those states: the detail screen
509
+ * renders activation for an inactive market, the soft delete is only offered
510
+ * once a market is inactive, and the hard delete only runs on a soft-deleted
511
+ * one. Every ordinary lookup (check-ins, favourites, interest/going, activity)
512
+ * must keep the default, otherwise a user could act on a market that has been
513
+ * taken down or switched off.
514
+ */
515
+ includeDeleted?: boolean;
516
+ };
471
517
  /**
472
- * This function attempts to find an Event, Google Imported Market, or AI
473
- * Imported Market by the given resource ID.
474
- * It first normalizes the resource ID to a string format, then performs parallel queries to all three collections.
475
- * If an Event is found, it returns that; otherwise it checks the imported-market collections and returns the first match.
476
- * If none is found, it returns null.
477
- * @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.
478
- * @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.
518
+ * Resolves an `EVENT`-typed id for the frequent ordinary flows: check-ins,
519
+ * favourites, interest/going, resource activity and the cron notifications.
520
+ *
521
+ * This is the single definition of that lookup **and** of its visibility rule:
522
+ * by default it only returns live rows (active and not soft-deleted, the same
523
+ * pair the public lists and the activity feeds filter on), and the admin flows
524
+ * that must see an inactive or retired market pass `includeDeleted`.
525
+ *
526
+ * It returns only the `EventReference` fields. These run on every user action, so
527
+ * hydrating descriptions, images, locations or association metadata would
528
+ * transfer and retain whole documents just to read an id and a date list. The
529
+ * screens and admin flows that render a market use
530
+ * `findEventOrImportedMarketDetailsById`.
531
+ *
532
+ * @param resourceId - The id to resolve: ObjectId, string, or nothing.
533
+ * @param options - `includeDeleted` for the admin hard-delete/detail flows.
534
+ * @returns The matched collection plus the fields an ordinary caller reads, or null.
535
+ */
536
+ declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined, options?: EventOrImportedMarketLookupOptions): Promise<EventOrImportedMarketReferenceMatch | null>;
537
+ /**
538
+ * Resolves an `EVENT`-typed id to the whole document, for the flows that render
539
+ * it: the market detail screen (which returns it to the client) and the admin
540
+ * mutations (activation, soft delete, hard delete with its asset folder).
541
+ *
542
+ * Same collections and same visibility rule as
543
+ * `findEventOrImportedMarketById`; only the projection differs, so anything that
544
+ * resolves there resolves here too. The caller still decides what its own
545
+ * audience may see (e.g. `getEvent` runs `canUserViewResourceById`).
546
+ */
547
+ declare function findEventOrImportedMarketDetailsById(resourceId: ObjectId | string | null | undefined, options?: EventOrImportedMarketLookupOptions): Promise<EventOrImportedMarketMatch | null>;
548
+
549
+ /**
550
+ * What "the public may still see this resource" means, as a Mongo filter.
551
+ *
552
+ * Events, Google imports and AI imports all carry the same `active` +
553
+ * `deletedAt` pair, so the public lists, the user activity feeds and the
554
+ * by-id lookup all reuse this one definition instead of restating the pair.
555
+ */
556
+ declare const LIVE_RESOURCE_FILTER: {
557
+ readonly active: true;
558
+ readonly deletedAt: null;
559
+ };
560
+ /**
561
+ * The JavaScript form of `LIVE_RESOURCE_FILTER`, for rows already loaded.
562
+ *
563
+ * A missing `active` counts as inactive: the Mongo filter does not match absent
564
+ * fields either, so the two forms agree.
479
565
  */
480
- declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
566
+ declare function isLiveResource(resource: {
567
+ active?: boolean | null;
568
+ deletedAt?: Date | null;
569
+ }): boolean;
481
570
 
482
571
  type EventDateSlot = Pick<DateTimeType$1, "startDate" | "startTime">;
483
572
  type StartedDateSlot = Pick<DateTimeType$1, "dateStatus" | "startDate" | "startTime">;
@@ -831,4 +920,4 @@ declare function hasActiveProLicenceForResource({ includeStripeProtected, userId
831
920
  resourceType: EnumResourceType;
832
921
  }): Promise<boolean>;
833
922
 
834
- export { ACTIVE_NOT_DELETED_FILTER, type ActiveLicenceOptions, type AssociableResourceType, type AwardAffiliateVendorSubscriptionRewardsResult, type DetachedAssociateGrants, type IndexBuildFailure, type IndexableModel, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, SUBSCRIPTION_REWARD_TIMEZONE, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getActiveLicenceForResource, getAssociateAccessMeta, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
923
+ export { ACTIVE_NOT_DELETED_FILTER, type ActiveLicenceOptions, type AiImportedMarketReference, type AssociableResourceType, type AwardAffiliateVendorSubscriptionRewardsResult, type DetachedAssociateGrants, type EventOrImportedMarketLookupOptions, type EventOrImportedMarketMatch, type EventOrImportedMarketReferenceMatch, type EventReference, type ImportedMarketReference, type IndexBuildFailure, type IndexableModel, LIVE_RESOURCE_FILTER, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, SUBSCRIPTION_REWARD_TIMEZONE, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, findEventOrImportedMarketDetailsById, getActiveLicenceForResource, getAssociateAccessMeta, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isLiveResource, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
@@ -11,7 +11,7 @@ import {
11
11
  PushTokenModel,
12
12
  UserModel,
13
13
  VendorModel
14
- } from "../chunk-ABW2L2HY.mjs";
14
+ } from "../chunk-VM4B5D2I.mjs";
15
15
  import "../chunk-F54NB7VH.mjs";
16
16
 
17
17
  // src/service/promoCode/constants.ts
@@ -1402,17 +1402,76 @@ async function updateAllEventDateTimeStatuses() {
1402
1402
  import { updateSingleDateTimeStatus as updateSingleDateTimeStatus2 } from "@timardex/cluemart-shared";
1403
1403
 
1404
1404
  // src/service/event/findEventOrImportedMarketById.ts
1405
- async function findEventOrImportedMarketById(resourceId) {
1406
- if (!resourceId) {
1407
- return null;
1405
+ import { EnumImportedMarketReviewStatus } from "@timardex/cluemart-shared";
1406
+
1407
+ // src/service/event/resourceVisibility.ts
1408
+ var LIVE_RESOURCE_FILTER = { active: true, deletedAt: null };
1409
+ function isLiveResource(resource) {
1410
+ return resource.active === true && resource.deletedAt == null;
1411
+ }
1412
+
1413
+ // src/service/event/findEventOrImportedMarketById.ts
1414
+ var EVENT_REFERENCE_FIELDS = "_id active dateTime deletedAt name owner";
1415
+ var IMPORTED_MARKET_REFERENCE_FIELDS = "_id active dateTime deletedAt name";
1416
+ var AI_IMPORTED_MARKET_REFERENCE_FIELDS = `${IMPORTED_MARKET_REFERENCE_FIELDS} reviewStatus`;
1417
+ function isAddressableAiImport(market, includeDeleted) {
1418
+ const isApproved = market.reviewStatus === EnumImportedMarketReviewStatus.APPROVED;
1419
+ return includeDeleted ? isApproved || market.deletedAt != null : isApproved && isLiveResource(market);
1420
+ }
1421
+ function pickMatch(eventDoc, googleImportedDoc, aiImportedDoc, includeDeleted) {
1422
+ if (eventDoc && (includeDeleted || isLiveResource(eventDoc))) {
1423
+ return { doc: eventDoc, kind: "event" };
1408
1424
  }
1409
- const normalizedId = convertObjectIdsToStrings(resourceId);
1410
- const [eventDoc, googleImportedDoc, aiImportedDoc] = await Promise.all([
1411
- EventModel.findById(normalizedId).select("_id name dateTime owner").lean().exec(),
1412
- GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec(),
1413
- AiImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
1425
+ if (googleImportedDoc && (includeDeleted || isLiveResource(googleImportedDoc))) {
1426
+ return { doc: googleImportedDoc, kind: "google" };
1427
+ }
1428
+ if (aiImportedDoc && isAddressableAiImport(aiImportedDoc, includeDeleted)) {
1429
+ return { doc: aiImportedDoc, kind: "ai" };
1430
+ }
1431
+ return null;
1432
+ }
1433
+ function normalizeLookupId(resourceId) {
1434
+ return resourceId ? convertObjectIdsToStrings(resourceId) : null;
1435
+ }
1436
+ async function findReferenceRows(normalizedId) {
1437
+ return Promise.all([
1438
+ EventModel.findById(normalizedId).select(EVENT_REFERENCE_FIELDS).lean().exec(),
1439
+ GoogleImportedMarketModel.findById(normalizedId).select(IMPORTED_MARKET_REFERENCE_FIELDS).lean().exec(),
1440
+ AiImportedMarketModel.findById(normalizedId).select(AI_IMPORTED_MARKET_REFERENCE_FIELDS).lean().exec()
1414
1441
  ]);
1415
- return eventDoc ?? googleImportedDoc ?? aiImportedDoc;
1442
+ }
1443
+ async function findDetailRows(normalizedId) {
1444
+ return Promise.all([
1445
+ EventModel.findById(normalizedId).lean().exec(),
1446
+ GoogleImportedMarketModel.findById(normalizedId).lean().exec(),
1447
+ AiImportedMarketModel.findById(normalizedId).lean().exec()
1448
+ ]);
1449
+ }
1450
+ async function findEventOrImportedMarketById(resourceId, options = {}) {
1451
+ const normalizedId = normalizeLookupId(resourceId);
1452
+ if (!normalizedId) {
1453
+ return null;
1454
+ }
1455
+ const [eventDoc, googleImportedDoc, aiImportedDoc] = await findReferenceRows(normalizedId);
1456
+ return pickMatch(
1457
+ eventDoc,
1458
+ googleImportedDoc,
1459
+ aiImportedDoc,
1460
+ options.includeDeleted ?? false
1461
+ );
1462
+ }
1463
+ async function findEventOrImportedMarketDetailsById(resourceId, options = {}) {
1464
+ const normalizedId = normalizeLookupId(resourceId);
1465
+ if (!normalizedId) {
1466
+ return null;
1467
+ }
1468
+ const [eventDoc, googleImportedDoc, aiImportedDoc] = await findDetailRows(normalizedId);
1469
+ return pickMatch(
1470
+ eventDoc,
1471
+ googleImportedDoc,
1472
+ aiImportedDoc,
1473
+ options.includeDeleted ?? false
1474
+ );
1416
1475
  }
1417
1476
 
1418
1477
  // src/service/relations.ts
@@ -2670,6 +2729,7 @@ async function remindUsersAboutLicenseExpiration() {
2670
2729
  }
2671
2730
  export {
2672
2731
  ACTIVE_NOT_DELETED_FILTER,
2732
+ LIVE_RESOURCE_FILTER,
2673
2733
  LicenceCategory,
2674
2734
  REMINDER_WINDOW_MAX_HOURS,
2675
2735
  REMINDER_WINDOW_MIN_HOURS,
@@ -2700,6 +2760,7 @@ export {
2700
2760
  eventLicences,
2701
2761
  findAffiliateByPromoCode,
2702
2762
  findEventOrImportedMarketById,
2763
+ findEventOrImportedMarketDetailsById,
2703
2764
  getActiveLicenceForResource,
2704
2765
  getAssociateAccessMeta,
2705
2766
  getEventResourceInfo,
@@ -2720,6 +2781,7 @@ export {
2720
2781
  hasActiveProLicenceForResource,
2721
2782
  hasValidLicence,
2722
2783
  isAssociableResourceType,
2784
+ isLiveResource,
2723
2785
  isProLicence,
2724
2786
  isProtectedByCurrentStripeSubscription,
2725
2787
  isStandardLicence,