@timardex/cluemart-server-shared 1.0.206 → 1.0.208

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
@@ -78,6 +78,7 @@ __export(index_exports, {
78
78
  termsAgreementSchema: () => termsAgreementSchema,
79
79
  updateAdStatuses: () => updateAdStatuses,
80
80
  updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
81
+ updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
81
82
  updateVendorBasedOnUserLicense: () => updateVendorBasedOnUserLicense,
82
83
  userLicenseSchema: () => userLicenseSchema
83
84
  });
@@ -3457,6 +3458,12 @@ var EnumSubscriptionStatus = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
3457
3458
  EnumSubscriptionStatus22["TRIALING"] = "trialing";
3458
3459
  return EnumSubscriptionStatus22;
3459
3460
  })(EnumSubscriptionStatus || {});
3461
+ var EnumReward = /* @__PURE__ */ ((EnumReward22) => {
3462
+ EnumReward22["MYSTERY_JOY_BOX"] = "mystery_joy_box";
3463
+ EnumReward22["MYSTERY_SQUEEZE_BOX"] = "mystery_squeeze_box";
3464
+ EnumReward22["MYSTERY_DELUXE_BOX"] = "mystery_deluxe_box";
3465
+ return EnumReward22;
3466
+ })(EnumReward || {});
3460
3467
  var OBJECT_ID_PATH_SEGMENT = "[a-f0-9]{24}";
3461
3468
  var OBJECT_ID_PATH_SEGMENT_END = `${OBJECT_ID_PATH_SEGMENT}$`;
3462
3469
  var gameScreenIdentifierList = [
@@ -3556,6 +3563,8 @@ var gameScreenIdentifierList = [
3556
3563
  match: "/visitors"
3557
3564
  }
3558
3565
  ];
3566
+ var dateFormat = "DD-MM-YYYY";
3567
+ var timeFormat = "HH:mm";
3559
3568
  import_dayjs.default.extend(import_customParseFormat.default);
3560
3569
  import_dayjs.default.extend(import_utc.default);
3561
3570
  import_dayjs.default.extend(import_timezone.default);
@@ -4921,6 +4930,26 @@ var DATETIME_FIELDS_FRAGMENT = gql`
4921
4930
  startTime
4922
4931
  }
4923
4932
  `;
4933
+ var LOCATION_GEO_FIELDS_FRAGMENT = gql`
4934
+ fragment LocationGeoFields on LocationGeoType {
4935
+ coordinates
4936
+ type
4937
+ }
4938
+ `;
4939
+ var LOCATION_FIELDS_FRAGMENT = gql`
4940
+ fragment LocationFields on LocationType {
4941
+ city
4942
+ country
4943
+ fullAddress
4944
+ geo {
4945
+ ...LocationGeoFields
4946
+ }
4947
+ latitude
4948
+ longitude
4949
+ region
4950
+ }
4951
+ ${LOCATION_GEO_FIELDS_FRAGMENT}
4952
+ `;
4924
4953
  var USER_ACTIVITY_FIELDS_FRAGMENT = gql`
4925
4954
  fragment UserActivityFields on UserActivityType {
4926
4955
  favourites {
@@ -4955,6 +4984,13 @@ var USER_ACTIVITY_FIELDS_FRAGMENT = gql`
4955
4984
  }
4956
4985
  ${DATETIME_FIELDS_FRAGMENT}
4957
4986
  `;
4987
+ var REDEEMED_REWARD_FIELDS_FRAGMENT = gql`
4988
+ fragment RedeemedRewardFields on RedeemedRewardType {
4989
+ name
4990
+ pointsUsed
4991
+ redeemedAt
4992
+ }
4993
+ `;
4958
4994
  var USER_FIELDS_FRAGMENT = gql`
4959
4995
  fragment UserFields on UserType {
4960
4996
  _id
@@ -4976,12 +5012,18 @@ var USER_FIELDS_FRAGMENT = gql`
4976
5012
  licences {
4977
5013
  ...LicenceFields
4978
5014
  }
5015
+ location {
5016
+ ...LocationFields
5017
+ }
4979
5018
  partner
4980
5019
  overallPoints
4981
5020
  platform
4982
5021
  preferredRegion
4983
5022
  promoCodes
4984
5023
  role
5024
+ redeemedRewards {
5025
+ ...RedeemedRewardFields
5026
+ }
4985
5027
  school
4986
5028
  termsAgreement {
4987
5029
  ...TermsAgreementFields
@@ -4997,6 +5039,8 @@ var USER_FIELDS_FRAGMENT = gql`
4997
5039
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
4998
5040
  ${USER_ACTIVITY_FIELDS_FRAGMENT}
4999
5041
  ${LICENCE_FIELDS_FRAGMENT}
5042
+ ${LOCATION_FIELDS_FRAGMENT}
5043
+ ${REDEEMED_REWARD_FIELDS_FRAGMENT}
5000
5044
  `;
5001
5045
  var STALL_TYPE_FIELDS_FRAGMENT = gql`
5002
5046
  fragment StallTypeFields on StallTypeType {
@@ -5033,26 +5077,6 @@ var CONTACT_DETAILS_FIELDS_FRAGMENT = gql`
5033
5077
  mobilePhone
5034
5078
  }
5035
5079
  `;
5036
- var LOCATION_GEO_FIELDS_FRAGMENT = gql`
5037
- fragment LocationGeoFields on LocationGeoType {
5038
- coordinates
5039
- type
5040
- }
5041
- `;
5042
- var LOCATION_FIELDS_FRAGMENT = gql`
5043
- fragment LocationFields on LocationType {
5044
- city
5045
- country
5046
- fullAddress
5047
- geo {
5048
- ...LocationGeoFields
5049
- }
5050
- latitude
5051
- longitude
5052
- region
5053
- }
5054
- ${LOCATION_GEO_FIELDS_FRAGMENT}
5055
- `;
5056
5080
  var EVENT_LIST_ITEM = gql`
5057
5081
  fragment EventListItemFields on EventListItemType {
5058
5082
  _id
@@ -6245,6 +6269,14 @@ var DELETE_USER_MUTATION = gql`
6245
6269
  deleteUser(email: $email)
6246
6270
  }
6247
6271
  `;
6272
+ var REDEEM_REWARD_MUTATION = gql`
6273
+ mutation redeemReward($input: RedeemRewardInputType!) {
6274
+ redeemReward(input: $input) {
6275
+ message
6276
+ userId
6277
+ }
6278
+ }
6279
+ `;
6248
6280
  var ADD_USER_FAVOURITE_RESOURCE_MUTATION = gql`
6249
6281
  mutation addUserFavouriteResource(
6250
6282
  $resourceId: ID!
@@ -6952,6 +6984,7 @@ var UPDATE_PUZZLE_GAME_MUTATION = gql`
6952
6984
  var SCHOOL_REGISTERED_USERS_FIELDS_FRAGMENT = gql`
6953
6985
  fragment SchoolRegisteredUsersFields on SchoolRegisteredUserType {
6954
6986
  _id
6987
+ active
6955
6988
  avatar {
6956
6989
  ...ResourceImageFields
6957
6990
  }
@@ -7951,7 +7984,7 @@ schema4.index({ isRead: 1, userId: 1 });
7951
7984
  schema4.index({ createdAt: -1, userId: 1 });
7952
7985
  var NotificationModel = import_mongoose8.default.models.Notification || import_mongoose8.default.model("Notification", schema4);
7953
7986
 
7954
- // node_modules/@timardex/cluemart-shared/dist/chunk-JMOGW4IX.mjs
7987
+ // node_modules/@timardex/cluemart-shared/dist/chunk-6B75Q67V.mjs
7955
7988
  var EnumOSPlatform2 = /* @__PURE__ */ ((EnumOSPlatform22) => {
7956
7989
  EnumOSPlatform22["ANDROID"] = "android";
7957
7990
  EnumOSPlatform22["IOS"] = "ios";
@@ -8092,6 +8125,18 @@ var stripeSchema = new MongooseSchema11(
8092
8125
  },
8093
8126
  { _id: false }
8094
8127
  );
8128
+ var redeemedRewardSchema = new MongooseSchema11(
8129
+ {
8130
+ name: {
8131
+ enum: Object.values(EnumReward),
8132
+ required: true,
8133
+ type: String
8134
+ },
8135
+ pointsUsed: { required: true, type: Number },
8136
+ redeemedAt: { required: true, type: Date }
8137
+ },
8138
+ { _id: false }
8139
+ );
8095
8140
  var schema7 = new MongooseSchema11(
8096
8141
  {
8097
8142
  active: { default: false, required: true, type: Boolean },
@@ -8146,6 +8191,10 @@ var schema7 = new MongooseSchema11(
8146
8191
  required: false,
8147
8192
  type: [String]
8148
8193
  },
8194
+ redeemedRewards: {
8195
+ required: false,
8196
+ type: [redeemedRewardSchema]
8197
+ },
8149
8198
  refreshToken: {
8150
8199
  required: false,
8151
8200
  type: String
@@ -9125,6 +9174,15 @@ function convertObjectIdsToStrings(obj) {
9125
9174
  }
9126
9175
 
9127
9176
  // src/service/event.ts
9177
+ var import_dayjs2 = __toESM(require("dayjs"));
9178
+ var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat"));
9179
+ var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
9180
+ var import_isToday = __toESM(require("dayjs/plugin/isToday"));
9181
+ var import_isTomorrow = __toESM(require("dayjs/plugin/isTomorrow"));
9182
+ import_dayjs2.default.extend(import_customParseFormat2.default);
9183
+ import_dayjs2.default.extend(import_isToday.default);
9184
+ import_dayjs2.default.extend(import_isTomorrow.default);
9185
+ import_dayjs2.default.extend(import_isoWeek.default);
9128
9186
  async function findEventOrImportedMarketById(resourceId) {
9129
9187
  if (!resourceId) {
9130
9188
  return null;
@@ -9136,6 +9194,54 @@ async function findEventOrImportedMarketById(resourceId) {
9136
9194
  ]);
9137
9195
  return eventDoc ?? googleImportedDoc;
9138
9196
  }
9197
+ function getFutureEventStatus(startDateTime, now) {
9198
+ if (startDateTime.isToday()) {
9199
+ return EnumEventDateStatus.TODAY;
9200
+ }
9201
+ if (startDateTime.isTomorrow()) {
9202
+ return EnumEventDateStatus.TOMORROW;
9203
+ }
9204
+ if (startDateTime.isSame(now, "isoWeek")) {
9205
+ return EnumEventDateStatus.THIS_WEEK;
9206
+ }
9207
+ if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
9208
+ return EnumEventDateStatus.NEXT_WEEK;
9209
+ }
9210
+ const hoursUntilStart = startDateTime.diff(now, "hour", true);
9211
+ if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
9212
+ return EnumEventDateStatus.STARTING_SOON;
9213
+ }
9214
+ return EnumEventDateStatus.UPCOMING;
9215
+ }
9216
+ function updateSingleDateTimeStatus(dateTime) {
9217
+ const now = (0, import_dayjs2.default)();
9218
+ const startDateTime = (0, import_dayjs2.default)(
9219
+ `${dateTime.startDate} ${dateTime.startTime}`,
9220
+ `${dateFormat} ${timeFormat}`
9221
+ );
9222
+ const endDateTime = (0, import_dayjs2.default)(
9223
+ `${dateTime.endDate} ${dateTime.endTime}`,
9224
+ `${dateFormat} ${timeFormat}`
9225
+ );
9226
+ if (!startDateTime.isValid() || !endDateTime.isValid()) {
9227
+ return {
9228
+ ...dateTime,
9229
+ dateStatus: null
9230
+ };
9231
+ }
9232
+ let dateStatus = null;
9233
+ if (endDateTime.isBefore(now)) {
9234
+ dateStatus = EnumEventDateStatus.ENDED;
9235
+ } else if (startDateTime.isBefore(now) && endDateTime.isAfter(now)) {
9236
+ dateStatus = EnumEventDateStatus.STARTED;
9237
+ } else {
9238
+ dateStatus = getFutureEventStatus(startDateTime, now);
9239
+ }
9240
+ return {
9241
+ ...dateTime,
9242
+ dateStatus
9243
+ };
9244
+ }
9139
9245
 
9140
9246
  // src/service/relations.ts
9141
9247
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
@@ -9220,6 +9326,7 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
9220
9326
  termsAgreementSchema,
9221
9327
  updateAdStatuses,
9222
9328
  updateRelationDatesToUnavailable,
9329
+ updateSingleDateTimeStatus,
9223
9330
  updateVendorBasedOnUserLicense,
9224
9331
  userLicenseSchema
9225
9332
  });