@timardex/cluemart-server-shared 4.0.1 → 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';
@@ -516,6 +516,16 @@ type SchemaAiImportedMarket = Omit<AiImportedMarket, "eventId" | "claimedByUserI
516
516
  searchName?: string;
517
517
  /** Indexed earliest `dateTime` start instant for chronological pagination. */
518
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;
519
529
  };
520
530
  declare const AiImportedMarketModel: mongoose__default.Model<SchemaAiImportedMarket, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaAiImportedMarket, {}, {}> & Omit<AiImportedMarket, "eventId" | "claimedByUserId" | "reviewedByUserId"> & {
521
531
  eventId?: mongoose__default.Types.ObjectId;
@@ -525,23 +535,94 @@ declare const AiImportedMarketModel: mongoose__default.Model<SchemaAiImportedMar
525
535
  searchName?: string;
526
536
  /** Indexed earliest `dateTime` start instant for chronological pagination. */
527
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;
528
548
  } & Required<{
529
549
  _id: string;
530
550
  }> & {
531
551
  __v: number;
532
552
  }, any>;
533
553
 
534
- declare const SCRAPE_SITES_CONFIG_KEY = "scrapeSites";
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 = {
566
+ _id: mongoose__default.Types.ObjectId;
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";
535
615
  type SchemaScrapeSiteItem = Omit<ScrapeSite, "_id" | "createdAt" | "updatedAt">;
536
616
  type SchemaScrapeSiteConfig = {
537
- key: string;
617
+ _id: string;
538
618
  sites: Array<SchemaScrapeSiteItem & {
539
619
  _id: mongoose__default.Types.ObjectId;
540
620
  }>;
621
+ updatedByUserId?: mongoose__default.Types.ObjectId;
541
622
  };
542
- declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & {
543
- _id: mongoose__default.Types.ObjectId;
544
- } & {
623
+ declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & Required<{
624
+ _id: string;
625
+ }> & {
545
626
  __v: number;
546
627
  }, any>;
547
628
 
@@ -1249,9 +1330,10 @@ declare function buildUserPointEntryRemovalPipeline(pointType: EnumPointType, so
1249
1330
  }[];
1250
1331
 
1251
1332
  /**
1252
- * Recomputes dateStatus for every dateTime slot on events and google imported
1253
- * markets, moves ended event date slots into the event date archive, and keeps
1254
- * `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.
1255
1337
  */
1256
1338
  declare function updateAllEventDateTimeStatuses(): Promise<void>;
1257
1339
 
@@ -1597,4 +1679,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1597
1679
  resourceType: EnumResourceType;
1598
1680
  }): Promise<void>;
1599
1681
 
1600
- 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, SCRAPE_SITES_CONFIG_KEY, 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 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 };
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';
@@ -516,6 +516,16 @@ type SchemaAiImportedMarket = Omit<AiImportedMarket, "eventId" | "claimedByUserI
516
516
  searchName?: string;
517
517
  /** Indexed earliest `dateTime` start instant for chronological pagination. */
518
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;
519
529
  };
520
530
  declare const AiImportedMarketModel: mongoose__default.Model<SchemaAiImportedMarket, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaAiImportedMarket, {}, {}> & Omit<AiImportedMarket, "eventId" | "claimedByUserId" | "reviewedByUserId"> & {
521
531
  eventId?: mongoose__default.Types.ObjectId;
@@ -525,23 +535,94 @@ declare const AiImportedMarketModel: mongoose__default.Model<SchemaAiImportedMar
525
535
  searchName?: string;
526
536
  /** Indexed earliest `dateTime` start instant for chronological pagination. */
527
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;
528
548
  } & Required<{
529
549
  _id: string;
530
550
  }> & {
531
551
  __v: number;
532
552
  }, any>;
533
553
 
534
- declare const SCRAPE_SITES_CONFIG_KEY = "scrapeSites";
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 = {
566
+ _id: mongoose__default.Types.ObjectId;
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";
535
615
  type SchemaScrapeSiteItem = Omit<ScrapeSite, "_id" | "createdAt" | "updatedAt">;
536
616
  type SchemaScrapeSiteConfig = {
537
- key: string;
617
+ _id: string;
538
618
  sites: Array<SchemaScrapeSiteItem & {
539
619
  _id: mongoose__default.Types.ObjectId;
540
620
  }>;
621
+ updatedByUserId?: mongoose__default.Types.ObjectId;
541
622
  };
542
- declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & {
543
- _id: mongoose__default.Types.ObjectId;
544
- } & {
623
+ declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & Required<{
624
+ _id: string;
625
+ }> & {
545
626
  __v: number;
546
627
  }, any>;
547
628
 
@@ -1249,9 +1330,10 @@ declare function buildUserPointEntryRemovalPipeline(pointType: EnumPointType, so
1249
1330
  }[];
1250
1331
 
1251
1332
  /**
1252
- * Recomputes dateStatus for every dateTime slot on events and google imported
1253
- * markets, moves ended event date slots into the event date archive, and keeps
1254
- * `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.
1255
1337
  */
1256
1338
  declare function updateAllEventDateTimeStatuses(): Promise<void>;
1257
1339
 
@@ -1597,4 +1679,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1597
1679
  resourceType: EnumResourceType;
1598
1680
  }): Promise<void>;
1599
1681
 
1600
- 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, SCRAPE_SITES_CONFIG_KEY, 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 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 };
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 };