@timardex/cluemart-server-shared 2.1.0 → 2.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-CMJdECzs.d.mts → Affiliate-B1mxoMeD.d.mts} +3 -0
- package/dist/{Affiliate-VLZdlt5K.d.ts → Affiliate-Dlf_OLIh.d.ts} +3 -0
- package/dist/{chunk-BEUTBR4H.mjs → chunk-MEEBCSMJ.mjs} +517 -206
- package/dist/chunk-MEEBCSMJ.mjs.map +1 -0
- package/dist/index.cjs +790 -414
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +53 -5
- package/dist/index.d.ts +53 -5
- package/dist/index.mjs +621 -238
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +593 -284
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +47 -4
- package/dist/mongoose/index.d.ts +47 -4
- package/dist/mongoose/index.mjs +15 -1
- package/dist/service/index.cjs +765 -411
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +6 -4
- package/dist/service/index.d.ts +6 -4
- package/dist/service/index.mjs +99 -27
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-BEUTBR4H.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// src/mongoose/Ad.ts
|
|
2
2
|
import {
|
|
3
|
+
EnumAdApprovalStatus,
|
|
4
|
+
EnumAdBookingSlotKind,
|
|
5
|
+
EnumAdPaymentStatus,
|
|
3
6
|
EnumAdShowOn,
|
|
4
7
|
EnumAdStatus,
|
|
5
8
|
EnumAdStyle,
|
|
@@ -37,9 +40,30 @@ var schemaAdresource = new MongooseSchema({
|
|
|
37
40
|
var schema = new MongooseSchema(
|
|
38
41
|
{
|
|
39
42
|
active: { default: true, type: Boolean },
|
|
43
|
+
adminManaged: { default: false, type: Boolean },
|
|
44
|
+
approvalStatus: {
|
|
45
|
+
enum: Object.values(EnumAdApprovalStatus),
|
|
46
|
+
required: false,
|
|
47
|
+
type: String
|
|
48
|
+
},
|
|
49
|
+
bookingIds: {
|
|
50
|
+
default: void 0,
|
|
51
|
+
ref: "AdBooking",
|
|
52
|
+
type: [mongoose.Schema.Types.ObjectId]
|
|
53
|
+
},
|
|
54
|
+
bookingKind: {
|
|
55
|
+
enum: Object.values(EnumAdBookingSlotKind),
|
|
56
|
+
required: false,
|
|
57
|
+
type: String
|
|
58
|
+
},
|
|
40
59
|
clicks: { default: 0, required: true, type: Number },
|
|
41
60
|
end: { required: true, type: Date },
|
|
42
61
|
impressions: { default: 0, required: true, type: Number },
|
|
62
|
+
paymentStatus: {
|
|
63
|
+
enum: Object.values(EnumAdPaymentStatus),
|
|
64
|
+
required: false,
|
|
65
|
+
type: String
|
|
66
|
+
},
|
|
43
67
|
resource: { required: true, type: schemaAdresource },
|
|
44
68
|
showOn: {
|
|
45
69
|
default: [EnumAdShowOn.FRONT_PAGE],
|
|
@@ -71,8 +95,276 @@ schema.index({
|
|
|
71
95
|
// eslint-disable-next-line sort-keys
|
|
72
96
|
start: -1
|
|
73
97
|
});
|
|
98
|
+
schema.index(
|
|
99
|
+
{ bookingIds: 1 },
|
|
100
|
+
{
|
|
101
|
+
partialFilterExpression: { bookingIds: { $exists: true } },
|
|
102
|
+
unique: true
|
|
103
|
+
}
|
|
104
|
+
);
|
|
74
105
|
var AdModel = mongoose.models.Ad || mongoose.model("Ad", schema);
|
|
75
106
|
|
|
107
|
+
// src/mongoose/AdBillingCatalog.ts
|
|
108
|
+
import mongoose2 from "mongoose";
|
|
109
|
+
var AD_BILLING_CATALOG_COLLECTION_NAME = "adBillingCatalog";
|
|
110
|
+
var schema2 = new mongoose2.Schema(
|
|
111
|
+
{
|
|
112
|
+
active: { default: true, required: true, type: Boolean },
|
|
113
|
+
currency: {
|
|
114
|
+
default: "nzd",
|
|
115
|
+
enum: ["nzd"],
|
|
116
|
+
immutable: true,
|
|
117
|
+
required: true,
|
|
118
|
+
type: String
|
|
119
|
+
},
|
|
120
|
+
key: {
|
|
121
|
+
enum: ["front_page_day", "market_search_day"],
|
|
122
|
+
immutable: true,
|
|
123
|
+
required: true,
|
|
124
|
+
type: String,
|
|
125
|
+
unique: true
|
|
126
|
+
},
|
|
127
|
+
revision: { default: 1, min: 1, required: true, type: Number },
|
|
128
|
+
unitAmount: {
|
|
129
|
+
min: 1,
|
|
130
|
+
required: true,
|
|
131
|
+
type: Number,
|
|
132
|
+
validate: {
|
|
133
|
+
message: "Daily ad price must be a positive integer amount of cents.",
|
|
134
|
+
validator: Number.isInteger
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{ collection: AD_BILLING_CATALOG_COLLECTION_NAME, timestamps: true }
|
|
139
|
+
);
|
|
140
|
+
var AdBillingCatalogModel = mongoose2.models.AdBillingCatalog || mongoose2.model(
|
|
141
|
+
"AdBillingCatalog",
|
|
142
|
+
schema2,
|
|
143
|
+
AD_BILLING_CATALOG_COLLECTION_NAME
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// src/mongoose/AdBooking.ts
|
|
147
|
+
import {
|
|
148
|
+
EnumAdApprovalStatus as EnumAdApprovalStatus2,
|
|
149
|
+
EnumAdBookingSlotKind as EnumAdBookingSlotKind2,
|
|
150
|
+
EnumAdBookingState,
|
|
151
|
+
EnumAdEntitlementSource,
|
|
152
|
+
EnumAdShowOn as EnumAdShowOn2
|
|
153
|
+
} from "@timardex/cluemart-shared";
|
|
154
|
+
import mongoose3 from "mongoose";
|
|
155
|
+
var liveStates = [
|
|
156
|
+
EnumAdBookingState.HELD,
|
|
157
|
+
EnumAdBookingState.PENDING_APPROVAL,
|
|
158
|
+
EnumAdBookingState.APPROVED
|
|
159
|
+
];
|
|
160
|
+
var placementValues = [EnumAdShowOn2.FRONT_PAGE, EnumAdShowOn2.MARKET_SEARCH];
|
|
161
|
+
var schema3 = new mongoose3.Schema(
|
|
162
|
+
{
|
|
163
|
+
adId: { default: null, ref: "Ad", type: String },
|
|
164
|
+
approvalStatus: {
|
|
165
|
+
default: EnumAdApprovalStatus2.PENDING,
|
|
166
|
+
enum: Object.values(EnumAdApprovalStatus2),
|
|
167
|
+
required: true,
|
|
168
|
+
type: String
|
|
169
|
+
},
|
|
170
|
+
checkoutAttemptId: { default: null, type: String },
|
|
171
|
+
currency: { default: null, lowercase: true, type: String },
|
|
172
|
+
dayKey: {
|
|
173
|
+
immutable: true,
|
|
174
|
+
match: /^\d{4}-\d{2}-\d{2}$/,
|
|
175
|
+
required: true,
|
|
176
|
+
type: String
|
|
177
|
+
},
|
|
178
|
+
entitlementClaimKey: { default: null, type: String },
|
|
179
|
+
entitlementSource: {
|
|
180
|
+
default: null,
|
|
181
|
+
enum: Object.values(EnumAdEntitlementSource),
|
|
182
|
+
type: String
|
|
183
|
+
},
|
|
184
|
+
expiresAt: { default: null, type: Date },
|
|
185
|
+
placement: {
|
|
186
|
+
enum: placementValues,
|
|
187
|
+
immutable: true,
|
|
188
|
+
required: true,
|
|
189
|
+
type: String
|
|
190
|
+
},
|
|
191
|
+
purchaseKey: { default: null, immutable: true, type: String },
|
|
192
|
+
region: {
|
|
193
|
+
immutable: true,
|
|
194
|
+
lowercase: true,
|
|
195
|
+
required: true,
|
|
196
|
+
trim: true,
|
|
197
|
+
type: String
|
|
198
|
+
},
|
|
199
|
+
resource: { required: true, type: schemaAdresource },
|
|
200
|
+
slotKind: {
|
|
201
|
+
enum: Object.values(EnumAdBookingSlotKind2),
|
|
202
|
+
immutable: true,
|
|
203
|
+
required: true,
|
|
204
|
+
type: String
|
|
205
|
+
},
|
|
206
|
+
slotNumber: { immutable: true, min: 1, required: true, type: Number },
|
|
207
|
+
state: {
|
|
208
|
+
default: EnumAdBookingState.HELD,
|
|
209
|
+
enum: Object.values(EnumAdBookingState),
|
|
210
|
+
required: true,
|
|
211
|
+
type: String
|
|
212
|
+
},
|
|
213
|
+
stripeCheckoutSessionId: { default: null, type: String },
|
|
214
|
+
stripePaymentIntentId: { default: null, type: String },
|
|
215
|
+
unitAmount: { default: null, min: 1, type: Number },
|
|
216
|
+
userId: { immutable: true, ref: "User", required: true, type: String }
|
|
217
|
+
},
|
|
218
|
+
{ timestamps: true }
|
|
219
|
+
);
|
|
220
|
+
schema3.pre(
|
|
221
|
+
"validate",
|
|
222
|
+
function validateSlot() {
|
|
223
|
+
if (!Number.isInteger(this.slotNumber)) {
|
|
224
|
+
this.invalidate("slotNumber", "Ad booking slot must be an integer.");
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const maximum = this.slotKind === EnumAdBookingSlotKind2.PAID ? 30 : 7;
|
|
228
|
+
if (this.slotNumber < 1 || this.slotNumber > maximum) {
|
|
229
|
+
this.invalidate(
|
|
230
|
+
"slotNumber",
|
|
231
|
+
`Ad booking slot must be between 1 and ${maximum}.`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
if (this.slotKind === EnumAdBookingSlotKind2.PAID && this.state !== EnumAdBookingState.HELD && this.state !== EnumAdBookingState.FAILED && this.state !== EnumAdBookingState.CANCELLED && (!this.unitAmount || !this.currency)) {
|
|
235
|
+
this.invalidate(
|
|
236
|
+
"unitAmount",
|
|
237
|
+
"Paid ad booking must retain its checkout price."
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
schema3.index(
|
|
243
|
+
{ region: 1, placement: 1, dayKey: 1, slotKind: 1, slotNumber: 1 },
|
|
244
|
+
{ unique: true, partialFilterExpression: { state: { $in: liveStates } } }
|
|
245
|
+
);
|
|
246
|
+
schema3.index({ userId: 1, dayKey: -1 });
|
|
247
|
+
schema3.index(
|
|
248
|
+
{ checkoutAttemptId: 1 },
|
|
249
|
+
{
|
|
250
|
+
partialFilterExpression: { checkoutAttemptId: { $type: "string" } },
|
|
251
|
+
unique: true
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
schema3.index(
|
|
255
|
+
{ purchaseKey: 1 },
|
|
256
|
+
{
|
|
257
|
+
partialFilterExpression: {
|
|
258
|
+
purchaseKey: { $type: "string" },
|
|
259
|
+
state: { $in: liveStates }
|
|
260
|
+
},
|
|
261
|
+
unique: true
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
schema3.index(
|
|
265
|
+
{ entitlementClaimKey: 1 },
|
|
266
|
+
{
|
|
267
|
+
partialFilterExpression: {
|
|
268
|
+
entitlementClaimKey: { $type: "string" },
|
|
269
|
+
state: { $in: liveStates }
|
|
270
|
+
},
|
|
271
|
+
unique: true
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
schema3.index(
|
|
275
|
+
{ adId: 1, region: 1, placement: 1, dayKey: 1 },
|
|
276
|
+
{
|
|
277
|
+
partialFilterExpression: {
|
|
278
|
+
entitlementSource: EnumAdEntitlementSource.ADMIN,
|
|
279
|
+
state: { $in: liveStates }
|
|
280
|
+
},
|
|
281
|
+
unique: true
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
schema3.index(
|
|
285
|
+
{ stripeCheckoutSessionId: 1 },
|
|
286
|
+
{
|
|
287
|
+
partialFilterExpression: { stripeCheckoutSessionId: { $type: "string" } },
|
|
288
|
+
unique: true
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
var AdBookingModel = mongoose3.models.AdBooking || mongoose3.model("AdBooking", schema3);
|
|
292
|
+
|
|
293
|
+
// src/mongoose/AdImpression.ts
|
|
294
|
+
import { EnumAdShowOn as EnumAdShowOn3 } from "@timardex/cluemart-shared";
|
|
295
|
+
import mongoose4 from "mongoose";
|
|
296
|
+
var schema4 = new mongoose4.Schema(
|
|
297
|
+
{
|
|
298
|
+
_id: { required: true, type: String },
|
|
299
|
+
adId: { required: true, type: String },
|
|
300
|
+
dayKey: { match: /^\d{4}-\d{2}-\d{2}$/, required: true, type: String },
|
|
301
|
+
placement: {
|
|
302
|
+
enum: [EnumAdShowOn3.FRONT_PAGE, EnumAdShowOn3.MARKET_SEARCH],
|
|
303
|
+
required: true,
|
|
304
|
+
type: String
|
|
305
|
+
},
|
|
306
|
+
recordedAt: { default: Date.now, required: true, type: Date },
|
|
307
|
+
viewerSlotKey: { required: true, type: String }
|
|
308
|
+
},
|
|
309
|
+
{ collection: "adImpressions" }
|
|
310
|
+
);
|
|
311
|
+
schema4.index({ adId: 1, recordedAt: 1 });
|
|
312
|
+
schema4.index({ adId: 1, placement: 1, viewerSlotKey: 1 }, { unique: true });
|
|
313
|
+
schema4.index({ recordedAt: 1 }, { expireAfterSeconds: 7 * 24 * 60 * 60 });
|
|
314
|
+
schema4.index({ dayKey: 1, placement: 1, adId: 1 });
|
|
315
|
+
var AdImpressionModel = mongoose4.models.AdImpression || mongoose4.model("AdImpression", schema4, "adImpressions");
|
|
316
|
+
|
|
317
|
+
// src/mongoose/AdSettings.ts
|
|
318
|
+
import mongoose5 from "mongoose";
|
|
319
|
+
var DEFAULT_AD_SETTINGS = {
|
|
320
|
+
_id: "default",
|
|
321
|
+
approvalRequired: true,
|
|
322
|
+
minAppearancesPerHour: 12,
|
|
323
|
+
paidSlotsPerPlacement: 30,
|
|
324
|
+
reservedSlotsPerPlacement: 7,
|
|
325
|
+
rotationSeconds: 8
|
|
326
|
+
};
|
|
327
|
+
var schema5 = new mongoose5.Schema(
|
|
328
|
+
{
|
|
329
|
+
_id: { default: "default", enum: ["default"], type: String },
|
|
330
|
+
approvalRequired: { default: true, required: true, type: Boolean },
|
|
331
|
+
minAppearancesPerHour: {
|
|
332
|
+
default: 12,
|
|
333
|
+
min: 1,
|
|
334
|
+
required: true,
|
|
335
|
+
type: Number,
|
|
336
|
+
validate: {
|
|
337
|
+
message: "Minimum appearances per hour must be a whole number.",
|
|
338
|
+
validator: Number.isInteger
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
paidSlotsPerPlacement: {
|
|
342
|
+
default: 30,
|
|
343
|
+
enum: [30],
|
|
344
|
+
immutable: true,
|
|
345
|
+
type: Number
|
|
346
|
+
},
|
|
347
|
+
reservedSlotsPerPlacement: {
|
|
348
|
+
default: 7,
|
|
349
|
+
enum: [7],
|
|
350
|
+
immutable: true,
|
|
351
|
+
type: Number
|
|
352
|
+
},
|
|
353
|
+
rotationSeconds: { default: 8, enum: [8], immutable: true, type: Number }
|
|
354
|
+
},
|
|
355
|
+
{ collection: "adSettings", timestamps: true }
|
|
356
|
+
);
|
|
357
|
+
schema5.pre("validate", function validateRotationCapacity() {
|
|
358
|
+
const availableRotationsPerHour = 3600 / this.rotationSeconds;
|
|
359
|
+
if (this.minAppearancesPerHour * (this.paidSlotsPerPlacement + this.reservedSlotsPerPlacement) > availableRotationsPerHour) {
|
|
360
|
+
this.invalidate(
|
|
361
|
+
"minAppearancesPerHour",
|
|
362
|
+
"The configured minimum exceeds the available rotation slots."
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
var AdSettingsModel = mongoose5.models.AdSettings || mongoose5.model("AdSettings", schema5, "adSettings");
|
|
367
|
+
|
|
76
368
|
// src/mongoose/BillingCatalog.ts
|
|
77
369
|
import {
|
|
78
370
|
BILLING_CATALOG_CURRENCY,
|
|
@@ -83,8 +375,8 @@ import {
|
|
|
83
375
|
EnumUserLicence,
|
|
84
376
|
INITIAL_BILLING_CATALOG
|
|
85
377
|
} from "@timardex/cluemart-shared";
|
|
86
|
-
import
|
|
87
|
-
var MongooseSchema2 =
|
|
378
|
+
import mongoose6 from "mongoose";
|
|
379
|
+
var MongooseSchema2 = mongoose6.Schema;
|
|
88
380
|
var BILLING_CATALOG_COLLECTION_NAME = "billingCatalog";
|
|
89
381
|
var paidVendorLicences = [
|
|
90
382
|
EnumUserLicence.PRO_VENDOR,
|
|
@@ -131,7 +423,7 @@ var priceHistorySchema = new MongooseSchema2(
|
|
|
131
423
|
default: null,
|
|
132
424
|
ref: "User",
|
|
133
425
|
required: false,
|
|
134
|
-
type:
|
|
426
|
+
type: mongoose6.Schema.Types.ObjectId
|
|
135
427
|
},
|
|
136
428
|
currency: currencyField,
|
|
137
429
|
effectiveFrom: { required: true, type: Date },
|
|
@@ -142,7 +434,7 @@ var priceHistorySchema = new MongooseSchema2(
|
|
|
142
434
|
},
|
|
143
435
|
{ _id: false }
|
|
144
436
|
);
|
|
145
|
-
var
|
|
437
|
+
var schema6 = new MongooseSchema2(
|
|
146
438
|
{
|
|
147
439
|
active: { default: true, required: true, type: Boolean },
|
|
148
440
|
billingPeriod: {
|
|
@@ -198,7 +490,7 @@ var schema2 = new MongooseSchema2(
|
|
|
198
490
|
default: null,
|
|
199
491
|
ref: "User",
|
|
200
492
|
required: false,
|
|
201
|
-
type:
|
|
493
|
+
type: mongoose6.Schema.Types.ObjectId
|
|
202
494
|
}
|
|
203
495
|
},
|
|
204
496
|
{
|
|
@@ -207,7 +499,7 @@ var schema2 = new MongooseSchema2(
|
|
|
207
499
|
timestamps: true
|
|
208
500
|
}
|
|
209
501
|
);
|
|
210
|
-
|
|
502
|
+
schema6.pre("validate", function validateDefinition() {
|
|
211
503
|
if (!billingCatalogDefinitionMatches(this)) {
|
|
212
504
|
this.invalidate(
|
|
213
505
|
"key",
|
|
@@ -215,18 +507,18 @@ schema2.pre("validate", function validateDefinition() {
|
|
|
215
507
|
);
|
|
216
508
|
}
|
|
217
509
|
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
510
|
+
schema6.index({ billingPeriod: 1, licenceType: 1 }, { unique: true });
|
|
511
|
+
schema6.index({ active: 1, licenceType: 1 });
|
|
512
|
+
schema6.index(
|
|
221
513
|
{ stripePriceId: 1 },
|
|
222
514
|
{
|
|
223
515
|
partialFilterExpression: { stripePriceId: { $type: "string" } },
|
|
224
516
|
unique: true
|
|
225
517
|
}
|
|
226
518
|
);
|
|
227
|
-
var BillingCatalogModel =
|
|
519
|
+
var BillingCatalogModel = mongoose6.models.BillingCatalogEntry || mongoose6.model(
|
|
228
520
|
"BillingCatalogEntry",
|
|
229
|
-
|
|
521
|
+
schema6,
|
|
230
522
|
BILLING_CATALOG_COLLECTION_NAME
|
|
231
523
|
);
|
|
232
524
|
function buildInitialBillingCatalogEntries(now = /* @__PURE__ */ new Date()) {
|
|
@@ -254,15 +546,15 @@ function getBillingCatalogDefinition(key) {
|
|
|
254
546
|
import {
|
|
255
547
|
EnumChatType
|
|
256
548
|
} from "@timardex/cluemart-shared";
|
|
257
|
-
import
|
|
258
|
-
var MongooseSchema3 =
|
|
549
|
+
import mongoose7 from "mongoose";
|
|
550
|
+
var MongooseSchema3 = mongoose7.Schema;
|
|
259
551
|
var MessageReplyPreviewSchema = new MongooseSchema3(
|
|
260
552
|
{
|
|
261
553
|
contentPreview: { required: true, type: String },
|
|
262
554
|
senderId: {
|
|
263
555
|
ref: "User",
|
|
264
556
|
required: true,
|
|
265
|
-
type:
|
|
557
|
+
type: mongoose7.Schema.Types.ObjectId
|
|
266
558
|
},
|
|
267
559
|
senderName: { required: true, type: String }
|
|
268
560
|
},
|
|
@@ -274,7 +566,7 @@ var MessageReactionSchema = new MongooseSchema3(
|
|
|
274
566
|
userId: {
|
|
275
567
|
ref: "User",
|
|
276
568
|
required: true,
|
|
277
|
-
type:
|
|
569
|
+
type: mongoose7.Schema.Types.ObjectId
|
|
278
570
|
}
|
|
279
571
|
},
|
|
280
572
|
{ _id: false }
|
|
@@ -285,7 +577,7 @@ var MessageSeenSchema = new MongooseSchema3(
|
|
|
285
577
|
userId: {
|
|
286
578
|
ref: "User",
|
|
287
579
|
required: true,
|
|
288
|
-
type:
|
|
580
|
+
type: mongoose7.Schema.Types.ObjectId
|
|
289
581
|
}
|
|
290
582
|
},
|
|
291
583
|
{ _id: false }
|
|
@@ -301,13 +593,13 @@ var MessageSchema = new MongooseSchema3(
|
|
|
301
593
|
replyToMessageId: {
|
|
302
594
|
ref: "Chat.messages",
|
|
303
595
|
required: false,
|
|
304
|
-
type:
|
|
596
|
+
type: mongoose7.Schema.Types.ObjectId
|
|
305
597
|
},
|
|
306
598
|
seenBy: { default: [], required: false, type: [MessageSeenSchema] },
|
|
307
599
|
senderId: {
|
|
308
600
|
ref: "User",
|
|
309
601
|
required: true,
|
|
310
|
-
type:
|
|
602
|
+
type: mongoose7.Schema.Types.ObjectId
|
|
311
603
|
}
|
|
312
604
|
},
|
|
313
605
|
{ timestamps: true }
|
|
@@ -320,7 +612,7 @@ var ParticipantSchema = new MongooseSchema3(
|
|
|
320
612
|
userId: {
|
|
321
613
|
ref: "User",
|
|
322
614
|
required: true,
|
|
323
|
-
type:
|
|
615
|
+
type: mongoose7.Schema.Types.ObjectId
|
|
324
616
|
},
|
|
325
617
|
userName: { required: true, type: String }
|
|
326
618
|
},
|
|
@@ -351,14 +643,14 @@ ChatSchema.index({
|
|
|
351
643
|
"participants.userId": 1,
|
|
352
644
|
updatedAt: -1
|
|
353
645
|
});
|
|
354
|
-
var ChatModel =
|
|
646
|
+
var ChatModel = mongoose7.models.Chat || mongoose7.model("Chat", ChatSchema);
|
|
355
647
|
|
|
356
648
|
// src/mongoose/chat/ChatReport.ts
|
|
357
649
|
import {
|
|
358
650
|
EnumChatReportReason
|
|
359
651
|
} from "@timardex/cluemart-shared";
|
|
360
|
-
import
|
|
361
|
-
var MongooseSchema4 =
|
|
652
|
+
import mongoose8 from "mongoose";
|
|
653
|
+
var MongooseSchema4 = mongoose8.Schema;
|
|
362
654
|
var ReasonSchema = new MongooseSchema4(
|
|
363
655
|
{
|
|
364
656
|
details: { default: null, required: false, type: String },
|
|
@@ -375,18 +667,18 @@ var ChatReportSchema = new MongooseSchema4(
|
|
|
375
667
|
chatId: {
|
|
376
668
|
ref: "Chat",
|
|
377
669
|
required: true,
|
|
378
|
-
type:
|
|
670
|
+
type: mongoose8.Schema.Types.ObjectId
|
|
379
671
|
},
|
|
380
672
|
reason: { required: true, type: ReasonSchema },
|
|
381
673
|
reportedUserId: {
|
|
382
674
|
ref: "User",
|
|
383
675
|
required: true,
|
|
384
|
-
type:
|
|
676
|
+
type: mongoose8.Schema.Types.ObjectId
|
|
385
677
|
},
|
|
386
678
|
reporterUserId: {
|
|
387
679
|
ref: "User",
|
|
388
680
|
required: true,
|
|
389
|
-
type:
|
|
681
|
+
type: mongoose8.Schema.Types.ObjectId
|
|
390
682
|
},
|
|
391
683
|
resolved: { default: false, required: true, type: Boolean }
|
|
392
684
|
},
|
|
@@ -394,7 +686,7 @@ var ChatReportSchema = new MongooseSchema4(
|
|
|
394
686
|
);
|
|
395
687
|
ChatReportSchema.index({ chatId: 1, reportedUserId: 1 });
|
|
396
688
|
ChatReportSchema.index({ createdAt: -1, reporterUserId: 1 });
|
|
397
|
-
var ChatReportModel =
|
|
689
|
+
var ChatReportModel = mongoose8.models.ChatReport || mongoose8.model("ChatReport", ChatReportSchema);
|
|
398
690
|
|
|
399
691
|
// src/mongoose/global.ts
|
|
400
692
|
import {
|
|
@@ -402,7 +694,7 @@ import {
|
|
|
402
694
|
EnumPostType,
|
|
403
695
|
EnumUserLicence as EnumUserLicence2
|
|
404
696
|
} from "@timardex/cluemart-shared";
|
|
405
|
-
import
|
|
697
|
+
import mongoose11 from "mongoose";
|
|
406
698
|
|
|
407
699
|
// src/mongoose/Relation.ts
|
|
408
700
|
import {
|
|
@@ -411,15 +703,15 @@ import {
|
|
|
411
703
|
EnumRelationResource,
|
|
412
704
|
EnumResourceType as EnumResourceType2
|
|
413
705
|
} from "@timardex/cluemart-shared";
|
|
414
|
-
import
|
|
706
|
+
import mongoose10 from "mongoose";
|
|
415
707
|
|
|
416
708
|
// src/mongoose/event/EventInfo.ts
|
|
417
709
|
import {
|
|
418
710
|
EnumEventDateStatus,
|
|
419
711
|
EnumPaymentMethod
|
|
420
712
|
} from "@timardex/cluemart-shared";
|
|
421
|
-
import
|
|
422
|
-
var MongooseSchema5 =
|
|
713
|
+
import mongoose9 from "mongoose";
|
|
714
|
+
var MongooseSchema5 = mongoose9.Schema;
|
|
423
715
|
var StallTypeSchema = new MongooseSchema5(
|
|
424
716
|
{
|
|
425
717
|
label: { required: false, type: String },
|
|
@@ -480,7 +772,7 @@ var refundPolicySchema = new MongooseSchema5(
|
|
|
480
772
|
},
|
|
481
773
|
{ _id: false }
|
|
482
774
|
);
|
|
483
|
-
var
|
|
775
|
+
var schema7 = new MongooseSchema5(
|
|
484
776
|
{
|
|
485
777
|
active: { default: true, type: Boolean },
|
|
486
778
|
applicationDeadlineHours: { required: true, type: Number },
|
|
@@ -488,7 +780,7 @@ var schema3 = new MongooseSchema5(
|
|
|
488
780
|
eventId: {
|
|
489
781
|
ref: "Event",
|
|
490
782
|
required: true,
|
|
491
|
-
type:
|
|
783
|
+
type: mongoose9.Schema.Types.ObjectId
|
|
492
784
|
},
|
|
493
785
|
packInTime: { required: true, type: Number },
|
|
494
786
|
paymentDueHours: { required: true, type: Number },
|
|
@@ -498,11 +790,11 @@ var schema3 = new MongooseSchema5(
|
|
|
498
790
|
},
|
|
499
791
|
{ timestamps: true }
|
|
500
792
|
);
|
|
501
|
-
|
|
502
|
-
var EventInfoModel =
|
|
793
|
+
schema7.index({ eventId: 1 });
|
|
794
|
+
var EventInfoModel = mongoose9.models.EventInfo || mongoose9.model("EventInfo", schema7);
|
|
503
795
|
|
|
504
796
|
// src/mongoose/Relation.ts
|
|
505
|
-
var MongooseSchema6 =
|
|
797
|
+
var MongooseSchema6 = mongoose10.Schema;
|
|
506
798
|
var relationDateTimeSchema = new MongooseSchema6(
|
|
507
799
|
{
|
|
508
800
|
dateStatus: {
|
|
@@ -543,13 +835,13 @@ var RelationTypeSchema = new MongooseSchema6(
|
|
|
543
835
|
chatId: {
|
|
544
836
|
ref: "Chat",
|
|
545
837
|
required: true,
|
|
546
|
-
type:
|
|
838
|
+
type: mongoose10.Schema.Types.ObjectId
|
|
547
839
|
},
|
|
548
840
|
deletedAt: { default: null, required: false, type: Date },
|
|
549
841
|
eventId: {
|
|
550
842
|
ref: "Event",
|
|
551
843
|
required: true,
|
|
552
|
-
type:
|
|
844
|
+
type: mongoose10.Schema.Types.ObjectId
|
|
553
845
|
},
|
|
554
846
|
lastUpdateBy: {
|
|
555
847
|
enum: Object.values(EnumResourceType2),
|
|
@@ -565,7 +857,7 @@ var RelationTypeSchema = new MongooseSchema6(
|
|
|
565
857
|
vendorId: {
|
|
566
858
|
ref: "Vendor",
|
|
567
859
|
required: true,
|
|
568
|
-
type:
|
|
860
|
+
type: mongoose10.Schema.Types.ObjectId
|
|
569
861
|
}
|
|
570
862
|
},
|
|
571
863
|
{ timestamps: true }
|
|
@@ -577,17 +869,17 @@ RelationTypeSchema.index({
|
|
|
577
869
|
"relationDates.status": 1,
|
|
578
870
|
vendorId: 1
|
|
579
871
|
});
|
|
580
|
-
var RelationModel =
|
|
872
|
+
var RelationModel = mongoose10.models.Relation || mongoose10.model("Relation", RelationTypeSchema);
|
|
581
873
|
|
|
582
874
|
// src/mongoose/global.ts
|
|
583
|
-
var MongooseSchema7 =
|
|
875
|
+
var MongooseSchema7 = mongoose11.Schema;
|
|
584
876
|
var OwnerTypeSchema = new MongooseSchema7(
|
|
585
877
|
{
|
|
586
878
|
email: { required: true, type: String },
|
|
587
879
|
userId: {
|
|
588
880
|
ref: "User",
|
|
589
881
|
required: true,
|
|
590
|
-
type:
|
|
882
|
+
type: mongoose11.Schema.Types.ObjectId
|
|
591
883
|
}
|
|
592
884
|
},
|
|
593
885
|
{ _id: false }
|
|
@@ -694,7 +986,7 @@ var resourceRelationsSchema = new MongooseSchema7(
|
|
|
694
986
|
relationId: {
|
|
695
987
|
ref: "Relation",
|
|
696
988
|
required: false,
|
|
697
|
-
type:
|
|
989
|
+
type: mongoose11.Schema.Types.ObjectId
|
|
698
990
|
}
|
|
699
991
|
},
|
|
700
992
|
{ _id: false }
|
|
@@ -745,7 +1037,7 @@ var relatedPostSchema = new MongooseSchema7(
|
|
|
745
1037
|
postId: {
|
|
746
1038
|
ref: "Post",
|
|
747
1039
|
required: true,
|
|
748
|
-
type:
|
|
1040
|
+
type: mongoose11.Schema.Types.ObjectId
|
|
749
1041
|
},
|
|
750
1042
|
postSlug: { required: true, type: String },
|
|
751
1043
|
postType: {
|
|
@@ -770,7 +1062,7 @@ var baseResourceFields = {
|
|
|
770
1062
|
adIds: {
|
|
771
1063
|
ref: "Ad",
|
|
772
1064
|
required: false,
|
|
773
|
-
type: [
|
|
1065
|
+
type: [mongoose11.Schema.Types.ObjectId]
|
|
774
1066
|
},
|
|
775
1067
|
approvedAt: { default: null, required: false, type: Date },
|
|
776
1068
|
contactDetails: { required: false, type: ContactDetailsSchema },
|
|
@@ -803,7 +1095,7 @@ var baseResourceFields = {
|
|
|
803
1095
|
import {
|
|
804
1096
|
EnumEventType
|
|
805
1097
|
} from "@timardex/cluemart-shared";
|
|
806
|
-
import
|
|
1098
|
+
import mongoose12 from "mongoose";
|
|
807
1099
|
|
|
808
1100
|
// src/mongoose/searchNamePlugin.ts
|
|
809
1101
|
function deriveSearchName(name) {
|
|
@@ -849,15 +1141,15 @@ function syncSearchNameInUpdate(update) {
|
|
|
849
1141
|
}
|
|
850
1142
|
return null;
|
|
851
1143
|
}
|
|
852
|
-
function searchNamePlugin(
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
1144
|
+
function searchNamePlugin(schema24) {
|
|
1145
|
+
schema24.add({ searchName: { default: "", required: false, type: String } });
|
|
1146
|
+
schema24.index({ searchName: 1 });
|
|
1147
|
+
schema24.pre("save", function syncSearchNameOnSave(next) {
|
|
856
1148
|
const doc = this;
|
|
857
1149
|
doc.searchName = deriveSearchName(doc.name);
|
|
858
1150
|
next();
|
|
859
1151
|
});
|
|
860
|
-
|
|
1152
|
+
schema24.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
|
|
861
1153
|
const list = Array.isArray(docs) ? docs : [docs];
|
|
862
1154
|
for (const doc of list) {
|
|
863
1155
|
if (doc && typeof doc.name === "string") {
|
|
@@ -866,7 +1158,7 @@ function searchNamePlugin(schema20) {
|
|
|
866
1158
|
}
|
|
867
1159
|
next();
|
|
868
1160
|
});
|
|
869
|
-
|
|
1161
|
+
schema24.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
|
|
870
1162
|
for (const op of ops) {
|
|
871
1163
|
const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
|
|
872
1164
|
if (doc && typeof doc.name === "string") {
|
|
@@ -892,14 +1184,14 @@ function searchNamePlugin(schema20) {
|
|
|
892
1184
|
}
|
|
893
1185
|
next();
|
|
894
1186
|
};
|
|
895
|
-
|
|
1187
|
+
schema24.pre(
|
|
896
1188
|
["findOneAndUpdate", "updateOne", "updateMany"],
|
|
897
1189
|
syncSearchNameOnUpdate
|
|
898
1190
|
);
|
|
899
1191
|
}
|
|
900
1192
|
|
|
901
1193
|
// src/mongoose/GoogleImportedMarket.ts
|
|
902
|
-
var MongooseSchema8 =
|
|
1194
|
+
var MongooseSchema8 = mongoose12.Schema;
|
|
903
1195
|
var addressComponentSchema = new MongooseSchema8(
|
|
904
1196
|
{
|
|
905
1197
|
longName: { required: false, type: String },
|
|
@@ -908,7 +1200,7 @@ var addressComponentSchema = new MongooseSchema8(
|
|
|
908
1200
|
},
|
|
909
1201
|
{ _id: false }
|
|
910
1202
|
);
|
|
911
|
-
var
|
|
1203
|
+
var schema8 = new MongooseSchema8(
|
|
912
1204
|
{
|
|
913
1205
|
active: { default: false, required: true, type: Boolean },
|
|
914
1206
|
address: { required: true, type: String },
|
|
@@ -920,7 +1212,7 @@ var schema4 = new MongooseSchema8(
|
|
|
920
1212
|
claimedByUserId: {
|
|
921
1213
|
ref: "User",
|
|
922
1214
|
required: false,
|
|
923
|
-
type:
|
|
1215
|
+
type: mongoose12.Schema.Types.ObjectId
|
|
924
1216
|
},
|
|
925
1217
|
cover: {
|
|
926
1218
|
required: false,
|
|
@@ -932,7 +1224,7 @@ var schema4 = new MongooseSchema8(
|
|
|
932
1224
|
eventId: {
|
|
933
1225
|
ref: "Event",
|
|
934
1226
|
required: false,
|
|
935
|
-
type:
|
|
1227
|
+
type: mongoose12.Schema.Types.ObjectId
|
|
936
1228
|
},
|
|
937
1229
|
eventType: {
|
|
938
1230
|
enum: Object.values(EnumEventType),
|
|
@@ -971,24 +1263,24 @@ var schema4 = new MongooseSchema8(
|
|
|
971
1263
|
},
|
|
972
1264
|
{ timestamps: true }
|
|
973
1265
|
);
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
var GoogleImportedMarketModel =
|
|
1266
|
+
schema8.index({ "location.geo": "2dsphere" });
|
|
1267
|
+
schema8.index({ name: 1 });
|
|
1268
|
+
schema8.index({ region: 1 });
|
|
1269
|
+
schema8.index({ deletedAt: 1 });
|
|
1270
|
+
schema8.index({ "dateTime.dateStatus": 1 });
|
|
1271
|
+
schema8.index({ slug: 1 });
|
|
1272
|
+
schema8.index({ name: "text", description: "text" });
|
|
1273
|
+
schema8.plugin(searchNamePlugin);
|
|
1274
|
+
var GoogleImportedMarketModel = mongoose12.models.GoogleImportedMarket || mongoose12.model("GoogleImportedMarket", schema8);
|
|
983
1275
|
|
|
984
1276
|
// src/mongoose/Notification.ts
|
|
985
1277
|
import {
|
|
986
1278
|
EnumNotificationResourceType,
|
|
987
1279
|
EnumNotificationType
|
|
988
1280
|
} from "@timardex/cluemart-shared";
|
|
989
|
-
import
|
|
990
|
-
var MongooseSchema9 =
|
|
991
|
-
var
|
|
1281
|
+
import mongoose13 from "mongoose";
|
|
1282
|
+
var MongooseSchema9 = mongoose13.Schema;
|
|
1283
|
+
var schema9 = new MongooseSchema9(
|
|
992
1284
|
{
|
|
993
1285
|
data: {
|
|
994
1286
|
resourceId: { required: true, type: String },
|
|
@@ -1011,20 +1303,20 @@ var schema5 = new MongooseSchema9(
|
|
|
1011
1303
|
userId: {
|
|
1012
1304
|
ref: "User",
|
|
1013
1305
|
required: true,
|
|
1014
|
-
type:
|
|
1306
|
+
type: mongoose13.Schema.Types.ObjectId
|
|
1015
1307
|
}
|
|
1016
1308
|
},
|
|
1017
1309
|
{ timestamps: true }
|
|
1018
1310
|
);
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
var NotificationModel =
|
|
1311
|
+
schema9.index({ isRead: 1, userId: 1 });
|
|
1312
|
+
schema9.index({ createdAt: -1, userId: 1 });
|
|
1313
|
+
var NotificationModel = mongoose13.models.Notification || mongoose13.model("Notification", schema9);
|
|
1022
1314
|
|
|
1023
1315
|
// src/mongoose/PushToken.ts
|
|
1024
1316
|
import { EnumOSPlatform } from "@timardex/cluemart-shared/enums";
|
|
1025
|
-
import
|
|
1026
|
-
var MongooseSchema10 =
|
|
1027
|
-
var
|
|
1317
|
+
import mongoose14 from "mongoose";
|
|
1318
|
+
var MongooseSchema10 = mongoose14.Schema;
|
|
1319
|
+
var schema10 = new MongooseSchema10(
|
|
1028
1320
|
{
|
|
1029
1321
|
platform: {
|
|
1030
1322
|
enum: Object.values(EnumOSPlatform),
|
|
@@ -1035,12 +1327,12 @@ var schema6 = new MongooseSchema10(
|
|
|
1035
1327
|
userId: {
|
|
1036
1328
|
ref: "User",
|
|
1037
1329
|
required: true,
|
|
1038
|
-
type:
|
|
1330
|
+
type: mongoose14.Schema.Types.ObjectId
|
|
1039
1331
|
}
|
|
1040
1332
|
},
|
|
1041
1333
|
{ timestamps: true }
|
|
1042
1334
|
);
|
|
1043
|
-
var PushTokenModel =
|
|
1335
|
+
var PushTokenModel = mongoose14.models.PushToken || mongoose14.model("PushToken", schema10);
|
|
1044
1336
|
|
|
1045
1337
|
// src/mongoose/ResourceActivity.ts
|
|
1046
1338
|
import {
|
|
@@ -1049,8 +1341,8 @@ import {
|
|
|
1049
1341
|
EnumOSPlatform as EnumOSPlatform2,
|
|
1050
1342
|
EnumResourceType as EnumResourceType3
|
|
1051
1343
|
} from "@timardex/cluemart-shared";
|
|
1052
|
-
import
|
|
1053
|
-
var MongooseSchema11 =
|
|
1344
|
+
import mongoose15 from "mongoose";
|
|
1345
|
+
var MongooseSchema11 = mongoose15.Schema;
|
|
1054
1346
|
var ActivitySchema = new MongooseSchema11(
|
|
1055
1347
|
{
|
|
1056
1348
|
activityType: {
|
|
@@ -1079,7 +1371,7 @@ var ActivitySchema = new MongooseSchema11(
|
|
|
1079
1371
|
},
|
|
1080
1372
|
{ _id: false }
|
|
1081
1373
|
);
|
|
1082
|
-
var
|
|
1374
|
+
var schema11 = new MongooseSchema11(
|
|
1083
1375
|
{
|
|
1084
1376
|
activity: { default: [], type: [ActivitySchema] },
|
|
1085
1377
|
resourceId: { required: true, type: String },
|
|
@@ -1091,9 +1383,9 @@ var schema7 = new MongooseSchema11(
|
|
|
1091
1383
|
},
|
|
1092
1384
|
{ timestamps: true }
|
|
1093
1385
|
);
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
var ResourceActivityModel =
|
|
1386
|
+
schema11.index({ resourceId: 1, resourceType: 1 }, { unique: true });
|
|
1387
|
+
schema11.index({ "views.location": "2dsphere" });
|
|
1388
|
+
var ResourceActivityModel = mongoose15.models.ResourceActivity || mongoose15.model("ResourceActivity", schema11);
|
|
1097
1389
|
|
|
1098
1390
|
// src/mongoose/User.ts
|
|
1099
1391
|
import {
|
|
@@ -1106,15 +1398,15 @@ import {
|
|
|
1106
1398
|
EnumUserLicence as EnumUserLicence3,
|
|
1107
1399
|
EnumUserRole
|
|
1108
1400
|
} from "@timardex/cluemart-shared";
|
|
1109
|
-
import
|
|
1110
|
-
var MongooseSchema12 =
|
|
1401
|
+
import mongoose16 from "mongoose";
|
|
1402
|
+
var MongooseSchema12 = mongoose16.Schema;
|
|
1111
1403
|
var userActivityEventSchema = new MongooseSchema12(
|
|
1112
1404
|
{
|
|
1113
1405
|
dateTime: dateTimeSchema2,
|
|
1114
1406
|
resourceId: {
|
|
1115
1407
|
ref: "Event",
|
|
1116
1408
|
required: false,
|
|
1117
|
-
type:
|
|
1409
|
+
type: mongoose16.Schema.Types.ObjectId
|
|
1118
1410
|
}
|
|
1119
1411
|
},
|
|
1120
1412
|
{ _id: false }
|
|
@@ -1124,17 +1416,17 @@ var userActivityFavouritesSchema = new MongooseSchema12(
|
|
|
1124
1416
|
events: {
|
|
1125
1417
|
ref: "Event",
|
|
1126
1418
|
required: false,
|
|
1127
|
-
type: [
|
|
1419
|
+
type: [mongoose16.Schema.Types.ObjectId]
|
|
1128
1420
|
},
|
|
1129
1421
|
partners: {
|
|
1130
1422
|
ref: "Partner",
|
|
1131
1423
|
required: false,
|
|
1132
|
-
type: [
|
|
1424
|
+
type: [mongoose16.Schema.Types.ObjectId]
|
|
1133
1425
|
},
|
|
1134
1426
|
vendors: {
|
|
1135
1427
|
ref: "Vendor",
|
|
1136
1428
|
required: false,
|
|
1137
|
-
type: [
|
|
1429
|
+
type: [mongoose16.Schema.Types.ObjectId]
|
|
1138
1430
|
}
|
|
1139
1431
|
},
|
|
1140
1432
|
{ _id: false }
|
|
@@ -1163,6 +1455,18 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1163
1455
|
required: false,
|
|
1164
1456
|
type: Date
|
|
1165
1457
|
},
|
|
1458
|
+
paymentFailedAt: {
|
|
1459
|
+
required: false,
|
|
1460
|
+
type: Date
|
|
1461
|
+
},
|
|
1462
|
+
paymentGracePeriodEndsAt: {
|
|
1463
|
+
required: false,
|
|
1464
|
+
type: Date
|
|
1465
|
+
},
|
|
1466
|
+
paymentGraceSubscriptionId: {
|
|
1467
|
+
required: false,
|
|
1468
|
+
type: String
|
|
1469
|
+
},
|
|
1166
1470
|
pendingBillingPeriod: {
|
|
1167
1471
|
enum: Object.values(EnumBillingPeriod2),
|
|
1168
1472
|
required: false,
|
|
@@ -1221,13 +1525,13 @@ var redeemedRewardSchema = new MongooseSchema12(
|
|
|
1221
1525
|
},
|
|
1222
1526
|
{ _id: false }
|
|
1223
1527
|
);
|
|
1224
|
-
var
|
|
1528
|
+
var schema12 = new MongooseSchema12(
|
|
1225
1529
|
{
|
|
1226
1530
|
active: { default: false, required: true, type: Boolean },
|
|
1227
1531
|
affiliate: {
|
|
1228
1532
|
ref: "Affiliate",
|
|
1229
1533
|
required: false,
|
|
1230
|
-
type:
|
|
1534
|
+
type: mongoose16.Schema.Types.ObjectId
|
|
1231
1535
|
},
|
|
1232
1536
|
avatar: {
|
|
1233
1537
|
required: false,
|
|
@@ -1236,7 +1540,7 @@ var schema8 = new MongooseSchema12(
|
|
|
1236
1540
|
coupon: {
|
|
1237
1541
|
ref: "Coupon",
|
|
1238
1542
|
required: false,
|
|
1239
|
-
type:
|
|
1543
|
+
type: mongoose16.Schema.Types.ObjectId
|
|
1240
1544
|
},
|
|
1241
1545
|
deletedAt: { default: null, required: false, type: Date },
|
|
1242
1546
|
email: { required: true, type: String },
|
|
@@ -1248,13 +1552,13 @@ var schema8 = new MongooseSchema12(
|
|
|
1248
1552
|
events: {
|
|
1249
1553
|
ref: "Event",
|
|
1250
1554
|
required: false,
|
|
1251
|
-
type: [
|
|
1555
|
+
type: [mongoose16.Schema.Types.ObjectId]
|
|
1252
1556
|
},
|
|
1253
1557
|
firstName: { required: true, type: String },
|
|
1254
1558
|
game: {
|
|
1255
1559
|
ref: "Game",
|
|
1256
1560
|
required: false,
|
|
1257
|
-
type:
|
|
1561
|
+
type: mongoose16.Schema.Types.ObjectId
|
|
1258
1562
|
},
|
|
1259
1563
|
interests: {
|
|
1260
1564
|
enum: Object.values(EnumResourceType4),
|
|
@@ -1276,7 +1580,7 @@ var schema8 = new MongooseSchema12(
|
|
|
1276
1580
|
partner: {
|
|
1277
1581
|
ref: "Partner",
|
|
1278
1582
|
required: false,
|
|
1279
|
-
type:
|
|
1583
|
+
type: mongoose16.Schema.Types.ObjectId
|
|
1280
1584
|
},
|
|
1281
1585
|
password: { required: true, type: String },
|
|
1282
1586
|
platform: {
|
|
@@ -1309,7 +1613,7 @@ var schema8 = new MongooseSchema12(
|
|
|
1309
1613
|
school: {
|
|
1310
1614
|
ref: "School",
|
|
1311
1615
|
required: false,
|
|
1312
|
-
type:
|
|
1616
|
+
type: mongoose16.Schema.Types.ObjectId
|
|
1313
1617
|
},
|
|
1314
1618
|
stripe: {
|
|
1315
1619
|
required: false,
|
|
@@ -1334,20 +1638,20 @@ var schema8 = new MongooseSchema12(
|
|
|
1334
1638
|
vendor: {
|
|
1335
1639
|
ref: "Vendor",
|
|
1336
1640
|
required: false,
|
|
1337
|
-
type:
|
|
1641
|
+
type: mongoose16.Schema.Types.ObjectId
|
|
1338
1642
|
}
|
|
1339
1643
|
},
|
|
1340
1644
|
{ strict: false, timestamps: true }
|
|
1341
1645
|
);
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
var UserModel =
|
|
1646
|
+
schema12.index({ "licences.expiryDate": 1 });
|
|
1647
|
+
schema12.index({ "licences.licenceType": 1 });
|
|
1648
|
+
schema12.index({ promoCodes: 1, active: 1, deletedAt: 1 });
|
|
1649
|
+
var UserModel = mongoose16.models.User || mongoose16.model("User", schema12);
|
|
1346
1650
|
|
|
1347
1651
|
// src/mongoose/VerificationToken.ts
|
|
1348
|
-
import
|
|
1349
|
-
var MongooseSchema13 =
|
|
1350
|
-
var
|
|
1652
|
+
import mongoose17 from "mongoose";
|
|
1653
|
+
var MongooseSchema13 = mongoose17.Schema;
|
|
1654
|
+
var schema13 = new MongooseSchema13(
|
|
1351
1655
|
{
|
|
1352
1656
|
createdAt: {
|
|
1353
1657
|
default: Date.now,
|
|
@@ -1362,15 +1666,15 @@ var schema9 = new MongooseSchema13(
|
|
|
1362
1666
|
},
|
|
1363
1667
|
{ timestamps: true }
|
|
1364
1668
|
);
|
|
1365
|
-
var VerificationTokenModel =
|
|
1669
|
+
var VerificationTokenModel = mongoose17.models.VerificationToken || mongoose17.model("VerificationToken", schema13);
|
|
1366
1670
|
|
|
1367
1671
|
// src/mongoose/vendor/Vendor.ts
|
|
1368
1672
|
import {
|
|
1369
1673
|
EnumEventDateStatus as EnumEventDateStatus5,
|
|
1370
1674
|
EnumVendorType
|
|
1371
1675
|
} from "@timardex/cluemart-shared";
|
|
1372
|
-
import
|
|
1373
|
-
var MongooseSchema14 =
|
|
1676
|
+
import mongoose18 from "mongoose";
|
|
1677
|
+
var MongooseSchema14 = mongoose18.Schema;
|
|
1374
1678
|
var vendorProductTypeSchema = new MongooseSchema14(
|
|
1375
1679
|
{
|
|
1376
1680
|
description: { required: false, type: String },
|
|
@@ -1433,7 +1737,7 @@ var downgradeSnapshotSchema = new MongooseSchema14(
|
|
|
1433
1737
|
},
|
|
1434
1738
|
{ _id: false }
|
|
1435
1739
|
);
|
|
1436
|
-
var
|
|
1740
|
+
var schema14 = new MongooseSchema14(
|
|
1437
1741
|
{
|
|
1438
1742
|
...baseResourceFields,
|
|
1439
1743
|
// Importing base resource fields from global.ts
|
|
@@ -1457,12 +1761,12 @@ var schema10 = new MongooseSchema14(
|
|
|
1457
1761
|
unregisteredVendorId: {
|
|
1458
1762
|
ref: "UnregisteredVendor",
|
|
1459
1763
|
required: false,
|
|
1460
|
-
type:
|
|
1764
|
+
type: mongoose18.Schema.Types.ObjectId
|
|
1461
1765
|
},
|
|
1462
1766
|
vendorInfoId: {
|
|
1463
1767
|
ref: "VendorInfo",
|
|
1464
1768
|
required: false,
|
|
1465
|
-
type:
|
|
1769
|
+
type: mongoose18.Schema.Types.ObjectId
|
|
1466
1770
|
},
|
|
1467
1771
|
vendorType: {
|
|
1468
1772
|
enum: Object.values(EnumVendorType),
|
|
@@ -1472,26 +1776,26 @@ var schema10 = new MongooseSchema14(
|
|
|
1472
1776
|
},
|
|
1473
1777
|
{ timestamps: true }
|
|
1474
1778
|
);
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1779
|
+
schema14.index({ name: 1 });
|
|
1780
|
+
schema14.index({ description: 1 });
|
|
1781
|
+
schema14.index({ region: 1 });
|
|
1782
|
+
schema14.index({ "categories.name": 1 });
|
|
1783
|
+
schema14.index({ slug: 1 });
|
|
1784
|
+
schema14.index({
|
|
1481
1785
|
categoriesNames: "text",
|
|
1482
1786
|
description: "text",
|
|
1483
1787
|
name: "text"
|
|
1484
1788
|
});
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
var VendorModel =
|
|
1789
|
+
schema14.index({ deletedAt: 1, "owner.userId": 1 });
|
|
1790
|
+
schema14.plugin(searchNamePlugin);
|
|
1791
|
+
var VendorModel = mongoose18.models.Vendor || mongoose18.model("Vendor", schema14);
|
|
1488
1792
|
|
|
1489
1793
|
// src/mongoose/vendor/VendorInfo.ts
|
|
1490
1794
|
import {
|
|
1491
1795
|
EnumFoodFlavor
|
|
1492
1796
|
} from "@timardex/cluemart-shared";
|
|
1493
|
-
import
|
|
1494
|
-
var MongooseSchema15 =
|
|
1797
|
+
import mongoose19 from "mongoose";
|
|
1798
|
+
var MongooseSchema15 = mongoose19.Schema;
|
|
1495
1799
|
var AttributesSchema = new MongooseSchema15(
|
|
1496
1800
|
{
|
|
1497
1801
|
details: { required: false, type: String },
|
|
@@ -1499,7 +1803,7 @@ var AttributesSchema = new MongooseSchema15(
|
|
|
1499
1803
|
},
|
|
1500
1804
|
{ _id: false }
|
|
1501
1805
|
);
|
|
1502
|
-
var
|
|
1806
|
+
var schema15 = new MongooseSchema15(
|
|
1503
1807
|
{
|
|
1504
1808
|
active: { default: true, type: Boolean },
|
|
1505
1809
|
compliance: {
|
|
@@ -1534,29 +1838,29 @@ var schema11 = new MongooseSchema15(
|
|
|
1534
1838
|
vendorId: {
|
|
1535
1839
|
ref: "Vendor",
|
|
1536
1840
|
required: true,
|
|
1537
|
-
type:
|
|
1841
|
+
type: mongoose19.Schema.Types.ObjectId
|
|
1538
1842
|
}
|
|
1539
1843
|
},
|
|
1540
1844
|
{ timestamps: true }
|
|
1541
1845
|
);
|
|
1542
|
-
|
|
1543
|
-
var VendorInfoModel =
|
|
1846
|
+
schema15.index({ vendorId: 1 });
|
|
1847
|
+
var VendorInfoModel = mongoose19.models.VendorInfo || mongoose19.model("VendorInfo", schema15);
|
|
1544
1848
|
|
|
1545
1849
|
// src/mongoose/vendor/UnregisteredVendor.ts
|
|
1546
|
-
import
|
|
1547
|
-
var MongooseSchema16 =
|
|
1850
|
+
import mongoose20 from "mongoose";
|
|
1851
|
+
var MongooseSchema16 = mongoose20.Schema;
|
|
1548
1852
|
var invitationSchema = new MongooseSchema16(
|
|
1549
1853
|
{
|
|
1550
1854
|
dateTime: { required: true, type: [dateTimeSchema2] },
|
|
1551
1855
|
inviterId: {
|
|
1552
1856
|
ref: "Event",
|
|
1553
1857
|
required: true,
|
|
1554
|
-
type:
|
|
1858
|
+
type: mongoose20.Schema.Types.ObjectId
|
|
1555
1859
|
}
|
|
1556
1860
|
},
|
|
1557
1861
|
{ _id: false }
|
|
1558
1862
|
);
|
|
1559
|
-
var
|
|
1863
|
+
var schema16 = new MongooseSchema16(
|
|
1560
1864
|
{
|
|
1561
1865
|
active: { default: true, required: true, type: Boolean },
|
|
1562
1866
|
categoryIds: { required: true, type: [String] },
|
|
@@ -1565,7 +1869,7 @@ var schema12 = new MongooseSchema16(
|
|
|
1565
1869
|
claimedByUserId: {
|
|
1566
1870
|
ref: "User",
|
|
1567
1871
|
required: false,
|
|
1568
|
-
type:
|
|
1872
|
+
type: mongoose20.Schema.Types.ObjectId
|
|
1569
1873
|
},
|
|
1570
1874
|
claimInitiatedAt: { default: null, required: false, type: Date },
|
|
1571
1875
|
claimToken: { default: null, required: false, type: String },
|
|
@@ -1578,15 +1882,15 @@ var schema12 = new MongooseSchema16(
|
|
|
1578
1882
|
},
|
|
1579
1883
|
{ timestamps: true }
|
|
1580
1884
|
);
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
var UnregisteredVendorModel =
|
|
1885
|
+
schema16.index({ name: 1 });
|
|
1886
|
+
schema16.index({ email: 1 });
|
|
1887
|
+
var UnregisteredVendorModel = mongoose20.models.UnregisteredVendor || mongoose20.model("UnregisteredVendor", schema16);
|
|
1584
1888
|
|
|
1585
1889
|
// src/mongoose/event/Event.ts
|
|
1586
1890
|
import { EnumEventType as EnumEventType2 } from "@timardex/cluemart-shared";
|
|
1587
|
-
import
|
|
1588
|
-
var MongooseSchema17 =
|
|
1589
|
-
var
|
|
1891
|
+
import mongoose21 from "mongoose";
|
|
1892
|
+
var MongooseSchema17 = mongoose21.Schema;
|
|
1893
|
+
var schema17 = new MongooseSchema17(
|
|
1590
1894
|
{
|
|
1591
1895
|
...baseResourceFields,
|
|
1592
1896
|
// Importing base resource fields from global.ts
|
|
@@ -1595,7 +1899,7 @@ var schema13 = new MongooseSchema17(
|
|
|
1595
1899
|
eventInfoId: {
|
|
1596
1900
|
ref: "EventInfo",
|
|
1597
1901
|
required: false,
|
|
1598
|
-
type:
|
|
1902
|
+
type: mongoose21.Schema.Types.ObjectId
|
|
1599
1903
|
},
|
|
1600
1904
|
eventType: {
|
|
1601
1905
|
enum: Object.values(EnumEventType2),
|
|
@@ -1624,24 +1928,24 @@ var schema13 = new MongooseSchema17(
|
|
|
1624
1928
|
},
|
|
1625
1929
|
{ timestamps: true }
|
|
1626
1930
|
);
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
var EventModel =
|
|
1931
|
+
schema17.index({ name: 1 });
|
|
1932
|
+
schema17.index({ description: 1 });
|
|
1933
|
+
schema17.index({ region: 1 });
|
|
1934
|
+
schema17.index({ "location.geo": "2dsphere" });
|
|
1935
|
+
schema17.index({ tags: 1 });
|
|
1936
|
+
schema17.index({ deletedAt: 1 });
|
|
1937
|
+
schema17.index({ "dateTime.dateStatus": 1 });
|
|
1938
|
+
schema17.index({ slug: 1 });
|
|
1939
|
+
schema17.index({ name: "text", description: "text", tags: "text" });
|
|
1940
|
+
schema17.index({ "owner.userId": 1, deletedAt: 1 });
|
|
1941
|
+
schema17.plugin(searchNamePlugin);
|
|
1942
|
+
var EventModel = mongoose21.models.Event || mongoose21.model("Event", schema17);
|
|
1639
1943
|
|
|
1640
1944
|
// src/mongoose/Partner.ts
|
|
1641
1945
|
import { EnumPartnerType } from "@timardex/cluemart-shared";
|
|
1642
|
-
import
|
|
1643
|
-
var MongooseSchema18 =
|
|
1644
|
-
var
|
|
1946
|
+
import mongoose22 from "mongoose";
|
|
1947
|
+
var MongooseSchema18 = mongoose22.Schema;
|
|
1948
|
+
var schema18 = new MongooseSchema18(
|
|
1645
1949
|
{
|
|
1646
1950
|
...baseResourceFields,
|
|
1647
1951
|
location: {
|
|
@@ -1657,15 +1961,15 @@ var schema14 = new MongooseSchema18(
|
|
|
1657
1961
|
},
|
|
1658
1962
|
{ timestamps: true }
|
|
1659
1963
|
);
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
var PartnerModel =
|
|
1964
|
+
schema18.index({ name: 1 });
|
|
1965
|
+
schema18.index({ description: 1 });
|
|
1966
|
+
schema18.index({ region: 1 });
|
|
1967
|
+
schema18.index({ "location.geo": "2dsphere" });
|
|
1968
|
+
schema18.index({ slug: 1 });
|
|
1969
|
+
schema18.index({ name: "text", description: "text" });
|
|
1970
|
+
schema18.index({ "owner.userId": 1, deletedAt: 1 });
|
|
1971
|
+
schema18.plugin(searchNamePlugin);
|
|
1972
|
+
var PartnerModel = mongoose22.models.Partner || mongoose22.model("Partner", schema18);
|
|
1669
1973
|
|
|
1670
1974
|
// src/mongoose/Post.ts
|
|
1671
1975
|
import {
|
|
@@ -1673,8 +1977,8 @@ import {
|
|
|
1673
1977
|
EnumPostType as EnumPostType2,
|
|
1674
1978
|
EnumResourceType as EnumResourceType5
|
|
1675
1979
|
} from "@timardex/cluemart-shared";
|
|
1676
|
-
import
|
|
1677
|
-
var MongooseSchema19 =
|
|
1980
|
+
import mongoose23, { Schema } from "mongoose";
|
|
1981
|
+
var MongooseSchema19 = mongoose23.Schema;
|
|
1678
1982
|
var contentSchema = new MongooseSchema19(
|
|
1679
1983
|
{
|
|
1680
1984
|
contentData: Schema.Types.Mixed,
|
|
@@ -1700,7 +2004,7 @@ var resourceSchema = new MongooseSchema19(
|
|
|
1700
2004
|
},
|
|
1701
2005
|
{ _id: false }
|
|
1702
2006
|
);
|
|
1703
|
-
var
|
|
2007
|
+
var schema19 = new MongooseSchema19(
|
|
1704
2008
|
{
|
|
1705
2009
|
active: { default: false, required: true, type: Boolean },
|
|
1706
2010
|
approvedAt: { default: null, required: false, type: Date },
|
|
@@ -1731,14 +2035,14 @@ var schema15 = new MongooseSchema19(
|
|
|
1731
2035
|
},
|
|
1732
2036
|
{ timestamps: true }
|
|
1733
2037
|
);
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
var PostModel =
|
|
2038
|
+
schema19.index({ title: 1 });
|
|
2039
|
+
schema19.index({ tags: 1 });
|
|
2040
|
+
schema19.index({ postType: 1, slug: 1 }, { unique: true });
|
|
2041
|
+
var PostModel = mongoose23.models.Post || mongoose23.model("Post", schema19);
|
|
1738
2042
|
|
|
1739
2043
|
// src/mongoose/AppSetting.ts
|
|
1740
|
-
import
|
|
1741
|
-
var MongooseSchema20 =
|
|
2044
|
+
import mongoose24 from "mongoose";
|
|
2045
|
+
var MongooseSchema20 = mongoose24.Schema;
|
|
1742
2046
|
var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
|
|
1743
2047
|
var AppSettingSchema = new MongooseSchema20(
|
|
1744
2048
|
{
|
|
@@ -1771,21 +2075,21 @@ var AppSettingSchema = new MongooseSchema20(
|
|
|
1771
2075
|
},
|
|
1772
2076
|
{ timestamps: true }
|
|
1773
2077
|
);
|
|
1774
|
-
var AppSettingModel =
|
|
2078
|
+
var AppSettingModel = mongoose24.models.AppSetting || mongoose24.model("AppSetting", AppSettingSchema);
|
|
1775
2079
|
|
|
1776
2080
|
// src/mongoose/game/Game.ts
|
|
1777
2081
|
import {
|
|
1778
2082
|
EnumGameStatus,
|
|
1779
2083
|
EnumGameType
|
|
1780
2084
|
} from "@timardex/cluemart-shared";
|
|
1781
|
-
import
|
|
2085
|
+
import mongoose28 from "mongoose";
|
|
1782
2086
|
|
|
1783
2087
|
// src/mongoose/game/DailyClue.ts
|
|
1784
|
-
import
|
|
2088
|
+
import mongoose26 from "mongoose";
|
|
1785
2089
|
|
|
1786
2090
|
// src/mongoose/game/utils.ts
|
|
1787
|
-
import
|
|
1788
|
-
var MongooseSchema21 =
|
|
2091
|
+
import mongoose25 from "mongoose";
|
|
2092
|
+
var MongooseSchema21 = mongoose25.Schema;
|
|
1789
2093
|
var schemaGameDate = new MongooseSchema21(
|
|
1790
2094
|
{
|
|
1791
2095
|
endDate: { required: true, type: Date },
|
|
@@ -1795,7 +2099,7 @@ var schemaGameDate = new MongooseSchema21(
|
|
|
1795
2099
|
);
|
|
1796
2100
|
|
|
1797
2101
|
// src/mongoose/game/DailyClue.ts
|
|
1798
|
-
var MongooseSchema22 =
|
|
2102
|
+
var MongooseSchema22 = mongoose26.Schema;
|
|
1799
2103
|
var schemaLetters = new MongooseSchema22(
|
|
1800
2104
|
{
|
|
1801
2105
|
collected: { required: false, type: [String] },
|
|
@@ -1826,8 +2130,8 @@ var schemaDailyClueGameData = new MongooseSchema22(
|
|
|
1826
2130
|
);
|
|
1827
2131
|
|
|
1828
2132
|
// src/mongoose/game/PuzzleGame.ts
|
|
1829
|
-
import
|
|
1830
|
-
var MongooseSchema23 =
|
|
2133
|
+
import mongoose27 from "mongoose";
|
|
2134
|
+
var MongooseSchema23 = mongoose27.Schema;
|
|
1831
2135
|
var schemaPuzzleAnswer = new MongooseSchema23(
|
|
1832
2136
|
{
|
|
1833
2137
|
answer: { required: true, type: String },
|
|
@@ -1872,16 +2176,16 @@ var schemaPuzzleGameData = new MongooseSchema23(
|
|
|
1872
2176
|
);
|
|
1873
2177
|
|
|
1874
2178
|
// src/mongoose/game/Game.ts
|
|
1875
|
-
var MongooseSchema24 =
|
|
2179
|
+
var MongooseSchema24 = mongoose28.Schema;
|
|
1876
2180
|
var gameDataSchemas = {
|
|
1877
2181
|
[EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
|
|
1878
2182
|
[EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
|
|
1879
2183
|
[EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
|
|
1880
2184
|
};
|
|
1881
2185
|
var gameDataDefinition = Object.fromEntries(
|
|
1882
|
-
Object.entries(gameDataSchemas).map(([key,
|
|
2186
|
+
Object.entries(gameDataSchemas).map(([key, schema24]) => [
|
|
1883
2187
|
key,
|
|
1884
|
-
{ default: null, required: false, type:
|
|
2188
|
+
{ default: null, required: false, type: schema24 }
|
|
1885
2189
|
])
|
|
1886
2190
|
);
|
|
1887
2191
|
var gameHistorySchema = new MongooseSchema24(
|
|
@@ -1919,7 +2223,7 @@ var gameTypeSchema = new MongooseSchema24(
|
|
|
1919
2223
|
},
|
|
1920
2224
|
{ timestamps: true }
|
|
1921
2225
|
);
|
|
1922
|
-
var
|
|
2226
|
+
var schema20 = new MongooseSchema24(
|
|
1923
2227
|
{
|
|
1924
2228
|
active: { default: false, required: true, type: Boolean },
|
|
1925
2229
|
deletedAt: { default: null, required: false, type: Date },
|
|
@@ -1932,11 +2236,11 @@ var schema16 = new MongooseSchema24(
|
|
|
1932
2236
|
},
|
|
1933
2237
|
{ timestamps: true }
|
|
1934
2238
|
);
|
|
1935
|
-
var GameModel =
|
|
2239
|
+
var GameModel = mongoose28.models.Game || mongoose28.model("Game", schema20);
|
|
1936
2240
|
|
|
1937
2241
|
// src/mongoose/School.ts
|
|
1938
|
-
import
|
|
1939
|
-
var MongooseSchema25 =
|
|
2242
|
+
import mongoose29 from "mongoose";
|
|
2243
|
+
var MongooseSchema25 = mongoose29.Schema;
|
|
1940
2244
|
var campaignsSchema = new MongooseSchema25(
|
|
1941
2245
|
{
|
|
1942
2246
|
endDate: { required: true, type: Date },
|
|
@@ -1945,7 +2249,7 @@ var campaignsSchema = new MongooseSchema25(
|
|
|
1945
2249
|
},
|
|
1946
2250
|
{ _id: false }
|
|
1947
2251
|
);
|
|
1948
|
-
var
|
|
2252
|
+
var schema21 = new MongooseSchema25(
|
|
1949
2253
|
{
|
|
1950
2254
|
// New schools are active by default
|
|
1951
2255
|
active: { default: false, required: true, type: Boolean },
|
|
@@ -1972,14 +2276,14 @@ var schema17 = new MongooseSchema25(
|
|
|
1972
2276
|
},
|
|
1973
2277
|
{ timestamps: true }
|
|
1974
2278
|
);
|
|
1975
|
-
|
|
2279
|
+
schema21.index(
|
|
1976
2280
|
{ schoolCode: 1 },
|
|
1977
2281
|
{
|
|
1978
2282
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
1979
2283
|
unique: true
|
|
1980
2284
|
}
|
|
1981
2285
|
);
|
|
1982
|
-
var SchoolModel =
|
|
2286
|
+
var SchoolModel = mongoose29.models.School || mongoose29.model("School", schema21);
|
|
1983
2287
|
|
|
1984
2288
|
// src/mongoose/Affiliate.ts
|
|
1985
2289
|
import {
|
|
@@ -1987,8 +2291,8 @@ import {
|
|
|
1987
2291
|
EnumAffiliateRewardType,
|
|
1988
2292
|
EnumResourceType as EnumResourceType6
|
|
1989
2293
|
} from "@timardex/cluemart-shared";
|
|
1990
|
-
import
|
|
1991
|
-
var MongooseSchema26 =
|
|
2294
|
+
import mongoose30 from "mongoose";
|
|
2295
|
+
var MongooseSchema26 = mongoose30.Schema;
|
|
1992
2296
|
var affiliateRewardSchema = new MongooseSchema26(
|
|
1993
2297
|
{
|
|
1994
2298
|
createdAt: { required: true, type: Date },
|
|
@@ -2009,7 +2313,7 @@ var affiliateResourceSchema = new MongooseSchema26(
|
|
|
2009
2313
|
resourceDeletedAt: { default: null, required: false, type: Date },
|
|
2010
2314
|
resourceId: {
|
|
2011
2315
|
required: true,
|
|
2012
|
-
type:
|
|
2316
|
+
type: mongoose30.Schema.Types.ObjectId
|
|
2013
2317
|
},
|
|
2014
2318
|
resourceName: { required: true, type: String },
|
|
2015
2319
|
resourceOwner: {
|
|
@@ -2072,7 +2376,7 @@ var redeemHistorySchema = new MongooseSchema26(
|
|
|
2072
2376
|
},
|
|
2073
2377
|
{ _id: false }
|
|
2074
2378
|
);
|
|
2075
|
-
var
|
|
2379
|
+
var schema22 = new MongooseSchema26(
|
|
2076
2380
|
{
|
|
2077
2381
|
active: { default: false, required: true, type: Boolean },
|
|
2078
2382
|
affiliateBonusRewards: {
|
|
@@ -2102,22 +2406,22 @@ var schema18 = new MongooseSchema26(
|
|
|
2102
2406
|
},
|
|
2103
2407
|
{ timestamps: true }
|
|
2104
2408
|
);
|
|
2105
|
-
|
|
2409
|
+
schema22.index(
|
|
2106
2410
|
{ affiliateCode: 1 },
|
|
2107
2411
|
{
|
|
2108
2412
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
2109
2413
|
unique: true
|
|
2110
2414
|
}
|
|
2111
2415
|
);
|
|
2112
|
-
var AffiliateModel =
|
|
2416
|
+
var AffiliateModel = mongoose30.models.Affiliate || mongoose30.model("Affiliate", schema22);
|
|
2113
2417
|
|
|
2114
2418
|
// src/mongoose/Coupon.ts
|
|
2115
2419
|
import {
|
|
2116
2420
|
EnumCouponQualificationType,
|
|
2117
2421
|
EnumResourceType as EnumResourceType7
|
|
2118
2422
|
} from "@timardex/cluemart-shared";
|
|
2119
|
-
import
|
|
2120
|
-
var MongooseSchema27 =
|
|
2423
|
+
import mongoose31 from "mongoose";
|
|
2424
|
+
var MongooseSchema27 = mongoose31.Schema;
|
|
2121
2425
|
var couponOptionSchema = new MongooseSchema27(
|
|
2122
2426
|
{
|
|
2123
2427
|
buy: { required: false, type: Number },
|
|
@@ -2137,20 +2441,20 @@ var couponVendorProductSchema = new MongooseSchema27(
|
|
|
2137
2441
|
{
|
|
2138
2442
|
couponId: {
|
|
2139
2443
|
required: true,
|
|
2140
|
-
type:
|
|
2444
|
+
type: mongoose31.Schema.Types.ObjectId
|
|
2141
2445
|
},
|
|
2142
2446
|
productId: {
|
|
2143
2447
|
required: true,
|
|
2144
|
-
type:
|
|
2448
|
+
type: mongoose31.Schema.Types.ObjectId
|
|
2145
2449
|
},
|
|
2146
2450
|
vendorCouponId: {
|
|
2147
2451
|
required: false,
|
|
2148
|
-
type:
|
|
2452
|
+
type: mongoose31.Schema.Types.ObjectId
|
|
2149
2453
|
},
|
|
2150
2454
|
vendorId: {
|
|
2151
2455
|
ref: "Vendor",
|
|
2152
2456
|
required: true,
|
|
2153
|
-
type:
|
|
2457
|
+
type: mongoose31.Schema.Types.ObjectId
|
|
2154
2458
|
}
|
|
2155
2459
|
},
|
|
2156
2460
|
{ _id: false }
|
|
@@ -2172,7 +2476,7 @@ var couponParticipantUserSchema = new MongooseSchema27(
|
|
|
2172
2476
|
userId: {
|
|
2173
2477
|
ref: "User",
|
|
2174
2478
|
required: true,
|
|
2175
|
-
type:
|
|
2479
|
+
type: mongoose31.Schema.Types.ObjectId
|
|
2176
2480
|
}
|
|
2177
2481
|
},
|
|
2178
2482
|
{ timestamps: true }
|
|
@@ -2204,7 +2508,7 @@ var couponDataSchema = new MongooseSchema27(
|
|
|
2204
2508
|
},
|
|
2205
2509
|
{ timestamps: true }
|
|
2206
2510
|
);
|
|
2207
|
-
var
|
|
2511
|
+
var schema23 = new MongooseSchema27(
|
|
2208
2512
|
{
|
|
2209
2513
|
active: { default: true, required: true, type: Boolean },
|
|
2210
2514
|
couponData: { default: [], required: false, type: [couponDataSchema] },
|
|
@@ -2216,9 +2520,9 @@ var schema19 = new MongooseSchema27(
|
|
|
2216
2520
|
},
|
|
2217
2521
|
{ timestamps: true }
|
|
2218
2522
|
);
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
var CouponModel =
|
|
2523
|
+
schema23.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
|
|
2524
|
+
schema23.index({ "couponData.participantUsers.userId": 1 });
|
|
2525
|
+
var CouponModel = mongoose31.models.Coupon || mongoose31.model("Coupon", schema23);
|
|
2222
2526
|
|
|
2223
2527
|
// src/service/promoCode/constants.ts
|
|
2224
2528
|
var ACTIVE_NOT_DELETED_FILTER = {
|
|
@@ -2417,8 +2721,9 @@ async function getPayingStripePlanFor(userId, now, payingPlans) {
|
|
|
2417
2721
|
if (stripe == null || stripe.subscriptionId == null) {
|
|
2418
2722
|
return { hasSubscription: false, plan: null, validTypes };
|
|
2419
2723
|
}
|
|
2420
|
-
const hasActiveStatus = stripe.status === EnumSubscriptionStatus2.ACTIVE
|
|
2421
|
-
|
|
2724
|
+
const hasActiveStatus = stripe.status === EnumSubscriptionStatus2.ACTIVE;
|
|
2725
|
+
const paidThrough = stripe.endDate ? new Date(stripe.endDate).getTime() : Number.NaN;
|
|
2726
|
+
if (!hasActiveStatus || !Number.isFinite(paidThrough) || paidThrough <= now.getTime() || stripe.currentPlan == null) {
|
|
2422
2727
|
return { hasSubscription: false, plan: null, validTypes };
|
|
2423
2728
|
}
|
|
2424
2729
|
const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
|
|
@@ -2489,16 +2794,22 @@ async function isEligibleReferredVendor({
|
|
|
2489
2794
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
2490
2795
|
affiliateId,
|
|
2491
2796
|
affiliateOwnerUserId,
|
|
2492
|
-
|
|
2493
|
-
rewardValue
|
|
2797
|
+
awards
|
|
2494
2798
|
}) {
|
|
2799
|
+
if (awards.length === 0) {
|
|
2800
|
+
return;
|
|
2801
|
+
}
|
|
2802
|
+
const totalPoints = awards.reduce((sum, award) => sum + award.rewardValue, 0);
|
|
2803
|
+
const resourceNames = awards.map((award) => award.resourceName);
|
|
2804
|
+
const pointLabel = totalPoints === 1 ? "point" : "points";
|
|
2805
|
+
const message = awards.length === 1 ? `You earned ${totalPoints} ${pointLabel}! Your referred vendor "${resourceNames[0]}" has an active subscription.` : `You earned ${totalPoints} ${pointLabel}! ${awards.length} of your referred vendors have an active subscription.`;
|
|
2495
2806
|
const payload = {
|
|
2496
2807
|
data: {
|
|
2497
2808
|
resourceId: String(affiliateId),
|
|
2498
|
-
resourceName,
|
|
2809
|
+
resourceName: resourceNames.join(", "),
|
|
2499
2810
|
resourceType: EnumNotificationResourceType3.AFFILIATE_REWARD_RECEIVED
|
|
2500
2811
|
},
|
|
2501
|
-
message
|
|
2812
|
+
message,
|
|
2502
2813
|
title: "Affiliate points earned",
|
|
2503
2814
|
type: EnumNotificationType2.SYSTEM,
|
|
2504
2815
|
userIds: [affiliateOwnerUserId]
|
|
@@ -2550,15 +2861,12 @@ async function tryAwardSubscriptionReward({
|
|
|
2550
2861
|
}
|
|
2551
2862
|
).exec();
|
|
2552
2863
|
if (updateResult.modifiedCount === 0) {
|
|
2553
|
-
return
|
|
2864
|
+
return null;
|
|
2554
2865
|
}
|
|
2555
|
-
|
|
2556
|
-
affiliateId: affiliate._id,
|
|
2557
|
-
affiliateOwnerUserId: affiliate.owner.userId,
|
|
2866
|
+
return {
|
|
2558
2867
|
resourceName: resource.resourceName,
|
|
2559
2868
|
rewardValue: reward.rewardValue
|
|
2560
|
-
}
|
|
2561
|
-
return "awarded";
|
|
2869
|
+
};
|
|
2562
2870
|
}
|
|
2563
2871
|
async function processAffiliateVendorReferral({
|
|
2564
2872
|
affiliate,
|
|
@@ -2572,14 +2880,14 @@ async function processAffiliateVendorReferral({
|
|
|
2572
2880
|
resourceOwnerUserId: resource.resourceOwner.userId
|
|
2573
2881
|
});
|
|
2574
2882
|
if (!vendorEligible) {
|
|
2575
|
-
return
|
|
2883
|
+
return null;
|
|
2576
2884
|
}
|
|
2577
2885
|
const rewardType = await mapVendorLicenceToSubscriptionRewardType(
|
|
2578
2886
|
resource.resourceOwner.userId,
|
|
2579
2887
|
now
|
|
2580
2888
|
);
|
|
2581
2889
|
if (!rewardType) {
|
|
2582
|
-
return
|
|
2890
|
+
return null;
|
|
2583
2891
|
}
|
|
2584
2892
|
return tryAwardSubscriptionReward({
|
|
2585
2893
|
affiliate,
|
|
@@ -2595,8 +2903,9 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
|
|
|
2595
2903
|
const affiliates = await findAffiliatesWithActiveVendorReferrals();
|
|
2596
2904
|
let awarded = 0;
|
|
2597
2905
|
let skipped = 0;
|
|
2598
|
-
const seenPairs = /* @__PURE__ */ new Set();
|
|
2599
2906
|
for (const affiliate of affiliates) {
|
|
2907
|
+
const awards = [];
|
|
2908
|
+
const seenPairs = /* @__PURE__ */ new Set();
|
|
2600
2909
|
for (const resource of affiliate.affiliateResources) {
|
|
2601
2910
|
if (!isEligibleVendorResource(resource)) {
|
|
2602
2911
|
continue;
|
|
@@ -2606,19 +2915,27 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
|
|
|
2606
2915
|
continue;
|
|
2607
2916
|
}
|
|
2608
2917
|
seenPairs.add(pairKey);
|
|
2609
|
-
const
|
|
2918
|
+
const award = await processAffiliateVendorReferral({
|
|
2610
2919
|
affiliate,
|
|
2611
2920
|
createdAt,
|
|
2612
2921
|
now,
|
|
2613
2922
|
period,
|
|
2614
2923
|
resource
|
|
2615
2924
|
});
|
|
2616
|
-
if (
|
|
2925
|
+
if (award) {
|
|
2617
2926
|
awarded += 1;
|
|
2927
|
+
awards.push(award);
|
|
2618
2928
|
} else {
|
|
2619
2929
|
skipped += 1;
|
|
2620
2930
|
}
|
|
2621
2931
|
}
|
|
2932
|
+
if (awards.length > 0) {
|
|
2933
|
+
await notifyAffiliateOwnerOfSubscriptionReward({
|
|
2934
|
+
affiliateId: affiliate._id,
|
|
2935
|
+
affiliateOwnerUserId: affiliate.owner.userId,
|
|
2936
|
+
awards
|
|
2937
|
+
});
|
|
2938
|
+
}
|
|
2622
2939
|
}
|
|
2623
2940
|
return { awarded, skipped };
|
|
2624
2941
|
}
|
|
@@ -2644,7 +2961,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
|
|
|
2644
2961
|
}
|
|
2645
2962
|
|
|
2646
2963
|
// src/service/database.ts
|
|
2647
|
-
import
|
|
2964
|
+
import mongoose32 from "mongoose";
|
|
2648
2965
|
var connectToDatabase = async ({
|
|
2649
2966
|
appName,
|
|
2650
2967
|
dbName,
|
|
@@ -2657,7 +2974,7 @@ var connectToDatabase = async ({
|
|
|
2657
2974
|
// Fallback to MongoDB Atlas connection string
|
|
2658
2975
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
2659
2976
|
);
|
|
2660
|
-
await
|
|
2977
|
+
await mongoose32.connect(mongoUri);
|
|
2661
2978
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
2662
2979
|
console.log(
|
|
2663
2980
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -2670,7 +2987,7 @@ var connectToDatabase = async ({
|
|
|
2670
2987
|
|
|
2671
2988
|
// src/types/index.ts
|
|
2672
2989
|
import express from "express";
|
|
2673
|
-
import
|
|
2990
|
+
import mongoose33 from "mongoose";
|
|
2674
2991
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
2675
2992
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
2676
2993
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
@@ -2725,7 +3042,12 @@ async function notifyUsers({
|
|
|
2725
3042
|
}
|
|
2726
3043
|
|
|
2727
3044
|
// src/service/updateAdStatus.ts
|
|
2728
|
-
import {
|
|
3045
|
+
import {
|
|
3046
|
+
EnumAdApprovalStatus as EnumAdApprovalStatus3,
|
|
3047
|
+
EnumAdBookingSlotKind as EnumAdBookingSlotKind3,
|
|
3048
|
+
EnumAdPaymentStatus as EnumAdPaymentStatus2,
|
|
3049
|
+
EnumAdStatus as EnumAdStatus2
|
|
3050
|
+
} from "@timardex/cluemart-shared";
|
|
2729
3051
|
async function updateAdStatuses() {
|
|
2730
3052
|
const now = /* @__PURE__ */ new Date();
|
|
2731
3053
|
const invalidResult = await AdModel.updateMany(
|
|
@@ -2743,11 +3065,36 @@ async function updateAdStatuses() {
|
|
|
2743
3065
|
{ end: { $lte: now }, status: { $ne: EnumAdStatus2.EXPIRED } },
|
|
2744
3066
|
{ $set: { status: EnumAdStatus2.EXPIRED } }
|
|
2745
3067
|
);
|
|
3068
|
+
const eligibleBooking = {
|
|
3069
|
+
$or: [
|
|
3070
|
+
{ bookingKind: { $exists: false } },
|
|
3071
|
+
{ bookingKind: null },
|
|
3072
|
+
{
|
|
3073
|
+
approvalStatus: EnumAdApprovalStatus3.APPROVED,
|
|
3074
|
+
bookingKind: EnumAdBookingSlotKind3.RESERVED
|
|
3075
|
+
},
|
|
3076
|
+
{
|
|
3077
|
+
approvalStatus: EnumAdApprovalStatus3.APPROVED,
|
|
3078
|
+
bookingKind: EnumAdBookingSlotKind3.PAID,
|
|
3079
|
+
paymentStatus: EnumAdPaymentStatus2.PAID
|
|
3080
|
+
}
|
|
3081
|
+
]
|
|
3082
|
+
};
|
|
3083
|
+
const awaitingApprovalResult = await AdModel.updateMany(
|
|
3084
|
+
{
|
|
3085
|
+
$nor: eligibleBooking.$or,
|
|
3086
|
+
bookingKind: { $in: Object.values(EnumAdBookingSlotKind3) },
|
|
3087
|
+
end: { $gt: now },
|
|
3088
|
+
status: EnumAdStatus2.ACTIVE
|
|
3089
|
+
},
|
|
3090
|
+
{ $set: { status: EnumAdStatus2.PAUSED } }
|
|
3091
|
+
);
|
|
2746
3092
|
const activeResult = await AdModel.updateMany(
|
|
2747
3093
|
{
|
|
2748
3094
|
end: { $gt: now },
|
|
2749
3095
|
start: { $lte: now },
|
|
2750
|
-
status: { $ne: EnumAdStatus2.ACTIVE }
|
|
3096
|
+
status: { $ne: EnumAdStatus2.ACTIVE },
|
|
3097
|
+
...eligibleBooking
|
|
2751
3098
|
},
|
|
2752
3099
|
{ $set: { status: EnumAdStatus2.ACTIVE } }
|
|
2753
3100
|
);
|
|
@@ -2756,20 +3103,20 @@ async function updateAdStatuses() {
|
|
|
2756
3103
|
{ $set: { status: EnumAdStatus2.PAUSED } }
|
|
2757
3104
|
);
|
|
2758
3105
|
console.log(
|
|
2759
|
-
`\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
|
|
3106
|
+
`\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
|
|
2760
3107
|
);
|
|
2761
3108
|
}
|
|
2762
3109
|
|
|
2763
3110
|
// src/service/objectIdToString.ts
|
|
2764
|
-
import
|
|
3111
|
+
import mongoose34 from "mongoose";
|
|
2765
3112
|
function isValidObjectId(value) {
|
|
2766
|
-
return
|
|
3113
|
+
return mongoose34.Types.ObjectId.isValid(value);
|
|
2767
3114
|
}
|
|
2768
3115
|
function convertObjectIdsToStrings(obj) {
|
|
2769
3116
|
if (obj === null || obj === void 0) {
|
|
2770
3117
|
return obj;
|
|
2771
3118
|
}
|
|
2772
|
-
if (obj instanceof
|
|
3119
|
+
if (obj instanceof mongoose34.Types.ObjectId) {
|
|
2773
3120
|
return obj.toString();
|
|
2774
3121
|
}
|
|
2775
3122
|
if (obj instanceof Date) {
|
|
@@ -3449,7 +3796,9 @@ async function findUserVendor(userId, logLabel) {
|
|
|
3449
3796
|
"owner.userId": userId
|
|
3450
3797
|
}).lean().exec();
|
|
3451
3798
|
if (!vendor) {
|
|
3452
|
-
console.warn(
|
|
3799
|
+
console.warn(
|
|
3800
|
+
`[${logLabel}] Vendor not found for id=${user.vendor}, userId=${userId}`
|
|
3801
|
+
);
|
|
3453
3802
|
return null;
|
|
3454
3803
|
}
|
|
3455
3804
|
return vendor;
|
|
@@ -3502,6 +3851,7 @@ async function downgradeVendorProFeatures(userId, licenceType) {
|
|
|
3502
3851
|
await applyVendorDowngrade(vendor, userId);
|
|
3503
3852
|
} catch (error) {
|
|
3504
3853
|
console.error("[downgradeVendorProFeatures] Failed:", error);
|
|
3854
|
+
throw error;
|
|
3505
3855
|
}
|
|
3506
3856
|
}
|
|
3507
3857
|
async function applyVendorRestore(vendor, ownerUserId) {
|
|
@@ -3548,6 +3898,7 @@ async function restoreVendorProFeatures(userId, licenceType) {
|
|
|
3548
3898
|
await applyVendorRestore(vendor, userId);
|
|
3549
3899
|
} catch (error) {
|
|
3550
3900
|
console.error("[restoreVendorProFeatures] Failed:", error);
|
|
3901
|
+
throw error;
|
|
3551
3902
|
}
|
|
3552
3903
|
}
|
|
3553
3904
|
var vendorLicences = [
|
|
@@ -3557,14 +3908,25 @@ var vendorLicences = [
|
|
|
3557
3908
|
];
|
|
3558
3909
|
function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
|
|
3559
3910
|
const stripe = user.stripe;
|
|
3560
|
-
if (!stripe
|
|
3911
|
+
if (!stripe || stripe.currentPlan !== licenceType) {
|
|
3561
3912
|
return false;
|
|
3562
3913
|
}
|
|
3563
|
-
|
|
3914
|
+
const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? dayjs4(stripe.paymentGracePeriodEndsAt) : null;
|
|
3915
|
+
const hasActivePaymentGracePeriod = (stripe.status === EnumSubscriptionStatus3.PAST_DUE || stripe.status === EnumSubscriptionStatus3.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
|
|
3916
|
+
if (hasActivePaymentGracePeriod) {
|
|
3564
3917
|
return true;
|
|
3565
3918
|
}
|
|
3919
|
+
if (!stripe.subscriptionId) {
|
|
3920
|
+
return false;
|
|
3921
|
+
}
|
|
3922
|
+
if (stripe.status !== EnumSubscriptionStatus3.ACTIVE) {
|
|
3923
|
+
return false;
|
|
3924
|
+
}
|
|
3925
|
+
if (!stripe.endDate) {
|
|
3926
|
+
return false;
|
|
3927
|
+
}
|
|
3566
3928
|
const paidThrough = dayjs4(stripe.endDate);
|
|
3567
|
-
return
|
|
3929
|
+
return paidThrough.isValid() && paidThrough.isAfter(now);
|
|
3568
3930
|
}
|
|
3569
3931
|
async function handleVendorLicenceCompliance(user, now) {
|
|
3570
3932
|
if (!user.licences || !user.vendor) {
|
|
@@ -3639,9 +4001,23 @@ async function vendorOwnerHasProLicence(vendorId) {
|
|
|
3639
4001
|
if (!vendor) {
|
|
3640
4002
|
return false;
|
|
3641
4003
|
}
|
|
3642
|
-
const owner = await UserModel.findById(vendor.owner.userId, {
|
|
4004
|
+
const owner = await UserModel.findById(vendor.owner.userId, {
|
|
4005
|
+
licences: 1,
|
|
4006
|
+
stripe: 1
|
|
4007
|
+
}).lean().exec();
|
|
4008
|
+
if (!owner) {
|
|
4009
|
+
return false;
|
|
4010
|
+
}
|
|
4011
|
+
const now = dayjs4();
|
|
4012
|
+
const effectiveVendorLicences = owner.licences?.filter(
|
|
4013
|
+
(licence) => licence?.licenceType && (dayjs4(licence.expiryDate).isAfter(now) || isProtectedByCurrentStripeSubscription(
|
|
4014
|
+
owner,
|
|
4015
|
+
licence.licenceType,
|
|
4016
|
+
now
|
|
4017
|
+
))
|
|
4018
|
+
);
|
|
3643
4019
|
const highestVendorLicence = getHighestLicenceForCategory(
|
|
3644
|
-
|
|
4020
|
+
effectiveVendorLicences,
|
|
3645
4021
|
"vendor" /* VENDOR */
|
|
3646
4022
|
);
|
|
3647
4023
|
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[EnumUserLicence9.PRO_VENDOR];
|
|
@@ -4058,8 +4434,13 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4058
4434
|
}
|
|
4059
4435
|
export {
|
|
4060
4436
|
ACTIVE_NOT_DELETED_FILTER,
|
|
4437
|
+
AD_BILLING_CATALOG_COLLECTION_NAME,
|
|
4061
4438
|
APP_SETTINGS_ID,
|
|
4439
|
+
AdBillingCatalogModel,
|
|
4440
|
+
AdBookingModel,
|
|
4441
|
+
AdImpressionModel,
|
|
4062
4442
|
AdModel,
|
|
4443
|
+
AdSettingsModel,
|
|
4063
4444
|
AffiliateModel,
|
|
4064
4445
|
AppSettingModel,
|
|
4065
4446
|
BILLING_CATALOG_COLLECTION_NAME,
|
|
@@ -4069,6 +4450,7 @@ export {
|
|
|
4069
4450
|
ChatReportModel,
|
|
4070
4451
|
ContactDetailsSchema,
|
|
4071
4452
|
CouponModel,
|
|
4453
|
+
DEFAULT_AD_SETTINGS,
|
|
4072
4454
|
EnumPubSubEvents,
|
|
4073
4455
|
EventInfoModel,
|
|
4074
4456
|
EventModel,
|
|
@@ -4136,7 +4518,7 @@ export {
|
|
|
4136
4518
|
locationGeoSchema,
|
|
4137
4519
|
locationsSchema,
|
|
4138
4520
|
mapVendorLicenceToSubscriptionRewardType,
|
|
4139
|
-
|
|
4521
|
+
mongoose33 as mongoose,
|
|
4140
4522
|
normalizeAffiliatePromoCodes,
|
|
4141
4523
|
normalizePromoCode,
|
|
4142
4524
|
notifyUsers,
|
|
@@ -4153,6 +4535,7 @@ export {
|
|
|
4153
4535
|
resourceRelationsSchema,
|
|
4154
4536
|
restoreVendorProFeatures,
|
|
4155
4537
|
saveNotificationsInDb,
|
|
4538
|
+
schemaAdresource,
|
|
4156
4539
|
sendDeactivationNotification,
|
|
4157
4540
|
sendLicenseReminder,
|
|
4158
4541
|
sendPushNotifications,
|