@timardex/cluemart-server-shared 4.0.0 → 4.0.3

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, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, AiImportedMarket, 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, 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';
3
3
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
4
4
  import * as mongoose from 'mongoose';
5
5
  import mongoose__default from 'mongoose';
@@ -492,12 +492,16 @@ type SchemaGoogleImportedMarket = Omit<GoogleImportedMarket, "eventId" | "claime
492
492
  claimedByUserId?: mongoose__default.Types.ObjectId;
493
493
  /** Lowercase `name` mirror for prefix type-ahead (see searchNamePlugin). */
494
494
  searchName?: string;
495
+ /** Indexed earliest `dateTime` start instant for chronological pagination. */
496
+ earliestStartDate?: Date | null;
495
497
  };
496
498
  declare const GoogleImportedMarketModel: mongoose__default.Model<SchemaGoogleImportedMarket, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaGoogleImportedMarket, {}, {}> & Omit<GoogleImportedMarket, "eventId" | "claimedByUserId"> & {
497
499
  eventId?: mongoose__default.Types.ObjectId;
498
500
  claimedByUserId?: mongoose__default.Types.ObjectId;
499
501
  /** Lowercase `name` mirror for prefix type-ahead (see searchNamePlugin). */
500
502
  searchName?: string;
503
+ /** Indexed earliest `dateTime` start instant for chronological pagination. */
504
+ earliestStartDate?: Date | null;
501
505
  } & Required<{
502
506
  _id: string;
503
507
  }> & {
@@ -510,6 +514,18 @@ type SchemaAiImportedMarket = Omit<AiImportedMarket, "eventId" | "claimedByUserI
510
514
  reviewedByUserId?: mongoose__default.Types.ObjectId;
511
515
  /** Lowercase `name` mirror for prefix type-ahead (see searchNamePlugin). */
512
516
  searchName?: string;
517
+ /** Indexed earliest `dateTime` start instant for chronological pagination. */
518
+ earliestStartDate?: Date | null;
519
+ /** Set to the run timestamp each time the market appears on its source. */
520
+ lastSeenAt?: Date | null;
521
+ /** Consecutive successful runs where the market did not appear. */
522
+ missedRuns?: number;
523
+ /** Hash of the raw model description used to skip unchanged re-rewrites. */
524
+ descriptionSourceHash?: string | null;
525
+ /** Why an active market was deactivated (null while active). */
526
+ deactivatedReason?: EnumImportedMarketDeactivationReason | null;
527
+ /** sourceKey of an existing AI market this one may duplicate (soft flag). */
528
+ duplicateHint?: string | null;
513
529
  };
514
530
  declare const AiImportedMarketModel: mongoose__default.Model<SchemaAiImportedMarket, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaAiImportedMarket, {}, {}> & Omit<AiImportedMarket, "eventId" | "claimedByUserId" | "reviewedByUserId"> & {
515
531
  eventId?: mongoose__default.Types.ObjectId;
@@ -517,16 +533,96 @@ declare const AiImportedMarketModel: mongoose__default.Model<SchemaAiImportedMar
517
533
  reviewedByUserId?: mongoose__default.Types.ObjectId;
518
534
  /** Lowercase `name` mirror for prefix type-ahead (see searchNamePlugin). */
519
535
  searchName?: string;
536
+ /** Indexed earliest `dateTime` start instant for chronological pagination. */
537
+ earliestStartDate?: Date | null;
538
+ /** Set to the run timestamp each time the market appears on its source. */
539
+ lastSeenAt?: Date | null;
540
+ /** Consecutive successful runs where the market did not appear. */
541
+ missedRuns?: number;
542
+ /** Hash of the raw model description used to skip unchanged re-rewrites. */
543
+ descriptionSourceHash?: string | null;
544
+ /** Why an active market was deactivated (null while active). */
545
+ deactivatedReason?: EnumImportedMarketDeactivationReason | null;
546
+ /** sourceKey of an existing AI market this one may duplicate (soft flag). */
547
+ duplicateHint?: string | null;
520
548
  } & Required<{
521
549
  _id: string;
522
550
  }> & {
523
551
  __v: number;
524
552
  }, any>;
525
553
 
526
- type SchemaScrapeSite = Omit<ScrapeSite, "_id">;
527
- declare const ScrapeSiteModel: mongoose__default.Model<SchemaScrapeSite, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSite, {}, {}> & SchemaScrapeSite & {
554
+ type AiImportRunStatus = EnumAiImportRunStatus;
555
+ type AiImportSiteResult = {
556
+ errors: number;
557
+ found: number;
558
+ imported: number;
559
+ name: string;
560
+ skipped: number;
561
+ status: EnumAiImportRunStatus.SUCCESS | EnumAiImportRunStatus.ERROR;
562
+ usage: AiImportUsage;
563
+ url: string;
564
+ };
565
+ type SchemaAiImportRun = {
528
566
  _id: mongoose__default.Types.ObjectId;
529
- } & {
567
+ createdAt: Date;
568
+ updatedAt: Date;
569
+ error?: string | null;
570
+ finishedAt?: Date | null;
571
+ result?: {
572
+ errors: number;
573
+ totalFound: number;
574
+ totalImported: number;
575
+ totalSkipped: number;
576
+ } | null;
577
+ siteResults: AiImportSiteResult[];
578
+ startedAt: Date;
579
+ status: AiImportRunStatus;
580
+ triggeredByUserId?: mongoose__default.Types.ObjectId | null;
581
+ usage?: AiImportUsage | null;
582
+ };
583
+ declare const AiImportRunModel: mongoose__default.Model<SchemaAiImportRun, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaAiImportRun, {}, {}> & SchemaAiImportRun & Required<{
584
+ _id: mongoose__default.Types.ObjectId;
585
+ }> & {
586
+ __v: number;
587
+ }, any>;
588
+
589
+ /** Fixed `_id` of the single-document lock guarding AI import runs. */
590
+ declare const AI_IMPORT_RUN_LOCK_KEY = "ai-import-run";
591
+ declare const AiImportRunLockModel: mongoose__default.Model<{
592
+ _id: string;
593
+ lockedAt?: Date | null;
594
+ token?: string | null;
595
+ }, {}, {}, {}, mongoose__default.Document<unknown, {}, {
596
+ _id: string;
597
+ lockedAt?: Date | null;
598
+ token?: string | null;
599
+ }, {}, {}> & {
600
+ _id: string;
601
+ lockedAt?: Date | null;
602
+ token?: string | null;
603
+ } & Required<{
604
+ _id: string;
605
+ }> & {
606
+ __v: number;
607
+ }, any>;
608
+
609
+ /**
610
+ * Fixed `_id` of the single-document AI scrape-site config. Using `_id`
611
+ * (rather than a free-form `key` field) makes the singleton structural: the
612
+ * collection can only ever contain one configuration document.
613
+ */
614
+ declare const SCRAPE_SITES_CONFIG_ID = "scrapeSites";
615
+ type SchemaScrapeSiteItem = Omit<ScrapeSite, "_id" | "createdAt" | "updatedAt">;
616
+ type SchemaScrapeSiteConfig = {
617
+ _id: string;
618
+ sites: Array<SchemaScrapeSiteItem & {
619
+ _id: mongoose__default.Types.ObjectId;
620
+ }>;
621
+ updatedByUserId?: mongoose__default.Types.ObjectId;
622
+ };
623
+ declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & Required<{
624
+ _id: string;
625
+ }> & {
530
626
  __v: number;
531
627
  }, any>;
532
628
 
@@ -1234,9 +1330,10 @@ declare function buildUserPointEntryRemovalPipeline(pointType: EnumPointType, so
1234
1330
  }[];
1235
1331
 
1236
1332
  /**
1237
- * Recomputes dateStatus for every dateTime slot on events and google imported
1238
- * markets, moves ended event date slots into the event date archive, and keeps
1239
- * `EventInfo.dateTime` future-only.
1333
+ * Recomputes dateStatus for every dateTime slot on events, Google-imported
1334
+ * markets, and AI-imported markets (run on a schedule by
1335
+ * `cluemart-server-cron`), moves ended event date slots into the event date
1336
+ * archive, and keeps `EventInfo.dateTime` future-only.
1240
1337
  */
1241
1338
  declare function updateAllEventDateTimeStatuses(): Promise<void>;
1242
1339
 
@@ -1582,4 +1679,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1582
1679
  resourceType: EnumResourceType;
1583
1680
  }): Promise<void>;
1584
1681
 
1585
- export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdPurchaseModel, AffiliateModel, AiImportedMarketModel, AppSettingModel, AuthHandoffTokenModel, type AuthHandoffTokenType, type AuthTokenClient, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAiImportedMarket, type SchemaAppSettingsType, 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 SchemaScrapeSite, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, ScrapeSiteModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
1682
+ export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, AI_IMPORT_RUN_LOCK_KEY, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdPurchaseModel, AffiliateModel, AiImportRunLockModel, AiImportRunModel, type AiImportRunStatus, type AiImportSiteResult, AiImportedMarketModel, AppSettingModel, AuthHandoffTokenModel, type AuthHandoffTokenType, type AuthTokenClient, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SCRAPE_SITES_CONFIG_ID, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAiImportRun, type SchemaAiImportedMarket, type SchemaAppSettingsType, 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 SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, ScrapeSiteConfigModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, 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, Category, ResourceContactDetailsType, ResourceImageType, RelatedPostType, SocialMediaType, PosterUsageType, SocialShareResourceType, TermsAgreement, DateTimeType, LocationGeoType, LocationType, UserLicenceType, GoogleImportedMarket, AiImportedMarket, 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, 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';
3
3
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
4
4
  import * as mongoose from 'mongoose';
5
5
  import mongoose__default from 'mongoose';
@@ -492,12 +492,16 @@ type SchemaGoogleImportedMarket = Omit<GoogleImportedMarket, "eventId" | "claime
492
492
  claimedByUserId?: mongoose__default.Types.ObjectId;
493
493
  /** Lowercase `name` mirror for prefix type-ahead (see searchNamePlugin). */
494
494
  searchName?: string;
495
+ /** Indexed earliest `dateTime` start instant for chronological pagination. */
496
+ earliestStartDate?: Date | null;
495
497
  };
496
498
  declare const GoogleImportedMarketModel: mongoose__default.Model<SchemaGoogleImportedMarket, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaGoogleImportedMarket, {}, {}> & Omit<GoogleImportedMarket, "eventId" | "claimedByUserId"> & {
497
499
  eventId?: mongoose__default.Types.ObjectId;
498
500
  claimedByUserId?: mongoose__default.Types.ObjectId;
499
501
  /** Lowercase `name` mirror for prefix type-ahead (see searchNamePlugin). */
500
502
  searchName?: string;
503
+ /** Indexed earliest `dateTime` start instant for chronological pagination. */
504
+ earliestStartDate?: Date | null;
501
505
  } & Required<{
502
506
  _id: string;
503
507
  }> & {
@@ -510,6 +514,18 @@ type SchemaAiImportedMarket = Omit<AiImportedMarket, "eventId" | "claimedByUserI
510
514
  reviewedByUserId?: mongoose__default.Types.ObjectId;
511
515
  /** Lowercase `name` mirror for prefix type-ahead (see searchNamePlugin). */
512
516
  searchName?: string;
517
+ /** Indexed earliest `dateTime` start instant for chronological pagination. */
518
+ earliestStartDate?: Date | null;
519
+ /** Set to the run timestamp each time the market appears on its source. */
520
+ lastSeenAt?: Date | null;
521
+ /** Consecutive successful runs where the market did not appear. */
522
+ missedRuns?: number;
523
+ /** Hash of the raw model description used to skip unchanged re-rewrites. */
524
+ descriptionSourceHash?: string | null;
525
+ /** Why an active market was deactivated (null while active). */
526
+ deactivatedReason?: EnumImportedMarketDeactivationReason | null;
527
+ /** sourceKey of an existing AI market this one may duplicate (soft flag). */
528
+ duplicateHint?: string | null;
513
529
  };
514
530
  declare const AiImportedMarketModel: mongoose__default.Model<SchemaAiImportedMarket, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaAiImportedMarket, {}, {}> & Omit<AiImportedMarket, "eventId" | "claimedByUserId" | "reviewedByUserId"> & {
515
531
  eventId?: mongoose__default.Types.ObjectId;
@@ -517,16 +533,96 @@ declare const AiImportedMarketModel: mongoose__default.Model<SchemaAiImportedMar
517
533
  reviewedByUserId?: mongoose__default.Types.ObjectId;
518
534
  /** Lowercase `name` mirror for prefix type-ahead (see searchNamePlugin). */
519
535
  searchName?: string;
536
+ /** Indexed earliest `dateTime` start instant for chronological pagination. */
537
+ earliestStartDate?: Date | null;
538
+ /** Set to the run timestamp each time the market appears on its source. */
539
+ lastSeenAt?: Date | null;
540
+ /** Consecutive successful runs where the market did not appear. */
541
+ missedRuns?: number;
542
+ /** Hash of the raw model description used to skip unchanged re-rewrites. */
543
+ descriptionSourceHash?: string | null;
544
+ /** Why an active market was deactivated (null while active). */
545
+ deactivatedReason?: EnumImportedMarketDeactivationReason | null;
546
+ /** sourceKey of an existing AI market this one may duplicate (soft flag). */
547
+ duplicateHint?: string | null;
520
548
  } & Required<{
521
549
  _id: string;
522
550
  }> & {
523
551
  __v: number;
524
552
  }, any>;
525
553
 
526
- type SchemaScrapeSite = Omit<ScrapeSite, "_id">;
527
- declare const ScrapeSiteModel: mongoose__default.Model<SchemaScrapeSite, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSite, {}, {}> & SchemaScrapeSite & {
554
+ type AiImportRunStatus = EnumAiImportRunStatus;
555
+ type AiImportSiteResult = {
556
+ errors: number;
557
+ found: number;
558
+ imported: number;
559
+ name: string;
560
+ skipped: number;
561
+ status: EnumAiImportRunStatus.SUCCESS | EnumAiImportRunStatus.ERROR;
562
+ usage: AiImportUsage;
563
+ url: string;
564
+ };
565
+ type SchemaAiImportRun = {
528
566
  _id: mongoose__default.Types.ObjectId;
529
- } & {
567
+ createdAt: Date;
568
+ updatedAt: Date;
569
+ error?: string | null;
570
+ finishedAt?: Date | null;
571
+ result?: {
572
+ errors: number;
573
+ totalFound: number;
574
+ totalImported: number;
575
+ totalSkipped: number;
576
+ } | null;
577
+ siteResults: AiImportSiteResult[];
578
+ startedAt: Date;
579
+ status: AiImportRunStatus;
580
+ triggeredByUserId?: mongoose__default.Types.ObjectId | null;
581
+ usage?: AiImportUsage | null;
582
+ };
583
+ declare const AiImportRunModel: mongoose__default.Model<SchemaAiImportRun, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaAiImportRun, {}, {}> & SchemaAiImportRun & Required<{
584
+ _id: mongoose__default.Types.ObjectId;
585
+ }> & {
586
+ __v: number;
587
+ }, any>;
588
+
589
+ /** Fixed `_id` of the single-document lock guarding AI import runs. */
590
+ declare const AI_IMPORT_RUN_LOCK_KEY = "ai-import-run";
591
+ declare const AiImportRunLockModel: mongoose__default.Model<{
592
+ _id: string;
593
+ lockedAt?: Date | null;
594
+ token?: string | null;
595
+ }, {}, {}, {}, mongoose__default.Document<unknown, {}, {
596
+ _id: string;
597
+ lockedAt?: Date | null;
598
+ token?: string | null;
599
+ }, {}, {}> & {
600
+ _id: string;
601
+ lockedAt?: Date | null;
602
+ token?: string | null;
603
+ } & Required<{
604
+ _id: string;
605
+ }> & {
606
+ __v: number;
607
+ }, any>;
608
+
609
+ /**
610
+ * Fixed `_id` of the single-document AI scrape-site config. Using `_id`
611
+ * (rather than a free-form `key` field) makes the singleton structural: the
612
+ * collection can only ever contain one configuration document.
613
+ */
614
+ declare const SCRAPE_SITES_CONFIG_ID = "scrapeSites";
615
+ type SchemaScrapeSiteItem = Omit<ScrapeSite, "_id" | "createdAt" | "updatedAt">;
616
+ type SchemaScrapeSiteConfig = {
617
+ _id: string;
618
+ sites: Array<SchemaScrapeSiteItem & {
619
+ _id: mongoose__default.Types.ObjectId;
620
+ }>;
621
+ updatedByUserId?: mongoose__default.Types.ObjectId;
622
+ };
623
+ declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & Required<{
624
+ _id: string;
625
+ }> & {
530
626
  __v: number;
531
627
  }, any>;
532
628
 
@@ -1234,9 +1330,10 @@ declare function buildUserPointEntryRemovalPipeline(pointType: EnumPointType, so
1234
1330
  }[];
1235
1331
 
1236
1332
  /**
1237
- * Recomputes dateStatus for every dateTime slot on events and google imported
1238
- * markets, moves ended event date slots into the event date archive, and keeps
1239
- * `EventInfo.dateTime` future-only.
1333
+ * Recomputes dateStatus for every dateTime slot on events, Google-imported
1334
+ * markets, and AI-imported markets (run on a schedule by
1335
+ * `cluemart-server-cron`), moves ended event date slots into the event date
1336
+ * archive, and keeps `EventInfo.dateTime` future-only.
1240
1337
  */
1241
1338
  declare function updateAllEventDateTimeStatuses(): Promise<void>;
1242
1339
 
@@ -1582,4 +1679,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1582
1679
  resourceType: EnumResourceType;
1583
1680
  }): Promise<void>;
1584
1681
 
1585
- export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdPurchaseModel, AffiliateModel, AiImportedMarketModel, AppSettingModel, AuthHandoffTokenModel, type AuthHandoffTokenType, type AuthTokenClient, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAiImportedMarket, type SchemaAppSettingsType, 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 SchemaScrapeSite, type SchemaStripeSubscription, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, ScrapeSiteModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
1682
+ export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, AI_IMPORT_RUN_LOCK_KEY, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdPurchaseModel, AffiliateModel, AiImportRunLockModel, AiImportRunModel, type AiImportRunStatus, type AiImportSiteResult, AiImportedMarketModel, AppSettingModel, AuthHandoffTokenModel, type AuthHandoffTokenType, type AuthTokenClient, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, EnumPubSubEvents, EventDateArchiveModel, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, ImpersonationAuditModel, ImpersonationSessionModel, LicenceCategory, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SCRAPE_SITES_CONFIG_ID, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaAiImportRun, type SchemaAiImportedMarket, type SchemaAppSettingsType, 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 SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, ScrapeSiteConfigModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildInitialBillingCatalogEntries, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getBillingCatalogDefinition, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, schemaAdresource, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, splitEventDatesForArchive, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };