@timardex/cluemart-server-shared 5.0.0 → 5.3.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/{Affiliate-CisCDggv.d.ts → Affiliate-BRwzOt3b.d.ts} +19 -3
- package/dist/{Affiliate-DfBYlDtn.d.mts → Affiliate-DmLBN3lW.d.mts} +19 -3
- package/dist/{chunk-VM4B5D2I.mjs → chunk-JYBS6IOE.mjs} +13 -4
- package/dist/chunk-JYBS6IOE.mjs.map +1 -0
- package/dist/index.cjs +278 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +137 -11
- package/dist/index.d.ts +137 -11
- package/dist/index.mjs +282 -107
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +8 -0
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +28 -2
- package/dist/mongoose/index.d.ts +28 -2
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +278 -104
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +96 -12
- package/dist/service/index.d.ts +96 -12
- package/dist/service/index.mjs +271 -105
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-VM4B5D2I.mjs.map +0 -1
package/dist/service/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as mongoose from 'mongoose';
|
|
2
2
|
import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
|
|
3
|
-
import { PromoCodeType, EnumAffiliateRewardType, EnumResourceType, EnumUserRole, EnumPointType, UserOverallPointsEntry, DateTimeType, DateTimeWithPriceType, EnumUserLicence as EnumUserLicence$1, UserLicenceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
|
|
3
|
+
import { PromoCodeType, EnumAffiliateRewardType, EnumResourceType, EnumUserRole, EnumPointType, UserOverallPointsEntry, DateTimeType, DateTimeWithPriceType, EnumUserLicence as EnumUserLicence$1, UserLicenceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate, isProLicenceType, isStandardLicenceType } from '@timardex/cluemart-shared';
|
|
4
4
|
export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
|
|
5
|
-
import { g as SchemaAffiliateResourceType, a as SchemaOwnerType, S as SchemaAssociateType, k as SchemaGoogleImportedMarket, i as SchemaAiImportedMarket, j as SchemaEventType, m as SchemaRelationType, q as SchemaUserType } from '../Affiliate-
|
|
5
|
+
import { g as SchemaAffiliateResourceType, a as SchemaOwnerType, S as SchemaAssociateType, k as SchemaGoogleImportedMarket, i as SchemaAiImportedMarket, j as SchemaEventType, m as SchemaRelationType, q as SchemaUserType } from '../Affiliate-DmLBN3lW.mjs';
|
|
6
6
|
import { O as ObjectId, G as GraphQLContext, e as SchemaCreateBulkNotificationInput } from '../index-BptxBl9x.mjs';
|
|
7
7
|
import { DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
|
|
8
8
|
import { EnumUserLicence } from '@timardex/cluemart-shared/enums';
|
|
@@ -133,6 +133,67 @@ declare function getAssociateAccessMeta(resourceType: AssociableResourceType): {
|
|
|
133
133
|
associatedPath: string;
|
|
134
134
|
associateRole: EnumUserRole;
|
|
135
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* A pinned bookkeeping timestamp for a concurrency filter.
|
|
138
|
+
*
|
|
139
|
+
* - `null` matches both a stored `null` and a missing path, so a legacy entry
|
|
140
|
+
* that never wrote the field still matches.
|
|
141
|
+
* - A date is pinned together with `null` (`$in`) because mongoose hydrates the
|
|
142
|
+
* schema default for a missing path: without the `null` alternative, an entry
|
|
143
|
+
* written before the field existed could never be matched again. A re-created
|
|
144
|
+
* invitation always carries a fresh non-null `addedAt`, so the alternative
|
|
145
|
+
* cannot hide a replacement.
|
|
146
|
+
*/
|
|
147
|
+
type PinnedAssociateTimestamp = Date | null | {
|
|
148
|
+
$in: Array<Date | null>;
|
|
149
|
+
};
|
|
150
|
+
declare function pinAssociateTimestamp(value: Date | null | undefined): PinnedAssociateTimestamp;
|
|
151
|
+
type AssociatesWriteGuard = {
|
|
152
|
+
/** Conditions the stored document must still satisfy for the write to apply. */
|
|
153
|
+
filter: {
|
|
154
|
+
associates?: {
|
|
155
|
+
$size: number;
|
|
156
|
+
};
|
|
157
|
+
$and?: Array<{
|
|
158
|
+
associates: {
|
|
159
|
+
$elemMatch: {
|
|
160
|
+
addedAt: PinnedAssociateTimestamp;
|
|
161
|
+
respondedAt: PinnedAssociateTimestamp;
|
|
162
|
+
status: SchemaAssociateType["status"];
|
|
163
|
+
userId: SchemaAssociateType["userId"];
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
}>;
|
|
167
|
+
$or?: Array<{
|
|
168
|
+
associates: {
|
|
169
|
+
$size: number;
|
|
170
|
+
};
|
|
171
|
+
} | {
|
|
172
|
+
associates: null;
|
|
173
|
+
}>;
|
|
174
|
+
};
|
|
175
|
+
/** The associate list to persist. */
|
|
176
|
+
update: {
|
|
177
|
+
associates: SchemaAssociateType[];
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Builds the `associates` half of a resource update, or `null` when the array
|
|
182
|
+
* must not be written at all: the actor may not manage it, or the payload did
|
|
183
|
+
* not carry an `associates` field (clients that omit it keep the stored list).
|
|
184
|
+
*
|
|
185
|
+
* Access grants are never written from a stale snapshot. The returned filter
|
|
186
|
+
* pins membership, statuses **and** the invitation timestamps to what the caller
|
|
187
|
+
* validated against, so a concurrent acceptance, removal or replacement makes
|
|
188
|
+
* the update miss instead of resurrecting revoked access or reverting an
|
|
189
|
+
* accepted invitation. Treat a miss as a conflict (see
|
|
190
|
+
* {@link throwAssociatesChangedError}).
|
|
191
|
+
*/
|
|
192
|
+
declare function buildAssociatesWriteGuard({ canManage, nextAssociates, snapshot, }: {
|
|
193
|
+
canManage: boolean;
|
|
194
|
+
nextAssociates: SchemaAssociateType[];
|
|
195
|
+
snapshot?: SchemaAssociateType[] | null;
|
|
196
|
+
}): AssociatesWriteGuard | null;
|
|
136
197
|
/** The users a resource currently grants associate access to. */
|
|
137
198
|
declare function acceptedAssociateUserIds(associates?: SchemaAssociateType[] | null): ObjectId[];
|
|
138
199
|
/**
|
|
@@ -198,6 +259,9 @@ declare function grantAssociateGrants({ resourceId, resourceType, userIds, }: {
|
|
|
198
259
|
* instead makes the call idempotent and convergent — the same call repairs a
|
|
199
260
|
* removal whose side effect was lost, whether it comes from a retry, the next
|
|
200
261
|
* edit of the resource, or the cron reconciliation job.
|
|
262
|
+
*
|
|
263
|
+
* The grant of a user the resource still accepts is handed back, so a caller's
|
|
264
|
+
* stale `acceptedUserIds` never strips access the resource grants.
|
|
201
265
|
*/
|
|
202
266
|
declare function detachStaleAssociateGrants({ acceptedUserIds, resourceId, resourceType, }: {
|
|
203
267
|
/** Users the resource currently lists as `ACCEPTED`. */
|
|
@@ -691,10 +755,7 @@ declare function syncUserLicencesAfterExpiry(userId: ObjectId, licenceTypes: Enu
|
|
|
691
755
|
* Checks if user has a valid licence of the given types
|
|
692
756
|
*/
|
|
693
757
|
declare function hasValidLicence(licences: UserLicenceType[], licenceTypes: EnumUserLicence$1[], now: dayjs.Dayjs): boolean;
|
|
694
|
-
|
|
695
|
-
* Sends a deactivation notification to the user
|
|
696
|
-
*/
|
|
697
|
-
declare function sendDeactivationNotification(payload: {
|
|
758
|
+
type DeactivationNotificationPayload = {
|
|
698
759
|
data: {
|
|
699
760
|
resourceId: string;
|
|
700
761
|
resourceName: string;
|
|
@@ -704,7 +765,17 @@ declare function sendDeactivationNotification(payload: {
|
|
|
704
765
|
title: string;
|
|
705
766
|
type: EnumNotificationType;
|
|
706
767
|
userIds: ObjectId[];
|
|
707
|
-
}
|
|
768
|
+
};
|
|
769
|
+
/**
|
|
770
|
+
* Sends a deactivation notification to the user.
|
|
771
|
+
*
|
|
772
|
+
* `retryOf` is the previous attempt's timestamp: when the stored in-app notice
|
|
773
|
+
* from that attempt (or later) already exists, the notice is not sent again, so
|
|
774
|
+
* a retried run does not duplicate it.
|
|
775
|
+
*
|
|
776
|
+
* Returns whether the notice is stored.
|
|
777
|
+
*/
|
|
778
|
+
declare function sendDeactivationNotification(payload: DeactivationNotificationPayload, userId: ObjectId, resourceName: string, resourceType: string, retryOf?: Date | null): Promise<boolean>;
|
|
708
779
|
/**
|
|
709
780
|
* Processes license compliance for a single user
|
|
710
781
|
*/
|
|
@@ -835,10 +906,23 @@ declare enum LicenceCategory {
|
|
|
835
906
|
}
|
|
836
907
|
declare const licenceCategoryMapping: Record<EnumUserLicence$1, LicenceCategory>;
|
|
837
908
|
declare const licencePriority: Record<EnumUserLicence$1, number>;
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
909
|
+
/**
|
|
910
|
+
* True for the STANDARD tier of Event, Partner or Vendor.
|
|
911
|
+
*
|
|
912
|
+
* Defined once in `cluemart-shared` (`isStandardLicenceType`), next to the
|
|
913
|
+
* `isProLicenceType` rule, and re-exported here under this historical name for
|
|
914
|
+
* existing importers of `@timardex/cluemart-server-shared`.
|
|
915
|
+
*/
|
|
916
|
+
declare const isStandardLicence: typeof isStandardLicenceType;
|
|
917
|
+
/**
|
|
918
|
+
* True for the paid PRO / PRO_PLUS tiers of any resource category.
|
|
919
|
+
*
|
|
920
|
+
* The rule itself is defined once, in `cluemart-shared` (`isProLicenceType`),
|
|
921
|
+
* and reused here so the mobile client, this package and the server cannot
|
|
922
|
+
* disagree about what counts as PRO. This name is kept for existing importers of
|
|
923
|
+
* `@timardex/cluemart-server-shared`.
|
|
924
|
+
*/
|
|
925
|
+
declare const isProLicence: typeof isProLicenceType;
|
|
842
926
|
type LicenceUpgradeArgs = {
|
|
843
927
|
expiryDate: LicenceExpiryDate;
|
|
844
928
|
licenceType: EnumUserLicence$1;
|
|
@@ -920,4 +1004,4 @@ declare function hasActiveProLicenceForResource({ includeStripeProtected, userId
|
|
|
920
1004
|
resourceType: EnumResourceType;
|
|
921
1005
|
}): Promise<boolean>;
|
|
922
1006
|
|
|
923
|
-
export { ACTIVE_NOT_DELETED_FILTER, type ActiveLicenceOptions, type AiImportedMarketReference, type AssociableResourceType, type AwardAffiliateVendorSubscriptionRewardsResult, type DetachedAssociateGrants, type EventOrImportedMarketLookupOptions, type EventOrImportedMarketMatch, type EventOrImportedMarketReferenceMatch, type EventReference, type ImportedMarketReference, type IndexBuildFailure, type IndexableModel, LIVE_RESOURCE_FILTER, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, SUBSCRIPTION_REWARD_TIMEZONE, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, findEventOrImportedMarketDetailsById, getActiveLicenceForResource, getAssociateAccessMeta, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isLiveResource, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
|
|
1007
|
+
export { ACTIVE_NOT_DELETED_FILTER, type ActiveLicenceOptions, type AiImportedMarketReference, type AssociableResourceType, type AssociatesWriteGuard, type AwardAffiliateVendorSubscriptionRewardsResult, type DetachedAssociateGrants, type EventOrImportedMarketLookupOptions, type EventOrImportedMarketMatch, type EventOrImportedMarketReferenceMatch, type EventReference, type ImportedMarketReference, type IndexBuildFailure, type IndexableModel, LIVE_RESOURCE_FILTER, LicenceCategory, type NotificationPubSub, type PinnedAssociateTimestamp, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, SUBSCRIPTION_REWARD_TIMEZONE, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildAssociatesWriteGuard, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, findEventOrImportedMarketDetailsById, getActiveLicenceForResource, getAssociateAccessMeta, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isLiveResource, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, pinAssociateTimestamp, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
|
package/dist/service/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as mongoose from 'mongoose';
|
|
2
2
|
import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
|
|
3
|
-
import { PromoCodeType, EnumAffiliateRewardType, EnumResourceType, EnumUserRole, EnumPointType, UserOverallPointsEntry, DateTimeType, DateTimeWithPriceType, EnumUserLicence as EnumUserLicence$1, UserLicenceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate } from '@timardex/cluemart-shared';
|
|
3
|
+
import { PromoCodeType, EnumAffiliateRewardType, EnumResourceType, EnumUserRole, EnumPointType, UserOverallPointsEntry, DateTimeType, DateTimeWithPriceType, EnumUserLicence as EnumUserLicence$1, UserLicenceType, EnumNotificationResourceType, EnumNotificationType, LicenceExpiryDate, isProLicenceType, isStandardLicenceType } from '@timardex/cluemart-shared';
|
|
4
4
|
export { updateSingleDateTimeStatus } from '@timardex/cluemart-shared';
|
|
5
|
-
import { g as SchemaAffiliateResourceType, a as SchemaOwnerType, S as SchemaAssociateType, k as SchemaGoogleImportedMarket, i as SchemaAiImportedMarket, j as SchemaEventType, m as SchemaRelationType, q as SchemaUserType } from '../Affiliate-
|
|
5
|
+
import { g as SchemaAffiliateResourceType, a as SchemaOwnerType, S as SchemaAssociateType, k as SchemaGoogleImportedMarket, i as SchemaAiImportedMarket, j as SchemaEventType, m as SchemaRelationType, q as SchemaUserType } from '../Affiliate-BRwzOt3b.js';
|
|
6
6
|
import { O as ObjectId, G as GraphQLContext, e as SchemaCreateBulkNotificationInput } from '../index-BptxBl9x.js';
|
|
7
7
|
import { DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
|
|
8
8
|
import { EnumUserLicence } from '@timardex/cluemart-shared/enums';
|
|
@@ -133,6 +133,67 @@ declare function getAssociateAccessMeta(resourceType: AssociableResourceType): {
|
|
|
133
133
|
associatedPath: string;
|
|
134
134
|
associateRole: EnumUserRole;
|
|
135
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* A pinned bookkeeping timestamp for a concurrency filter.
|
|
138
|
+
*
|
|
139
|
+
* - `null` matches both a stored `null` and a missing path, so a legacy entry
|
|
140
|
+
* that never wrote the field still matches.
|
|
141
|
+
* - A date is pinned together with `null` (`$in`) because mongoose hydrates the
|
|
142
|
+
* schema default for a missing path: without the `null` alternative, an entry
|
|
143
|
+
* written before the field existed could never be matched again. A re-created
|
|
144
|
+
* invitation always carries a fresh non-null `addedAt`, so the alternative
|
|
145
|
+
* cannot hide a replacement.
|
|
146
|
+
*/
|
|
147
|
+
type PinnedAssociateTimestamp = Date | null | {
|
|
148
|
+
$in: Array<Date | null>;
|
|
149
|
+
};
|
|
150
|
+
declare function pinAssociateTimestamp(value: Date | null | undefined): PinnedAssociateTimestamp;
|
|
151
|
+
type AssociatesWriteGuard = {
|
|
152
|
+
/** Conditions the stored document must still satisfy for the write to apply. */
|
|
153
|
+
filter: {
|
|
154
|
+
associates?: {
|
|
155
|
+
$size: number;
|
|
156
|
+
};
|
|
157
|
+
$and?: Array<{
|
|
158
|
+
associates: {
|
|
159
|
+
$elemMatch: {
|
|
160
|
+
addedAt: PinnedAssociateTimestamp;
|
|
161
|
+
respondedAt: PinnedAssociateTimestamp;
|
|
162
|
+
status: SchemaAssociateType["status"];
|
|
163
|
+
userId: SchemaAssociateType["userId"];
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
}>;
|
|
167
|
+
$or?: Array<{
|
|
168
|
+
associates: {
|
|
169
|
+
$size: number;
|
|
170
|
+
};
|
|
171
|
+
} | {
|
|
172
|
+
associates: null;
|
|
173
|
+
}>;
|
|
174
|
+
};
|
|
175
|
+
/** The associate list to persist. */
|
|
176
|
+
update: {
|
|
177
|
+
associates: SchemaAssociateType[];
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Builds the `associates` half of a resource update, or `null` when the array
|
|
182
|
+
* must not be written at all: the actor may not manage it, or the payload did
|
|
183
|
+
* not carry an `associates` field (clients that omit it keep the stored list).
|
|
184
|
+
*
|
|
185
|
+
* Access grants are never written from a stale snapshot. The returned filter
|
|
186
|
+
* pins membership, statuses **and** the invitation timestamps to what the caller
|
|
187
|
+
* validated against, so a concurrent acceptance, removal or replacement makes
|
|
188
|
+
* the update miss instead of resurrecting revoked access or reverting an
|
|
189
|
+
* accepted invitation. Treat a miss as a conflict (see
|
|
190
|
+
* {@link throwAssociatesChangedError}).
|
|
191
|
+
*/
|
|
192
|
+
declare function buildAssociatesWriteGuard({ canManage, nextAssociates, snapshot, }: {
|
|
193
|
+
canManage: boolean;
|
|
194
|
+
nextAssociates: SchemaAssociateType[];
|
|
195
|
+
snapshot?: SchemaAssociateType[] | null;
|
|
196
|
+
}): AssociatesWriteGuard | null;
|
|
136
197
|
/** The users a resource currently grants associate access to. */
|
|
137
198
|
declare function acceptedAssociateUserIds(associates?: SchemaAssociateType[] | null): ObjectId[];
|
|
138
199
|
/**
|
|
@@ -198,6 +259,9 @@ declare function grantAssociateGrants({ resourceId, resourceType, userIds, }: {
|
|
|
198
259
|
* instead makes the call idempotent and convergent — the same call repairs a
|
|
199
260
|
* removal whose side effect was lost, whether it comes from a retry, the next
|
|
200
261
|
* edit of the resource, or the cron reconciliation job.
|
|
262
|
+
*
|
|
263
|
+
* The grant of a user the resource still accepts is handed back, so a caller's
|
|
264
|
+
* stale `acceptedUserIds` never strips access the resource grants.
|
|
201
265
|
*/
|
|
202
266
|
declare function detachStaleAssociateGrants({ acceptedUserIds, resourceId, resourceType, }: {
|
|
203
267
|
/** Users the resource currently lists as `ACCEPTED`. */
|
|
@@ -691,10 +755,7 @@ declare function syncUserLicencesAfterExpiry(userId: ObjectId, licenceTypes: Enu
|
|
|
691
755
|
* Checks if user has a valid licence of the given types
|
|
692
756
|
*/
|
|
693
757
|
declare function hasValidLicence(licences: UserLicenceType[], licenceTypes: EnumUserLicence$1[], now: dayjs.Dayjs): boolean;
|
|
694
|
-
|
|
695
|
-
* Sends a deactivation notification to the user
|
|
696
|
-
*/
|
|
697
|
-
declare function sendDeactivationNotification(payload: {
|
|
758
|
+
type DeactivationNotificationPayload = {
|
|
698
759
|
data: {
|
|
699
760
|
resourceId: string;
|
|
700
761
|
resourceName: string;
|
|
@@ -704,7 +765,17 @@ declare function sendDeactivationNotification(payload: {
|
|
|
704
765
|
title: string;
|
|
705
766
|
type: EnumNotificationType;
|
|
706
767
|
userIds: ObjectId[];
|
|
707
|
-
}
|
|
768
|
+
};
|
|
769
|
+
/**
|
|
770
|
+
* Sends a deactivation notification to the user.
|
|
771
|
+
*
|
|
772
|
+
* `retryOf` is the previous attempt's timestamp: when the stored in-app notice
|
|
773
|
+
* from that attempt (or later) already exists, the notice is not sent again, so
|
|
774
|
+
* a retried run does not duplicate it.
|
|
775
|
+
*
|
|
776
|
+
* Returns whether the notice is stored.
|
|
777
|
+
*/
|
|
778
|
+
declare function sendDeactivationNotification(payload: DeactivationNotificationPayload, userId: ObjectId, resourceName: string, resourceType: string, retryOf?: Date | null): Promise<boolean>;
|
|
708
779
|
/**
|
|
709
780
|
* Processes license compliance for a single user
|
|
710
781
|
*/
|
|
@@ -835,10 +906,23 @@ declare enum LicenceCategory {
|
|
|
835
906
|
}
|
|
836
907
|
declare const licenceCategoryMapping: Record<EnumUserLicence$1, LicenceCategory>;
|
|
837
908
|
declare const licencePriority: Record<EnumUserLicence$1, number>;
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
909
|
+
/**
|
|
910
|
+
* True for the STANDARD tier of Event, Partner or Vendor.
|
|
911
|
+
*
|
|
912
|
+
* Defined once in `cluemart-shared` (`isStandardLicenceType`), next to the
|
|
913
|
+
* `isProLicenceType` rule, and re-exported here under this historical name for
|
|
914
|
+
* existing importers of `@timardex/cluemart-server-shared`.
|
|
915
|
+
*/
|
|
916
|
+
declare const isStandardLicence: typeof isStandardLicenceType;
|
|
917
|
+
/**
|
|
918
|
+
* True for the paid PRO / PRO_PLUS tiers of any resource category.
|
|
919
|
+
*
|
|
920
|
+
* The rule itself is defined once, in `cluemart-shared` (`isProLicenceType`),
|
|
921
|
+
* and reused here so the mobile client, this package and the server cannot
|
|
922
|
+
* disagree about what counts as PRO. This name is kept for existing importers of
|
|
923
|
+
* `@timardex/cluemart-server-shared`.
|
|
924
|
+
*/
|
|
925
|
+
declare const isProLicence: typeof isProLicenceType;
|
|
842
926
|
type LicenceUpgradeArgs = {
|
|
843
927
|
expiryDate: LicenceExpiryDate;
|
|
844
928
|
licenceType: EnumUserLicence$1;
|
|
@@ -920,4 +1004,4 @@ declare function hasActiveProLicenceForResource({ includeStripeProtected, userId
|
|
|
920
1004
|
resourceType: EnumResourceType;
|
|
921
1005
|
}): Promise<boolean>;
|
|
922
1006
|
|
|
923
|
-
export { ACTIVE_NOT_DELETED_FILTER, type ActiveLicenceOptions, type AiImportedMarketReference, type AssociableResourceType, type AwardAffiliateVendorSubscriptionRewardsResult, type DetachedAssociateGrants, type EventOrImportedMarketLookupOptions, type EventOrImportedMarketMatch, type EventOrImportedMarketReferenceMatch, type EventReference, type ImportedMarketReference, type IndexBuildFailure, type IndexableModel, LIVE_RESOURCE_FILTER, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, SUBSCRIPTION_REWARD_TIMEZONE, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, findEventOrImportedMarketDetailsById, getActiveLicenceForResource, getAssociateAccessMeta, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isLiveResource, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
|
|
1007
|
+
export { ACTIVE_NOT_DELETED_FILTER, type ActiveLicenceOptions, type AiImportedMarketReference, type AssociableResourceType, type AssociatesWriteGuard, type AwardAffiliateVendorSubscriptionRewardsResult, type DetachedAssociateGrants, type EventOrImportedMarketLookupOptions, type EventOrImportedMarketMatch, type EventOrImportedMarketReferenceMatch, type EventReference, type ImportedMarketReference, type IndexBuildFailure, type IndexableModel, LIVE_RESOURCE_FILTER, LicenceCategory, type NotificationPubSub, type PinnedAssociateTimestamp, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, type ReconcileAssociateGrantsResult, SUBSCRIPTION_REWARD_TIMEZONE, acceptedAssociateUserIds, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildAssociatesWriteGuard, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, detachAssociateGrantsForResources, detachStaleAssociateGrants, detachUsersFromResource, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureDatabaseIndexes, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, findEventOrImportedMarketDetailsById, getActiveLicenceForResource, getAssociateAccessMeta, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getUserIdsWithActiveProLicence, getVendorResourceInfo, grantAssociateGrants, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasActiveProLicenceForResource, hasValidLicence, isAssociableResourceType, isLiveResource, isProLicence, isProtectedByCurrentStripeSubscription, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, persistArchivedEventDates, pinAssociateTimestamp, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, reconcileAssociateGrants, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
|