@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.
@@ -37,7 +37,7 @@ import {
37
37
  resourceRelationsSchema,
38
38
  termsAgreementSchema,
39
39
  userLicenseSchema
40
- } from "../chunk-BIHC7C72.mjs";
40
+ } from "../chunk-3BUXU7KR.mjs";
41
41
  export {
42
42
  APP_SETTINGS_ID,
43
43
  AdModel,
@@ -38,6 +38,7 @@ __export(service_exports, {
38
38
  sendPushNotifications: () => sendPushNotifications,
39
39
  updateAdStatuses: () => updateAdStatuses,
40
40
  updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
41
+ updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
41
42
  updateVendorBasedOnUserLicense: () => updateVendorBasedOnUserLicense
42
43
  });
43
44
  module.exports = __toCommonJS(service_exports);
@@ -3441,6 +3442,12 @@ var EnumSubscriptionStatus = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
3441
3442
  EnumSubscriptionStatus22["TRIALING"] = "trialing";
3442
3443
  return EnumSubscriptionStatus22;
3443
3444
  })(EnumSubscriptionStatus || {});
3445
+ var EnumReward = /* @__PURE__ */ ((EnumReward22) => {
3446
+ EnumReward22["MYSTERY_JOY_BOX"] = "mystery_joy_box";
3447
+ EnumReward22["MYSTERY_SQUEEZE_BOX"] = "mystery_squeeze_box";
3448
+ EnumReward22["MYSTERY_DELUXE_BOX"] = "mystery_deluxe_box";
3449
+ return EnumReward22;
3450
+ })(EnumReward || {});
3444
3451
  var OBJECT_ID_PATH_SEGMENT = "[a-f0-9]{24}";
3445
3452
  var OBJECT_ID_PATH_SEGMENT_END = `${OBJECT_ID_PATH_SEGMENT}$`;
3446
3453
  var gameScreenIdentifierList = [
@@ -3540,6 +3547,8 @@ var gameScreenIdentifierList = [
3540
3547
  match: "/visitors"
3541
3548
  }
3542
3549
  ];
3550
+ var dateFormat = "DD-MM-YYYY";
3551
+ var timeFormat = "HH:mm";
3543
3552
  import_dayjs.default.extend(import_customParseFormat.default);
3544
3553
  import_dayjs.default.extend(import_utc.default);
3545
3554
  import_dayjs.default.extend(import_timezone.default);
@@ -4905,6 +4914,26 @@ var DATETIME_FIELDS_FRAGMENT = gql`
4905
4914
  startTime
4906
4915
  }
4907
4916
  `;
4917
+ var LOCATION_GEO_FIELDS_FRAGMENT = gql`
4918
+ fragment LocationGeoFields on LocationGeoType {
4919
+ coordinates
4920
+ type
4921
+ }
4922
+ `;
4923
+ var LOCATION_FIELDS_FRAGMENT = gql`
4924
+ fragment LocationFields on LocationType {
4925
+ city
4926
+ country
4927
+ fullAddress
4928
+ geo {
4929
+ ...LocationGeoFields
4930
+ }
4931
+ latitude
4932
+ longitude
4933
+ region
4934
+ }
4935
+ ${LOCATION_GEO_FIELDS_FRAGMENT}
4936
+ `;
4908
4937
  var USER_ACTIVITY_FIELDS_FRAGMENT = gql`
4909
4938
  fragment UserActivityFields on UserActivityType {
4910
4939
  favourites {
@@ -4939,6 +4968,13 @@ var USER_ACTIVITY_FIELDS_FRAGMENT = gql`
4939
4968
  }
4940
4969
  ${DATETIME_FIELDS_FRAGMENT}
4941
4970
  `;
4971
+ var REDEEMED_REWARD_FIELDS_FRAGMENT = gql`
4972
+ fragment RedeemedRewardFields on RedeemedRewardType {
4973
+ name
4974
+ pointsUsed
4975
+ redeemedAt
4976
+ }
4977
+ `;
4942
4978
  var USER_FIELDS_FRAGMENT = gql`
4943
4979
  fragment UserFields on UserType {
4944
4980
  _id
@@ -4960,12 +4996,18 @@ var USER_FIELDS_FRAGMENT = gql`
4960
4996
  licences {
4961
4997
  ...LicenceFields
4962
4998
  }
4999
+ location {
5000
+ ...LocationFields
5001
+ }
4963
5002
  partner
4964
5003
  overallPoints
4965
5004
  platform
4966
5005
  preferredRegion
4967
5006
  promoCodes
4968
5007
  role
5008
+ redeemedRewards {
5009
+ ...RedeemedRewardFields
5010
+ }
4969
5011
  school
4970
5012
  termsAgreement {
4971
5013
  ...TermsAgreementFields
@@ -4981,6 +5023,8 @@ var USER_FIELDS_FRAGMENT = gql`
4981
5023
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
4982
5024
  ${USER_ACTIVITY_FIELDS_FRAGMENT}
4983
5025
  ${LICENCE_FIELDS_FRAGMENT}
5026
+ ${LOCATION_FIELDS_FRAGMENT}
5027
+ ${REDEEMED_REWARD_FIELDS_FRAGMENT}
4984
5028
  `;
4985
5029
  var STALL_TYPE_FIELDS_FRAGMENT = gql`
4986
5030
  fragment StallTypeFields on StallTypeType {
@@ -5017,26 +5061,6 @@ var CONTACT_DETAILS_FIELDS_FRAGMENT = gql`
5017
5061
  mobilePhone
5018
5062
  }
5019
5063
  `;
5020
- var LOCATION_GEO_FIELDS_FRAGMENT = gql`
5021
- fragment LocationGeoFields on LocationGeoType {
5022
- coordinates
5023
- type
5024
- }
5025
- `;
5026
- var LOCATION_FIELDS_FRAGMENT = gql`
5027
- fragment LocationFields on LocationType {
5028
- city
5029
- country
5030
- fullAddress
5031
- geo {
5032
- ...LocationGeoFields
5033
- }
5034
- latitude
5035
- longitude
5036
- region
5037
- }
5038
- ${LOCATION_GEO_FIELDS_FRAGMENT}
5039
- `;
5040
5064
  var EVENT_LIST_ITEM = gql`
5041
5065
  fragment EventListItemFields on EventListItemType {
5042
5066
  _id
@@ -6229,6 +6253,14 @@ var DELETE_USER_MUTATION = gql`
6229
6253
  deleteUser(email: $email)
6230
6254
  }
6231
6255
  `;
6256
+ var REDEEM_REWARD_MUTATION = gql`
6257
+ mutation redeemReward($input: RedeemRewardInputType!) {
6258
+ redeemReward(input: $input) {
6259
+ message
6260
+ userId
6261
+ }
6262
+ }
6263
+ `;
6232
6264
  var ADD_USER_FAVOURITE_RESOURCE_MUTATION = gql`
6233
6265
  mutation addUserFavouriteResource(
6234
6266
  $resourceId: ID!
@@ -6936,6 +6968,7 @@ var UPDATE_PUZZLE_GAME_MUTATION = gql`
6936
6968
  var SCHOOL_REGISTERED_USERS_FIELDS_FRAGMENT = gql`
6937
6969
  fragment SchoolRegisteredUsersFields on SchoolRegisteredUserType {
6938
6970
  _id
6971
+ active
6939
6972
  avatar {
6940
6973
  ...ResourceImageFields
6941
6974
  }
@@ -7301,7 +7334,7 @@ async function saveNotificationsInDb(payload) {
7301
7334
  // src/service/sendPushNotifications.ts
7302
7335
  var import_expo_server_sdk = require("expo-server-sdk");
7303
7336
 
7304
- // node_modules/@timardex/cluemart-shared/dist/chunk-JMOGW4IX.mjs
7337
+ // node_modules/@timardex/cluemart-shared/dist/chunk-6B75Q67V.mjs
7305
7338
  var EnumOSPlatform2 = /* @__PURE__ */ ((EnumOSPlatform22) => {
7306
7339
  EnumOSPlatform22["ANDROID"] = "android";
7307
7340
  EnumOSPlatform22["IOS"] = "ios";
@@ -8211,6 +8244,18 @@ var stripeSchema = new MongooseSchema11(
8211
8244
  },
8212
8245
  { _id: false }
8213
8246
  );
8247
+ var redeemedRewardSchema = new MongooseSchema11(
8248
+ {
8249
+ name: {
8250
+ enum: Object.values(EnumReward),
8251
+ required: true,
8252
+ type: String
8253
+ },
8254
+ pointsUsed: { required: true, type: Number },
8255
+ redeemedAt: { required: true, type: Date }
8256
+ },
8257
+ { _id: false }
8258
+ );
8214
8259
  var schema7 = new MongooseSchema11(
8215
8260
  {
8216
8261
  active: { default: false, required: true, type: Boolean },
@@ -8265,6 +8310,10 @@ var schema7 = new MongooseSchema11(
8265
8310
  required: false,
8266
8311
  type: [String]
8267
8312
  },
8313
+ redeemedRewards: {
8314
+ required: false,
8315
+ type: [redeemedRewardSchema]
8316
+ },
8268
8317
  refreshToken: {
8269
8318
  required: false,
8270
8319
  type: String
@@ -9086,6 +9135,15 @@ function convertObjectIdsToStrings(obj) {
9086
9135
  }
9087
9136
 
9088
9137
  // src/service/event.ts
9138
+ var import_dayjs2 = __toESM(require("dayjs"));
9139
+ var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat"));
9140
+ var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
9141
+ var import_isToday = __toESM(require("dayjs/plugin/isToday"));
9142
+ var import_isTomorrow = __toESM(require("dayjs/plugin/isTomorrow"));
9143
+ import_dayjs2.default.extend(import_customParseFormat2.default);
9144
+ import_dayjs2.default.extend(import_isToday.default);
9145
+ import_dayjs2.default.extend(import_isTomorrow.default);
9146
+ import_dayjs2.default.extend(import_isoWeek.default);
9089
9147
  async function findEventOrImportedMarketById(resourceId) {
9090
9148
  if (!resourceId) {
9091
9149
  return null;
@@ -9097,6 +9155,54 @@ async function findEventOrImportedMarketById(resourceId) {
9097
9155
  ]);
9098
9156
  return eventDoc ?? googleImportedDoc;
9099
9157
  }
9158
+ function getFutureEventStatus(startDateTime, now) {
9159
+ if (startDateTime.isToday()) {
9160
+ return EnumEventDateStatus.TODAY;
9161
+ }
9162
+ if (startDateTime.isTomorrow()) {
9163
+ return EnumEventDateStatus.TOMORROW;
9164
+ }
9165
+ if (startDateTime.isSame(now, "isoWeek")) {
9166
+ return EnumEventDateStatus.THIS_WEEK;
9167
+ }
9168
+ if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
9169
+ return EnumEventDateStatus.NEXT_WEEK;
9170
+ }
9171
+ const hoursUntilStart = startDateTime.diff(now, "hour", true);
9172
+ if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
9173
+ return EnumEventDateStatus.STARTING_SOON;
9174
+ }
9175
+ return EnumEventDateStatus.UPCOMING;
9176
+ }
9177
+ function updateSingleDateTimeStatus(dateTime) {
9178
+ const now = (0, import_dayjs2.default)();
9179
+ const startDateTime = (0, import_dayjs2.default)(
9180
+ `${dateTime.startDate} ${dateTime.startTime}`,
9181
+ `${dateFormat} ${timeFormat}`
9182
+ );
9183
+ const endDateTime = (0, import_dayjs2.default)(
9184
+ `${dateTime.endDate} ${dateTime.endTime}`,
9185
+ `${dateFormat} ${timeFormat}`
9186
+ );
9187
+ if (!startDateTime.isValid() || !endDateTime.isValid()) {
9188
+ return {
9189
+ ...dateTime,
9190
+ dateStatus: null
9191
+ };
9192
+ }
9193
+ let dateStatus = null;
9194
+ if (endDateTime.isBefore(now)) {
9195
+ dateStatus = EnumEventDateStatus.ENDED;
9196
+ } else if (startDateTime.isBefore(now) && endDateTime.isAfter(now)) {
9197
+ dateStatus = EnumEventDateStatus.STARTED;
9198
+ } else {
9199
+ dateStatus = getFutureEventStatus(startDateTime, now);
9200
+ }
9201
+ return {
9202
+ ...dateTime,
9203
+ dateStatus
9204
+ };
9205
+ }
9100
9206
 
9101
9207
  // src/service/relations.ts
9102
9208
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
@@ -9130,6 +9236,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
9130
9236
  sendPushNotifications,
9131
9237
  updateAdStatuses,
9132
9238
  updateRelationDatesToUnavailable,
9239
+ updateSingleDateTimeStatus,
9133
9240
  updateVendorBasedOnUserLicense
9134
9241
  });
9135
9242
  //# sourceMappingURL=index.cjs.map