@timardex/cluemart-server-shared 2.2.23 → 2.2.30

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, EventListItemType, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } 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';
3
3
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
4
4
  import * as mongoose from 'mongoose';
5
5
  import mongoose__default from 'mongoose';
@@ -572,7 +572,7 @@ declare const ResourceActivityModel: mongoose__default.Model<ResourceActivityTyp
572
572
  type SchemaUserActivityEvent = Omit<UserActivityEvent, "resourceId"> & {
573
573
  resourceId: ObjectId;
574
574
  };
575
- type SchemaUserType = Omit<UserType, "vendor" | "coupon" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate" | "permissions" | "stripe"> & {
575
+ type SchemaUserType = Omit<UserType, "vendor" | "coupon" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate" | "permissions" | "stripe" | "totalOverallPoints"> & {
576
576
  _id: ObjectId;
577
577
  affiliate: ObjectId;
578
578
  coupon: ObjectId;
@@ -613,7 +613,7 @@ type SchemaStripeSubscription = StripeSubscription & {
613
613
  subscriptionMutationLockExpiresAt?: Date;
614
614
  subscriptionMutationLockId?: string;
615
615
  };
616
- declare const UserModel: mongoose__default.Model<SchemaUserType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "coupon" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate" | "permissions" | "stripe"> & {
616
+ declare const UserModel: mongoose__default.Model<SchemaUserType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "coupon" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate" | "permissions" | "stripe" | "totalOverallPoints"> & {
617
617
  _id: ObjectId;
618
618
  affiliate: ObjectId;
619
619
  coupon: ObjectId;
@@ -1078,6 +1078,93 @@ declare function isValidObjectId(value: string): boolean;
1078
1078
  */
1079
1079
  declare function convertObjectIdsToStrings(obj: any): any;
1080
1080
 
1081
+ /**
1082
+ * One ledger entry for an award.
1083
+ *
1084
+ * `User.overallPoints` is append-only: awarding points must push a new entry so
1085
+ * previously earned points are never replaced.
1086
+ *
1087
+ * `sourceId` is the idempotency key for the award (e.g. the game row `_id`).
1088
+ * Pass it whenever the award can be retried, so `buildUserPointCreditFilter`
1089
+ * can dedupe it.
1090
+ *
1091
+ * `undefined` is the only "no key" value: an empty string is stored as-is so the
1092
+ * entry always matches what `buildUserPointCreditFilter` searches for (a
1093
+ * truthiness check here would drop `""` from the entry while the filter still
1094
+ * looked for it, silently disabling dedupe).
1095
+ */
1096
+ declare function buildUserPointAwardEntry(pointType: EnumPointType, points: number, sourceId?: string): UserOverallPointsEntry;
1097
+ /**
1098
+ * Filter for an idempotent award: matches the user only when no ledger entry
1099
+ * already carries `sourceId`.
1100
+ *
1101
+ * Uses `$not` + `$elemMatch` rather than a dotted `$ne` so the "no entry with
1102
+ * this key" intent is explicit and cannot be mistaken for a per-element
1103
+ * comparison. Combined with `$push` of
1104
+ * `buildUserPointAwardEntry(..., sourceId)`, running the award twice credits it
1105
+ * once. This replaces a cross-document transaction (unavailable on standalone
1106
+ * MongoDB) for "credit points, then mark the source as done" flows.
1107
+ */
1108
+ declare function buildUserPointCreditFilter(userId: unknown, sourceId: string): {
1109
+ _id: unknown;
1110
+ overallPoints: {
1111
+ $not: {
1112
+ $elemMatch: {
1113
+ sourceId: string;
1114
+ };
1115
+ };
1116
+ };
1117
+ };
1118
+ /**
1119
+ * Matches users whose spendable total (sum of every ledger entry) covers
1120
+ * `amount`. Legacy numeric values contribute 0 until the startup migration runs.
1121
+ */
1122
+ declare function buildUserHasEnoughPointsFilter(amount: number): {
1123
+ $expr: {
1124
+ $gte: (number | {
1125
+ $sum: {
1126
+ $ifNull: (string | never[])[];
1127
+ };
1128
+ })[];
1129
+ };
1130
+ };
1131
+ /**
1132
+ * Debits `amount` from the oldest entries first (FIFO), flooring every entry at
1133
+ * 0 and dropping emptied ones. Pair with `buildUserHasEnoughPointsFilter` so
1134
+ * the full amount is always covered.
1135
+ *
1136
+ * Non-array `overallPoints` values are handled by `buildLedgerWriteExpr`: a
1137
+ * legacy number is written back unchanged (treating it as an empty ledger would
1138
+ * delete the stored balance), while null/missing becomes an empty ledger.
1139
+ */
1140
+ declare function buildUserPointDebitPipeline(amount: number): {
1141
+ $set: {
1142
+ overallPoints: {
1143
+ $cond: object[];
1144
+ };
1145
+ };
1146
+ }[];
1147
+ /**
1148
+ * Removes the first ledger entry matching `pointType` (and `sourceId`, when
1149
+ * given), reversing a single award. `$pull` cannot be used because it would
1150
+ * remove every entry of that type.
1151
+ *
1152
+ * Always pass `sourceId` when the award carries one: matching on `pointType`
1153
+ * alone would remove an unrelated award of the same type (e.g. checking out of
1154
+ * one event stripping a different event's check-in points).
1155
+ *
1156
+ * Non-array `overallPoints` values are handled by `buildLedgerWriteExpr`: a
1157
+ * legacy number is written back unchanged so the stored balance is never
1158
+ * replaced, while null/missing becomes an empty ledger.
1159
+ */
1160
+ declare function buildUserPointEntryRemovalPipeline(pointType: EnumPointType, sourceId?: string): {
1161
+ $set: {
1162
+ overallPoints: {
1163
+ $cond: object[];
1164
+ };
1165
+ };
1166
+ }[];
1167
+
1081
1168
  /**
1082
1169
  * Recomputes dateStatus for every dateTime slot on events and google imported
1083
1170
  * markets, moves ended event date slots into the event date archive, and keeps
@@ -1425,4 +1512,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1425
1512
  resourceType: EnumResourceType;
1426
1513
  }): Promise<void>;
1427
1514
 
1428
- 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, 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 };
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 };
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, EventListItemType, DateTimeWithPriceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } 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';
3
3
  export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
4
4
  import * as mongoose from 'mongoose';
5
5
  import mongoose__default from 'mongoose';
@@ -572,7 +572,7 @@ declare const ResourceActivityModel: mongoose__default.Model<ResourceActivityTyp
572
572
  type SchemaUserActivityEvent = Omit<UserActivityEvent, "resourceId"> & {
573
573
  resourceId: ObjectId;
574
574
  };
575
- type SchemaUserType = Omit<UserType, "vendor" | "coupon" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate" | "permissions" | "stripe"> & {
575
+ type SchemaUserType = Omit<UserType, "vendor" | "coupon" | "events" | "partner" | "userActivity" | "_id" | "game" | "school" | "affiliate" | "permissions" | "stripe" | "totalOverallPoints"> & {
576
576
  _id: ObjectId;
577
577
  affiliate: ObjectId;
578
578
  coupon: ObjectId;
@@ -613,7 +613,7 @@ type SchemaStripeSubscription = StripeSubscription & {
613
613
  subscriptionMutationLockExpiresAt?: Date;
614
614
  subscriptionMutationLockId?: string;
615
615
  };
616
- declare const UserModel: mongoose__default.Model<SchemaUserType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "coupon" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate" | "permissions" | "stripe"> & {
616
+ declare const UserModel: mongoose__default.Model<SchemaUserType, {}, {}, {}, mongoose__default.Document<unknown, {}, SchemaUserType, {}, {}> & Omit<UserType, "_id" | "vendor" | "coupon" | "events" | "partner" | "userActivity" | "game" | "school" | "affiliate" | "permissions" | "stripe" | "totalOverallPoints"> & {
617
617
  _id: ObjectId;
618
618
  affiliate: ObjectId;
619
619
  coupon: ObjectId;
@@ -1078,6 +1078,93 @@ declare function isValidObjectId(value: string): boolean;
1078
1078
  */
1079
1079
  declare function convertObjectIdsToStrings(obj: any): any;
1080
1080
 
1081
+ /**
1082
+ * One ledger entry for an award.
1083
+ *
1084
+ * `User.overallPoints` is append-only: awarding points must push a new entry so
1085
+ * previously earned points are never replaced.
1086
+ *
1087
+ * `sourceId` is the idempotency key for the award (e.g. the game row `_id`).
1088
+ * Pass it whenever the award can be retried, so `buildUserPointCreditFilter`
1089
+ * can dedupe it.
1090
+ *
1091
+ * `undefined` is the only "no key" value: an empty string is stored as-is so the
1092
+ * entry always matches what `buildUserPointCreditFilter` searches for (a
1093
+ * truthiness check here would drop `""` from the entry while the filter still
1094
+ * looked for it, silently disabling dedupe).
1095
+ */
1096
+ declare function buildUserPointAwardEntry(pointType: EnumPointType, points: number, sourceId?: string): UserOverallPointsEntry;
1097
+ /**
1098
+ * Filter for an idempotent award: matches the user only when no ledger entry
1099
+ * already carries `sourceId`.
1100
+ *
1101
+ * Uses `$not` + `$elemMatch` rather than a dotted `$ne` so the "no entry with
1102
+ * this key" intent is explicit and cannot be mistaken for a per-element
1103
+ * comparison. Combined with `$push` of
1104
+ * `buildUserPointAwardEntry(..., sourceId)`, running the award twice credits it
1105
+ * once. This replaces a cross-document transaction (unavailable on standalone
1106
+ * MongoDB) for "credit points, then mark the source as done" flows.
1107
+ */
1108
+ declare function buildUserPointCreditFilter(userId: unknown, sourceId: string): {
1109
+ _id: unknown;
1110
+ overallPoints: {
1111
+ $not: {
1112
+ $elemMatch: {
1113
+ sourceId: string;
1114
+ };
1115
+ };
1116
+ };
1117
+ };
1118
+ /**
1119
+ * Matches users whose spendable total (sum of every ledger entry) covers
1120
+ * `amount`. Legacy numeric values contribute 0 until the startup migration runs.
1121
+ */
1122
+ declare function buildUserHasEnoughPointsFilter(amount: number): {
1123
+ $expr: {
1124
+ $gte: (number | {
1125
+ $sum: {
1126
+ $ifNull: (string | never[])[];
1127
+ };
1128
+ })[];
1129
+ };
1130
+ };
1131
+ /**
1132
+ * Debits `amount` from the oldest entries first (FIFO), flooring every entry at
1133
+ * 0 and dropping emptied ones. Pair with `buildUserHasEnoughPointsFilter` so
1134
+ * the full amount is always covered.
1135
+ *
1136
+ * Non-array `overallPoints` values are handled by `buildLedgerWriteExpr`: a
1137
+ * legacy number is written back unchanged (treating it as an empty ledger would
1138
+ * delete the stored balance), while null/missing becomes an empty ledger.
1139
+ */
1140
+ declare function buildUserPointDebitPipeline(amount: number): {
1141
+ $set: {
1142
+ overallPoints: {
1143
+ $cond: object[];
1144
+ };
1145
+ };
1146
+ }[];
1147
+ /**
1148
+ * Removes the first ledger entry matching `pointType` (and `sourceId`, when
1149
+ * given), reversing a single award. `$pull` cannot be used because it would
1150
+ * remove every entry of that type.
1151
+ *
1152
+ * Always pass `sourceId` when the award carries one: matching on `pointType`
1153
+ * alone would remove an unrelated award of the same type (e.g. checking out of
1154
+ * one event stripping a different event's check-in points).
1155
+ *
1156
+ * Non-array `overallPoints` values are handled by `buildLedgerWriteExpr`: a
1157
+ * legacy number is written back unchanged so the stored balance is never
1158
+ * replaced, while null/missing becomes an empty ledger.
1159
+ */
1160
+ declare function buildUserPointEntryRemovalPipeline(pointType: EnumPointType, sourceId?: string): {
1161
+ $set: {
1162
+ overallPoints: {
1163
+ $cond: object[];
1164
+ };
1165
+ };
1166
+ }[];
1167
+
1081
1168
  /**
1082
1169
  * Recomputes dateStatus for every dateTime slot on events and google imported
1083
1170
  * markets, moves ended event date slots into the event date archive, and keeps
@@ -1425,4 +1512,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
1425
1512
  resourceType: EnumResourceType;
1426
1513
  }): Promise<void>;
1427
1514
 
1428
- 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, 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 };
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 };