@timardex/cluemart-server-shared 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-XGBC5DCX.mjs → chunk-T5TP2XMR.mjs} +67 -89
- package/dist/chunk-T5TP2XMR.mjs.map +1 -0
- package/dist/index.cjs +287 -311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +36 -26
- package/dist/index.d.ts +36 -26
- package/dist/index.mjs +86 -103
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +150 -177
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +15 -12
- package/dist/mongoose/index.d.ts +15 -12
- package/dist/mongoose/index.mjs +3 -3
- package/dist/service/index.cjs +282 -302
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +22 -15
- package/dist/service/index.d.ts +22 -15
- package/dist/service/index.mjs +21 -16
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-XGBC5DCX.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
APP_SETTINGS_ID: () => APP_SETTINGS_ID,
|
|
36
36
|
AdBillingCatalogModel: () => AdBillingCatalogModel,
|
|
37
37
|
AdBookingModel: () => AdBookingModel,
|
|
38
|
-
|
|
38
|
+
AdMetricsModel: () => AdMetricsModel,
|
|
39
39
|
AdModel: () => AdModel,
|
|
40
40
|
AdSettingsModel: () => AdSettingsModel,
|
|
41
41
|
AffiliateModel: () => AffiliateModel,
|
|
@@ -152,8 +152,8 @@ __export(index_exports, {
|
|
|
152
152
|
termsAgreementSchema: () => termsAgreementSchema,
|
|
153
153
|
updateAdStatuses: () => updateAdStatuses,
|
|
154
154
|
updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
|
|
155
|
-
|
|
156
|
-
updateSingleDateTimeStatus: () =>
|
|
155
|
+
updateRelationDatesToCanceled: () => updateRelationDatesToCanceled,
|
|
156
|
+
updateSingleDateTimeStatus: () => import_cluemart_shared36.updateSingleDateTimeStatus,
|
|
157
157
|
upgradeUserToLicence: () => upgradeUserToLicence,
|
|
158
158
|
userLicenseSchema: () => userLicenseSchema,
|
|
159
159
|
vendorOwnerHasProLicence: () => vendorOwnerHasProLicence,
|
|
@@ -194,7 +194,6 @@ var schemaAdresource = new MongooseSchema({
|
|
|
194
194
|
var schema = new MongooseSchema(
|
|
195
195
|
{
|
|
196
196
|
active: { default: true, type: Boolean },
|
|
197
|
-
adminManaged: { default: false, type: Boolean },
|
|
198
197
|
approvalStatus: {
|
|
199
198
|
enum: Object.values(import_cluemart_shared.EnumAdApprovalStatus),
|
|
200
199
|
required: false,
|
|
@@ -210,9 +209,14 @@ var schema = new MongooseSchema(
|
|
|
210
209
|
required: false,
|
|
211
210
|
type: String
|
|
212
211
|
},
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
end: {
|
|
213
|
+
required: true,
|
|
214
|
+
type: Date,
|
|
215
|
+
validate: {
|
|
216
|
+
message: "end must be a UTC-midnight day key.",
|
|
217
|
+
validator: import_cluemart_shared.isUtcMidnight
|
|
218
|
+
}
|
|
219
|
+
},
|
|
216
220
|
paymentStatus: {
|
|
217
221
|
enum: Object.values(import_cluemart_shared.EnumAdPaymentStatus),
|
|
218
222
|
required: false,
|
|
@@ -225,7 +229,14 @@ var schema = new MongooseSchema(
|
|
|
225
229
|
required: true,
|
|
226
230
|
type: [String]
|
|
227
231
|
},
|
|
228
|
-
start: {
|
|
232
|
+
start: {
|
|
233
|
+
required: true,
|
|
234
|
+
type: Date,
|
|
235
|
+
validate: {
|
|
236
|
+
message: "start must be a UTC-midnight day key.",
|
|
237
|
+
validator: import_cluemart_shared.isUtcMidnight
|
|
238
|
+
}
|
|
239
|
+
},
|
|
229
240
|
status: {
|
|
230
241
|
default: import_cluemart_shared.EnumAdStatus.ACTIVE,
|
|
231
242
|
enum: Object.values(import_cluemart_shared.EnumAdStatus),
|
|
@@ -259,6 +270,7 @@ schema.index(
|
|
|
259
270
|
var AdModel = import_mongoose.default.models.Ad || import_mongoose.default.model("Ad", schema);
|
|
260
271
|
|
|
261
272
|
// src/mongoose/ad/AdBillingCatalog.ts
|
|
273
|
+
var import_cluemart_shared2 = require("@timardex/cluemart-shared");
|
|
262
274
|
var import_mongoose2 = __toESM(require("mongoose"));
|
|
263
275
|
var AD_BILLING_CATALOG_COLLECTION_NAME = "adBillingCatalog";
|
|
264
276
|
var schema2 = new import_mongoose2.default.Schema(
|
|
@@ -272,7 +284,7 @@ var schema2 = new import_mongoose2.default.Schema(
|
|
|
272
284
|
type: String
|
|
273
285
|
},
|
|
274
286
|
key: {
|
|
275
|
-
enum:
|
|
287
|
+
enum: Object.values(import_cluemart_shared2.EnumAdShowOn),
|
|
276
288
|
immutable: true,
|
|
277
289
|
required: true,
|
|
278
290
|
type: String,
|
|
@@ -298,20 +310,19 @@ var AdBillingCatalogModel = import_mongoose2.default.models.AdBillingCatalog ||
|
|
|
298
310
|
);
|
|
299
311
|
|
|
300
312
|
// src/mongoose/ad/AdBooking.ts
|
|
301
|
-
var
|
|
313
|
+
var import_cluemart_shared3 = require("@timardex/cluemart-shared");
|
|
302
314
|
var import_mongoose3 = __toESM(require("mongoose"));
|
|
303
315
|
var liveStates = [
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
316
|
+
import_cluemart_shared3.EnumAdBookingState.HELD,
|
|
317
|
+
import_cluemart_shared3.EnumAdBookingState.PENDING_APPROVAL,
|
|
318
|
+
import_cluemart_shared3.EnumAdBookingState.APPROVED
|
|
307
319
|
];
|
|
308
|
-
var placementValues = [import_cluemart_shared2.EnumAdShowOn.FRONT_PAGE, import_cluemart_shared2.EnumAdShowOn.MARKET_SEARCH];
|
|
309
320
|
var schema3 = new import_mongoose3.default.Schema(
|
|
310
321
|
{
|
|
311
322
|
adId: { default: null, ref: "Ad", type: String },
|
|
312
323
|
approvalStatus: {
|
|
313
|
-
default:
|
|
314
|
-
enum: Object.values(
|
|
324
|
+
default: import_cluemart_shared3.EnumAdApprovalStatus.PENDING,
|
|
325
|
+
enum: Object.values(import_cluemart_shared3.EnumAdApprovalStatus),
|
|
315
326
|
required: true,
|
|
316
327
|
type: String
|
|
317
328
|
},
|
|
@@ -319,19 +330,16 @@ var schema3 = new import_mongoose3.default.Schema(
|
|
|
319
330
|
currency: { default: null, lowercase: true, type: String },
|
|
320
331
|
dayKey: {
|
|
321
332
|
immutable: true,
|
|
322
|
-
match: /^\d{4}-\d{2}-\d{2}$/,
|
|
323
333
|
required: true,
|
|
324
|
-
type:
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
enum: Object.values(import_cluemart_shared2.EnumAdEntitlementSource),
|
|
330
|
-
type: String
|
|
334
|
+
type: Date,
|
|
335
|
+
validate: {
|
|
336
|
+
message: "dayKey must be a UTC-midnight day key.",
|
|
337
|
+
validator: import_cluemart_shared3.isUtcMidnight
|
|
338
|
+
}
|
|
331
339
|
},
|
|
332
340
|
expiresAt: { default: null, type: Date },
|
|
333
341
|
placement: {
|
|
334
|
-
enum:
|
|
342
|
+
enum: Object.values(import_cluemart_shared3.EnumAdShowOn),
|
|
335
343
|
immutable: true,
|
|
336
344
|
required: true,
|
|
337
345
|
type: String
|
|
@@ -346,15 +354,16 @@ var schema3 = new import_mongoose3.default.Schema(
|
|
|
346
354
|
},
|
|
347
355
|
resource: { required: true, type: schemaAdresource },
|
|
348
356
|
slotKind: {
|
|
349
|
-
|
|
357
|
+
default: import_cluemart_shared3.EnumAdBookingSlotKind.PAID,
|
|
358
|
+
enum: Object.values(import_cluemart_shared3.EnumAdBookingSlotKind),
|
|
350
359
|
immutable: true,
|
|
351
360
|
required: true,
|
|
352
361
|
type: String
|
|
353
362
|
},
|
|
354
363
|
slotNumber: { immutable: true, min: 1, required: true, type: Number },
|
|
355
364
|
state: {
|
|
356
|
-
default:
|
|
357
|
-
enum: Object.values(
|
|
365
|
+
default: import_cluemart_shared3.EnumAdBookingState.HELD,
|
|
366
|
+
enum: Object.values(import_cluemart_shared3.EnumAdBookingState),
|
|
358
367
|
required: true,
|
|
359
368
|
type: String
|
|
360
369
|
},
|
|
@@ -372,14 +381,14 @@ schema3.pre(
|
|
|
372
381
|
this.invalidate("slotNumber", "Ad booking slot must be an integer.");
|
|
373
382
|
return;
|
|
374
383
|
}
|
|
375
|
-
const maximum =
|
|
384
|
+
const maximum = 30;
|
|
376
385
|
if (this.slotNumber < 1 || this.slotNumber > maximum) {
|
|
377
386
|
this.invalidate(
|
|
378
387
|
"slotNumber",
|
|
379
388
|
`Ad booking slot must be between 1 and ${maximum}.`
|
|
380
389
|
);
|
|
381
390
|
}
|
|
382
|
-
if (this.slotKind ===
|
|
391
|
+
if (this.slotKind === import_cluemart_shared3.EnumAdBookingSlotKind.PAID && this.state !== import_cluemart_shared3.EnumAdBookingState.HELD && this.state !== import_cluemart_shared3.EnumAdBookingState.FAILED && this.state !== import_cluemart_shared3.EnumAdBookingState.CANCELLED && (!this.unitAmount || !this.currency)) {
|
|
383
392
|
this.invalidate(
|
|
384
393
|
"unitAmount",
|
|
385
394
|
"Paid ad booking must retain its checkout price."
|
|
@@ -409,26 +418,6 @@ schema3.index(
|
|
|
409
418
|
unique: true
|
|
410
419
|
}
|
|
411
420
|
);
|
|
412
|
-
schema3.index(
|
|
413
|
-
{ entitlementClaimKey: 1 },
|
|
414
|
-
{
|
|
415
|
-
partialFilterExpression: {
|
|
416
|
-
entitlementClaimKey: { $type: "string" },
|
|
417
|
-
state: { $in: liveStates }
|
|
418
|
-
},
|
|
419
|
-
unique: true
|
|
420
|
-
}
|
|
421
|
-
);
|
|
422
|
-
schema3.index(
|
|
423
|
-
{ adId: 1, region: 1, placement: 1, dayKey: 1 },
|
|
424
|
-
{
|
|
425
|
-
partialFilterExpression: {
|
|
426
|
-
entitlementSource: import_cluemart_shared2.EnumAdEntitlementSource.ADMIN,
|
|
427
|
-
state: { $in: liveStates }
|
|
428
|
-
},
|
|
429
|
-
unique: true
|
|
430
|
-
}
|
|
431
|
-
);
|
|
432
421
|
schema3.index(
|
|
433
422
|
{ stripeCheckoutSessionId: 1 },
|
|
434
423
|
{
|
|
@@ -438,93 +427,77 @@ schema3.index(
|
|
|
438
427
|
);
|
|
439
428
|
var AdBookingModel = import_mongoose3.default.models.AdBooking || import_mongoose3.default.model("AdBooking", schema3);
|
|
440
429
|
|
|
441
|
-
// src/mongoose/ad/
|
|
442
|
-
var
|
|
430
|
+
// src/mongoose/ad/AdMetrics.ts
|
|
431
|
+
var import_cluemart_shared4 = require("@timardex/cluemart-shared");
|
|
443
432
|
var import_mongoose4 = __toESM(require("mongoose"));
|
|
444
433
|
var schema4 = new import_mongoose4.default.Schema(
|
|
445
434
|
{
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
435
|
+
adId: { ref: "Ad", required: true, type: String },
|
|
436
|
+
clicks: { default: 0, required: true, type: Number },
|
|
437
|
+
date: {
|
|
438
|
+
immutable: true,
|
|
439
|
+
required: true,
|
|
440
|
+
type: Date,
|
|
441
|
+
validate: {
|
|
442
|
+
message: "date must be a UTC-midnight day key.",
|
|
443
|
+
validator: import_cluemart_shared4.isUtcMidnight
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
impressions: { default: 0, required: true, type: Number },
|
|
449
447
|
placement: {
|
|
450
|
-
enum:
|
|
448
|
+
enum: Object.values(import_cluemart_shared4.EnumAdShowOn),
|
|
449
|
+
immutable: true,
|
|
451
450
|
required: true,
|
|
452
451
|
type: String
|
|
453
452
|
},
|
|
454
|
-
|
|
455
|
-
|
|
453
|
+
platform: {
|
|
454
|
+
enum: Object.values(import_cluemart_shared4.EnumAdPlatform),
|
|
455
|
+
immutable: true,
|
|
456
|
+
required: true,
|
|
457
|
+
type: String
|
|
458
|
+
}
|
|
456
459
|
},
|
|
457
|
-
{
|
|
460
|
+
{ timestamps: true }
|
|
458
461
|
);
|
|
459
|
-
schema4.index({ adId: 1,
|
|
460
|
-
|
|
461
|
-
schema4.index({ recordedAt: 1 }, { expireAfterSeconds: 7 * 24 * 60 * 60 });
|
|
462
|
-
schema4.index({ dayKey: 1, placement: 1, adId: 1 });
|
|
463
|
-
var AdImpressionModel = import_mongoose4.default.models.AdImpression || import_mongoose4.default.model("AdImpression", schema4, "adImpressions");
|
|
462
|
+
schema4.index({ adId: 1, date: 1, placement: 1, platform: 1 }, { unique: true });
|
|
463
|
+
var AdMetricsModel = import_mongoose4.default.models.AdMetrics || import_mongoose4.default.model("AdMetrics", schema4);
|
|
464
464
|
|
|
465
465
|
// src/mongoose/ad/AdSettings.ts
|
|
466
466
|
var import_mongoose5 = __toESM(require("mongoose"));
|
|
467
467
|
var DEFAULT_AD_SETTINGS = {
|
|
468
468
|
_id: "default",
|
|
469
|
-
approvalRequired: true
|
|
470
|
-
minAppearancesPerHour: 12,
|
|
471
|
-
paidSlotsPerPlacement: 30,
|
|
472
|
-
reservedSlotsPerPlacement: 7,
|
|
473
|
-
rotationSeconds: 8
|
|
469
|
+
approvalRequired: true
|
|
474
470
|
};
|
|
475
471
|
var schema5 = new import_mongoose5.default.Schema(
|
|
476
472
|
{
|
|
477
473
|
_id: { default: "default", enum: ["default"], type: String },
|
|
478
474
|
approvalRequired: { default: true, required: true, type: Boolean },
|
|
479
475
|
minAppearancesPerHour: {
|
|
480
|
-
|
|
476
|
+
max: 12,
|
|
481
477
|
min: 1,
|
|
482
|
-
required: true,
|
|
483
478
|
type: Number,
|
|
484
|
-
validate:
|
|
485
|
-
message: "Minimum appearances per hour must be a whole number.",
|
|
486
|
-
validator: Number.isInteger
|
|
487
|
-
}
|
|
479
|
+
validate: Number.isInteger
|
|
488
480
|
},
|
|
489
|
-
paidSlotsPerPlacement: {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
immutable: true,
|
|
493
|
-
type: Number
|
|
494
|
-
},
|
|
495
|
-
reservedSlotsPerPlacement: {
|
|
496
|
-
default: 7,
|
|
497
|
-
enum: [7],
|
|
498
|
-
immutable: true,
|
|
499
|
-
type: Number
|
|
500
|
-
},
|
|
501
|
-
rotationSeconds: { default: 8, enum: [8], immutable: true, type: Number }
|
|
481
|
+
paidSlotsPerPlacement: { enum: [30], immutable: true, type: Number },
|
|
482
|
+
reservedSlotsPerPlacement: { enum: [7], immutable: true, type: Number },
|
|
483
|
+
rotationSeconds: { enum: [8], immutable: true, type: Number }
|
|
502
484
|
},
|
|
503
485
|
{ collection: "adSettings", timestamps: true }
|
|
504
486
|
);
|
|
505
|
-
schema5.pre("validate", function validateRotationCapacity() {
|
|
506
|
-
const availableRotationsPerHour = 3600 / this.rotationSeconds;
|
|
507
|
-
if (this.minAppearancesPerHour * (this.paidSlotsPerPlacement + this.reservedSlotsPerPlacement) > availableRotationsPerHour) {
|
|
508
|
-
this.invalidate(
|
|
509
|
-
"minAppearancesPerHour",
|
|
510
|
-
"The configured minimum exceeds the available rotation slots."
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
});
|
|
514
487
|
var AdSettingsModel = import_mongoose5.default.models.AdSettings || import_mongoose5.default.model("AdSettings", schema5, "adSettings");
|
|
515
488
|
|
|
516
489
|
// src/mongoose/BillingCatalog.ts
|
|
517
|
-
var
|
|
490
|
+
var import_cluemart_shared5 = require("@timardex/cluemart-shared");
|
|
518
491
|
var import_mongoose6 = __toESM(require("mongoose"));
|
|
519
492
|
var MongooseSchema2 = import_mongoose6.default.Schema;
|
|
520
493
|
var BILLING_CATALOG_COLLECTION_NAME = "billingCatalog";
|
|
521
494
|
var paidVendorLicences = [
|
|
522
|
-
|
|
523
|
-
|
|
495
|
+
import_cluemart_shared5.EnumUserLicence.PRO_VENDOR,
|
|
496
|
+
import_cluemart_shared5.EnumUserLicence.PRO_PLUS_VENDOR
|
|
524
497
|
];
|
|
525
498
|
var supportedBillingPeriods = [
|
|
526
|
-
|
|
527
|
-
|
|
499
|
+
import_cluemart_shared5.EnumBillingPeriod.MONTHLY_CANCEL_ANYTIME,
|
|
500
|
+
import_cluemart_shared5.EnumBillingPeriod.YEARLY_ANNUAL_BILLED
|
|
528
501
|
];
|
|
529
502
|
var unitAmountField = {
|
|
530
503
|
min: 1,
|
|
@@ -536,8 +509,8 @@ var unitAmountField = {
|
|
|
536
509
|
}
|
|
537
510
|
};
|
|
538
511
|
var currencyField = {
|
|
539
|
-
default:
|
|
540
|
-
enum: [
|
|
512
|
+
default: import_cluemart_shared5.BILLING_CATALOG_CURRENCY,
|
|
513
|
+
enum: [import_cluemart_shared5.BILLING_CATALOG_CURRENCY],
|
|
541
514
|
immutable: true,
|
|
542
515
|
lowercase: true,
|
|
543
516
|
required: true,
|
|
@@ -586,7 +559,7 @@ var schema6 = new MongooseSchema2(
|
|
|
586
559
|
currency: currencyField,
|
|
587
560
|
effectiveFrom: { default: Date.now, required: true, type: Date },
|
|
588
561
|
key: {
|
|
589
|
-
enum:
|
|
562
|
+
enum: import_cluemart_shared5.BILLING_CATALOG_KEYS,
|
|
590
563
|
immutable: true,
|
|
591
564
|
required: true,
|
|
592
565
|
type: String,
|
|
@@ -640,7 +613,7 @@ var schema6 = new MongooseSchema2(
|
|
|
640
613
|
}
|
|
641
614
|
);
|
|
642
615
|
schema6.pre("validate", function validateDefinition() {
|
|
643
|
-
if (!(0,
|
|
616
|
+
if (!(0, import_cluemart_shared5.billingCatalogDefinitionMatches)(this)) {
|
|
644
617
|
this.invalidate(
|
|
645
618
|
"key",
|
|
646
619
|
"Billing catalogue key does not match its licence and billing period."
|
|
@@ -662,7 +635,7 @@ var BillingCatalogModel = import_mongoose6.default.models.BillingCatalogEntry ||
|
|
|
662
635
|
BILLING_CATALOG_COLLECTION_NAME
|
|
663
636
|
);
|
|
664
637
|
function buildInitialBillingCatalogEntries(now = /* @__PURE__ */ new Date()) {
|
|
665
|
-
return
|
|
638
|
+
return import_cluemart_shared5.INITIAL_BILLING_CATALOG.map((entry) => ({
|
|
666
639
|
active: entry.active,
|
|
667
640
|
billingPeriod: entry.billingPeriod,
|
|
668
641
|
currency: entry.currency,
|
|
@@ -679,11 +652,11 @@ function buildInitialBillingCatalogEntries(now = /* @__PURE__ */ new Date()) {
|
|
|
679
652
|
}));
|
|
680
653
|
}
|
|
681
654
|
function getBillingCatalogDefinition(key) {
|
|
682
|
-
return
|
|
655
|
+
return import_cluemart_shared5.BILLING_CATALOG_DEFINITIONS[key];
|
|
683
656
|
}
|
|
684
657
|
|
|
685
658
|
// src/mongoose/chat/Chat.ts
|
|
686
|
-
var
|
|
659
|
+
var import_cluemart_shared6 = require("@timardex/cluemart-shared");
|
|
687
660
|
var import_mongoose7 = __toESM(require("mongoose"));
|
|
688
661
|
var MongooseSchema3 = import_mongoose7.default.Schema;
|
|
689
662
|
var MessageReplyPreviewSchema = new MongooseSchema3(
|
|
@@ -763,7 +736,7 @@ var ChatSchema = new MongooseSchema3(
|
|
|
763
736
|
chatDescription: { required: false, type: String },
|
|
764
737
|
chatName: { required: true, type: String },
|
|
765
738
|
chatType: {
|
|
766
|
-
enum: Object.values(
|
|
739
|
+
enum: Object.values(import_cluemart_shared6.EnumChatType),
|
|
767
740
|
required: true,
|
|
768
741
|
type: String
|
|
769
742
|
},
|
|
@@ -784,14 +757,14 @@ ChatSchema.index({
|
|
|
784
757
|
var ChatModel = import_mongoose7.default.models.Chat || import_mongoose7.default.model("Chat", ChatSchema);
|
|
785
758
|
|
|
786
759
|
// src/mongoose/chat/ChatReport.ts
|
|
787
|
-
var
|
|
760
|
+
var import_cluemart_shared7 = require("@timardex/cluemart-shared");
|
|
788
761
|
var import_mongoose8 = __toESM(require("mongoose"));
|
|
789
762
|
var MongooseSchema4 = import_mongoose8.default.Schema;
|
|
790
763
|
var ReasonSchema = new MongooseSchema4(
|
|
791
764
|
{
|
|
792
765
|
details: { default: null, required: false, type: String },
|
|
793
766
|
reasonType: {
|
|
794
|
-
enum: Object.values(
|
|
767
|
+
enum: Object.values(import_cluemart_shared7.EnumChatReportReason),
|
|
795
768
|
required: true,
|
|
796
769
|
type: String
|
|
797
770
|
}
|
|
@@ -825,7 +798,7 @@ ChatReportSchema.index({ createdAt: -1, reporterUserId: 1 });
|
|
|
825
798
|
var ChatReportModel = import_mongoose8.default.models.ChatReport || import_mongoose8.default.model("ChatReport", ChatReportSchema);
|
|
826
799
|
|
|
827
800
|
// src/mongoose/global.ts
|
|
828
|
-
var
|
|
801
|
+
var import_cluemart_shared8 = require("@timardex/cluemart-shared");
|
|
829
802
|
var import_mongoose9 = __toESM(require("mongoose"));
|
|
830
803
|
var MongooseSchema5 = import_mongoose9.default.Schema;
|
|
831
804
|
var OwnerTypeSchema = new MongooseSchema5(
|
|
@@ -893,12 +866,12 @@ var userLicenseSchema = new MongooseSchema5(
|
|
|
893
866
|
expiryDate: { required: true, type: Date },
|
|
894
867
|
issuedDate: { required: true, type: Date },
|
|
895
868
|
licenceType: {
|
|
896
|
-
enum: Object.values(
|
|
869
|
+
enum: Object.values(import_cluemart_shared8.EnumUserLicence),
|
|
897
870
|
required: true,
|
|
898
871
|
type: String
|
|
899
872
|
},
|
|
900
873
|
prevLicenceType: {
|
|
901
|
-
enum: Object.values(
|
|
874
|
+
enum: Object.values(import_cluemart_shared8.EnumUserLicence),
|
|
902
875
|
required: false,
|
|
903
876
|
type: String
|
|
904
877
|
}
|
|
@@ -934,7 +907,7 @@ var termsAgreementSchema = new MongooseSchema5(
|
|
|
934
907
|
var dateTimeSchema = new MongooseSchema5(
|
|
935
908
|
{
|
|
936
909
|
dateStatus: {
|
|
937
|
-
enum: Object.values(
|
|
910
|
+
enum: Object.values(import_cluemart_shared8.EnumEventDateStatus),
|
|
938
911
|
required: false,
|
|
939
912
|
type: String
|
|
940
913
|
},
|
|
@@ -981,7 +954,7 @@ var relatedPostSchema = new MongooseSchema5(
|
|
|
981
954
|
},
|
|
982
955
|
postSlug: { required: true, type: String },
|
|
983
956
|
postType: {
|
|
984
|
-
enum: Object.values(
|
|
957
|
+
enum: Object.values(import_cluemart_shared8.EnumPostType),
|
|
985
958
|
required: true,
|
|
986
959
|
type: String
|
|
987
960
|
}
|
|
@@ -1032,7 +1005,7 @@ var baseResourceFields = {
|
|
|
1032
1005
|
};
|
|
1033
1006
|
|
|
1034
1007
|
// src/mongoose/GoogleImportedMarket.ts
|
|
1035
|
-
var
|
|
1008
|
+
var import_cluemart_shared9 = require("@timardex/cluemart-shared");
|
|
1036
1009
|
var import_mongoose10 = __toESM(require("mongoose"));
|
|
1037
1010
|
|
|
1038
1011
|
// src/mongoose/searchNamePlugin.ts
|
|
@@ -1165,7 +1138,7 @@ var schema7 = new MongooseSchema6(
|
|
|
1165
1138
|
type: import_mongoose10.default.Schema.Types.ObjectId
|
|
1166
1139
|
},
|
|
1167
1140
|
eventType: {
|
|
1168
|
-
enum: Object.values(
|
|
1141
|
+
enum: Object.values(import_cluemart_shared9.EnumEventType),
|
|
1169
1142
|
required: true,
|
|
1170
1143
|
type: String
|
|
1171
1144
|
},
|
|
@@ -1207,7 +1180,7 @@ schema7.plugin(searchNamePlugin);
|
|
|
1207
1180
|
var GoogleImportedMarketModel = import_mongoose10.default.models.GoogleImportedMarket || import_mongoose10.default.model("GoogleImportedMarket", schema7);
|
|
1208
1181
|
|
|
1209
1182
|
// src/mongoose/Notification.ts
|
|
1210
|
-
var
|
|
1183
|
+
var import_cluemart_shared10 = require("@timardex/cluemart-shared");
|
|
1211
1184
|
var import_mongoose11 = __toESM(require("mongoose"));
|
|
1212
1185
|
var MongooseSchema7 = import_mongoose11.default.Schema;
|
|
1213
1186
|
var notificationDataSchema = new MongooseSchema7(
|
|
@@ -1215,7 +1188,7 @@ var notificationDataSchema = new MongooseSchema7(
|
|
|
1215
1188
|
resourceId: { required: true, type: String },
|
|
1216
1189
|
resourceName: { required: true, type: String },
|
|
1217
1190
|
resourceType: {
|
|
1218
|
-
enum: Object.values(
|
|
1191
|
+
enum: Object.values(import_cluemart_shared10.EnumNotificationResourceType),
|
|
1219
1192
|
required: true,
|
|
1220
1193
|
type: String
|
|
1221
1194
|
}
|
|
@@ -1233,8 +1206,8 @@ var schema8 = new MongooseSchema7(
|
|
|
1233
1206
|
message: { required: true, type: String },
|
|
1234
1207
|
title: { required: true, type: String },
|
|
1235
1208
|
type: {
|
|
1236
|
-
default:
|
|
1237
|
-
enum: Object.values(
|
|
1209
|
+
default: import_cluemart_shared10.EnumNotificationType.SYSTEM,
|
|
1210
|
+
enum: Object.values(import_cluemart_shared10.EnumNotificationType),
|
|
1238
1211
|
required: true,
|
|
1239
1212
|
type: String
|
|
1240
1213
|
},
|
|
@@ -1273,11 +1246,11 @@ var schema9 = new MongooseSchema8(
|
|
|
1273
1246
|
var PushTokenModel = import_mongoose12.default.models.PushToken || import_mongoose12.default.model("PushToken", schema9);
|
|
1274
1247
|
|
|
1275
1248
|
// src/mongoose/Relation.ts
|
|
1276
|
-
var
|
|
1249
|
+
var import_cluemart_shared12 = require("@timardex/cluemart-shared");
|
|
1277
1250
|
var import_mongoose14 = __toESM(require("mongoose"));
|
|
1278
1251
|
|
|
1279
1252
|
// src/mongoose/event/EventInfo.ts
|
|
1280
|
-
var
|
|
1253
|
+
var import_cluemart_shared11 = require("@timardex/cluemart-shared");
|
|
1281
1254
|
var import_mongoose13 = __toESM(require("mongoose"));
|
|
1282
1255
|
var MongooseSchema9 = import_mongoose13.default.Schema;
|
|
1283
1256
|
var StallTypeSchema = new MongooseSchema9(
|
|
@@ -1294,7 +1267,7 @@ var StallTypeSchema = new MongooseSchema9(
|
|
|
1294
1267
|
var dateTimeSchema2 = new MongooseSchema9(
|
|
1295
1268
|
{
|
|
1296
1269
|
dateStatus: {
|
|
1297
|
-
enum: Object.values(
|
|
1270
|
+
enum: Object.values(import_cluemart_shared11.EnumEventDateStatus),
|
|
1298
1271
|
required: false,
|
|
1299
1272
|
type: String
|
|
1300
1273
|
},
|
|
@@ -1313,7 +1286,7 @@ var paymentInfoSchema = new MongooseSchema9(
|
|
|
1313
1286
|
accountNumber: { required: false, type: String },
|
|
1314
1287
|
link: { required: false, type: String },
|
|
1315
1288
|
paymentMethod: {
|
|
1316
|
-
enum: Object.values(
|
|
1289
|
+
enum: Object.values(import_cluemart_shared11.EnumPaymentMethod),
|
|
1317
1290
|
required: true,
|
|
1318
1291
|
type: String
|
|
1319
1292
|
}
|
|
@@ -1366,7 +1339,7 @@ var MongooseSchema10 = import_mongoose14.default.Schema;
|
|
|
1366
1339
|
var relationDateTimeSchema = new MongooseSchema10(
|
|
1367
1340
|
{
|
|
1368
1341
|
dateStatus: {
|
|
1369
|
-
enum: Object.values(
|
|
1342
|
+
enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
|
|
1370
1343
|
required: true,
|
|
1371
1344
|
type: String
|
|
1372
1345
|
},
|
|
@@ -1390,7 +1363,7 @@ var relationDatesSchema = new MongooseSchema10(
|
|
|
1390
1363
|
},
|
|
1391
1364
|
paymentReference: { required: false, type: String },
|
|
1392
1365
|
status: {
|
|
1393
|
-
enum: Object.values(
|
|
1366
|
+
enum: Object.values(import_cluemart_shared12.EnumInviteStatus),
|
|
1394
1367
|
required: false,
|
|
1395
1368
|
type: String
|
|
1396
1369
|
}
|
|
@@ -1412,13 +1385,13 @@ var RelationTypeSchema = new MongooseSchema10(
|
|
|
1412
1385
|
type: import_mongoose14.default.Schema.Types.ObjectId
|
|
1413
1386
|
},
|
|
1414
1387
|
lastUpdateBy: {
|
|
1415
|
-
enum: Object.values(
|
|
1388
|
+
enum: Object.values(import_cluemart_shared12.EnumResourceType),
|
|
1416
1389
|
required: true,
|
|
1417
1390
|
type: String
|
|
1418
1391
|
},
|
|
1419
1392
|
relationDates: [relationDatesSchema],
|
|
1420
1393
|
relationType: {
|
|
1421
|
-
enum: Object.values(
|
|
1394
|
+
enum: Object.values(import_cluemart_shared12.EnumRelationResource),
|
|
1422
1395
|
required: true,
|
|
1423
1396
|
type: String
|
|
1424
1397
|
},
|
|
@@ -1440,18 +1413,18 @@ RelationTypeSchema.index({
|
|
|
1440
1413
|
var RelationModel = import_mongoose14.default.models.Relation || import_mongoose14.default.model("Relation", RelationTypeSchema);
|
|
1441
1414
|
|
|
1442
1415
|
// src/mongoose/ResourceActivity.ts
|
|
1443
|
-
var
|
|
1416
|
+
var import_cluemart_shared13 = require("@timardex/cluemart-shared");
|
|
1444
1417
|
var import_mongoose15 = __toESM(require("mongoose"));
|
|
1445
1418
|
var MongooseSchema11 = import_mongoose15.default.Schema;
|
|
1446
1419
|
var ActivitySchema = new MongooseSchema11(
|
|
1447
1420
|
{
|
|
1448
1421
|
activityType: {
|
|
1449
|
-
enum: Object.values(
|
|
1422
|
+
enum: Object.values(import_cluemart_shared13.EnumActivity),
|
|
1450
1423
|
required: true,
|
|
1451
1424
|
type: String
|
|
1452
1425
|
},
|
|
1453
1426
|
dateStatus: {
|
|
1454
|
-
enum: Object.values(
|
|
1427
|
+
enum: Object.values(import_cluemart_shared13.EnumEventDateStatus),
|
|
1455
1428
|
required: false,
|
|
1456
1429
|
type: String
|
|
1457
1430
|
},
|
|
@@ -1463,7 +1436,7 @@ var ActivitySchema = new MongooseSchema11(
|
|
|
1463
1436
|
startTime: { required: false, type: String },
|
|
1464
1437
|
timestamp: { default: Date.now, type: Date },
|
|
1465
1438
|
userAgent: {
|
|
1466
|
-
enum: Object.values(
|
|
1439
|
+
enum: Object.values(import_cluemart_shared13.EnumOSPlatform),
|
|
1467
1440
|
required: true,
|
|
1468
1441
|
type: String
|
|
1469
1442
|
},
|
|
@@ -1476,7 +1449,7 @@ var schema11 = new MongooseSchema11(
|
|
|
1476
1449
|
activity: { default: [], type: [ActivitySchema] },
|
|
1477
1450
|
resourceId: { required: true, type: String },
|
|
1478
1451
|
resourceType: {
|
|
1479
|
-
enum: Object.values(
|
|
1452
|
+
enum: Object.values(import_cluemart_shared13.EnumResourceType),
|
|
1480
1453
|
required: true,
|
|
1481
1454
|
type: String
|
|
1482
1455
|
}
|
|
@@ -1488,7 +1461,7 @@ schema11.index({ "views.location": "2dsphere" });
|
|
|
1488
1461
|
var ResourceActivityModel = import_mongoose15.default.models.ResourceActivity || import_mongoose15.default.model("ResourceActivity", schema11);
|
|
1489
1462
|
|
|
1490
1463
|
// src/mongoose/User.ts
|
|
1491
|
-
var
|
|
1464
|
+
var import_cluemart_shared14 = require("@timardex/cluemart-shared");
|
|
1492
1465
|
var import_mongoose16 = __toESM(require("mongoose"));
|
|
1493
1466
|
var MongooseSchema12 = import_mongoose16.default.Schema;
|
|
1494
1467
|
var userActivityEventSchema = new MongooseSchema12(
|
|
@@ -1525,7 +1498,7 @@ var userActivityFavouritesSchema = new MongooseSchema12(
|
|
|
1525
1498
|
var stripeSchema = new MongooseSchema12(
|
|
1526
1499
|
{
|
|
1527
1500
|
billingPeriod: {
|
|
1528
|
-
enum: Object.values(
|
|
1501
|
+
enum: Object.values(import_cluemart_shared14.EnumBillingPeriod),
|
|
1529
1502
|
required: false,
|
|
1530
1503
|
type: String
|
|
1531
1504
|
},
|
|
@@ -1534,7 +1507,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1534
1507
|
type: Boolean
|
|
1535
1508
|
},
|
|
1536
1509
|
currentPlan: {
|
|
1537
|
-
enum: Object.values(
|
|
1510
|
+
enum: Object.values(import_cluemart_shared14.EnumUserLicence),
|
|
1538
1511
|
required: false,
|
|
1539
1512
|
type: String
|
|
1540
1513
|
},
|
|
@@ -1559,7 +1532,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1559
1532
|
type: String
|
|
1560
1533
|
},
|
|
1561
1534
|
pendingBillingPeriod: {
|
|
1562
|
-
enum: Object.values(
|
|
1535
|
+
enum: Object.values(import_cluemart_shared14.EnumBillingPeriod),
|
|
1563
1536
|
required: false,
|
|
1564
1537
|
type: String
|
|
1565
1538
|
},
|
|
@@ -1568,7 +1541,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1568
1541
|
type: Date
|
|
1569
1542
|
},
|
|
1570
1543
|
pendingPlan: {
|
|
1571
|
-
enum: Object.values(
|
|
1544
|
+
enum: Object.values(import_cluemart_shared14.EnumUserLicence),
|
|
1572
1545
|
required: false,
|
|
1573
1546
|
type: String
|
|
1574
1547
|
},
|
|
@@ -1585,7 +1558,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1585
1558
|
type: Date
|
|
1586
1559
|
},
|
|
1587
1560
|
status: {
|
|
1588
|
-
enum: Object.values(
|
|
1561
|
+
enum: Object.values(import_cluemart_shared14.EnumSubscriptionStatus),
|
|
1589
1562
|
required: false,
|
|
1590
1563
|
type: String
|
|
1591
1564
|
},
|
|
@@ -1607,7 +1580,7 @@ var stripeSchema = new MongooseSchema12(
|
|
|
1607
1580
|
var redeemedRewardSchema = new MongooseSchema12(
|
|
1608
1581
|
{
|
|
1609
1582
|
name: {
|
|
1610
|
-
enum: Object.values(
|
|
1583
|
+
enum: Object.values(import_cluemart_shared14.EnumReward),
|
|
1611
1584
|
required: true,
|
|
1612
1585
|
type: String
|
|
1613
1586
|
},
|
|
@@ -1621,7 +1594,7 @@ var userOverallPointsSchema = new MongooseSchema12(
|
|
|
1621
1594
|
createdAt: { required: true, type: Date },
|
|
1622
1595
|
points: { default: 0, required: true, type: Number },
|
|
1623
1596
|
pointType: {
|
|
1624
|
-
enum: Object.values(
|
|
1597
|
+
enum: Object.values(import_cluemart_shared14.EnumPointType),
|
|
1625
1598
|
required: true,
|
|
1626
1599
|
type: String
|
|
1627
1600
|
},
|
|
@@ -1649,7 +1622,7 @@ var schema12 = new MongooseSchema12(
|
|
|
1649
1622
|
deletedAt: { default: null, required: false, type: Date },
|
|
1650
1623
|
email: { required: true, type: String },
|
|
1651
1624
|
emailSentFor: {
|
|
1652
|
-
enum: Object.values(
|
|
1625
|
+
enum: Object.values(import_cluemart_shared14.EnumNotificationResourceType),
|
|
1653
1626
|
required: false,
|
|
1654
1627
|
type: [String]
|
|
1655
1628
|
},
|
|
@@ -1665,7 +1638,7 @@ var schema12 = new MongooseSchema12(
|
|
|
1665
1638
|
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1666
1639
|
},
|
|
1667
1640
|
interests: {
|
|
1668
|
-
enum: Object.values(
|
|
1641
|
+
enum: Object.values(import_cluemart_shared14.EnumResourceType),
|
|
1669
1642
|
required: false,
|
|
1670
1643
|
type: [String]
|
|
1671
1644
|
},
|
|
@@ -1692,7 +1665,7 @@ var schema12 = new MongooseSchema12(
|
|
|
1692
1665
|
},
|
|
1693
1666
|
password: { required: true, type: String },
|
|
1694
1667
|
platform: {
|
|
1695
|
-
enum: Object.values(
|
|
1668
|
+
enum: Object.values(import_cluemart_shared14.EnumOSPlatform),
|
|
1696
1669
|
required: false,
|
|
1697
1670
|
type: String
|
|
1698
1671
|
},
|
|
@@ -1713,8 +1686,8 @@ var schema12 = new MongooseSchema12(
|
|
|
1713
1686
|
type: String
|
|
1714
1687
|
},
|
|
1715
1688
|
roles: {
|
|
1716
|
-
default: [
|
|
1717
|
-
enum: Object.values(
|
|
1689
|
+
default: [import_cluemart_shared14.EnumUserRole.CUSTOMER],
|
|
1690
|
+
enum: Object.values(import_cluemart_shared14.EnumUserRole),
|
|
1718
1691
|
required: true,
|
|
1719
1692
|
type: [String]
|
|
1720
1693
|
},
|
|
@@ -1778,7 +1751,7 @@ var schema13 = new MongooseSchema13(
|
|
|
1778
1751
|
var VerificationTokenModel = import_mongoose17.default.models.VerificationToken || import_mongoose17.default.model("VerificationToken", schema13);
|
|
1779
1752
|
|
|
1780
1753
|
// src/mongoose/vendor/Vendor.ts
|
|
1781
|
-
var
|
|
1754
|
+
var import_cluemart_shared15 = require("@timardex/cluemart-shared");
|
|
1782
1755
|
var import_mongoose18 = __toESM(require("mongoose"));
|
|
1783
1756
|
var MongooseSchema14 = import_mongoose18.default.Schema;
|
|
1784
1757
|
var vendorProductTypeSchema = new MongooseSchema14(
|
|
@@ -1803,7 +1776,7 @@ var calendarSchema = new MongooseSchema14(
|
|
|
1803
1776
|
{
|
|
1804
1777
|
dateTime: {
|
|
1805
1778
|
dateStatus: {
|
|
1806
|
-
enum: Object.values(
|
|
1779
|
+
enum: Object.values(import_cluemart_shared15.EnumEventDateStatus),
|
|
1807
1780
|
required: false,
|
|
1808
1781
|
type: String
|
|
1809
1782
|
},
|
|
@@ -1870,7 +1843,7 @@ var schema14 = new MongooseSchema14(
|
|
|
1870
1843
|
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1871
1844
|
},
|
|
1872
1845
|
vendorType: {
|
|
1873
|
-
enum: Object.values(
|
|
1846
|
+
enum: Object.values(import_cluemart_shared15.EnumVendorType),
|
|
1874
1847
|
required: true,
|
|
1875
1848
|
type: String
|
|
1876
1849
|
}
|
|
@@ -1892,7 +1865,7 @@ schema14.plugin(searchNamePlugin);
|
|
|
1892
1865
|
var VendorModel = import_mongoose18.default.models.Vendor || import_mongoose18.default.model("Vendor", schema14);
|
|
1893
1866
|
|
|
1894
1867
|
// src/mongoose/vendor/VendorInfo.ts
|
|
1895
|
-
var
|
|
1868
|
+
var import_cluemart_shared16 = require("@timardex/cluemart-shared");
|
|
1896
1869
|
var import_mongoose19 = __toESM(require("mongoose"));
|
|
1897
1870
|
var MongooseSchema15 = import_mongoose19.default.Schema;
|
|
1898
1871
|
var AttributesSchema = new MongooseSchema15(
|
|
@@ -1912,7 +1885,7 @@ var schema15 = new MongooseSchema15(
|
|
|
1912
1885
|
documents: [ResourceImageTypeSchema],
|
|
1913
1886
|
product: {
|
|
1914
1887
|
foodFlavors: {
|
|
1915
|
-
enum: Object.values(
|
|
1888
|
+
enum: Object.values(import_cluemart_shared16.EnumFoodFlavor),
|
|
1916
1889
|
required: true,
|
|
1917
1890
|
type: [String]
|
|
1918
1891
|
},
|
|
@@ -1986,7 +1959,7 @@ schema16.index({ email: 1 });
|
|
|
1986
1959
|
var UnregisteredVendorModel = import_mongoose20.default.models.UnregisteredVendor || import_mongoose20.default.model("UnregisteredVendor", schema16);
|
|
1987
1960
|
|
|
1988
1961
|
// src/mongoose/event/Event.ts
|
|
1989
|
-
var
|
|
1962
|
+
var import_cluemart_shared17 = require("@timardex/cluemart-shared");
|
|
1990
1963
|
var import_mongoose21 = __toESM(require("mongoose"));
|
|
1991
1964
|
var MongooseSchema17 = import_mongoose21.default.Schema;
|
|
1992
1965
|
var schema17 = new MongooseSchema17(
|
|
@@ -2001,7 +1974,7 @@ var schema17 = new MongooseSchema17(
|
|
|
2001
1974
|
type: import_mongoose21.default.Schema.Types.ObjectId
|
|
2002
1975
|
},
|
|
2003
1976
|
eventType: {
|
|
2004
|
-
enum: Object.values(
|
|
1977
|
+
enum: Object.values(import_cluemart_shared17.EnumEventType),
|
|
2005
1978
|
required: true,
|
|
2006
1979
|
type: String
|
|
2007
1980
|
},
|
|
@@ -2052,7 +2025,7 @@ schema18.index({ eventId: 1 }, { unique: true });
|
|
|
2052
2025
|
var EventDateArchiveModel = import_mongoose22.default.models.EventDateArchive || import_mongoose22.default.model("EventDateArchive", schema18);
|
|
2053
2026
|
|
|
2054
2027
|
// src/mongoose/Partner.ts
|
|
2055
|
-
var
|
|
2028
|
+
var import_cluemart_shared18 = require("@timardex/cluemart-shared");
|
|
2056
2029
|
var import_mongoose23 = __toESM(require("mongoose"));
|
|
2057
2030
|
var MongooseSchema18 = import_mongoose23.default.Schema;
|
|
2058
2031
|
var schema19 = new MongooseSchema18(
|
|
@@ -2064,7 +2037,7 @@ var schema19 = new MongooseSchema18(
|
|
|
2064
2037
|
},
|
|
2065
2038
|
nzbn: { required: true, type: String },
|
|
2066
2039
|
partnerType: {
|
|
2067
|
-
enum: Object.values(
|
|
2040
|
+
enum: Object.values(import_cluemart_shared18.EnumPartnerType),
|
|
2068
2041
|
required: true,
|
|
2069
2042
|
type: String
|
|
2070
2043
|
}
|
|
@@ -2082,7 +2055,7 @@ schema19.plugin(searchNamePlugin);
|
|
|
2082
2055
|
var PartnerModel = import_mongoose23.default.models.Partner || import_mongoose23.default.model("Partner", schema19);
|
|
2083
2056
|
|
|
2084
2057
|
// src/mongoose/Post.ts
|
|
2085
|
-
var
|
|
2058
|
+
var import_cluemart_shared19 = require("@timardex/cluemart-shared");
|
|
2086
2059
|
var import_mongoose24 = __toESM(require("mongoose"));
|
|
2087
2060
|
var MongooseSchema19 = import_mongoose24.default.Schema;
|
|
2088
2061
|
var contentSchema = new MongooseSchema19(
|
|
@@ -2090,7 +2063,7 @@ var contentSchema = new MongooseSchema19(
|
|
|
2090
2063
|
contentData: import_mongoose24.Schema.Types.Mixed,
|
|
2091
2064
|
contentOrder: { required: true, type: Number },
|
|
2092
2065
|
contentType: {
|
|
2093
|
-
enum: Object.values(
|
|
2066
|
+
enum: Object.values(import_cluemart_shared19.EnumPostContentType),
|
|
2094
2067
|
required: true,
|
|
2095
2068
|
type: String
|
|
2096
2069
|
}
|
|
@@ -2103,7 +2076,7 @@ var resourceSchema = new MongooseSchema19(
|
|
|
2103
2076
|
resourceRegion: { required: true, type: String },
|
|
2104
2077
|
resourceSlug: { required: true, type: String },
|
|
2105
2078
|
resourceType: {
|
|
2106
|
-
enum: Object.values(
|
|
2079
|
+
enum: Object.values(import_cluemart_shared19.EnumResourceType),
|
|
2107
2080
|
required: true,
|
|
2108
2081
|
type: String
|
|
2109
2082
|
}
|
|
@@ -2126,7 +2099,7 @@ var schema20 = new MongooseSchema19(
|
|
|
2126
2099
|
},
|
|
2127
2100
|
deletedAt: { default: null, required: false, type: Date },
|
|
2128
2101
|
postType: {
|
|
2129
|
-
enum: Object.values(
|
|
2102
|
+
enum: Object.values(import_cluemart_shared19.EnumPostType),
|
|
2130
2103
|
required: true,
|
|
2131
2104
|
type: String
|
|
2132
2105
|
},
|
|
@@ -2188,7 +2161,7 @@ var AppSettingSchema = new MongooseSchema20(
|
|
|
2188
2161
|
var AppSettingModel = import_mongoose25.default.models.AppSetting || import_mongoose25.default.model("AppSetting", AppSettingSchema);
|
|
2189
2162
|
|
|
2190
2163
|
// src/mongoose/game/Game.ts
|
|
2191
|
-
var
|
|
2164
|
+
var import_cluemart_shared20 = require("@timardex/cluemart-shared");
|
|
2192
2165
|
var import_mongoose29 = __toESM(require("mongoose"));
|
|
2193
2166
|
|
|
2194
2167
|
// src/mongoose/game/DailyClue.ts
|
|
@@ -2285,9 +2258,9 @@ var schemaPuzzleGameData = new MongooseSchema23(
|
|
|
2285
2258
|
// src/mongoose/game/Game.ts
|
|
2286
2259
|
var MongooseSchema24 = import_mongoose29.default.Schema;
|
|
2287
2260
|
var gameDataSchemas = {
|
|
2288
|
-
[
|
|
2289
|
-
[
|
|
2290
|
-
[
|
|
2261
|
+
[import_cluemart_shared20.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
|
|
2262
|
+
[import_cluemart_shared20.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
|
|
2263
|
+
[import_cluemart_shared20.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
|
|
2291
2264
|
};
|
|
2292
2265
|
var gameDataDefinition = Object.fromEntries(
|
|
2293
2266
|
Object.entries(gameDataSchemas).map(([key, schema25]) => [
|
|
@@ -2300,13 +2273,13 @@ var gameHistorySchema = new MongooseSchema24(
|
|
|
2300
2273
|
createdAt: { required: true, type: Date },
|
|
2301
2274
|
gameDate: { required: true, type: schemaGameDate },
|
|
2302
2275
|
gameStatus: {
|
|
2303
|
-
enum: Object.values(
|
|
2276
|
+
enum: Object.values(import_cluemart_shared20.EnumGameStatus),
|
|
2304
2277
|
required: true,
|
|
2305
2278
|
type: String
|
|
2306
2279
|
},
|
|
2307
2280
|
gameTitle: { required: true, type: String },
|
|
2308
2281
|
gameType: {
|
|
2309
|
-
enum: Object.values(
|
|
2282
|
+
enum: Object.values(import_cluemart_shared20.EnumGameType),
|
|
2310
2283
|
required: true,
|
|
2311
2284
|
type: String
|
|
2312
2285
|
},
|
|
@@ -2322,7 +2295,7 @@ var gameTypeSchema = new MongooseSchema24(
|
|
|
2322
2295
|
gameHistory: { default: [], required: true, type: [gameHistorySchema] },
|
|
2323
2296
|
gameTitle: { required: true, type: String },
|
|
2324
2297
|
gameType: {
|
|
2325
|
-
enum: Object.values(
|
|
2298
|
+
enum: Object.values(import_cluemart_shared20.EnumGameType),
|
|
2326
2299
|
required: true,
|
|
2327
2300
|
type: String
|
|
2328
2301
|
},
|
|
@@ -2396,7 +2369,7 @@ schema22.index(
|
|
|
2396
2369
|
var SchoolModel = import_mongoose30.default.models.School || import_mongoose30.default.model("School", schema22);
|
|
2397
2370
|
|
|
2398
2371
|
// src/mongoose/Affiliate.ts
|
|
2399
|
-
var
|
|
2372
|
+
var import_cluemart_shared21 = require("@timardex/cluemart-shared");
|
|
2400
2373
|
var import_mongoose31 = __toESM(require("mongoose"));
|
|
2401
2374
|
var MongooseSchema26 = import_mongoose31.default.Schema;
|
|
2402
2375
|
var affiliateRewardSchema = new MongooseSchema26(
|
|
@@ -2405,7 +2378,7 @@ var affiliateRewardSchema = new MongooseSchema26(
|
|
|
2405
2378
|
redeemedAt: { default: null, required: false, type: Date },
|
|
2406
2379
|
rewardDescription: { required: true, type: String },
|
|
2407
2380
|
rewardType: {
|
|
2408
|
-
enum: Object.values(
|
|
2381
|
+
enum: Object.values(import_cluemart_shared21.EnumAffiliateRewardType),
|
|
2409
2382
|
required: true,
|
|
2410
2383
|
type: String
|
|
2411
2384
|
},
|
|
@@ -2427,7 +2400,7 @@ var affiliateResourceSchema = new MongooseSchema26(
|
|
|
2427
2400
|
type: OwnerTypeSchema
|
|
2428
2401
|
},
|
|
2429
2402
|
resourceType: {
|
|
2430
|
-
enum: Object.values(
|
|
2403
|
+
enum: Object.values(import_cluemart_shared21.EnumResourceType),
|
|
2431
2404
|
required: true,
|
|
2432
2405
|
type: String
|
|
2433
2406
|
},
|
|
@@ -2465,7 +2438,7 @@ var affiliateDetailsSchema = new MongooseSchema26(
|
|
|
2465
2438
|
lastName: { required: true, type: String },
|
|
2466
2439
|
location: { required: true, type: locationsSchema },
|
|
2467
2440
|
participantType: {
|
|
2468
|
-
enum: Object.values(
|
|
2441
|
+
enum: Object.values(import_cluemart_shared21.EnumAffiliateParticipantType),
|
|
2469
2442
|
required: true,
|
|
2470
2443
|
type: String
|
|
2471
2444
|
},
|
|
@@ -2522,7 +2495,7 @@ schema23.index(
|
|
|
2522
2495
|
var AffiliateModel = import_mongoose31.default.models.Affiliate || import_mongoose31.default.model("Affiliate", schema23);
|
|
2523
2496
|
|
|
2524
2497
|
// src/mongoose/Coupon.ts
|
|
2525
|
-
var
|
|
2498
|
+
var import_cluemart_shared22 = require("@timardex/cluemart-shared");
|
|
2526
2499
|
var import_mongoose32 = __toESM(require("mongoose"));
|
|
2527
2500
|
var MongooseSchema27 = import_mongoose32.default.Schema;
|
|
2528
2501
|
var couponOptionSchema = new MongooseSchema27(
|
|
@@ -2531,7 +2504,7 @@ var couponOptionSchema = new MongooseSchema27(
|
|
|
2531
2504
|
get: { required: false, type: Number },
|
|
2532
2505
|
maxRewardCount: { required: false, type: Number },
|
|
2533
2506
|
type: {
|
|
2534
|
-
enum: Object.values(
|
|
2507
|
+
enum: Object.values(import_cluemart_shared22.EnumCouponQualificationType),
|
|
2535
2508
|
required: true,
|
|
2536
2509
|
type: String
|
|
2537
2510
|
},
|
|
@@ -2603,7 +2576,7 @@ var couponDataSchema = new MongooseSchema27(
|
|
|
2603
2576
|
},
|
|
2604
2577
|
resourceId: { required: true, type: String },
|
|
2605
2578
|
resourceType: {
|
|
2606
|
-
enum: Object.values(
|
|
2579
|
+
enum: Object.values(import_cluemart_shared22.EnumResourceType),
|
|
2607
2580
|
required: true,
|
|
2608
2581
|
type: String
|
|
2609
2582
|
},
|
|
@@ -2628,7 +2601,7 @@ schema24.index({ "couponData.participantUsers.userId": 1 });
|
|
|
2628
2601
|
var CouponModel = import_mongoose32.default.models.Coupon || import_mongoose32.default.model("Coupon", schema24);
|
|
2629
2602
|
|
|
2630
2603
|
// src/mongoose/Impersonation.ts
|
|
2631
|
-
var
|
|
2604
|
+
var import_cluemart_shared23 = require("@timardex/cluemart-shared");
|
|
2632
2605
|
var import_mongoose33 = __toESM(require("mongoose"));
|
|
2633
2606
|
var MongooseSchema28 = import_mongoose33.default.Schema;
|
|
2634
2607
|
var impersonationSessionSchema = new MongooseSchema28(
|
|
@@ -2669,7 +2642,7 @@ var impersonationAuditSchema = new MongooseSchema28(
|
|
|
2669
2642
|
type: import_mongoose33.default.Schema.Types.ObjectId
|
|
2670
2643
|
},
|
|
2671
2644
|
resourceId: { type: import_mongoose33.default.Schema.Types.ObjectId },
|
|
2672
|
-
resourceType: { enum: Object.values(
|
|
2645
|
+
resourceType: { enum: Object.values(import_cluemart_shared23.EnumResourceType), type: String },
|
|
2673
2646
|
sessionId: {
|
|
2674
2647
|
ref: "ImpersonationSession",
|
|
2675
2648
|
required: true,
|
|
@@ -2699,7 +2672,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
|
|
|
2699
2672
|
}
|
|
2700
2673
|
|
|
2701
2674
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
2702
|
-
var
|
|
2675
|
+
var import_cluemart_shared25 = require("@timardex/cluemart-shared");
|
|
2703
2676
|
var import_utils3 = require("@timardex/cluemart-shared/utils");
|
|
2704
2677
|
|
|
2705
2678
|
// src/service/saveNotificationsInDb.ts
|
|
@@ -2834,7 +2807,7 @@ async function sendPushNotifications({
|
|
|
2834
2807
|
}
|
|
2835
2808
|
|
|
2836
2809
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
2837
|
-
var
|
|
2810
|
+
var import_cluemart_shared24 = require("@timardex/cluemart-shared");
|
|
2838
2811
|
var import_dayjs = __toESM(require("dayjs"));
|
|
2839
2812
|
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
|
|
2840
2813
|
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
@@ -2853,7 +2826,7 @@ var PRO_PLANS = /* @__PURE__ */ new Set([
|
|
|
2853
2826
|
...PRO_EVENT_PLANS,
|
|
2854
2827
|
...PRO_VENDOR_PLANS
|
|
2855
2828
|
]);
|
|
2856
|
-
async function
|
|
2829
|
+
async function getStripePlanFor(userId, now, allowedPlans, requirePaidAccess = true) {
|
|
2857
2830
|
const user = await UserModel.findById(userId).select("licences stripe").lean().exec();
|
|
2858
2831
|
if (!user) {
|
|
2859
2832
|
return { hasSubscription: false, plan: null, validTypes: /* @__PURE__ */ new Set() };
|
|
@@ -2868,38 +2841,41 @@ async function getPayingStripePlanFor(userId, now, payingPlans) {
|
|
|
2868
2841
|
if (stripe == null || stripe.subscriptionId == null) {
|
|
2869
2842
|
return { hasSubscription: false, plan: null, validTypes };
|
|
2870
2843
|
}
|
|
2871
|
-
const hasActiveStatus = stripe.status === import_enums2.EnumSubscriptionStatus.ACTIVE;
|
|
2844
|
+
const hasActiveStatus = stripe.status === import_enums2.EnumSubscriptionStatus.ACTIVE || !requirePaidAccess && stripe.status === import_enums2.EnumSubscriptionStatus.TRIALING;
|
|
2872
2845
|
const paidThrough = stripe.endDate ? new Date(stripe.endDate).getTime() : Number.NaN;
|
|
2873
|
-
if (!hasActiveStatus || !Number.isFinite(paidThrough) || paidThrough <= now.getTime() || stripe.currentPlan == null) {
|
|
2846
|
+
if (!hasActiveStatus || requirePaidAccess && (!Number.isFinite(paidThrough) || paidThrough <= now.getTime()) || stripe.currentPlan == null) {
|
|
2874
2847
|
return { hasSubscription: false, plan: null, validTypes };
|
|
2875
2848
|
}
|
|
2876
|
-
const plan =
|
|
2849
|
+
const plan = allowedPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
|
|
2877
2850
|
return { hasSubscription: plan != null, plan, validTypes };
|
|
2878
2851
|
}
|
|
2879
2852
|
async function getPayingStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
2880
|
-
return
|
|
2853
|
+
return getStripePlanFor(userId, now, PRO_PLANS);
|
|
2881
2854
|
}
|
|
2882
2855
|
async function getPayingVendorStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
2883
|
-
return
|
|
2856
|
+
return getStripePlanFor(userId, now, PRO_VENDOR_PLANS);
|
|
2857
|
+
}
|
|
2858
|
+
async function getVendorStripeSubscriptionPlanForRewards(userId, now = /* @__PURE__ */ new Date()) {
|
|
2859
|
+
return getStripePlanFor(userId, now, PRO_VENDOR_PLANS, false);
|
|
2884
2860
|
}
|
|
2885
2861
|
async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
2886
|
-
return
|
|
2862
|
+
return getStripePlanFor(userId, now, PRO_EVENT_PLANS);
|
|
2887
2863
|
}
|
|
2888
2864
|
|
|
2889
2865
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
2890
2866
|
import_dayjs.default.extend(import_utc.default);
|
|
2891
2867
|
import_dayjs.default.extend(import_timezone.default);
|
|
2892
|
-
var SUBSCRIPTION_REWARD_TIMEZONE =
|
|
2868
|
+
var SUBSCRIPTION_REWARD_TIMEZONE = import_cluemart_shared24.NZ_TZ;
|
|
2893
2869
|
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
2894
|
-
const { hasSubscription, validTypes } = await
|
|
2895
|
-
if (validTypes.has(
|
|
2870
|
+
const { hasSubscription, validTypes } = await getVendorStripeSubscriptionPlanForRewards(userId, now);
|
|
2871
|
+
if (validTypes.has(import_cluemart_shared24.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared24.EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
2896
2872
|
if (hasSubscription) {
|
|
2897
|
-
return
|
|
2873
|
+
return import_cluemart_shared24.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
2898
2874
|
}
|
|
2899
|
-
return
|
|
2875
|
+
return import_cluemart_shared24.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2900
2876
|
}
|
|
2901
|
-
if (validTypes.has(
|
|
2902
|
-
return
|
|
2877
|
+
if (validTypes.has(import_cluemart_shared24.EnumUserLicence.STANDARD_VENDOR)) {
|
|
2878
|
+
return import_cluemart_shared24.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2903
2879
|
}
|
|
2904
2880
|
return null;
|
|
2905
2881
|
}
|
|
@@ -2911,7 +2887,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
|
|
|
2911
2887
|
|
|
2912
2888
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
2913
2889
|
function isEligibleVendorResource(resource) {
|
|
2914
|
-
return resource.resourceType ===
|
|
2890
|
+
return resource.resourceType === import_cluemart_shared25.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
|
|
2915
2891
|
}
|
|
2916
2892
|
async function findAffiliatesWithActiveVendorReferrals() {
|
|
2917
2893
|
return await AffiliateModel.find({
|
|
@@ -2920,7 +2896,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
2920
2896
|
$elemMatch: {
|
|
2921
2897
|
resourceActive: true,
|
|
2922
2898
|
resourceDeletedAt: null,
|
|
2923
|
-
resourceType:
|
|
2899
|
+
resourceType: import_cluemart_shared25.EnumResourceType.VENDOR
|
|
2924
2900
|
}
|
|
2925
2901
|
},
|
|
2926
2902
|
deletedAt: null
|
|
@@ -2954,11 +2930,11 @@ async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
|
2954
2930
|
data: {
|
|
2955
2931
|
resourceId: String(affiliateId),
|
|
2956
2932
|
resourceName: resourceNames.join(", "),
|
|
2957
|
-
resourceType:
|
|
2933
|
+
resourceType: import_cluemart_shared25.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
|
|
2958
2934
|
},
|
|
2959
2935
|
message,
|
|
2960
2936
|
title: "Affiliate points earned",
|
|
2961
|
-
type:
|
|
2937
|
+
type: import_cluemart_shared25.EnumNotificationType.SYSTEM,
|
|
2962
2938
|
userIds: [affiliateOwnerUserId]
|
|
2963
2939
|
};
|
|
2964
2940
|
try {
|
|
@@ -2987,7 +2963,7 @@ async function tryAwardSubscriptionReward({
|
|
|
2987
2963
|
resourceActive: true,
|
|
2988
2964
|
resourceDeletedAt: null,
|
|
2989
2965
|
resourceId: resource.resourceId,
|
|
2990
|
-
resourceType:
|
|
2966
|
+
resourceType: import_cluemart_shared25.EnumResourceType.VENDOR,
|
|
2991
2967
|
rewards: {
|
|
2992
2968
|
$not: {
|
|
2993
2969
|
$elemMatch: {
|
|
@@ -3189,9 +3165,9 @@ async function notifyUsers({
|
|
|
3189
3165
|
}
|
|
3190
3166
|
|
|
3191
3167
|
// src/service/updateAdStatus.ts
|
|
3192
|
-
var
|
|
3168
|
+
var import_cluemart_shared26 = require("@timardex/cluemart-shared");
|
|
3193
3169
|
async function updateAdStatuses() {
|
|
3194
|
-
const now =
|
|
3170
|
+
const now = (0, import_cluemart_shared26.nzDayKey)();
|
|
3195
3171
|
const invalidResult = await AdModel.updateMany(
|
|
3196
3172
|
{
|
|
3197
3173
|
$or: [
|
|
@@ -3199,50 +3175,50 @@ async function updateAdStatuses() {
|
|
|
3199
3175
|
{ end: { $exists: false } },
|
|
3200
3176
|
{ $expr: { $gt: ["$start", "$end"] } }
|
|
3201
3177
|
],
|
|
3202
|
-
status: { $ne:
|
|
3178
|
+
status: { $ne: import_cluemart_shared26.EnumAdStatus.PAUSED }
|
|
3203
3179
|
},
|
|
3204
|
-
{ $set: { status:
|
|
3180
|
+
{ $set: { status: import_cluemart_shared26.EnumAdStatus.PAUSED } }
|
|
3205
3181
|
);
|
|
3206
3182
|
const expiredResult = await AdModel.updateMany(
|
|
3207
|
-
{ end: { $lte: now }, status: { $ne:
|
|
3208
|
-
{ $set: { status:
|
|
3183
|
+
{ end: { $lte: now }, status: { $ne: import_cluemart_shared26.EnumAdStatus.EXPIRED } },
|
|
3184
|
+
{ $set: { status: import_cluemart_shared26.EnumAdStatus.EXPIRED } }
|
|
3209
3185
|
);
|
|
3210
3186
|
const eligibleBooking = {
|
|
3211
3187
|
$or: [
|
|
3212
3188
|
{ bookingKind: { $exists: false } },
|
|
3213
3189
|
{ bookingKind: null },
|
|
3214
3190
|
{
|
|
3215
|
-
approvalStatus:
|
|
3216
|
-
bookingKind:
|
|
3191
|
+
approvalStatus: import_cluemart_shared26.EnumAdApprovalStatus.APPROVED,
|
|
3192
|
+
bookingKind: import_cluemart_shared26.EnumAdBookingSlotKind.RESERVED
|
|
3217
3193
|
},
|
|
3218
3194
|
{
|
|
3219
|
-
approvalStatus:
|
|
3220
|
-
bookingKind:
|
|
3221
|
-
paymentStatus:
|
|
3195
|
+
approvalStatus: import_cluemart_shared26.EnumAdApprovalStatus.APPROVED,
|
|
3196
|
+
bookingKind: import_cluemart_shared26.EnumAdBookingSlotKind.PAID,
|
|
3197
|
+
paymentStatus: import_cluemart_shared26.EnumAdPaymentStatus.PAID
|
|
3222
3198
|
}
|
|
3223
3199
|
]
|
|
3224
3200
|
};
|
|
3225
3201
|
const awaitingApprovalResult = await AdModel.updateMany(
|
|
3226
3202
|
{
|
|
3227
3203
|
$nor: eligibleBooking.$or,
|
|
3228
|
-
bookingKind: { $in: Object.values(
|
|
3204
|
+
bookingKind: { $in: Object.values(import_cluemart_shared26.EnumAdBookingSlotKind) },
|
|
3229
3205
|
end: { $gt: now },
|
|
3230
|
-
status:
|
|
3206
|
+
status: import_cluemart_shared26.EnumAdStatus.ACTIVE
|
|
3231
3207
|
},
|
|
3232
|
-
{ $set: { status:
|
|
3208
|
+
{ $set: { status: import_cluemart_shared26.EnumAdStatus.PAUSED } }
|
|
3233
3209
|
);
|
|
3234
3210
|
const activeResult = await AdModel.updateMany(
|
|
3235
3211
|
{
|
|
3236
3212
|
end: { $gt: now },
|
|
3237
3213
|
start: { $lte: now },
|
|
3238
|
-
status: { $ne:
|
|
3214
|
+
status: { $ne: import_cluemart_shared26.EnumAdStatus.ACTIVE },
|
|
3239
3215
|
...eligibleBooking
|
|
3240
3216
|
},
|
|
3241
|
-
{ $set: { status:
|
|
3217
|
+
{ $set: { status: import_cluemart_shared26.EnumAdStatus.ACTIVE } }
|
|
3242
3218
|
);
|
|
3243
3219
|
const pausedResult = await AdModel.updateMany(
|
|
3244
|
-
{ start: { $gt: now }, status: { $ne:
|
|
3245
|
-
{ $set: { status:
|
|
3220
|
+
{ start: { $gt: now }, status: { $ne: import_cluemart_shared26.EnumAdStatus.PAUSED } },
|
|
3221
|
+
{ $set: { status: import_cluemart_shared26.EnumAdStatus.PAUSED } }
|
|
3246
3222
|
);
|
|
3247
3223
|
console.log(
|
|
3248
3224
|
`\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
|
|
@@ -3452,19 +3428,19 @@ function buildUserPointEntryRemovalPipeline(pointType, sourceId) {
|
|
|
3452
3428
|
}
|
|
3453
3429
|
|
|
3454
3430
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
3455
|
-
var
|
|
3431
|
+
var import_cluemart_shared28 = require("@timardex/cluemart-shared");
|
|
3456
3432
|
var import_dayjs4 = __toESM(require("dayjs"));
|
|
3457
3433
|
|
|
3458
3434
|
// src/service/event/archiveEndedEventDates.ts
|
|
3459
|
-
var
|
|
3435
|
+
var import_cluemart_shared27 = require("@timardex/cluemart-shared");
|
|
3460
3436
|
var import_dayjs3 = __toESM(require("dayjs"));
|
|
3461
3437
|
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
3462
3438
|
import_dayjs3.default.extend(import_customParseFormat.default);
|
|
3463
3439
|
var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
|
|
3464
|
-
|
|
3440
|
+
import_cluemart_shared27.EnumEventDateStatus.ENDED
|
|
3465
3441
|
]);
|
|
3466
3442
|
var DISCARDED_STATUSES = /* @__PURE__ */ new Set([
|
|
3467
|
-
|
|
3443
|
+
import_cluemart_shared27.EnumEventDateStatus.INVALID
|
|
3468
3444
|
]);
|
|
3469
3445
|
function splitEventDatesForArchive(dateTime) {
|
|
3470
3446
|
return {
|
|
@@ -3487,12 +3463,12 @@ function dedupeArchivedSlotsByStartDateTime(slots) {
|
|
|
3487
3463
|
});
|
|
3488
3464
|
}
|
|
3489
3465
|
function isPastCanceledEventDate(slot, now) {
|
|
3490
|
-
if (slot.dateStatus !==
|
|
3466
|
+
if (slot.dateStatus !== import_cluemart_shared27.EnumEventDateStatus.CANCELED) {
|
|
3491
3467
|
return false;
|
|
3492
3468
|
}
|
|
3493
3469
|
const endDateTime = (0, import_dayjs3.default)(
|
|
3494
3470
|
`${slot.endDate} ${slot.endTime}`,
|
|
3495
|
-
`${
|
|
3471
|
+
`${import_cluemart_shared27.dateFormat} ${import_cluemart_shared27.timeFormat}`,
|
|
3496
3472
|
true
|
|
3497
3473
|
);
|
|
3498
3474
|
return endDateTime.isValid() && endDateTime.isBefore(now);
|
|
@@ -3538,7 +3514,7 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3538
3514
|
try {
|
|
3539
3515
|
for await (const doc of cursor) {
|
|
3540
3516
|
const dateTime = doc.dateTime.map(
|
|
3541
|
-
(slot) => (0,
|
|
3517
|
+
(slot) => (0, import_cluemart_shared28.updateSingleDateTimeStatus)(slot, now)
|
|
3542
3518
|
);
|
|
3543
3519
|
if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
|
|
3544
3520
|
continue;
|
|
@@ -3562,9 +3538,9 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3562
3538
|
var ARCHIVABLE_EVENT_FILTER = {
|
|
3563
3539
|
"dateTime.dateStatus": {
|
|
3564
3540
|
$in: [
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3541
|
+
import_cluemart_shared28.EnumEventDateStatus.ENDED,
|
|
3542
|
+
import_cluemart_shared28.EnumEventDateStatus.INVALID,
|
|
3543
|
+
import_cluemart_shared28.EnumEventDateStatus.CANCELED
|
|
3568
3544
|
]
|
|
3569
3545
|
},
|
|
3570
3546
|
deletedAt: null
|
|
@@ -3589,7 +3565,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
|
3589
3565
|
try {
|
|
3590
3566
|
for await (const doc of cursor) {
|
|
3591
3567
|
const updated = doc.dateTime.map(
|
|
3592
|
-
(slot) => (0,
|
|
3568
|
+
(slot) => (0, import_cluemart_shared28.updateSingleDateTimeStatus)(slot, now)
|
|
3593
3569
|
);
|
|
3594
3570
|
const { archive, discard } = splitEventDatesForArchive(updated);
|
|
3595
3571
|
const pastCanceled = updated.filter(
|
|
@@ -3613,13 +3589,13 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
|
3613
3589
|
if (archive.length > 0 || discard.length > 0) {
|
|
3614
3590
|
pullConditions.push({
|
|
3615
3591
|
dateStatus: {
|
|
3616
|
-
$in: [
|
|
3592
|
+
$in: [import_cluemart_shared28.EnumEventDateStatus.ENDED, import_cluemart_shared28.EnumEventDateStatus.INVALID]
|
|
3617
3593
|
}
|
|
3618
3594
|
});
|
|
3619
3595
|
}
|
|
3620
3596
|
for (const slot of pastCanceled) {
|
|
3621
3597
|
pullConditions.push({
|
|
3622
|
-
dateStatus:
|
|
3598
|
+
dateStatus: import_cluemart_shared28.EnumEventDateStatus.CANCELED,
|
|
3623
3599
|
startDate: slot.startDate,
|
|
3624
3600
|
startTime: slot.startTime
|
|
3625
3601
|
});
|
|
@@ -3661,9 +3637,9 @@ async function cleanEventInfoDates(now) {
|
|
|
3661
3637
|
try {
|
|
3662
3638
|
for await (const doc of cursor) {
|
|
3663
3639
|
const updated = doc.dateTime.map(
|
|
3664
|
-
(slot) => (0,
|
|
3640
|
+
(slot) => (0, import_cluemart_shared28.updateSingleDateTimeStatus)(slot, now)
|
|
3665
3641
|
);
|
|
3666
|
-
const kept = (0,
|
|
3642
|
+
const kept = (0, import_cluemart_shared28.filterDatesByFutureStatus)(updated);
|
|
3667
3643
|
if (kept.length === updated.length) {
|
|
3668
3644
|
continue;
|
|
3669
3645
|
}
|
|
@@ -3709,7 +3685,7 @@ async function updateAllEventDateTimeStatuses() {
|
|
|
3709
3685
|
}
|
|
3710
3686
|
|
|
3711
3687
|
// src/service/index.ts
|
|
3712
|
-
var
|
|
3688
|
+
var import_cluemart_shared36 = require("@timardex/cluemart-shared");
|
|
3713
3689
|
|
|
3714
3690
|
// src/service/event/findEventOrImportedMarketById.ts
|
|
3715
3691
|
async function findEventOrImportedMarketById(resourceId) {
|
|
@@ -3725,7 +3701,7 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
3725
3701
|
}
|
|
3726
3702
|
|
|
3727
3703
|
// src/service/relations.ts
|
|
3728
|
-
var
|
|
3704
|
+
var import_cluemart_shared29 = require("@timardex/cluemart-shared");
|
|
3729
3705
|
function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
|
|
3730
3706
|
if (!previousDateTime?.length) {
|
|
3731
3707
|
return false;
|
|
@@ -3741,19 +3717,19 @@ function didRemoveAnyStartedDates(previousDateTime, nextDateTime) {
|
|
|
3741
3717
|
return false;
|
|
3742
3718
|
}
|
|
3743
3719
|
return previousDateTime.some(
|
|
3744
|
-
(prev) => prev.dateStatus ===
|
|
3745
|
-
(next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus ===
|
|
3720
|
+
(prev) => prev.dateStatus === import_cluemart_shared29.EnumEventDateStatus.STARTED && !nextDateTime?.some(
|
|
3721
|
+
(next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus === import_cluemart_shared29.EnumEventDateStatus.STARTED
|
|
3746
3722
|
)
|
|
3747
3723
|
);
|
|
3748
3724
|
}
|
|
3749
|
-
function
|
|
3725
|
+
function updateRelationDatesToCanceled(relationDates, eventDateTime) {
|
|
3750
3726
|
return relationDates.map((relationDate) => {
|
|
3751
3727
|
const existsInEvent = eventDateTime?.some(
|
|
3752
3728
|
(dt) => dt.startDate === relationDate.dateTime.startDate && dt.startTime === relationDate.dateTime.startTime
|
|
3753
3729
|
) ?? false;
|
|
3754
3730
|
return {
|
|
3755
3731
|
...relationDate,
|
|
3756
|
-
status: existsInEvent ? relationDate.status :
|
|
3732
|
+
status: existsInEvent ? relationDate.status : import_cluemart_shared29.EnumInviteStatus.CANCELED
|
|
3757
3733
|
};
|
|
3758
3734
|
});
|
|
3759
3735
|
}
|
|
@@ -3762,15 +3738,15 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
3762
3738
|
var import_dayjs8 = __toESM(require("dayjs"));
|
|
3763
3739
|
|
|
3764
3740
|
// src/service/license/compliance/utils.ts
|
|
3765
|
-
var
|
|
3741
|
+
var import_cluemart_shared34 = require("@timardex/cluemart-shared");
|
|
3766
3742
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
3767
3743
|
|
|
3768
3744
|
// src/service/license/compliance/event.ts
|
|
3769
|
-
var
|
|
3745
|
+
var import_cluemart_shared30 = require("@timardex/cluemart-shared");
|
|
3770
3746
|
var eventLicences = [
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3747
|
+
import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT,
|
|
3748
|
+
import_cluemart_shared30.EnumUserLicence.PRO_EVENT,
|
|
3749
|
+
import_cluemart_shared30.EnumUserLicence.PRO_PLUS_EVENT
|
|
3774
3750
|
];
|
|
3775
3751
|
async function handleEventLicenceCompliance(user, now) {
|
|
3776
3752
|
if (!user.licences || !user.events?.length) {
|
|
@@ -3982,9 +3958,9 @@ function buildLicenceExpiryPipeline(params) {
|
|
|
3982
3958
|
}
|
|
3983
3959
|
|
|
3984
3960
|
// src/service/license/compliance/partner.ts
|
|
3985
|
-
var
|
|
3961
|
+
var import_cluemart_shared31 = require("@timardex/cluemart-shared");
|
|
3986
3962
|
var partnerLicences = [
|
|
3987
|
-
|
|
3963
|
+
import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER
|
|
3988
3964
|
];
|
|
3989
3965
|
async function handlePartnerLicenceCompliance(user, now) {
|
|
3990
3966
|
if (!user.licences || !user.partner) {
|
|
@@ -3994,11 +3970,11 @@ async function handlePartnerLicenceCompliance(user, now) {
|
|
|
3994
3970
|
}
|
|
3995
3971
|
|
|
3996
3972
|
// src/service/license/compliance/vendor.ts
|
|
3997
|
-
var
|
|
3973
|
+
var import_cluemart_shared33 = require("@timardex/cluemart-shared");
|
|
3998
3974
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
3999
3975
|
|
|
4000
3976
|
// src/service/license/models.ts
|
|
4001
|
-
var
|
|
3977
|
+
var import_cluemart_shared32 = require("@timardex/cluemart-shared");
|
|
4002
3978
|
var import_dayjs5 = __toESM(require("dayjs"));
|
|
4003
3979
|
var import_graphql = require("graphql");
|
|
4004
3980
|
var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
@@ -4010,31 +3986,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
|
4010
3986
|
return LicenceCategory2;
|
|
4011
3987
|
})(LicenceCategory || {});
|
|
4012
3988
|
var licenceCategoryMapping = {
|
|
4013
|
-
[
|
|
4014
|
-
[
|
|
4015
|
-
[
|
|
4016
|
-
[
|
|
4017
|
-
[
|
|
4018
|
-
[
|
|
4019
|
-
[
|
|
4020
|
-
[
|
|
4021
|
-
[
|
|
3989
|
+
[import_cluemart_shared32.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
|
|
3990
|
+
[import_cluemart_shared32.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
|
|
3991
|
+
[import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
|
|
3992
|
+
[import_cluemart_shared32.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
|
|
3993
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
|
|
3994
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
|
|
3995
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
|
|
3996
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
3997
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
|
|
4022
3998
|
};
|
|
4023
3999
|
var licencePriority = {
|
|
4024
|
-
[
|
|
4025
|
-
[
|
|
4026
|
-
[
|
|
4027
|
-
[
|
|
4028
|
-
[
|
|
4029
|
-
[
|
|
4030
|
-
[
|
|
4031
|
-
[
|
|
4032
|
-
[
|
|
4000
|
+
[import_cluemart_shared32.EnumUserLicence.PRO_PLUS_EVENT]: 3,
|
|
4001
|
+
[import_cluemart_shared32.EnumUserLicence.PRO_EVENT]: 2,
|
|
4002
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT]: 1,
|
|
4003
|
+
[import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
|
|
4004
|
+
[import_cluemart_shared32.EnumUserLicence.PRO_VENDOR]: 2,
|
|
4005
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR]: 1,
|
|
4006
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER]: 1,
|
|
4007
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_AFFILIATE]: 1,
|
|
4008
|
+
[import_cluemart_shared32.EnumUserLicence.STANDARD_SCHOOL]: 1
|
|
4033
4009
|
};
|
|
4034
4010
|
var standardLicences = [
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4011
|
+
import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR,
|
|
4012
|
+
import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT,
|
|
4013
|
+
import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER
|
|
4038
4014
|
];
|
|
4039
4015
|
var standardLicenceSet = new Set(standardLicences);
|
|
4040
4016
|
function isStandardLicence(licence) {
|
|
@@ -4048,11 +4024,11 @@ var categoryRegexMapping = {
|
|
|
4048
4024
|
["school" /* SCHOOL */]: /_school$/
|
|
4049
4025
|
};
|
|
4050
4026
|
var categoryFallbackLicence = {
|
|
4051
|
-
["event" /* EVENT */]:
|
|
4052
|
-
["partner" /* PARTNER */]:
|
|
4053
|
-
["vendor" /* VENDOR */]:
|
|
4054
|
-
["affiliate" /* AFFILIATE */]:
|
|
4055
|
-
["school" /* SCHOOL */]:
|
|
4027
|
+
["event" /* EVENT */]: import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT,
|
|
4028
|
+
["partner" /* PARTNER */]: import_cluemart_shared32.EnumUserLicence.STANDARD_PARTNER,
|
|
4029
|
+
["vendor" /* VENDOR */]: import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR,
|
|
4030
|
+
["affiliate" /* AFFILIATE */]: import_cluemart_shared32.EnumUserLicence.STANDARD_AFFILIATE,
|
|
4031
|
+
["school" /* SCHOOL */]: import_cluemart_shared32.EnumUserLicence.STANDARD_SCHOOL
|
|
4056
4032
|
};
|
|
4057
4033
|
var LicenceFilterInput = {
|
|
4058
4034
|
INPUT_USER_LICENCES: "$licences"
|
|
@@ -4082,11 +4058,11 @@ function getHighestLicenceForCategory(licences, category) {
|
|
|
4082
4058
|
function createLicenceObject(expiryDate, licenceType) {
|
|
4083
4059
|
const today = (0, import_dayjs5.default)();
|
|
4084
4060
|
const expiryDateMapping = {
|
|
4085
|
-
[
|
|
4086
|
-
[
|
|
4087
|
-
[
|
|
4088
|
-
[
|
|
4089
|
-
[
|
|
4061
|
+
[import_cluemart_shared32.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
|
|
4062
|
+
[import_cluemart_shared32.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
|
|
4063
|
+
[import_cluemart_shared32.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
|
|
4064
|
+
[import_cluemart_shared32.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
|
|
4065
|
+
[import_cluemart_shared32.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
|
|
4090
4066
|
};
|
|
4091
4067
|
const licenceObject = {
|
|
4092
4068
|
expiryDate: expiryDateMapping[expiryDate],
|
|
@@ -4190,13 +4166,13 @@ async function checkOwnerHasLicence({
|
|
|
4190
4166
|
const owner = await UserModel.findById(userId);
|
|
4191
4167
|
if (!owner) throw new import_graphql.GraphQLError("Owner not found");
|
|
4192
4168
|
const categoryByResource = {
|
|
4193
|
-
[
|
|
4194
|
-
[
|
|
4195
|
-
[
|
|
4196
|
-
[
|
|
4197
|
-
[
|
|
4169
|
+
[import_cluemart_shared32.EnumResourceType.EVENT]: "event" /* EVENT */,
|
|
4170
|
+
[import_cluemart_shared32.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
|
|
4171
|
+
[import_cluemart_shared32.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
|
|
4172
|
+
[import_cluemart_shared32.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
4173
|
+
[import_cluemart_shared32.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
|
|
4198
4174
|
};
|
|
4199
|
-
if (!(0,
|
|
4175
|
+
if (!(0, import_cluemart_shared32.isNonVisitorResourceType)(resourceType)) {
|
|
4200
4176
|
throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
|
|
4201
4177
|
}
|
|
4202
4178
|
const requiredCategory = categoryByResource[resourceType];
|
|
@@ -4276,7 +4252,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
|
|
|
4276
4252
|
return (result?.matchedCount ?? 0) > 0;
|
|
4277
4253
|
}
|
|
4278
4254
|
async function downgradeVendorProFeatures(userId, licenceType) {
|
|
4279
|
-
const isStandardVendor = licenceType ===
|
|
4255
|
+
const isStandardVendor = licenceType === import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR;
|
|
4280
4256
|
if (!isStandardVendor) {
|
|
4281
4257
|
return;
|
|
4282
4258
|
}
|
|
@@ -4323,7 +4299,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
|
|
|
4323
4299
|
return (result?.matchedCount ?? 0) > 0;
|
|
4324
4300
|
}
|
|
4325
4301
|
async function restoreVendorProFeatures(userId, licenceType) {
|
|
4326
|
-
const isProVendor = licenceType ===
|
|
4302
|
+
const isProVendor = licenceType === import_cluemart_shared33.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR;
|
|
4327
4303
|
if (!isProVendor) {
|
|
4328
4304
|
return;
|
|
4329
4305
|
}
|
|
@@ -4344,14 +4320,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
|
|
|
4344
4320
|
return false;
|
|
4345
4321
|
}
|
|
4346
4322
|
const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs6.default)(stripe.paymentGracePeriodEndsAt) : null;
|
|
4347
|
-
const hasActivePaymentGracePeriod = (stripe.status ===
|
|
4323
|
+
const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared33.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared33.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
|
|
4348
4324
|
if (hasActivePaymentGracePeriod) {
|
|
4349
4325
|
return true;
|
|
4350
4326
|
}
|
|
4351
4327
|
if (!stripe.subscriptionId) {
|
|
4352
4328
|
return false;
|
|
4353
4329
|
}
|
|
4354
|
-
if (stripe.status !==
|
|
4330
|
+
if (stripe.status !== import_cluemart_shared33.EnumSubscriptionStatus.ACTIVE) {
|
|
4355
4331
|
return false;
|
|
4356
4332
|
}
|
|
4357
4333
|
if (!stripe.endDate) {
|
|
@@ -4371,7 +4347,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4371
4347
|
return;
|
|
4372
4348
|
}
|
|
4373
4349
|
const proLicences = vendorLicencesOfUser.filter(
|
|
4374
|
-
(licence) => licence.licenceType !==
|
|
4350
|
+
(licence) => licence.licenceType !== import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR
|
|
4375
4351
|
);
|
|
4376
4352
|
const expiredProLicences = proLicences.filter(
|
|
4377
4353
|
(licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now)
|
|
@@ -4384,7 +4360,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4384
4360
|
const expiredProLicence = expiredProLicences.some(
|
|
4385
4361
|
(licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
4386
4362
|
);
|
|
4387
|
-
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences,
|
|
4363
|
+
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared33.vendorLicences, now);
|
|
4388
4364
|
const hasExpiredVendorLicence = vendorLicencesOfUser.some(
|
|
4389
4365
|
(licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
4390
4366
|
);
|
|
@@ -4400,7 +4376,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4400
4376
|
"owner.userId": user._id
|
|
4401
4377
|
}).lean().exec();
|
|
4402
4378
|
}
|
|
4403
|
-
const licencesToSync =
|
|
4379
|
+
const licencesToSync = import_cluemart_shared33.vendorLicences.filter(
|
|
4404
4380
|
(licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
|
|
4405
4381
|
);
|
|
4406
4382
|
await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
|
|
@@ -4415,11 +4391,11 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4415
4391
|
data: {
|
|
4416
4392
|
resourceId: String(vendor._id),
|
|
4417
4393
|
resourceName: vendor.name,
|
|
4418
|
-
resourceType:
|
|
4394
|
+
resourceType: import_cluemart_shared33.EnumNotificationResourceType.DOWNGRADED_VENDOR
|
|
4419
4395
|
},
|
|
4420
4396
|
message: `Your Vendor licence has been downgraded due to licence expiration.`,
|
|
4421
4397
|
title: `Vendor Licence Downgraded`,
|
|
4422
|
-
type:
|
|
4398
|
+
type: import_cluemart_shared33.EnumNotificationType.SYSTEM,
|
|
4423
4399
|
userIds: [user._id]
|
|
4424
4400
|
};
|
|
4425
4401
|
await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
|
|
@@ -4452,7 +4428,7 @@ async function vendorOwnerHasProLicence(vendorId) {
|
|
|
4452
4428
|
effectiveVendorLicences,
|
|
4453
4429
|
"vendor" /* VENDOR */
|
|
4454
4430
|
);
|
|
4455
|
-
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[
|
|
4431
|
+
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared33.EnumUserLicence.PRO_VENDOR];
|
|
4456
4432
|
}
|
|
4457
4433
|
|
|
4458
4434
|
// src/service/license/compliance/utils.ts
|
|
@@ -4462,12 +4438,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
|
|
|
4462
4438
|
const pipeline = buildLicenceExpiryPipeline({
|
|
4463
4439
|
downgradeBranches: [
|
|
4464
4440
|
{
|
|
4465
|
-
case:
|
|
4466
|
-
then:
|
|
4441
|
+
case: import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR,
|
|
4442
|
+
then: import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR
|
|
4467
4443
|
},
|
|
4468
4444
|
{
|
|
4469
|
-
case:
|
|
4470
|
-
then:
|
|
4445
|
+
case: import_cluemart_shared34.EnumUserLicence.PRO_VENDOR,
|
|
4446
|
+
then: import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR
|
|
4471
4447
|
}
|
|
4472
4448
|
],
|
|
4473
4449
|
licenceTypes,
|
|
@@ -4596,7 +4572,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
|
|
|
4596
4572
|
var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
|
|
4597
4573
|
|
|
4598
4574
|
// src/service/license/reminder/utils.ts
|
|
4599
|
-
var
|
|
4575
|
+
var import_cluemart_shared35 = require("@timardex/cluemart-shared");
|
|
4600
4576
|
var import_utils8 = require("@timardex/cluemart-shared/utils");
|
|
4601
4577
|
var import_dayjs9 = __toESM(require("dayjs"));
|
|
4602
4578
|
|
|
@@ -4662,28 +4638,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
|
|
|
4662
4638
|
return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
|
|
4663
4639
|
}
|
|
4664
4640
|
function getLicenseName(licenceType) {
|
|
4665
|
-
return
|
|
4641
|
+
return import_cluemart_shared35.licenseNiceNames[licenceType] || licenceType;
|
|
4666
4642
|
}
|
|
4667
4643
|
function getNotificationTypes(isVendorLicense, isPartnerLicense) {
|
|
4668
4644
|
if (isVendorLicense) {
|
|
4669
4645
|
return {
|
|
4670
|
-
notificationType:
|
|
4671
|
-
resourceType:
|
|
4646
|
+
notificationType: import_cluemart_shared35.EnumNotificationType.SYSTEM,
|
|
4647
|
+
resourceType: import_cluemart_shared35.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
|
|
4672
4648
|
};
|
|
4673
4649
|
}
|
|
4674
4650
|
if (isPartnerLicense) {
|
|
4675
4651
|
return {
|
|
4676
|
-
notificationType:
|
|
4677
|
-
resourceType:
|
|
4652
|
+
notificationType: import_cluemart_shared35.EnumNotificationType.SYSTEM,
|
|
4653
|
+
resourceType: import_cluemart_shared35.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
|
|
4678
4654
|
};
|
|
4679
4655
|
}
|
|
4680
4656
|
return {
|
|
4681
|
-
notificationType:
|
|
4682
|
-
resourceType:
|
|
4657
|
+
notificationType: import_cluemart_shared35.EnumNotificationType.SYSTEM,
|
|
4658
|
+
resourceType: import_cluemart_shared35.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
|
|
4683
4659
|
};
|
|
4684
4660
|
}
|
|
4685
4661
|
async function getLicenseResourceInfo(user, licence) {
|
|
4686
|
-
const isVendorLicense =
|
|
4662
|
+
const isVendorLicense = import_cluemart_shared35.vendorLicences.includes(licence.licenceType);
|
|
4687
4663
|
const isPartnerLicense = partnerLicences.includes(licence.licenceType);
|
|
4688
4664
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4689
4665
|
const { notificationType, resourceType } = getNotificationTypes(
|
|
@@ -4731,11 +4707,11 @@ async function getLicenseResourceInfo(user, licence) {
|
|
|
4731
4707
|
};
|
|
4732
4708
|
}
|
|
4733
4709
|
function getLicenceExpiryMode(licenceType) {
|
|
4734
|
-
return licenceType ===
|
|
4710
|
+
return licenceType === import_cluemart_shared35.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
|
|
4735
4711
|
}
|
|
4736
4712
|
async function sendLicenseReminder(user, licence) {
|
|
4737
4713
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4738
|
-
const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(
|
|
4714
|
+
const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(import_cluemart_shared35.dateFormat);
|
|
4739
4715
|
const userId = String(user._id);
|
|
4740
4716
|
const resourceInfo = await getLicenseResourceInfo(user, licence);
|
|
4741
4717
|
if (!resourceInfo) {
|
|
@@ -4865,7 +4841,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4865
4841
|
APP_SETTINGS_ID,
|
|
4866
4842
|
AdBillingCatalogModel,
|
|
4867
4843
|
AdBookingModel,
|
|
4868
|
-
|
|
4844
|
+
AdMetricsModel,
|
|
4869
4845
|
AdModel,
|
|
4870
4846
|
AdSettingsModel,
|
|
4871
4847
|
AffiliateModel,
|
|
@@ -4982,7 +4958,7 @@ async function remindUsersAboutLicenseExpiration() {
|
|
|
4982
4958
|
termsAgreementSchema,
|
|
4983
4959
|
updateAdStatuses,
|
|
4984
4960
|
updateAllEventDateTimeStatuses,
|
|
4985
|
-
|
|
4961
|
+
updateRelationDatesToCanceled,
|
|
4986
4962
|
updateSingleDateTimeStatus,
|
|
4987
4963
|
upgradeUserToLicence,
|
|
4988
4964
|
userLicenseSchema,
|