@timardex/cluemart-server-shared 1.0.146 → 1.0.148

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/index.cjs CHANGED
@@ -1711,7 +1711,7 @@ __export(index_exports, {
1711
1711
  findEventOrImportedMarketById: () => findEventOrImportedMarketById,
1712
1712
  locationGeoSchema: () => locationGeoSchema,
1713
1713
  locationsSchema: () => locationsSchema,
1714
- mongoose: () => import_mongoose27.default,
1714
+ mongoose: () => import_mongoose28.default,
1715
1715
  refundPolicySchema: () => refundPolicySchema,
1716
1716
  relationDatesSchema: () => relationDatesSchema,
1717
1717
  resourceRelationsSchema: () => resourceRelationsSchema,
@@ -7002,17 +7002,6 @@ var gameScreenIdentifierList = [
7002
7002
  match: "/visitors"
7003
7003
  }
7004
7004
  ];
7005
- var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
7006
- EnumGameType2["DAILY_CLUE"] = "dailyClue";
7007
- return EnumGameType2;
7008
- })(EnumGameType || {});
7009
- var EnumGameStatus = /* @__PURE__ */ ((EnumGameStatus3) => {
7010
- EnumGameStatus3["GAME_COMPLETED"] = "GAME_COMPLETED";
7011
- EnumGameStatus3["GAME_IN_PROGRESS"] = "GAME_IN_PROGRESS";
7012
- EnumGameStatus3["GAME_LEFT"] = "GAME_LEFT";
7013
- EnumGameStatus3["GAME_STARTED"] = "GAME_STARTED";
7014
- return EnumGameStatus3;
7015
- })(EnumGameStatus || {});
7016
7005
  var dateFormat = "DD-MM-YYYY";
7017
7006
  var timeFormat = "HH:mm";
7018
7007
  import_dayjs.default.extend(import_customParseFormat.default);
@@ -7041,6 +7030,7 @@ function normalizeUrl(url) {
7041
7030
  }
7042
7031
  return url;
7043
7032
  }
7033
+ var SCHOOL_MIN_STUDENT_COUNT = 300;
7044
7034
  var packagingTypes = [
7045
7035
  "Biodegradable",
7046
7036
  "Compostable",
@@ -10010,33 +10000,32 @@ var GAME_DATE_FIELDS_FRAGMENT = gql`
10010
10000
  endDate
10011
10001
  }
10012
10002
  `;
10013
- var BASE_GAME_FIELDS_FRAGMENT = gql`
10014
- fragment BaseGameFields on BaseGameType {
10003
+ var DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT = gql`
10004
+ fragment DailyClueBaseGameFields on DailyClueBaseGameType {
10015
10005
  gameDate {
10016
10006
  ...GameDateFields
10017
10007
  }
10018
10008
  gameSolution
10019
- gameType
10020
10009
  }
10021
10010
  ${GAME_DATE_FIELDS_FRAGMENT}
10022
10011
  `;
10023
10012
  var DAILY_CLUE_GAME_DATA_FIELDS_FRAGMENT = gql`
10024
10013
  fragment DailyClueGameDataFields on DailyClueGameDataType {
10025
10014
  gameFields {
10026
- ...BaseGameFields
10015
+ ...DailyClueBaseGameFields
10027
10016
  }
10028
10017
  lastFoundDate
10029
10018
  points
10030
10019
  letterInfo {
10031
10020
  collected
10032
- shuffled
10033
- todaysLetter
10021
+ solutionShuffled
10034
10022
  todaysClue
10023
+ todaysLetter
10035
10024
  todaysPlacement
10036
10025
  }
10037
10026
  streak
10038
10027
  }
10039
- ${BASE_GAME_FIELDS_FRAGMENT}
10028
+ ${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
10040
10029
  `;
10041
10030
  var GAME_HISTORY_FIELDS_FRAGMENT = gql`
10042
10031
  fragment GameHistoryFields on GameHistoryType {
@@ -10124,6 +10113,15 @@ var GET_GAME_LEADERBOARD = gql`
10124
10113
  ${OWNER_FIELDS_FRAGMENT}
10125
10114
  ${GAME_HISTORY_FIELDS_FRAGMENT}
10126
10115
  `;
10116
+ var BASE_GAME_FIELDS_FRAGMENT = gql`
10117
+ fragment BaseGameFields on BaseGameType {
10118
+ gameType
10119
+ dailyClue {
10120
+ ...DailyClueBaseGameFields
10121
+ }
10122
+ }
10123
+ ${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
10124
+ `;
10127
10125
  var POST_CONTENT_DATA_FIELDS_FRAGMENT = gql`
10128
10126
  fragment PostContentDataFields on PostContentData {
10129
10127
  game {
@@ -11015,7 +11013,10 @@ var schoolSchema = create$3().shape({
11015
11013
  name: create$6().trim().required("Name is required"),
11016
11014
  region: create$6().trim().required("Region is required"),
11017
11015
  socialMedia: create$2().of(socialMediaSchema).nullable().default(null),
11018
- studentCount: create$5().label("Student Count").nullable().transform((value, originalValue) => originalValue === "" ? null : value).typeError("Student count must be a number").min(350, "Student count must be at least 350").required("Student count is required").test("no-leading-zeros", "", noLeadingZeros("Student Count"))
11016
+ studentCount: create$5().label("Student Count").nullable().transform((value, originalValue) => originalValue === "" ? null : value).typeError("Student count must be a number").min(
11017
+ SCHOOL_MIN_STUDENT_COUNT,
11018
+ `Student count must be at least ${SCHOOL_MIN_STUDENT_COUNT}`
11019
+ ).required("Student count is required").test("no-leading-zeros", "", noLeadingZeros("Student Count"))
11019
11020
  });
11020
11021
  var PKG = "@timardex/cluemart-shared";
11021
11022
  var IMAGE_EXTENSION = ".webp";
@@ -11107,6 +11108,17 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
11107
11108
  EnumActivity2["VIEW"] = "VIEW";
11108
11109
  return EnumActivity2;
11109
11110
  })(EnumActivity || {});
11111
+ var EnumGameStatus = /* @__PURE__ */ ((EnumGameStatus2) => {
11112
+ EnumGameStatus2["GAME_COMPLETED"] = "GAME_COMPLETED";
11113
+ EnumGameStatus2["GAME_IN_PROGRESS"] = "GAME_IN_PROGRESS";
11114
+ EnumGameStatus2["GAME_LEFT"] = "GAME_LEFT";
11115
+ EnumGameStatus2["GAME_STARTED"] = "GAME_STARTED";
11116
+ return EnumGameStatus2;
11117
+ })(EnumGameStatus || {});
11118
+ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
11119
+ EnumGameType2["DAILY_CLUE"] = "dailyClue";
11120
+ return EnumGameType2;
11121
+ })(EnumGameType || {});
11110
11122
 
11111
11123
  // src/mongoose/Ad.ts
11112
11124
  var import_mongoose = __toESM(require("mongoose"));
@@ -12349,6 +12361,9 @@ var AppSettingSchema = new MongooseSchema18(
12349
12361
  var AppSettingModel = import_mongoose18.default.models.AppSetting || import_mongoose18.default.model("AppSetting", AppSettingSchema);
12350
12362
 
12351
12363
  // src/mongoose/game/Game.ts
12364
+ var import_mongoose20 = __toESM(require("mongoose"));
12365
+
12366
+ // src/mongoose/game/utils.ts
12352
12367
  var import_mongoose19 = __toESM(require("mongoose"));
12353
12368
  var MongooseSchema19 = import_mongoose19.default.Schema;
12354
12369
  var schemaGameDate = new MongooseSchema19(
@@ -12358,29 +12373,24 @@ var schemaGameDate = new MongooseSchema19(
12358
12373
  },
12359
12374
  { _id: false }
12360
12375
  );
12361
- var schemaBaseGame = new MongooseSchema19(
12376
+ var schemaLetters = new MongooseSchema19(
12362
12377
  {
12363
- gameDate: { required: true, type: schemaGameDate },
12364
- gameSolution: { required: true, type: String },
12365
- gameType: {
12366
- enum: Object.values(EnumGameType),
12367
- required: false,
12368
- type: String
12369
- }
12378
+ collected: { required: false, type: [String] },
12379
+ solutionShuffled: { required: true, type: [String] }
12380
+ // todaysLetter and todaysPlacement is generated in the backend, so they are not required
12370
12381
  },
12371
12382
  { _id: false }
12372
12383
  );
12373
- var schemaLetters = new MongooseSchema19(
12384
+ var schemaDailyClueBaseGame = new MongooseSchema19(
12374
12385
  {
12375
- collected: { required: false, type: [String] },
12376
- shuffled: { required: true, type: [String] }
12377
- // todaysLetter and todaysPlacement is generated in the backend, so they are not required
12386
+ gameDate: { required: true, type: schemaGameDate },
12387
+ gameSolution: { required: true, type: String }
12378
12388
  },
12379
12389
  { _id: false }
12380
12390
  );
12381
- var schemaDailyClue = new MongooseSchema19(
12391
+ var schemaDailyClueGameData = new MongooseSchema19(
12382
12392
  {
12383
- gameFields: { required: true, type: schemaBaseGame },
12393
+ gameFields: { required: true, type: schemaDailyClueBaseGame },
12384
12394
  lastFoundDate: { default: null, required: false, type: Date },
12385
12395
  letterInfo: {
12386
12396
  required: true,
@@ -12391,8 +12401,11 @@ var schemaDailyClue = new MongooseSchema19(
12391
12401
  },
12392
12402
  { _id: false }
12393
12403
  );
12404
+
12405
+ // src/mongoose/game/Game.ts
12406
+ var MongooseSchema20 = import_mongoose20.default.Schema;
12394
12407
  var gameDataSchemas = {
12395
- [EnumGameType.DAILY_CLUE]: schemaDailyClue
12408
+ [EnumGameType.DAILY_CLUE]: schemaDailyClueGameData
12396
12409
  };
12397
12410
  var gameDataDefinition = Object.fromEntries(
12398
12411
  Object.entries(gameDataSchemas).map(([key, schema16]) => [
@@ -12400,7 +12413,7 @@ var gameDataDefinition = Object.fromEntries(
12400
12413
  { default: null, required: false, type: schema16 }
12401
12414
  ])
12402
12415
  );
12403
- var gameHistorySchema = new MongooseSchema19(
12416
+ var gameHistorySchema = new MongooseSchema20(
12404
12417
  {
12405
12418
  createdAt: { required: true, type: Date },
12406
12419
  gameDate: { required: true, type: schemaGameDate },
@@ -12418,7 +12431,7 @@ var gameHistorySchema = new MongooseSchema19(
12418
12431
  },
12419
12432
  { _id: false }
12420
12433
  );
12421
- var gameTypeSchema = new MongooseSchema19(
12434
+ var gameTypeSchema = new MongooseSchema20(
12422
12435
  {
12423
12436
  active: { default: true, required: true, type: Boolean },
12424
12437
  gameData: gameDataDefinition,
@@ -12431,7 +12444,7 @@ var gameTypeSchema = new MongooseSchema19(
12431
12444
  },
12432
12445
  { timestamps: true }
12433
12446
  );
12434
- var schema14 = new MongooseSchema19(
12447
+ var schema14 = new MongooseSchema20(
12435
12448
  {
12436
12449
  active: { default: false, required: true, type: Boolean },
12437
12450
  deletedAt: { default: null, required: false, type: Date },
@@ -12444,12 +12457,12 @@ var schema14 = new MongooseSchema19(
12444
12457
  },
12445
12458
  { timestamps: true }
12446
12459
  );
12447
- var GameModel = import_mongoose19.default.models.Game || import_mongoose19.default.model("Game", schema14);
12460
+ var GameModel = import_mongoose20.default.models.Game || import_mongoose20.default.model("Game", schema14);
12448
12461
 
12449
12462
  // src/mongoose/School.ts
12450
- var import_mongoose20 = __toESM(require("mongoose"));
12451
- var MongooseSchema20 = import_mongoose20.default.Schema;
12452
- var schema15 = new MongooseSchema20(
12463
+ var import_mongoose21 = __toESM(require("mongoose"));
12464
+ var MongooseSchema21 = import_mongoose21.default.Schema;
12465
+ var schema15 = new MongooseSchema21(
12453
12466
  {
12454
12467
  // New schools are active by default
12455
12468
  active: { default: true, required: true, type: Boolean },
@@ -12474,10 +12487,10 @@ var schema15 = new MongooseSchema20(
12474
12487
  },
12475
12488
  { timestamps: true }
12476
12489
  );
12477
- var SchoolModel = import_mongoose20.default.models.School || import_mongoose20.default.model("School", schema15);
12490
+ var SchoolModel = import_mongoose21.default.models.School || import_mongoose21.default.model("School", schema15);
12478
12491
 
12479
12492
  // src/service/database.ts
12480
- var import_mongoose21 = __toESM(require("mongoose"));
12493
+ var import_mongoose22 = __toESM(require("mongoose"));
12481
12494
  var connectToDatabase = async ({
12482
12495
  appName,
12483
12496
  dbName,
@@ -12490,7 +12503,7 @@ var connectToDatabase = async ({
12490
12503
  // Fallback to MongoDB Atlas connection string
12491
12504
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
12492
12505
  );
12493
- await import_mongoose21.default.connect(mongoUri);
12506
+ await import_mongoose22.default.connect(mongoUri);
12494
12507
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
12495
12508
  console.log(
12496
12509
  `${connectionType} connected from server/src/service/database.ts`
@@ -12758,12 +12771,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
12758
12771
  }
12759
12772
 
12760
12773
  // src/service/objectIdToString.ts
12761
- var import_mongoose25 = __toESM(require("mongoose"));
12774
+ var import_mongoose26 = __toESM(require("mongoose"));
12762
12775
  function convertObjectIdsToStrings(obj) {
12763
12776
  if (obj === null || obj === void 0) {
12764
12777
  return obj;
12765
12778
  }
12766
- if (obj instanceof import_mongoose25.default.Types.ObjectId) {
12779
+ if (obj instanceof import_mongoose26.default.Types.ObjectId) {
12767
12780
  return obj.toString();
12768
12781
  }
12769
12782
  if (Array.isArray(obj)) {
@@ -12794,7 +12807,7 @@ async function findEventOrImportedMarketById(resourceId) {
12794
12807
 
12795
12808
  // src/types/index.ts
12796
12809
  var import_express = __toESM(require("express"));
12797
- var import_mongoose27 = __toESM(require("mongoose"));
12810
+ var import_mongoose28 = __toESM(require("mongoose"));
12798
12811
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
12799
12812
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
12800
12813
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";