@timardex/cluemart-server-shared 1.0.146 → 1.0.147

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,
@@ -6908,6 +6908,10 @@ var EnumSubscriptionStatus = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
6908
6908
  EnumSubscriptionStatus22["TRIALING"] = "trialing";
6909
6909
  return EnumSubscriptionStatus22;
6910
6910
  })(EnumSubscriptionStatus || {});
6911
+ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
6912
+ EnumGameType2["DAILY_CLUE"] = "dailyClue";
6913
+ return EnumGameType2;
6914
+ })(EnumGameType || {});
6911
6915
  var OBJECT_ID_PATH_SEGMENT = "[a-f0-9]{24}";
6912
6916
  var OBJECT_ID_PATH_SEGMENT_END = `${OBJECT_ID_PATH_SEGMENT}$`;
6913
6917
  var gameScreenIdentifierList = [
@@ -7002,17 +7006,6 @@ var gameScreenIdentifierList = [
7002
7006
  match: "/visitors"
7003
7007
  }
7004
7008
  ];
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
7009
  var dateFormat = "DD-MM-YYYY";
7017
7010
  var timeFormat = "HH:mm";
7018
7011
  import_dayjs.default.extend(import_customParseFormat.default);
@@ -7041,6 +7034,7 @@ function normalizeUrl(url) {
7041
7034
  }
7042
7035
  return url;
7043
7036
  }
7037
+ var SCHOOL_MIN_STUDENT_COUNT = 300;
7044
7038
  var packagingTypes = [
7045
7039
  "Biodegradable",
7046
7040
  "Compostable",
@@ -10010,8 +10004,8 @@ var GAME_DATE_FIELDS_FRAGMENT = gql`
10010
10004
  endDate
10011
10005
  }
10012
10006
  `;
10013
- var BASE_GAME_FIELDS_FRAGMENT = gql`
10014
- fragment BaseGameFields on BaseGameType {
10007
+ var DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT = gql`
10008
+ fragment DailyClueBaseGameFields on DailyClueBaseGameType {
10015
10009
  gameDate {
10016
10010
  ...GameDateFields
10017
10011
  }
@@ -10023,20 +10017,20 @@ var BASE_GAME_FIELDS_FRAGMENT = gql`
10023
10017
  var DAILY_CLUE_GAME_DATA_FIELDS_FRAGMENT = gql`
10024
10018
  fragment DailyClueGameDataFields on DailyClueGameDataType {
10025
10019
  gameFields {
10026
- ...BaseGameFields
10020
+ ...DailyClueBaseGameFields
10027
10021
  }
10028
10022
  lastFoundDate
10029
10023
  points
10030
10024
  letterInfo {
10031
10025
  collected
10032
- shuffled
10033
- todaysLetter
10026
+ solutionShuffled
10034
10027
  todaysClue
10028
+ todaysLetter
10035
10029
  todaysPlacement
10036
10030
  }
10037
10031
  streak
10038
10032
  }
10039
- ${BASE_GAME_FIELDS_FRAGMENT}
10033
+ ${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
10040
10034
  `;
10041
10035
  var GAME_HISTORY_FIELDS_FRAGMENT = gql`
10042
10036
  fragment GameHistoryFields on GameHistoryType {
@@ -10124,6 +10118,14 @@ var GET_GAME_LEADERBOARD = gql`
10124
10118
  ${OWNER_FIELDS_FRAGMENT}
10125
10119
  ${GAME_HISTORY_FIELDS_FRAGMENT}
10126
10120
  `;
10121
+ var BASE_GAME_FIELDS_FRAGMENT = gql`
10122
+ fragment BaseGameFields on BaseGameType {
10123
+ dailyClue {
10124
+ ...DailyClueBaseGameFields
10125
+ }
10126
+ }
10127
+ ${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
10128
+ `;
10127
10129
  var POST_CONTENT_DATA_FIELDS_FRAGMENT = gql`
10128
10130
  fragment PostContentDataFields on PostContentData {
10129
10131
  game {
@@ -11015,7 +11017,10 @@ var schoolSchema = create$3().shape({
11015
11017
  name: create$6().trim().required("Name is required"),
11016
11018
  region: create$6().trim().required("Region is required"),
11017
11019
  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"))
11020
+ studentCount: create$5().label("Student Count").nullable().transform((value, originalValue) => originalValue === "" ? null : value).typeError("Student count must be a number").min(
11021
+ SCHOOL_MIN_STUDENT_COUNT,
11022
+ `Student count must be at least ${SCHOOL_MIN_STUDENT_COUNT}`
11023
+ ).required("Student count is required").test("no-leading-zeros", "", noLeadingZeros("Student Count"))
11019
11024
  });
11020
11025
  var PKG = "@timardex/cluemart-shared";
11021
11026
  var IMAGE_EXTENSION = ".webp";
@@ -11107,6 +11112,13 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
11107
11112
  EnumActivity2["VIEW"] = "VIEW";
11108
11113
  return EnumActivity2;
11109
11114
  })(EnumActivity || {});
11115
+ var EnumGameStatus = /* @__PURE__ */ ((EnumGameStatus2) => {
11116
+ EnumGameStatus2["GAME_COMPLETED"] = "GAME_COMPLETED";
11117
+ EnumGameStatus2["GAME_IN_PROGRESS"] = "GAME_IN_PROGRESS";
11118
+ EnumGameStatus2["GAME_LEFT"] = "GAME_LEFT";
11119
+ EnumGameStatus2["GAME_STARTED"] = "GAME_STARTED";
11120
+ return EnumGameStatus2;
11121
+ })(EnumGameStatus || {});
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,7 +12373,15 @@ var schemaGameDate = new MongooseSchema19(
12358
12373
  },
12359
12374
  { _id: false }
12360
12375
  );
12361
- var schemaBaseGame = new MongooseSchema19(
12376
+ var schemaLetters = new MongooseSchema19(
12377
+ {
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
12381
+ },
12382
+ { _id: false }
12383
+ );
12384
+ var schemaDailyClueBaseGame = new MongooseSchema19(
12362
12385
  {
12363
12386
  gameDate: { required: true, type: schemaGameDate },
12364
12387
  gameSolution: { required: true, type: String },
@@ -12370,17 +12393,9 @@ var schemaBaseGame = new MongooseSchema19(
12370
12393
  },
12371
12394
  { _id: false }
12372
12395
  );
12373
- var schemaLetters = new MongooseSchema19(
12374
- {
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
12378
- },
12379
- { _id: false }
12380
- );
12381
- var schemaDailyClue = new MongooseSchema19(
12396
+ var schemaDailyClueGameData = new MongooseSchema19(
12382
12397
  {
12383
- gameFields: { required: true, type: schemaBaseGame },
12398
+ gameFields: { required: true, type: schemaDailyClueBaseGame },
12384
12399
  lastFoundDate: { default: null, required: false, type: Date },
12385
12400
  letterInfo: {
12386
12401
  required: true,
@@ -12391,8 +12406,11 @@ var schemaDailyClue = new MongooseSchema19(
12391
12406
  },
12392
12407
  { _id: false }
12393
12408
  );
12409
+
12410
+ // src/mongoose/game/Game.ts
12411
+ var MongooseSchema20 = import_mongoose20.default.Schema;
12394
12412
  var gameDataSchemas = {
12395
- [EnumGameType.DAILY_CLUE]: schemaDailyClue
12413
+ [EnumGameType.DAILY_CLUE]: schemaDailyClueGameData
12396
12414
  };
12397
12415
  var gameDataDefinition = Object.fromEntries(
12398
12416
  Object.entries(gameDataSchemas).map(([key, schema16]) => [
@@ -12400,7 +12418,7 @@ var gameDataDefinition = Object.fromEntries(
12400
12418
  { default: null, required: false, type: schema16 }
12401
12419
  ])
12402
12420
  );
12403
- var gameHistorySchema = new MongooseSchema19(
12421
+ var gameHistorySchema = new MongooseSchema20(
12404
12422
  {
12405
12423
  createdAt: { required: true, type: Date },
12406
12424
  gameDate: { required: true, type: schemaGameDate },
@@ -12418,7 +12436,7 @@ var gameHistorySchema = new MongooseSchema19(
12418
12436
  },
12419
12437
  { _id: false }
12420
12438
  );
12421
- var gameTypeSchema = new MongooseSchema19(
12439
+ var gameTypeSchema = new MongooseSchema20(
12422
12440
  {
12423
12441
  active: { default: true, required: true, type: Boolean },
12424
12442
  gameData: gameDataDefinition,
@@ -12431,7 +12449,7 @@ var gameTypeSchema = new MongooseSchema19(
12431
12449
  },
12432
12450
  { timestamps: true }
12433
12451
  );
12434
- var schema14 = new MongooseSchema19(
12452
+ var schema14 = new MongooseSchema20(
12435
12453
  {
12436
12454
  active: { default: false, required: true, type: Boolean },
12437
12455
  deletedAt: { default: null, required: false, type: Date },
@@ -12444,12 +12462,12 @@ var schema14 = new MongooseSchema19(
12444
12462
  },
12445
12463
  { timestamps: true }
12446
12464
  );
12447
- var GameModel = import_mongoose19.default.models.Game || import_mongoose19.default.model("Game", schema14);
12465
+ var GameModel = import_mongoose20.default.models.Game || import_mongoose20.default.model("Game", schema14);
12448
12466
 
12449
12467
  // src/mongoose/School.ts
12450
- var import_mongoose20 = __toESM(require("mongoose"));
12451
- var MongooseSchema20 = import_mongoose20.default.Schema;
12452
- var schema15 = new MongooseSchema20(
12468
+ var import_mongoose21 = __toESM(require("mongoose"));
12469
+ var MongooseSchema21 = import_mongoose21.default.Schema;
12470
+ var schema15 = new MongooseSchema21(
12453
12471
  {
12454
12472
  // New schools are active by default
12455
12473
  active: { default: true, required: true, type: Boolean },
@@ -12474,10 +12492,10 @@ var schema15 = new MongooseSchema20(
12474
12492
  },
12475
12493
  { timestamps: true }
12476
12494
  );
12477
- var SchoolModel = import_mongoose20.default.models.School || import_mongoose20.default.model("School", schema15);
12495
+ var SchoolModel = import_mongoose21.default.models.School || import_mongoose21.default.model("School", schema15);
12478
12496
 
12479
12497
  // src/service/database.ts
12480
- var import_mongoose21 = __toESM(require("mongoose"));
12498
+ var import_mongoose22 = __toESM(require("mongoose"));
12481
12499
  var connectToDatabase = async ({
12482
12500
  appName,
12483
12501
  dbName,
@@ -12490,7 +12508,7 @@ var connectToDatabase = async ({
12490
12508
  // Fallback to MongoDB Atlas connection string
12491
12509
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
12492
12510
  );
12493
- await import_mongoose21.default.connect(mongoUri);
12511
+ await import_mongoose22.default.connect(mongoUri);
12494
12512
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
12495
12513
  console.log(
12496
12514
  `${connectionType} connected from server/src/service/database.ts`
@@ -12758,12 +12776,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
12758
12776
  }
12759
12777
 
12760
12778
  // src/service/objectIdToString.ts
12761
- var import_mongoose25 = __toESM(require("mongoose"));
12779
+ var import_mongoose26 = __toESM(require("mongoose"));
12762
12780
  function convertObjectIdsToStrings(obj) {
12763
12781
  if (obj === null || obj === void 0) {
12764
12782
  return obj;
12765
12783
  }
12766
- if (obj instanceof import_mongoose25.default.Types.ObjectId) {
12784
+ if (obj instanceof import_mongoose26.default.Types.ObjectId) {
12767
12785
  return obj.toString();
12768
12786
  }
12769
12787
  if (Array.isArray(obj)) {
@@ -12794,7 +12812,7 @@ async function findEventOrImportedMarketById(resourceId) {
12794
12812
 
12795
12813
  // src/types/index.ts
12796
12814
  var import_express = __toESM(require("express"));
12797
- var import_mongoose27 = __toESM(require("mongoose"));
12815
+ var import_mongoose28 = __toESM(require("mongoose"));
12798
12816
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
12799
12817
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
12800
12818
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";