@timardex/cluemart-server-shared 4.0.1 → 4.0.4
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-J7ZINA3I.mjs → chunk-AHC434D4.mjs} +351 -242
- package/dist/chunk-AHC434D4.mjs.map +1 -0
- package/dist/index.cjs +541 -432
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +93 -10
- package/dist/index.d.ts +93 -10
- package/dist/index.mjs +357 -248
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +411 -302
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +89 -7
- package/dist/mongoose/index.d.ts +89 -7
- package/dist/mongoose/index.mjs +9 -3
- package/dist/service/index.cjs +530 -428
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +4 -3
- package/dist/service/index.d.ts +4 -3
- package/dist/service/index.mjs +1 -1
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-J7ZINA3I.mjs.map +0 -1
package/dist/service/index.cjs
CHANGED
|
@@ -97,7 +97,7 @@ __export(service_exports, {
|
|
|
97
97
|
updateAdStatuses: () => updateAdStatuses,
|
|
98
98
|
updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
|
|
99
99
|
updateRelationDatesToCanceled: () => updateRelationDatesToCanceled,
|
|
100
|
-
updateSingleDateTimeStatus: () =>
|
|
100
|
+
updateSingleDateTimeStatus: () => import_cluemart_shared38.updateSingleDateTimeStatus,
|
|
101
101
|
upgradeUserToLicence: () => upgradeUserToLicence,
|
|
102
102
|
vendorOwnerHasProLicence: () => vendorOwnerHasProLicence
|
|
103
103
|
});
|
|
@@ -1004,15 +1004,15 @@ function syncSearchNameInUpdate(update) {
|
|
|
1004
1004
|
}
|
|
1005
1005
|
return null;
|
|
1006
1006
|
}
|
|
1007
|
-
function searchNamePlugin(
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1007
|
+
function searchNamePlugin(schema29) {
|
|
1008
|
+
schema29.add({ searchName: { default: "", required: false, type: String } });
|
|
1009
|
+
schema29.index({ searchName: 1 });
|
|
1010
|
+
schema29.pre("save", function syncSearchNameOnSave(next) {
|
|
1011
1011
|
const doc = this;
|
|
1012
1012
|
doc.searchName = deriveSearchName(doc.name);
|
|
1013
1013
|
next();
|
|
1014
1014
|
});
|
|
1015
|
-
|
|
1015
|
+
schema29.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
|
|
1016
1016
|
const list = Array.isArray(docs) ? docs : [docs];
|
|
1017
1017
|
for (const doc of list) {
|
|
1018
1018
|
if (doc && typeof doc.name === "string") {
|
|
@@ -1021,7 +1021,7 @@ function searchNamePlugin(schema27) {
|
|
|
1021
1021
|
}
|
|
1022
1022
|
next();
|
|
1023
1023
|
});
|
|
1024
|
-
|
|
1024
|
+
schema29.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
|
|
1025
1025
|
for (const op of ops) {
|
|
1026
1026
|
const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
|
|
1027
1027
|
if (doc && typeof doc.name === "string") {
|
|
@@ -1047,7 +1047,7 @@ function searchNamePlugin(schema27) {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
next();
|
|
1049
1049
|
};
|
|
1050
|
-
|
|
1050
|
+
schema29.pre(
|
|
1051
1051
|
["findOneAndUpdate", "updateOne", "updateMany"],
|
|
1052
1052
|
syncSearchNameOnUpdate
|
|
1053
1053
|
);
|
|
@@ -1163,8 +1163,15 @@ var schema8 = new MongooseSchema7(
|
|
|
1163
1163
|
type: ResourceImageTypeSchema
|
|
1164
1164
|
},
|
|
1165
1165
|
dateTime: [dateTimeSchema],
|
|
1166
|
+
deactivatedReason: {
|
|
1167
|
+
enum: Object.values(import_cluemart_shared10.EnumImportedMarketDeactivationReason),
|
|
1168
|
+
required: false,
|
|
1169
|
+
type: String
|
|
1170
|
+
},
|
|
1166
1171
|
deletedAt: { default: null, required: false, type: Date },
|
|
1167
1172
|
description: { required: true, type: String },
|
|
1173
|
+
descriptionSourceHash: { required: false, type: String },
|
|
1174
|
+
duplicateHint: { required: false, type: String },
|
|
1168
1175
|
earliestStartDate: { default: null, required: false, type: Date },
|
|
1169
1176
|
eventId: {
|
|
1170
1177
|
ref: "Event",
|
|
@@ -1177,11 +1184,13 @@ var schema8 = new MongooseSchema7(
|
|
|
1177
1184
|
type: String
|
|
1178
1185
|
},
|
|
1179
1186
|
images: { required: false, type: [ResourceImageTypeSchema] },
|
|
1187
|
+
lastSeenAt: { default: null, required: false, type: Date },
|
|
1180
1188
|
location: {
|
|
1181
1189
|
required: true,
|
|
1182
1190
|
type: locationsSchema
|
|
1183
1191
|
},
|
|
1184
1192
|
logo: { required: false, type: ResourceImageTypeSchema },
|
|
1193
|
+
missedRuns: { default: 0, required: true, type: Number },
|
|
1185
1194
|
name: { required: true, type: String },
|
|
1186
1195
|
openingHours: { required: false, type: [String] },
|
|
1187
1196
|
rainOrShine: { required: true, type: Boolean },
|
|
@@ -1211,6 +1220,7 @@ var schema8 = new MongooseSchema7(
|
|
|
1211
1220
|
},
|
|
1212
1221
|
sourceName: { required: true, type: String },
|
|
1213
1222
|
sourceUrl: { required: true, type: String },
|
|
1223
|
+
tags: { required: false, type: [String] },
|
|
1214
1224
|
website: { required: false, type: String }
|
|
1215
1225
|
},
|
|
1216
1226
|
{ timestamps: true }
|
|
@@ -1221,18 +1231,105 @@ schema8.index({ region: 1 });
|
|
|
1221
1231
|
schema8.index({ deletedAt: 1 });
|
|
1222
1232
|
schema8.index({ "dateTime.dateStatus": 1 });
|
|
1223
1233
|
schema8.index({ earliestStartDate: 1, _id: 1 });
|
|
1234
|
+
schema8.index({ reviewStatus: 1, active: 1, earliestStartDate: 1, _id: 1 });
|
|
1235
|
+
schema8.index({
|
|
1236
|
+
region: 1,
|
|
1237
|
+
reviewStatus: 1,
|
|
1238
|
+
active: 1,
|
|
1239
|
+
earliestStartDate: 1,
|
|
1240
|
+
_id: 1
|
|
1241
|
+
});
|
|
1242
|
+
schema8.index({ region: 1, searchName: 1 });
|
|
1224
1243
|
schema8.index({ slug: 1 });
|
|
1225
1244
|
schema8.index({ reviewStatus: 1 });
|
|
1226
1245
|
schema8.index({ description: "text", name: "text" });
|
|
1227
1246
|
schema8.plugin(searchNamePlugin);
|
|
1228
1247
|
var AiImportedMarketModel = import_mongoose11.default.models.AiImportedMarket || import_mongoose11.default.model("AiImportedMarket", schema8);
|
|
1229
1248
|
|
|
1230
|
-
// src/mongoose/
|
|
1249
|
+
// src/mongoose/AiImportRun.ts
|
|
1250
|
+
var import_cluemart_shared11 = require("@timardex/cluemart-shared");
|
|
1231
1251
|
var import_mongoose12 = __toESM(require("mongoose"));
|
|
1232
1252
|
var MongooseSchema8 = import_mongoose12.default.Schema;
|
|
1233
|
-
var
|
|
1253
|
+
var usageSchema = new MongooseSchema8(
|
|
1254
|
+
{
|
|
1255
|
+
completionTokens: { default: 0, required: true, type: Number },
|
|
1256
|
+
promptTokens: { default: 0, required: true, type: Number },
|
|
1257
|
+
totalTokens: { default: 0, required: true, type: Number }
|
|
1258
|
+
},
|
|
1259
|
+
{ _id: false }
|
|
1260
|
+
);
|
|
1261
|
+
var siteResultSchema = new MongooseSchema8(
|
|
1262
|
+
{
|
|
1263
|
+
error: { required: false, type: String },
|
|
1264
|
+
errors: { default: 0, required: true, type: Number },
|
|
1265
|
+
found: { default: 0, required: true, type: Number },
|
|
1266
|
+
imported: { default: 0, required: true, type: Number },
|
|
1267
|
+
name: { required: true, type: String },
|
|
1268
|
+
skipped: { default: 0, required: true, type: Number },
|
|
1269
|
+
status: {
|
|
1270
|
+
enum: [import_cluemart_shared11.EnumAiImportRunStatus.SUCCESS, import_cluemart_shared11.EnumAiImportRunStatus.ERROR],
|
|
1271
|
+
required: true,
|
|
1272
|
+
type: String
|
|
1273
|
+
},
|
|
1274
|
+
url: { required: true, type: String },
|
|
1275
|
+
usage: { required: true, type: usageSchema }
|
|
1276
|
+
},
|
|
1277
|
+
{ _id: false, suppressReservedKeysWarning: true }
|
|
1278
|
+
);
|
|
1279
|
+
var resultSchema = new MongooseSchema8(
|
|
1280
|
+
{
|
|
1281
|
+
errors: { default: 0, required: true, type: Number },
|
|
1282
|
+
totalFound: { default: 0, required: true, type: Number },
|
|
1283
|
+
totalImported: { default: 0, required: true, type: Number },
|
|
1284
|
+
totalSkipped: { default: 0, required: true, type: Number }
|
|
1285
|
+
},
|
|
1286
|
+
{ _id: false, suppressReservedKeysWarning: true }
|
|
1287
|
+
);
|
|
1288
|
+
var schema9 = new MongooseSchema8(
|
|
1289
|
+
{
|
|
1290
|
+
error: { required: false, type: String },
|
|
1291
|
+
finishedAt: { required: false, type: Date },
|
|
1292
|
+
result: { required: false, type: resultSchema },
|
|
1293
|
+
siteResults: { default: [], required: true, type: [siteResultSchema] },
|
|
1294
|
+
startedAt: { default: () => /* @__PURE__ */ new Date(), required: true, type: Date },
|
|
1295
|
+
status: {
|
|
1296
|
+
default: import_cluemart_shared11.EnumAiImportRunStatus.PENDING,
|
|
1297
|
+
enum: Object.values(import_cluemart_shared11.EnumAiImportRunStatus),
|
|
1298
|
+
required: true,
|
|
1299
|
+
type: String
|
|
1300
|
+
},
|
|
1301
|
+
triggeredByUserId: {
|
|
1302
|
+
ref: "User",
|
|
1303
|
+
required: false,
|
|
1304
|
+
type: import_mongoose12.default.Schema.Types.ObjectId
|
|
1305
|
+
},
|
|
1306
|
+
usage: { required: false, type: usageSchema }
|
|
1307
|
+
},
|
|
1308
|
+
{ timestamps: true }
|
|
1309
|
+
);
|
|
1310
|
+
schema9.index({ createdAt: -1 });
|
|
1311
|
+
var AiImportRunModel = import_mongoose12.default.models.AiImportRun || import_mongoose12.default.model("AiImportRun", schema9);
|
|
1312
|
+
|
|
1313
|
+
// src/mongoose/AiImportRunLock.ts
|
|
1314
|
+
var import_mongoose13 = __toESM(require("mongoose"));
|
|
1315
|
+
var MongooseSchema9 = import_mongoose13.default.Schema;
|
|
1316
|
+
var schema10 = new MongooseSchema9(
|
|
1317
|
+
{
|
|
1318
|
+
_id: { required: true, type: String },
|
|
1319
|
+
lockedAt: { required: false, type: Date },
|
|
1320
|
+
token: { required: false, type: String }
|
|
1321
|
+
},
|
|
1322
|
+
{ timestamps: true }
|
|
1323
|
+
);
|
|
1324
|
+
var AiImportRunLockModel = import_mongoose13.default.models.AiImportRunLock || import_mongoose13.default.model("AiImportRunLock", schema10);
|
|
1325
|
+
|
|
1326
|
+
// src/mongoose/ScrapeSite.ts
|
|
1327
|
+
var import_mongoose14 = __toESM(require("mongoose"));
|
|
1328
|
+
var MongooseSchema10 = import_mongoose14.default.Schema;
|
|
1329
|
+
var scrapeSiteItemSchema = new MongooseSchema10(
|
|
1234
1330
|
{
|
|
1235
1331
|
enabled: { default: true, required: true, type: Boolean },
|
|
1332
|
+
lastCount: { required: false, type: Number },
|
|
1236
1333
|
lastError: { required: false, type: String },
|
|
1237
1334
|
lastScrapedAt: { required: false, type: Date },
|
|
1238
1335
|
lastScrapeStatus: { required: false, type: String },
|
|
@@ -1242,36 +1339,41 @@ var scrapeSiteItemSchema = new MongooseSchema8(
|
|
|
1242
1339
|
},
|
|
1243
1340
|
{ timestamps: true }
|
|
1244
1341
|
);
|
|
1245
|
-
var configSchema = new
|
|
1342
|
+
var configSchema = new MongooseSchema10(
|
|
1246
1343
|
{
|
|
1247
|
-
|
|
1344
|
+
_id: { required: true, type: String },
|
|
1248
1345
|
sites: {
|
|
1249
1346
|
default: [],
|
|
1250
1347
|
required: true,
|
|
1251
1348
|
type: [scrapeSiteItemSchema]
|
|
1349
|
+
},
|
|
1350
|
+
updatedByUserId: {
|
|
1351
|
+
ref: "User",
|
|
1352
|
+
required: false,
|
|
1353
|
+
type: import_mongoose14.default.Schema.Types.ObjectId
|
|
1252
1354
|
}
|
|
1253
1355
|
},
|
|
1254
1356
|
{ timestamps: true }
|
|
1255
1357
|
);
|
|
1256
|
-
var ScrapeSiteConfigModel =
|
|
1358
|
+
var ScrapeSiteConfigModel = import_mongoose14.default.models.ScrapeSiteConfig || import_mongoose14.default.model("ScrapeSiteConfig", configSchema);
|
|
1257
1359
|
|
|
1258
1360
|
// src/mongoose/Notification.ts
|
|
1259
|
-
var
|
|
1260
|
-
var
|
|
1261
|
-
var
|
|
1262
|
-
var notificationDataSchema = new
|
|
1361
|
+
var import_cluemart_shared12 = require("@timardex/cluemart-shared");
|
|
1362
|
+
var import_mongoose15 = __toESM(require("mongoose"));
|
|
1363
|
+
var MongooseSchema11 = import_mongoose15.default.Schema;
|
|
1364
|
+
var notificationDataSchema = new MongooseSchema11(
|
|
1263
1365
|
{
|
|
1264
1366
|
resourceId: { required: true, type: String },
|
|
1265
1367
|
resourceName: { required: true, type: String },
|
|
1266
1368
|
resourceType: {
|
|
1267
|
-
enum: Object.values(
|
|
1369
|
+
enum: Object.values(import_cluemart_shared12.EnumNotificationResourceType),
|
|
1268
1370
|
required: true,
|
|
1269
1371
|
type: String
|
|
1270
1372
|
}
|
|
1271
1373
|
},
|
|
1272
1374
|
{ _id: false }
|
|
1273
1375
|
);
|
|
1274
|
-
var
|
|
1376
|
+
var schema11 = new MongooseSchema11(
|
|
1275
1377
|
{
|
|
1276
1378
|
data: {
|
|
1277
1379
|
default: null,
|
|
@@ -1282,28 +1384,28 @@ var schema9 = new MongooseSchema9(
|
|
|
1282
1384
|
message: { required: true, type: String },
|
|
1283
1385
|
title: { required: true, type: String },
|
|
1284
1386
|
type: {
|
|
1285
|
-
default:
|
|
1286
|
-
enum: Object.values(
|
|
1387
|
+
default: import_cluemart_shared12.EnumNotificationType.SYSTEM,
|
|
1388
|
+
enum: Object.values(import_cluemart_shared12.EnumNotificationType),
|
|
1287
1389
|
required: true,
|
|
1288
1390
|
type: String
|
|
1289
1391
|
},
|
|
1290
1392
|
userId: {
|
|
1291
1393
|
ref: "User",
|
|
1292
1394
|
required: true,
|
|
1293
|
-
type:
|
|
1395
|
+
type: import_mongoose15.default.Schema.Types.ObjectId
|
|
1294
1396
|
}
|
|
1295
1397
|
},
|
|
1296
1398
|
{ timestamps: true }
|
|
1297
1399
|
);
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
var NotificationModel =
|
|
1400
|
+
schema11.index({ isRead: 1, userId: 1 });
|
|
1401
|
+
schema11.index({ createdAt: -1, userId: 1 });
|
|
1402
|
+
var NotificationModel = import_mongoose15.default.models.Notification || import_mongoose15.default.model("Notification", schema11);
|
|
1301
1403
|
|
|
1302
1404
|
// src/mongoose/PushToken.ts
|
|
1303
1405
|
var import_enums = require("@timardex/cluemart-shared/enums");
|
|
1304
|
-
var
|
|
1305
|
-
var
|
|
1306
|
-
var
|
|
1406
|
+
var import_mongoose16 = __toESM(require("mongoose"));
|
|
1407
|
+
var MongooseSchema12 = import_mongoose16.default.Schema;
|
|
1408
|
+
var schema12 = new MongooseSchema12(
|
|
1307
1409
|
{
|
|
1308
1410
|
platform: {
|
|
1309
1411
|
enum: Object.values(import_enums.EnumOSPlatform),
|
|
@@ -1314,22 +1416,22 @@ var schema10 = new MongooseSchema10(
|
|
|
1314
1416
|
userId: {
|
|
1315
1417
|
ref: "User",
|
|
1316
1418
|
required: true,
|
|
1317
|
-
type:
|
|
1419
|
+
type: import_mongoose16.default.Schema.Types.ObjectId
|
|
1318
1420
|
}
|
|
1319
1421
|
},
|
|
1320
1422
|
{ timestamps: true }
|
|
1321
1423
|
);
|
|
1322
|
-
var PushTokenModel =
|
|
1424
|
+
var PushTokenModel = import_mongoose16.default.models.PushToken || import_mongoose16.default.model("PushToken", schema12);
|
|
1323
1425
|
|
|
1324
1426
|
// src/mongoose/Relation.ts
|
|
1325
|
-
var
|
|
1326
|
-
var
|
|
1427
|
+
var import_cluemart_shared14 = require("@timardex/cluemart-shared");
|
|
1428
|
+
var import_mongoose18 = __toESM(require("mongoose"));
|
|
1327
1429
|
|
|
1328
1430
|
// src/mongoose/event/EventInfo.ts
|
|
1329
|
-
var
|
|
1330
|
-
var
|
|
1331
|
-
var
|
|
1332
|
-
var StallTypeSchema = new
|
|
1431
|
+
var import_cluemart_shared13 = require("@timardex/cluemart-shared");
|
|
1432
|
+
var import_mongoose17 = __toESM(require("mongoose"));
|
|
1433
|
+
var MongooseSchema13 = import_mongoose17.default.Schema;
|
|
1434
|
+
var StallTypeSchema = new MongooseSchema13(
|
|
1333
1435
|
{
|
|
1334
1436
|
label: { required: false, type: String },
|
|
1335
1437
|
price: { required: false, type: Number },
|
|
@@ -1340,10 +1442,10 @@ var StallTypeSchema = new MongooseSchema11(
|
|
|
1340
1442
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1341
1443
|
}
|
|
1342
1444
|
);
|
|
1343
|
-
var dateTimeSchema2 = new
|
|
1445
|
+
var dateTimeSchema2 = new MongooseSchema13(
|
|
1344
1446
|
{
|
|
1345
1447
|
dateStatus: {
|
|
1346
|
-
enum: Object.values(
|
|
1448
|
+
enum: Object.values(import_cluemart_shared13.EnumEventDateStatus),
|
|
1347
1449
|
required: false,
|
|
1348
1450
|
type: String
|
|
1349
1451
|
},
|
|
@@ -1356,13 +1458,13 @@ var dateTimeSchema2 = new MongooseSchema11(
|
|
|
1356
1458
|
{ _id: false }
|
|
1357
1459
|
// Prevents Mongoose from creating an additional _id field for subdocuments
|
|
1358
1460
|
);
|
|
1359
|
-
var paymentInfoSchema = new
|
|
1461
|
+
var paymentInfoSchema = new MongooseSchema13(
|
|
1360
1462
|
{
|
|
1361
1463
|
accountHolderName: { required: false, type: String },
|
|
1362
1464
|
accountNumber: { required: false, type: String },
|
|
1363
1465
|
link: { required: false, type: String },
|
|
1364
1466
|
paymentMethod: {
|
|
1365
|
-
enum: Object.values(
|
|
1467
|
+
enum: Object.values(import_cluemart_shared13.EnumPaymentMethod),
|
|
1366
1468
|
required: true,
|
|
1367
1469
|
type: String
|
|
1368
1470
|
}
|
|
@@ -1370,7 +1472,7 @@ var paymentInfoSchema = new MongooseSchema11(
|
|
|
1370
1472
|
{ _id: false }
|
|
1371
1473
|
// Prevents Mongoose from creating an additional _id field
|
|
1372
1474
|
);
|
|
1373
|
-
var requirementsSchema = new
|
|
1475
|
+
var requirementsSchema = new MongooseSchema13(
|
|
1374
1476
|
{
|
|
1375
1477
|
category: { required: true, type: String },
|
|
1376
1478
|
label: { required: true, type: String },
|
|
@@ -1381,7 +1483,7 @@ var requirementsSchema = new MongooseSchema11(
|
|
|
1381
1483
|
// Prevents Mongoose from creating an additional _id field for
|
|
1382
1484
|
}
|
|
1383
1485
|
);
|
|
1384
|
-
var refundPolicySchema = new
|
|
1486
|
+
var refundPolicySchema = new MongooseSchema13(
|
|
1385
1487
|
{
|
|
1386
1488
|
category: { required: true, type: String },
|
|
1387
1489
|
label: { required: true, type: String },
|
|
@@ -1389,7 +1491,7 @@ var refundPolicySchema = new MongooseSchema11(
|
|
|
1389
1491
|
},
|
|
1390
1492
|
{ _id: false }
|
|
1391
1493
|
);
|
|
1392
|
-
var
|
|
1494
|
+
var schema13 = new MongooseSchema13(
|
|
1393
1495
|
{
|
|
1394
1496
|
active: { default: true, type: Boolean },
|
|
1395
1497
|
applicationDeadlineHours: { required: true, type: Number },
|
|
@@ -1397,7 +1499,7 @@ var schema11 = new MongooseSchema11(
|
|
|
1397
1499
|
eventId: {
|
|
1398
1500
|
ref: "Event",
|
|
1399
1501
|
required: true,
|
|
1400
|
-
type:
|
|
1502
|
+
type: import_mongoose17.default.Schema.Types.ObjectId
|
|
1401
1503
|
},
|
|
1402
1504
|
packInTime: { required: true, type: Number },
|
|
1403
1505
|
paymentDueHours: { required: true, type: Number },
|
|
@@ -1407,15 +1509,15 @@ var schema11 = new MongooseSchema11(
|
|
|
1407
1509
|
},
|
|
1408
1510
|
{ timestamps: true }
|
|
1409
1511
|
);
|
|
1410
|
-
|
|
1411
|
-
var EventInfoModel =
|
|
1512
|
+
schema13.index({ eventId: 1 });
|
|
1513
|
+
var EventInfoModel = import_mongoose17.default.models.EventInfo || import_mongoose17.default.model("EventInfo", schema13);
|
|
1412
1514
|
|
|
1413
1515
|
// src/mongoose/Relation.ts
|
|
1414
|
-
var
|
|
1415
|
-
var relationDateTimeSchema = new
|
|
1516
|
+
var MongooseSchema14 = import_mongoose18.default.Schema;
|
|
1517
|
+
var relationDateTimeSchema = new MongooseSchema14(
|
|
1416
1518
|
{
|
|
1417
1519
|
dateStatus: {
|
|
1418
|
-
enum: Object.values(
|
|
1520
|
+
enum: Object.values(import_cluemart_shared14.EnumEventDateStatus),
|
|
1419
1521
|
required: true,
|
|
1420
1522
|
type: String
|
|
1421
1523
|
},
|
|
@@ -1427,7 +1529,7 @@ var relationDateTimeSchema = new MongooseSchema12(
|
|
|
1427
1529
|
},
|
|
1428
1530
|
{ _id: false }
|
|
1429
1531
|
);
|
|
1430
|
-
var relationDatesSchema = new
|
|
1532
|
+
var relationDatesSchema = new MongooseSchema14(
|
|
1431
1533
|
{
|
|
1432
1534
|
dateTime: {
|
|
1433
1535
|
required: true,
|
|
@@ -1439,42 +1541,42 @@ var relationDatesSchema = new MongooseSchema12(
|
|
|
1439
1541
|
},
|
|
1440
1542
|
paymentReference: { required: false, type: String },
|
|
1441
1543
|
status: {
|
|
1442
|
-
enum: Object.values(
|
|
1544
|
+
enum: Object.values(import_cluemart_shared14.EnumInviteStatus),
|
|
1443
1545
|
required: false,
|
|
1444
1546
|
type: String
|
|
1445
1547
|
}
|
|
1446
1548
|
},
|
|
1447
1549
|
{ _id: false }
|
|
1448
1550
|
);
|
|
1449
|
-
var RelationTypeSchema = new
|
|
1551
|
+
var RelationTypeSchema = new MongooseSchema14(
|
|
1450
1552
|
{
|
|
1451
1553
|
active: { default: true, required: true, type: Boolean },
|
|
1452
1554
|
chatId: {
|
|
1453
1555
|
ref: "Chat",
|
|
1454
1556
|
required: true,
|
|
1455
|
-
type:
|
|
1557
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1456
1558
|
},
|
|
1457
1559
|
deletedAt: { default: null, required: false, type: Date },
|
|
1458
1560
|
eventId: {
|
|
1459
1561
|
ref: "Event",
|
|
1460
1562
|
required: true,
|
|
1461
|
-
type:
|
|
1563
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1462
1564
|
},
|
|
1463
1565
|
lastUpdateBy: {
|
|
1464
|
-
enum: Object.values(
|
|
1566
|
+
enum: Object.values(import_cluemart_shared14.EnumResourceType),
|
|
1465
1567
|
required: true,
|
|
1466
1568
|
type: String
|
|
1467
1569
|
},
|
|
1468
1570
|
relationDates: [relationDatesSchema],
|
|
1469
1571
|
relationType: {
|
|
1470
|
-
enum: Object.values(
|
|
1572
|
+
enum: Object.values(import_cluemart_shared14.EnumRelationResource),
|
|
1471
1573
|
required: true,
|
|
1472
1574
|
type: String
|
|
1473
1575
|
},
|
|
1474
1576
|
vendorId: {
|
|
1475
1577
|
ref: "Vendor",
|
|
1476
1578
|
required: true,
|
|
1477
|
-
type:
|
|
1579
|
+
type: import_mongoose18.default.Schema.Types.ObjectId
|
|
1478
1580
|
}
|
|
1479
1581
|
},
|
|
1480
1582
|
{ timestamps: true }
|
|
@@ -1486,21 +1588,21 @@ RelationTypeSchema.index({
|
|
|
1486
1588
|
"relationDates.status": 1,
|
|
1487
1589
|
vendorId: 1
|
|
1488
1590
|
});
|
|
1489
|
-
var RelationModel =
|
|
1591
|
+
var RelationModel = import_mongoose18.default.models.Relation || import_mongoose18.default.model("Relation", RelationTypeSchema);
|
|
1490
1592
|
|
|
1491
1593
|
// src/mongoose/ResourceActivity.ts
|
|
1492
|
-
var
|
|
1493
|
-
var
|
|
1494
|
-
var
|
|
1495
|
-
var ActivitySchema = new
|
|
1594
|
+
var import_cluemart_shared15 = require("@timardex/cluemart-shared");
|
|
1595
|
+
var import_mongoose19 = __toESM(require("mongoose"));
|
|
1596
|
+
var MongooseSchema15 = import_mongoose19.default.Schema;
|
|
1597
|
+
var ActivitySchema = new MongooseSchema15(
|
|
1496
1598
|
{
|
|
1497
1599
|
activityType: {
|
|
1498
|
-
enum: Object.values(
|
|
1600
|
+
enum: Object.values(import_cluemart_shared15.EnumActivity),
|
|
1499
1601
|
required: true,
|
|
1500
1602
|
type: String
|
|
1501
1603
|
},
|
|
1502
1604
|
dateStatus: {
|
|
1503
|
-
enum: Object.values(
|
|
1605
|
+
enum: Object.values(import_cluemart_shared15.EnumEventDateStatus),
|
|
1504
1606
|
required: false,
|
|
1505
1607
|
type: String
|
|
1506
1608
|
},
|
|
@@ -1512,7 +1614,7 @@ var ActivitySchema = new MongooseSchema13(
|
|
|
1512
1614
|
startTime: { required: false, type: String },
|
|
1513
1615
|
timestamp: { default: Date.now, type: Date },
|
|
1514
1616
|
userAgent: {
|
|
1515
|
-
enum: Object.values(
|
|
1617
|
+
enum: Object.values(import_cluemart_shared15.EnumOSPlatform),
|
|
1516
1618
|
required: true,
|
|
1517
1619
|
type: String
|
|
1518
1620
|
},
|
|
@@ -1520,61 +1622,61 @@ var ActivitySchema = new MongooseSchema13(
|
|
|
1520
1622
|
},
|
|
1521
1623
|
{ _id: false }
|
|
1522
1624
|
);
|
|
1523
|
-
var
|
|
1625
|
+
var schema14 = new MongooseSchema15(
|
|
1524
1626
|
{
|
|
1525
1627
|
activity: { default: [], type: [ActivitySchema] },
|
|
1526
1628
|
resourceId: { required: true, type: String },
|
|
1527
1629
|
resourceType: {
|
|
1528
|
-
enum: Object.values(
|
|
1630
|
+
enum: Object.values(import_cluemart_shared15.EnumResourceType),
|
|
1529
1631
|
required: true,
|
|
1530
1632
|
type: String
|
|
1531
1633
|
}
|
|
1532
1634
|
},
|
|
1533
1635
|
{ timestamps: true }
|
|
1534
1636
|
);
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
var ResourceActivityModel =
|
|
1637
|
+
schema14.index({ resourceId: 1, resourceType: 1 }, { unique: true });
|
|
1638
|
+
schema14.index({ "views.location": "2dsphere" });
|
|
1639
|
+
var ResourceActivityModel = import_mongoose19.default.models.ResourceActivity || import_mongoose19.default.model("ResourceActivity", schema14);
|
|
1538
1640
|
|
|
1539
1641
|
// src/mongoose/User.ts
|
|
1540
|
-
var
|
|
1541
|
-
var
|
|
1542
|
-
var
|
|
1543
|
-
var userActivityEventSchema = new
|
|
1642
|
+
var import_cluemart_shared16 = require("@timardex/cluemart-shared");
|
|
1643
|
+
var import_mongoose20 = __toESM(require("mongoose"));
|
|
1644
|
+
var MongooseSchema16 = import_mongoose20.default.Schema;
|
|
1645
|
+
var userActivityEventSchema = new MongooseSchema16(
|
|
1544
1646
|
{
|
|
1545
1647
|
dateTime: dateTimeSchema,
|
|
1546
1648
|
resourceId: {
|
|
1547
1649
|
ref: "Event",
|
|
1548
1650
|
required: false,
|
|
1549
|
-
type:
|
|
1651
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1550
1652
|
}
|
|
1551
1653
|
},
|
|
1552
1654
|
{ _id: false }
|
|
1553
1655
|
);
|
|
1554
|
-
var userActivityFavouritesSchema = new
|
|
1656
|
+
var userActivityFavouritesSchema = new MongooseSchema16(
|
|
1555
1657
|
{
|
|
1556
1658
|
events: {
|
|
1557
1659
|
ref: "Event",
|
|
1558
1660
|
required: false,
|
|
1559
|
-
type: [
|
|
1661
|
+
type: [import_mongoose20.default.Schema.Types.ObjectId]
|
|
1560
1662
|
},
|
|
1561
1663
|
partners: {
|
|
1562
1664
|
ref: "Partner",
|
|
1563
1665
|
required: false,
|
|
1564
|
-
type: [
|
|
1666
|
+
type: [import_mongoose20.default.Schema.Types.ObjectId]
|
|
1565
1667
|
},
|
|
1566
1668
|
vendors: {
|
|
1567
1669
|
ref: "Vendor",
|
|
1568
1670
|
required: false,
|
|
1569
|
-
type: [
|
|
1671
|
+
type: [import_mongoose20.default.Schema.Types.ObjectId]
|
|
1570
1672
|
}
|
|
1571
1673
|
},
|
|
1572
1674
|
{ _id: false }
|
|
1573
1675
|
);
|
|
1574
|
-
var stripeSchema = new
|
|
1676
|
+
var stripeSchema = new MongooseSchema16(
|
|
1575
1677
|
{
|
|
1576
1678
|
billingPeriod: {
|
|
1577
|
-
enum: Object.values(
|
|
1679
|
+
enum: Object.values(import_cluemart_shared16.EnumBillingPeriod),
|
|
1578
1680
|
required: false,
|
|
1579
1681
|
type: String
|
|
1580
1682
|
},
|
|
@@ -1583,7 +1685,7 @@ var stripeSchema = new MongooseSchema14(
|
|
|
1583
1685
|
type: Boolean
|
|
1584
1686
|
},
|
|
1585
1687
|
currentPlan: {
|
|
1586
|
-
enum: Object.values(
|
|
1688
|
+
enum: Object.values(import_cluemart_shared16.EnumUserLicence),
|
|
1587
1689
|
required: false,
|
|
1588
1690
|
type: String
|
|
1589
1691
|
},
|
|
@@ -1608,7 +1710,7 @@ var stripeSchema = new MongooseSchema14(
|
|
|
1608
1710
|
type: String
|
|
1609
1711
|
},
|
|
1610
1712
|
pendingBillingPeriod: {
|
|
1611
|
-
enum: Object.values(
|
|
1713
|
+
enum: Object.values(import_cluemart_shared16.EnumBillingPeriod),
|
|
1612
1714
|
required: false,
|
|
1613
1715
|
type: String
|
|
1614
1716
|
},
|
|
@@ -1617,7 +1719,7 @@ var stripeSchema = new MongooseSchema14(
|
|
|
1617
1719
|
type: Date
|
|
1618
1720
|
},
|
|
1619
1721
|
pendingPlan: {
|
|
1620
|
-
enum: Object.values(
|
|
1722
|
+
enum: Object.values(import_cluemart_shared16.EnumUserLicence),
|
|
1621
1723
|
required: false,
|
|
1622
1724
|
type: String
|
|
1623
1725
|
},
|
|
@@ -1634,7 +1736,7 @@ var stripeSchema = new MongooseSchema14(
|
|
|
1634
1736
|
type: Date
|
|
1635
1737
|
},
|
|
1636
1738
|
status: {
|
|
1637
|
-
enum: Object.values(
|
|
1739
|
+
enum: Object.values(import_cluemart_shared16.EnumSubscriptionStatus),
|
|
1638
1740
|
required: false,
|
|
1639
1741
|
type: String
|
|
1640
1742
|
},
|
|
@@ -1653,10 +1755,10 @@ var stripeSchema = new MongooseSchema14(
|
|
|
1653
1755
|
},
|
|
1654
1756
|
{ _id: false }
|
|
1655
1757
|
);
|
|
1656
|
-
var redeemedRewardSchema = new
|
|
1758
|
+
var redeemedRewardSchema = new MongooseSchema16(
|
|
1657
1759
|
{
|
|
1658
1760
|
name: {
|
|
1659
|
-
enum: Object.values(
|
|
1761
|
+
enum: Object.values(import_cluemart_shared16.EnumReward),
|
|
1660
1762
|
required: true,
|
|
1661
1763
|
type: String
|
|
1662
1764
|
},
|
|
@@ -1665,12 +1767,12 @@ var redeemedRewardSchema = new MongooseSchema14(
|
|
|
1665
1767
|
},
|
|
1666
1768
|
{ _id: false }
|
|
1667
1769
|
);
|
|
1668
|
-
var userOverallPointsSchema = new
|
|
1770
|
+
var userOverallPointsSchema = new MongooseSchema16(
|
|
1669
1771
|
{
|
|
1670
1772
|
createdAt: { required: true, type: Date },
|
|
1671
1773
|
points: { default: 0, required: true, type: Number },
|
|
1672
1774
|
pointType: {
|
|
1673
|
-
enum: Object.values(
|
|
1775
|
+
enum: Object.values(import_cluemart_shared16.EnumPointType),
|
|
1674
1776
|
required: true,
|
|
1675
1777
|
type: String
|
|
1676
1778
|
},
|
|
@@ -1678,13 +1780,13 @@ var userOverallPointsSchema = new MongooseSchema14(
|
|
|
1678
1780
|
},
|
|
1679
1781
|
{ _id: false }
|
|
1680
1782
|
);
|
|
1681
|
-
var
|
|
1783
|
+
var schema15 = new MongooseSchema16(
|
|
1682
1784
|
{
|
|
1683
1785
|
active: { default: false, required: true, type: Boolean },
|
|
1684
1786
|
affiliate: {
|
|
1685
1787
|
ref: "Affiliate",
|
|
1686
1788
|
required: false,
|
|
1687
|
-
type:
|
|
1789
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1688
1790
|
},
|
|
1689
1791
|
avatar: {
|
|
1690
1792
|
required: false,
|
|
@@ -1693,28 +1795,28 @@ var schema13 = new MongooseSchema14(
|
|
|
1693
1795
|
coupon: {
|
|
1694
1796
|
ref: "Coupon",
|
|
1695
1797
|
required: false,
|
|
1696
|
-
type:
|
|
1798
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1697
1799
|
},
|
|
1698
1800
|
deletedAt: { default: null, required: false, type: Date },
|
|
1699
1801
|
email: { required: true, type: String },
|
|
1700
1802
|
emailSentFor: {
|
|
1701
|
-
enum: Object.values(
|
|
1803
|
+
enum: Object.values(import_cluemart_shared16.EnumNotificationResourceType),
|
|
1702
1804
|
required: false,
|
|
1703
1805
|
type: [String]
|
|
1704
1806
|
},
|
|
1705
1807
|
events: {
|
|
1706
1808
|
ref: "Event",
|
|
1707
1809
|
required: false,
|
|
1708
|
-
type: [
|
|
1810
|
+
type: [import_mongoose20.default.Schema.Types.ObjectId]
|
|
1709
1811
|
},
|
|
1710
1812
|
firstName: { required: true, type: String },
|
|
1711
1813
|
game: {
|
|
1712
1814
|
ref: "Game",
|
|
1713
1815
|
required: false,
|
|
1714
|
-
type:
|
|
1816
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1715
1817
|
},
|
|
1716
1818
|
interests: {
|
|
1717
|
-
enum: Object.values(
|
|
1819
|
+
enum: Object.values(import_cluemart_shared16.EnumResourceType),
|
|
1718
1820
|
required: false,
|
|
1719
1821
|
type: [String]
|
|
1720
1822
|
},
|
|
@@ -1737,11 +1839,11 @@ var schema13 = new MongooseSchema14(
|
|
|
1737
1839
|
partner: {
|
|
1738
1840
|
ref: "Partner",
|
|
1739
1841
|
required: false,
|
|
1740
|
-
type:
|
|
1842
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1741
1843
|
},
|
|
1742
1844
|
password: { required: true, type: String },
|
|
1743
1845
|
platform: {
|
|
1744
|
-
enum: Object.values(
|
|
1846
|
+
enum: Object.values(import_cluemart_shared16.EnumOSPlatform),
|
|
1745
1847
|
required: false,
|
|
1746
1848
|
type: String
|
|
1747
1849
|
},
|
|
@@ -1770,15 +1872,15 @@ var schema13 = new MongooseSchema14(
|
|
|
1770
1872
|
type: String
|
|
1771
1873
|
},
|
|
1772
1874
|
roles: {
|
|
1773
|
-
default: [
|
|
1774
|
-
enum: Object.values(
|
|
1875
|
+
default: [import_cluemart_shared16.EnumUserRole.CUSTOMER],
|
|
1876
|
+
enum: Object.values(import_cluemart_shared16.EnumUserRole),
|
|
1775
1877
|
required: true,
|
|
1776
1878
|
type: [String]
|
|
1777
1879
|
},
|
|
1778
1880
|
school: {
|
|
1779
1881
|
ref: "School",
|
|
1780
1882
|
required: false,
|
|
1781
|
-
type:
|
|
1883
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1782
1884
|
},
|
|
1783
1885
|
stripe: {
|
|
1784
1886
|
required: false,
|
|
@@ -1803,21 +1905,21 @@ var schema13 = new MongooseSchema14(
|
|
|
1803
1905
|
vendor: {
|
|
1804
1906
|
ref: "Vendor",
|
|
1805
1907
|
required: false,
|
|
1806
|
-
type:
|
|
1908
|
+
type: import_mongoose20.default.Schema.Types.ObjectId
|
|
1807
1909
|
}
|
|
1808
1910
|
},
|
|
1809
1911
|
{ strict: false, timestamps: true }
|
|
1810
1912
|
);
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
var UserModel =
|
|
1913
|
+
schema15.index({ "licences.expiryDate": 1 });
|
|
1914
|
+
schema15.index({ "licences.licenceType": 1 });
|
|
1915
|
+
schema15.index({ promoCodes: 1, active: 1, deletedAt: 1 });
|
|
1916
|
+
schema15.index({ email: "text", firstName: "text", lastName: "text" });
|
|
1917
|
+
var UserModel = import_mongoose20.default.models.User || import_mongoose20.default.model("User", schema15);
|
|
1816
1918
|
|
|
1817
1919
|
// src/mongoose/VerificationToken.ts
|
|
1818
|
-
var
|
|
1819
|
-
var
|
|
1820
|
-
var
|
|
1920
|
+
var import_mongoose21 = __toESM(require("mongoose"));
|
|
1921
|
+
var MongooseSchema17 = import_mongoose21.default.Schema;
|
|
1922
|
+
var schema16 = new MongooseSchema17(
|
|
1821
1923
|
{
|
|
1822
1924
|
createdAt: {
|
|
1823
1925
|
default: Date.now,
|
|
@@ -1832,13 +1934,13 @@ var schema14 = new MongooseSchema15(
|
|
|
1832
1934
|
},
|
|
1833
1935
|
{ timestamps: true }
|
|
1834
1936
|
);
|
|
1835
|
-
var VerificationTokenModel =
|
|
1937
|
+
var VerificationTokenModel = import_mongoose21.default.models.VerificationToken || import_mongoose21.default.model("VerificationToken", schema16);
|
|
1836
1938
|
|
|
1837
1939
|
// src/mongoose/vendor/Vendor.ts
|
|
1838
|
-
var
|
|
1839
|
-
var
|
|
1840
|
-
var
|
|
1841
|
-
var vendorProductTypeSchema = new
|
|
1940
|
+
var import_cluemart_shared17 = require("@timardex/cluemart-shared");
|
|
1941
|
+
var import_mongoose22 = __toESM(require("mongoose"));
|
|
1942
|
+
var MongooseSchema18 = import_mongoose22.default.Schema;
|
|
1943
|
+
var vendorProductTypeSchema = new MongooseSchema18(
|
|
1842
1944
|
{
|
|
1843
1945
|
description: { required: false, type: String },
|
|
1844
1946
|
name: { required: true, type: String },
|
|
@@ -1849,18 +1951,18 @@ var vendorProductTypeSchema = new MongooseSchema16(
|
|
|
1849
1951
|
},
|
|
1850
1952
|
{ timestamps: true }
|
|
1851
1953
|
);
|
|
1852
|
-
var productWrapperSchema = new
|
|
1954
|
+
var productWrapperSchema = new MongooseSchema18(
|
|
1853
1955
|
{
|
|
1854
1956
|
active: { default: false, required: false, type: Boolean },
|
|
1855
1957
|
productsList: { required: false, type: [vendorProductTypeSchema] }
|
|
1856
1958
|
},
|
|
1857
1959
|
{ _id: false }
|
|
1858
1960
|
);
|
|
1859
|
-
var calendarSchema = new
|
|
1961
|
+
var calendarSchema = new MongooseSchema18(
|
|
1860
1962
|
{
|
|
1861
1963
|
dateTime: {
|
|
1862
1964
|
dateStatus: {
|
|
1863
|
-
enum: Object.values(
|
|
1965
|
+
enum: Object.values(import_cluemart_shared17.EnumEventDateStatus),
|
|
1864
1966
|
required: false,
|
|
1865
1967
|
type: String
|
|
1866
1968
|
},
|
|
@@ -1877,14 +1979,14 @@ var calendarSchema = new MongooseSchema16(
|
|
|
1877
1979
|
},
|
|
1878
1980
|
{ _id: false }
|
|
1879
1981
|
);
|
|
1880
|
-
var calendarWrapperSchema = new
|
|
1982
|
+
var calendarWrapperSchema = new MongooseSchema18(
|
|
1881
1983
|
{
|
|
1882
1984
|
active: { default: false, required: true, type: Boolean },
|
|
1883
1985
|
calendarData: { required: false, type: [calendarSchema] }
|
|
1884
1986
|
},
|
|
1885
1987
|
{ _id: false }
|
|
1886
1988
|
);
|
|
1887
|
-
var vendorAvailabilitySchema = new
|
|
1989
|
+
var vendorAvailabilitySchema = new MongooseSchema18(
|
|
1888
1990
|
{
|
|
1889
1991
|
corporate: { default: false, required: false, type: Boolean },
|
|
1890
1992
|
private: { default: false, required: false, type: Boolean },
|
|
@@ -1892,7 +1994,7 @@ var vendorAvailabilitySchema = new MongooseSchema16(
|
|
|
1892
1994
|
},
|
|
1893
1995
|
{ _id: false }
|
|
1894
1996
|
);
|
|
1895
|
-
var downgradeSnapshotSchema = new
|
|
1997
|
+
var downgradeSnapshotSchema = new MongooseSchema18(
|
|
1896
1998
|
{
|
|
1897
1999
|
availability: { required: false, type: vendorAvailabilitySchema },
|
|
1898
2000
|
calendarActive: { required: false, type: Boolean },
|
|
@@ -1900,7 +2002,7 @@ var downgradeSnapshotSchema = new MongooseSchema16(
|
|
|
1900
2002
|
},
|
|
1901
2003
|
{ _id: false }
|
|
1902
2004
|
);
|
|
1903
|
-
var
|
|
2005
|
+
var schema17 = new MongooseSchema18(
|
|
1904
2006
|
{
|
|
1905
2007
|
...baseResourceFields,
|
|
1906
2008
|
// Importing base resource fields from global.ts
|
|
@@ -1919,47 +2021,47 @@ var schema15 = new MongooseSchema16(
|
|
|
1919
2021
|
unregisteredVendorId: {
|
|
1920
2022
|
ref: "UnregisteredVendor",
|
|
1921
2023
|
required: false,
|
|
1922
|
-
type:
|
|
2024
|
+
type: import_mongoose22.default.Schema.Types.ObjectId
|
|
1923
2025
|
},
|
|
1924
2026
|
vendorInfoId: {
|
|
1925
2027
|
ref: "VendorInfo",
|
|
1926
2028
|
required: false,
|
|
1927
|
-
type:
|
|
2029
|
+
type: import_mongoose22.default.Schema.Types.ObjectId
|
|
1928
2030
|
},
|
|
1929
2031
|
vendorType: {
|
|
1930
|
-
enum: Object.values(
|
|
2032
|
+
enum: Object.values(import_cluemart_shared17.EnumVendorType),
|
|
1931
2033
|
required: true,
|
|
1932
2034
|
type: String
|
|
1933
2035
|
}
|
|
1934
2036
|
},
|
|
1935
2037
|
{ timestamps: true }
|
|
1936
2038
|
);
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2039
|
+
schema17.index({ name: 1 });
|
|
2040
|
+
schema17.index({ description: 1 });
|
|
2041
|
+
schema17.index({ region: 1 });
|
|
2042
|
+
schema17.index({ "categories.name": 1 });
|
|
2043
|
+
schema17.index({ slug: 1 });
|
|
2044
|
+
schema17.index({
|
|
1943
2045
|
categoriesNames: "text",
|
|
1944
2046
|
description: "text",
|
|
1945
2047
|
name: "text"
|
|
1946
2048
|
});
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
var VendorModel =
|
|
2049
|
+
schema17.index({ deletedAt: 1, "owner.userId": 1 });
|
|
2050
|
+
schema17.plugin(searchNamePlugin);
|
|
2051
|
+
var VendorModel = import_mongoose22.default.models.Vendor || import_mongoose22.default.model("Vendor", schema17);
|
|
1950
2052
|
|
|
1951
2053
|
// src/mongoose/vendor/VendorInfo.ts
|
|
1952
|
-
var
|
|
1953
|
-
var
|
|
1954
|
-
var
|
|
1955
|
-
var AttributesSchema = new
|
|
2054
|
+
var import_cluemart_shared18 = require("@timardex/cluemart-shared");
|
|
2055
|
+
var import_mongoose23 = __toESM(require("mongoose"));
|
|
2056
|
+
var MongooseSchema19 = import_mongoose23.default.Schema;
|
|
2057
|
+
var AttributesSchema = new MongooseSchema19(
|
|
1956
2058
|
{
|
|
1957
2059
|
details: { required: false, type: String },
|
|
1958
2060
|
isRequired: { default: false, required: true, type: Boolean }
|
|
1959
2061
|
},
|
|
1960
2062
|
{ _id: false }
|
|
1961
2063
|
);
|
|
1962
|
-
var
|
|
2064
|
+
var schema18 = new MongooseSchema19(
|
|
1963
2065
|
{
|
|
1964
2066
|
active: { default: true, type: Boolean },
|
|
1965
2067
|
compliance: {
|
|
@@ -1969,7 +2071,7 @@ var schema16 = new MongooseSchema17(
|
|
|
1969
2071
|
documents: [ResourceImageTypeSchema],
|
|
1970
2072
|
product: {
|
|
1971
2073
|
foodFlavors: {
|
|
1972
|
-
enum: Object.values(
|
|
2074
|
+
enum: Object.values(import_cluemart_shared18.EnumFoodFlavor),
|
|
1973
2075
|
required: true,
|
|
1974
2076
|
type: [String]
|
|
1975
2077
|
},
|
|
@@ -1994,29 +2096,29 @@ var schema16 = new MongooseSchema17(
|
|
|
1994
2096
|
vendorId: {
|
|
1995
2097
|
ref: "Vendor",
|
|
1996
2098
|
required: true,
|
|
1997
|
-
type:
|
|
2099
|
+
type: import_mongoose23.default.Schema.Types.ObjectId
|
|
1998
2100
|
}
|
|
1999
2101
|
},
|
|
2000
2102
|
{ timestamps: true }
|
|
2001
2103
|
);
|
|
2002
|
-
|
|
2003
|
-
var VendorInfoModel =
|
|
2104
|
+
schema18.index({ vendorId: 1 });
|
|
2105
|
+
var VendorInfoModel = import_mongoose23.default.models.VendorInfo || import_mongoose23.default.model("VendorInfo", schema18);
|
|
2004
2106
|
|
|
2005
2107
|
// src/mongoose/vendor/UnregisteredVendor.ts
|
|
2006
|
-
var
|
|
2007
|
-
var
|
|
2008
|
-
var invitationSchema = new
|
|
2108
|
+
var import_mongoose24 = __toESM(require("mongoose"));
|
|
2109
|
+
var MongooseSchema20 = import_mongoose24.default.Schema;
|
|
2110
|
+
var invitationSchema = new MongooseSchema20(
|
|
2009
2111
|
{
|
|
2010
2112
|
dateTime: { required: true, type: [dateTimeSchema] },
|
|
2011
2113
|
inviterId: {
|
|
2012
2114
|
ref: "Event",
|
|
2013
2115
|
required: true,
|
|
2014
|
-
type:
|
|
2116
|
+
type: import_mongoose24.default.Schema.Types.ObjectId
|
|
2015
2117
|
}
|
|
2016
2118
|
},
|
|
2017
2119
|
{ _id: false }
|
|
2018
2120
|
);
|
|
2019
|
-
var
|
|
2121
|
+
var schema19 = new MongooseSchema20(
|
|
2020
2122
|
{
|
|
2021
2123
|
active: { default: true, required: true, type: Boolean },
|
|
2022
2124
|
categoryIds: { required: true, type: [String] },
|
|
@@ -2025,7 +2127,7 @@ var schema17 = new MongooseSchema18(
|
|
|
2025
2127
|
claimedByUserId: {
|
|
2026
2128
|
ref: "User",
|
|
2027
2129
|
required: false,
|
|
2028
|
-
type:
|
|
2130
|
+
type: import_mongoose24.default.Schema.Types.ObjectId
|
|
2029
2131
|
},
|
|
2030
2132
|
claimInitiatedAt: { default: null, required: false, type: Date },
|
|
2031
2133
|
claimToken: { default: null, required: false, type: String },
|
|
@@ -2038,15 +2140,15 @@ var schema17 = new MongooseSchema18(
|
|
|
2038
2140
|
},
|
|
2039
2141
|
{ timestamps: true }
|
|
2040
2142
|
);
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
var UnregisteredVendorModel =
|
|
2143
|
+
schema19.index({ name: 1 });
|
|
2144
|
+
schema19.index({ email: 1 });
|
|
2145
|
+
var UnregisteredVendorModel = import_mongoose24.default.models.UnregisteredVendor || import_mongoose24.default.model("UnregisteredVendor", schema19);
|
|
2044
2146
|
|
|
2045
2147
|
// src/mongoose/event/Event.ts
|
|
2046
|
-
var
|
|
2047
|
-
var
|
|
2048
|
-
var
|
|
2049
|
-
var
|
|
2148
|
+
var import_cluemart_shared19 = require("@timardex/cluemart-shared");
|
|
2149
|
+
var import_mongoose25 = __toESM(require("mongoose"));
|
|
2150
|
+
var MongooseSchema21 = import_mongoose25.default.Schema;
|
|
2151
|
+
var schema20 = new MongooseSchema21(
|
|
2050
2152
|
{
|
|
2051
2153
|
...baseResourceFields,
|
|
2052
2154
|
// Importing base resource fields from global.ts
|
|
@@ -2055,10 +2157,10 @@ var schema18 = new MongooseSchema19(
|
|
|
2055
2157
|
eventInfoId: {
|
|
2056
2158
|
ref: "EventInfo",
|
|
2057
2159
|
required: false,
|
|
2058
|
-
type:
|
|
2160
|
+
type: import_mongoose25.default.Schema.Types.ObjectId
|
|
2059
2161
|
},
|
|
2060
2162
|
eventType: {
|
|
2061
|
-
enum: Object.values(
|
|
2163
|
+
enum: Object.values(import_cluemart_shared19.EnumEventType),
|
|
2062
2164
|
required: true,
|
|
2063
2165
|
type: String
|
|
2064
2166
|
},
|
|
@@ -2079,40 +2181,40 @@ var schema18 = new MongooseSchema19(
|
|
|
2079
2181
|
},
|
|
2080
2182
|
{ timestamps: true }
|
|
2081
2183
|
);
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
var EventModel =
|
|
2184
|
+
schema20.index({ name: 1 });
|
|
2185
|
+
schema20.index({ description: 1 });
|
|
2186
|
+
schema20.index({ region: 1 });
|
|
2187
|
+
schema20.index({ "location.geo": "2dsphere" });
|
|
2188
|
+
schema20.index({ tags: 1 });
|
|
2189
|
+
schema20.index({ deletedAt: 1 });
|
|
2190
|
+
schema20.index({ "dateTime.dateStatus": 1 });
|
|
2191
|
+
schema20.index({ slug: 1 });
|
|
2192
|
+
schema20.index({ description: "text", name: "text", tags: "text" });
|
|
2193
|
+
schema20.index({ deletedAt: 1, "owner.userId": 1 });
|
|
2194
|
+
schema20.plugin(searchNamePlugin);
|
|
2195
|
+
var EventModel = import_mongoose25.default.models.Event || import_mongoose25.default.model("Event", schema20);
|
|
2094
2196
|
|
|
2095
2197
|
// src/mongoose/event/EventDateArchive.ts
|
|
2096
|
-
var
|
|
2097
|
-
var
|
|
2198
|
+
var import_mongoose26 = __toESM(require("mongoose"));
|
|
2199
|
+
var schema21 = new import_mongoose26.default.Schema(
|
|
2098
2200
|
{
|
|
2099
2201
|
dateTime: { required: true, type: [dateTimeSchema] },
|
|
2100
2202
|
eventId: {
|
|
2101
2203
|
ref: "Event",
|
|
2102
2204
|
required: true,
|
|
2103
|
-
type:
|
|
2205
|
+
type: import_mongoose26.default.Schema.Types.ObjectId
|
|
2104
2206
|
}
|
|
2105
2207
|
},
|
|
2106
2208
|
{ timestamps: true }
|
|
2107
2209
|
);
|
|
2108
|
-
|
|
2109
|
-
var EventDateArchiveModel =
|
|
2210
|
+
schema21.index({ eventId: 1 }, { unique: true });
|
|
2211
|
+
var EventDateArchiveModel = import_mongoose26.default.models.EventDateArchive || import_mongoose26.default.model("EventDateArchive", schema21);
|
|
2110
2212
|
|
|
2111
2213
|
// src/mongoose/Partner.ts
|
|
2112
|
-
var
|
|
2113
|
-
var
|
|
2114
|
-
var
|
|
2115
|
-
var
|
|
2214
|
+
var import_cluemart_shared20 = require("@timardex/cluemart-shared");
|
|
2215
|
+
var import_mongoose27 = __toESM(require("mongoose"));
|
|
2216
|
+
var MongooseSchema22 = import_mongoose27.default.Schema;
|
|
2217
|
+
var schema22 = new MongooseSchema22(
|
|
2116
2218
|
{
|
|
2117
2219
|
...baseResourceFields,
|
|
2118
2220
|
location: {
|
|
@@ -2121,53 +2223,53 @@ var schema20 = new MongooseSchema20(
|
|
|
2121
2223
|
},
|
|
2122
2224
|
nzbn: { required: true, type: String },
|
|
2123
2225
|
partnerType: {
|
|
2124
|
-
enum: Object.values(
|
|
2226
|
+
enum: Object.values(import_cluemart_shared20.EnumPartnerType),
|
|
2125
2227
|
required: true,
|
|
2126
2228
|
type: String
|
|
2127
2229
|
}
|
|
2128
2230
|
},
|
|
2129
2231
|
{ timestamps: true }
|
|
2130
2232
|
);
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
var PartnerModel =
|
|
2233
|
+
schema22.index({ name: 1 });
|
|
2234
|
+
schema22.index({ description: 1 });
|
|
2235
|
+
schema22.index({ region: 1 });
|
|
2236
|
+
schema22.index({ "location.geo": "2dsphere" });
|
|
2237
|
+
schema22.index({ slug: 1 });
|
|
2238
|
+
schema22.index({ name: "text", description: "text" });
|
|
2239
|
+
schema22.index({ "owner.userId": 1, deletedAt: 1 });
|
|
2240
|
+
schema22.plugin(searchNamePlugin);
|
|
2241
|
+
var PartnerModel = import_mongoose27.default.models.Partner || import_mongoose27.default.model("Partner", schema22);
|
|
2140
2242
|
|
|
2141
2243
|
// src/mongoose/Post.ts
|
|
2142
|
-
var
|
|
2143
|
-
var
|
|
2144
|
-
var
|
|
2145
|
-
var contentSchema = new
|
|
2244
|
+
var import_cluemart_shared21 = require("@timardex/cluemart-shared");
|
|
2245
|
+
var import_mongoose28 = __toESM(require("mongoose"));
|
|
2246
|
+
var MongooseSchema23 = import_mongoose28.default.Schema;
|
|
2247
|
+
var contentSchema = new MongooseSchema23(
|
|
2146
2248
|
{
|
|
2147
|
-
contentData:
|
|
2249
|
+
contentData: import_mongoose28.Schema.Types.Mixed,
|
|
2148
2250
|
contentOrder: { required: true, type: Number },
|
|
2149
2251
|
contentType: {
|
|
2150
|
-
enum: Object.values(
|
|
2252
|
+
enum: Object.values(import_cluemart_shared21.EnumPostContentType),
|
|
2151
2253
|
required: true,
|
|
2152
2254
|
type: String
|
|
2153
2255
|
}
|
|
2154
2256
|
},
|
|
2155
2257
|
{ _id: false }
|
|
2156
2258
|
);
|
|
2157
|
-
var resourceSchema = new
|
|
2259
|
+
var resourceSchema = new MongooseSchema23(
|
|
2158
2260
|
{
|
|
2159
2261
|
resourceId: { required: true, type: String },
|
|
2160
2262
|
resourceRegion: { required: true, type: String },
|
|
2161
2263
|
resourceSlug: { required: true, type: String },
|
|
2162
2264
|
resourceType: {
|
|
2163
|
-
enum: Object.values(
|
|
2265
|
+
enum: Object.values(import_cluemart_shared21.EnumResourceType),
|
|
2164
2266
|
required: true,
|
|
2165
2267
|
type: String
|
|
2166
2268
|
}
|
|
2167
2269
|
},
|
|
2168
2270
|
{ _id: false }
|
|
2169
2271
|
);
|
|
2170
|
-
var
|
|
2272
|
+
var schema23 = new MongooseSchema23(
|
|
2171
2273
|
{
|
|
2172
2274
|
active: { default: false, required: true, type: Boolean },
|
|
2173
2275
|
approvedAt: { default: null, required: false, type: Date },
|
|
@@ -2183,7 +2285,7 @@ var schema21 = new MongooseSchema21(
|
|
|
2183
2285
|
},
|
|
2184
2286
|
deletedAt: { default: null, required: false, type: Date },
|
|
2185
2287
|
postType: {
|
|
2186
|
-
enum: Object.values(
|
|
2288
|
+
enum: Object.values(import_cluemart_shared21.EnumPostType),
|
|
2187
2289
|
required: true,
|
|
2188
2290
|
type: String
|
|
2189
2291
|
},
|
|
@@ -2198,16 +2300,16 @@ var schema21 = new MongooseSchema21(
|
|
|
2198
2300
|
},
|
|
2199
2301
|
{ timestamps: true }
|
|
2200
2302
|
);
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
var PostModel =
|
|
2303
|
+
schema23.index({ title: 1 });
|
|
2304
|
+
schema23.index({ tags: 1 });
|
|
2305
|
+
schema23.index({ postType: 1, slug: 1 }, { unique: true });
|
|
2306
|
+
var PostModel = import_mongoose28.default.models.Post || import_mongoose28.default.model("Post", schema23);
|
|
2205
2307
|
|
|
2206
2308
|
// src/mongoose/AppSetting.ts
|
|
2207
|
-
var
|
|
2208
|
-
var
|
|
2309
|
+
var import_mongoose29 = __toESM(require("mongoose"));
|
|
2310
|
+
var MongooseSchema24 = import_mongoose29.default.Schema;
|
|
2209
2311
|
var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
|
|
2210
|
-
var AppSettingSchema = new
|
|
2312
|
+
var AppSettingSchema = new MongooseSchema24(
|
|
2211
2313
|
{
|
|
2212
2314
|
activeSchoolsStudentCountTotal: {
|
|
2213
2315
|
default: 0,
|
|
@@ -2229,8 +2331,8 @@ var AppSettingSchema = new MongooseSchema22(
|
|
|
2229
2331
|
validate: Number.isInteger
|
|
2230
2332
|
},
|
|
2231
2333
|
mobileDisplayEnabled: { default: false, required: true, type: Boolean },
|
|
2232
|
-
purchasePricing: { type:
|
|
2233
|
-
regionPricing: { type:
|
|
2334
|
+
purchasePricing: { type: MongooseSchema24.Types.Mixed },
|
|
2335
|
+
regionPricing: { type: MongooseSchema24.Types.Mixed },
|
|
2234
2336
|
paidSlotsPerPlacement: { enum: [30], type: Number },
|
|
2235
2337
|
reservedSlotsPerPlacement: { enum: [7], type: Number },
|
|
2236
2338
|
rotationSeconds: { enum: [8], type: Number },
|
|
@@ -2255,12 +2357,12 @@ var AppSettingSchema = new MongooseSchema22(
|
|
|
2255
2357
|
},
|
|
2256
2358
|
{ timestamps: true }
|
|
2257
2359
|
);
|
|
2258
|
-
var AppSettingModel =
|
|
2360
|
+
var AppSettingModel = import_mongoose29.default.models.AppSetting || import_mongoose29.default.model("AppSetting", AppSettingSchema);
|
|
2259
2361
|
|
|
2260
2362
|
// src/mongoose/AuthHandoffToken.ts
|
|
2261
|
-
var
|
|
2262
|
-
var
|
|
2263
|
-
var
|
|
2363
|
+
var import_mongoose30 = __toESM(require("mongoose"));
|
|
2364
|
+
var MongooseSchema25 = import_mongoose30.default.Schema;
|
|
2365
|
+
var schema24 = new MongooseSchema25(
|
|
2264
2366
|
{
|
|
2265
2367
|
expiresAt: { required: true, type: Date },
|
|
2266
2368
|
jti: { index: true, required: true, type: String, unique: true },
|
|
@@ -2269,25 +2371,25 @@ var schema22 = new MongooseSchema23(
|
|
|
2269
2371
|
index: true,
|
|
2270
2372
|
ref: "User",
|
|
2271
2373
|
required: true,
|
|
2272
|
-
type:
|
|
2374
|
+
type: import_mongoose30.default.Schema.Types.ObjectId
|
|
2273
2375
|
}
|
|
2274
2376
|
},
|
|
2275
2377
|
{ timestamps: true }
|
|
2276
2378
|
);
|
|
2277
|
-
|
|
2278
|
-
var AuthHandoffTokenModel =
|
|
2379
|
+
schema24.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
|
2380
|
+
var AuthHandoffTokenModel = import_mongoose30.default.models.AuthHandoffToken || import_mongoose30.default.model("AuthHandoffToken", schema24);
|
|
2279
2381
|
|
|
2280
2382
|
// src/mongoose/game/Game.ts
|
|
2281
|
-
var
|
|
2282
|
-
var
|
|
2383
|
+
var import_cluemart_shared22 = require("@timardex/cluemart-shared");
|
|
2384
|
+
var import_mongoose34 = __toESM(require("mongoose"));
|
|
2283
2385
|
|
|
2284
2386
|
// src/mongoose/game/DailyClue.ts
|
|
2285
|
-
var
|
|
2387
|
+
var import_mongoose32 = __toESM(require("mongoose"));
|
|
2286
2388
|
|
|
2287
2389
|
// src/mongoose/game/utils.ts
|
|
2288
|
-
var
|
|
2289
|
-
var
|
|
2290
|
-
var schemaGameDate = new
|
|
2390
|
+
var import_mongoose31 = __toESM(require("mongoose"));
|
|
2391
|
+
var MongooseSchema26 = import_mongoose31.default.Schema;
|
|
2392
|
+
var schemaGameDate = new MongooseSchema26(
|
|
2291
2393
|
{
|
|
2292
2394
|
endDate: { required: true, type: Date },
|
|
2293
2395
|
startDate: { required: true, type: Date }
|
|
@@ -2296,8 +2398,8 @@ var schemaGameDate = new MongooseSchema24(
|
|
|
2296
2398
|
);
|
|
2297
2399
|
|
|
2298
2400
|
// src/mongoose/game/DailyClue.ts
|
|
2299
|
-
var
|
|
2300
|
-
var schemaLetters = new
|
|
2401
|
+
var MongooseSchema27 = import_mongoose32.default.Schema;
|
|
2402
|
+
var schemaLetters = new MongooseSchema27(
|
|
2301
2403
|
{
|
|
2302
2404
|
collected: { required: false, type: [String] },
|
|
2303
2405
|
solutionShuffled: { required: true, type: [String] }
|
|
@@ -2305,14 +2407,14 @@ var schemaLetters = new MongooseSchema25(
|
|
|
2305
2407
|
},
|
|
2306
2408
|
{ _id: false }
|
|
2307
2409
|
);
|
|
2308
|
-
var schemaDailyClueBaseGame = new
|
|
2410
|
+
var schemaDailyClueBaseGame = new MongooseSchema27(
|
|
2309
2411
|
{
|
|
2310
2412
|
gameDate: { required: true, type: schemaGameDate },
|
|
2311
2413
|
gameSolution: { required: true, type: String }
|
|
2312
2414
|
},
|
|
2313
2415
|
{ _id: false }
|
|
2314
2416
|
);
|
|
2315
|
-
var schemaDailyClueGameData = new
|
|
2417
|
+
var schemaDailyClueGameData = new MongooseSchema27(
|
|
2316
2418
|
{
|
|
2317
2419
|
gameFields: { required: true, type: schemaDailyClueBaseGame },
|
|
2318
2420
|
lastFoundDate: { default: null, required: false, type: Date },
|
|
@@ -2327,9 +2429,9 @@ var schemaDailyClueGameData = new MongooseSchema25(
|
|
|
2327
2429
|
);
|
|
2328
2430
|
|
|
2329
2431
|
// src/mongoose/game/PuzzleGame.ts
|
|
2330
|
-
var
|
|
2331
|
-
var
|
|
2332
|
-
var schemaPuzzleAnswer = new
|
|
2432
|
+
var import_mongoose33 = __toESM(require("mongoose"));
|
|
2433
|
+
var MongooseSchema28 = import_mongoose33.default.Schema;
|
|
2434
|
+
var schemaPuzzleAnswer = new MongooseSchema28(
|
|
2333
2435
|
{
|
|
2334
2436
|
answer: { required: true, type: String },
|
|
2335
2437
|
answerId: { required: true, type: String },
|
|
@@ -2337,7 +2439,7 @@ var schemaPuzzleAnswer = new MongooseSchema26(
|
|
|
2337
2439
|
},
|
|
2338
2440
|
{ _id: false }
|
|
2339
2441
|
);
|
|
2340
|
-
var schemaPuzzleQuestion = new
|
|
2442
|
+
var schemaPuzzleQuestion = new MongooseSchema28(
|
|
2341
2443
|
{
|
|
2342
2444
|
answers: { required: true, type: [schemaPuzzleAnswer] },
|
|
2343
2445
|
question: { required: true, type: String },
|
|
@@ -2345,20 +2447,20 @@ var schemaPuzzleQuestion = new MongooseSchema26(
|
|
|
2345
2447
|
},
|
|
2346
2448
|
{ _id: false }
|
|
2347
2449
|
);
|
|
2348
|
-
var schemaPuzzleBaseGame = new
|
|
2450
|
+
var schemaPuzzleBaseGame = new MongooseSchema28(
|
|
2349
2451
|
{
|
|
2350
2452
|
questions: { required: true, type: [schemaPuzzleQuestion] }
|
|
2351
2453
|
},
|
|
2352
2454
|
{ _id: false }
|
|
2353
2455
|
);
|
|
2354
|
-
var schemaPuzzleAnsweredQuestion = new
|
|
2456
|
+
var schemaPuzzleAnsweredQuestion = new MongooseSchema28(
|
|
2355
2457
|
{
|
|
2356
2458
|
questionId: { required: true, type: String },
|
|
2357
2459
|
selectedAnswerId: { required: true, type: String }
|
|
2358
2460
|
},
|
|
2359
2461
|
{ _id: false }
|
|
2360
2462
|
);
|
|
2361
|
-
var schemaPuzzleGameData = new
|
|
2463
|
+
var schemaPuzzleGameData = new MongooseSchema28(
|
|
2362
2464
|
{
|
|
2363
2465
|
answeredQuestions: {
|
|
2364
2466
|
default: null,
|
|
@@ -2373,30 +2475,30 @@ var schemaPuzzleGameData = new MongooseSchema26(
|
|
|
2373
2475
|
);
|
|
2374
2476
|
|
|
2375
2477
|
// src/mongoose/game/Game.ts
|
|
2376
|
-
var
|
|
2478
|
+
var MongooseSchema29 = import_mongoose34.default.Schema;
|
|
2377
2479
|
var gameDataSchemas = {
|
|
2378
|
-
[
|
|
2379
|
-
[
|
|
2380
|
-
[
|
|
2480
|
+
[import_cluemart_shared22.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
|
|
2481
|
+
[import_cluemart_shared22.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
|
|
2482
|
+
[import_cluemart_shared22.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
|
|
2381
2483
|
};
|
|
2382
2484
|
var gameDataDefinition = Object.fromEntries(
|
|
2383
|
-
Object.entries(gameDataSchemas).map(([key,
|
|
2485
|
+
Object.entries(gameDataSchemas).map(([key, schema29]) => [
|
|
2384
2486
|
key,
|
|
2385
|
-
{ default: null, required: false, type:
|
|
2487
|
+
{ default: null, required: false, type: schema29 }
|
|
2386
2488
|
])
|
|
2387
2489
|
);
|
|
2388
|
-
var gameHistorySchema = new
|
|
2490
|
+
var gameHistorySchema = new MongooseSchema29(
|
|
2389
2491
|
{
|
|
2390
2492
|
createdAt: { required: true, type: Date },
|
|
2391
2493
|
gameDate: { required: true, type: schemaGameDate },
|
|
2392
2494
|
gameStatus: {
|
|
2393
|
-
enum: Object.values(
|
|
2495
|
+
enum: Object.values(import_cluemart_shared22.EnumGameStatus),
|
|
2394
2496
|
required: true,
|
|
2395
2497
|
type: String
|
|
2396
2498
|
},
|
|
2397
2499
|
gameTitle: { required: true, type: String },
|
|
2398
2500
|
gameType: {
|
|
2399
|
-
enum: Object.values(
|
|
2501
|
+
enum: Object.values(import_cluemart_shared22.EnumGameType),
|
|
2400
2502
|
required: true,
|
|
2401
2503
|
type: String
|
|
2402
2504
|
},
|
|
@@ -2405,14 +2507,14 @@ var gameHistorySchema = new MongooseSchema27(
|
|
|
2405
2507
|
},
|
|
2406
2508
|
{ _id: false }
|
|
2407
2509
|
);
|
|
2408
|
-
var gameTypeSchema = new
|
|
2510
|
+
var gameTypeSchema = new MongooseSchema29(
|
|
2409
2511
|
{
|
|
2410
2512
|
active: { default: true, required: true, type: Boolean },
|
|
2411
2513
|
gameData: gameDataDefinition,
|
|
2412
2514
|
gameHistory: { default: [], required: true, type: [gameHistorySchema] },
|
|
2413
2515
|
gameTitle: { required: true, type: String },
|
|
2414
2516
|
gameType: {
|
|
2415
|
-
enum: Object.values(
|
|
2517
|
+
enum: Object.values(import_cluemart_shared22.EnumGameType),
|
|
2416
2518
|
required: true,
|
|
2417
2519
|
type: String
|
|
2418
2520
|
},
|
|
@@ -2423,7 +2525,7 @@ var gameTypeSchema = new MongooseSchema27(
|
|
|
2423
2525
|
},
|
|
2424
2526
|
{ timestamps: true }
|
|
2425
2527
|
);
|
|
2426
|
-
var
|
|
2528
|
+
var schema25 = new MongooseSchema29(
|
|
2427
2529
|
{
|
|
2428
2530
|
active: { default: false, required: true, type: Boolean },
|
|
2429
2531
|
deletedAt: { default: null, required: false, type: Date },
|
|
@@ -2436,12 +2538,12 @@ var schema23 = new MongooseSchema27(
|
|
|
2436
2538
|
},
|
|
2437
2539
|
{ timestamps: true }
|
|
2438
2540
|
);
|
|
2439
|
-
var GameModel =
|
|
2541
|
+
var GameModel = import_mongoose34.default.models.Game || import_mongoose34.default.model("Game", schema25);
|
|
2440
2542
|
|
|
2441
2543
|
// src/mongoose/School.ts
|
|
2442
|
-
var
|
|
2443
|
-
var
|
|
2444
|
-
var campaignsSchema = new
|
|
2544
|
+
var import_mongoose35 = __toESM(require("mongoose"));
|
|
2545
|
+
var MongooseSchema30 = import_mongoose35.default.Schema;
|
|
2546
|
+
var campaignsSchema = new MongooseSchema30(
|
|
2445
2547
|
{
|
|
2446
2548
|
endDate: { required: true, type: Date },
|
|
2447
2549
|
name: { required: true, type: String },
|
|
@@ -2449,7 +2551,7 @@ var campaignsSchema = new MongooseSchema28(
|
|
|
2449
2551
|
},
|
|
2450
2552
|
{ _id: false }
|
|
2451
2553
|
);
|
|
2452
|
-
var
|
|
2554
|
+
var schema26 = new MongooseSchema30(
|
|
2453
2555
|
{
|
|
2454
2556
|
// New schools are active by default
|
|
2455
2557
|
active: { default: false, required: true, type: Boolean },
|
|
@@ -2476,26 +2578,26 @@ var schema24 = new MongooseSchema28(
|
|
|
2476
2578
|
},
|
|
2477
2579
|
{ timestamps: true }
|
|
2478
2580
|
);
|
|
2479
|
-
|
|
2581
|
+
schema26.index(
|
|
2480
2582
|
{ schoolCode: 1 },
|
|
2481
2583
|
{
|
|
2482
2584
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
2483
2585
|
unique: true
|
|
2484
2586
|
}
|
|
2485
2587
|
);
|
|
2486
|
-
var SchoolModel =
|
|
2588
|
+
var SchoolModel = import_mongoose35.default.models.School || import_mongoose35.default.model("School", schema26);
|
|
2487
2589
|
|
|
2488
2590
|
// src/mongoose/Affiliate.ts
|
|
2489
|
-
var
|
|
2490
|
-
var
|
|
2491
|
-
var
|
|
2492
|
-
var affiliateRewardSchema = new
|
|
2591
|
+
var import_cluemart_shared23 = require("@timardex/cluemart-shared");
|
|
2592
|
+
var import_mongoose36 = __toESM(require("mongoose"));
|
|
2593
|
+
var MongooseSchema31 = import_mongoose36.default.Schema;
|
|
2594
|
+
var affiliateRewardSchema = new MongooseSchema31(
|
|
2493
2595
|
{
|
|
2494
2596
|
createdAt: { required: true, type: Date },
|
|
2495
2597
|
redeemedAt: { default: null, required: false, type: Date },
|
|
2496
2598
|
rewardDescription: { required: true, type: String },
|
|
2497
2599
|
rewardType: {
|
|
2498
|
-
enum: Object.values(
|
|
2600
|
+
enum: Object.values(import_cluemart_shared23.EnumAffiliateRewardType),
|
|
2499
2601
|
required: true,
|
|
2500
2602
|
type: String
|
|
2501
2603
|
},
|
|
@@ -2503,13 +2605,13 @@ var affiliateRewardSchema = new MongooseSchema29(
|
|
|
2503
2605
|
},
|
|
2504
2606
|
{ _id: false }
|
|
2505
2607
|
);
|
|
2506
|
-
var affiliateResourceSchema = new
|
|
2608
|
+
var affiliateResourceSchema = new MongooseSchema31(
|
|
2507
2609
|
{
|
|
2508
2610
|
resourceActive: { default: true, required: true, type: Boolean },
|
|
2509
2611
|
resourceDeletedAt: { default: null, required: false, type: Date },
|
|
2510
2612
|
resourceId: {
|
|
2511
2613
|
required: true,
|
|
2512
|
-
type:
|
|
2614
|
+
type: import_mongoose36.default.Schema.Types.ObjectId
|
|
2513
2615
|
},
|
|
2514
2616
|
resourceName: { required: true, type: String },
|
|
2515
2617
|
resourceOwner: {
|
|
@@ -2517,7 +2619,7 @@ var affiliateResourceSchema = new MongooseSchema29(
|
|
|
2517
2619
|
type: OwnerTypeSchema
|
|
2518
2620
|
},
|
|
2519
2621
|
resourceType: {
|
|
2520
|
-
enum: Object.values(
|
|
2622
|
+
enum: Object.values(import_cluemart_shared23.EnumResourceType),
|
|
2521
2623
|
required: true,
|
|
2522
2624
|
type: String
|
|
2523
2625
|
},
|
|
@@ -2529,20 +2631,20 @@ var affiliateResourceSchema = new MongooseSchema29(
|
|
|
2529
2631
|
},
|
|
2530
2632
|
{ _id: false }
|
|
2531
2633
|
);
|
|
2532
|
-
var affiliateContactDetailsSchema = new
|
|
2634
|
+
var affiliateContactDetailsSchema = new MongooseSchema31(
|
|
2533
2635
|
{
|
|
2534
2636
|
mobilePhone: { required: true, type: String }
|
|
2535
2637
|
},
|
|
2536
2638
|
{ _id: false }
|
|
2537
2639
|
);
|
|
2538
|
-
var affiliateBankAccountDetailsSchema = new
|
|
2640
|
+
var affiliateBankAccountDetailsSchema = new MongooseSchema31(
|
|
2539
2641
|
{
|
|
2540
2642
|
accountHolderName: { required: true, type: String },
|
|
2541
2643
|
accountNumber: { required: true, type: String }
|
|
2542
2644
|
},
|
|
2543
2645
|
{ _id: false }
|
|
2544
2646
|
);
|
|
2545
|
-
var affiliateDetailsSchema = new
|
|
2647
|
+
var affiliateDetailsSchema = new MongooseSchema31(
|
|
2546
2648
|
{
|
|
2547
2649
|
bankAccountDetails: {
|
|
2548
2650
|
required: true,
|
|
@@ -2555,7 +2657,7 @@ var affiliateDetailsSchema = new MongooseSchema29(
|
|
|
2555
2657
|
lastName: { required: true, type: String },
|
|
2556
2658
|
location: { required: true, type: locationsSchema },
|
|
2557
2659
|
participantType: {
|
|
2558
|
-
enum: Object.values(
|
|
2660
|
+
enum: Object.values(import_cluemart_shared23.EnumAffiliateParticipantType),
|
|
2559
2661
|
required: true,
|
|
2560
2662
|
type: String
|
|
2561
2663
|
},
|
|
@@ -2564,7 +2666,7 @@ var affiliateDetailsSchema = new MongooseSchema29(
|
|
|
2564
2666
|
},
|
|
2565
2667
|
{ _id: false }
|
|
2566
2668
|
);
|
|
2567
|
-
var redeemHistorySchema = new
|
|
2669
|
+
var redeemHistorySchema = new MongooseSchema31(
|
|
2568
2670
|
{
|
|
2569
2671
|
paidAt: { default: null, required: false, type: Date },
|
|
2570
2672
|
redeemedAt: { required: true, type: Date },
|
|
@@ -2572,7 +2674,7 @@ var redeemHistorySchema = new MongooseSchema29(
|
|
|
2572
2674
|
},
|
|
2573
2675
|
{ _id: false }
|
|
2574
2676
|
);
|
|
2575
|
-
var
|
|
2677
|
+
var schema27 = new MongooseSchema31(
|
|
2576
2678
|
{
|
|
2577
2679
|
active: { default: false, required: true, type: Boolean },
|
|
2578
2680
|
affiliateBonusRewards: {
|
|
@@ -2602,26 +2704,26 @@ var schema25 = new MongooseSchema29(
|
|
|
2602
2704
|
},
|
|
2603
2705
|
{ timestamps: true }
|
|
2604
2706
|
);
|
|
2605
|
-
|
|
2707
|
+
schema27.index(
|
|
2606
2708
|
{ affiliateCode: 1 },
|
|
2607
2709
|
{
|
|
2608
2710
|
partialFilterExpression: { active: true, deletedAt: null },
|
|
2609
2711
|
unique: true
|
|
2610
2712
|
}
|
|
2611
2713
|
);
|
|
2612
|
-
var AffiliateModel =
|
|
2714
|
+
var AffiliateModel = import_mongoose36.default.models.Affiliate || import_mongoose36.default.model("Affiliate", schema27);
|
|
2613
2715
|
|
|
2614
2716
|
// src/mongoose/Coupon.ts
|
|
2615
|
-
var
|
|
2616
|
-
var
|
|
2617
|
-
var
|
|
2618
|
-
var couponOptionSchema = new
|
|
2717
|
+
var import_cluemart_shared24 = require("@timardex/cluemart-shared");
|
|
2718
|
+
var import_mongoose37 = __toESM(require("mongoose"));
|
|
2719
|
+
var MongooseSchema32 = import_mongoose37.default.Schema;
|
|
2720
|
+
var couponOptionSchema = new MongooseSchema32(
|
|
2619
2721
|
{
|
|
2620
2722
|
buy: { required: false, type: Number },
|
|
2621
2723
|
get: { required: false, type: Number },
|
|
2622
2724
|
maxRewardCount: { required: false, type: Number },
|
|
2623
2725
|
type: {
|
|
2624
|
-
enum: Object.values(
|
|
2726
|
+
enum: Object.values(import_cluemart_shared24.EnumCouponQualificationType),
|
|
2625
2727
|
required: true,
|
|
2626
2728
|
type: String
|
|
2627
2729
|
},
|
|
@@ -2630,29 +2732,29 @@ var couponOptionSchema = new MongooseSchema30(
|
|
|
2630
2732
|
},
|
|
2631
2733
|
{ _id: false }
|
|
2632
2734
|
);
|
|
2633
|
-
var couponVendorProductSchema = new
|
|
2735
|
+
var couponVendorProductSchema = new MongooseSchema32(
|
|
2634
2736
|
{
|
|
2635
2737
|
couponId: {
|
|
2636
2738
|
required: true,
|
|
2637
|
-
type:
|
|
2739
|
+
type: import_mongoose37.default.Schema.Types.ObjectId
|
|
2638
2740
|
},
|
|
2639
2741
|
productId: {
|
|
2640
2742
|
required: true,
|
|
2641
|
-
type:
|
|
2743
|
+
type: import_mongoose37.default.Schema.Types.ObjectId
|
|
2642
2744
|
},
|
|
2643
2745
|
vendorCouponId: {
|
|
2644
2746
|
required: false,
|
|
2645
|
-
type:
|
|
2747
|
+
type: import_mongoose37.default.Schema.Types.ObjectId
|
|
2646
2748
|
},
|
|
2647
2749
|
vendorId: {
|
|
2648
2750
|
ref: "Vendor",
|
|
2649
2751
|
required: true,
|
|
2650
|
-
type:
|
|
2752
|
+
type: import_mongoose37.default.Schema.Types.ObjectId
|
|
2651
2753
|
}
|
|
2652
2754
|
},
|
|
2653
2755
|
{ _id: false }
|
|
2654
2756
|
);
|
|
2655
|
-
var couponCodeSchema = new
|
|
2757
|
+
var couponCodeSchema = new MongooseSchema32(
|
|
2656
2758
|
{
|
|
2657
2759
|
code: { required: true, type: String },
|
|
2658
2760
|
qrCode: { required: true, type: ResourceImageTypeSchema },
|
|
@@ -2660,7 +2762,7 @@ var couponCodeSchema = new MongooseSchema30(
|
|
|
2660
2762
|
},
|
|
2661
2763
|
{ _id: false }
|
|
2662
2764
|
);
|
|
2663
|
-
var couponParticipantUserSchema = new
|
|
2765
|
+
var couponParticipantUserSchema = new MongooseSchema32(
|
|
2664
2766
|
{
|
|
2665
2767
|
couponCollectedCount: { default: 0, required: true, type: Number },
|
|
2666
2768
|
couponCycleRedeemed: { default: false, required: true, type: Boolean },
|
|
@@ -2669,12 +2771,12 @@ var couponParticipantUserSchema = new MongooseSchema30(
|
|
|
2669
2771
|
userId: {
|
|
2670
2772
|
ref: "User",
|
|
2671
2773
|
required: true,
|
|
2672
|
-
type:
|
|
2774
|
+
type: import_mongoose37.default.Schema.Types.ObjectId
|
|
2673
2775
|
}
|
|
2674
2776
|
},
|
|
2675
2777
|
{ timestamps: true }
|
|
2676
2778
|
);
|
|
2677
|
-
var couponDataSchema = new
|
|
2779
|
+
var couponDataSchema = new MongooseSchema32(
|
|
2678
2780
|
{
|
|
2679
2781
|
active: { default: true, required: true, type: Boolean },
|
|
2680
2782
|
couponCode: { required: false, type: couponCodeSchema },
|
|
@@ -2693,7 +2795,7 @@ var couponDataSchema = new MongooseSchema30(
|
|
|
2693
2795
|
},
|
|
2694
2796
|
resourceId: { required: true, type: String },
|
|
2695
2797
|
resourceType: {
|
|
2696
|
-
enum: Object.values(
|
|
2798
|
+
enum: Object.values(import_cluemart_shared24.EnumResourceType),
|
|
2697
2799
|
required: true,
|
|
2698
2800
|
type: String
|
|
2699
2801
|
},
|
|
@@ -2701,7 +2803,7 @@ var couponDataSchema = new MongooseSchema30(
|
|
|
2701
2803
|
},
|
|
2702
2804
|
{ timestamps: true }
|
|
2703
2805
|
);
|
|
2704
|
-
var
|
|
2806
|
+
var schema28 = new MongooseSchema32(
|
|
2705
2807
|
{
|
|
2706
2808
|
active: { default: true, required: true, type: Boolean },
|
|
2707
2809
|
couponData: { default: [], required: false, type: [couponDataSchema] },
|
|
@@ -2713,62 +2815,62 @@ var schema26 = new MongooseSchema30(
|
|
|
2713
2815
|
},
|
|
2714
2816
|
{ timestamps: true }
|
|
2715
2817
|
);
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
var CouponModel =
|
|
2818
|
+
schema28.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
|
|
2819
|
+
schema28.index({ "couponData.participantUsers.userId": 1 });
|
|
2820
|
+
var CouponModel = import_mongoose37.default.models.Coupon || import_mongoose37.default.model("Coupon", schema28);
|
|
2719
2821
|
|
|
2720
2822
|
// src/mongoose/Impersonation.ts
|
|
2721
|
-
var
|
|
2722
|
-
var
|
|
2723
|
-
var
|
|
2724
|
-
var impersonationSessionSchema = new
|
|
2823
|
+
var import_cluemart_shared25 = require("@timardex/cluemart-shared");
|
|
2824
|
+
var import_mongoose38 = __toESM(require("mongoose"));
|
|
2825
|
+
var MongooseSchema33 = import_mongoose38.default.Schema;
|
|
2826
|
+
var impersonationSessionSchema = new MongooseSchema33(
|
|
2725
2827
|
{
|
|
2726
2828
|
expiresAt: { expires: 0, required: true, type: Date },
|
|
2727
2829
|
impersonatedUserId: {
|
|
2728
2830
|
index: true,
|
|
2729
2831
|
ref: "User",
|
|
2730
2832
|
required: true,
|
|
2731
|
-
type:
|
|
2833
|
+
type: import_mongoose38.default.Schema.Types.ObjectId
|
|
2732
2834
|
},
|
|
2733
2835
|
impersonatorUserId: {
|
|
2734
2836
|
index: true,
|
|
2735
2837
|
ref: "User",
|
|
2736
2838
|
required: true,
|
|
2737
|
-
type:
|
|
2839
|
+
type: import_mongoose38.default.Schema.Types.ObjectId
|
|
2738
2840
|
},
|
|
2739
2841
|
refreshToken: { required: true, type: String }
|
|
2740
2842
|
},
|
|
2741
2843
|
{ timestamps: true }
|
|
2742
2844
|
);
|
|
2743
|
-
var ImpersonationSessionModel =
|
|
2845
|
+
var ImpersonationSessionModel = import_mongoose38.default.models.ImpersonationSession || import_mongoose38.default.model(
|
|
2744
2846
|
"ImpersonationSession",
|
|
2745
2847
|
impersonationSessionSchema
|
|
2746
2848
|
);
|
|
2747
|
-
var impersonationAuditSchema = new
|
|
2849
|
+
var impersonationAuditSchema = new MongooseSchema33(
|
|
2748
2850
|
{
|
|
2749
2851
|
action: { enum: ["start", "end"], required: true, type: String },
|
|
2750
2852
|
endReason: { type: String },
|
|
2751
2853
|
impersonatedUserId: {
|
|
2752
2854
|
ref: "User",
|
|
2753
2855
|
required: true,
|
|
2754
|
-
type:
|
|
2856
|
+
type: import_mongoose38.default.Schema.Types.ObjectId
|
|
2755
2857
|
},
|
|
2756
2858
|
impersonatorUserId: {
|
|
2757
2859
|
ref: "User",
|
|
2758
2860
|
required: true,
|
|
2759
|
-
type:
|
|
2861
|
+
type: import_mongoose38.default.Schema.Types.ObjectId
|
|
2760
2862
|
},
|
|
2761
|
-
resourceId: { type:
|
|
2762
|
-
resourceType: { enum: Object.values(
|
|
2863
|
+
resourceId: { type: import_mongoose38.default.Schema.Types.ObjectId },
|
|
2864
|
+
resourceType: { enum: Object.values(import_cluemart_shared25.EnumResourceType), type: String },
|
|
2763
2865
|
sessionId: {
|
|
2764
2866
|
ref: "ImpersonationSession",
|
|
2765
2867
|
required: true,
|
|
2766
|
-
type:
|
|
2868
|
+
type: import_mongoose38.default.Schema.Types.ObjectId
|
|
2767
2869
|
}
|
|
2768
2870
|
},
|
|
2769
2871
|
{ timestamps: true }
|
|
2770
2872
|
);
|
|
2771
|
-
var ImpersonationAuditModel =
|
|
2873
|
+
var ImpersonationAuditModel = import_mongoose38.default.models.ImpersonationAudit || import_mongoose38.default.model(
|
|
2772
2874
|
"ImpersonationAudit",
|
|
2773
2875
|
impersonationAuditSchema
|
|
2774
2876
|
);
|
|
@@ -2789,7 +2891,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
|
|
|
2789
2891
|
}
|
|
2790
2892
|
|
|
2791
2893
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
2792
|
-
var
|
|
2894
|
+
var import_cluemart_shared27 = require("@timardex/cluemart-shared");
|
|
2793
2895
|
var import_utils3 = require("@timardex/cluemart-shared/utils");
|
|
2794
2896
|
|
|
2795
2897
|
// src/service/saveNotificationsInDb.ts
|
|
@@ -2924,7 +3026,7 @@ async function sendPushNotifications({
|
|
|
2924
3026
|
}
|
|
2925
3027
|
|
|
2926
3028
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
2927
|
-
var
|
|
3029
|
+
var import_cluemart_shared26 = require("@timardex/cluemart-shared");
|
|
2928
3030
|
var import_dayjs = __toESM(require("dayjs"));
|
|
2929
3031
|
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
|
|
2930
3032
|
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
@@ -2982,17 +3084,17 @@ async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ *
|
|
|
2982
3084
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
2983
3085
|
import_dayjs.default.extend(import_utc.default);
|
|
2984
3086
|
import_dayjs.default.extend(import_timezone.default);
|
|
2985
|
-
var SUBSCRIPTION_REWARD_TIMEZONE =
|
|
3087
|
+
var SUBSCRIPTION_REWARD_TIMEZONE = import_cluemart_shared26.NZ_TZ;
|
|
2986
3088
|
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
2987
3089
|
const { hasSubscription, validTypes } = await getVendorStripeSubscriptionPlanForRewards(userId, now);
|
|
2988
|
-
if (validTypes.has(
|
|
3090
|
+
if (validTypes.has(import_cluemart_shared26.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared26.EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
2989
3091
|
if (hasSubscription) {
|
|
2990
|
-
return
|
|
3092
|
+
return import_cluemart_shared26.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
2991
3093
|
}
|
|
2992
|
-
return
|
|
3094
|
+
return import_cluemart_shared26.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2993
3095
|
}
|
|
2994
|
-
if (validTypes.has(
|
|
2995
|
-
return
|
|
3096
|
+
if (validTypes.has(import_cluemart_shared26.EnumUserLicence.STANDARD_VENDOR)) {
|
|
3097
|
+
return import_cluemart_shared26.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
2996
3098
|
}
|
|
2997
3099
|
return null;
|
|
2998
3100
|
}
|
|
@@ -3004,7 +3106,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
|
|
|
3004
3106
|
|
|
3005
3107
|
// src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
|
|
3006
3108
|
function isEligibleVendorResource(resource) {
|
|
3007
|
-
return resource.resourceType ===
|
|
3109
|
+
return resource.resourceType === import_cluemart_shared27.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
|
|
3008
3110
|
}
|
|
3009
3111
|
async function findAffiliatesWithActiveVendorReferrals() {
|
|
3010
3112
|
return await AffiliateModel.find({
|
|
@@ -3013,7 +3115,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
3013
3115
|
$elemMatch: {
|
|
3014
3116
|
resourceActive: true,
|
|
3015
3117
|
resourceDeletedAt: null,
|
|
3016
|
-
resourceType:
|
|
3118
|
+
resourceType: import_cluemart_shared27.EnumResourceType.VENDOR
|
|
3017
3119
|
}
|
|
3018
3120
|
},
|
|
3019
3121
|
deletedAt: null
|
|
@@ -3047,11 +3149,11 @@ async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
|
3047
3149
|
data: {
|
|
3048
3150
|
resourceId: String(affiliateId),
|
|
3049
3151
|
resourceName: resourceNames.join(", "),
|
|
3050
|
-
resourceType:
|
|
3152
|
+
resourceType: import_cluemart_shared27.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
|
|
3051
3153
|
},
|
|
3052
3154
|
message,
|
|
3053
3155
|
title: "Affiliate points earned",
|
|
3054
|
-
type:
|
|
3156
|
+
type: import_cluemart_shared27.EnumNotificationType.SYSTEM,
|
|
3055
3157
|
userIds: [affiliateOwnerUserId]
|
|
3056
3158
|
};
|
|
3057
3159
|
try {
|
|
@@ -3080,7 +3182,7 @@ async function tryAwardSubscriptionReward({
|
|
|
3080
3182
|
resourceActive: true,
|
|
3081
3183
|
resourceDeletedAt: null,
|
|
3082
3184
|
resourceId: resource.resourceId,
|
|
3083
|
-
resourceType:
|
|
3185
|
+
resourceType: import_cluemart_shared27.EnumResourceType.VENDOR,
|
|
3084
3186
|
rewards: {
|
|
3085
3187
|
$not: {
|
|
3086
3188
|
$elemMatch: {
|
|
@@ -3201,7 +3303,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
|
|
|
3201
3303
|
}
|
|
3202
3304
|
|
|
3203
3305
|
// src/service/database.ts
|
|
3204
|
-
var
|
|
3306
|
+
var import_mongoose42 = __toESM(require("mongoose"));
|
|
3205
3307
|
var connectToDatabase = async ({
|
|
3206
3308
|
appName,
|
|
3207
3309
|
dbName,
|
|
@@ -3214,7 +3316,7 @@ var connectToDatabase = async ({
|
|
|
3214
3316
|
// Fallback to MongoDB Atlas connection string
|
|
3215
3317
|
`mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
|
|
3216
3318
|
);
|
|
3217
|
-
await
|
|
3319
|
+
await import_mongoose42.default.connect(mongoUri);
|
|
3218
3320
|
const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
|
|
3219
3321
|
console.log(
|
|
3220
3322
|
`${connectionType} connected from server/src/service/database.ts`
|
|
@@ -3227,7 +3329,7 @@ var connectToDatabase = async ({
|
|
|
3227
3329
|
|
|
3228
3330
|
// src/types/index.ts
|
|
3229
3331
|
var import_express = __toESM(require("express"));
|
|
3230
|
-
var
|
|
3332
|
+
var import_mongoose43 = __toESM(require("mongoose"));
|
|
3231
3333
|
|
|
3232
3334
|
// src/service/notifyUsers.ts
|
|
3233
3335
|
async function publishNotificationEvents(userId, pubsub) {
|
|
@@ -3275,9 +3377,9 @@ async function notifyUsers({
|
|
|
3275
3377
|
}
|
|
3276
3378
|
|
|
3277
3379
|
// src/service/updateAdStatus.ts
|
|
3278
|
-
var
|
|
3380
|
+
var import_cluemart_shared28 = require("@timardex/cluemart-shared");
|
|
3279
3381
|
async function updateAdStatuses() {
|
|
3280
|
-
const now = (0,
|
|
3382
|
+
const now = (0, import_cluemart_shared28.nzDayKey)();
|
|
3281
3383
|
const invalidResult = await AdModel.updateMany(
|
|
3282
3384
|
{
|
|
3283
3385
|
$or: [
|
|
@@ -3285,50 +3387,50 @@ async function updateAdStatuses() {
|
|
|
3285
3387
|
{ end: { $exists: false } },
|
|
3286
3388
|
{ $expr: { $gt: ["$start", "$end"] } }
|
|
3287
3389
|
],
|
|
3288
|
-
status: { $ne:
|
|
3390
|
+
status: { $ne: import_cluemart_shared28.EnumAdStatus.PAUSED }
|
|
3289
3391
|
},
|
|
3290
|
-
{ $set: { status:
|
|
3392
|
+
{ $set: { status: import_cluemart_shared28.EnumAdStatus.PAUSED } }
|
|
3291
3393
|
);
|
|
3292
3394
|
const expiredResult = await AdModel.updateMany(
|
|
3293
|
-
{ end: { $lte: now }, status: { $ne:
|
|
3294
|
-
{ $set: { status:
|
|
3395
|
+
{ end: { $lte: now }, status: { $ne: import_cluemart_shared28.EnumAdStatus.EXPIRED } },
|
|
3396
|
+
{ $set: { status: import_cluemart_shared28.EnumAdStatus.EXPIRED } }
|
|
3295
3397
|
);
|
|
3296
3398
|
const eligibleBooking = {
|
|
3297
3399
|
$or: [
|
|
3298
3400
|
{ bookingKind: { $exists: false } },
|
|
3299
3401
|
{ bookingKind: null },
|
|
3300
3402
|
{
|
|
3301
|
-
approvalStatus:
|
|
3302
|
-
bookingKind:
|
|
3403
|
+
approvalStatus: import_cluemart_shared28.EnumAdApprovalStatus.APPROVED,
|
|
3404
|
+
bookingKind: import_cluemart_shared28.EnumAdBookingSlotKind.RESERVED
|
|
3303
3405
|
},
|
|
3304
3406
|
{
|
|
3305
|
-
approvalStatus:
|
|
3306
|
-
bookingKind:
|
|
3307
|
-
paymentStatus:
|
|
3407
|
+
approvalStatus: import_cluemart_shared28.EnumAdApprovalStatus.APPROVED,
|
|
3408
|
+
bookingKind: import_cluemart_shared28.EnumAdBookingSlotKind.PAID,
|
|
3409
|
+
paymentStatus: import_cluemart_shared28.EnumAdPaymentStatus.PAID
|
|
3308
3410
|
}
|
|
3309
3411
|
]
|
|
3310
3412
|
};
|
|
3311
3413
|
const awaitingApprovalResult = await AdModel.updateMany(
|
|
3312
3414
|
{
|
|
3313
3415
|
$nor: eligibleBooking.$or,
|
|
3314
|
-
bookingKind: { $in: Object.values(
|
|
3416
|
+
bookingKind: { $in: Object.values(import_cluemart_shared28.EnumAdBookingSlotKind) },
|
|
3315
3417
|
end: { $gt: now },
|
|
3316
|
-
status:
|
|
3418
|
+
status: import_cluemart_shared28.EnumAdStatus.ACTIVE
|
|
3317
3419
|
},
|
|
3318
|
-
{ $set: { status:
|
|
3420
|
+
{ $set: { status: import_cluemart_shared28.EnumAdStatus.PAUSED } }
|
|
3319
3421
|
);
|
|
3320
3422
|
const activeResult = await AdModel.updateMany(
|
|
3321
3423
|
{
|
|
3322
3424
|
end: { $gt: now },
|
|
3323
3425
|
start: { $lte: now },
|
|
3324
|
-
status: { $ne:
|
|
3426
|
+
status: { $ne: import_cluemart_shared28.EnumAdStatus.ACTIVE },
|
|
3325
3427
|
...eligibleBooking
|
|
3326
3428
|
},
|
|
3327
|
-
{ $set: { status:
|
|
3429
|
+
{ $set: { status: import_cluemart_shared28.EnumAdStatus.ACTIVE } }
|
|
3328
3430
|
);
|
|
3329
3431
|
const pausedResult = await AdModel.updateMany(
|
|
3330
|
-
{ start: { $gt: now }, status: { $ne:
|
|
3331
|
-
{ $set: { status:
|
|
3432
|
+
{ start: { $gt: now }, status: { $ne: import_cluemart_shared28.EnumAdStatus.PAUSED } },
|
|
3433
|
+
{ $set: { status: import_cluemart_shared28.EnumAdStatus.PAUSED } }
|
|
3332
3434
|
);
|
|
3333
3435
|
console.log(
|
|
3334
3436
|
`\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
|
|
@@ -3336,15 +3438,15 @@ async function updateAdStatuses() {
|
|
|
3336
3438
|
}
|
|
3337
3439
|
|
|
3338
3440
|
// src/service/objectIdToString.ts
|
|
3339
|
-
var
|
|
3441
|
+
var import_mongoose45 = __toESM(require("mongoose"));
|
|
3340
3442
|
function isValidObjectId(value) {
|
|
3341
|
-
return
|
|
3443
|
+
return import_mongoose45.default.Types.ObjectId.isValid(value);
|
|
3342
3444
|
}
|
|
3343
3445
|
function convertObjectIdsToStrings(obj) {
|
|
3344
3446
|
if (obj === null || obj === void 0) {
|
|
3345
3447
|
return obj;
|
|
3346
3448
|
}
|
|
3347
|
-
if (obj instanceof
|
|
3449
|
+
if (obj instanceof import_mongoose45.default.Types.ObjectId) {
|
|
3348
3450
|
return obj.toString();
|
|
3349
3451
|
}
|
|
3350
3452
|
if (obj instanceof Date) {
|
|
@@ -3538,19 +3640,19 @@ function buildUserPointEntryRemovalPipeline(pointType, sourceId) {
|
|
|
3538
3640
|
}
|
|
3539
3641
|
|
|
3540
3642
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
3541
|
-
var
|
|
3643
|
+
var import_cluemart_shared30 = require("@timardex/cluemart-shared");
|
|
3542
3644
|
var import_dayjs4 = __toESM(require("dayjs"));
|
|
3543
3645
|
|
|
3544
3646
|
// src/service/event/archiveEndedEventDates.ts
|
|
3545
|
-
var
|
|
3647
|
+
var import_cluemart_shared29 = require("@timardex/cluemart-shared");
|
|
3546
3648
|
var import_dayjs3 = __toESM(require("dayjs"));
|
|
3547
3649
|
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
3548
3650
|
import_dayjs3.default.extend(import_customParseFormat.default);
|
|
3549
3651
|
var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
|
|
3550
|
-
|
|
3652
|
+
import_cluemart_shared29.EnumEventDateStatus.ENDED
|
|
3551
3653
|
]);
|
|
3552
3654
|
var DISCARDED_STATUSES = /* @__PURE__ */ new Set([
|
|
3553
|
-
|
|
3655
|
+
import_cluemart_shared29.EnumEventDateStatus.INVALID
|
|
3554
3656
|
]);
|
|
3555
3657
|
function splitEventDatesForArchive(dateTime) {
|
|
3556
3658
|
return {
|
|
@@ -3573,12 +3675,12 @@ function dedupeArchivedSlotsByStartDateTime(slots) {
|
|
|
3573
3675
|
});
|
|
3574
3676
|
}
|
|
3575
3677
|
function isPastCanceledEventDate(slot, now) {
|
|
3576
|
-
if (slot.dateStatus !==
|
|
3678
|
+
if (slot.dateStatus !== import_cluemart_shared29.EnumEventDateStatus.CANCELED) {
|
|
3577
3679
|
return false;
|
|
3578
3680
|
}
|
|
3579
3681
|
const endDateTime = (0, import_dayjs3.default)(
|
|
3580
3682
|
`${slot.endDate} ${slot.endTime}`,
|
|
3581
|
-
`${
|
|
3683
|
+
`${import_cluemart_shared29.dateFormat} ${import_cluemart_shared29.timeFormat}`,
|
|
3582
3684
|
true
|
|
3583
3685
|
);
|
|
3584
3686
|
return endDateTime.isValid() && endDateTime.isBefore(now);
|
|
@@ -3624,7 +3726,7 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3624
3726
|
try {
|
|
3625
3727
|
for await (const doc of cursor) {
|
|
3626
3728
|
const dateTime = doc.dateTime.map(
|
|
3627
|
-
(slot) => (0,
|
|
3729
|
+
(slot) => (0, import_cluemart_shared30.updateSingleDateTimeStatus)(slot, now)
|
|
3628
3730
|
);
|
|
3629
3731
|
if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
|
|
3630
3732
|
continue;
|
|
@@ -3648,9 +3750,9 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
3648
3750
|
var ARCHIVABLE_EVENT_FILTER = {
|
|
3649
3751
|
"dateTime.dateStatus": {
|
|
3650
3752
|
$in: [
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3753
|
+
import_cluemart_shared30.EnumEventDateStatus.ENDED,
|
|
3754
|
+
import_cluemart_shared30.EnumEventDateStatus.INVALID,
|
|
3755
|
+
import_cluemart_shared30.EnumEventDateStatus.CANCELED
|
|
3654
3756
|
]
|
|
3655
3757
|
},
|
|
3656
3758
|
deletedAt: null
|
|
@@ -3675,7 +3777,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
|
3675
3777
|
try {
|
|
3676
3778
|
for await (const doc of cursor) {
|
|
3677
3779
|
const updated = doc.dateTime.map(
|
|
3678
|
-
(slot) => (0,
|
|
3780
|
+
(slot) => (0, import_cluemart_shared30.updateSingleDateTimeStatus)(slot, now)
|
|
3679
3781
|
);
|
|
3680
3782
|
const { archive, discard } = splitEventDatesForArchive(updated);
|
|
3681
3783
|
const pastCanceled = updated.filter(
|
|
@@ -3699,13 +3801,13 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
|
|
|
3699
3801
|
if (archive.length > 0 || discard.length > 0) {
|
|
3700
3802
|
pullConditions.push({
|
|
3701
3803
|
dateStatus: {
|
|
3702
|
-
$in: [
|
|
3804
|
+
$in: [import_cluemart_shared30.EnumEventDateStatus.ENDED, import_cluemart_shared30.EnumEventDateStatus.INVALID]
|
|
3703
3805
|
}
|
|
3704
3806
|
});
|
|
3705
3807
|
}
|
|
3706
3808
|
for (const slot of pastCanceled) {
|
|
3707
3809
|
pullConditions.push({
|
|
3708
|
-
dateStatus:
|
|
3810
|
+
dateStatus: import_cluemart_shared30.EnumEventDateStatus.CANCELED,
|
|
3709
3811
|
startDate: slot.startDate,
|
|
3710
3812
|
startTime: slot.startTime
|
|
3711
3813
|
});
|
|
@@ -3747,9 +3849,9 @@ async function cleanEventInfoDates(now) {
|
|
|
3747
3849
|
try {
|
|
3748
3850
|
for await (const doc of cursor) {
|
|
3749
3851
|
const updated = doc.dateTime.map(
|
|
3750
|
-
(slot) => (0,
|
|
3852
|
+
(slot) => (0, import_cluemart_shared30.updateSingleDateTimeStatus)(slot, now)
|
|
3751
3853
|
);
|
|
3752
|
-
const kept = (0,
|
|
3854
|
+
const kept = (0, import_cluemart_shared30.filterDatesByFutureStatus)(updated);
|
|
3753
3855
|
if (kept.length === updated.length) {
|
|
3754
3856
|
continue;
|
|
3755
3857
|
}
|
|
@@ -3799,7 +3901,7 @@ async function updateAllEventDateTimeStatuses() {
|
|
|
3799
3901
|
}
|
|
3800
3902
|
|
|
3801
3903
|
// src/service/index.ts
|
|
3802
|
-
var
|
|
3904
|
+
var import_cluemart_shared38 = require("@timardex/cluemart-shared");
|
|
3803
3905
|
|
|
3804
3906
|
// src/service/event/findEventOrImportedMarketById.ts
|
|
3805
3907
|
async function findEventOrImportedMarketById(resourceId) {
|
|
@@ -3816,7 +3918,7 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
3816
3918
|
}
|
|
3817
3919
|
|
|
3818
3920
|
// src/service/relations.ts
|
|
3819
|
-
var
|
|
3921
|
+
var import_cluemart_shared31 = require("@timardex/cluemart-shared");
|
|
3820
3922
|
function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
|
|
3821
3923
|
if (!previousDateTime?.length) {
|
|
3822
3924
|
return false;
|
|
@@ -3832,8 +3934,8 @@ function didRemoveAnyStartedDates(previousDateTime, nextDateTime) {
|
|
|
3832
3934
|
return false;
|
|
3833
3935
|
}
|
|
3834
3936
|
return previousDateTime.some(
|
|
3835
|
-
(prev) => prev.dateStatus ===
|
|
3836
|
-
(next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus ===
|
|
3937
|
+
(prev) => prev.dateStatus === import_cluemart_shared31.EnumEventDateStatus.STARTED && !nextDateTime?.some(
|
|
3938
|
+
(next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus === import_cluemart_shared31.EnumEventDateStatus.STARTED
|
|
3837
3939
|
)
|
|
3838
3940
|
);
|
|
3839
3941
|
}
|
|
@@ -3844,7 +3946,7 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
|
|
|
3844
3946
|
) ?? false;
|
|
3845
3947
|
return {
|
|
3846
3948
|
...relationDate,
|
|
3847
|
-
status: existsInEvent ? relationDate.status :
|
|
3949
|
+
status: existsInEvent ? relationDate.status : import_cluemart_shared31.EnumInviteStatus.CANCELED
|
|
3848
3950
|
};
|
|
3849
3951
|
});
|
|
3850
3952
|
}
|
|
@@ -3853,15 +3955,15 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
|
|
|
3853
3955
|
var import_dayjs8 = __toESM(require("dayjs"));
|
|
3854
3956
|
|
|
3855
3957
|
// src/service/license/compliance/utils.ts
|
|
3856
|
-
var
|
|
3958
|
+
var import_cluemart_shared36 = require("@timardex/cluemart-shared");
|
|
3857
3959
|
var import_dayjs7 = __toESM(require("dayjs"));
|
|
3858
3960
|
|
|
3859
3961
|
// src/service/license/compliance/event.ts
|
|
3860
|
-
var
|
|
3962
|
+
var import_cluemart_shared32 = require("@timardex/cluemart-shared");
|
|
3861
3963
|
var eventLicences = [
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3964
|
+
import_cluemart_shared32.EnumUserLicence.STANDARD_EVENT,
|
|
3965
|
+
import_cluemart_shared32.EnumUserLicence.PRO_EVENT,
|
|
3966
|
+
import_cluemart_shared32.EnumUserLicence.PRO_PLUS_EVENT
|
|
3865
3967
|
];
|
|
3866
3968
|
async function handleEventLicenceCompliance(user, now) {
|
|
3867
3969
|
if (!user.licences || !user.events?.length) {
|
|
@@ -4073,9 +4175,9 @@ function buildLicenceExpiryPipeline(params) {
|
|
|
4073
4175
|
}
|
|
4074
4176
|
|
|
4075
4177
|
// src/service/license/compliance/partner.ts
|
|
4076
|
-
var
|
|
4178
|
+
var import_cluemart_shared33 = require("@timardex/cluemart-shared");
|
|
4077
4179
|
var partnerLicences = [
|
|
4078
|
-
|
|
4180
|
+
import_cluemart_shared33.EnumUserLicence.STANDARD_PARTNER
|
|
4079
4181
|
];
|
|
4080
4182
|
async function handlePartnerLicenceCompliance(user, now) {
|
|
4081
4183
|
if (!user.licences || !user.partner) {
|
|
@@ -4085,11 +4187,11 @@ async function handlePartnerLicenceCompliance(user, now) {
|
|
|
4085
4187
|
}
|
|
4086
4188
|
|
|
4087
4189
|
// src/service/license/compliance/vendor.ts
|
|
4088
|
-
var
|
|
4190
|
+
var import_cluemart_shared35 = require("@timardex/cluemart-shared");
|
|
4089
4191
|
var import_dayjs6 = __toESM(require("dayjs"));
|
|
4090
4192
|
|
|
4091
4193
|
// src/service/license/models.ts
|
|
4092
|
-
var
|
|
4194
|
+
var import_cluemart_shared34 = require("@timardex/cluemart-shared");
|
|
4093
4195
|
var import_dayjs5 = __toESM(require("dayjs"));
|
|
4094
4196
|
var import_graphql = require("graphql");
|
|
4095
4197
|
var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
@@ -4101,31 +4203,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
|
|
|
4101
4203
|
return LicenceCategory2;
|
|
4102
4204
|
})(LicenceCategory || {});
|
|
4103
4205
|
var licenceCategoryMapping = {
|
|
4104
|
-
[
|
|
4105
|
-
[
|
|
4106
|
-
[
|
|
4107
|
-
[
|
|
4108
|
-
[
|
|
4109
|
-
[
|
|
4110
|
-
[
|
|
4111
|
-
[
|
|
4112
|
-
[
|
|
4206
|
+
[import_cluemart_shared34.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
|
|
4207
|
+
[import_cluemart_shared34.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
|
|
4208
|
+
[import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
|
|
4209
|
+
[import_cluemart_shared34.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
|
|
4210
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
|
|
4211
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
|
|
4212
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
|
|
4213
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
4214
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
|
|
4113
4215
|
};
|
|
4114
4216
|
var licencePriority = {
|
|
4115
|
-
[
|
|
4116
|
-
[
|
|
4117
|
-
[
|
|
4118
|
-
[
|
|
4119
|
-
[
|
|
4120
|
-
[
|
|
4121
|
-
[
|
|
4122
|
-
[
|
|
4123
|
-
[
|
|
4217
|
+
[import_cluemart_shared34.EnumUserLicence.PRO_PLUS_EVENT]: 3,
|
|
4218
|
+
[import_cluemart_shared34.EnumUserLicence.PRO_EVENT]: 2,
|
|
4219
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_EVENT]: 1,
|
|
4220
|
+
[import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
|
|
4221
|
+
[import_cluemart_shared34.EnumUserLicence.PRO_VENDOR]: 2,
|
|
4222
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR]: 1,
|
|
4223
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_PARTNER]: 1,
|
|
4224
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_AFFILIATE]: 1,
|
|
4225
|
+
[import_cluemart_shared34.EnumUserLicence.STANDARD_SCHOOL]: 1
|
|
4124
4226
|
};
|
|
4125
4227
|
var standardLicences = [
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4228
|
+
import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR,
|
|
4229
|
+
import_cluemart_shared34.EnumUserLicence.STANDARD_EVENT,
|
|
4230
|
+
import_cluemart_shared34.EnumUserLicence.STANDARD_PARTNER
|
|
4129
4231
|
];
|
|
4130
4232
|
var standardLicenceSet = new Set(standardLicences);
|
|
4131
4233
|
function isStandardLicence(licence) {
|
|
@@ -4139,11 +4241,11 @@ var categoryRegexMapping = {
|
|
|
4139
4241
|
["school" /* SCHOOL */]: /_school$/
|
|
4140
4242
|
};
|
|
4141
4243
|
var categoryFallbackLicence = {
|
|
4142
|
-
["event" /* EVENT */]:
|
|
4143
|
-
["partner" /* PARTNER */]:
|
|
4144
|
-
["vendor" /* VENDOR */]:
|
|
4145
|
-
["affiliate" /* AFFILIATE */]:
|
|
4146
|
-
["school" /* SCHOOL */]:
|
|
4244
|
+
["event" /* EVENT */]: import_cluemart_shared34.EnumUserLicence.STANDARD_EVENT,
|
|
4245
|
+
["partner" /* PARTNER */]: import_cluemart_shared34.EnumUserLicence.STANDARD_PARTNER,
|
|
4246
|
+
["vendor" /* VENDOR */]: import_cluemart_shared34.EnumUserLicence.STANDARD_VENDOR,
|
|
4247
|
+
["affiliate" /* AFFILIATE */]: import_cluemart_shared34.EnumUserLicence.STANDARD_AFFILIATE,
|
|
4248
|
+
["school" /* SCHOOL */]: import_cluemart_shared34.EnumUserLicence.STANDARD_SCHOOL
|
|
4147
4249
|
};
|
|
4148
4250
|
var LicenceFilterInput = {
|
|
4149
4251
|
INPUT_USER_LICENCES: "$licences"
|
|
@@ -4173,11 +4275,11 @@ function getHighestLicenceForCategory(licences, category) {
|
|
|
4173
4275
|
function createLicenceObject(expiryDate, licenceType) {
|
|
4174
4276
|
const today = (0, import_dayjs5.default)();
|
|
4175
4277
|
const expiryDateMapping = {
|
|
4176
|
-
[
|
|
4177
|
-
[
|
|
4178
|
-
[
|
|
4179
|
-
[
|
|
4180
|
-
[
|
|
4278
|
+
[import_cluemart_shared34.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
|
|
4279
|
+
[import_cluemart_shared34.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
|
|
4280
|
+
[import_cluemart_shared34.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
|
|
4281
|
+
[import_cluemart_shared34.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
|
|
4282
|
+
[import_cluemart_shared34.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
|
|
4181
4283
|
};
|
|
4182
4284
|
const licenceObject = {
|
|
4183
4285
|
expiryDate: expiryDateMapping[expiryDate],
|
|
@@ -4281,13 +4383,13 @@ async function checkOwnerHasLicence({
|
|
|
4281
4383
|
const owner = await UserModel.findById(userId);
|
|
4282
4384
|
if (!owner) throw new import_graphql.GraphQLError("Owner not found");
|
|
4283
4385
|
const categoryByResource = {
|
|
4284
|
-
[
|
|
4285
|
-
[
|
|
4286
|
-
[
|
|
4287
|
-
[
|
|
4288
|
-
[
|
|
4386
|
+
[import_cluemart_shared34.EnumResourceType.EVENT]: "event" /* EVENT */,
|
|
4387
|
+
[import_cluemart_shared34.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
|
|
4388
|
+
[import_cluemart_shared34.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
|
|
4389
|
+
[import_cluemart_shared34.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
|
|
4390
|
+
[import_cluemart_shared34.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
|
|
4289
4391
|
};
|
|
4290
|
-
if (!(0,
|
|
4392
|
+
if (!(0, import_cluemart_shared34.isNonVisitorResourceType)(resourceType)) {
|
|
4291
4393
|
throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
|
|
4292
4394
|
}
|
|
4293
4395
|
const requiredCategory = categoryByResource[resourceType];
|
|
@@ -4367,7 +4469,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
|
|
|
4367
4469
|
return (result?.matchedCount ?? 0) > 0;
|
|
4368
4470
|
}
|
|
4369
4471
|
async function downgradeVendorProFeatures(userId, licenceType) {
|
|
4370
|
-
const isStandardVendor = licenceType ===
|
|
4472
|
+
const isStandardVendor = licenceType === import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR;
|
|
4371
4473
|
if (!isStandardVendor) {
|
|
4372
4474
|
return;
|
|
4373
4475
|
}
|
|
@@ -4414,7 +4516,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
|
|
|
4414
4516
|
return (result?.matchedCount ?? 0) > 0;
|
|
4415
4517
|
}
|
|
4416
4518
|
async function restoreVendorProFeatures(userId, licenceType) {
|
|
4417
|
-
const isProVendor = licenceType ===
|
|
4519
|
+
const isProVendor = licenceType === import_cluemart_shared35.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR;
|
|
4418
4520
|
if (!isProVendor) {
|
|
4419
4521
|
return;
|
|
4420
4522
|
}
|
|
@@ -4435,14 +4537,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
|
|
|
4435
4537
|
return false;
|
|
4436
4538
|
}
|
|
4437
4539
|
const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs6.default)(stripe.paymentGracePeriodEndsAt) : null;
|
|
4438
|
-
const hasActivePaymentGracePeriod = (stripe.status ===
|
|
4540
|
+
const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared35.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared35.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
|
|
4439
4541
|
if (hasActivePaymentGracePeriod) {
|
|
4440
4542
|
return true;
|
|
4441
4543
|
}
|
|
4442
4544
|
if (!stripe.subscriptionId) {
|
|
4443
4545
|
return false;
|
|
4444
4546
|
}
|
|
4445
|
-
if (stripe.status !==
|
|
4547
|
+
if (stripe.status !== import_cluemart_shared35.EnumSubscriptionStatus.ACTIVE) {
|
|
4446
4548
|
return false;
|
|
4447
4549
|
}
|
|
4448
4550
|
if (!stripe.endDate) {
|
|
@@ -4462,7 +4564,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4462
4564
|
return;
|
|
4463
4565
|
}
|
|
4464
4566
|
const proLicences = vendorLicencesOfUser.filter(
|
|
4465
|
-
(licence) => licence.licenceType !==
|
|
4567
|
+
(licence) => licence.licenceType !== import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR
|
|
4466
4568
|
);
|
|
4467
4569
|
const expiredProLicences = proLicences.filter(
|
|
4468
4570
|
(licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now)
|
|
@@ -4475,7 +4577,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4475
4577
|
const expiredProLicence = expiredProLicences.some(
|
|
4476
4578
|
(licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
4477
4579
|
);
|
|
4478
|
-
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences,
|
|
4580
|
+
const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared35.vendorLicences, now);
|
|
4479
4581
|
const hasExpiredVendorLicence = vendorLicencesOfUser.some(
|
|
4480
4582
|
(licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
|
|
4481
4583
|
);
|
|
@@ -4491,7 +4593,7 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4491
4593
|
"owner.userId": user._id
|
|
4492
4594
|
}).lean().exec();
|
|
4493
4595
|
}
|
|
4494
|
-
const licencesToSync =
|
|
4596
|
+
const licencesToSync = import_cluemart_shared35.vendorLicences.filter(
|
|
4495
4597
|
(licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
|
|
4496
4598
|
);
|
|
4497
4599
|
await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
|
|
@@ -4506,11 +4608,11 @@ async function handleVendorLicenceCompliance(user, now) {
|
|
|
4506
4608
|
data: {
|
|
4507
4609
|
resourceId: String(vendor._id),
|
|
4508
4610
|
resourceName: vendor.name,
|
|
4509
|
-
resourceType:
|
|
4611
|
+
resourceType: import_cluemart_shared35.EnumNotificationResourceType.DOWNGRADED_VENDOR
|
|
4510
4612
|
},
|
|
4511
4613
|
message: `Your Vendor licence has been downgraded due to licence expiration.`,
|
|
4512
4614
|
title: `Vendor Licence Downgraded`,
|
|
4513
|
-
type:
|
|
4615
|
+
type: import_cluemart_shared35.EnumNotificationType.SYSTEM,
|
|
4514
4616
|
userIds: [user._id]
|
|
4515
4617
|
};
|
|
4516
4618
|
await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
|
|
@@ -4543,7 +4645,7 @@ async function vendorOwnerHasProLicence(vendorId) {
|
|
|
4543
4645
|
effectiveVendorLicences,
|
|
4544
4646
|
"vendor" /* VENDOR */
|
|
4545
4647
|
);
|
|
4546
|
-
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[
|
|
4648
|
+
return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared35.EnumUserLicence.PRO_VENDOR];
|
|
4547
4649
|
}
|
|
4548
4650
|
|
|
4549
4651
|
// src/service/license/compliance/utils.ts
|
|
@@ -4553,12 +4655,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
|
|
|
4553
4655
|
const pipeline = buildLicenceExpiryPipeline({
|
|
4554
4656
|
downgradeBranches: [
|
|
4555
4657
|
{
|
|
4556
|
-
case:
|
|
4557
|
-
then:
|
|
4658
|
+
case: import_cluemart_shared36.EnumUserLicence.PRO_PLUS_VENDOR,
|
|
4659
|
+
then: import_cluemart_shared36.EnumUserLicence.STANDARD_VENDOR
|
|
4558
4660
|
},
|
|
4559
4661
|
{
|
|
4560
|
-
case:
|
|
4561
|
-
then:
|
|
4662
|
+
case: import_cluemart_shared36.EnumUserLicence.PRO_VENDOR,
|
|
4663
|
+
then: import_cluemart_shared36.EnumUserLicence.STANDARD_VENDOR
|
|
4562
4664
|
}
|
|
4563
4665
|
],
|
|
4564
4666
|
licenceTypes,
|
|
@@ -4687,7 +4789,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
|
|
|
4687
4789
|
var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
|
|
4688
4790
|
|
|
4689
4791
|
// src/service/license/reminder/utils.ts
|
|
4690
|
-
var
|
|
4792
|
+
var import_cluemart_shared37 = require("@timardex/cluemart-shared");
|
|
4691
4793
|
var import_utils8 = require("@timardex/cluemart-shared/utils");
|
|
4692
4794
|
var import_dayjs9 = __toESM(require("dayjs"));
|
|
4693
4795
|
|
|
@@ -4753,28 +4855,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
|
|
|
4753
4855
|
return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
|
|
4754
4856
|
}
|
|
4755
4857
|
function getLicenseName(licenceType) {
|
|
4756
|
-
return
|
|
4858
|
+
return import_cluemart_shared37.licenseNiceNames[licenceType] || licenceType;
|
|
4757
4859
|
}
|
|
4758
4860
|
function getNotificationTypes(isVendorLicense, isPartnerLicense) {
|
|
4759
4861
|
if (isVendorLicense) {
|
|
4760
4862
|
return {
|
|
4761
|
-
notificationType:
|
|
4762
|
-
resourceType:
|
|
4863
|
+
notificationType: import_cluemart_shared37.EnumNotificationType.SYSTEM,
|
|
4864
|
+
resourceType: import_cluemart_shared37.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
|
|
4763
4865
|
};
|
|
4764
4866
|
}
|
|
4765
4867
|
if (isPartnerLicense) {
|
|
4766
4868
|
return {
|
|
4767
|
-
notificationType:
|
|
4768
|
-
resourceType:
|
|
4869
|
+
notificationType: import_cluemart_shared37.EnumNotificationType.SYSTEM,
|
|
4870
|
+
resourceType: import_cluemart_shared37.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
|
|
4769
4871
|
};
|
|
4770
4872
|
}
|
|
4771
4873
|
return {
|
|
4772
|
-
notificationType:
|
|
4773
|
-
resourceType:
|
|
4874
|
+
notificationType: import_cluemart_shared37.EnumNotificationType.SYSTEM,
|
|
4875
|
+
resourceType: import_cluemart_shared37.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
|
|
4774
4876
|
};
|
|
4775
4877
|
}
|
|
4776
4878
|
async function getLicenseResourceInfo(user, licence) {
|
|
4777
|
-
const isVendorLicense =
|
|
4879
|
+
const isVendorLicense = import_cluemart_shared37.vendorLicences.includes(licence.licenceType);
|
|
4778
4880
|
const isPartnerLicense = partnerLicences.includes(licence.licenceType);
|
|
4779
4881
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4780
4882
|
const { notificationType, resourceType } = getNotificationTypes(
|
|
@@ -4822,11 +4924,11 @@ async function getLicenseResourceInfo(user, licence) {
|
|
|
4822
4924
|
};
|
|
4823
4925
|
}
|
|
4824
4926
|
function getLicenceExpiryMode(licenceType) {
|
|
4825
|
-
return licenceType ===
|
|
4927
|
+
return licenceType === import_cluemart_shared37.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared37.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
|
|
4826
4928
|
}
|
|
4827
4929
|
async function sendLicenseReminder(user, licence) {
|
|
4828
4930
|
const licenceName = getLicenseName(licence.licenceType);
|
|
4829
|
-
const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(
|
|
4931
|
+
const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(import_cluemart_shared37.dateFormat);
|
|
4830
4932
|
const userId = String(user._id);
|
|
4831
4933
|
const resourceInfo = await getLicenseResourceInfo(user, licence);
|
|
4832
4934
|
if (!resourceInfo) {
|