@timardex/cluemart-server-shared 1.1.0 → 1.1.1
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-CtH6MdT3.d.ts → Affiliate-B76iZ3fE.d.mts} +7 -38
- package/dist/{Affiliate-DaFyIRHK.d.mts → Affiliate-gqV1-654.d.ts} +7 -38
- package/dist/{Chat-NS-2VVEV.d.mts → Chat-Wn7yfc3v.d.mts} +5 -7
- package/dist/{Chat-NS-2VVEV.d.ts → Chat-Wn7yfc3v.d.ts} +5 -7
- package/dist/{chunk-RU5PTSIO.mjs → chunk-6PNG5BI5.mjs} +1 -1
- package/dist/chunk-6PNG5BI5.mjs.map +1 -0
- package/dist/{chunk-Z22PTYAL.mjs → chunk-YI7Y4K2J.mjs} +2202 -2874
- package/dist/chunk-YI7Y4K2J.mjs.map +1 -0
- package/dist/index.cjs +2232 -3020
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +66 -213
- package/dist/index.d.ts +66 -213
- package/dist/index.mjs +2232 -3020
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +2140 -2864
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +56 -163
- package/dist/mongoose/index.d.ts +56 -163
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +2232 -3020
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +10 -17
- package/dist/service/index.d.ts +10 -17
- package/dist/service/index.mjs +59 -167
- package/dist/service/index.mjs.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-RU5PTSIO.mjs.map +0 -1
- package/dist/chunk-Z22PTYAL.mjs.map +0 -1
package/dist/service/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
|
|
2
|
-
import { PromoCodeType, UserLicenceType, UserType, AffiliateRewardEnumType, LicencesEnumType, DateTimeType, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
|
|
3
1
|
import * as mongoose from 'mongoose';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
|
|
3
|
+
import { PromoCodeType, UserLicenceType, UserType, EnumAffiliateRewardType, EnumUserLicence, DateTimeType, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
|
|
4
|
+
import { n as SchemaAffiliateResourceType, S as SchemaOwnerType, i as SchemaRelationType } from '../Affiliate-B76iZ3fE.mjs';
|
|
5
|
+
import { G as GraphQLContext, O as ObjectId, f as SchemaCreateBulkNotificationInput } from '../Chat-Wn7yfc3v.mjs';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import { DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
|
|
8
8
|
import 'express';
|
|
@@ -54,19 +54,12 @@ declare function awardAffiliateVendorSubscriptionRewards(now?: Date): Promise<Aw
|
|
|
54
54
|
* @param promoCode - Normalized affiliate promo code to resolve.
|
|
55
55
|
* @returns The matching affiliate document, or `null` when not found.
|
|
56
56
|
*/
|
|
57
|
-
declare function findAffiliateByPromoCode(promoCode: PromoCodeType): Promise<(mongoose.Document<unknown, {},
|
|
58
|
-
|
|
57
|
+
declare function findAffiliateByPromoCode(promoCode: PromoCodeType): Promise<(mongoose.Document<unknown, {}, Omit<_timardex_cluemart_shared.AffiliateType, "_id" | "owner" | "affiliateResources"> & {
|
|
58
|
+
affiliateResources: SchemaAffiliateResourceType[];
|
|
59
|
+
owner: SchemaOwnerType;
|
|
60
|
+
}, {}, {}> & Omit<_timardex_cluemart_shared.AffiliateType, "_id" | "owner" | "affiliateResources"> & {
|
|
59
61
|
affiliateResources: SchemaAffiliateResourceType[];
|
|
60
|
-
approvedAt?: Date | null;
|
|
61
|
-
createdAt: Date;
|
|
62
|
-
deletedAt?: Date | null;
|
|
63
62
|
owner: SchemaOwnerType;
|
|
64
|
-
redeemHistory?: {
|
|
65
|
-
paidAt?: Date | null;
|
|
66
|
-
redeemedAt: Date;
|
|
67
|
-
rewardValue: number;
|
|
68
|
-
}[];
|
|
69
|
-
updatedAt: Date;
|
|
70
63
|
} & {
|
|
71
64
|
_id: mongoose.Types.ObjectId;
|
|
72
65
|
} & {
|
|
@@ -89,7 +82,7 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
|
|
|
89
82
|
* otherwise falls back to the Standard subscription reward.
|
|
90
83
|
* Returns `null` when no non-expired vendor licence applies.
|
|
91
84
|
*/
|
|
92
|
-
declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date, stripe?: UserType["stripe"] | null):
|
|
85
|
+
declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date, stripe?: UserType["stripe"] | null): EnumAffiliateRewardType | null;
|
|
93
86
|
/** Inclusive start / exclusive end of the UTC calendar month containing `now`. */
|
|
94
87
|
declare function getSubscriptionRewardPeriodBounds(now?: Date): {
|
|
95
88
|
periodEnd: Date;
|
|
@@ -151,7 +144,7 @@ declare function sendPushNotifications({ data, message, title, userIds, }: Schem
|
|
|
151
144
|
*/
|
|
152
145
|
declare function updateAdStatuses(): Promise<void>;
|
|
153
146
|
|
|
154
|
-
declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType:
|
|
147
|
+
declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType: EnumUserLicence): Promise<void>;
|
|
155
148
|
|
|
156
149
|
/**
|
|
157
150
|
* True when `value` is a valid Mongo ObjectId string.
|
package/dist/service/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
|
|
2
|
-
import { PromoCodeType, UserLicenceType, UserType, AffiliateRewardEnumType, LicencesEnumType, DateTimeType, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
|
|
3
1
|
import * as mongoose from 'mongoose';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
import * as _timardex_cluemart_shared from '@timardex/cluemart-shared';
|
|
3
|
+
import { PromoCodeType, UserLicenceType, UserType, EnumAffiliateRewardType, EnumUserLicence, DateTimeType, EventListItemType, DateTimeWithPriceType } from '@timardex/cluemart-shared';
|
|
4
|
+
import { n as SchemaAffiliateResourceType, S as SchemaOwnerType, i as SchemaRelationType } from '../Affiliate-gqV1-654.js';
|
|
5
|
+
import { G as GraphQLContext, O as ObjectId, f as SchemaCreateBulkNotificationInput } from '../Chat-Wn7yfc3v.js';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import { DateTimeType as DateTimeType$1 } from '@timardex/cluemart-shared/types';
|
|
8
8
|
import 'express';
|
|
@@ -54,19 +54,12 @@ declare function awardAffiliateVendorSubscriptionRewards(now?: Date): Promise<Aw
|
|
|
54
54
|
* @param promoCode - Normalized affiliate promo code to resolve.
|
|
55
55
|
* @returns The matching affiliate document, or `null` when not found.
|
|
56
56
|
*/
|
|
57
|
-
declare function findAffiliateByPromoCode(promoCode: PromoCodeType): Promise<(mongoose.Document<unknown, {},
|
|
58
|
-
|
|
57
|
+
declare function findAffiliateByPromoCode(promoCode: PromoCodeType): Promise<(mongoose.Document<unknown, {}, Omit<_timardex_cluemart_shared.AffiliateType, "_id" | "owner" | "affiliateResources"> & {
|
|
58
|
+
affiliateResources: SchemaAffiliateResourceType[];
|
|
59
|
+
owner: SchemaOwnerType;
|
|
60
|
+
}, {}, {}> & Omit<_timardex_cluemart_shared.AffiliateType, "_id" | "owner" | "affiliateResources"> & {
|
|
59
61
|
affiliateResources: SchemaAffiliateResourceType[];
|
|
60
|
-
approvedAt?: Date | null;
|
|
61
|
-
createdAt: Date;
|
|
62
|
-
deletedAt?: Date | null;
|
|
63
62
|
owner: SchemaOwnerType;
|
|
64
|
-
redeemHistory?: {
|
|
65
|
-
paidAt?: Date | null;
|
|
66
|
-
redeemedAt: Date;
|
|
67
|
-
rewardValue: number;
|
|
68
|
-
}[];
|
|
69
|
-
updatedAt: Date;
|
|
70
63
|
} & {
|
|
71
64
|
_id: mongoose.Types.ObjectId;
|
|
72
65
|
} & {
|
|
@@ -89,7 +82,7 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
|
|
|
89
82
|
* otherwise falls back to the Standard subscription reward.
|
|
90
83
|
* Returns `null` when no non-expired vendor licence applies.
|
|
91
84
|
*/
|
|
92
|
-
declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date, stripe?: UserType["stripe"] | null):
|
|
85
|
+
declare function mapVendorLicenceToSubscriptionRewardType(licences: UserLicenceType[] | null | undefined, now?: Date, stripe?: UserType["stripe"] | null): EnumAffiliateRewardType | null;
|
|
93
86
|
/** Inclusive start / exclusive end of the UTC calendar month containing `now`. */
|
|
94
87
|
declare function getSubscriptionRewardPeriodBounds(now?: Date): {
|
|
95
88
|
periodEnd: Date;
|
|
@@ -151,7 +144,7 @@ declare function sendPushNotifications({ data, message, title, userIds, }: Schem
|
|
|
151
144
|
*/
|
|
152
145
|
declare function updateAdStatuses(): Promise<void>;
|
|
153
146
|
|
|
154
|
-
declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType:
|
|
147
|
+
declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType: EnumUserLicence): Promise<void>;
|
|
155
148
|
|
|
156
149
|
/**
|
|
157
150
|
* True when `value` is a valid Mongo ObjectId string.
|
package/dist/service/index.mjs
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AdModel,
|
|
3
|
-
AdStatusTypeEnum,
|
|
4
3
|
AffiliateModel,
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
EnumAdStatus,
|
|
5
|
+
EnumAffiliateRewardType,
|
|
6
|
+
EnumEventDateStatus,
|
|
7
|
+
EnumEventDateStatus2,
|
|
8
|
+
EnumInviteStatus,
|
|
9
|
+
EnumInviteStatus2,
|
|
10
|
+
EnumNotificationResourceType,
|
|
11
|
+
EnumNotificationType,
|
|
12
|
+
EnumPaymentMethod,
|
|
13
|
+
EnumRegions,
|
|
14
|
+
EnumResourceType,
|
|
15
|
+
EnumSubscriptionStatus,
|
|
16
|
+
EnumUserLicence,
|
|
7
17
|
EventModel,
|
|
8
18
|
GoogleImportedMarketModel,
|
|
9
|
-
InviteEnumType,
|
|
10
|
-
LicencesEnumType,
|
|
11
|
-
NotificationEnumType,
|
|
12
19
|
NotificationModel,
|
|
13
|
-
NotificationResourceEnumType,
|
|
14
20
|
PushTokenModel,
|
|
15
|
-
ResourceTypeEnum,
|
|
16
|
-
SubscriptionStatusEnumType,
|
|
17
21
|
UserModel,
|
|
18
22
|
VendorModel,
|
|
19
23
|
dateFormat,
|
|
20
24
|
timeFormat
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
25
|
+
} from "../chunk-YI7Y4K2J.mjs";
|
|
26
|
+
import "../chunk-6PNG5BI5.mjs";
|
|
23
27
|
|
|
24
28
|
// src/service/promoCode/constants.ts
|
|
25
29
|
var ACTIVE_NOT_DELETED_FILTER = {
|
|
@@ -36,41 +40,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
|
|
|
36
40
|
return existing !== null;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
40
|
-
var EventDateStatusEnumType2 = /* @__PURE__ */ ((EventDateStatusEnumType22) => {
|
|
41
|
-
EventDateStatusEnumType22["Canceled"] = "Canceled";
|
|
42
|
-
EventDateStatusEnumType22["Ended"] = "Ended";
|
|
43
|
-
EventDateStatusEnumType22["Invalid"] = "Invalid";
|
|
44
|
-
EventDateStatusEnumType22["NextWeek"] = "Next_Week";
|
|
45
|
-
EventDateStatusEnumType22["Rescheduled"] = "Rescheduled";
|
|
46
|
-
EventDateStatusEnumType22["Started"] = "Started";
|
|
47
|
-
EventDateStatusEnumType22["StartingSoon"] = "Starting_Soon";
|
|
48
|
-
EventDateStatusEnumType22["ThisWeek"] = "This_Week";
|
|
49
|
-
EventDateStatusEnumType22["Today"] = "Today";
|
|
50
|
-
EventDateStatusEnumType22["Tomorrow"] = "Tomorrow";
|
|
51
|
-
EventDateStatusEnumType22["Upcoming"] = "Upcoming";
|
|
52
|
-
return EventDateStatusEnumType22;
|
|
53
|
-
})(EventDateStatusEnumType2 || {});
|
|
54
|
-
var InviteEnumType2 = /* @__PURE__ */ ((InviteEnumType22) => {
|
|
55
|
-
InviteEnumType22["Accepted"] = "Accepted";
|
|
56
|
-
InviteEnumType22["Completed"] = "Completed";
|
|
57
|
-
InviteEnumType22["Expired"] = "Expired";
|
|
58
|
-
InviteEnumType22["NoStatus"] = "No_Status";
|
|
59
|
-
InviteEnumType22["Pending"] = "Pending";
|
|
60
|
-
InviteEnumType22["Rejected"] = "Rejected";
|
|
61
|
-
InviteEnumType22["Unavailable"] = "Unavailable";
|
|
62
|
-
return InviteEnumType22;
|
|
63
|
-
})(InviteEnumType2 || {});
|
|
64
|
-
var PaymentMethodEnumType = /* @__PURE__ */ ((PaymentMethodEnumType2) => {
|
|
65
|
-
PaymentMethodEnumType2["BankTransfer"] = "bank_transfer";
|
|
66
|
-
PaymentMethodEnumType2["Cash"] = "cash";
|
|
67
|
-
PaymentMethodEnumType2["Eftpos"] = "eftpos";
|
|
68
|
-
PaymentMethodEnumType2["Paypal"] = "paypal";
|
|
69
|
-
PaymentMethodEnumType2["Stripe"] = "stripe";
|
|
70
|
-
return PaymentMethodEnumType2;
|
|
71
|
-
})(PaymentMethodEnumType || {});
|
|
72
|
-
|
|
73
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-NWWKI4PJ.mjs
|
|
43
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-SD42WIMV.mjs
|
|
74
44
|
import dayjs from "dayjs";
|
|
75
45
|
import customParseFormat from "dayjs/plugin/customParseFormat.js";
|
|
76
46
|
import isSameOrAfter from "dayjs/plugin/isSameOrAfter.js";
|
|
@@ -85,10 +55,10 @@ dayjs.extend(utc);
|
|
|
85
55
|
dayjs.extend(timezone);
|
|
86
56
|
dayjs.extend(isSameOrAfter);
|
|
87
57
|
var futureTimePeriods = mapArrayToOptions(
|
|
88
|
-
Object.values(
|
|
58
|
+
Object.values(EnumEventDateStatus2)
|
|
89
59
|
).filter(
|
|
90
60
|
(period) => period.value !== "Starting_Soon" && period.value !== "Canceled" && period.value !== "Rescheduled" && period.value !== "Started" && period.value !== "Ended" && period.value !== "Invalid"
|
|
91
|
-
/*
|
|
61
|
+
/* INVALID */
|
|
92
62
|
).map((period) => ({
|
|
93
63
|
label: period.value.replaceAll("_", " "),
|
|
94
64
|
value: period.value
|
|
@@ -125,68 +95,8 @@ var SHARE_RESOURCE_LABEL = {
|
|
|
125
95
|
school: "School"
|
|
126
96
|
};
|
|
127
97
|
|
|
128
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
129
|
-
var PERMISSIONS = [
|
|
130
|
-
"*",
|
|
131
|
-
// Dashboards
|
|
132
|
-
"dashboard.admin",
|
|
133
|
-
"dashboard.affiliate",
|
|
134
|
-
"dashboard.customer",
|
|
135
|
-
"dashboard.event",
|
|
136
|
-
"dashboard.partner",
|
|
137
|
-
"dashboard.school",
|
|
138
|
-
"dashboard.vendor",
|
|
139
|
-
// Admin: users
|
|
140
|
-
"users.delete",
|
|
141
|
-
"users.read",
|
|
142
|
-
"users.update",
|
|
143
|
-
// Admin: events
|
|
144
|
-
"events.create",
|
|
145
|
-
"events.delete",
|
|
146
|
-
"events.read",
|
|
147
|
-
"events.update",
|
|
148
|
-
// Admin: vendors
|
|
149
|
-
"vendors.create",
|
|
150
|
-
"vendors.delete",
|
|
151
|
-
"vendors.read",
|
|
152
|
-
"vendors.update",
|
|
153
|
-
// Admin: partners
|
|
154
|
-
"partners.create",
|
|
155
|
-
"partners.delete",
|
|
156
|
-
"partners.read",
|
|
157
|
-
"partners.update",
|
|
158
|
-
// Admin: schools
|
|
159
|
-
"schools.create",
|
|
160
|
-
"schools.delete",
|
|
161
|
-
"schools.read",
|
|
162
|
-
"schools.update",
|
|
163
|
-
// Admin: affiliates
|
|
164
|
-
"affiliates.create",
|
|
165
|
-
"affiliates.delete",
|
|
166
|
-
"affiliates.read",
|
|
167
|
-
"affiliates.update",
|
|
168
|
-
// Admin: ads / posts / settings
|
|
169
|
-
"ads.create",
|
|
170
|
-
"ads.delete",
|
|
171
|
-
"ads.read",
|
|
172
|
-
"ads.update",
|
|
173
|
-
"posts.create",
|
|
174
|
-
"posts.delete",
|
|
175
|
-
"posts.read",
|
|
176
|
-
"posts.update",
|
|
177
|
-
"settings.read",
|
|
178
|
-
"settings.update",
|
|
179
|
-
// Product: own-resource management
|
|
180
|
-
"affiliates.manage_own",
|
|
181
|
-
"events.manage_own",
|
|
182
|
-
"partners.manage_own",
|
|
183
|
-
"schools.manage_own",
|
|
184
|
-
"vendors.manage_own"
|
|
185
|
-
];
|
|
98
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-ILILH7E2.mjs
|
|
186
99
|
var PROMO_CODE_PREFIX = "CM-";
|
|
187
|
-
var PERMISSION_SET = new Set(PERMISSIONS);
|
|
188
|
-
|
|
189
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-DDHECBJR.mjs
|
|
190
100
|
var OBJECT_ID_PATH_SEGMENT = "[a-f0-9]{24}";
|
|
191
101
|
var OBJECT_ID_PATH_SEGMENT_END = `${OBJECT_ID_PATH_SEGMENT}$`;
|
|
192
102
|
var gameScreenIdentifierList = [
|
|
@@ -287,28 +197,10 @@ var gameScreenIdentifierList = [
|
|
|
287
197
|
}
|
|
288
198
|
];
|
|
289
199
|
|
|
290
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
291
|
-
var EnumRegions = /* @__PURE__ */ ((EnumRegions2) => {
|
|
292
|
-
EnumRegions2["All"] = "All Regions";
|
|
293
|
-
EnumRegions2["Auckland"] = "Auckland";
|
|
294
|
-
EnumRegions2["BayOfPlentyGisborne"] = "Bay of Plenty & Gisborne";
|
|
295
|
-
EnumRegions2["CanterburyWestCoast"] = "Canterbury & West Coast";
|
|
296
|
-
EnumRegions2["HawkesBay"] = "Hawke's Bay";
|
|
297
|
-
EnumRegions2["ManawatuWanganui"] = "Manawatu-Wanganui";
|
|
298
|
-
EnumRegions2["MarlboroughNelsonTasman"] = "Marlborough & Nelson & Tasman";
|
|
299
|
-
EnumRegions2["Northland"] = "Northland";
|
|
300
|
-
EnumRegions2["Otago"] = "Otago";
|
|
301
|
-
EnumRegions2["Southland"] = "Southland";
|
|
302
|
-
EnumRegions2["Taranaki"] = "Taranaki";
|
|
303
|
-
EnumRegions2["Waikato"] = "Waikato";
|
|
304
|
-
EnumRegions2["Wellington"] = "Wellington";
|
|
305
|
-
return EnumRegions2;
|
|
306
|
-
})(EnumRegions || {});
|
|
307
|
-
|
|
308
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-OHHJ3KJJ.mjs
|
|
200
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-LBEJECG3.mjs
|
|
309
201
|
import dayjs2 from "dayjs";
|
|
310
202
|
var statusOptions = [
|
|
311
|
-
...Object.values(
|
|
203
|
+
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
312
204
|
label: status,
|
|
313
205
|
value: status
|
|
314
206
|
})).sort((a, b) => a.label.localeCompare(b.label))
|
|
@@ -317,7 +209,7 @@ var statusOptions = [
|
|
|
317
209
|
var availableRegionTypes = Object.values(EnumRegions);
|
|
318
210
|
var availableRegionOptions = mapArrayToOptions(availableRegionTypes);
|
|
319
211
|
var paymentMethodOptions = mapArrayToOptions(
|
|
320
|
-
Object.values(
|
|
212
|
+
Object.values(EnumPaymentMethod)
|
|
321
213
|
);
|
|
322
214
|
var CM_SCHOOL_PROMO_CODE = `${PROMO_CODE_PREFIX}SCHOOL`;
|
|
323
215
|
var CM_AFFILIATE_PROMO_CODE = `${PROMO_CODE_PREFIX}AFFILIATE`;
|
|
@@ -1297,42 +1189,42 @@ var availableCategories = assignColorToCategories([
|
|
|
1297
1189
|
var AFFILIATE_REWARDS = {
|
|
1298
1190
|
[
|
|
1299
1191
|
"NEW_EVENT_REGISTRATION"
|
|
1300
|
-
/*
|
|
1192
|
+
/* NEW_EVENT_REGISTRATION */
|
|
1301
1193
|
]: {
|
|
1302
1194
|
description: "10 points for new event registration (one-time reward)",
|
|
1303
1195
|
value: 10
|
|
1304
1196
|
},
|
|
1305
1197
|
[
|
|
1306
1198
|
"NEW_VENDOR_REGISTRATION"
|
|
1307
|
-
/*
|
|
1199
|
+
/* NEW_VENDOR_REGISTRATION */
|
|
1308
1200
|
]: {
|
|
1309
1201
|
description: "5 points for new vendor registration (one-time reward)",
|
|
1310
1202
|
value: 5
|
|
1311
1203
|
},
|
|
1312
1204
|
[
|
|
1313
1205
|
"ACTIVE_VENDOR_PRO_SUBSCRIPTION"
|
|
1314
|
-
/*
|
|
1206
|
+
/* ACTIVE_VENDOR_PRO_SUBSCRIPTION */
|
|
1315
1207
|
]: {
|
|
1316
1208
|
description: "3 points for active vendor pro subscription (monthly reward)",
|
|
1317
1209
|
value: 3
|
|
1318
1210
|
},
|
|
1319
1211
|
[
|
|
1320
1212
|
"ACTIVE_VENDOR_STANDARD_SUBSCRIPTION"
|
|
1321
|
-
/*
|
|
1213
|
+
/* ACTIVE_VENDOR_STANDARD_SUBSCRIPTION */
|
|
1322
1214
|
]: {
|
|
1323
1215
|
description: "1 point for active vendor standard subscription (monthly reward)",
|
|
1324
1216
|
value: 1
|
|
1325
1217
|
},
|
|
1326
1218
|
[
|
|
1327
1219
|
"ACTIVE_VENDOR_BONUS_REWARD"
|
|
1328
|
-
/*
|
|
1220
|
+
/* ACTIVE_VENDOR_BONUS_REWARD */
|
|
1329
1221
|
]: {
|
|
1330
1222
|
description: "5 bonus points for every 10th active vendor (one-time reward)",
|
|
1331
1223
|
value: 5
|
|
1332
1224
|
},
|
|
1333
1225
|
[
|
|
1334
1226
|
"ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS"
|
|
1335
|
-
/*
|
|
1227
|
+
/* ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS */
|
|
1336
1228
|
]: {
|
|
1337
1229
|
description: "40 points for active event with vendor registrations (one-time reward)",
|
|
1338
1230
|
value: 40
|
|
@@ -1491,7 +1383,7 @@ async function sendPushNotifications({
|
|
|
1491
1383
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
1492
1384
|
function isPayingStripeSubscription(stripe) {
|
|
1493
1385
|
if (!stripe?.subscriptionId) return false;
|
|
1494
|
-
return (stripe.status ===
|
|
1386
|
+
return (stripe.status === EnumSubscriptionStatus.ACTIVE || stripe.status === EnumSubscriptionStatus.TRIALING) && (stripe.currentPlan === EnumUserLicence.PRO_VENDOR || stripe.currentPlan === EnumUserLicence.PRO_PLUS_VENDOR);
|
|
1495
1387
|
}
|
|
1496
1388
|
function mapVendorLicenceToSubscriptionRewardType(licences, now = /* @__PURE__ */ new Date(), stripe) {
|
|
1497
1389
|
const validTypes = new Set(
|
|
@@ -1499,14 +1391,14 @@ function mapVendorLicenceToSubscriptionRewardType(licences, now = /* @__PURE__ *
|
|
|
1499
1391
|
(licence) => new Date(licence.expiryDate).getTime() > now.getTime()
|
|
1500
1392
|
).map((licence) => licence.licenceType)
|
|
1501
1393
|
);
|
|
1502
|
-
if (validTypes.has(
|
|
1394
|
+
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
1503
1395
|
if (isPayingStripeSubscription(stripe)) {
|
|
1504
|
-
return
|
|
1396
|
+
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
1505
1397
|
}
|
|
1506
|
-
return
|
|
1398
|
+
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
1507
1399
|
}
|
|
1508
|
-
if (validTypes.has(
|
|
1509
|
-
return
|
|
1400
|
+
if (validTypes.has(EnumUserLicence.STANDARD_VENDOR)) {
|
|
1401
|
+
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
1510
1402
|
}
|
|
1511
1403
|
return null;
|
|
1512
1404
|
}
|
|
@@ -1522,7 +1414,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
|
|
|
1522
1414
|
|
|
1523
1415
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
1524
1416
|
function isEligibleVendorResource(resource) {
|
|
1525
|
-
return resource.resourceType ===
|
|
1417
|
+
return resource.resourceType === EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
|
|
1526
1418
|
}
|
|
1527
1419
|
async function findAffiliatesWithActiveVendorReferrals() {
|
|
1528
1420
|
return await AffiliateModel.find({
|
|
@@ -1530,7 +1422,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
1530
1422
|
$elemMatch: {
|
|
1531
1423
|
resourceActive: true,
|
|
1532
1424
|
resourceDeletedAt: null,
|
|
1533
|
-
resourceType:
|
|
1425
|
+
resourceType: EnumResourceType.VENDOR
|
|
1534
1426
|
}
|
|
1535
1427
|
},
|
|
1536
1428
|
deletedAt: null
|
|
@@ -1568,11 +1460,11 @@ async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
|
1568
1460
|
data: {
|
|
1569
1461
|
resourceId: String(affiliateId),
|
|
1570
1462
|
resourceName,
|
|
1571
|
-
resourceType:
|
|
1463
|
+
resourceType: EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
|
|
1572
1464
|
},
|
|
1573
1465
|
message: `You earned ${rewardValue} points! Your referred vendor "${resourceName}" has an active subscription.`,
|
|
1574
1466
|
title: "Affiliate points earned",
|
|
1575
|
-
type:
|
|
1467
|
+
type: EnumNotificationType.SYSTEM,
|
|
1576
1468
|
userIds: [affiliateOwnerUserId]
|
|
1577
1469
|
};
|
|
1578
1470
|
try {
|
|
@@ -1601,7 +1493,7 @@ async function tryAwardSubscriptionReward({
|
|
|
1601
1493
|
resourceActive: true,
|
|
1602
1494
|
resourceDeletedAt: null,
|
|
1603
1495
|
resourceId: resource.resourceId,
|
|
1604
|
-
resourceType:
|
|
1496
|
+
resourceType: EnumResourceType.VENDOR,
|
|
1605
1497
|
rewards: {
|
|
1606
1498
|
$not: {
|
|
1607
1499
|
$elemMatch: {
|
|
@@ -1797,25 +1689,25 @@ async function updateAdStatuses() {
|
|
|
1797
1689
|
{ end: { $exists: false } },
|
|
1798
1690
|
{ $expr: { $gt: ["$start", "$end"] } }
|
|
1799
1691
|
],
|
|
1800
|
-
status: { $ne:
|
|
1692
|
+
status: { $ne: EnumAdStatus.PAUSED }
|
|
1801
1693
|
},
|
|
1802
|
-
{ $set: { status:
|
|
1694
|
+
{ $set: { status: EnumAdStatus.PAUSED } }
|
|
1803
1695
|
);
|
|
1804
1696
|
const expiredResult = await AdModel.updateMany(
|
|
1805
|
-
{ end: { $lte: now }, status: { $ne:
|
|
1806
|
-
{ $set: { status:
|
|
1697
|
+
{ end: { $lte: now }, status: { $ne: EnumAdStatus.EXPIRED } },
|
|
1698
|
+
{ $set: { status: EnumAdStatus.EXPIRED } }
|
|
1807
1699
|
);
|
|
1808
1700
|
const activeResult = await AdModel.updateMany(
|
|
1809
1701
|
{
|
|
1810
1702
|
end: { $gt: now },
|
|
1811
1703
|
start: { $lte: now },
|
|
1812
|
-
status: { $ne:
|
|
1704
|
+
status: { $ne: EnumAdStatus.ACTIVE }
|
|
1813
1705
|
},
|
|
1814
|
-
{ $set: { status:
|
|
1706
|
+
{ $set: { status: EnumAdStatus.ACTIVE } }
|
|
1815
1707
|
);
|
|
1816
1708
|
const pausedResult = await AdModel.updateMany(
|
|
1817
|
-
{ start: { $gt: now }, status: { $ne:
|
|
1818
|
-
{ $set: { status:
|
|
1709
|
+
{ start: { $gt: now }, status: { $ne: EnumAdStatus.PAUSED } },
|
|
1710
|
+
{ $set: { status: EnumAdStatus.PAUSED } }
|
|
1819
1711
|
);
|
|
1820
1712
|
console.log(
|
|
1821
1713
|
`\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
|
|
@@ -1836,7 +1728,7 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
|
|
|
1836
1728
|
return;
|
|
1837
1729
|
}
|
|
1838
1730
|
const updateData = {};
|
|
1839
|
-
const isStandardVendor = licenceType ===
|
|
1731
|
+
const isStandardVendor = licenceType === EnumUserLicence.STANDARD_VENDOR;
|
|
1840
1732
|
if (isStandardVendor) {
|
|
1841
1733
|
updateData.availability = {
|
|
1842
1734
|
corporate: false,
|
|
@@ -1899,21 +1791,21 @@ dayjs3.extend(isoWeek);
|
|
|
1899
1791
|
function getFutureEventStatus(startDateTime, now) {
|
|
1900
1792
|
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
1901
1793
|
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
1902
|
-
return
|
|
1794
|
+
return EnumEventDateStatus.STARTING_SOON;
|
|
1903
1795
|
}
|
|
1904
1796
|
if (startDateTime.isSame(now, "day")) {
|
|
1905
|
-
return
|
|
1797
|
+
return EnumEventDateStatus.TODAY;
|
|
1906
1798
|
}
|
|
1907
1799
|
if (startDateTime.isSame(now.add(1, "day"), "day")) {
|
|
1908
|
-
return
|
|
1800
|
+
return EnumEventDateStatus.TOMORROW;
|
|
1909
1801
|
}
|
|
1910
1802
|
if (startDateTime.isSame(now, "isoWeek")) {
|
|
1911
|
-
return
|
|
1803
|
+
return EnumEventDateStatus.THIS_WEEK;
|
|
1912
1804
|
}
|
|
1913
1805
|
if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
|
|
1914
|
-
return
|
|
1806
|
+
return EnumEventDateStatus.NEXT_WEEK;
|
|
1915
1807
|
}
|
|
1916
|
-
return
|
|
1808
|
+
return EnumEventDateStatus.UPCOMING;
|
|
1917
1809
|
}
|
|
1918
1810
|
function updateSingleDateTimeStatus(dateTime, now = dayjs3()) {
|
|
1919
1811
|
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
@@ -1930,13 +1822,13 @@ function updateSingleDateTimeStatus(dateTime, now = dayjs3()) {
|
|
|
1930
1822
|
if (!startDateTime.isValid() || !endDateTime.isValid()) {
|
|
1931
1823
|
return {
|
|
1932
1824
|
...dateTime,
|
|
1933
|
-
dateStatus:
|
|
1825
|
+
dateStatus: EnumEventDateStatus.INVALID
|
|
1934
1826
|
};
|
|
1935
1827
|
}
|
|
1936
1828
|
if (endDateTime.isBefore(startDateTime)) {
|
|
1937
1829
|
return {
|
|
1938
1830
|
...dateTime,
|
|
1939
|
-
dateStatus:
|
|
1831
|
+
dateStatus: EnumEventDateStatus.INVALID
|
|
1940
1832
|
};
|
|
1941
1833
|
}
|
|
1942
1834
|
let dateStatus;
|
|
@@ -1944,10 +1836,10 @@ function updateSingleDateTimeStatus(dateTime, now = dayjs3()) {
|
|
|
1944
1836
|
if (startDateTime.isAfter(now)) {
|
|
1945
1837
|
dateStatus = getFutureEventStatus(startDateTime, now);
|
|
1946
1838
|
} else {
|
|
1947
|
-
dateStatus =
|
|
1839
|
+
dateStatus = EnumEventDateStatus.STARTED;
|
|
1948
1840
|
}
|
|
1949
1841
|
} else {
|
|
1950
|
-
dateStatus =
|
|
1842
|
+
dateStatus = EnumEventDateStatus.ENDED;
|
|
1951
1843
|
}
|
|
1952
1844
|
return {
|
|
1953
1845
|
...dateTime,
|
|
@@ -2048,7 +1940,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
2048
1940
|
) ?? false;
|
|
2049
1941
|
return {
|
|
2050
1942
|
...relationDate,
|
|
2051
|
-
status: existsInEvent ? relationDate.status :
|
|
1943
|
+
status: existsInEvent ? relationDate.status : EnumInviteStatus.UNAVAILABLE
|
|
2052
1944
|
};
|
|
2053
1945
|
});
|
|
2054
1946
|
}
|