@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.mjs CHANGED
@@ -6848,6 +6848,10 @@ var EnumSubscriptionStatus = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
6848
6848
  EnumSubscriptionStatus22["TRIALING"] = "trialing";
6849
6849
  return EnumSubscriptionStatus22;
6850
6850
  })(EnumSubscriptionStatus || {});
6851
+ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
6852
+ EnumGameType2["DAILY_CLUE"] = "dailyClue";
6853
+ return EnumGameType2;
6854
+ })(EnumGameType || {});
6851
6855
  var OBJECT_ID_PATH_SEGMENT = "[a-f0-9]{24}";
6852
6856
  var OBJECT_ID_PATH_SEGMENT_END = `${OBJECT_ID_PATH_SEGMENT}$`;
6853
6857
  var gameScreenIdentifierList = [
@@ -6942,17 +6946,6 @@ var gameScreenIdentifierList = [
6942
6946
  match: "/visitors"
6943
6947
  }
6944
6948
  ];
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
6949
  var dateFormat = "DD-MM-YYYY";
6957
6950
  var timeFormat = "HH:mm";
6958
6951
  dayjs.extend(customParseFormat);
@@ -6981,6 +6974,7 @@ function normalizeUrl(url) {
6981
6974
  }
6982
6975
  return url;
6983
6976
  }
6977
+ var SCHOOL_MIN_STUDENT_COUNT = 300;
6984
6978
  var packagingTypes = [
6985
6979
  "Biodegradable",
6986
6980
  "Compostable",
@@ -9950,8 +9944,8 @@ var GAME_DATE_FIELDS_FRAGMENT = gql`
9950
9944
  endDate
9951
9945
  }
9952
9946
  `;
9953
- var BASE_GAME_FIELDS_FRAGMENT = gql`
9954
- fragment BaseGameFields on BaseGameType {
9947
+ var DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT = gql`
9948
+ fragment DailyClueBaseGameFields on DailyClueBaseGameType {
9955
9949
  gameDate {
9956
9950
  ...GameDateFields
9957
9951
  }
@@ -9963,20 +9957,20 @@ var BASE_GAME_FIELDS_FRAGMENT = gql`
9963
9957
  var DAILY_CLUE_GAME_DATA_FIELDS_FRAGMENT = gql`
9964
9958
  fragment DailyClueGameDataFields on DailyClueGameDataType {
9965
9959
  gameFields {
9966
- ...BaseGameFields
9960
+ ...DailyClueBaseGameFields
9967
9961
  }
9968
9962
  lastFoundDate
9969
9963
  points
9970
9964
  letterInfo {
9971
9965
  collected
9972
- shuffled
9973
- todaysLetter
9966
+ solutionShuffled
9974
9967
  todaysClue
9968
+ todaysLetter
9975
9969
  todaysPlacement
9976
9970
  }
9977
9971
  streak
9978
9972
  }
9979
- ${BASE_GAME_FIELDS_FRAGMENT}
9973
+ ${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
9980
9974
  `;
9981
9975
  var GAME_HISTORY_FIELDS_FRAGMENT = gql`
9982
9976
  fragment GameHistoryFields on GameHistoryType {
@@ -10064,6 +10058,14 @@ var GET_GAME_LEADERBOARD = gql`
10064
10058
  ${OWNER_FIELDS_FRAGMENT}
10065
10059
  ${GAME_HISTORY_FIELDS_FRAGMENT}
10066
10060
  `;
10061
+ var BASE_GAME_FIELDS_FRAGMENT = gql`
10062
+ fragment BaseGameFields on BaseGameType {
10063
+ dailyClue {
10064
+ ...DailyClueBaseGameFields
10065
+ }
10066
+ }
10067
+ ${DAILY_CLUE_BASE_GAME_FIELDS_FRAGMENT}
10068
+ `;
10067
10069
  var POST_CONTENT_DATA_FIELDS_FRAGMENT = gql`
10068
10070
  fragment PostContentDataFields on PostContentData {
10069
10071
  game {
@@ -10955,7 +10957,10 @@ var schoolSchema = create$3().shape({
10955
10957
  name: create$6().trim().required("Name is required"),
10956
10958
  region: create$6().trim().required("Region is required"),
10957
10959
  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"))
10960
+ studentCount: create$5().label("Student Count").nullable().transform((value, originalValue) => originalValue === "" ? null : value).typeError("Student count must be a number").min(
10961
+ SCHOOL_MIN_STUDENT_COUNT,
10962
+ `Student count must be at least ${SCHOOL_MIN_STUDENT_COUNT}`
10963
+ ).required("Student count is required").test("no-leading-zeros", "", noLeadingZeros("Student Count"))
10959
10964
  });
10960
10965
  var PKG = "@timardex/cluemart-shared";
10961
10966
  var IMAGE_EXTENSION = ".webp";
@@ -11047,6 +11052,13 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
11047
11052
  EnumActivity2["VIEW"] = "VIEW";
11048
11053
  return EnumActivity2;
11049
11054
  })(EnumActivity || {});
11055
+ var EnumGameStatus = /* @__PURE__ */ ((EnumGameStatus2) => {
11056
+ EnumGameStatus2["GAME_COMPLETED"] = "GAME_COMPLETED";
11057
+ EnumGameStatus2["GAME_IN_PROGRESS"] = "GAME_IN_PROGRESS";
11058
+ EnumGameStatus2["GAME_LEFT"] = "GAME_LEFT";
11059
+ EnumGameStatus2["GAME_STARTED"] = "GAME_STARTED";
11060
+ return EnumGameStatus2;
11061
+ })(EnumGameStatus || {});
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,7 +12313,15 @@ var schemaGameDate = new MongooseSchema19(
12298
12313
  },
12299
12314
  { _id: false }
12300
12315
  );
12301
- var schemaBaseGame = new MongooseSchema19(
12316
+ var schemaLetters = new MongooseSchema19(
12317
+ {
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
12321
+ },
12322
+ { _id: false }
12323
+ );
12324
+ var schemaDailyClueBaseGame = new MongooseSchema19(
12302
12325
  {
12303
12326
  gameDate: { required: true, type: schemaGameDate },
12304
12327
  gameSolution: { required: true, type: String },
@@ -12310,17 +12333,9 @@ var schemaBaseGame = new MongooseSchema19(
12310
12333
  },
12311
12334
  { _id: false }
12312
12335
  );
12313
- var schemaLetters = new MongooseSchema19(
12314
- {
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
12318
- },
12319
- { _id: false }
12320
- );
12321
- var schemaDailyClue = new MongooseSchema19(
12336
+ var schemaDailyClueGameData = new MongooseSchema19(
12322
12337
  {
12323
- gameFields: { required: true, type: schemaBaseGame },
12338
+ gameFields: { required: true, type: schemaDailyClueBaseGame },
12324
12339
  lastFoundDate: { default: null, required: false, type: Date },
12325
12340
  letterInfo: {
12326
12341
  required: true,
@@ -12331,8 +12346,11 @@ var schemaDailyClue = new MongooseSchema19(
12331
12346
  },
12332
12347
  { _id: false }
12333
12348
  );
12349
+
12350
+ // src/mongoose/game/Game.ts
12351
+ var MongooseSchema20 = mongoose20.Schema;
12334
12352
  var gameDataSchemas = {
12335
- [EnumGameType.DAILY_CLUE]: schemaDailyClue
12353
+ [EnumGameType.DAILY_CLUE]: schemaDailyClueGameData
12336
12354
  };
12337
12355
  var gameDataDefinition = Object.fromEntries(
12338
12356
  Object.entries(gameDataSchemas).map(([key, schema16]) => [
@@ -12340,7 +12358,7 @@ var gameDataDefinition = Object.fromEntries(
12340
12358
  { default: null, required: false, type: schema16 }
12341
12359
  ])
12342
12360
  );
12343
- var gameHistorySchema = new MongooseSchema19(
12361
+ var gameHistorySchema = new MongooseSchema20(
12344
12362
  {
12345
12363
  createdAt: { required: true, type: Date },
12346
12364
  gameDate: { required: true, type: schemaGameDate },
@@ -12358,7 +12376,7 @@ var gameHistorySchema = new MongooseSchema19(
12358
12376
  },
12359
12377
  { _id: false }
12360
12378
  );
12361
- var gameTypeSchema = new MongooseSchema19(
12379
+ var gameTypeSchema = new MongooseSchema20(
12362
12380
  {
12363
12381
  active: { default: true, required: true, type: Boolean },
12364
12382
  gameData: gameDataDefinition,
@@ -12371,7 +12389,7 @@ var gameTypeSchema = new MongooseSchema19(
12371
12389
  },
12372
12390
  { timestamps: true }
12373
12391
  );
12374
- var schema14 = new MongooseSchema19(
12392
+ var schema14 = new MongooseSchema20(
12375
12393
  {
12376
12394
  active: { default: false, required: true, type: Boolean },
12377
12395
  deletedAt: { default: null, required: false, type: Date },
@@ -12384,12 +12402,12 @@ var schema14 = new MongooseSchema19(
12384
12402
  },
12385
12403
  { timestamps: true }
12386
12404
  );
12387
- var GameModel = mongoose19.models.Game || mongoose19.model("Game", schema14);
12405
+ var GameModel = mongoose20.models.Game || mongoose20.model("Game", schema14);
12388
12406
 
12389
12407
  // src/mongoose/School.ts
12390
- import mongoose20 from "mongoose";
12391
- var MongooseSchema20 = mongoose20.Schema;
12392
- var schema15 = new MongooseSchema20(
12408
+ import mongoose21 from "mongoose";
12409
+ var MongooseSchema21 = mongoose21.Schema;
12410
+ var schema15 = new MongooseSchema21(
12393
12411
  {
12394
12412
  // New schools are active by default
12395
12413
  active: { default: true, required: true, type: Boolean },
@@ -12414,10 +12432,10 @@ var schema15 = new MongooseSchema20(
12414
12432
  },
12415
12433
  { timestamps: true }
12416
12434
  );
12417
- var SchoolModel = mongoose20.models.School || mongoose20.model("School", schema15);
12435
+ var SchoolModel = mongoose21.models.School || mongoose21.model("School", schema15);
12418
12436
 
12419
12437
  // src/service/database.ts
12420
- import mongoose21 from "mongoose";
12438
+ import mongoose22 from "mongoose";
12421
12439
  var connectToDatabase = async ({
12422
12440
  appName,
12423
12441
  dbName,
@@ -12430,7 +12448,7 @@ var connectToDatabase = async ({
12430
12448
  // Fallback to MongoDB Atlas connection string
12431
12449
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
12432
12450
  );
12433
- await mongoose21.connect(mongoUri);
12451
+ await mongoose22.connect(mongoUri);
12434
12452
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
12435
12453
  console.log(
12436
12454
  `${connectionType} connected from server/src/service/database.ts`
@@ -12698,12 +12716,12 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
12698
12716
  }
12699
12717
 
12700
12718
  // src/service/objectIdToString.ts
12701
- import mongoose22 from "mongoose";
12719
+ import mongoose23 from "mongoose";
12702
12720
  function convertObjectIdsToStrings(obj) {
12703
12721
  if (obj === null || obj === void 0) {
12704
12722
  return obj;
12705
12723
  }
12706
- if (obj instanceof mongoose22.Types.ObjectId) {
12724
+ if (obj instanceof mongoose23.Types.ObjectId) {
12707
12725
  return obj.toString();
12708
12726
  }
12709
12727
  if (Array.isArray(obj)) {
@@ -12734,7 +12752,7 @@ async function findEventOrImportedMarketById(resourceId) {
12734
12752
 
12735
12753
  // src/types/index.ts
12736
12754
  import express from "express";
12737
- import mongoose23 from "mongoose";
12755
+ import mongoose24 from "mongoose";
12738
12756
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
12739
12757
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
12740
12758
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -12781,7 +12799,7 @@ export {
12781
12799
  findEventOrImportedMarketById,
12782
12800
  locationGeoSchema,
12783
12801
  locationsSchema,
12784
- mongoose23 as mongoose,
12802
+ mongoose24 as mongoose,
12785
12803
  refundPolicySchema,
12786
12804
  relationDatesSchema,
12787
12805
  resourceRelationsSchema,