@timardex/cluemart-server-shared 4.0.1 → 4.0.4

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,95 @@ 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
+ error?: string | null;
557
+ errors: number;
558
+ found: number;
559
+ imported: number;
560
+ name: string;
561
+ skipped: number;
562
+ status: EnumAiImportRunStatus.SUCCESS | EnumAiImportRunStatus.ERROR;
563
+ usage: AiImportUsage;
564
+ url: string;
565
+ };
566
+ type SchemaAiImportRun = {
567
+ _id: mongoose__default.Types.ObjectId;
568
+ createdAt: Date;
569
+ updatedAt: Date;
570
+ error?: string | null;
571
+ finishedAt?: Date | null;
572
+ result?: {
573
+ errors: number;
574
+ totalFound: number;
575
+ totalImported: number;
576
+ totalSkipped: number;
577
+ } | null;
578
+ siteResults: AiImportSiteResult[];
579
+ startedAt: Date;
580
+ status: AiImportRunStatus;
581
+ triggeredByUserId?: mongoose__default.Types.ObjectId | null;
582
+ usage?: AiImportUsage | null;
583
+ };
584
+ declare const AiImportRunModel: mongoose__default.Model<SchemaAiImportRun, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaAiImportRun, {}, {}> & SchemaAiImportRun & Required<{
585
+ _id: mongoose__default.Types.ObjectId;
586
+ }> & {
587
+ __v: number;
588
+ }, any>;
589
+
590
+ /** Fixed `_id` of the single-document lock guarding AI import runs. */
591
+ declare const AI_IMPORT_RUN_LOCK_KEY = "ai-import-run";
592
+ declare const AiImportRunLockModel: mongoose__default.Model<{
593
+ _id: string;
594
+ lockedAt?: Date | null;
595
+ token?: string | null;
596
+ }, {}, {}, {}, mongoose__default.Document<unknown, {}, {
597
+ _id: string;
598
+ lockedAt?: Date | null;
599
+ token?: string | null;
600
+ }, {}, {}> & {
601
+ _id: string;
602
+ lockedAt?: Date | null;
603
+ token?: string | null;
604
+ } & Required<{
605
+ _id: string;
606
+ }> & {
607
+ __v: number;
608
+ }, any>;
609
+
610
+ /**
611
+ * Fixed `_id` of the single-document AI scrape-site config. Using `_id`
612
+ * (rather than a free-form `key` field) makes the singleton structural: the
613
+ * collection can only ever contain one configuration document.
614
+ */
615
+ declare const SCRAPE_SITES_CONFIG_ID = "scrapeSites";
535
616
  type SchemaScrapeSiteItem = Omit<ScrapeSite, "_id" | "createdAt" | "updatedAt">;
536
617
  type SchemaScrapeSiteConfig = {
537
- key: string;
618
+ _id: string;
538
619
  sites: Array<SchemaScrapeSiteItem & {
539
620
  _id: mongoose__default.Types.ObjectId;
540
621
  }>;
622
+ updatedByUserId?: mongoose__default.Types.ObjectId;
541
623
  };
542
- declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & {
543
- _id: mongoose__default.Types.ObjectId;
544
- } & {
624
+ declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & Required<{
625
+ _id: string;
626
+ }> & {
545
627
  __v: number;
546
628
  }, any>;
547
629
 
@@ -1249,9 +1331,10 @@ declare function buildUserPointEntryRemovalPipeline(pointType: EnumPointType, so
1249
1331
  }[];
1250
1332
 
1251
1333
  /**
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.
1334
+ * Recomputes dateStatus for every dateTime slot on events, Google-imported
1335
+ * markets, and AI-imported markets (run on a schedule by
1336
+ * `cluemart-server-cron`), moves ended event date slots into the event date
1337
+ * archive, and keeps `EventInfo.dateTime` future-only.
1255
1338
  */
1256
1339
  declare function updateAllEventDateTimeStatuses(): Promise<void>;
1257
1340
 
@@ -1597,4 +1680,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1597
1680
  resourceType: EnumResourceType;
1598
1681
  }): Promise<void>;
1599
1682
 
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 };
1683
+ 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,95 @@ 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
+ error?: string | null;
557
+ errors: number;
558
+ found: number;
559
+ imported: number;
560
+ name: string;
561
+ skipped: number;
562
+ status: EnumAiImportRunStatus.SUCCESS | EnumAiImportRunStatus.ERROR;
563
+ usage: AiImportUsage;
564
+ url: string;
565
+ };
566
+ type SchemaAiImportRun = {
567
+ _id: mongoose__default.Types.ObjectId;
568
+ createdAt: Date;
569
+ updatedAt: Date;
570
+ error?: string | null;
571
+ finishedAt?: Date | null;
572
+ result?: {
573
+ errors: number;
574
+ totalFound: number;
575
+ totalImported: number;
576
+ totalSkipped: number;
577
+ } | null;
578
+ siteResults: AiImportSiteResult[];
579
+ startedAt: Date;
580
+ status: AiImportRunStatus;
581
+ triggeredByUserId?: mongoose__default.Types.ObjectId | null;
582
+ usage?: AiImportUsage | null;
583
+ };
584
+ declare const AiImportRunModel: mongoose__default.Model<SchemaAiImportRun, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaAiImportRun, {}, {}> & SchemaAiImportRun & Required<{
585
+ _id: mongoose__default.Types.ObjectId;
586
+ }> & {
587
+ __v: number;
588
+ }, any>;
589
+
590
+ /** Fixed `_id` of the single-document lock guarding AI import runs. */
591
+ declare const AI_IMPORT_RUN_LOCK_KEY = "ai-import-run";
592
+ declare const AiImportRunLockModel: mongoose__default.Model<{
593
+ _id: string;
594
+ lockedAt?: Date | null;
595
+ token?: string | null;
596
+ }, {}, {}, {}, mongoose__default.Document<unknown, {}, {
597
+ _id: string;
598
+ lockedAt?: Date | null;
599
+ token?: string | null;
600
+ }, {}, {}> & {
601
+ _id: string;
602
+ lockedAt?: Date | null;
603
+ token?: string | null;
604
+ } & Required<{
605
+ _id: string;
606
+ }> & {
607
+ __v: number;
608
+ }, any>;
609
+
610
+ /**
611
+ * Fixed `_id` of the single-document AI scrape-site config. Using `_id`
612
+ * (rather than a free-form `key` field) makes the singleton structural: the
613
+ * collection can only ever contain one configuration document.
614
+ */
615
+ declare const SCRAPE_SITES_CONFIG_ID = "scrapeSites";
535
616
  type SchemaScrapeSiteItem = Omit<ScrapeSite, "_id" | "createdAt" | "updatedAt">;
536
617
  type SchemaScrapeSiteConfig = {
537
- key: string;
618
+ _id: string;
538
619
  sites: Array<SchemaScrapeSiteItem & {
539
620
  _id: mongoose__default.Types.ObjectId;
540
621
  }>;
622
+ updatedByUserId?: mongoose__default.Types.ObjectId;
541
623
  };
542
- declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & {
543
- _id: mongoose__default.Types.ObjectId;
544
- } & {
624
+ declare const ScrapeSiteConfigModel: mongoose__default.Model<SchemaScrapeSiteConfig, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaScrapeSiteConfig, {}, {}> & SchemaScrapeSiteConfig & Required<{
625
+ _id: string;
626
+ }> & {
545
627
  __v: number;
546
628
  }, any>;
547
629
 
@@ -1249,9 +1331,10 @@ declare function buildUserPointEntryRemovalPipeline(pointType: EnumPointType, so
1249
1331
  }[];
1250
1332
 
1251
1333
  /**
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.
1334
+ * Recomputes dateStatus for every dateTime slot on events, Google-imported
1335
+ * markets, and AI-imported markets (run on a schedule by
1336
+ * `cluemart-server-cron`), moves ended event date slots into the event date
1337
+ * archive, and keeps `EventInfo.dateTime` future-only.
1255
1338
  */
1256
1339
  declare function updateAllEventDateTimeStatuses(): Promise<void>;
1257
1340
 
@@ -1597,4 +1680,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1597
1680
  resourceType: EnumResourceType;
1598
1681
  }): Promise<void>;
1599
1682
 
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 };
1683
+ 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 };