@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.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, AdDailyPriceType, AdBookingType, AdMetricsType, ChatType, ParticipantType, ChatMessageType, NotificationType, CreateBulkNotificationInput, EnumUserRole, BillingCatalogEntryType, BillingCatalogPriceHistoryEntry, EnumBillingPeriod, EnumUserLicence, BILLING_CATALOG_KEYS, ReportChatUser, OwnerType, AssociateType, EnumAssociateStatus, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, AiImportedMarket, EnumImportedMarketDeactivationReason, EnumAiImportRunStatus, AiImportUsage, ScrapeSite, PushTokenType, RelationType, RelationDate, ResourceActivityType, StripeSubscription, UserActivityEvent, UserType, VendorType, VendorProductList, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, EventInfoType, StallType, RefundPolicy, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameDocType, GameType, SchoolType, AffiliateType, AffiliateResourceType, AffiliateRewardType, CouponType, CouponDataType, CouponParticipantUserType, EnumResourceType, PromoCodeType, EnumAffiliateRewardType, EnumPointType, UserOverallPointsEntry, EventListItemType, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
2
+ import { AdType, AdDailyPriceType, AdBookingType, AdMetricsType, ChatType, ParticipantType, ChatMessageType, NotificationType, CreateBulkNotificationInput, EnumUserRole, BillingCatalogEntryType, BillingCatalogPriceHistoryEntry, EnumBillingPeriod, EnumUserLicence, BILLING_CATALOG_KEYS, ReportChatUser, OwnerType, AssociateType, EnumAssociateStatus, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, AiImportedMarket, EnumImportedMarketDeactivationReason, EnumAiImportRunStatus, AiImportUsage, ScrapeSite, PushTokenType, RelationType, RelationDate, ResourceActivityType, StripeSubscription, UserActivityEvent, UserType, VendorType, VendorProductList, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, EventInfoType, StallType, RefundPolicy, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameDocType, GameType, SchoolType, AffiliateType, AffiliateResourceType, AffiliateRewardType, CouponType, CouponDataType, CouponParticipantUserType, EnumResourceType, PromoCodeType, EnumAffiliateRewardType, EnumPointType, UserOverallPointsEntry, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
3
3
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
4
4
  import * as mongoose from 'mongoose';
5
5
  import mongoose__default from 'mongoose';
@@ -1637,20 +1637,109 @@ declare function dedupeArchivedSlotsByStartDateTime(slots: DateTimeType[]): Date
1637
1637
  */
1638
1638
  declare function persistArchivedEventDates(eventId: ObjectId | string, slots: DateTimeType[]): Promise<void>;
1639
1639
 
1640
- type EventOrMarket = (Pick<EventListItemType, "_id" | "name" | "dateTime"> & {
1641
- /** Present on owned EventModel docs; absent on Google-imported markets. */
1640
+ /** Which collection an `EVENT`-typed id resolved to, together with its document. */
1641
+ type EventOrImportedMarketMatch = {
1642
+ doc: SchemaAiImportedMarket;
1643
+ kind: "ai";
1644
+ } | {
1645
+ doc: SchemaEventType;
1646
+ kind: "event";
1647
+ } | {
1648
+ doc: SchemaGoogleImportedMarket;
1649
+ kind: "google";
1650
+ };
1651
+ /**
1652
+ * What an ordinary caller reads off an Event: its identity, the visibility
1653
+ * flags, the name a notification needs, the owner the "no activity on your own
1654
+ * resource" guard needs, and the slots a check-in is validated against.
1655
+ */
1656
+ type EventReference = Pick<SchemaEventType, "_id" | "active" | "dateTime" | "deletedAt" | "name"> & {
1642
1657
  owner?: SchemaOwnerType;
1643
- }) | null;
1658
+ };
1659
+ /** The same subset for an imported market, which has no owner. */
1660
+ type ImportedMarketReference = Pick<SchemaGoogleImportedMarket, "_id" | "active" | "dateTime" | "deletedAt" | "name">;
1661
+ type AiImportedMarketReference = ImportedMarketReference & {
1662
+ reviewStatus: SchemaAiImportedMarket["reviewStatus"];
1663
+ };
1664
+ /** Which collection an `EVENT`-typed id resolved to, with the fields an ordinary caller reads. */
1665
+ type EventOrImportedMarketReferenceMatch = {
1666
+ doc: AiImportedMarketReference;
1667
+ kind: "ai";
1668
+ } | {
1669
+ doc: EventReference;
1670
+ kind: "event";
1671
+ } | {
1672
+ doc: ImportedMarketReference;
1673
+ kind: "google";
1674
+ };
1675
+ type EventOrImportedMarketLookupOptions = {
1676
+ /**
1677
+ * Also return markets the public can no longer reach: inactive and/or
1678
+ * soft-deleted ones.
1679
+ *
1680
+ * Reserved for the admin flows that have to see them, because every admin
1681
+ * action starts from a market in one of those states: the detail screen
1682
+ * renders activation for an inactive market, the soft delete is only offered
1683
+ * once a market is inactive, and the hard delete only runs on a soft-deleted
1684
+ * one. Every ordinary lookup (check-ins, favourites, interest/going, activity)
1685
+ * must keep the default, otherwise a user could act on a market that has been
1686
+ * taken down or switched off.
1687
+ */
1688
+ includeDeleted?: boolean;
1689
+ };
1644
1690
  /**
1645
- * This function attempts to find an Event, Google Imported Market, or AI
1646
- * Imported Market by the given resource ID.
1647
- * It first normalizes the resource ID to a string format, then performs parallel queries to all three collections.
1648
- * If an Event is found, it returns that; otherwise it checks the imported-market collections and returns the first match.
1649
- * If none is found, it returns null.
1650
- * @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.
1651
- * @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.
1691
+ * Resolves an `EVENT`-typed id for the frequent ordinary flows: check-ins,
1692
+ * favourites, interest/going, resource activity and the cron notifications.
1693
+ *
1694
+ * This is the single definition of that lookup **and** of its visibility rule:
1695
+ * by default it only returns live rows (active and not soft-deleted, the same
1696
+ * pair the public lists and the activity feeds filter on), and the admin flows
1697
+ * that must see an inactive or retired market pass `includeDeleted`.
1698
+ *
1699
+ * It returns only the `EventReference` fields. These run on every user action, so
1700
+ * hydrating descriptions, images, locations or association metadata would
1701
+ * transfer and retain whole documents just to read an id and a date list. The
1702
+ * screens and admin flows that render a market use
1703
+ * `findEventOrImportedMarketDetailsById`.
1704
+ *
1705
+ * @param resourceId - The id to resolve: ObjectId, string, or nothing.
1706
+ * @param options - `includeDeleted` for the admin hard-delete/detail flows.
1707
+ * @returns The matched collection plus the fields an ordinary caller reads, or null.
1708
+ */
1709
+ declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined, options?: EventOrImportedMarketLookupOptions): Promise<EventOrImportedMarketReferenceMatch | null>;
1710
+ /**
1711
+ * Resolves an `EVENT`-typed id to the whole document, for the flows that render
1712
+ * it: the market detail screen (which returns it to the client) and the admin
1713
+ * mutations (activation, soft delete, hard delete with its asset folder).
1714
+ *
1715
+ * Same collections and same visibility rule as
1716
+ * `findEventOrImportedMarketById`; only the projection differs, so anything that
1717
+ * resolves there resolves here too. The caller still decides what its own
1718
+ * audience may see (e.g. `getEvent` runs `canUserViewResourceById`).
1719
+ */
1720
+ declare function findEventOrImportedMarketDetailsById(resourceId: ObjectId | string | null | undefined, options?: EventOrImportedMarketLookupOptions): Promise<EventOrImportedMarketMatch | null>;
1721
+
1722
+ /**
1723
+ * What "the public may still see this resource" means, as a Mongo filter.
1724
+ *
1725
+ * Events, Google imports and AI imports all carry the same `active` +
1726
+ * `deletedAt` pair, so the public lists, the user activity feeds and the
1727
+ * by-id lookup all reuse this one definition instead of restating the pair.
1728
+ */
1729
+ declare const LIVE_RESOURCE_FILTER: {
1730
+ readonly active: true;
1731
+ readonly deletedAt: null;
1732
+ };
1733
+ /**
1734
+ * The JavaScript form of `LIVE_RESOURCE_FILTER`, for rows already loaded.
1735
+ *
1736
+ * A missing `active` counts as inactive: the Mongo filter does not match absent
1737
+ * fields either, so the two forms agree.
1652
1738
  */
1653
- declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
1739
+ declare function isLiveResource(resource: {
1740
+ active?: boolean | null;
1741
+ deletedAt?: Date | null;
1742
+ }): boolean;
1654
1743
 
1655
1744
  type EventDateSlot = Pick<DateTimeType$1, "startDate" | "startTime">;
1656
1745
  type StartedDateSlot = Pick<DateTimeType$1, "dateStatus" | "startDate" | "startTime">;
@@ -2004,4 +2093,4 @@ declare function hasActiveProLicenceForResource({ includeStripeProtected, userId
2004
2093
  resourceType: EnumResourceType;
2005
2094
  }): Promise<boolean>;
2006
2095
 
2007
- export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, AI_IMPORT_RUN_LOCK_KEY, APP_SETTINGS_ID, type ActiveLicenceOptions, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdPurchaseModel, AffiliateModel, AiImportRunLockModel, AiImportRunModel, type AiImportRunStatus, type AiImportSiteResult, AiImportedMarketModel, AppSettingModel, type AssociableResourceType, AssociateTypeSchema, AuthHandoffTokenModel, type AuthHandoffTokenType, type AuthTokenClient, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, type DetachedAssociateGrants, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, type IndexBuildFailure, type IndexableModel, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SCRAPE_SITES_CONFIG_ID, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAiImportRun, type SchemaAiImportedMarket, type SchemaAppSettingsType, type SchemaAssociateType, type SchemaBillingCatalogEntry, type SchemaBillingCatalogPriceHistoryEntry, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventDateArchiveType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaImpersonationAuditType, type SchemaImpersonationSessionType, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserAssociatedResourcesType, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, ScrapeSiteConfigModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getActiveLicenceForResource, getAssociateAccessMeta, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
2096
+ export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, AI_IMPORT_RUN_LOCK_KEY, APP_SETTINGS_ID, type ActiveLicenceOptions, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdPurchaseModel, AffiliateModel, AiImportRunLockModel, AiImportRunModel, type AiImportRunStatus, type AiImportSiteResult, AiImportedMarketModel, type AiImportedMarketReference, AppSettingModel, type AssociableResourceType, AssociateTypeSchema, AuthHandoffTokenModel, type AuthHandoffTokenType, type AuthTokenClient, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, type DetachedAssociateGrants, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, type EventOrImportedMarketLookupOptions, type EventOrImportedMarketMatch, type EventOrImportedMarketReferenceMatch, type EventReference, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, type ImportedMarketReference, type IndexBuildFailure, type IndexableModel, LIVE_RESOURCE_FILTER, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SCRAPE_SITES_CONFIG_ID, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAiImportRun, type SchemaAiImportedMarket, type SchemaAppSettingsType, type SchemaAssociateType, type SchemaBillingCatalogEntry, type SchemaBillingCatalogPriceHistoryEntry, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventDateArchiveType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaImpersonationAuditType, type SchemaImpersonationSessionType, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserAssociatedResourcesType, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, ScrapeSiteConfigModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, findEventOrImportedMarketDetailsById, getActiveLicenceForResource, getAssociateAccessMeta, getBillingCatalogDefinition, 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, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, AdDailyPriceType, AdBookingType, AdMetricsType, ChatType, ParticipantType, ChatMessageType, NotificationType, CreateBulkNotificationInput, EnumUserRole, BillingCatalogEntryType, BillingCatalogPriceHistoryEntry, EnumBillingPeriod, EnumUserLicence, BILLING_CATALOG_KEYS, ReportChatUser, OwnerType, AssociateType, EnumAssociateStatus, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, AiImportedMarket, EnumImportedMarketDeactivationReason, EnumAiImportRunStatus, AiImportUsage, ScrapeSite, PushTokenType, RelationType, RelationDate, ResourceActivityType, StripeSubscription, UserActivityEvent, UserType, VendorType, VendorProductList, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, EventInfoType, StallType, RefundPolicy, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameDocType, GameType, SchoolType, AffiliateType, AffiliateResourceType, AffiliateRewardType, CouponType, CouponDataType, CouponParticipantUserType, EnumResourceType, PromoCodeType, EnumAffiliateRewardType, EnumPointType, UserOverallPointsEntry, EventListItemType, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
2
+ import { AdType, AdDailyPriceType, AdBookingType, AdMetricsType, ChatType, ParticipantType, ChatMessageType, NotificationType, CreateBulkNotificationInput, EnumUserRole, BillingCatalogEntryType, BillingCatalogPriceHistoryEntry, EnumBillingPeriod, EnumUserLicence, BILLING_CATALOG_KEYS, ReportChatUser, OwnerType, AssociateType, EnumAssociateStatus, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, AiImportedMarket, EnumImportedMarketDeactivationReason, EnumAiImportRunStatus, AiImportUsage, ScrapeSite, PushTokenType, RelationType, RelationDate, ResourceActivityType, StripeSubscription, UserActivityEvent, UserType, VendorType, VendorProductList, VendorInfoType, UnregisteredVendorInvitationType, UnregisteredVendorType, EventType, EventInfoType, StallType, RefundPolicy, PartnerType, PostType, PostContentType, PostResource, AppSettingsType, GameDocType, GameType, SchoolType, AffiliateType, AffiliateResourceType, AffiliateRewardType, CouponType, CouponDataType, CouponParticipantUserType, EnumResourceType, PromoCodeType, EnumAffiliateRewardType, EnumPointType, UserOverallPointsEntry, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
3
3
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
4
4
  import * as mongoose from 'mongoose';
5
5
  import mongoose__default from 'mongoose';
@@ -1637,20 +1637,109 @@ declare function dedupeArchivedSlotsByStartDateTime(slots: DateTimeType[]): Date
1637
1637
  */
1638
1638
  declare function persistArchivedEventDates(eventId: ObjectId | string, slots: DateTimeType[]): Promise<void>;
1639
1639
 
1640
- type EventOrMarket = (Pick<EventListItemType, "_id" | "name" | "dateTime"> & {
1641
- /** Present on owned EventModel docs; absent on Google-imported markets. */
1640
+ /** Which collection an `EVENT`-typed id resolved to, together with its document. */
1641
+ type EventOrImportedMarketMatch = {
1642
+ doc: SchemaAiImportedMarket;
1643
+ kind: "ai";
1644
+ } | {
1645
+ doc: SchemaEventType;
1646
+ kind: "event";
1647
+ } | {
1648
+ doc: SchemaGoogleImportedMarket;
1649
+ kind: "google";
1650
+ };
1651
+ /**
1652
+ * What an ordinary caller reads off an Event: its identity, the visibility
1653
+ * flags, the name a notification needs, the owner the "no activity on your own
1654
+ * resource" guard needs, and the slots a check-in is validated against.
1655
+ */
1656
+ type EventReference = Pick<SchemaEventType, "_id" | "active" | "dateTime" | "deletedAt" | "name"> & {
1642
1657
  owner?: SchemaOwnerType;
1643
- }) | null;
1658
+ };
1659
+ /** The same subset for an imported market, which has no owner. */
1660
+ type ImportedMarketReference = Pick<SchemaGoogleImportedMarket, "_id" | "active" | "dateTime" | "deletedAt" | "name">;
1661
+ type AiImportedMarketReference = ImportedMarketReference & {
1662
+ reviewStatus: SchemaAiImportedMarket["reviewStatus"];
1663
+ };
1664
+ /** Which collection an `EVENT`-typed id resolved to, with the fields an ordinary caller reads. */
1665
+ type EventOrImportedMarketReferenceMatch = {
1666
+ doc: AiImportedMarketReference;
1667
+ kind: "ai";
1668
+ } | {
1669
+ doc: EventReference;
1670
+ kind: "event";
1671
+ } | {
1672
+ doc: ImportedMarketReference;
1673
+ kind: "google";
1674
+ };
1675
+ type EventOrImportedMarketLookupOptions = {
1676
+ /**
1677
+ * Also return markets the public can no longer reach: inactive and/or
1678
+ * soft-deleted ones.
1679
+ *
1680
+ * Reserved for the admin flows that have to see them, because every admin
1681
+ * action starts from a market in one of those states: the detail screen
1682
+ * renders activation for an inactive market, the soft delete is only offered
1683
+ * once a market is inactive, and the hard delete only runs on a soft-deleted
1684
+ * one. Every ordinary lookup (check-ins, favourites, interest/going, activity)
1685
+ * must keep the default, otherwise a user could act on a market that has been
1686
+ * taken down or switched off.
1687
+ */
1688
+ includeDeleted?: boolean;
1689
+ };
1644
1690
  /**
1645
- * This function attempts to find an Event, Google Imported Market, or AI
1646
- * Imported Market by the given resource ID.
1647
- * It first normalizes the resource ID to a string format, then performs parallel queries to all three collections.
1648
- * If an Event is found, it returns that; otherwise it checks the imported-market collections and returns the first match.
1649
- * If none is found, it returns null.
1650
- * @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.
1651
- * @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.
1691
+ * Resolves an `EVENT`-typed id for the frequent ordinary flows: check-ins,
1692
+ * favourites, interest/going, resource activity and the cron notifications.
1693
+ *
1694
+ * This is the single definition of that lookup **and** of its visibility rule:
1695
+ * by default it only returns live rows (active and not soft-deleted, the same
1696
+ * pair the public lists and the activity feeds filter on), and the admin flows
1697
+ * that must see an inactive or retired market pass `includeDeleted`.
1698
+ *
1699
+ * It returns only the `EventReference` fields. These run on every user action, so
1700
+ * hydrating descriptions, images, locations or association metadata would
1701
+ * transfer and retain whole documents just to read an id and a date list. The
1702
+ * screens and admin flows that render a market use
1703
+ * `findEventOrImportedMarketDetailsById`.
1704
+ *
1705
+ * @param resourceId - The id to resolve: ObjectId, string, or nothing.
1706
+ * @param options - `includeDeleted` for the admin hard-delete/detail flows.
1707
+ * @returns The matched collection plus the fields an ordinary caller reads, or null.
1708
+ */
1709
+ declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined, options?: EventOrImportedMarketLookupOptions): Promise<EventOrImportedMarketReferenceMatch | null>;
1710
+ /**
1711
+ * Resolves an `EVENT`-typed id to the whole document, for the flows that render
1712
+ * it: the market detail screen (which returns it to the client) and the admin
1713
+ * mutations (activation, soft delete, hard delete with its asset folder).
1714
+ *
1715
+ * Same collections and same visibility rule as
1716
+ * `findEventOrImportedMarketById`; only the projection differs, so anything that
1717
+ * resolves there resolves here too. The caller still decides what its own
1718
+ * audience may see (e.g. `getEvent` runs `canUserViewResourceById`).
1719
+ */
1720
+ declare function findEventOrImportedMarketDetailsById(resourceId: ObjectId | string | null | undefined, options?: EventOrImportedMarketLookupOptions): Promise<EventOrImportedMarketMatch | null>;
1721
+
1722
+ /**
1723
+ * What "the public may still see this resource" means, as a Mongo filter.
1724
+ *
1725
+ * Events, Google imports and AI imports all carry the same `active` +
1726
+ * `deletedAt` pair, so the public lists, the user activity feeds and the
1727
+ * by-id lookup all reuse this one definition instead of restating the pair.
1728
+ */
1729
+ declare const LIVE_RESOURCE_FILTER: {
1730
+ readonly active: true;
1731
+ readonly deletedAt: null;
1732
+ };
1733
+ /**
1734
+ * The JavaScript form of `LIVE_RESOURCE_FILTER`, for rows already loaded.
1735
+ *
1736
+ * A missing `active` counts as inactive: the Mongo filter does not match absent
1737
+ * fields either, so the two forms agree.
1652
1738
  */
1653
- declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
1739
+ declare function isLiveResource(resource: {
1740
+ active?: boolean | null;
1741
+ deletedAt?: Date | null;
1742
+ }): boolean;
1654
1743
 
1655
1744
  type EventDateSlot = Pick<DateTimeType$1, "startDate" | "startTime">;
1656
1745
  type StartedDateSlot = Pick<DateTimeType$1, "dateStatus" | "startDate" | "startTime">;
@@ -2004,4 +2093,4 @@ declare function hasActiveProLicenceForResource({ includeStripeProtected, userId
2004
2093
  resourceType: EnumResourceType;
2005
2094
  }): Promise<boolean>;
2006
2095
 
2007
- export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, AI_IMPORT_RUN_LOCK_KEY, APP_SETTINGS_ID, type ActiveLicenceOptions, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdPurchaseModel, AffiliateModel, AiImportRunLockModel, AiImportRunModel, type AiImportRunStatus, type AiImportSiteResult, AiImportedMarketModel, AppSettingModel, type AssociableResourceType, AssociateTypeSchema, AuthHandoffTokenModel, type AuthHandoffTokenType, type AuthTokenClient, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, type DetachedAssociateGrants, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, type IndexBuildFailure, type IndexableModel, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SCRAPE_SITES_CONFIG_ID, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAiImportRun, type SchemaAiImportedMarket, type SchemaAppSettingsType, type SchemaAssociateType, type SchemaBillingCatalogEntry, type SchemaBillingCatalogPriceHistoryEntry, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventDateArchiveType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaImpersonationAuditType, type SchemaImpersonationSessionType, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserAssociatedResourcesType, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, ScrapeSiteConfigModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getActiveLicenceForResource, getAssociateAccessMeta, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
2096
+ export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, AI_IMPORT_RUN_LOCK_KEY, APP_SETTINGS_ID, type ActiveLicenceOptions, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdPurchaseModel, AffiliateModel, AiImportRunLockModel, AiImportRunModel, type AiImportRunStatus, type AiImportSiteResult, AiImportedMarketModel, type AiImportedMarketReference, AppSettingModel, type AssociableResourceType, AssociateTypeSchema, AuthHandoffTokenModel, type AuthHandoffTokenType, type AuthTokenClient, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, type DetachedAssociateGrants, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, type EventOrImportedMarketLookupOptions, type EventOrImportedMarketMatch, type EventOrImportedMarketReferenceMatch, type EventReference, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, type ImportedMarketReference, type IndexBuildFailure, type IndexableModel, LIVE_RESOURCE_FILTER, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SCRAPE_SITES_CONFIG_ID, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAiImportRun, type SchemaAiImportedMarket, type SchemaAppSettingsType, type SchemaAssociateType, type SchemaBillingCatalogEntry, type SchemaBillingCatalogPriceHistoryEntry, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventDateArchiveType, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaImpersonationAuditType, type SchemaImpersonationSessionType, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserAssociatedResourcesType, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, ScrapeSiteConfigModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, findEventOrImportedMarketDetailsById, getActiveLicenceForResource, getAssociateAccessMeta, getBillingCatalogDefinition, 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, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
package/dist/index.mjs CHANGED
@@ -1981,6 +1981,15 @@ schema15.index({ "licences.expiryDate": 1 });
1981
1981
  schema15.index({ "licences.licenceType": 1 });
1982
1982
  schema15.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1983
1983
  schema15.index({ email: "text", firstName: "text", lastName: "text" });
1984
+ schema15.index({ email: 1 }, { name: "email_unique", unique: true });
1985
+ schema15.index(
1986
+ { email: 1 },
1987
+ {
1988
+ collation: { locale: "en", strength: 2 },
1989
+ name: "email_unique_normalized",
1990
+ unique: true
1991
+ }
1992
+ );
1984
1993
  schema15.index({ "associatedResources.events": 1 });
1985
1994
  schema15.index({ "associatedResources.partners": 1 });
1986
1995
  schema15.index({ "associatedResources.vendors": 1 });
@@ -4373,17 +4382,76 @@ async function updateAllEventDateTimeStatuses() {
4373
4382
  import { updateSingleDateTimeStatus as updateSingleDateTimeStatus2 } from "@timardex/cluemart-shared";
4374
4383
 
4375
4384
  // src/service/event/findEventOrImportedMarketById.ts
4376
- async function findEventOrImportedMarketById(resourceId) {
4377
- if (!resourceId) {
4378
- return null;
4385
+ import { EnumImportedMarketReviewStatus as EnumImportedMarketReviewStatus2 } from "@timardex/cluemart-shared";
4386
+
4387
+ // src/service/event/resourceVisibility.ts
4388
+ var LIVE_RESOURCE_FILTER = { active: true, deletedAt: null };
4389
+ function isLiveResource(resource) {
4390
+ return resource.active === true && resource.deletedAt == null;
4391
+ }
4392
+
4393
+ // src/service/event/findEventOrImportedMarketById.ts
4394
+ var EVENT_REFERENCE_FIELDS = "_id active dateTime deletedAt name owner";
4395
+ var IMPORTED_MARKET_REFERENCE_FIELDS = "_id active dateTime deletedAt name";
4396
+ var AI_IMPORTED_MARKET_REFERENCE_FIELDS = `${IMPORTED_MARKET_REFERENCE_FIELDS} reviewStatus`;
4397
+ function isAddressableAiImport(market, includeDeleted) {
4398
+ const isApproved = market.reviewStatus === EnumImportedMarketReviewStatus2.APPROVED;
4399
+ return includeDeleted ? isApproved || market.deletedAt != null : isApproved && isLiveResource(market);
4400
+ }
4401
+ function pickMatch(eventDoc, googleImportedDoc, aiImportedDoc, includeDeleted) {
4402
+ if (eventDoc && (includeDeleted || isLiveResource(eventDoc))) {
4403
+ return { doc: eventDoc, kind: "event" };
4379
4404
  }
4380
- const normalizedId = convertObjectIdsToStrings(resourceId);
4381
- const [eventDoc, googleImportedDoc, aiImportedDoc] = await Promise.all([
4382
- EventModel.findById(normalizedId).select("_id name dateTime owner").lean().exec(),
4383
- GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec(),
4384
- AiImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
4405
+ if (googleImportedDoc && (includeDeleted || isLiveResource(googleImportedDoc))) {
4406
+ return { doc: googleImportedDoc, kind: "google" };
4407
+ }
4408
+ if (aiImportedDoc && isAddressableAiImport(aiImportedDoc, includeDeleted)) {
4409
+ return { doc: aiImportedDoc, kind: "ai" };
4410
+ }
4411
+ return null;
4412
+ }
4413
+ function normalizeLookupId(resourceId) {
4414
+ return resourceId ? convertObjectIdsToStrings(resourceId) : null;
4415
+ }
4416
+ async function findReferenceRows(normalizedId) {
4417
+ return Promise.all([
4418
+ EventModel.findById(normalizedId).select(EVENT_REFERENCE_FIELDS).lean().exec(),
4419
+ GoogleImportedMarketModel.findById(normalizedId).select(IMPORTED_MARKET_REFERENCE_FIELDS).lean().exec(),
4420
+ AiImportedMarketModel.findById(normalizedId).select(AI_IMPORTED_MARKET_REFERENCE_FIELDS).lean().exec()
4421
+ ]);
4422
+ }
4423
+ async function findDetailRows(normalizedId) {
4424
+ return Promise.all([
4425
+ EventModel.findById(normalizedId).lean().exec(),
4426
+ GoogleImportedMarketModel.findById(normalizedId).lean().exec(),
4427
+ AiImportedMarketModel.findById(normalizedId).lean().exec()
4385
4428
  ]);
4386
- return eventDoc ?? googleImportedDoc ?? aiImportedDoc;
4429
+ }
4430
+ async function findEventOrImportedMarketById(resourceId, options = {}) {
4431
+ const normalizedId = normalizeLookupId(resourceId);
4432
+ if (!normalizedId) {
4433
+ return null;
4434
+ }
4435
+ const [eventDoc, googleImportedDoc, aiImportedDoc] = await findReferenceRows(normalizedId);
4436
+ return pickMatch(
4437
+ eventDoc,
4438
+ googleImportedDoc,
4439
+ aiImportedDoc,
4440
+ options.includeDeleted ?? false
4441
+ );
4442
+ }
4443
+ async function findEventOrImportedMarketDetailsById(resourceId, options = {}) {
4444
+ const normalizedId = normalizeLookupId(resourceId);
4445
+ if (!normalizedId) {
4446
+ return null;
4447
+ }
4448
+ const [eventDoc, googleImportedDoc, aiImportedDoc] = await findDetailRows(normalizedId);
4449
+ return pickMatch(
4450
+ eventDoc,
4451
+ googleImportedDoc,
4452
+ aiImportedDoc,
4453
+ options.includeDeleted ?? false
4454
+ );
4387
4455
  }
4388
4456
 
4389
4457
  // src/service/relations.ts
@@ -5671,6 +5739,7 @@ export {
5671
5739
  GoogleImportedMarketModel,
5672
5740
  ImpersonationAuditModel,
5673
5741
  ImpersonationSessionModel,
5742
+ LIVE_RESOURCE_FILTER,
5674
5743
  LicenceCategory,
5675
5744
  NotificationModel,
5676
5745
  OwnerTypeSchema,
@@ -5724,6 +5793,7 @@ export {
5724
5793
  express,
5725
5794
  findAffiliateByPromoCode,
5726
5795
  findEventOrImportedMarketById,
5796
+ findEventOrImportedMarketDetailsById,
5727
5797
  getActiveLicenceForResource,
5728
5798
  getAssociateAccessMeta,
5729
5799
  getBillingCatalogDefinition,
@@ -5745,6 +5815,7 @@ export {
5745
5815
  hasActiveProLicenceForResource,
5746
5816
  hasValidLicence,
5747
5817
  isAssociableResourceType,
5818
+ isLiveResource,
5748
5819
  isProLicence,
5749
5820
  isProtectedByCurrentStripeSubscription,
5750
5821
  isStandardLicence,