@timardex/cluemart-server-shared 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
2
- import { AdType, AdDailyPriceType, AdBookingType, EnumAdShowOn, AdSettingsType, 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, 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, AdSettingsType, 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, 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';
@@ -38,22 +38,25 @@ declare const AdBookingModel: mongoose__default.Model<AdBookingType, {}, {}, {},
38
38
  __v: number;
39
39
  }, any>;
40
40
 
41
- type AdImpressionEntry = {
42
- _id: string;
43
- adId: string;
44
- dayKey: string;
45
- placement: EnumAdShowOn.FRONT_PAGE | EnumAdShowOn.MARKET_SEARCH;
46
- recordedAt: Date;
47
- viewerSlotKey: string;
48
- };
49
- declare const AdImpressionModel: mongoose__default.Model<AdImpressionEntry, {}, {}, {}, mongoose__default.Document<unknown, {}, AdImpressionEntry, {}, {}> & AdImpressionEntry & Required<{
41
+ declare const AdMetricsModel: mongoose__default.Model<AdMetricsType, {}, {}, {}, mongoose__default.Document<unknown, {}, AdMetricsType, {}, {}> & AdMetricsType & Required<{
50
42
  _id: string;
51
43
  }> & {
52
44
  __v: number;
53
45
  }, any>;
54
46
 
47
+ type AdSettingsDocument = AdSettingsType & {
48
+ minAppearancesPerHour?: number;
49
+ paidSlotsPerPlacement?: number;
50
+ reservedSlotsPerPlacement?: number;
51
+ rotationSeconds?: number;
52
+ };
55
53
  declare const DEFAULT_AD_SETTINGS: AdSettingsType;
56
- declare const AdSettingsModel: mongoose__default.Model<AdSettingsType, {}, {}, {}, mongoose__default.Document<unknown, {}, AdSettingsType, {}, {}> & AdSettingsType & Required<{
54
+ declare const AdSettingsModel: mongoose__default.Model<AdSettingsDocument, {}, {}, {}, mongoose__default.Document<unknown, {}, AdSettingsDocument, {}, {}> & AdSettingsType & {
55
+ minAppearancesPerHour?: number;
56
+ paidSlotsPerPlacement?: number;
57
+ reservedSlotsPerPlacement?: number;
58
+ rotationSeconds?: number;
59
+ } & Required<{
57
60
  _id: "default";
58
61
  }> & {
59
62
  __v: number;
@@ -953,13 +956,15 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
953
956
  * `affiliateResources.resourceOwner.userId`
954
957
  * - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
955
958
  *
956
- * Reward type follows the owner's highest valid licence + Stripe paying status:
957
- * - Pro / Pro+ with paying Stripe (ACTIVE) → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
958
- * - Pro / Pro+ without paying Stripe → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
959
+ * Reward type follows the owner's highest valid licence + Stripe subscription status:
960
+ * - Pro / Pro+ with Stripe (ACTIVE/TRIALING) → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
961
+ * - Pro / Pro+ without an eligible Stripe subscription → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
959
962
  * - Standard → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
960
963
  *
961
- * Idempotent per affiliate + vendor + calendar month — a mid-month licence
962
- * upgrade (Standard → paying Pro) takes effect from the following month.
964
+ * Stripe eligibility requires a subscription ID and a vendor Pro / Pro+ plan,
965
+ * but not a future paid-through endDate. It does not establish paid licence access.
966
+ * Idempotent per affiliate + vendor + calendar month — a mid-month upgrade
967
+ * (Standard → Pro with an eligible Stripe subscription) affects the next month.
963
968
  * On successful awards, sends the affiliate owner a single aggregated
964
969
  * notification per run (best-effort).
965
970
  *
@@ -1003,8 +1008,10 @@ declare const SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
1003
1008
  * Maps a vendor owner's highest valid vendor licence to a monthly subscription reward.
1004
1009
  *
1005
1010
  * Prefer Pro / Pro+ over Standard when both are valid.
1006
- * Pro / Pro+ only yields the Pro reward when the owner has an active Stripe subscription;
1007
- * otherwise falls back to the Standard subscription reward.
1011
+ * Pro / Pro+ yields the Pro reward when the owner has a Stripe subscription ID,
1012
+ * a vendor Pro / Pro+ plan, and ACTIVE or TRIALING subscription status.
1013
+ * A future paid-through endDate is not required for rewards; this does not
1014
+ * establish paid access for licence compliance. Otherwise falls back to Standard.
1008
1015
  * Returns `null` when no non-expired vendor licence applies.
1009
1016
  */
1010
1017
  declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
@@ -1064,7 +1071,9 @@ declare function saveNotificationsInDb(payload: SchemaCreateBulkNotificationInpu
1064
1071
  declare function sendPushNotifications({ data, message, title, userIds, }: SchemaCreateBulkNotificationInput): Promise<void>;
1065
1072
 
1066
1073
  /**
1067
- * Updates ad statuses based on start/end dates and validity
1074
+ * Updates ad statuses based on start/end dates and validity.
1075
+ * `start`/`end` are UTC-midnight NZ day keys, so comparisons run against
1076
+ * today's NZ day key rather than the current instant.
1068
1077
  */
1069
1078
  declare function updateAdStatuses(): Promise<void>;
1070
1079
 
@@ -1233,11 +1242,12 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
1233
1242
  declare function didRemoveAnyStartedDates(previousDateTime: StartedDateSlot[] | undefined, nextDateTime: StartedDateSlot[] | undefined): boolean;
1234
1243
  /**
1235
1244
  * Helper: Update relationDates based on event's dateTime
1236
- * Marks dates as UNAVAILABLE if they no longer exist in the event's dateTime.
1245
+ * Marks dates as CANCELED if they no longer exist in the event's dateTime.
1237
1246
  */
1238
- declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
1247
+ declare function updateRelationDatesToCanceled(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
1239
1248
 
1240
- type PayingStripeSubscriptionPlanResult = {
1249
+ type StripeSubscriptionPlanResult = {
1250
+ /** Meets the caller's eligibility policy; reward eligibility is not paid access. */
1241
1251
  hasSubscription: boolean;
1242
1252
  plan: EnumUserLicence$1 | null;
1243
1253
  validTypes: Set<EnumUserLicence$1>;
@@ -1247,17 +1257,17 @@ type PayingStripeSubscriptionPlanResult = {
1247
1257
  * (event or vendor), the subscription is active, and its finite paid-through
1248
1258
  * `endDate` is later than `now`. Status alone does not establish paid access.
1249
1259
  */
1250
- declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1260
+ declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
1251
1261
  /**
1252
1262
  * Like {@link getPayingStripeSubscriptionPlan} but only treats a vendor PRO
1253
1263
  * plan (`PRO_VENDOR` / `PRO_PLUS_VENDOR`) as paying.
1254
1264
  */
1255
- declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1265
+ declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
1256
1266
  /**
1257
1267
  * Like {@link getPayingStripeSubscriptionPlan} but only treats an event PRO
1258
1268
  * plan (`PRO_EVENT` / `PRO_PLUS_EVENT`) as paying.
1259
1269
  */
1260
- declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1270
+ declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
1261
1271
 
1262
1272
  /**
1263
1273
  * Runs the established compliance pipeline for one freshly loaded user.
@@ -1512,4 +1522,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1512
1522
  resourceType: EnumResourceType;
1513
1523
  }): Promise<void>;
1514
1524
 
1515
- export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, type AdImpressionEntry, AdImpressionModel, AdModel, AdSettingsModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, DEFAULT_AD_SETTINGS, 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 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, 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, updateRelationDatesToUnavailable, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
1525
+ export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdSettingsModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, DEFAULT_AD_SETTINGS, 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 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, 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, EnumAdShowOn, AdSettingsType, 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, 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, AdSettingsType, 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, 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';
@@ -38,22 +38,25 @@ declare const AdBookingModel: mongoose__default.Model<AdBookingType, {}, {}, {},
38
38
  __v: number;
39
39
  }, any>;
40
40
 
41
- type AdImpressionEntry = {
42
- _id: string;
43
- adId: string;
44
- dayKey: string;
45
- placement: EnumAdShowOn.FRONT_PAGE | EnumAdShowOn.MARKET_SEARCH;
46
- recordedAt: Date;
47
- viewerSlotKey: string;
48
- };
49
- declare const AdImpressionModel: mongoose__default.Model<AdImpressionEntry, {}, {}, {}, mongoose__default.Document<unknown, {}, AdImpressionEntry, {}, {}> & AdImpressionEntry & Required<{
41
+ declare const AdMetricsModel: mongoose__default.Model<AdMetricsType, {}, {}, {}, mongoose__default.Document<unknown, {}, AdMetricsType, {}, {}> & AdMetricsType & Required<{
50
42
  _id: string;
51
43
  }> & {
52
44
  __v: number;
53
45
  }, any>;
54
46
 
47
+ type AdSettingsDocument = AdSettingsType & {
48
+ minAppearancesPerHour?: number;
49
+ paidSlotsPerPlacement?: number;
50
+ reservedSlotsPerPlacement?: number;
51
+ rotationSeconds?: number;
52
+ };
55
53
  declare const DEFAULT_AD_SETTINGS: AdSettingsType;
56
- declare const AdSettingsModel: mongoose__default.Model<AdSettingsType, {}, {}, {}, mongoose__default.Document<unknown, {}, AdSettingsType, {}, {}> & AdSettingsType & Required<{
54
+ declare const AdSettingsModel: mongoose__default.Model<AdSettingsDocument, {}, {}, {}, mongoose__default.Document<unknown, {}, AdSettingsDocument, {}, {}> & AdSettingsType & {
55
+ minAppearancesPerHour?: number;
56
+ paidSlotsPerPlacement?: number;
57
+ reservedSlotsPerPlacement?: number;
58
+ rotationSeconds?: number;
59
+ } & Required<{
57
60
  _id: "default";
58
61
  }> & {
59
62
  __v: number;
@@ -953,13 +956,15 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
953
956
  * `affiliateResources.resourceOwner.userId`
954
957
  * - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
955
958
  *
956
- * Reward type follows the owner's highest valid licence + Stripe paying status:
957
- * - Pro / Pro+ with paying Stripe (ACTIVE) → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
958
- * - Pro / Pro+ without paying Stripe → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
959
+ * Reward type follows the owner's highest valid licence + Stripe subscription status:
960
+ * - Pro / Pro+ with Stripe (ACTIVE/TRIALING) → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
961
+ * - Pro / Pro+ without an eligible Stripe subscription → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
959
962
  * - Standard → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
960
963
  *
961
- * Idempotent per affiliate + vendor + calendar month — a mid-month licence
962
- * upgrade (Standard → paying Pro) takes effect from the following month.
964
+ * Stripe eligibility requires a subscription ID and a vendor Pro / Pro+ plan,
965
+ * but not a future paid-through endDate. It does not establish paid licence access.
966
+ * Idempotent per affiliate + vendor + calendar month — a mid-month upgrade
967
+ * (Standard → Pro with an eligible Stripe subscription) affects the next month.
963
968
  * On successful awards, sends the affiliate owner a single aggregated
964
969
  * notification per run (best-effort).
965
970
  *
@@ -1003,8 +1008,10 @@ declare const SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
1003
1008
  * Maps a vendor owner's highest valid vendor licence to a monthly subscription reward.
1004
1009
  *
1005
1010
  * Prefer Pro / Pro+ over Standard when both are valid.
1006
- * Pro / Pro+ only yields the Pro reward when the owner has an active Stripe subscription;
1007
- * otherwise falls back to the Standard subscription reward.
1011
+ * Pro / Pro+ yields the Pro reward when the owner has a Stripe subscription ID,
1012
+ * a vendor Pro / Pro+ plan, and ACTIVE or TRIALING subscription status.
1013
+ * A future paid-through endDate is not required for rewards; this does not
1014
+ * establish paid access for licence compliance. Otherwise falls back to Standard.
1008
1015
  * Returns `null` when no non-expired vendor licence applies.
1009
1016
  */
1010
1017
  declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
@@ -1064,7 +1071,9 @@ declare function saveNotificationsInDb(payload: SchemaCreateBulkNotificationInpu
1064
1071
  declare function sendPushNotifications({ data, message, title, userIds, }: SchemaCreateBulkNotificationInput): Promise<void>;
1065
1072
 
1066
1073
  /**
1067
- * Updates ad statuses based on start/end dates and validity
1074
+ * Updates ad statuses based on start/end dates and validity.
1075
+ * `start`/`end` are UTC-midnight NZ day keys, so comparisons run against
1076
+ * today's NZ day key rather than the current instant.
1068
1077
  */
1069
1078
  declare function updateAdStatuses(): Promise<void>;
1070
1079
 
@@ -1233,11 +1242,12 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
1233
1242
  declare function didRemoveAnyStartedDates(previousDateTime: StartedDateSlot[] | undefined, nextDateTime: StartedDateSlot[] | undefined): boolean;
1234
1243
  /**
1235
1244
  * Helper: Update relationDates based on event's dateTime
1236
- * Marks dates as UNAVAILABLE if they no longer exist in the event's dateTime.
1245
+ * Marks dates as CANCELED if they no longer exist in the event's dateTime.
1237
1246
  */
1238
- declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
1247
+ declare function updateRelationDatesToCanceled(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
1239
1248
 
1240
- type PayingStripeSubscriptionPlanResult = {
1249
+ type StripeSubscriptionPlanResult = {
1250
+ /** Meets the caller's eligibility policy; reward eligibility is not paid access. */
1241
1251
  hasSubscription: boolean;
1242
1252
  plan: EnumUserLicence$1 | null;
1243
1253
  validTypes: Set<EnumUserLicence$1>;
@@ -1247,17 +1257,17 @@ type PayingStripeSubscriptionPlanResult = {
1247
1257
  * (event or vendor), the subscription is active, and its finite paid-through
1248
1258
  * `endDate` is later than `now`. Status alone does not establish paid access.
1249
1259
  */
1250
- declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1260
+ declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
1251
1261
  /**
1252
1262
  * Like {@link getPayingStripeSubscriptionPlan} but only treats a vendor PRO
1253
1263
  * plan (`PRO_VENDOR` / `PRO_PLUS_VENDOR`) as paying.
1254
1264
  */
1255
- declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1265
+ declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
1256
1266
  /**
1257
1267
  * Like {@link getPayingStripeSubscriptionPlan} but only treats an event PRO
1258
1268
  * plan (`PRO_EVENT` / `PRO_PLUS_EVENT`) as paying.
1259
1269
  */
1260
- declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
1270
+ declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
1261
1271
 
1262
1272
  /**
1263
1273
  * Runs the established compliance pipeline for one freshly loaded user.
@@ -1512,4 +1522,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1512
1522
  resourceType: EnumResourceType;
1513
1523
  }): Promise<void>;
1514
1524
 
1515
- export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, type AdImpressionEntry, AdImpressionModel, AdModel, AdSettingsModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, DEFAULT_AD_SETTINGS, 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 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, 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, updateRelationDatesToUnavailable, upgradeUserToLicence, userLicenseSchema, vendorOwnerHasProLicence, vendorProductTypeSchema };
1525
+ export { ACTIVE_NOT_DELETED_FILTER, AD_BILLING_CATALOG_COLLECTION_NAME, APP_SETTINGS_ID, AdBillingCatalogModel, AdBookingModel, AdMetricsModel, AdModel, AdSettingsModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, BILLING_CATALOG_COLLECTION_NAME, BillingCatalogModel, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, DEFAULT_AD_SETTINGS, 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 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, 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 };