@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.mjs CHANGED
@@ -6942,17 +6942,6 @@ var gameScreenIdentifierList = [
6942
6942
  match: "/visitors"
6943
6943
  }
6944
6944
  ];
6945
- var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
6946
- EnumGameType2["DAILY_CLUE"] = "dailyClue";
6947
- return EnumGameType2;
6948
- })(EnumGameType || {});
6949
- var EnumGameStatus = /* @__PURE__ */ ((EnumGameStatus3) => {
6950
- EnumGameStatus3["GAME_COMPLETED"] = "GAME_COMPLETED";
6951
- EnumGameStatus3["GAME_IN_PROGRESS"] = "GAME_IN_PROGRESS";
6952
- EnumGameStatus3["GAME_LEFT"] = "GAME_LEFT";
6953
- EnumGameStatus3["GAME_STARTED"] = "GAME_STARTED";
6954
- return EnumGameStatus3;
6955
- })(EnumGameStatus || {});
6956
6945
  var dateFormat = "DD-MM-YYYY";
6957
6946
  var timeFormat = "HH:mm";
6958
6947
  dayjs.extend(customParseFormat);
@@ -6981,6 +6970,7 @@ function normalizeUrl(url) {
6981
6970
  }
6982
6971
  return url;
6983
6972
  }
6973
+ var SCHOOL_MIN_STUDENT_COUNT = 300;
6984
6974
  var packagingTypes = [
6985
6975
  "Biodegradable",
6986
6976
  "Compostable",
@@ -9950,33 +9940,32 @@ var GAME_DATE_FIELDS_FRAGMENT = gql`
9950
9940
  endDate
9951
9941
  }
9952
9942
  `;
9953
- var BASE_GAME_FIELDS_FRAGMENT = gql`
9954
- fragment BaseGameFields on BaseGameType {
9943
+ var DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT = gql`
9944
+ fragment DailyClueBaseGameFields on DailyClueBaseGameType {
9955
9945
  gameDate {
9956
9946
  ...GameDateFields
9957
9947
  }
9958
9948
  gameSolution
9959
- gameType
9960
9949
  }
9961
9950
  ${GAME_DATE_FIELDS_FRAGMENT}
9962
9951
  `;
9963
9952
  var DAILY_CLUE_GAME_DATA_FIELDS_FRAGMENT = gql`
9964
9953
  fragment DailyClueGameDataFields on DailyClueGameDataType {
9965
9954
  gameFields {
9966
- ...BaseGameFields
9955
+ ...DailyClueBaseGameFields
9967
9956
  }
9968
9957
  lastFoundDate
9969
9958
  points
9970
9959
  letterInfo {
9971
9960
  collected
9972
- shuffled
9973
- todaysLetter
9961
+ solutionShuffled
9974
9962
  todaysClue
9963
+ todaysLetter
9975
9964
  todaysPlacement
9976
9965
  }
9977
9966
  streak
9978
9967
  }
9979
- ${BASE_GAME_FIELDS_FRAGMENT}
9968
+ ${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
9980
9969
  `;
9981
9970
  var GAME_HISTORY_FIELDS_FRAGMENT = gql`
9982
9971
  fragment GameHistoryFields on GameHistoryType {
@@ -10064,6 +10053,15 @@ var GET_GAME_LEADERBOARD = gql`
10064
10053
  ${OWNER_FIELDS_FRAGMENT}
10065
10054
  ${GAME_HISTORY_FIELDS_FRAGMENT}
10066
10055
  `;
10056
+ var BASE_GAME_FIELDS_FRAGMENT = gql`
10057
+ fragment BaseGameFields on BaseGameType {
10058
+ gameType
10059
+ dailyClue {
10060
+ ...DailyClueBaseGameFields
10061
+ }
10062
+ }
10063
+ ${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
10064
+ `;
10067
10065
  var POST_CONTENT_DATA_FIELDS_FRAGMENT = gql`
10068
10066
  fragment PostContentDataFields on PostContentData {
10069
10067
  game {
@@ -10955,7 +10953,10 @@ var schoolSchema = create$3().shape({
10955
10953
  name: create$6().trim().required("Name is required"),
10956
10954
  region: create$6().trim().required("Region is required"),
10957
10955
  socialMedia: create$2().of(socialMediaSchema).nullable().default(null),
10958
- 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"))
10956
+ studentCount: create$5().label("Student Count").nullable().transform((value, originalValue) => originalValue === "" ? null : value).typeError("Student count must be a number").min(
10957
+ SCHOOL_MIN_STUDENT_COUNT,
10958
+ `Student count must be at least ${SCHOOL_MIN_STUDENT_COUNT}`
10959
+ ).required("Student count is required").test("no-leading-zeros", "", noLeadingZeros("Student Count"))
10959
10960
  });
10960
10961
  var PKG = "@timardex/cluemart-shared";
10961
10962
  var IMAGE_EXTENSION = ".webp";
@@ -11047,6 +11048,17 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
11047
11048
  EnumActivity2["VIEW"] = "VIEW";
11048
11049
  return EnumActivity2;
11049
11050
  })(EnumActivity || {});
11051
+ var EnumGameStatus = /* @__PURE__ */ ((EnumGameStatus2) => {
11052
+ EnumGameStatus2["GAME_COMPLETED"] = "GAME_COMPLETED";
11053
+ EnumGameStatus2["GAME_IN_PROGRESS"] = "GAME_IN_PROGRESS";
11054
+ EnumGameStatus2["GAME_LEFT"] = "GAME_LEFT";
11055
+ EnumGameStatus2["GAME_STARTED"] = "GAME_STARTED";
11056
+ return EnumGameStatus2;
11057
+ })(EnumGameStatus || {});
11058
+ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
11059
+ EnumGameType2["DAILY_CLUE"] = "dailyClue";
11060
+ return EnumGameType2;
11061
+ })(EnumGameType || {});
11050
11062
 
11051
11063
  // src/mongoose/Ad.ts
11052
11064
  import mongoose from "mongoose";
@@ -12289,6 +12301,9 @@ var AppSettingSchema = new MongooseSchema18(
12289
12301
  var AppSettingModel = mongoose18.models.AppSetting || mongoose18.model("AppSetting", AppSettingSchema);
12290
12302
 
12291
12303
  // src/mongoose/game/Game.ts
12304
+ import mongoose20 from "mongoose";
12305
+
12306
+ // src/mongoose/game/utils.ts
12292
12307
  import mongoose19 from "mongoose";
12293
12308
  var MongooseSchema19 = mongoose19.Schema;
12294
12309
  var schemaGameDate = new MongooseSchema19(
@@ -12298,29 +12313,24 @@ var schemaGameDate = new MongooseSchema19(
12298
12313
  },
12299
12314
  { _id: false }
12300
12315
  );
12301
- var schemaBaseGame = new MongooseSchema19(
12316
+ var schemaLetters = new MongooseSchema19(
12302
12317
  {
12303
- gameDate: { required: true, type: schemaGameDate },
12304
- gameSolution: { required: true, type: String },
12305
- gameType: {
12306
- enum: Object.values(EnumGameType),
12307
- required: false,
12308
- type: String
12309
- }
12318
+ collected: { required: false, type: [String] },
12319
+ solutionShuffled: { required: true, type: [String] }
12320
+ // todaysLetter and todaysPlacement is generated in the backend, so they are not required
12310
12321
  },
12311
12322
  { _id: false }
12312
12323
  );
12313
- var schemaLetters = new MongooseSchema19(
12324
+ var schemaDailyClueBaseGame = new MongooseSchema19(
12314
12325
  {
12315
- collected: { required: false, type: [String] },
12316
- shuffled: { required: true, type: [String] }
12317
- // todaysLetter and todaysPlacement is generated in the backend, so they are not required
12326
+ gameDate: { required: true, type: schemaGameDate },
12327
+ gameSolution: { required: true, type: String }
12318
12328
  },
12319
12329
  { _id: false }
12320
12330
  );
12321
- var schemaDailyClue = new MongooseSchema19(
12331
+ var schemaDailyClueGameData = new MongooseSchema19(
12322
12332
  {
12323
- gameFields: { required: true, type: schemaBaseGame },
12333
+ gameFields: { required: true, type: schemaDailyClueBaseGame },
12324
12334
  lastFoundDate: { default: null, required: false, type: Date },
12325
12335
  letterInfo: {
12326
12336
  required: true,
@@ -12331,8 +12341,11 @@ var schemaDailyClue = new MongooseSchema19(
12331
12341
  },
12332
12342
  { _id: false }
12333
12343
  );
12344
+
12345
+ // src/mongoose/game/Game.ts
12346
+ var MongooseSchema20 = mongoose20.Schema;
12334
12347
  var gameDataSchemas = {
12335
- [EnumGameType.DAILY_CLUE]: schemaDailyClue
12348
+ [EnumGameType.DAILY_CLUE]: schemaDailyClueGameData
12336
12349
  };
12337
12350
  var gameDataDefinition = Object.fromEntries(
12338
12351
  Object.entries(gameDataSchemas).map(([key, schema16]) => [
@@ -12340,7 +12353,7 @@ var gameDataDefinition = Object.fromEntries(
12340
12353
  { default: null, required: false, type: schema16 }
12341
12354
  ])
12342
12355
  );
12343
- var gameHistorySchema = new MongooseSchema19(
12356
+ var gameHistorySchema = new MongooseSchema20(
12344
12357
  {
12345
12358
  createdAt: { required: true, type: Date },
12346
12359
  gameDate: { required: true, type: schemaGameDate },
@@ -12358,7 +12371,7 @@ var gameHistorySchema = new MongooseSchema19(
12358
12371
  },
12359
12372
  { _id: false }
12360
12373
  );
12361
- var gameTypeSchema = new MongooseSchema19(
12374
+ var gameTypeSchema = new MongooseSchema20(
12362
12375
  {
12363
12376
  active: { default: true, required: true, type: Boolean },
12364
12377
  gameData: gameDataDefinition,
@@ -12371,7 +12384,7 @@ var gameTypeSchema = new MongooseSchema19(
12371
12384
  },
12372
12385
  { timestamps: true }
12373
12386
  );
12374
- var schema14 = new MongooseSchema19(
12387
+ var schema14 = new MongooseSchema20(
12375
12388
  {
12376
12389
  active: { default: false, required: true, type: Boolean },
12377
12390
  deletedAt: { default: null, required: false, type: Date },
@@ -12384,12 +12397,12 @@ var schema14 = new MongooseSchema19(
12384
12397
  },
12385
12398
  { timestamps: true }
12386
12399
  );
12387
- var GameModel = mongoose19.models.Game || mongoose19.model("Game", schema14);
12400
+ var GameModel = mongoose20.models.Game || mongoose20.model("Game", schema14);
12388
12401
 
12389
12402
  // src/mongoose/School.ts
12390
- import mongoose20 from "mongoose";
12391
- var MongooseSchema20 = mongoose20.Schema;
12392
- var schema15 = new MongooseSchema20(
12403
+ import mongoose21 from "mongoose";
12404
+ var MongooseSchema21 = mongoose21.Schema;
12405
+ var schema15 = new MongooseSchema21(
12393
12406
  {
12394
12407
  // New schools are active by default
12395
12408
  active: { default: true, required: true, type: Boolean },
@@ -12414,10 +12427,10 @@ var schema15 = new MongooseSchema20(
12414
12427
  },
12415
12428
  { timestamps: true }
12416
12429
  );
12417
- var SchoolModel = mongoose20.models.School || mongoose20.model("School", schema15);
12430
+ var SchoolModel = mongoose21.models.School || mongoose21.model("School", schema15);
12418
12431
 
12419
12432
  // src/service/database.ts
12420
- import mongoose21 from "mongoose";
12433
+ import mongoose22 from "mongoose";
12421
12434
  var connectToDatabase = async ({
12422
12435
  appName,
12423
12436
  dbName,
@@ -12430,7 +12443,7 @@ var connectToDatabase = async ({
12430
12443
  // Fallback to MongoDB Atlas connection string
12431
12444
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
12432
12445
  );
12433
- await mongoose21.connect(mongoUri);
12446
+ await mongoose22.connect(mongoUri);
12434
12447
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
12435
12448
  console.log(
12436
12449
  `${connectionType} connected from server/src/service/database.ts`
@@ -12698,12 +12711,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
12698
12711
  }
12699
12712
 
12700
12713
  // src/service/objectIdToString.ts
12701
- import mongoose22 from "mongoose";
12714
+ import mongoose23 from "mongoose";
12702
12715
  function convertObjectIdsToStrings(obj) {
12703
12716
  if (obj === null || obj === void 0) {
12704
12717
  return obj;
12705
12718
  }
12706
- if (obj instanceof mongoose22.Types.ObjectId) {
12719
+ if (obj instanceof mongoose23.Types.ObjectId) {
12707
12720
  return obj.toString();
12708
12721
  }
12709
12722
  if (Array.isArray(obj)) {
@@ -12734,7 +12747,7 @@ async function findEventOrImportedMarketById(resourceId) {
12734
12747
 
12735
12748
  // src/types/index.ts
12736
12749
  import express from "express";
12737
- import mongoose23 from "mongoose";
12750
+ import mongoose24 from "mongoose";
12738
12751
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
12739
12752
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
12740
12753
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -12781,7 +12794,7 @@ export {
12781
12794
  findEventOrImportedMarketById,
12782
12795
  locationGeoSchema,
12783
12796
  locationsSchema,
12784
- mongoose23 as mongoose,
12797
+ mongoose24 as mongoose,
12785
12798
  refundPolicySchema,
12786
12799
  relationDatesSchema,
12787
12800
  resourceRelationsSchema,