@timardex/cluemart-server-shared 2.1.0 → 2.1.2
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 +795 -415
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +56 -6
- package/dist/index.d.ts +56 -6
- package/dist/index.mjs +626 -239
- 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 +770 -412
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +9 -5
- package/dist/service/index.d.ts +9 -5
- package/dist/service/index.mjs +104 -28
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-BEUTBR4H.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -31,8 +31,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ACTIVE_NOT_DELETED_FILTER: () => ACTIVE_NOT_DELETED_FILTER,
|
|
34
|
+
AD_BILLING_CATALOG_COLLECTION_NAME: () => AD_BILLING_CATALOG_COLLECTION_NAME,
|
|
34
35
|
APP_SETTINGS_ID: () => APP_SETTINGS_ID,
|
|
36
|
+
AdBillingCatalogModel: () => AdBillingCatalogModel,
|
|
37
|
+
AdBookingModel: () => AdBookingModel,
|
|
38
|
+
AdImpressionModel: () => AdImpressionModel,
|
|
35
39
|
AdModel: () => AdModel,
|
|
40
|
+
AdSettingsModel: () => AdSettingsModel,
|
|
36
41
|
AffiliateModel: () => AffiliateModel,
|
|
37
42
|
AppSettingModel: () => AppSettingModel,
|
|
38
43
|
BILLING_CATALOG_COLLECTION_NAME: () => BILLING_CATALOG_COLLECTION_NAME,
|
|
@@ -42,6 +47,7 @@ __export(index_exports, {
|
|
|
42
47
|
ChatReportModel: () => ChatReportModel,
|
|
43
48
|
ContactDetailsSchema: () => ContactDetailsSchema,
|
|
44
49
|
CouponModel: () => CouponModel,
|
|
50
|
+
DEFAULT_AD_SETTINGS: () => DEFAULT_AD_SETTINGS,
|
|
45
51
|
EnumPubSubEvents: () => EnumPubSubEvents,
|
|
46
52
|
EventInfoModel: () => EventInfoModel,
|
|
47
53
|
EventModel: () => EventModel,
|
|
@@ -109,7 +115,7 @@ __export(index_exports, {
|
|
|
109
115
|
locationGeoSchema: () => locationGeoSchema,
|
|
110
116
|
locationsSchema: () => locationsSchema,
|
|
111
117
|
mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
|
|
112
|
-
mongoose: () =>
|
|
118
|
+
mongoose: () => import_mongoose36.default,
|
|
113
119
|
normalizeAffiliatePromoCodes: () => normalizeAffiliatePromoCodes,
|
|
114
120
|
normalizePromoCode: () => normalizePromoCode,
|
|
115
121
|
notifyUsers: () => notifyUsers,
|
|
@@ -126,6 +132,7 @@ __export(index_exports, {
|
|
|
126
132
|
resourceRelationsSchema: () => resourceRelationsSchema,
|
|
127
133
|
restoreVendorProFeatures: () => restoreVendorProFeatures,
|
|
128
134
|
saveNotificationsInDb: () => saveNotificationsInDb,
|
|
135
|
+
schemaAdresource: () => schemaAdresource,
|
|
129
136
|
sendDeactivationNotification: () => sendDeactivationNotification,
|
|
130
137
|
sendLicenseReminder: () => sendLicenseReminder,
|
|
131
138
|
sendPushNotifications: () => sendPushNotifications,
|
|
@@ -178,9 +185,30 @@ var schemaAdresource = new MongooseSchema({
|
|
|
178
185
|
var schema = new MongooseSchema(
|
|
179
186
|
{
|
|
180
187
|
active: { default: true, type: Boolean },
|
|
188
|
+
adminManaged: { default: false, type: Boolean },
|
|
189
|
+
approvalStatus: {
|
|
190
|
+
enum: Object.values(import_cluemart_shared.EnumAdApprovalStatus),
|
|
191
|
+
required: false,
|
|
192
|
+
type: String
|
|
193
|
+
},
|
|
194
|
+
bookingIds: {
|
|
195
|
+
default: void 0,
|
|
196
|
+
ref: "AdBooking",
|
|
197
|
+
type: [import_mongoose.default.Schema.Types.ObjectId]
|
|
198
|
+
},
|
|
199
|
+
bookingKind: {
|
|
200
|
+
enum: Object.values(import_cluemart_shared.EnumAdBookingSlotKind),
|
|
201
|
+
required: false,
|
|
202
|
+
type: String
|
|
203
|
+
},
|
|
181
204
|
clicks: { default: 0, required: true, type: Number },
|
|
182
205
|
end: { required: true, type: Date },
|
|
183
206
|
impressions: { default: 0, required: true, type: Number },
|
|
207
|
+
paymentStatus: {
|
|
208
|
+
enum: Object.values(import_cluemart_shared.EnumAdPaymentStatus),
|
|
209
|
+
required: false,
|
|
210
|
+
type: String
|
|
211
|
+
},
|
|
184
212
|
resource: { required: true, type: schemaAdresource },
|
|
185
213
|
showOn: {
|
|
186
214
|
default: [import_cluemart_shared.EnumAdShowOn.FRONT_PAGE],
|
|
@@ -212,20 +240,282 @@ schema.index({
|
|
|
212
240
|
// eslint-disable-next-line sort-keys
|
|
213
241
|
start: -1
|
|
214
242
|
});
|
|
243
|
+
schema.index(
|
|
244
|
+
{ bookingIds: 1 },
|
|
245
|
+
{
|
|
246
|
+
partialFilterExpression: { bookingIds: { $exists: true } },
|
|
247
|
+
unique: true
|
|
248
|
+
}
|
|
249
|
+
);
|
|
215
250
|
var AdModel = import_mongoose.default.models.Ad || import_mongoose.default.model("Ad", schema);
|
|
216
251
|
|
|
217
|
-
// src/mongoose/
|
|
218
|
-
var import_cluemart_shared2 = require("@timardex/cluemart-shared");
|
|
252
|
+
// src/mongoose/AdBillingCatalog.ts
|
|
219
253
|
var import_mongoose2 = __toESM(require("mongoose"));
|
|
220
|
-
var
|
|
254
|
+
var AD_BILLING_CATALOG_COLLECTION_NAME = "adBillingCatalog";
|
|
255
|
+
var schema2 = new import_mongoose2.default.Schema(
|
|
256
|
+
{
|
|
257
|
+
active: { default: true, required: true, type: Boolean },
|
|
258
|
+
currency: {
|
|
259
|
+
default: "nzd",
|
|
260
|
+
enum: ["nzd"],
|
|
261
|
+
immutable: true,
|
|
262
|
+
required: true,
|
|
263
|
+
type: String
|
|
264
|
+
},
|
|
265
|
+
key: {
|
|
266
|
+
enum: ["front_page_day", "market_search_day"],
|
|
267
|
+
immutable: true,
|
|
268
|
+
required: true,
|
|
269
|
+
type: String,
|
|
270
|
+
unique: true
|
|
271
|
+
},
|
|
272
|
+
revision: { default: 1, min: 1, required: true, type: Number },
|
|
273
|
+
unitAmount: {
|
|
274
|
+
min: 1,
|
|
275
|
+
required: true,
|
|
276
|
+
type: Number,
|
|
277
|
+
validate: {
|
|
278
|
+
message: "Daily ad price must be a positive integer amount of cents.",
|
|
279
|
+
validator: Number.isInteger
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
{ collection: AD_BILLING_CATALOG_COLLECTION_NAME, timestamps: true }
|
|
284
|
+
);
|
|
285
|
+
var AdBillingCatalogModel = import_mongoose2.default.models.AdBillingCatalog || import_mongoose2.default.model(
|
|
286
|
+
"AdBillingCatalog",
|
|
287
|
+
schema2,
|
|
288
|
+
AD_BILLING_CATALOG_COLLECTION_NAME
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
// src/mongoose/AdBooking.ts
|
|
292
|
+
var import_cluemart_shared2 = require("@timardex/cluemart-shared");
|
|
293
|
+
var import_mongoose3 = __toESM(require("mongoose"));
|
|
294
|
+
var liveStates = [
|
|
295
|
+
import_cluemart_shared2.EnumAdBookingState.HELD,
|
|
296
|
+
import_cluemart_shared2.EnumAdBookingState.PENDING_APPROVAL,
|
|
297
|
+
import_cluemart_shared2.EnumAdBookingState.APPROVED
|
|
298
|
+
];
|
|
299
|
+
var placementValues = [import_cluemart_shared2.EnumAdShowOn.FRONT_PAGE, import_cluemart_shared2.EnumAdShowOn.MARKET_SEARCH];
|
|
300
|
+
var schema3 = new import_mongoose3.default.Schema(
|
|
301
|
+
{
|
|
302
|
+
adId: { default: null, ref: "Ad", type: String },
|
|
303
|
+
approvalStatus: {
|
|
304
|
+
default: import_cluemart_shared2.EnumAdApprovalStatus.PENDING,
|
|
305
|
+
enum: Object.values(import_cluemart_shared2.EnumAdApprovalStatus),
|
|
306
|
+
required: true,
|
|
307
|
+
type: String
|
|
308
|
+
},
|
|
309
|
+
checkoutAttemptId: { default: null, type: String },
|
|
310
|
+
currency: { default: null, lowercase: true, type: String },
|
|
311
|
+
dayKey: {
|
|
312
|
+
immutable: true,
|
|
313
|
+
match: /^\d{4}-\d{2}-\d{2}$/,
|
|
314
|
+
required: true,
|
|
315
|
+
type: String
|
|
316
|
+
},
|
|
317
|
+
entitlementClaimKey: { default: null, type: String },
|
|
318
|
+
entitlementSource: {
|
|
319
|
+
default: null,
|
|
320
|
+
enum: Object.values(import_cluemart_shared2.EnumAdEntitlementSource),
|
|
321
|
+
type: String
|
|
322
|
+
},
|
|
323
|
+
expiresAt: { default: null, type: Date },
|
|
324
|
+
placement: {
|
|
325
|
+
enum: placementValues,
|
|
326
|
+
immutable: true,
|
|
327
|
+
required: true,
|
|
328
|
+
type: String
|
|
329
|
+
},
|
|
330
|
+
purchaseKey: { default: null, immutable: true, type: String },
|
|
331
|
+
region: {
|
|
332
|
+
immutable: true,
|
|
333
|
+
lowercase: true,
|
|
334
|
+
required: true,
|
|
335
|
+
trim: true,
|
|
336
|
+
type: String
|
|
337
|
+
},
|
|
338
|
+
resource: { required: true, type: schemaAdresource },
|
|
339
|
+
slotKind: {
|
|
340
|
+
enum: Object.values(import_cluemart_shared2.EnumAdBookingSlotKind),
|
|
341
|
+
immutable: true,
|
|
342
|
+
required: true,
|
|
343
|
+
type: String
|
|
344
|
+
},
|
|
345
|
+
slotNumber: { immutable: true, min: 1, required: true, type: Number },
|
|
346
|
+
state: {
|
|
347
|
+
default: import_cluemart_shared2.EnumAdBookingState.HELD,
|
|
348
|
+
enum: Object.values(import_cluemart_shared2.EnumAdBookingState),
|
|
349
|
+
required: true,
|
|
350
|
+
type: String
|
|
351
|
+
},
|
|
352
|
+
stripeCheckoutSessionId: { default: null, type: String },
|
|
353
|
+
stripePaymentIntentId: { default: null, type: String },
|
|
354
|
+
unitAmount: { default: null, min: 1, type: Number },
|
|
355
|
+
userId: { immutable: true, ref: "User", required: true, type: String }
|
|
356
|
+
},
|
|
357
|
+
{ timestamps: true }
|
|
358
|
+
);
|
|
359
|
+
schema3.pre(
|
|
360
|
+
"validate",
|
|
361
|
+
function validateSlot() {
|
|
362
|
+
if (!Number.isInteger(this.slotNumber)) {
|
|
363
|
+
this.invalidate("slotNumber", "Ad booking slot must be an integer.");
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const maximum = this.slotKind === import_cluemart_shared2.EnumAdBookingSlotKind.PAID ? 30 : 7;
|
|
367
|
+
if (this.slotNumber < 1 || this.slotNumber > maximum) {
|
|
368
|
+
this.invalidate(
|
|
369
|
+
"slotNumber",
|
|
370
|
+
`Ad booking slot must be between 1 and ${maximum}.`
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
if (this.slotKind === import_cluemart_shared2.EnumAdBookingSlotKind.PAID && this.state !== import_cluemart_shared2.EnumAdBookingState.HELD && this.state !== import_cluemart_shared2.EnumAdBookingState.FAILED && this.state !== import_cluemart_shared2.EnumAdBookingState.CANCELLED && (!this.unitAmount || !this.currency)) {
|
|
374
|
+
this.invalidate(
|
|
375
|
+
"unitAmount",
|
|
376
|
+
"Paid ad booking must retain its checkout price."
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
schema3.index(
|
|
382
|
+
{ region: 1, placement: 1, dayKey: 1, slotKind: 1, slotNumber: 1 },
|
|
383
|
+
{ unique: true, partialFilterExpression: { state: { $in: liveStates } } }
|
|
384
|
+
);
|
|
385
|
+
schema3.index({ userId: 1, dayKey: -1 });
|
|
386
|
+
schema3.index(
|
|
387
|
+
{ checkoutAttemptId: 1 },
|
|
388
|
+
{
|
|
389
|
+
partialFilterExpression: { checkoutAttemptId: { $type: "string" } },
|
|
390
|
+
unique: true
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
schema3.index(
|
|
394
|
+
{ purchaseKey: 1 },
|
|
395
|
+
{
|
|
396
|
+
partialFilterExpression: {
|
|
397
|
+
purchaseKey: { $type: "string" },
|
|
398
|
+
state: { $in: liveStates }
|
|
399
|
+
},
|
|
400
|
+
unique: true
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
schema3.index(
|
|
404
|
+
{ entitlementClaimKey: 1 },
|
|
405
|
+
{
|
|
406
|
+
partialFilterExpression: {
|
|
407
|
+
entitlementClaimKey: { $type: "string" },
|
|
408
|
+
state: { $in: liveStates }
|
|
409
|
+
},
|
|
410
|
+
unique: true
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
schema3.index(
|
|
414
|
+
{ adId: 1, region: 1, placement: 1, dayKey: 1 },
|
|
415
|
+
{
|
|
416
|
+
partialFilterExpression: {
|
|
417
|
+
entitlementSource: import_cluemart_shared2.EnumAdEntitlementSource.ADMIN,
|
|
418
|
+
state: { $in: liveStates }
|
|
419
|
+
},
|
|
420
|
+
unique: true
|
|
421
|
+
}
|
|
422
|
+
);
|
|
423
|
+
schema3.index(
|
|
424
|
+
{ stripeCheckoutSessionId: 1 },
|
|
425
|
+
{
|
|
426
|
+
partialFilterExpression: { stripeCheckoutSessionId: { $type: "string" } },
|
|
427
|
+
unique: true
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
var AdBookingModel = import_mongoose3.default.models.AdBooking || import_mongoose3.default.model("AdBooking", schema3);
|
|
431
|
+
|
|
432
|
+
// src/mongoose/AdImpression.ts
|
|
433
|
+
var import_cluemart_shared3 = require("@timardex/cluemart-shared");
|
|
434
|
+
var import_mongoose4 = __toESM(require("mongoose"));
|
|
435
|
+
var schema4 = new import_mongoose4.default.Schema(
|
|
436
|
+
{
|
|
437
|
+
_id: { required: true, type: String },
|
|
438
|
+
adId: { required: true, type: String },
|
|
439
|
+
dayKey: { match: /^\d{4}-\d{2}-\d{2}$/, required: true, type: String },
|
|
440
|
+
placement: {
|
|
441
|
+
enum: [import_cluemart_shared3.EnumAdShowOn.FRONT_PAGE, import_cluemart_shared3.EnumAdShowOn.MARKET_SEARCH],
|
|
442
|
+
required: true,
|
|
443
|
+
type: String
|
|
444
|
+
},
|
|
445
|
+
recordedAt: { default: Date.now, required: true, type: Date },
|
|
446
|
+
viewerSlotKey: { required: true, type: String }
|
|
447
|
+
},
|
|
448
|
+
{ collection: "adImpressions" }
|
|
449
|
+
);
|
|
450
|
+
schema4.index({ adId: 1, recordedAt: 1 });
|
|
451
|
+
schema4.index({ adId: 1, placement: 1, viewerSlotKey: 1 }, { unique: true });
|
|
452
|
+
schema4.index({ recordedAt: 1 }, { expireAfterSeconds: 7 * 24 * 60 * 60 });
|
|
453
|
+
schema4.index({ dayKey: 1, placement: 1, adId: 1 });
|
|
454
|
+
var AdImpressionModel = import_mongoose4.default.models.AdImpression || import_mongoose4.default.model("AdImpression", schema4, "adImpressions");
|
|
455
|
+
|
|
456
|
+
// src/mongoose/AdSettings.ts
|
|
457
|
+
var import_mongoose5 = __toESM(require("mongoose"));
|
|
458
|
+
var DEFAULT_AD_SETTINGS = {
|
|
459
|
+
_id: "default",
|
|
460
|
+
approvalRequired: true,
|
|
461
|
+
minAppearancesPerHour: 12,
|
|
462
|
+
paidSlotsPerPlacement: 30,
|
|
463
|
+
reservedSlotsPerPlacement: 7,
|
|
464
|
+
rotationSeconds: 8
|
|
465
|
+
};
|
|
466
|
+
var schema5 = new import_mongoose5.default.Schema(
|
|
467
|
+
{
|
|
468
|
+
_id: { default: "default", enum: ["default"], type: String },
|
|
469
|
+
approvalRequired: { default: true, required: true, type: Boolean },
|
|
470
|
+
minAppearancesPerHour: {
|
|
471
|
+
default: 12,
|
|
472
|
+
min: 1,
|
|
473
|
+
required: true,
|
|
474
|
+
type: Number,
|
|
475
|
+
validate: {
|
|
476
|
+
message: "Minimum appearances per hour must be a whole number.",
|
|
477
|
+
validator: Number.isInteger
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
paidSlotsPerPlacement: {
|
|
481
|
+
default: 30,
|
|
482
|
+
enum: [30],
|
|
483
|
+
immutable: true,
|
|
484
|
+
type: Number
|
|
485
|
+
},
|
|
486
|
+
reservedSlotsPerPlacement: {
|
|
487
|
+
default: 7,
|
|
488
|
+
enum: [7],
|
|
489
|
+
immutable: true,
|
|
490
|
+
type: Number
|
|
491
|
+
},
|
|
492
|
+
rotationSeconds: { default: 8, enum: [8], immutable: true, type: Number }
|
|
493
|
+
},
|
|
494
|
+
{ collection: "adSettings", timestamps: true }
|
|
495
|
+
);
|
|
496
|
+
schema5.pre("validate", function validateRotationCapacity() {
|
|
497
|
+
const availableRotationsPerHour = 3600 / this.rotationSeconds;
|
|
498
|
+
if (this.minAppearancesPerHour * (this.paidSlotsPerPlacement + this.reservedSlotsPerPlacement) > availableRotationsPerHour) {
|
|
499
|
+
this.invalidate(
|
|
500
|
+
"minAppearancesPerHour",
|
|
501
|
+
"The configured minimum exceeds the available rotation slots."
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
var AdSettingsModel = import_mongoose5.default.models.AdSettings || import_mongoose5.default.model("AdSettings", schema5, "adSettings");
|
|
506
|
+
|
|
507
|
+
// src/mongoose/BillingCatalog.ts
|
|
508
|
+
var import_cluemart_shared4 = require("@timardex/cluemart-shared");
|
|
509
|
+
var import_mongoose6 = __toESM(require("mongoose"));
|
|
510
|
+
var MongooseSchema2 = import_mongoose6.default.Schema;
|
|
221
511
|
var BILLING_CATALOG_COLLECTION_NAME = "billingCatalog";
|
|
222
512
|
var paidVendorLicences = [
|
|
223
|
-
|
|
224
|
-
|
|
513
|
+
import_cluemart_shared4.EnumUserLicence.PRO_VENDOR,
|
|
514
|
+
import_cluemart_shared4.EnumUserLicence.PRO_PLUS_VENDOR
|
|
225
515
|
];
|
|
226
516
|
var supportedBillingPeriods = [
|
|
227
|
-
|
|
228
|
-
|
|
517
|
+
import_cluemart_shared4.EnumBillingPeriod.MONTHLY_CANCEL_ANYTIME,
|
|
518
|
+
import_cluemart_shared4.EnumBillingPeriod.YEARLY_ANNUAL_BILLED
|
|
229
519
|
];
|
|
230
520
|
var unitAmountField = {
|
|
231
521
|
min: 1,
|
|
@@ -237,8 +527,8 @@ var unitAmountField = {
|
|
|
237
527
|
}
|
|
238
528
|
};
|
|
239
529
|
var currencyField = {
|
|
240
|
-
default:
|
|
241
|
-
enum: [
|
|
530
|
+
default: import_cluemart_shared4.BILLING_CATALOG_CURRENCY,
|
|
531
|
+
enum: [import_cluemart_shared4.BILLING_CATALOG_CURRENCY],
|
|
242
532
|
immutable: true,
|
|
243
533
|
lowercase: true,
|
|
244
534
|
required: true,
|
|
@@ -264,7 +554,7 @@ var priceHistorySchema = new MongooseSchema2(
|
|
|
264
554
|
default: null,
|
|
265
555
|
ref: "User",
|
|
266
556
|
required: false,
|
|
267
|
-
type:
|
|
557
|
+
type: import_mongoose6.default.Schema.Types.ObjectId
|
|
268
558
|
},
|
|
269
559
|
currency: currencyField,
|
|
270
560
|
effectiveFrom: { required: true, type: Date },
|
|
@@ -275,7 +565,7 @@ var priceHistorySchema = new MongooseSchema2(
|
|
|
275
565
|
},
|
|
276
566
|
{ _id: false }
|
|
277
567
|
);
|
|
278
|
-
var
|
|
568
|
+
var schema6 = new MongooseSchema2(
|
|
279
569
|
{
|
|
280
570
|
active: { default: true, required: true, type: Boolean },
|
|
281
571
|
billingPeriod: {
|
|
@@ -287,7 +577,7 @@ var schema2 = new MongooseSchema2(
|
|
|
287
577
|
currency: currencyField,
|
|
288
578
|
effectiveFrom: { default: Date.now, required: true, type: Date },
|
|
289
579
|
key: {
|
|
290
|
-
enum:
|
|
580
|
+
enum: import_cluemart_shared4.BILLING_CATALOG_KEYS,
|
|
291
581
|
immutable: true,
|
|
292
582
|
required: true,
|
|
293
583
|
type: String,
|
|
@@ -331,7 +621,7 @@ var schema2 = new MongooseSchema2(
|
|
|
331
621
|
default: null,
|
|
332
622
|
ref: "User",
|
|
333
623
|
required: false,
|
|
334
|
-
type:
|
|
624
|
+
type: import_mongoose6.default.Schema.Types.ObjectId
|
|
335
625
|
}
|
|
336
626
|
},
|
|
337
627
|
{
|
|
@@ -340,30 +630,30 @@ var schema2 = new MongooseSchema2(
|
|
|
340
630
|
timestamps: true
|
|
341
631
|
}
|
|
342
632
|
);
|
|
343
|
-
|
|
344
|
-
if (!(0,
|
|
633
|
+
schema6.pre("validate", function validateDefinition() {
|
|
634
|
+
if (!(0, import_cluemart_shared4.billingCatalogDefinitionMatches)(this)) {
|
|
345
635
|
this.invalidate(
|
|
346
636
|
"key",
|
|
347
637
|
"Billing catalogue key does not match its licence and billing period."
|
|
348
638
|
);
|
|
349
639
|
}
|
|
350
640
|
});
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
641
|
+
schema6.index({ billingPeriod: 1, licenceType: 1 }, { unique: true });
|
|
642
|
+
schema6.index({ active: 1, licenceType: 1 });
|
|
643
|
+
schema6.index(
|
|
354
644
|
{ stripePriceId: 1 },
|
|
355
645
|
{
|
|
356
646
|
partialFilterExpression: { stripePriceId: { $type: "string" } },
|
|
357
647
|
unique: true
|
|
358
648
|
}
|
|
359
649
|
);
|
|
360
|
-
var BillingCatalogModel =
|
|
650
|
+
var BillingCatalogModel = import_mongoose6.default.models.BillingCatalogEntry || import_mongoose6.default.model(
|
|
361
651
|
"BillingCatalogEntry",
|
|
362
|
-
|
|
652
|
+
schema6,
|
|
363
653
|
BILLING_CATALOG_COLLECTION_NAME
|
|
364
654
|
);
|
|
365
655
|
function buildInitialBillingCatalogEntries(now = /* @__PURE__ */ new Date()) {
|
|
366
|
-
return
|
|
656
|
+
return import_cluemart_shared4.INITIAL_BILLING_CATALOG.map((entry) => ({
|
|
367
657
|
active: entry.active,
|
|
368
658
|
billingPeriod: entry.billingPeriod,
|
|
369
659
|
currency: entry.currency,
|
|
@@ -380,20 +670,20 @@ function buildInitialBillingCatalogEntries(now = /* @__PURE__ */ new Date()) {
|
|
|
380
670
|
}));
|
|
381
671
|
}
|
|
382
672
|
function getBillingCatalogDefinition(key) {
|
|
383
|
-
return
|
|
673
|
+
return import_cluemart_shared4.BILLING_CATALOG_DEFINITIONS[key];
|
|
384
674
|
}
|
|
385
675
|
|
|
386
676
|
// src/mongoose/chat/Chat.ts
|
|
387
|
-
var
|
|
388
|
-
var
|
|
389
|
-
var MongooseSchema3 =
|
|
677
|
+
var import_cluemart_shared5 = require("@timardex/cluemart-shared");
|
|
678
|
+
var import_mongoose7 = __toESM(require("mongoose"));
|
|
679
|
+
var MongooseSchema3 = import_mongoose7.default.Schema;
|
|
390
680
|
var MessageReplyPreviewSchema = new MongooseSchema3(
|
|
391
681
|
{
|
|
392
682
|
contentPreview: { required: true, type: String },
|
|
393
683
|
senderId: {
|
|
394
684
|
ref: "User",
|
|
395
685
|
required: true,
|
|
396
|
-
type:
|
|
686
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
397
687
|
},
|
|
398
688
|
senderName: { required: true, type: String }
|
|
399
689
|
},
|
|
@@ -405,7 +695,7 @@ var MessageReactionSchema = new MongooseSchema3(
|
|
|
405
695
|
userId: {
|
|
406
696
|
ref: "User",
|
|
407
697
|
required: true,
|
|
408
|
-
type:
|
|
698
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
409
699
|
}
|
|
410
700
|
},
|
|
411
701
|
{ _id: false }
|
|
@@ -416,7 +706,7 @@ var MessageSeenSchema = new MongooseSchema3(
|
|
|
416
706
|
userId: {
|
|
417
707
|
ref: "User",
|
|
418
708
|
required: true,
|
|
419
|
-
type:
|
|
709
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
420
710
|
}
|
|
421
711
|
},
|
|
422
712
|
{ _id: false }
|
|
@@ -432,13 +722,13 @@ var MessageSchema = new MongooseSchema3(
|
|
|
432
722
|
replyToMessageId: {
|
|
433
723
|
ref: "Chat.messages",
|
|
434
724
|
required: false,
|
|
435
|
-
type:
|
|
725
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
436
726
|
},
|
|
437
727
|
seenBy: { default: [], required: false, type: [MessageSeenSchema] },
|
|
438
728
|
senderId: {
|
|
439
729
|
ref: "User",
|
|
440
730
|
required: true,
|
|
441
|
-
type:
|
|
731
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
442
732
|
}
|
|
443
733
|
},
|
|
444
734
|
{ timestamps: true }
|
|
@@ -451,7 +741,7 @@ var ParticipantSchema = new MongooseSchema3(
|
|
|
451
741
|
userId: {
|
|
452
742
|
ref: "User",
|
|
453
743
|
required: true,
|
|
454
|
-
type:
|
|
744
|
+
type: import_mongoose7.default.Schema.Types.ObjectId
|
|
455
745
|
},
|
|
456
746
|
userName: { required: true, type: String }
|
|
457
747
|
},
|
|
@@ -464,7 +754,7 @@ var ChatSchema = new MongooseSchema3(
|
|
|
464
754
|
chatDescription: { required: false, type: String },
|
|
465
755
|
chatName: { required: true, type: String },
|
|
466
756
|
chatType: {
|
|
467
|
-
enum: Object.values(
|
|
757
|
+
enum: Object.values(import_cluemart_shared5.EnumChatType),
|
|
468
758
|
required: true,
|
|
469
759
|
type: String
|
|
470
760
|
},
|
|
@@ -482,17 +772,17 @@ ChatSchema.index({
|
|
|
482
772
|
"participants.userId": 1,
|
|
483
773
|
updatedAt: -1
|
|
484
774
|
});
|
|
485
|
-
var ChatModel =
|
|
775
|
+
var ChatModel = import_mongoose7.default.models.Chat || import_mongoose7.default.model("Chat", ChatSchema);
|
|
486
776
|
|
|
487
777
|
// src/mongoose/chat/ChatReport.ts
|
|
488
|
-
var
|
|
489
|
-
var
|
|
490
|
-
var MongooseSchema4 =
|
|
778
|
+
var import_cluemart_shared6 = require("@timardex/cluemart-shared");
|
|
779
|
+
var import_mongoose8 = __toESM(require("mongoose"));
|
|
780
|
+
var MongooseSchema4 = import_mongoose8.default.Schema;
|
|
491
781
|
var ReasonSchema = new MongooseSchema4(
|
|
492
782
|
{
|
|
493
783
|
details: { default: null, required: false, type: String },
|
|
494
784
|
reasonType: {
|
|
495
|
-
enum: Object.values(
|
|
785
|
+
enum: Object.values(import_cluemart_shared6.EnumChatReportReason),
|
|
496
786
|
required: true,
|
|
497
787
|
type: String
|
|
498
788
|
}
|
|
@@ -504,18 +794,18 @@ var ChatReportSchema = new MongooseSchema4(
|
|
|
504
794
|
chatId: {
|
|
505
795
|
ref: "Chat",
|
|
506
796
|
required: true,
|
|
507
|
-
type:
|
|
797
|
+
type: import_mongoose8.default.Schema.Types.ObjectId
|
|
508
798
|
},
|
|
509
799
|
reason: { required: true, type: ReasonSchema },
|
|
510
800
|
reportedUserId: {
|
|
511
801
|
ref: "User",
|
|
512
802
|
required: true,
|
|
513
|
-
type:
|
|
803
|
+
type: import_mongoose8.default.Schema.Types.ObjectId
|
|
514
804
|
},
|
|
515
805
|
reporterUserId: {
|
|
516
806
|
ref: "User",
|
|
517
807
|
required: true,
|
|
518
|
-
type:
|
|
808
|
+
type: import_mongoose8.default.Schema.Types.ObjectId
|
|
519
809
|
},
|
|
520
810
|
resolved: { default: false, required: true, type: Boolean }
|
|
521
811
|
},
|
|
@@ -523,20 +813,20 @@ var ChatReportSchema = new MongooseSchema4(
|
|
|
523
813
|
);
|
|
524
814
|
ChatReportSchema.index({ chatId: 1, reportedUserId: 1 });
|
|
525
815
|
ChatReportSchema.index({ createdAt: -1, reporterUserId: 1 });
|
|
526
|
-
var ChatReportModel =
|
|
816
|
+
var ChatReportModel = import_mongoose8.default.models.ChatReport || import_mongoose8.default.model("ChatReport", ChatReportSchema);
|
|
527
817
|
|
|
528
818
|
// src/mongoose/global.ts
|
|
529
|
-
var
|
|
530
|
-
var
|
|
819
|
+
var import_cluemart_shared9 = require("@timardex/cluemart-shared");
|
|
820
|
+
var import_mongoose11 = __toESM(require("mongoose"));
|
|
531
821
|
|
|
532
822
|
// src/mongoose/Relation.ts
|
|
533
|
-
var
|
|
534
|
-
var
|
|
823
|
+
var import_cluemart_shared8 = require("@timardex/cluemart-shared");
|
|
824
|
+
var import_mongoose10 = __toESM(require("mongoose"));
|
|
535
825
|
|
|
536
826
|
// src/mongoose/event/EventInfo.ts
|
|
537
|
-
var
|
|
538
|
-
var
|
|
539
|
-
var MongooseSchema5 =
|
|
827
|
+
var import_cluemart_shared7 = require("@timardex/cluemart-shared");
|
|
828
|
+
var import_mongoose9 = __toESM(require("mongoose"));
|
|
829
|
+
var MongooseSchema5 = import_mongoose9.default.Schema;
|
|
540
830
|
var StallTypeSchema = new MongooseSchema5(
|
|
541
831
|
{
|
|
542
832
|
label: { required: false, type: String },
|
|
@@ -551,7 +841,7 @@ var StallTypeSchema = new MongooseSchema5(
|
|
|
551
841
|
var dateTimeSchema = new MongooseSchema5(
|
|
552
842
|
{
|
|
553
843
|
dateStatus: {
|
|
554
|
-
enum: Object.values(
|
|
844
|
+
enum: Object.values(import_cluemart_shared7.EnumEventDateStatus),
|
|
555
845
|
required: false,
|
|
556
846
|
type: String
|
|
557
847
|
},
|
|
@@ -570,7 +860,7 @@ var paymentInfoSchema = new MongooseSchema5(
|
|
|
570
860
|
accountNumber: { required: false, type: String },
|
|
571
861
|
link: { required: false, type: String },
|
|
572
862
|
paymentMethod: {
|
|
573
|
-
enum: Object.values(
|
|
863
|
+
enum: Object.values(import_cluemart_shared7.EnumPaymentMethod),
|
|
574
864
|
required: true,
|
|
575
865
|
type: String
|
|
576
866
|
}
|
|
@@ -597,7 +887,7 @@ var refundPolicySchema = new MongooseSchema5(
|
|
|
597
887
|
},
|
|
598
888
|
{ _id: false }
|
|
599
889
|
);
|
|
600
|
-
var
|
|
890
|
+
var schema7 = new MongooseSchema5(
|
|
601
891
|
{
|
|
602
892
|
active: { default: true, type: Boolean },
|
|
603
893
|
applicationDeadlineHours: { required: true, type: Number },
|
|
@@ -605,7 +895,7 @@ var schema3 = new MongooseSchema5(
|
|
|
605
895
|
eventId: {
|
|
606
896
|
ref: "Event",
|
|
607
897
|
required: true,
|
|
608
|
-
type:
|
|
898
|
+
type: import_mongoose9.default.Schema.Types.ObjectId
|
|
609
899
|
},
|
|
610
900
|
packInTime: { required: true, type: Number },
|
|
611
901
|
paymentDueHours: { required: true, type: Number },
|
|
@@ -615,15 +905,15 @@ var schema3 = new MongooseSchema5(
|
|
|
615
905
|
},
|
|
616
906
|
{ timestamps: true }
|
|
617
907
|
);
|
|
618
|
-
|
|
619
|
-
var EventInfoModel =
|
|
908
|
+
schema7.index({ eventId: 1 });
|
|
909
|
+
var EventInfoModel = import_mongoose9.default.models.EventInfo || import_mongoose9.default.model("EventInfo", schema7);
|
|
620
910
|
|
|
621
911
|
// src/mongoose/Relation.ts
|
|
622
|
-
var MongooseSchema6 =
|
|
912
|
+
var MongooseSchema6 = import_mongoose10.default.Schema;
|
|
623
913
|
var relationDateTimeSchema = new MongooseSchema6(
|
|
624
914
|
{
|
|
625
915
|
dateStatus: {
|
|
626
|
-
enum: Object.values(
|
|
916
|
+
enum: Object.values(import_cluemart_shared8.EnumEventDateStatus),
|
|
627
917
|
required: true,
|
|
628
918
|
type: String
|
|
629
919
|
},
|
|
@@ -647,7 +937,7 @@ var relationDatesSchema = new MongooseSchema6(
|
|
|
647
937
|
},
|
|
648
938
|
paymentReference: { required: false, type: String },
|
|
649
939
|
status: {
|
|
650
|
-
enum: Object.values(
|
|
940
|
+
enum: Object.values(import_cluemart_shared8.EnumInviteStatus),
|
|
651
941
|
required: false,
|
|
652
942
|
type: String
|
|
653
943
|
}
|
|
@@ -660,29 +950,29 @@ var RelationTypeSchema = new MongooseSchema6(
|
|
|
660
950
|
chatId: {
|
|
661
951
|
ref: "Chat",
|
|
662
952
|
required: true,
|
|
663
|
-
type:
|
|
953
|
+
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
664
954
|
},
|
|
665
955
|
deletedAt: { default: null, required: false, type: Date },
|
|
666
956
|
eventId: {
|
|
667
957
|
ref: "Event",
|
|
668
958
|
required: true,
|
|
669
|
-
type:
|
|
959
|
+
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
670
960
|
},
|
|
671
961
|
lastUpdateBy: {
|
|
672
|
-
enum: Object.values(
|
|
962
|
+
enum: Object.values(import_cluemart_shared8.EnumResourceType),
|
|
673
963
|
required: true,
|
|
674
964
|
type: String
|
|
675
965
|
},
|
|
676
966
|
relationDates: [relationDatesSchema],
|
|
677
967
|
relationType: {
|
|
678
|
-
enum: Object.values(
|
|
968
|
+
enum: Object.values(import_cluemart_shared8.EnumRelationResource),
|
|
679
969
|
required: true,
|
|
680
970
|
type: String
|
|
681
971
|
},
|
|
682
972
|
vendorId: {
|
|
683
973
|
ref: "Vendor",
|
|
684
974
|
required: true,
|
|
685
|
-
type:
|
|
975
|
+
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
686
976
|
}
|
|
687
977
|
},
|
|
688
978
|
{ timestamps: true }
|
|
@@ -694,17 +984,17 @@ RelationTypeSchema.index({
|
|
|
694
984
|
"relationDates.status": 1,
|
|
695
985
|
vendorId: 1
|
|
696
986
|
});
|
|
697
|
-
var RelationModel =
|
|
987
|
+
var RelationModel = import_mongoose10.default.models.Relation || import_mongoose10.default.model("Relation", RelationTypeSchema);
|
|
698
988
|
|
|
699
989
|
// src/mongoose/global.ts
|
|
700
|
-
var MongooseSchema7 =
|
|
990
|
+
var MongooseSchema7 = import_mongoose11.default.Schema;
|
|
701
991
|
var OwnerTypeSchema = new MongooseSchema7(
|
|
702
992
|
{
|
|
703
993
|
email: { required: true, type: String },
|
|
704
994
|
userId: {
|
|
705
995
|
ref: "User",
|
|
706
996
|
required: true,
|
|
707
|
-
type:
|
|
997
|
+
type: import_mongoose11.default.Schema.Types.ObjectId
|
|
708
998
|
}
|
|
709
999
|
},
|
|
710
1000
|
{ _id: false }
|
|
@@ -763,12 +1053,12 @@ var userLicenseSchema = new MongooseSchema7(
|
|
|
763
1053
|
expiryDate: { required: true, type: Date },
|
|
764
1054
|
issuedDate: { required: true, type: Date },
|
|
765
1055
|
licenceType: {
|
|
766
|
-
enum: Object.values(
|
|
1056
|
+
enum: Object.values(import_cluemart_shared9.EnumUserLicence),
|
|
767
1057
|
required: true,
|
|
768
1058
|
type: String
|
|
769
1059
|
},
|
|
770
1060
|
prevLicenceType: {
|
|
771
|
-
enum: Object.values(
|
|
1061
|
+
enum: Object.values(import_cluemart_shared9.EnumUserLicence),
|
|
772
1062
|
required: false,
|
|
773
1063
|
type: String
|
|
774
1064
|
}
|
|
@@ -811,7 +1101,7 @@ var resourceRelationsSchema = new MongooseSchema7(
|
|
|
811
1101
|
relationId: {
|
|
812
1102
|
ref: "Relation",
|
|
813
1103
|
required: false,
|
|
814
|
-
type:
|
|
1104
|
+
type: import_mongoose11.default.Schema.Types.ObjectId
|
|
815
1105
|
}
|
|
816
1106
|
},
|
|
817
1107
|
{ _id: false }
|
|
@@ -819,7 +1109,7 @@ var resourceRelationsSchema = new MongooseSchema7(
|
|
|
819
1109
|
var dateTimeSchema2 = new MongooseSchema7(
|
|
820
1110
|
{
|
|
821
1111
|
dateStatus: {
|
|
822
|
-
enum: Object.values(
|
|
1112
|
+
enum: Object.values(import_cluemart_shared9.EnumEventDateStatus),
|
|
823
1113
|
required: false,
|
|
824
1114
|
type: String
|
|
825
1115
|
},
|
|
@@ -862,11 +1152,11 @@ var relatedPostSchema = new MongooseSchema7(
|
|
|
862
1152
|
postId: {
|
|
863
1153
|
ref: "Post",
|
|
864
1154
|
required: true,
|
|
865
|
-
type:
|
|
1155
|
+
type: import_mongoose11.default.Schema.Types.ObjectId
|
|
866
1156
|
},
|
|
867
1157
|
postSlug: { required: true, type: String },
|
|
868
1158
|
postType: {
|
|
869
|
-
enum: Object.values(
|
|
1159
|
+
enum: Object.values(import_cluemart_shared9.EnumPostType),
|
|
870
1160
|
required: true,
|
|
871
1161
|
type: String
|
|
872
1162
|
}
|
|
@@ -887,7 +1177,7 @@ var baseResourceFields = {
|
|
|
887
1177
|
adIds: {
|
|
888
1178
|
ref: "Ad",
|
|
889
1179
|
required: false,
|
|
890
|
-
type: [
|
|
1180
|
+
type: [import_mongoose11.default.Schema.Types.ObjectId]
|
|
891
1181
|
},
|
|
892
1182
|
approvedAt: { default: null, required: false, type: Date },
|
|
893
1183
|
contactDetails: { required: false, type: ContactDetailsSchema },
|
|
@@ -917,8 +1207,8 @@ var baseResourceFields = {
|
|
|
917
1207
|
};
|
|
918
1208
|
|
|
919
1209
|
// src/mongoose/GoogleImportedMarket.ts
|
|
920
|
-
var
|
|
921
|
-
var
|
|
1210
|
+
var import_cluemart_shared10 = require("@timardex/cluemart-shared");
|
|
1211
|
+
var import_mongoose12 = __toESM(require("mongoose"));
|
|
922
1212
|
|
|
923
1213
|
// src/mongoose/searchNamePlugin.ts
|
|
924
1214
|
function deriveSearchName(name) {
|
|
@@ -964,15 +1254,15 @@ function syncSearchNameInUpdate(update) {
|
|
|
964
1254
|
}
|
|
965
1255
|
return null;
|
|
966
1256
|
}
|
|
967
|
-
function searchNamePlugin(
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1257
|
+
function searchNamePlugin(schema24) {
|
|
1258
|
+
schema24.add({ searchName: { default: "", required: false, type: String } });
|
|
1259
|
+
schema24.index({ searchName: 1 });
|
|
1260
|
+
schema24.pre("save", function syncSearchNameOnSave(next) {
|
|
971
1261
|
const doc = this;
|
|
972
1262
|
doc.searchName = deriveSearchName(doc.name);
|
|
973
1263
|
next();
|
|
974
1264
|
});
|
|
975
|
-
|
|
1265
|
+
schema24.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
|
|
976
1266
|
const list = Array.isArray(docs) ? docs : [docs];
|
|
977
1267
|
for (const doc of list) {
|
|
978
1268
|
if (doc && typeof doc.name === "string") {
|
|
@@ -981,7 +1271,7 @@ function searchNamePlugin(schema20) {
|
|
|
981
1271
|
}
|
|
982
1272
|
next();
|
|
983
1273
|
});
|
|
984
|
-
|
|
1274
|
+
schema24.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
|
|
985
1275
|
for (const op of ops) {
|
|
986
1276
|
const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
|
|
987
1277
|
if (doc && typeof doc.name === "string") {
|
|
@@ -1007,14 +1297,14 @@ function searchNamePlugin(schema20) {
|
|
|
1007
1297
|
}
|
|
1008
1298
|
next();
|
|
1009
1299
|
};
|
|
1010
|
-
|
|
1300
|
+
schema24.pre(
|
|
1011
1301
|
["findOneAndUpdate", "updateOne", "updateMany"],
|
|
1012
1302
|
syncSearchNameOnUpdate
|
|
1013
1303
|
);
|
|
1014
1304
|
}
|
|
1015
1305
|
|
|
1016
1306
|
// src/mongoose/GoogleImportedMarket.ts
|
|
1017
|
-
var MongooseSchema8 =
|
|
1307
|
+
var MongooseSchema8 = import_mongoose12.default.Schema;
|
|
1018
1308
|
var addressComponentSchema = new MongooseSchema8(
|
|
1019
1309
|
{
|
|
1020
1310
|
longName: { required: false, type: String },
|
|
@@ -1023,7 +1313,7 @@ var addressComponentSchema = new MongooseSchema8(
|
|
|
1023
1313
|
},
|
|
1024
1314
|
{ _id: false }
|
|
1025
1315
|
);
|
|
1026
|
-
var
|
|
1316
|
+
var schema8 = new MongooseSchema8(
|
|
1027
1317
|
{
|
|
1028
1318
|
active: { default: false, required: true, type: Boolean },
|
|
1029
1319
|
address: { required: true, type: String },
|
|
@@ -1035,7 +1325,7 @@ var schema4 = new MongooseSchema8(
|
|
|
1035
1325
|
claimedByUserId: {
|
|
1036
1326
|
ref: "User",
|
|
1037
1327
|
required: false,
|
|
1038
|
-
type:
|
|
1328
|
+
type: import_mongoose12.default.Schema.Types.ObjectId
|
|
1039
1329
|
},
|
|
1040
1330
|
cover: {
|
|
1041
1331
|
required: false,
|
|
@@ -1047,10 +1337,10 @@ var schema4 = new MongooseSchema8(
|
|
|
1047
1337
|
eventId: {
|
|
1048
1338
|
ref: "Event",
|
|
1049
1339
|
required: false,
|
|
1050
|
-
type:
|
|
1340
|
+
type: import_mongoose12.default.Schema.Types.ObjectId
|
|
1051
1341
|
},
|
|
1052
1342
|
eventType: {
|
|
1053
|
-
enum: Object.values(
|
|
1343
|
+
enum: Object.values(import_cluemart_shared10.EnumEventType),
|
|
1054
1344
|
required: true,
|
|
1055
1345
|
type: String
|
|
1056
1346
|
},
|
|
@@ -1086,27 +1376,27 @@ var schema4 = new MongooseSchema8(
|
|
|
1086
1376
|
},
|
|
1087
1377
|
{ timestamps: true }
|
|
1088
1378
|
);
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
var GoogleImportedMarketModel =
|
|
1379
|
+
schema8.index({ "location.geo": "2dsphere" });
|
|
1380
|
+
schema8.index({ name: 1 });
|
|
1381
|
+
schema8.index({ region: 1 });
|
|
1382
|
+
schema8.index({ deletedAt: 1 });
|
|
1383
|
+
schema8.index({ "dateTime.dateStatus": 1 });
|
|
1384
|
+
schema8.index({ slug: 1 });
|
|
1385
|
+
schema8.index({ name: "text", description: "text" });
|
|
1386
|
+
schema8.plugin(searchNamePlugin);
|
|
1387
|
+
var GoogleImportedMarketModel = import_mongoose12.default.models.GoogleImportedMarket || import_mongoose12.default.model("GoogleImportedMarket", schema8);
|
|
1098
1388
|
|
|
1099
1389
|
// src/mongoose/Notification.ts
|
|
1100
|
-
var
|
|
1101
|
-
var
|
|
1102
|
-
var MongooseSchema9 =
|
|
1103
|
-
var
|
|
1390
|
+
var import_cluemart_shared11 = require("@timardex/cluemart-shared");
|
|
1391
|
+
var import_mongoose13 = __toESM(require("mongoose"));
|
|
1392
|
+
var MongooseSchema9 = import_mongoose13.default.Schema;
|
|
1393
|
+
var schema9 = new MongooseSchema9(
|
|
1104
1394
|
{
|
|
1105
1395
|
data: {
|
|
1106
1396
|
resourceId: { required: true, type: String },
|
|
1107
1397
|
resourceName: { required: true, type: String },
|
|
1108
1398
|
resourceType: {
|
|
1109
|
-
enum: Object.values(
|
|
1399
|
+
enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
|
|
1110
1400
|
required: true,
|
|
1111
1401
|
type: String
|
|
1112
1402
|
}
|
|
@@ -1115,28 +1405,28 @@ var schema5 = new MongooseSchema9(
|
|
|
1115
1405
|
message: { required: true, type: String },
|
|
1116
1406
|
title: { required: true, type: String },
|
|
1117
1407
|
type: {
|
|
1118
|
-
default:
|
|
1119
|
-
enum: Object.values(
|
|
1408
|
+
default: import_cluemart_shared11.EnumNotificationType.SYSTEM,
|
|
1409
|
+
enum: Object.values(import_cluemart_shared11.EnumNotificationType),
|
|
1120
1410
|
required: true,
|
|
1121
1411
|
type: String
|
|
1122
1412
|
},
|
|
1123
1413
|
userId: {
|
|
1124
1414
|
ref: "User",
|
|
1125
1415
|
required: true,
|
|
1126
|
-
type:
|
|
1416
|
+
type: import_mongoose13.default.Schema.Types.ObjectId
|
|
1127
1417
|
}
|
|
1128
1418
|
},
|
|
1129
1419
|
{ timestamps: true }
|
|
1130
1420
|
);
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
var NotificationModel =
|
|
1421
|
+
schema9.index({ isRead: 1, userId: 1 });
|
|
1422
|
+
schema9.index({ createdAt: -1, userId: 1 });
|
|
1423
|
+
var NotificationModel = import_mongoose13.default.models.Notification || import_mongoose13.default.model("Notification", schema9);
|
|
1134
1424
|
|
|
1135
1425
|
// src/mongoose/PushToken.ts
|
|
1136
1426
|
var import_enums = require("@timardex/cluemart-shared/enums");
|
|
1137
|
-
var
|
|
1138
|
-
var MongooseSchema10 =
|
|
1139
|
-
var
|
|
1427
|
+
var import_mongoose14 = __toESM(require("mongoose"));
|
|
1428
|
+
var MongooseSchema10 = import_mongoose14.default.Schema;
|
|
1429
|
+
var schema10 = new MongooseSchema10(
|
|
1140
1430
|
{
|
|
1141
1431
|
platform: {
|
|
1142
1432
|
enum: Object.values(import_enums.EnumOSPlatform),
|
|
@@ -1147,26 +1437,26 @@ var schema6 = new MongooseSchema10(
|
|
|
1147
1437
|
userId: {
|
|
1148
1438
|
ref: "User",
|
|
1149
1439
|
required: true,
|
|
1150
|
-
type:
|
|
1440
|
+
type: import_mongoose14.default.Schema.Types.ObjectId
|
|
1151
1441
|
}
|
|
1152
1442
|
},
|
|
1153
1443
|
{ timestamps: true }
|
|
1154
1444
|
);
|
|
1155
|
-
var PushTokenModel =
|
|
1445
|
+
var PushTokenModel = import_mongoose14.default.models.PushToken || import_mongoose14.default.model("PushToken", schema10);
|
|
1156
1446
|
|
|
1157
1447
|
// src/mongoose/ResourceActivity.ts
|
|
1158
|
-
var
|
|
1159
|
-
var
|
|
1160
|
-
var MongooseSchema11 =
|
|
1448
|
+
var import_cluemart_shared12 = require("@timardex/cluemart-shared");
|
|
1449
|
+
var import_mongoose15 = __toESM(require("mongoose"));
|
|
1450
|
+
var MongooseSchema11 = import_mongoose15.default.Schema;
|
|
1161
1451
|
var ActivitySchema = new MongooseSchema11(
|
|
1162
1452
|
{
|
|
1163
1453
|
activityType: {
|
|
1164
|
-
enum: Object.values(
|
|
1454
|
+
enum: Object.values(import_cluemart_shared12.EnumActivity),
|
|
1165
1455
|
required: true,
|
|
1166
1456
|
type: String
|
|
1167
1457
|
},
|
|
1168
1458
|
dateStatus: {
|
|
1169
|
-
enum: Object.values(
|
|
1459
|
+
enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
|
|
1170
1460
|
required: false,
|
|
1171
1461
|
type: String
|
|
1172
1462
|
},
|
|
@@ -1178,7 +1468,7 @@ var ActivitySchema = new MongooseSchema11(
|
|
|
1178
1468
|
startTime: { required: false, type: String },
|
|
1179
1469
|
timestamp: { default: Date.now, type: Date },
|
|
1180
1470
|
userAgent: {
|
|
1181
|
-
enum: Object.values(
|
|
1471
|
+
enum: Object.values(import_cluemart_shared12.EnumOSPlatform),
|
|
1182
1472
|
required: true,
|
|
1183
1473
|
type: String
|
|
1184
1474
|
},
|
|
@@ -1186,33 +1476,33 @@ var ActivitySchema = new MongooseSchema11(
|
|
|
1186
1476
|
},
|
|
1187
1477
|
{ _id: false }
|
|
1188
1478
|
);
|
|
1189
|
-
var
|
|
1479
|
+
var schema11 = new MongooseSchema11(
|
|
1190
1480
|
{
|
|
1191
1481
|
activity: { default: [], type: [ActivitySchema] },
|
|
1192
1482
|
resourceId: { required: true, type: String },
|
|
1193
1483
|
resourceType: {
|
|
1194
|
-
enum: Object.values(
|
|
1484
|
+
enum: Object.values(import_cluemart_shared12.EnumResourceType),
|
|
1195
1485
|
required: true,
|
|
1196
1486
|
type: String
|
|
1197
1487
|
}
|
|
1198
1488
|
},
|
|
1199
1489
|
{ timestamps: true }
|
|
1200
1490
|
);
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
var ResourceActivityModel =
|
|
1491
|
+
schema11.index({ resourceId: 1, resourceType: 1 }, { unique: true });
|
|
1492
|
+
schema11.index({ "views.location": "2dsphere" });
|
|
1493
|
+
var ResourceActivityModel = import_mongoose15.default.models.ResourceActivity || import_mongoose15.default.model("ResourceActivity", schema11);
|
|
1204
1494
|
|
|
1205
1495
|
// src/mongoose/User.ts
|
|
1206
|
-
var
|
|
1207
|
-
var
|
|
1208
|
-
var MongooseSchema12 =
|
|
1496
|
+
var import_cluemart_shared13 = require("@timardex/cluemart-shared");
|
|
1497
|
+
var import_mongoose16 = __toESM(require("mongoose"));
|
|
1498
|
+
var MongooseSchema12 = import_mongoose16.default.Schema;
|
|
1209
1499
|
var userActivityEventSchema = new MongooseSchema12(
|
|
1210
1500
|
{
|
|
1211
1501
|
dateTime: dateTimeSchema2,
|
|
1212
1502
|
resourceId: {
|
|
1213
1503
|
ref: "Event",
|
|
1214
1504
|
required: false,
|
|
1215
|
-
type:
|
|
1505
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1216
1506
|
}
|
|
1217
1507
|
},
|
|
1218
1508
|
{ _id: false }
|
|
@@ -1222,17 +1512,17 @@ var userActivityFavouritesSchema = new MongooseSchema12(
|
|
|
1222
1512
|
events: {
|
|
1223
1513
|
ref: "Event",
|
|
1224
1514
|
required: false,
|
|
1225
|
-
type: [
|
|
1515
|
+
type: [import_mongoose16.default.Schema.Types.ObjectId]
|
|
1226
1516
|
},
|
|
1227
1517
|
partners: {
|
|
1228
1518
|
ref: "Partner",
|
|
1229
1519
|
required: false,
|
|
1230
|
-
type: [
|
|
1520
|
+
type: [import_mongoose16.default.Schema.Types.ObjectId]
|
|
1231
1521
|
},
|
|
1232
1522
|
vendors: {
|
|
1233
1523
|
ref: "Vendor",
|
|
1234
1524
|
required: false,
|
|
1235
|
-
type: [
|
|
1525
|
+
type: [import_mongoose16.default.Schema.Types.ObjectId]
|
|
1236
1526
|
}
|
|
1237
1527
|
},
|
|
1238
1528
|
{ _id: false }
|
|
@@ -1240,7 +1530,7 @@ var userActivityFavouritesSchema = new MongooseSchema12(
|
|
|
1240
1530
|
var stripeSchema = new MongooseSchema12(
|
|
1241
1531
|
{
|
|
1242
1532
|
billingPeriod: {
|
|
1243
|
-
enum: Object.values(
|
|
1533
|
+
enum: Object.values(import_cluemart_shared13.EnumBillingPeriod),
|
|
1244
1534
|
required: false,
|
|
1245
1535
|
type: String
|
|
1246
1536
|
},
|
|
@@ -1249,7 +1539,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1249
1539
|
type: Boolean
|
|
1250
1540
|
},
|
|
1251
1541
|
currentPlan: {
|
|
1252
|
-
enum: Object.values(
|
|
1542
|
+
enum: Object.values(import_cluemart_shared13.EnumUserLicence),
|
|
1253
1543
|
required: false,
|
|
1254
1544
|
type: String
|
|
1255
1545
|
},
|
|
@@ -1261,8 +1551,20 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1261
1551
|
required: false,
|
|
1262
1552
|
type: Date
|
|
1263
1553
|
},
|
|
1554
|
+
paymentFailedAt: {
|
|
1555
|
+
required: false,
|
|
1556
|
+
type: Date
|
|
1557
|
+
},
|
|
1558
|
+
paymentGracePeriodEndsAt: {
|
|
1559
|
+
required: false,
|
|
1560
|
+
type: Date
|
|
1561
|
+
},
|
|
1562
|
+
paymentGraceSubscriptionId: {
|
|
1563
|
+
required: false,
|
|
1564
|
+
type: String
|
|
1565
|
+
},
|
|
1264
1566
|
pendingBillingPeriod: {
|
|
1265
|
-
enum: Object.values(
|
|
1567
|
+
enum: Object.values(import_cluemart_shared13.EnumBillingPeriod),
|
|
1266
1568
|
required: false,
|
|
1267
1569
|
type: String
|
|
1268
1570
|
},
|
|
@@ -1271,7 +1573,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1271
1573
|
type: Date
|
|
1272
1574
|
},
|
|
1273
1575
|
pendingPlan: {
|
|
1274
|
-
enum: Object.values(
|
|
1576
|
+
enum: Object.values(import_cluemart_shared13.EnumUserLicence),
|
|
1275
1577
|
required: false,
|
|
1276
1578
|
type: String
|
|
1277
1579
|
},
|
|
@@ -1288,7 +1590,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1288
1590
|
type: Date
|
|
1289
1591
|
},
|
|
1290
1592
|
status: {
|
|
1291
|
-
enum: Object.values(
|
|
1593
|
+
enum: Object.values(import_cluemart_shared13.EnumSubscriptionStatus),
|
|
1292
1594
|
required: false,
|
|
1293
1595
|
type: String
|
|
1294
1596
|
},
|
|
@@ -1310,7 +1612,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1310
1612
|
var redeemedRewardSchema = new MongooseSchema12(
|
|
1311
1613
|
{
|
|
1312
1614
|
name: {
|
|
1313
|
-
enum: Object.values(
|
|
1615
|
+
enum: Object.values(import_cluemart_shared13.EnumReward),
|
|
1314
1616
|
required: true,
|
|
1315
1617
|
type: String
|
|
1316
1618
|
},
|
|
@@ -1319,13 +1621,13 @@ var redeemedRewardSchema = new MongooseSchema12(
|
|
|
1319
1621
|
},
|
|
1320
1622
|
{ _id: false }
|
|
1321
1623
|
);
|
|
1322
|
-
var
|
|
1624
|
+
var schema12 = new MongooseSchema12(
|
|
1323
1625
|
{
|
|
1324
1626
|
active: { default: false, required: true, type: Boolean },
|
|
1325
1627
|
affiliate: {
|
|
1326
1628
|
ref: "Affiliate",
|
|
1327
1629
|
required: false,
|
|
1328
|
-
type:
|
|
1630
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1329
1631
|
},
|
|
1330
1632
|
avatar: {
|
|
1331
1633
|
required: false,
|
|
@@ -1334,28 +1636,28 @@ var schema8 = new MongooseSchema12(
|
|
|
1334
1636
|
coupon: {
|
|
1335
1637
|
ref: "Coupon",
|
|
1336
1638
|
required: false,
|
|
1337
|
-
type:
|
|
1639
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1338
1640
|
},
|
|
1339
1641
|
deletedAt: { default: null, required: false, type: Date },
|
|
1340
1642
|
email: { required: true, type: String },
|
|
1341
1643
|
emailSentFor: {
|
|
1342
|
-
enum: Object.values(
|
|
1644
|
+
enum: Object.values(import_cluemart_shared13.EnumNotificationResourceType),
|
|
1343
1645
|
required: false,
|
|
1344
1646
|
type: [String]
|
|
1345
1647
|
},
|
|
1346
1648
|
events: {
|
|
1347
1649
|
ref: "Event",
|
|
1348
1650
|
required: false,
|
|
1349
|
-
type: [
|
|
1651
|
+
type: [import_mongoose16.default.Schema.Types.ObjectId]
|
|
1350
1652
|
},
|
|
1351
1653
|
firstName: { required: true, type: String },
|
|
1352
1654
|
game: {
|
|
1353
1655
|
ref: "Game",
|
|
1354
1656
|
required: false,
|
|
1355
|
-
type:
|
|
1657
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1356
1658
|
},
|
|
1357
1659
|
interests: {
|
|
1358
|
-
enum: Object.values(
|
|
1660
|
+
enum: Object.values(import_cluemart_shared13.EnumResourceType),
|
|
1359
1661
|
required: false,
|
|
1360
1662
|
type: [String]
|
|
1361
1663
|
},
|
|
@@ -1374,11 +1676,11 @@ var schema8 = new MongooseSchema12(
|
|
|
1374
1676
|
partner: {
|
|
1375
1677
|
ref: "Partner",
|
|
1376
1678
|
required: false,
|
|
1377
|
-
type:
|
|
1679
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1378
1680
|
},
|
|
1379
1681
|
password: { required: true, type: String },
|
|
1380
1682
|
platform: {
|
|
1381
|
-
enum: Object.values(
|
|
1683
|
+
enum: Object.values(import_cluemart_shared13.EnumOSPlatform),
|
|
1382
1684
|
required: false,
|
|
1383
1685
|
type: String
|
|
1384
1686
|
},
|
|
@@ -1399,15 +1701,15 @@ var schema8 = new MongooseSchema12(
|
|
|
1399
1701
|
type: String
|
|
1400
1702
|
},
|
|
1401
1703
|
roles: {
|
|
1402
|
-
default: [
|
|
1403
|
-
enum: Object.values(
|
|
1704
|
+
default: [import_cluemart_shared13.EnumUserRole.CUSTOMER],
|
|
1705
|
+
enum: Object.values(import_cluemart_shared13.EnumUserRole),
|
|
1404
1706
|
required: true,
|
|
1405
1707
|
type: [String]
|
|
1406
1708
|
},
|
|
1407
1709
|
school: {
|
|
1408
1710
|
ref: "School",
|
|
1409
1711
|
required: false,
|
|
1410
|
-
type:
|
|
1712
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1411
1713
|
},
|
|
1412
1714
|
stripe: {
|
|
1413
1715
|
required: false,
|
|
@@ -1432,20 +1734,20 @@ var schema8 = new MongooseSchema12(
|
|
|
1432
1734
|
vendor: {
|
|
1433
1735
|
ref: "Vendor",
|
|
1434
1736
|
required: false,
|
|
1435
|
-
type:
|
|
1737
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1436
1738
|
}
|
|
1437
1739
|
},
|
|
1438
1740
|
{ strict: false, timestamps: true }
|
|
1439
1741
|
);
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
var UserModel =
|
|
1742
|
+
schema12.index({ "licences.expiryDate": 1 });
|
|
1743
|
+
schema12.index({ "licences.licenceType": 1 });
|
|
1744
|
+
schema12.index({ promoCodes: 1, active: 1, deletedAt: 1 });
|
|
1745
|
+
var UserModel = import_mongoose16.default.models.User || import_mongoose16.default.model("User", schema12);
|
|
1444
1746
|
|
|
1445
1747
|
// src/mongoose/VerificationToken.ts
|
|
1446
|
-
var
|
|
1447
|
-
var MongooseSchema13 =
|
|
1448
|
-
var
|
|
1748
|
+
var import_mongoose17 = __toESM(require("mongoose"));
|
|
1749
|
+
var MongooseSchema13 = import_mongoose17.default.Schema;
|
|
1750
|
+
var schema13 = new MongooseSchema13(
|
|
1449
1751
|
{
|
|
1450
1752
|
createdAt: {
|
|
1451
1753
|
default: Date.now,
|
|
@@ -1460,12 +1762,12 @@ var schema9 = new MongooseSchema13(
|
|
|
1460
1762
|
},
|
|
1461
1763
|
{ timestamps: true }
|
|
1462
1764
|
);
|
|
1463
|
-
var VerificationTokenModel =
|
|
1765
|
+
var VerificationTokenModel = import_mongoose17.default.models.VerificationToken || import_mongoose17.default.model("VerificationToken", schema13);
|
|
1464
1766
|
|
|
1465
1767
|
// src/mongoose/vendor/Vendor.ts
|
|
1466
|
-
var
|
|
1467
|
-
var
|
|
1468
|
-
var MongooseSchema14 =
|
|
1768
|
+
var import_cluemart_shared14 = require("@timardex/cluemart-shared");
|
|
1769
|
+
var import_mongoose18 = __toESM(require("mongoose"));
|
|
1770
|
+
var MongooseSchema14 = import_mongoose18.default.Schema;
|
|
1469
1771
|
var vendorProductTypeSchema = new MongooseSchema14(
|
|
1470
1772
|
{
|
|
1471
1773
|
description: { required: false, type: String },
|
|
@@ -1488,7 +1790,7 @@ var calendarSchema = new MongooseSchema14(
|
|
|
1488
1790
|
{
|
|
1489
1791
|
dateTime: {
|
|
1490
1792
|
dateStatus: {
|
|
1491
|
-
enum: Object.values(
|
|
1793
|
+
enum: Object.values(import_cluemart_shared14.EnumEventDateStatus),
|
|
1492
1794
|
required: false,
|
|
1493
1795
|
type: String
|
|
1494
1796
|
},
|
|
@@ -1528,7 +1830,7 @@ var downgradeSnapshotSchema = new MongooseSchema14(
|
|
|
1528
1830
|
},
|
|
1529
1831
|
{ _id: false }
|
|
1530
1832
|
);
|
|
1531
|
-
var
|
|
1833
|
+
var schema14 = new MongooseSchema14(
|
|
1532
1834
|
{
|
|
1533
1835
|
...baseResourceFields,
|
|
1534
1836
|
// Importing base resource fields from global.ts
|
|
@@ -1552,39 +1854,39 @@ var schema10 = new MongooseSchema14(
|
|
|
1552
1854
|
unregisteredVendorId: {
|
|
1553
1855
|
ref: "UnregisteredVendor",
|
|
1554
1856
|
required: false,
|
|
1555
|
-
type:
|
|
1857
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1556
1858
|
},
|
|
1557
1859
|
vendorInfoId: {
|
|
1558
1860
|
ref: "VendorInfo",
|
|
1559
1861
|
required: false,
|
|
1560
|
-
type:
|
|
1862
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1561
1863
|
},
|
|
1562
1864
|
vendorType: {
|
|
1563
|
-
enum: Object.values(
|
|
1865
|
+
enum: Object.values(import_cluemart_shared14.EnumVendorType),
|
|
1564
1866
|
required: true,
|
|
1565
1867
|
type: String
|
|
1566
1868
|
}
|
|
1567
1869
|
},
|
|
1568
1870
|
{ timestamps: true }
|
|
1569
1871
|
);
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1872
|
+
schema14.index({ name: 1 });
|
|
1873
|
+
schema14.index({ description: 1 });
|
|
1874
|
+
schema14.index({ region: 1 });
|
|
1875
|
+
schema14.index({ "categories.name": 1 });
|
|
1876
|
+
schema14.index({ slug: 1 });
|
|
1877
|
+
schema14.index({
|
|
1576
1878
|
categoriesNames: "text",
|
|
1577
1879
|
description: "text",
|
|
1578
1880
|
name: "text"
|
|
1579
1881
|
});
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
var VendorModel =
|
|
1882
|
+
schema14.index({ deletedAt: 1, "owner.userId": 1 });
|
|
1883
|
+
schema14.plugin(searchNamePlugin);
|
|
1884
|
+
var VendorModel = import_mongoose18.default.models.Vendor || import_mongoose18.default.model("Vendor", schema14);
|
|
1583
1885
|
|
|
1584
1886
|
// src/mongoose/vendor/VendorInfo.ts
|
|
1585
|
-
var
|
|
1586
|
-
var
|
|
1587
|
-
var MongooseSchema15 =
|
|
1887
|
+
var import_cluemart_shared15 = require("@timardex/cluemart-shared");
|
|
1888
|
+
var import_mongoose19 = __toESM(require("mongoose"));
|
|
1889
|
+
var MongooseSchema15 = import_mongoose19.default.Schema;
|
|
1588
1890
|
var AttributesSchema = new MongooseSchema15(
|
|
1589
1891
|
{
|
|
1590
1892
|
details: { required: false, type: String },
|
|
@@ -1592,7 +1894,7 @@ var AttributesSchema = new MongooseSchema15(
|
|
|
1592
1894
|
},
|
|
1593
1895
|
{ _id: false }
|
|
1594
1896
|
);
|
|
1595
|
-
var
|
|
1897
|
+
var schema15 = new MongooseSchema15(
|
|
1596
1898
|
{
|
|
1597
1899
|
active: { default: true, type: Boolean },
|
|
1598
1900
|
compliance: {
|
|
@@ -1602,7 +1904,7 @@ var schema11 = new MongooseSchema15(
|
|
|
1602
1904
|
documents: [ResourceImageTypeSchema],
|
|
1603
1905
|
product: {
|
|
1604
1906
|
foodFlavors: {
|
|
1605
|
-
enum: Object.values(
|
|
1907
|
+
enum: Object.values(import_cluemart_shared15.EnumFoodFlavor),
|
|
1606
1908
|
required: true,
|
|
1607
1909
|
type: [String]
|
|
1608
1910
|
},
|
|
@@ -1627,29 +1929,29 @@ var schema11 = new MongooseSchema15(
|
|
|
1627
1929
|
vendorId: {
|
|
1628
1930
|
ref: "Vendor",
|
|
1629
1931
|
required: true,
|
|
1630
|
-
type:
|
|
1932
|
+
type: import_mongoose19.default.Schema.Types.ObjectId
|
|
1631
1933
|
}
|
|
1632
1934
|
},
|
|
1633
1935
|
{ timestamps: true }
|
|
1634
1936
|
);
|
|
1635
|
-
|
|
1636
|
-
var VendorInfoModel =
|
|
1937
|
+
schema15.index({ vendorId: 1 });
|
|
1938
|
+
var VendorInfoModel = import_mongoose19.default.models.VendorInfo || import_mongoose19.default.model("VendorInfo", schema15);
|
|
1637
1939
|
|
|
1638
1940
|
// src/mongoose/vendor/UnregisteredVendor.ts
|
|
1639
|
-
var
|
|
1640
|
-
var MongooseSchema16 =
|
|
1941
|
+
var import_mongoose20 = __toESM(require("mongoose"));
|
|
1942
|
+
var MongooseSchema16 = import_mongoose20.default.Schema;
|
|
1641
1943
|
var invitationSchema = new MongooseSchema16(
|
|
1642
1944
|
{
|
|
1643
1945
|
dateTime: { required: true, type: [dateTimeSchema2] },
|
|
1644
1946
|
inviterId: {
|
|
1645
1947
|
ref: "Event",
|
|
1646
1948
|
required: true,
|
|
1647
|
-
type:
|
|
1949
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1648
1950
|
}
|
|
1649
1951
|
},
|
|
1650
1952
|
{ _id: false }
|
|
1651
1953
|
);
|
|
1652
|
-
var
|
|
1954
|
+
var schema16 = new MongooseSchema16(
|
|
1653
1955
|
{
|
|
1654
1956
|
active: { default: true, required: true, type: Boolean },
|
|
1655
1957
|
categoryIds: { required: true, type: [String] },
|
|
@@ -1658,7 +1960,7 @@ var schema12 = new MongooseSchema16(
|
|
|
1658
1960
|
claimedByUserId: {
|
|
1659
1961
|
ref: "User",
|
|
1660
1962
|
required: false,
|
|
1661
|
-
type:
|
|
1963
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1662
1964
|
},
|
|
1663
1965
|
claimInitiatedAt: { default: null, required: false, type: Date },
|
|
1664
1966
|
claimToken: { default: null, required: false, type: String },
|
|
@@ -1671,15 +1973,15 @@ var schema12 = new MongooseSchema16(
|
|
|
1671
1973
|
},
|
|
1672
1974
|
{ timestamps: true }
|
|
1673
1975
|
);
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
var UnregisteredVendorModel =
|
|
1976
|
+
schema16.index({ name: 1 });
|
|
1977
|
+
schema16.index({ email: 1 });
|
|
1978
|
+
var UnregisteredVendorModel = import_mongoose20.default.models.UnregisteredVendor || import_mongoose20.default.model("UnregisteredVendor", schema16);
|
|
1677
1979
|
|
|
1678
1980
|
// src/mongoose/event/Event.ts
|
|
1679
|
-
var
|
|
1680
|
-
var
|
|
1681
|
-
var MongooseSchema17 =
|
|
1682
|
-
var
|
|
1981
|
+
var import_cluemart_shared16 = require("@timardex/cluemart-shared");
|
|
1982
|
+
var import_mongoose21 = __toESM(require("mongoose"));
|
|
1983
|
+
var MongooseSchema17 = import_mongoose21.default.Schema;
|
|
1984
|
+
var schema17 = new MongooseSchema17(
|
|
1683
1985
|
{
|
|
1684
1986
|
...baseResourceFields,
|
|
1685
1987
|
// Importing base resource fields from global.ts
|
|
@@ -1688,10 +1990,10 @@ var schema13 = new MongooseSchema17(
|
|
|
1688
1990
|
eventInfoId: {
|
|
1689
1991
|
ref: "EventInfo",
|
|
1690
1992
|
required: false,
|
|
1691
|
-
type:
|
|
1993
|
+
type: import_mongoose21.default.Schema.Types.ObjectId
|
|
1692
1994
|
},
|
|
1693
1995
|
eventType: {
|
|
1694
|
-
enum: Object.values(
|
|
1996
|
+
enum: Object.values(import_cluemart_shared16.EnumEventType),
|
|
1695
1997
|
required: true,
|
|
1696
1998
|
type: String
|
|
1697
1999
|
},
|
|
@@ -1717,24 +2019,24 @@ var schema13 = new MongooseSchema17(
|
|
|
1717
2019
|
},
|
|
1718
2020
|
{ timestamps: true }
|
|
1719
2021
|
);
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
var EventModel =
|
|
2022
|
+
schema17.index({ name: 1 });
|
|
2023
|
+
schema17.index({ description: 1 });
|
|
2024
|
+
schema17.index({ region: 1 });
|
|
2025
|
+
schema17.index({ "location.geo": "2dsphere" });
|
|
2026
|
+
schema17.index({ tags: 1 });
|
|
2027
|
+
schema17.index({ deletedAt: 1 });
|
|
2028
|
+
schema17.index({ "dateTime.dateStatus": 1 });
|
|
2029
|
+
schema17.index({ slug: 1 });
|
|
2030
|
+
schema17.index({ name: "text", description: "text", tags: "text" });
|
|
2031
|
+
schema17.index({ "owner.userId": 1, deletedAt: 1 });
|
|
2032
|
+
schema17.plugin(searchNamePlugin);
|
|
2033
|
+
var EventModel = import_mongoose21.default.models.Event || import_mongoose21.default.model("Event", schema17);
|
|
1732
2034
|
|
|
1733
2035
|
// src/mongoose/Partner.ts
|
|
1734
|
-
var
|
|
1735
|
-
var
|
|
1736
|
-
var MongooseSchema18 =
|
|
1737
|
-
var
|
|
2036
|
+
var import_cluemart_shared17 = require("@timardex/cluemart-shared");
|
|
2037
|
+
var import_mongoose22 = __toESM(require("mongoose"));
|
|
2038
|
+
var MongooseSchema18 = import_mongoose22.default.Schema;
|
|
2039
|
+
var schema18 = new MongooseSchema18(
|
|
1738
2040
|
{
|
|
1739
2041
|
...baseResourceFields,
|
|
1740
2042
|
location: {
|
|
@@ -1743,33 +2045,33 @@ var schema14 = new MongooseSchema18(
|
|
|
1743
2045
|
},
|
|
1744
2046
|
nzbn: { required: true, type: String },
|
|
1745
2047
|
partnerType: {
|
|
1746
|
-
enum: Object.values(
|
|
2048
|
+
enum: Object.values(import_cluemart_shared17.EnumPartnerType),
|
|
1747
2049
|
required: true,
|
|
1748
2050
|
type: String
|
|
1749
2051
|
}
|
|
1750
2052
|
},
|
|
1751
2053
|
{ timestamps: true }
|
|
1752
2054
|
);
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
var PartnerModel =
|
|
2055
|
+
schema18.index({ name: 1 });
|
|
2056
|
+
schema18.index({ description: 1 });
|
|
2057
|
+
schema18.index({ region: 1 });
|
|
2058
|
+
schema18.index({ "location.geo": "2dsphere" });
|
|
2059
|
+
schema18.index({ slug: 1 });
|
|
2060
|
+
schema18.index({ name: "text", description: "text" });
|
|
2061
|
+
schema18.index({ "owner.userId": 1, deletedAt: 1 });
|
|
2062
|
+
schema18.plugin(searchNamePlugin);
|
|
2063
|
+
var PartnerModel = import_mongoose22.default.models.Partner || import_mongoose22.default.model("Partner", schema18);
|
|
1762
2064
|
|
|
1763
2065
|
// src/mongoose/Post.ts
|
|
1764
|
-
var
|
|
1765
|
-
var
|
|
1766
|
-
var MongooseSchema19 =
|
|
2066
|
+
var import_cluemart_shared18 = require("@timardex/cluemart-shared");
|
|
2067
|
+
var import_mongoose23 = __toESM(require("mongoose"));
|
|
2068
|
+
var MongooseSchema19 = import_mongoose23.default.Schema;
|
|
1767
2069
|
var contentSchema = new MongooseSchema19(
|
|
1768
2070
|
{
|
|
1769
|
-
contentData:
|
|
2071
|
+
contentData: import_mongoose23.Schema.Types.Mixed,
|
|
1770
2072
|
contentOrder: { required: true, type: Number },
|
|
1771
2073
|
contentType: {
|
|
1772
|
-
enum: Object.values(
|
|
2074
|
+
enum: Object.values(import_cluemart_shared18.EnumPostContentType),
|
|
1773
2075
|
required: true,
|
|
1774
2076
|
type: String
|
|
1775
2077
|
}
|
|
@@ -1782,14 +2084,14 @@ var resourceSchema = new MongooseSchema19(
|
|
|
1782
2084
|
resourceRegion: { required: true, type: String },
|
|
1783
2085
|
resourceSlug: { required: true, type: String },
|
|
1784
2086
|
resourceType: {
|
|
1785
|
-
enum: Object.values(
|
|
2087
|
+
enum: Object.values(import_cluemart_shared18.EnumResourceType),
|
|
1786
2088
|
required: true,
|
|
1787
2089
|
type: String
|
|
1788
2090
|
}
|
|
1789
2091
|
},
|
|
1790
2092
|
{ _id: false }
|
|
1791
2093
|
);
|
|
1792
|
-
var
|
|
2094
|
+
var schema19 = new MongooseSchema19(
|
|
1793
2095
|
{
|
|
1794
2096
|
active: { default: false, required: true, type: Boolean },
|
|
1795
2097
|
approvedAt: { default: null, required: false, type: Date },
|
|
@@ -1805,7 +2107,7 @@ var schema15 = new MongooseSchema19(
|
|
|
1805
2107
|
},
|
|
1806
2108
|
deletedAt: { default: null, required: false, type: Date },
|
|
1807
2109
|
postType: {
|
|
1808
|
-
enum: Object.values(
|
|
2110
|
+
enum: Object.values(import_cluemart_shared18.EnumPostType),
|
|
1809
2111
|
required: true,
|
|
1810
2112
|
type: String
|
|
1811
2113
|
},
|
|
@@ -1820,14 +2122,14 @@ var schema15 = new MongooseSchema19(
|
|
|
1820
2122
|
},
|
|
1821
2123
|
{ timestamps: true }
|
|
1822
2124
|
);
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
var PostModel =
|
|
2125
|
+
schema19.index({ title: 1 });
|
|
2126
|
+
schema19.index({ tags: 1 });
|
|
2127
|
+
schema19.index({ postType: 1, slug: 1 }, { unique: true });
|
|
2128
|
+
var PostModel = import_mongoose23.default.models.Post || import_mongoose23.default.model("Post", schema19);
|
|
1827
2129
|
|
|
1828
2130
|
// src/mongoose/AppSetting.ts
|
|
1829
|
-
var
|
|
1830
|
-
var MongooseSchema20 =
|
|
2131
|
+
var import_mongoose24 = __toESM(require("mongoose"));
|
|
2132
|
+
var MongooseSchema20 = import_mongoose24.default.Schema;
|
|
1831
2133
|
var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
|
|
1832
2134
|
var AppSettingSchema = new MongooseSchema20(
|
|
1833
2135
|
{
|
|
@@ -1860,18 +2162,18 @@ var AppSettingSchema = new MongooseSchema20(
|
|
|
1860
2162
|
},
|
|
1861
2163
|
{ timestamps: true }
|
|
1862
2164
|
);
|
|
1863
|
-
var AppSettingModel =
|
|
2165
|
+
var AppSettingModel = import_mongoose24.default.models.AppSetting || import_mongoose24.default.model("AppSetting", AppSettingSchema);
|
|
1864
2166
|
|
|
1865
2167
|
// src/mongoose/game/Game.ts
|
|
1866
|
-
var
|
|
1867
|
-
var
|
|
2168
|
+
var import_cluemart_shared19 = require("@timardex/cluemart-shared");
|
|
2169
|
+
var import_mongoose28 = __toESM(require("mongoose"));
|
|
1868
2170
|
|
|
1869
2171
|
// src/mongoose/game/DailyClue.ts
|
|
1870
|
-
var
|
|
2172
|
+
var import_mongoose26 = __toESM(require("mongoose"));
|
|
1871
2173
|
|
|
1872
2174
|
// src/mongoose/game/utils.ts
|
|
1873
|
-
var
|
|
1874
|
-
var MongooseSchema21 =
|
|
2175
|
+
var import_mongoose25 = __toESM(require("mongoose"));
|
|
2176
|
+
var MongooseSchema21 = import_mongoose25.default.Schema;
|
|
1875
2177
|
var schemaGameDate = new MongooseSchema21(
|
|
1876
2178
|
{
|
|
1877
2179
|
endDate: { required: true, type: Date },
|
|
@@ -1881,7 +2183,7 @@ var schemaGameDate = new MongooseSchema21(
|
|
|
1881
2183
|
);
|
|
1882
2184
|
|
|
1883
2185
|
// src/mongoose/game/DailyClue.ts
|
|
1884
|
-
var MongooseSchema22 =
|
|
2186
|
+
var MongooseSchema22 = import_mongoose26.default.Schema;
|
|
1885
2187
|
var schemaLetters = new MongooseSchema22(
|
|
1886
2188
|
{
|
|
1887
2189
|
collected: { required: false, type: [String] },
|
|
@@ -1912,8 +2214,8 @@ var schemaDailyClueGameData = new MongooseSchema22(
|
|
|
1912
2214
|
);
|
|
1913
2215
|
|
|
1914
2216
|
// src/mongoose/game/PuzzleGame.ts
|
|
1915
|
-
var
|
|
1916
|
-
var MongooseSchema23 =
|
|
2217
|
+
var import_mongoose27 = __toESM(require("mongoose"));
|
|
2218
|
+
var MongooseSchema23 = import_mongoose27.default.Schema;
|
|
1917
2219
|
var schemaPuzzleAnswer = new MongooseSchema23(
|
|
1918
2220
|
{
|
|
1919
2221
|
answer: { required: true, type: String },
|
|
@@ -1958,16 +2260,16 @@ var schemaPuzzleGameData = new MongooseSchema23(
|
|
|
1958
2260
|
);
|
|
1959
2261
|
|
|
1960
2262
|
// src/mongoose/game/Game.ts
|
|
1961
|
-
var MongooseSchema24 =
|
|
2263
|
+
var MongooseSchema24 = import_mongoose28.default.Schema;
|
|
1962
2264
|
var gameDataSchemas = {
|
|
1963
|
-
[
|
|
1964
|
-
[
|
|
1965
|
-
[
|
|
2265
|
+
[import_cluemart_shared19.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
|
|
2266
|
+
[import_cluemart_shared19.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
|
|
2267
|
+
[import_cluemart_shared19.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
|
|
1966
2268
|
};
|
|
1967
2269
|
var gameDataDefinition = Object.fromEntries(
|
|
1968
|
-
Object.entries(gameDataSchemas).map(([key,
|
|
2270
|
+
Object.entries(gameDataSchemas).map(([key, schema24]) => [
|
|
1969
2271
|
key,
|
|
1970
|
-
{ default: null, required: false, type:
|
|
2272
|
+
{ default: null, required: false, type: schema24 }
|
|
1971
2273
|
])
|
|
1972
2274
|
);
|
|
1973
2275
|
var gameHistorySchema = new MongooseSchema24(
|
|
@@ -1975,13 +2277,13 @@ var gameHistorySchema = new MongooseSchema24(
|
|
|
1975
2277
|
createdAt: { required: true, type: Date },
|
|
1976
2278
|
gameDate: { required: true, type: schemaGameDate },
|
|
1977
2279
|
gameStatus: {
|
|
1978
|
-
enum: Object.values(
|
|
2280
|
+
enum: Object.values(import_cluemart_shared19.EnumGameStatus),
|
|
1979
2281
|
required: true,
|
|
1980
2282
|
type: String
|
|
1981
2283
|
},
|
|
1982
2284
|
gameTitle: { required: true, type: String },
|
|
1983
2285
|
gameType: {
|
|
1984
|
-
enum: Object.values(
|
|
2286
|
+
enum: Object.values(import_cluemart_shared19.EnumGameType),
|
|
1985
2287
|
required: true,
|
|
1986
2288
|
type: String
|
|
1987
2289
|
},
|
|
@@ -1997,7 +2299,7 @@ var gameTypeSchema = new MongooseSchema24(
|
|
|
1997
2299
|
gameHistory: { default: [], required: true, type: [gameHistorySchema] },
|
|
1998
2300
|
gameTitle: { required: true, type: String },
|
|
1999
2301
|
gameType: {
|
|
2000
|
-
enum: Object.values(
|
|
2302
|
+
enum: Object.values(import_cluemart_shared19.EnumGameType),
|
|
2001
2303
|
required: true,
|
|
2002
2304
|
type: String
|
|
2003
2305
|
},
|
|
@@ -2005,7 +2307,7 @@ var gameTypeSchema = new MongooseSchema24(
|
|
|
2005
2307
|
},
|
|
2006
2308
|
{ timestamps: true }
|
|
2007
2309
|
);
|
|
2008
|
-
var
|
|
2310
|
+
var schema20 = new MongooseSchema24(
|
|
2009
2311
|
{
|
|
2010
2312
|
active: { default: false, required: true, type: Boolean },
|
|
2011
2313
|
deletedAt: { default: null, required: false, type: Date },
|
|
@@ -2018,11 +2320,11 @@ var schema16 = new MongooseSchema24(
|
|
|
2018
2320
|
},
|
|
2019
2321
|
{ timestamps: true }
|
|
2020
2322
|
);
|
|
2021
|
-
var GameModel =
|
|
2323
|
+
var GameModel = import_mongoose28.default.models.Game || import_mongoose28.default.model("Game", schema20);
|
|
2022
2324
|
|
|
2023
2325
|
// src/mongoose/School.ts
|
|
2024
|
-
var
|
|
2025
|
-
var MongooseSchema25 =
|
|
2326
|
+
var import_mongoose29 = __toESM(require("mongoose"));
|
|
2327
|
+
var MongooseSchema25 = import_mongoose29.default.Schema;
|
|
2026
2328
|
var campaignsSchema = new MongooseSchema25(
|
|
2027
2329
|
{
|
|
2028
2330
|
endDate: { required: true, type: Date },
|
|
@@ -2031,7 +2333,7 @@ var campaignsSchema = new MongooseSchema25(
|
|
|
2031
2333
|
},
|
|
2032
2334
|
{ _id: false }
|
|
2033
2335
|
);
|
|
2034
|
-
var
|
|
2336
|
+
var schema21 = new MongooseSchema25(
|
|
2035
2337
|
{
|
|
2036
2338
|
// New schools are active by default
|
|
2037
2339
|
active: { default: false, required: true, type: Boolean },
|
|
@@ -2058,26 +2360,26 @@ var schema17 = new MongooseSchema25(
|
|
|
2058
2360
|
},
|
|
2059
2361
|
{ timestamps: true }
|
|
2060
2362
|
);
|
|
2061
|
-
|
|
2363
|
+
schema21.index(
|
|
2062
2364
|
{ schoolCode: 1 },
|
|
2063
2365
|
{
|
|
2064
2366
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
2065
2367
|
unique: true
|
|
2066
2368
|
}
|
|
2067
2369
|
);
|
|
2068
|
-
var SchoolModel =
|
|
2370
|
+
var SchoolModel = import_mongoose29.default.models.School || import_mongoose29.default.model("School", schema21);
|
|
2069
2371
|
|
|
2070
2372
|
// src/mongoose/Affiliate.ts
|
|
2071
|
-
var
|
|
2072
|
-
var
|
|
2073
|
-
var MongooseSchema26 =
|
|
2373
|
+
var import_cluemart_shared20 = require("@timardex/cluemart-shared");
|
|
2374
|
+
var import_mongoose30 = __toESM(require("mongoose"));
|
|
2375
|
+
var MongooseSchema26 = import_mongoose30.default.Schema;
|
|
2074
2376
|
var affiliateRewardSchema = new MongooseSchema26(
|
|
2075
2377
|
{
|
|
2076
2378
|
createdAt: { required: true, type: Date },
|
|
2077
2379
|
redeemedAt: { default: null, required: false, type: Date },
|
|
2078
2380
|
rewardDescription: { required: true, type: String },
|
|
2079
2381
|
rewardType: {
|
|
2080
|
-
enum: Object.values(
|
|
2382
|
+
enum: Object.values(import_cluemart_shared20.EnumAffiliateRewardType),
|
|
2081
2383
|
required: true,
|
|
2082
2384
|
type: String
|
|
2083
2385
|
},
|
|
@@ -2091,7 +2393,7 @@ var affiliateResourceSchema = new MongooseSchema26(
|
|
|
2091
2393
|
resourceDeletedAt: { default: null, required: false, type: Date },
|
|
2092
2394
|
resourceId: {
|
|
2093
2395
|
required: true,
|
|
2094
|
-
type:
|
|
2396
|
+
type: import_mongoose30.default.Schema.Types.ObjectId
|
|
2095
2397
|
},
|
|
2096
2398
|
resourceName: { required: true, type: String },
|
|
2097
2399
|
resourceOwner: {
|
|
@@ -2099,7 +2401,7 @@ var affiliateResourceSchema = new MongooseSchema26(
|
|
|
2099
2401
|
type: OwnerTypeSchema
|
|
2100
2402
|
},
|
|
2101
2403
|
resourceType: {
|
|
2102
|
-
enum: Object.values(
|
|
2404
|
+
enum: Object.values(import_cluemart_shared20.EnumResourceType),
|
|
2103
2405
|
required: true,
|
|
2104
2406
|
type: String
|
|
2105
2407
|
},
|
|
@@ -2137,7 +2439,7 @@ var affiliateDetailsSchema = new MongooseSchema26(
|
|
|
2137
2439
|
lastName: { required: true, type: String },
|
|
2138
2440
|
location: { required: true, type: locationsSchema },
|
|
2139
2441
|
participantType: {
|
|
2140
|
-
enum: Object.values(
|
|
2442
|
+
enum: Object.values(import_cluemart_shared20.EnumAffiliateParticipantType),
|
|
2141
2443
|
required: true,
|
|
2142
2444
|
type: String
|
|
2143
2445
|
},
|
|
@@ -2154,7 +2456,7 @@ var redeemHistorySchema = new MongooseSchema26(
|
|
|
2154
2456
|
},
|
|
2155
2457
|
{ _id: false }
|
|
2156
2458
|
);
|
|
2157
|
-
var
|
|
2459
|
+
var schema22 = new MongooseSchema26(
|
|
2158
2460
|
{
|
|
2159
2461
|
active: { default: false, required: true, type: Boolean },
|
|
2160
2462
|
affiliateBonusRewards: {
|
|
@@ -2184,26 +2486,26 @@ var schema18 = new MongooseSchema26(
|
|
|
2184
2486
|
},
|
|
2185
2487
|
{ timestamps: true }
|
|
2186
2488
|
);
|
|
2187
|
-
|
|
2489
|
+
schema22.index(
|
|
2188
2490
|
{ affiliateCode: 1 },
|
|
2189
2491
|
{
|
|
2190
2492
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
2191
2493
|
unique: true
|
|
2192
2494
|
}
|
|
2193
2495
|
);
|
|
2194
|
-
var AffiliateModel =
|
|
2496
|
+
var AffiliateModel = import_mongoose30.default.models.Affiliate || import_mongoose30.default.model("Affiliate", schema22);
|
|
2195
2497
|
|
|
2196
2498
|
// src/mongoose/Coupon.ts
|
|
2197
|
-
var
|
|
2198
|
-
var
|
|
2199
|
-
var MongooseSchema27 =
|
|
2499
|
+
var import_cluemart_shared21 = require("@timardex/cluemart-shared");
|
|
2500
|
+
var import_mongoose31 = __toESM(require("mongoose"));
|
|
2501
|
+
var MongooseSchema27 = import_mongoose31.default.Schema;
|
|
2200
2502
|
var couponOptionSchema = new MongooseSchema27(
|
|
2201
2503
|
{
|
|
2202
2504
|
buy: { required: false, type: Number },
|
|
2203
2505
|
get: { required: false, type: Number },
|
|
2204
2506
|
maxRewardCount: { required: false, type: Number },
|
|
2205
2507
|
type: {
|
|
2206
|
-
enum: Object.values(
|
|
2508
|
+
enum: Object.values(import_cluemart_shared21.EnumCouponQualificationType),
|
|
2207
2509
|
required: true,
|
|
2208
2510
|
type: String
|
|
2209
2511
|
},
|
|
@@ -2216,20 +2518,20 @@ var couponVendorProductSchema = new MongooseSchema27(
|
|
|
2216
2518
|
{
|
|
2217
2519
|
couponId: {
|
|
2218
2520
|
required: true,
|
|
2219
|
-
type:
|
|
2521
|
+
type: import_mongoose31.default.Schema.Types.ObjectId
|
|
2220
2522
|
},
|
|
2221
2523
|
productId: {
|
|
2222
2524
|
required: true,
|
|
2223
|
-
type:
|
|
2525
|
+
type: import_mongoose31.default.Schema.Types.ObjectId
|
|
2224
2526
|
},
|
|
2225
2527
|
vendorCouponId: {
|
|
2226
2528
|
required: false,
|
|
2227
|
-
type:
|
|
2529
|
+
type: import_mongoose31.default.Schema.Types.ObjectId
|
|
2228
2530
|
},
|
|
2229
2531
|
vendorId: {
|
|
2230
2532
|
ref: "Vendor",
|
|
2231
2533
|
required: true,
|
|
2232
|
-
type:
|
|
2534
|
+
type: import_mongoose31.default.Schema.Types.ObjectId
|
|
2233
2535
|
}
|
|
2234
2536
|
},
|
|
2235
2537
|
{ _id: false }
|
|
@@ -2251,7 +2553,7 @@ var couponParticipantUserSchema = new MongooseSchema27(
|
|
|
2251
2553
|
userId: {
|
|
2252
2554
|
ref: "User",
|
|
2253
2555
|
required: true,
|
|
2254
|
-
type:
|
|
2556
|
+
type: import_mongoose31.default.Schema.Types.ObjectId
|
|
2255
2557
|
}
|
|
2256
2558
|
},
|
|
2257
2559
|
{ timestamps: true }
|
|
@@ -2275,7 +2577,7 @@ var couponDataSchema = new MongooseSchema27(
|
|
|
2275
2577
|
},
|
|
2276
2578
|
resourceId: { required: true, type: String },
|
|
2277
2579
|
resourceType: {
|
|
2278
|
-
enum: Object.values(
|
|
2580
|
+
enum: Object.values(import_cluemart_shared21.EnumResourceType),
|
|
2279
2581
|
required: true,
|
|
2280
2582
|
type: String
|
|
2281
2583
|
},
|
|
@@ -2283,7 +2585,7 @@ var couponDataSchema = new MongooseSchema27(
|
|
|
2283
2585
|
},
|
|
2284
2586
|
{ timestamps: true }
|
|
2285
2587
|
);
|
|
2286
|
-
var
|
|
2588
|
+
var schema23 = new MongooseSchema27(
|
|
2287
2589
|
{
|
|
2288
2590
|
active: { default: true, required: true, type: Boolean },
|
|
2289
2591
|
couponData: { default: [], required: false, type: [couponDataSchema] },
|
|
@@ -2295,9 +2597,9 @@ var schema19 = new MongooseSchema27(
|
|
|
2295
2597
|
},
|
|
2296
2598
|
{ timestamps: true }
|
|
2297
2599
|
);
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
var CouponModel =
|
|
2600
|
+
schema23.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
|
|
2601
|
+
schema23.index({ "couponData.participantUsers.userId": 1 });
|
|
2602
|
+
var CouponModel = import_mongoose31.default.models.Coupon || import_mongoose31.default.model("Coupon", schema23);
|
|
2301
2603
|
|
|
2302
2604
|
// src/service/promoCode/constants.ts
|
|
2303
2605
|
var ACTIVE_NOT_DELETED_FILTER = {
|
|
@@ -2315,7 +2617,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
|
|
|
2315
2617
|
}
|
|
2316
2618
|
|
|
2317
2619
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
2318
|
-
var
|
|
2620
|
+
var import_cluemart_shared23 = require("@timardex/cluemart-shared");
|
|
2319
2621
|
var import_utils3 = require("@timardex/cluemart-shared/utils");
|
|
2320
2622
|
|
|
2321
2623
|
// src/service/saveNotificationsInDb.ts
|
|
@@ -2452,7 +2754,7 @@ async function sendPushNotifications({
|
|
|
2452
2754
|
}
|
|
2453
2755
|
|
|
2454
2756
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
2455
|
-
var
|
|
2757
|
+
var import_cluemart_shared22 = require("@timardex/cluemart-shared");
|
|
2456
2758
|
var import_dayjs = __toESM(require("dayjs"));
|
|
2457
2759
|
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
|
|
2458
2760
|
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
@@ -2486,8 +2788,9 @@ async function getPayingStripePlanFor(userId, now, payingPlans) {
|
|
|
2486
2788
|
if (stripe == null || stripe.subscriptionId == null) {
|
|
2487
2789
|
return { hasSubscription: false, plan: null, validTypes };
|
|
2488
2790
|
}
|
|
2489
|
-
const hasActiveStatus = stripe.status === import_enums2.EnumSubscriptionStatus.ACTIVE
|
|
2490
|
-
|
|
2791
|
+
const hasActiveStatus = stripe.status === import_enums2.EnumSubscriptionStatus.ACTIVE;
|
|
2792
|
+
const paidThrough = stripe.endDate ? new Date(stripe.endDate).getTime() : Number.NaN;
|
|
2793
|
+
if (!hasActiveStatus || !Number.isFinite(paidThrough) || paidThrough <= now.getTime() || stripe.currentPlan == null) {
|
|
2491
2794
|
return { hasSubscription: false, plan: null, validTypes };
|
|
2492
2795
|
}
|
|
2493
2796
|
const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
|
|
@@ -2509,14 +2812,14 @@ import_dayjs.default.extend(import_timezone.default);
|
|
|
2509
2812
|
var SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
|
|
2510
2813
|
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
2511
2814
|
const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
|
|
2512
|
-
if (validTypes.has(
|
|
2815
|
+
if (validTypes.has(import_cluemart_shared22.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared22.EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
2513
2816
|
if (hasSubscription) {
|
|
2514
|
-
return
|
|
2817
|
+
return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
2515
2818
|
}
|
|
2516
|
-
return
|
|
2819
|
+
return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2517
2820
|
}
|
|
2518
|
-
if (validTypes.has(
|
|
2519
|
-
return
|
|
2821
|
+
if (validTypes.has(import_cluemart_shared22.EnumUserLicence.STANDARD_VENDOR)) {
|
|
2822
|
+
return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2520
2823
|
}
|
|
2521
2824
|
return null;
|
|
2522
2825
|
}
|
|
@@ -2528,7 +2831,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
|
|
|
2528
2831
|
|
|
2529
2832
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
2530
2833
|
function isEligibleVendorResource(resource) {
|
|
2531
|
-
return resource.resourceType ===
|
|
2834
|
+
return resource.resourceType === import_cluemart_shared23.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
|
|
2532
2835
|
}
|
|
2533
2836
|
async function findAffiliatesWithActiveVendorReferrals() {
|
|
2534
2837
|
return await AffiliateModel.find({
|
|
@@ -2537,7 +2840,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
2537
2840
|
$elemMatch: {
|
|
2538
2841
|
resourceActive: true,
|
|
2539
2842
|
resourceDeletedAt: null,
|
|
2540
|
-
resourceType:
|
|
2843
|
+
resourceType: import_cluemart_shared23.EnumResourceType.VENDOR
|
|
2541
2844
|
}
|
|
2542
2845
|
},
|
|
2543
2846
|
deletedAt: null
|
|
@@ -2558,18 +2861,24 @@ async function isEligibleReferredVendor({
|
|
|
2558
2861
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
2559
2862
|
affiliateId,
|
|
2560
2863
|
affiliateOwnerUserId,
|
|
2561
|
-
|
|
2562
|
-
rewardValue
|
|
2864
|
+
awards
|
|
2563
2865
|
}) {
|
|
2866
|
+
if (awards.length === 0) {
|
|
2867
|
+
return;
|
|
2868
|
+
}
|
|
2869
|
+
const totalPoints = awards.reduce((sum, award) => sum + award.rewardValue, 0);
|
|
2870
|
+
const resourceNames = awards.map((award) => award.resourceName);
|
|
2871
|
+
const pointLabel = totalPoints === 1 ? "point" : "points";
|
|
2872
|
+
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.`;
|
|
2564
2873
|
const payload = {
|
|
2565
2874
|
data: {
|
|
2566
2875
|
resourceId: String(affiliateId),
|
|
2567
|
-
resourceName,
|
|
2568
|
-
resourceType:
|
|
2876
|
+
resourceName: resourceNames.join(", "),
|
|
2877
|
+
resourceType: import_cluemart_shared23.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
|
|
2569
2878
|
},
|
|
2570
|
-
message
|
|
2879
|
+
message,
|
|
2571
2880
|
title: "Affiliate points earned",
|
|
2572
|
-
type:
|
|
2881
|
+
type: import_cluemart_shared23.EnumNotificationType.SYSTEM,
|
|
2573
2882
|
userIds: [affiliateOwnerUserId]
|
|
2574
2883
|
};
|
|
2575
2884
|
try {
|
|
@@ -2598,7 +2907,7 @@ async function tryAwardSubscriptionReward({
|
|
|
2598
2907
|
resourceActive: true,
|
|
2599
2908
|
resourceDeletedAt: null,
|
|
2600
2909
|
resourceId: resource.resourceId,
|
|
2601
|
-
resourceType:
|
|
2910
|
+
resourceType: import_cluemart_shared23.EnumResourceType.VENDOR,
|
|
2602
2911
|
rewards: {
|
|
2603
2912
|
$not: {
|
|
2604
2913
|
$elemMatch: {
|
|
@@ -2619,15 +2928,12 @@ async function tryAwardSubscriptionReward({
|
|
|
2619
2928
|
}
|
|
2620
2929
|
).exec();
|
|
2621
2930
|
if (updateResult.modifiedCount === 0) {
|
|
2622
|
-
return
|
|
2931
|
+
return null;
|
|
2623
2932
|
}
|
|
2624
|
-
|
|
2625
|
-
affiliateId: affiliate._id,
|
|
2626
|
-
affiliateOwnerUserId: affiliate.owner.userId,
|
|
2933
|
+
return {
|
|
2627
2934
|
resourceName: resource.resourceName,
|
|
2628
2935
|
rewardValue: reward.rewardValue
|
|
2629
|
-
}
|
|
2630
|
-
return "awarded";
|
|
2936
|
+
};
|
|
2631
2937
|
}
|
|
2632
2938
|
async function processAffiliateVendorReferral({
|
|
2633
2939
|
affiliate,
|
|
@@ -2641,14 +2947,14 @@ async function processAffiliateVendorReferral({
|
|
|
2641
2947
|
resourceOwnerUserId: resource.resourceOwner.userId
|
|
2642
2948
|
});
|
|
2643
2949
|
if (!vendorEligible) {
|
|
2644
|
-
return
|
|
2950
|
+
return null;
|
|
2645
2951
|
}
|
|
2646
2952
|
const rewardType = await mapVendorLicenceToSubscriptionRewardType(
|
|
2647
2953
|
resource.resourceOwner.userId,
|
|
2648
2954
|
now
|
|
2649
2955
|
);
|
|
2650
2956
|
if (!rewardType) {
|
|
2651
|
-
return
|
|
2957
|
+
return null;
|
|
2652
2958
|
}
|
|
2653
2959
|
return tryAwardSubscriptionReward({
|
|
2654
2960
|
affiliate,
|
|
@@ -2664,8 +2970,9 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
|
|
|
2664
2970
|
const affiliates = await findAffiliatesWithActiveVendorReferrals();
|
|
2665
2971
|
let awarded = 0;
|
|
2666
2972
|
let skipped = 0;
|
|
2667
|
-
const seenPairs = /* @__PURE__ */ new Set();
|
|
2668
2973
|
for (const affiliate of affiliates) {
|
|
2974
|
+
const awards = [];
|
|
2975
|
+
const seenPairs = /* @__PURE__ */ new Set();
|
|
2669
2976
|
for (const resource of affiliate.affiliateResources) {
|
|
2670
2977
|
if (!isEligibleVendorResource(resource)) {
|
|
2671
2978
|
continue;
|
|
@@ -2675,19 +2982,27 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
|
|
|
2675
2982
|
continue;
|
|
2676
2983
|
}
|
|
2677
2984
|
seenPairs.add(pairKey);
|
|
2678
|
-
const
|
|
2985
|
+
const award = await processAffiliateVendorReferral({
|
|
2679
2986
|
affiliate,
|
|
2680
2987
|
createdAt,
|
|
2681
2988
|
now,
|
|
2682
2989
|
period,
|
|
2683
2990
|
resource
|
|
2684
2991
|
});
|
|
2685
|
-
if (
|
|
2992
|
+
if (award) {
|
|
2686
2993
|
awarded += 1;
|
|
2994
|
+
awards.push(award);
|
|
2687
2995
|
} else {
|
|
2688
2996
|
skipped += 1;
|
|
2689
2997
|
}
|
|
2690
2998
|
}
|
|
2999
|
+
if (awards.length > 0) {
|
|
3000
|
+
await notifyAffiliateOwnerOfSubscriptionReward({
|
|
3001
|
+
affiliateId: affiliate._id,
|
|
3002
|
+
affiliateOwnerUserId: affiliate.owner.userId,
|
|
3003
|
+
awards
|
|
3004
|
+
});
|
|
3005
|
+
}
|
|
2691
3006
|
}
|
|
2692
3007
|
return { awarded, skipped };
|
|
2693
3008
|
}
|
|
@@ -2713,7 +3028,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
|
|
|
2713
3028
|
}
|
|
2714
3029
|
|
|
2715
3030
|
// src/service/database.ts
|
|
2716
|
-
var
|
|
3031
|
+
var import_mongoose35 = __toESM(require("mongoose"));
|
|
2717
3032
|
var connectToDatabase = async ({
|
|
2718
3033
|
appName,
|
|
2719
3034
|
dbName,
|
|
@@ -2726,7 +3041,7 @@ var connectToDatabase = async ({
|
|
|
2726
3041
|
// Fallback to MongoDB Atlas connection string
|
|
2727
3042
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
2728
3043
|
);
|
|
2729
|
-
await
|
|
3044
|
+
await import_mongoose35.default.connect(mongoUri);
|
|
2730
3045
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
2731
3046
|
console.log(
|
|
2732
3047
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -2739,7 +3054,7 @@ var connectToDatabase = async ({
|
|
|
2739
3054
|
|
|
2740
3055
|
// src/types/index.ts
|
|
2741
3056
|
var import_express = __toESM(require("express"));
|
|
2742
|
-
var
|
|
3057
|
+
var import_mongoose36 = __toESM(require("mongoose"));
|
|
2743
3058
|
var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
|
|
2744
3059
|
EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
|
|
2745
3060
|
EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
|
|
@@ -2794,7 +3109,7 @@ async function notifyUsers({
|
|
|
2794
3109
|
}
|
|
2795
3110
|
|
|
2796
3111
|
// src/service/updateAdStatus.ts
|
|
2797
|
-
var
|
|
3112
|
+
var import_cluemart_shared24 = require("@timardex/cluemart-shared");
|
|
2798
3113
|
async function updateAdStatuses() {
|
|
2799
3114
|
const now = /* @__PURE__ */ new Date();
|
|
2800
3115
|
const invalidResult = await AdModel.updateMany(
|
|
@@ -2804,41 +3119,66 @@ async function updateAdStatuses() {
|
|
|
2804
3119
|
{ end: { $exists: false } },
|
|
2805
3120
|
{ $expr: { $gt: ["$start", "$end"] } }
|
|
2806
3121
|
],
|
|
2807
|
-
status: { $ne:
|
|
3122
|
+
status: { $ne: import_cluemart_shared24.EnumAdStatus.PAUSED }
|
|
2808
3123
|
},
|
|
2809
|
-
{ $set: { status:
|
|
3124
|
+
{ $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
|
|
2810
3125
|
);
|
|
2811
3126
|
const expiredResult = await AdModel.updateMany(
|
|
2812
|
-
{ end: { $lte: now }, status: { $ne:
|
|
2813
|
-
{ $set: { status:
|
|
3127
|
+
{ end: { $lte: now }, status: { $ne: import_cluemart_shared24.EnumAdStatus.EXPIRED } },
|
|
3128
|
+
{ $set: { status: import_cluemart_shared24.EnumAdStatus.EXPIRED } }
|
|
3129
|
+
);
|
|
3130
|
+
const eligibleBooking = {
|
|
3131
|
+
$or: [
|
|
3132
|
+
{ bookingKind: { $exists: false } },
|
|
3133
|
+
{ bookingKind: null },
|
|
3134
|
+
{
|
|
3135
|
+
approvalStatus: import_cluemart_shared24.EnumAdApprovalStatus.APPROVED,
|
|
3136
|
+
bookingKind: import_cluemart_shared24.EnumAdBookingSlotKind.RESERVED
|
|
3137
|
+
},
|
|
3138
|
+
{
|
|
3139
|
+
approvalStatus: import_cluemart_shared24.EnumAdApprovalStatus.APPROVED,
|
|
3140
|
+
bookingKind: import_cluemart_shared24.EnumAdBookingSlotKind.PAID,
|
|
3141
|
+
paymentStatus: import_cluemart_shared24.EnumAdPaymentStatus.PAID
|
|
3142
|
+
}
|
|
3143
|
+
]
|
|
3144
|
+
};
|
|
3145
|
+
const awaitingApprovalResult = await AdModel.updateMany(
|
|
3146
|
+
{
|
|
3147
|
+
$nor: eligibleBooking.$or,
|
|
3148
|
+
bookingKind: { $in: Object.values(import_cluemart_shared24.EnumAdBookingSlotKind) },
|
|
3149
|
+
end: { $gt: now },
|
|
3150
|
+
status: import_cluemart_shared24.EnumAdStatus.ACTIVE
|
|
3151
|
+
},
|
|
3152
|
+
{ $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
|
|
2814
3153
|
);
|
|
2815
3154
|
const activeResult = await AdModel.updateMany(
|
|
2816
3155
|
{
|
|
2817
3156
|
end: { $gt: now },
|
|
2818
3157
|
start: { $lte: now },
|
|
2819
|
-
status: { $ne:
|
|
3158
|
+
status: { $ne: import_cluemart_shared24.EnumAdStatus.ACTIVE },
|
|
3159
|
+
...eligibleBooking
|
|
2820
3160
|
},
|
|
2821
|
-
{ $set: { status:
|
|
3161
|
+
{ $set: { status: import_cluemart_shared24.EnumAdStatus.ACTIVE } }
|
|
2822
3162
|
);
|
|
2823
3163
|
const pausedResult = await AdModel.updateMany(
|
|
2824
|
-
{ start: { $gt: now }, status: { $ne:
|
|
2825
|
-
{ $set: { status:
|
|
3164
|
+
{ start: { $gt: now }, status: { $ne: import_cluemart_shared24.EnumAdStatus.PAUSED } },
|
|
3165
|
+
{ $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
|
|
2826
3166
|
);
|
|
2827
3167
|
console.log(
|
|
2828
|
-
`\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
|
|
3168
|
+
`\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
|
|
2829
3169
|
);
|
|
2830
3170
|
}
|
|
2831
3171
|
|
|
2832
3172
|
// src/service/objectIdToString.ts
|
|
2833
|
-
var
|
|
3173
|
+
var import_mongoose38 = __toESM(require("mongoose"));
|
|
2834
3174
|
function isValidObjectId(value) {
|
|
2835
|
-
return
|
|
3175
|
+
return import_mongoose38.default.Types.ObjectId.isValid(value);
|
|
2836
3176
|
}
|
|
2837
3177
|
function convertObjectIdsToStrings(obj) {
|
|
2838
3178
|
if (obj === null || obj === void 0) {
|
|
2839
3179
|
return obj;
|
|
2840
3180
|
}
|
|
2841
|
-
if (obj instanceof
|
|
3181
|
+
if (obj instanceof import_mongoose38.default.Types.ObjectId) {
|
|
2842
3182
|
return obj.toString();
|
|
2843
3183
|
}
|
|
2844
3184
|
if (obj instanceof Date) {
|
|
@@ -2858,7 +3198,7 @@ function convertObjectIdsToStrings(obj) {
|
|
|
2858
3198
|
}
|
|
2859
3199
|
|
|
2860
3200
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
2861
|
-
var
|
|
3201
|
+
var import_cluemart_shared25 = require("@timardex/cluemart-shared");
|
|
2862
3202
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
2863
3203
|
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
2864
3204
|
var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
|
|
@@ -2867,24 +3207,24 @@ import_dayjs2.default.extend(import_isoWeek.default);
|
|
|
2867
3207
|
function getFutureEventStatus(startDateTime, now) {
|
|
2868
3208
|
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
2869
3209
|
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
2870
|
-
return
|
|
3210
|
+
return import_cluemart_shared25.EnumEventDateStatus.STARTING_SOON;
|
|
2871
3211
|
}
|
|
2872
3212
|
if (startDateTime.isSame(now, "day")) {
|
|
2873
|
-
return
|
|
3213
|
+
return import_cluemart_shared25.EnumEventDateStatus.TODAY;
|
|
2874
3214
|
}
|
|
2875
3215
|
if (startDateTime.isSame(now.add(1, "day"), "day")) {
|
|
2876
|
-
return
|
|
3216
|
+
return import_cluemart_shared25.EnumEventDateStatus.TOMORROW;
|
|
2877
3217
|
}
|
|
2878
3218
|
if (startDateTime.isSame(now, "isoWeek")) {
|
|
2879
|
-
return
|
|
3219
|
+
return import_cluemart_shared25.EnumEventDateStatus.THIS_WEEK;
|
|
2880
3220
|
}
|
|
2881
3221
|
if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
|
|
2882
|
-
return
|
|
3222
|
+
return import_cluemart_shared25.EnumEventDateStatus.NEXT_WEEK;
|
|
2883
3223
|
}
|
|
2884
|
-
return
|
|
3224
|
+
return import_cluemart_shared25.EnumEventDateStatus.UPCOMING;
|
|
2885
3225
|
}
|
|
2886
3226
|
function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()) {
|
|
2887
|
-
const dateTimeFormat = `${
|
|
3227
|
+
const dateTimeFormat = `${import_cluemart_shared25.dateFormat} ${import_cluemart_shared25.timeFormat}`;
|
|
2888
3228
|
const startDateTime = (0, import_dayjs2.default)(
|
|
2889
3229
|
`${dateTime.startDate} ${dateTime.startTime}`,
|
|
2890
3230
|
dateTimeFormat,
|
|
@@ -2898,13 +3238,13 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
|
|
|
2898
3238
|
if (!startDateTime.isValid() || !endDateTime.isValid()) {
|
|
2899
3239
|
return {
|
|
2900
3240
|
...dateTime,
|
|
2901
|
-
dateStatus:
|
|
3241
|
+
dateStatus: import_cluemart_shared25.EnumEventDateStatus.INVALID
|
|
2902
3242
|
};
|
|
2903
3243
|
}
|
|
2904
3244
|
if (endDateTime.isBefore(startDateTime)) {
|
|
2905
3245
|
return {
|
|
2906
3246
|
...dateTime,
|
|
2907
|
-
dateStatus:
|
|
3247
|
+
dateStatus: import_cluemart_shared25.EnumEventDateStatus.INVALID
|
|
2908
3248
|
};
|
|
2909
3249
|
}
|
|
2910
3250
|
let dateStatus;
|
|
@@ -2912,10 +3252,10 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
|
|
|
2912
3252
|
if (startDateTime.isAfter(now)) {
|
|
2913
3253
|
dateStatus = getFutureEventStatus(startDateTime, now);
|
|
2914
3254
|
} else {
|
|
2915
|
-
dateStatus =
|
|
3255
|
+
dateStatus = import_cluemart_shared25.EnumEventDateStatus.STARTED;
|
|
2916
3256
|
}
|
|
2917
3257
|
} else {
|
|
2918
|
-
dateStatus =
|
|
3258
|
+
dateStatus = import_cluemart_shared25.EnumEventDateStatus.ENDED;
|
|
2919
3259
|
}
|
|
2920
3260
|
return {
|
|
2921
3261
|
...dateTime,
|
|
@@ -2999,7 +3339,7 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
2999
3339
|
}
|
|
3000
3340
|
|
|
3001
3341
|
// src/service/relations.ts
|
|
3002
|
-
var
|
|
3342
|
+
var import_cluemart_shared26 = require("@timardex/cluemart-shared");
|
|
3003
3343
|
function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
|
|
3004
3344
|
if (!previousDateTime?.length) {
|
|
3005
3345
|
return false;
|
|
@@ -3017,7 +3357,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
3017
3357
|
) ?? false;
|
|
3018
3358
|
return {
|
|
3019
3359
|
...relationDate,
|
|
3020
|
-
status: existsInEvent ? relationDate.status :
|
|
3360
|
+
status: existsInEvent ? relationDate.status : import_cluemart_shared26.EnumInviteStatus.UNAVAILABLE
|
|
3021
3361
|
};
|
|
3022
3362
|
});
|
|
3023
3363
|
}
|
|
@@ -3026,15 +3366,15 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
3026
3366
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
3027
3367
|
|
|
3028
3368
|
// src/service/license/compliance/utils.ts
|
|
3029
|
-
var
|
|
3369
|
+
var import_cluemart_shared31 = require("@timardex/cluemart-shared");
|
|
3030
3370
|
var import_dayjs5 = __toESM(require("dayjs"));
|
|
3031
3371
|
|
|
3032
3372
|
// src/service/license/compliance/event.ts
|
|
3033
|
-
var
|
|
3373
|
+
var import_cluemart_shared27 = require("@timardex/cluemart-shared");
|
|
3034
3374
|
var eventLicences = [
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3375
|
+
import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT,
|
|
3376
|
+
import_cluemart_shared27.EnumUserLicence.PRO_EVENT,
|
|
3377
|
+
import_cluemart_shared27.EnumUserLicence.PRO_PLUS_EVENT
|
|
3038
3378
|
];
|
|
3039
3379
|
async function handleEventLicenceCompliance(user, now) {
|
|
3040
3380
|
if (!user.licences || !user.events?.length) {
|
|
@@ -3246,9 +3586,9 @@ function buildLicenceExpiryPipeline(params) {
|
|
|
3246
3586
|
}
|
|
3247
3587
|
|
|
3248
3588
|
// src/service/license/compliance/partner.ts
|
|
3249
|
-
var
|
|
3589
|
+
var import_cluemart_shared28 = require("@timardex/cluemart-shared");
|
|
3250
3590
|
var partnerLicences = [
|
|
3251
|
-
|
|
3591
|
+
import_cluemart_shared28.EnumUserLicence.STANDARD_PARTNER
|
|
3252
3592
|
];
|
|
3253
3593
|
async function handlePartnerLicenceCompliance(user, now) {
|
|
3254
3594
|
if (!user.licences || !user.partner) {
|
|
@@ -3258,17 +3598,19 @@ async function handlePartnerLicenceCompliance(user, now) {
|
|
|
3258
3598
|
}
|
|
3259
3599
|
|
|
3260
3600
|
// src/service/license/compliance/vendor.ts
|
|
3261
|
-
var
|
|
3601
|
+
var import_cluemart_shared30 = require("@timardex/cluemart-shared");
|
|
3262
3602
|
var import_dayjs4 = __toESM(require("dayjs"));
|
|
3263
3603
|
|
|
3264
3604
|
// src/service/license/models.ts
|
|
3265
|
-
var
|
|
3605
|
+
var import_cluemart_shared29 = require("@timardex/cluemart-shared");
|
|
3266
3606
|
var import_dayjs3 = __toESM(require("dayjs"));
|
|
3267
3607
|
var import_graphql = require("graphql");
|
|
3268
3608
|
var LicenceExpiryDate = /* @__PURE__ */ ((LicenceExpiryDate2) => {
|
|
3269
3609
|
LicenceExpiryDate2["ONE_YEAR"] = "1 year";
|
|
3270
3610
|
LicenceExpiryDate2["ONE_MONTH"] = "1 month";
|
|
3271
3611
|
LicenceExpiryDate2["TWO_MONTHS"] = "2 months";
|
|
3612
|
+
LicenceExpiryDate2["THREE_MONTHS"] = "3 months";
|
|
3613
|
+
LicenceExpiryDate2["SIX_MONTHS"] = "6 months";
|
|
3272
3614
|
return LicenceExpiryDate2;
|
|
3273
3615
|
})(LicenceExpiryDate || {});
|
|
3274
3616
|
var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
@@ -3280,31 +3622,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
|
3280
3622
|
return LicenceCategory2;
|
|
3281
3623
|
})(LicenceCategory || {});
|
|
3282
3624
|
var licenceCategoryMapping = {
|
|
3283
|
-
[
|
|
3284
|
-
[
|
|
3285
|
-
[
|
|
3286
|
-
[
|
|
3287
|
-
[
|
|
3288
|
-
[
|
|
3289
|
-
[
|
|
3290
|
-
[
|
|
3291
|
-
[
|
|
3625
|
+
[import_cluemart_shared29.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
|
|
3626
|
+
[import_cluemart_shared29.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
|
|
3627
|
+
[import_cluemart_shared29.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
|
|
3628
|
+
[import_cluemart_shared29.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
|
|
3629
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
|
|
3630
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
|
|
3631
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
|
|
3632
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
3633
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
|
|
3292
3634
|
};
|
|
3293
3635
|
var licencePriority = {
|
|
3294
|
-
[
|
|
3295
|
-
[
|
|
3296
|
-
[
|
|
3297
|
-
[
|
|
3298
|
-
[
|
|
3299
|
-
[
|
|
3300
|
-
[
|
|
3301
|
-
[
|
|
3302
|
-
[
|
|
3636
|
+
[import_cluemart_shared29.EnumUserLicence.PRO_PLUS_EVENT]: 3,
|
|
3637
|
+
[import_cluemart_shared29.EnumUserLicence.PRO_EVENT]: 2,
|
|
3638
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT]: 1,
|
|
3639
|
+
[import_cluemart_shared29.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
|
|
3640
|
+
[import_cluemart_shared29.EnumUserLicence.PRO_VENDOR]: 2,
|
|
3641
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR]: 1,
|
|
3642
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER]: 1,
|
|
3643
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_AFFILIATE]: 1,
|
|
3644
|
+
[import_cluemart_shared29.EnumUserLicence.STANDARD_SCHOOL]: 1
|
|
3303
3645
|
};
|
|
3304
3646
|
var standardLicences = [
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3647
|
+
import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR,
|
|
3648
|
+
import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT,
|
|
3649
|
+
import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER
|
|
3308
3650
|
];
|
|
3309
3651
|
var standardLicenceSet = new Set(standardLicences);
|
|
3310
3652
|
function isStandardLicence(licence) {
|
|
@@ -3318,11 +3660,11 @@ var categoryRegexMapping = {
|
|
|
3318
3660
|
["school" /* SCHOOL */]: /_school$/
|
|
3319
3661
|
};
|
|
3320
3662
|
var categoryFallbackLicence = {
|
|
3321
|
-
["event" /* EVENT */]:
|
|
3322
|
-
["partner" /* PARTNER */]:
|
|
3323
|
-
["vendor" /* VENDOR */]:
|
|
3324
|
-
["affiliate" /* AFFILIATE */]:
|
|
3325
|
-
["school" /* SCHOOL */]:
|
|
3663
|
+
["event" /* EVENT */]: import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT,
|
|
3664
|
+
["partner" /* PARTNER */]: import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER,
|
|
3665
|
+
["vendor" /* VENDOR */]: import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR,
|
|
3666
|
+
["affiliate" /* AFFILIATE */]: import_cluemart_shared29.EnumUserLicence.STANDARD_AFFILIATE,
|
|
3667
|
+
["school" /* SCHOOL */]: import_cluemart_shared29.EnumUserLicence.STANDARD_SCHOOL
|
|
3326
3668
|
};
|
|
3327
3669
|
var LicenceFilterInput = {
|
|
3328
3670
|
INPUT_USER_LICENCES: "$licences"
|
|
@@ -3354,7 +3696,9 @@ function createLicenceObject(expiryDate, licenceType) {
|
|
|
3354
3696
|
const expiryDateMapping = {
|
|
3355
3697
|
["1 year" /* ONE_YEAR */]: today.add(1, "year").endOf("day").toDate(),
|
|
3356
3698
|
["1 month" /* ONE_MONTH */]: today.add(1, "month").endOf("day").toDate(),
|
|
3357
|
-
["2 months" /* TWO_MONTHS */]: today.add(2, "month").endOf("day").toDate()
|
|
3699
|
+
["2 months" /* TWO_MONTHS */]: today.add(2, "month").endOf("day").toDate(),
|
|
3700
|
+
["3 months" /* THREE_MONTHS */]: today.add(3, "month").endOf("day").toDate(),
|
|
3701
|
+
["6 months" /* SIX_MONTHS */]: today.add(6, "month").endOf("day").toDate()
|
|
3358
3702
|
};
|
|
3359
3703
|
const licenceObject = {
|
|
3360
3704
|
expiryDate: expiryDateMapping[expiryDate],
|
|
@@ -3458,13 +3802,13 @@ async function checkOwnerHasLicence({
|
|
|
3458
3802
|
const owner = await UserModel.findById(userId);
|
|
3459
3803
|
if (!owner) throw new import_graphql.GraphQLError("Owner not found");
|
|
3460
3804
|
const categoryByResource = {
|
|
3461
|
-
[
|
|
3462
|
-
[
|
|
3463
|
-
[
|
|
3464
|
-
[
|
|
3465
|
-
[
|
|
3805
|
+
[import_cluemart_shared29.EnumResourceType.EVENT]: "event" /* EVENT */,
|
|
3806
|
+
[import_cluemart_shared29.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
|
|
3807
|
+
[import_cluemart_shared29.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
|
|
3808
|
+
[import_cluemart_shared29.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
3809
|
+
[import_cluemart_shared29.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
|
|
3466
3810
|
};
|
|
3467
|
-
if (!(0,
|
|
3811
|
+
if (!(0, import_cluemart_shared29.isNonVisitorResourceType)(resourceType)) {
|
|
3468
3812
|
throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
|
|
3469
3813
|
}
|
|
3470
3814
|
const requiredCategory = categoryByResource[resourceType];
|
|
@@ -3501,7 +3845,9 @@ async function findUserVendor(userId, logLabel) {
|
|
|
3501
3845
|
"owner.userId": userId
|
|
3502
3846
|
}).lean().exec();
|
|
3503
3847
|
if (!vendor) {
|
|
3504
|
-
console.warn(
|
|
3848
|
+
console.warn(
|
|
3849
|
+
`[${logLabel}] Vendor not found for id=${user.vendor}, userId=${userId}`
|
|
3850
|
+
);
|
|
3505
3851
|
return null;
|
|
3506
3852
|
}
|
|
3507
3853
|
return vendor;
|
|
@@ -3542,7 +3888,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
|
|
|
3542
3888
|
return (result?.matchedCount ?? 0) > 0;
|
|
3543
3889
|
}
|
|
3544
3890
|
async function downgradeVendorProFeatures(userId, licenceType) {
|
|
3545
|
-
const isStandardVendor = licenceType ===
|
|
3891
|
+
const isStandardVendor = licenceType === import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR;
|
|
3546
3892
|
if (!isStandardVendor) {
|
|
3547
3893
|
return;
|
|
3548
3894
|
}
|
|
@@ -3554,6 +3900,7 @@ async function downgradeVendorProFeatures(userId, licenceType) {
|
|
|
3554
3900
|
await applyVendorDowngrade(vendor, userId);
|
|
3555
3901
|
} catch (error) {
|
|
3556
3902
|
console.error("[downgradeVendorProFeatures] Failed:", error);
|
|
3903
|
+
throw error;
|
|
3557
3904
|
}
|
|
3558
3905
|
}
|
|
3559
3906
|
async function applyVendorRestore(vendor, ownerUserId) {
|
|
@@ -3588,7 +3935,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
|
|
|
3588
3935
|
return (result?.matchedCount ?? 0) > 0;
|
|
3589
3936
|
}
|
|
3590
3937
|
async function restoreVendorProFeatures(userId, licenceType) {
|
|
3591
|
-
const isProVendor = licenceType ===
|
|
3938
|
+
const isProVendor = licenceType === import_cluemart_shared30.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR;
|
|
3592
3939
|
if (!isProVendor) {
|
|
3593
3940
|
return;
|
|
3594
3941
|
}
|
|
@@ -3600,23 +3947,35 @@ async function restoreVendorProFeatures(userId, licenceType) {
|
|
|
3600
3947
|
await applyVendorRestore(vendor, userId);
|
|
3601
3948
|
} catch (error) {
|
|
3602
3949
|
console.error("[restoreVendorProFeatures] Failed:", error);
|
|
3950
|
+
throw error;
|
|
3603
3951
|
}
|
|
3604
3952
|
}
|
|
3605
3953
|
var vendorLicences = [
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3954
|
+
import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR,
|
|
3955
|
+
import_cluemart_shared30.EnumUserLicence.PRO_VENDOR,
|
|
3956
|
+
import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR
|
|
3609
3957
|
];
|
|
3610
3958
|
function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
|
|
3611
3959
|
const stripe = user.stripe;
|
|
3612
|
-
if (!stripe
|
|
3960
|
+
if (!stripe || stripe.currentPlan !== licenceType) {
|
|
3613
3961
|
return false;
|
|
3614
3962
|
}
|
|
3615
|
-
|
|
3963
|
+
const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs4.default)(stripe.paymentGracePeriodEndsAt) : null;
|
|
3964
|
+
const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared30.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared30.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
|
|
3965
|
+
if (hasActivePaymentGracePeriod) {
|
|
3616
3966
|
return true;
|
|
3617
3967
|
}
|
|
3968
|
+
if (!stripe.subscriptionId) {
|
|
3969
|
+
return false;
|
|
3970
|
+
}
|
|
3971
|
+
if (stripe.status !== import_cluemart_shared30.EnumSubscriptionStatus.ACTIVE) {
|
|
3972
|
+
return false;
|
|
3973
|
+
}
|
|
3974
|
+
if (!stripe.endDate) {
|
|
3975
|
+
return false;
|
|
3976
|
+
}
|
|
3618
3977
|
const paidThrough = (0, import_dayjs4.default)(stripe.endDate);
|
|
3619
|
-
return
|
|
3978
|
+
return paidThrough.isValid() && paidThrough.isAfter(now);
|
|
3620
3979
|
}
|
|
3621
3980
|
async function handleVendorLicenceCompliance(user, now) {
|
|
3622
3981
|
if (!user.licences || !user.vendor) {
|
|
@@ -3629,7 +3988,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3629
3988
|
return;
|
|
3630
3989
|
}
|
|
3631
3990
|
const proLicences = vendorLicencesOfUser.filter(
|
|
3632
|
-
(licence) => licence.licenceType !==
|
|
3991
|
+
(licence) => licence.licenceType !== import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR
|
|
3633
3992
|
);
|
|
3634
3993
|
const expiredProLicences = proLicences.filter(
|
|
3635
3994
|
(licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now)
|
|
@@ -3673,11 +4032,11 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
3673
4032
|
data: {
|
|
3674
4033
|
resourceId: String(vendor._id),
|
|
3675
4034
|
resourceName: vendor.name,
|
|
3676
|
-
resourceType:
|
|
4035
|
+
resourceType: import_cluemart_shared30.EnumNotificationResourceType.DOWNGRADED_VENDOR
|
|
3677
4036
|
},
|
|
3678
4037
|
message: `Your Vendor license has been downgraded due to licence expiration.`,
|
|
3679
4038
|
title: `Vendor License Downgraded`,
|
|
3680
|
-
type:
|
|
4039
|
+
type: import_cluemart_shared30.EnumNotificationType.SYSTEM,
|
|
3681
4040
|
userIds: [user._id]
|
|
3682
4041
|
};
|
|
3683
4042
|
await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
|
|
@@ -3691,12 +4050,26 @@ async function vendorOwnerHasProLicence(vendorId) {
|
|
|
3691
4050
|
if (!vendor) {
|
|
3692
4051
|
return false;
|
|
3693
4052
|
}
|
|
3694
|
-
const owner = await UserModel.findById(vendor.owner.userId, {
|
|
4053
|
+
const owner = await UserModel.findById(vendor.owner.userId, {
|
|
4054
|
+
licences: 1,
|
|
4055
|
+
stripe: 1
|
|
4056
|
+
}).lean().exec();
|
|
4057
|
+
if (!owner) {
|
|
4058
|
+
return false;
|
|
4059
|
+
}
|
|
4060
|
+
const now = (0, import_dayjs4.default)();
|
|
4061
|
+
const effectiveVendorLicences = owner.licences?.filter(
|
|
4062
|
+
(licence) => licence?.licenceType && ((0, import_dayjs4.default)(licence.expiryDate).isAfter(now) || isProtectedByCurrentStripeSubscription(
|
|
4063
|
+
owner,
|
|
4064
|
+
licence.licenceType,
|
|
4065
|
+
now
|
|
4066
|
+
))
|
|
4067
|
+
);
|
|
3695
4068
|
const highestVendorLicence = getHighestLicenceForCategory(
|
|
3696
|
-
|
|
4069
|
+
effectiveVendorLicences,
|
|
3697
4070
|
"vendor" /* VENDOR */
|
|
3698
4071
|
);
|
|
3699
|
-
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[
|
|
4072
|
+
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared30.EnumUserLicence.PRO_VENDOR];
|
|
3700
4073
|
}
|
|
3701
4074
|
|
|
3702
4075
|
// src/service/license/compliance/utils.ts
|
|
@@ -3706,12 +4079,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
|
|
|
3706
4079
|
const pipeline = buildLicenceExpiryPipeline({
|
|
3707
4080
|
downgradeBranches: [
|
|
3708
4081
|
{
|
|
3709
|
-
case:
|
|
3710
|
-
then:
|
|
4082
|
+
case: import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR,
|
|
4083
|
+
then: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
|
|
3711
4084
|
},
|
|
3712
4085
|
{
|
|
3713
|
-
case:
|
|
3714
|
-
then:
|
|
4086
|
+
case: import_cluemart_shared31.EnumUserLicence.PRO_VENDOR,
|
|
4087
|
+
then: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
|
|
3715
4088
|
}
|
|
3716
4089
|
],
|
|
3717
4090
|
licenceTypes,
|
|
@@ -3840,7 +4213,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
|
|
|
3840
4213
|
var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
|
|
3841
4214
|
|
|
3842
4215
|
// src/service/license/reminder/utils.ts
|
|
3843
|
-
var
|
|
4216
|
+
var import_cluemart_shared32 = require("@timardex/cluemart-shared");
|
|
3844
4217
|
var import_utils8 = require("@timardex/cluemart-shared/utils");
|
|
3845
4218
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
3846
4219
|
|
|
@@ -3906,24 +4279,24 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
|
|
|
3906
4279
|
return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
|
|
3907
4280
|
}
|
|
3908
4281
|
function getLicenseName(licenceType) {
|
|
3909
|
-
return
|
|
4282
|
+
return import_cluemart_shared32.licenseNiceNames[licenceType] || licenceType;
|
|
3910
4283
|
}
|
|
3911
4284
|
function getNotificationTypes(isVendorLicense, isPartnerLicense) {
|
|
3912
4285
|
if (isVendorLicense) {
|
|
3913
4286
|
return {
|
|
3914
|
-
notificationType:
|
|
3915
|
-
resourceType:
|
|
4287
|
+
notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
|
|
4288
|
+
resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
|
|
3916
4289
|
};
|
|
3917
4290
|
}
|
|
3918
4291
|
if (isPartnerLicense) {
|
|
3919
4292
|
return {
|
|
3920
|
-
notificationType:
|
|
3921
|
-
resourceType:
|
|
4293
|
+
notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
|
|
4294
|
+
resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
|
|
3922
4295
|
};
|
|
3923
4296
|
}
|
|
3924
4297
|
return {
|
|
3925
|
-
notificationType:
|
|
3926
|
-
resourceType:
|
|
4298
|
+
notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
|
|
4299
|
+
resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
|
|
3927
4300
|
};
|
|
3928
4301
|
}
|
|
3929
4302
|
async function getLicenseResourceInfo(user, licence) {
|
|
@@ -3975,11 +4348,11 @@ async function getLicenseResourceInfo(user, licence) {
|
|
|
3975
4348
|
};
|
|
3976
4349
|
}
|
|
3977
4350
|
function getLicenceExpiryMode(licenceType) {
|
|
3978
|
-
return licenceType ===
|
|
4351
|
+
return licenceType === import_cluemart_shared32.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
|
|
3979
4352
|
}
|
|
3980
4353
|
async function sendLicenseReminder(user, licence) {
|
|
3981
4354
|
const licenceName = getLicenseName(licence.licenceType);
|
|
3982
|
-
const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(
|
|
4355
|
+
const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared32.dateFormat);
|
|
3983
4356
|
const userId = String(user._id);
|
|
3984
4357
|
const resourceInfo = await getLicenseResourceInfo(user, licence);
|
|
3985
4358
|
if (!resourceInfo) {
|
|
@@ -4105,8 +4478,13 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4105
4478
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4106
4479
|
0 && (module.exports = {
|
|
4107
4480
|
ACTIVE_NOT_DELETED_FILTER,
|
|
4481
|
+
AD_BILLING_CATALOG_COLLECTION_NAME,
|
|
4108
4482
|
APP_SETTINGS_ID,
|
|
4483
|
+
AdBillingCatalogModel,
|
|
4484
|
+
AdBookingModel,
|
|
4485
|
+
AdImpressionModel,
|
|
4109
4486
|
AdModel,
|
|
4487
|
+
AdSettingsModel,
|
|
4110
4488
|
AffiliateModel,
|
|
4111
4489
|
AppSettingModel,
|
|
4112
4490
|
BILLING_CATALOG_COLLECTION_NAME,
|
|
@@ -4116,6 +4494,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4116
4494
|
ChatReportModel,
|
|
4117
4495
|
ContactDetailsSchema,
|
|
4118
4496
|
CouponModel,
|
|
4497
|
+
DEFAULT_AD_SETTINGS,
|
|
4119
4498
|
EnumPubSubEvents,
|
|
4120
4499
|
EventInfoModel,
|
|
4121
4500
|
EventModel,
|
|
@@ -4200,6 +4579,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4200
4579
|
resourceRelationsSchema,
|
|
4201
4580
|
restoreVendorProFeatures,
|
|
4202
4581
|
saveNotificationsInDb,
|
|
4582
|
+
schemaAdresource,
|
|
4203
4583
|
sendDeactivationNotification,
|
|
4204
4584
|
sendLicenseReminder,
|
|
4205
4585
|
sendPushNotifications,
|