@timardex/cluemart-server-shared 1.1.11 → 1.1.15

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
@@ -39,6 +39,7 @@ __export(index_exports, {
39
39
  ChatModel: () => ChatModel,
40
40
  ChatReportModel: () => ChatReportModel,
41
41
  ContactDetailsSchema: () => ContactDetailsSchema,
42
+ CouponModel: () => CouponModel,
42
43
  EnumPubSubEvents: () => EnumPubSubEvents,
43
44
  EventInfoModel: () => EventInfoModel,
44
45
  EventModel: () => EventModel,
@@ -76,7 +77,7 @@ __export(index_exports, {
76
77
  locationGeoSchema: () => locationGeoSchema,
77
78
  locationsSchema: () => locationsSchema,
78
79
  mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
79
- mongoose: () => import_mongoose30.default,
80
+ mongoose: () => import_mongoose31.default,
80
81
  normalizeAffiliatePromoCodes: () => normalizeAffiliatePromoCodes,
81
82
  normalizePromoCode: () => normalizePromoCode,
82
83
  notifyUsers: () => notifyUsers,
@@ -94,7 +95,8 @@ __export(index_exports, {
94
95
  updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
95
96
  updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
96
97
  updateVendorBasedOnUserLicense: () => updateVendorBasedOnUserLicense,
97
- userLicenseSchema: () => userLicenseSchema
98
+ userLicenseSchema: () => userLicenseSchema,
99
+ vendorProductTypeSchema: () => vendorProductTypeSchema
98
100
  });
99
101
  module.exports = __toCommonJS(index_exports);
100
102
 
@@ -5502,11 +5504,14 @@ var VENDOR_DATETIME_FIELDS_FRAGMENT = gql`
5502
5504
  `;
5503
5505
  var VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT = gql`
5504
5506
  fragment VendorProductListFields on VendorProductListType {
5507
+ _id
5508
+ createdAt
5505
5509
  description
5506
5510
  name
5507
5511
  price
5508
5512
  priceUnit
5509
5513
  productGroups
5514
+ updatedAt
5510
5515
  }
5511
5516
  `;
5512
5517
  var VENDOR = gql`
@@ -7809,6 +7814,109 @@ var ASSIGN_AFFILIATE_BONUS_REWARD_MUTATION = gql`
7809
7814
  }
7810
7815
  ${AFFILIATE_FIELDS_FRAGMENT}
7811
7816
  `;
7817
+ var COUPON_CODE_FIELDS_FRAGMENT = gql`
7818
+ fragment CouponCodeFields on CouponCodeType {
7819
+ code
7820
+ qrCode {
7821
+ ...ResourceImageFields
7822
+ }
7823
+ }
7824
+ ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
7825
+ `;
7826
+ var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
7827
+ fragment CouponParticipantUserFields on CouponParticipantUserType {
7828
+ couponCount
7829
+ couponRedeemedAt
7830
+ createdAt
7831
+ updatedAt
7832
+ userId
7833
+ }
7834
+ `;
7835
+ var PRODUCT_COUPON_FIELDS_FRAGMENT = gql`
7836
+ fragment ProductCouponFields on ProductCouponType {
7837
+ _id
7838
+ active
7839
+ couponCode {
7840
+ ...CouponCodeFields
7841
+ }
7842
+ couponDescription
7843
+ couponOption
7844
+ createdAt
7845
+ endDate
7846
+ participantProduct {
7847
+ ...VendorProductListFields
7848
+ }
7849
+ participantUsers {
7850
+ ...CouponParticipantUserFields
7851
+ }
7852
+ startDate
7853
+ updatedAt
7854
+ }
7855
+ ${COUPON_CODE_FIELDS_FRAGMENT}
7856
+ ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
7857
+ ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
7858
+ `;
7859
+ var COUPON = gql`
7860
+ fragment CouponFields on CouponType {
7861
+ _id
7862
+ active
7863
+ productCoupons {
7864
+ ...ProductCouponFields
7865
+ }
7866
+ createdAt
7867
+ deletedAt
7868
+ updatedAt
7869
+ }
7870
+ ${PRODUCT_COUPON_FIELDS_FRAGMENT}
7871
+ ${COUPON_CODE_FIELDS_FRAGMENT}
7872
+ ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
7873
+ `;
7874
+ var GET_COUPONS = gql`
7875
+ query getCoupons {
7876
+ coupons {
7877
+ ...CouponFields
7878
+ }
7879
+ }
7880
+ ${COUPON}
7881
+ `;
7882
+ var GET_COUPON = gql`
7883
+ query getCoupon($_id: ID!) {
7884
+ coupon(_id: $_id) {
7885
+ ...CouponFields
7886
+ }
7887
+ }
7888
+ ${COUPON}
7889
+ `;
7890
+ var CREATE_COUPON_MUTATION = gql`
7891
+ mutation createCoupon($input: CouponInputType!) {
7892
+ createCoupon(input: $input) {
7893
+ data {
7894
+ ...CouponFields
7895
+ }
7896
+ message
7897
+ }
7898
+ }
7899
+ ${COUPON}
7900
+ `;
7901
+ var UPDATE_COUPON_MUTATION = gql`
7902
+ mutation updateCoupon($_id: ID!, $input: CouponInputType!) {
7903
+ updateCoupon(_id: $_id, input: $input) {
7904
+ data {
7905
+ ...CouponFields
7906
+ }
7907
+ message
7908
+ }
7909
+ }
7910
+ ${COUPON}
7911
+ `;
7912
+ var DELETE_COUPON_MUTATION = gql`
7913
+ mutation deleteCoupon($_id: ID!) {
7914
+ deleteCoupon(_id: $_id) {
7915
+ data
7916
+ message
7917
+ }
7918
+ }
7919
+ `;
7812
7920
  var PKG = "@timardex/cluemart-shared";
7813
7921
  var IMAGE_EXTENSION = ".webp";
7814
7922
  var posterIds = [
@@ -8945,7 +9053,7 @@ var VerificationTokenModel = import_mongoose12.default.models.VerificationToken
8945
9053
  // src/mongoose/vendor/Vendor.ts
8946
9054
  var import_mongoose13 = __toESM(require("mongoose"));
8947
9055
  var MongooseSchema13 = import_mongoose13.default.Schema;
8948
- var productTypeSchema = new MongooseSchema13(
9056
+ var vendorProductTypeSchema = new MongooseSchema13(
8949
9057
  {
8950
9058
  description: { required: false, type: String },
8951
9059
  name: { required: false, type: String },
@@ -8953,12 +9061,12 @@ var productTypeSchema = new MongooseSchema13(
8953
9061
  priceUnit: { required: false, type: String },
8954
9062
  productGroups: { required: false, type: [String] }
8955
9063
  },
8956
- { _id: false }
9064
+ { timestamps: true }
8957
9065
  );
8958
9066
  var productWrapperSchema = new MongooseSchema13(
8959
9067
  {
8960
9068
  active: { default: false, type: Boolean },
8961
- productsList: { required: false, type: [productTypeSchema] }
9069
+ productsList: { required: false, type: [vendorProductTypeSchema] }
8962
9070
  },
8963
9071
  { _id: false }
8964
9072
  );
@@ -9119,7 +9227,7 @@ var schema11 = new MongooseSchema15(
9119
9227
  claimToken: { default: null, required: false, type: String },
9120
9228
  claimTokenExpiresAt: { default: null, required: false, type: Date },
9121
9229
  deletedAt: { default: null, required: false, type: Date },
9122
- email: { required: false, type: String },
9230
+ email: { required: true, type: String },
9123
9231
  invitations: { required: true, type: [invitationSchema] },
9124
9232
  name: { required: true, type: String },
9125
9233
  region: { required: true, type: String }
@@ -9410,9 +9518,9 @@ var gameDataSchemas = {
9410
9518
  [EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
9411
9519
  };
9412
9520
  var gameDataDefinition = Object.fromEntries(
9413
- Object.entries(gameDataSchemas).map(([key, schema18]) => [
9521
+ Object.entries(gameDataSchemas).map(([key, schema19]) => [
9414
9522
  key,
9415
- { default: null, required: false, type: schema18 }
9523
+ { default: null, required: false, type: schema19 }
9416
9524
  ])
9417
9525
  );
9418
9526
  var gameHistorySchema = new MongooseSchema23(
@@ -9637,6 +9745,63 @@ schema17.index(
9637
9745
  );
9638
9746
  var AffiliateModel = import_mongoose25.default.models.Affiliate || import_mongoose25.default.model("Affiliate", schema17);
9639
9747
 
9748
+ // src/mongoose/Coupon.ts
9749
+ var import_mongoose26 = __toESM(require("mongoose"));
9750
+ var MongooseSchema26 = import_mongoose26.default.Schema;
9751
+ var couponOptionSchema = new MongooseSchema26(
9752
+ {
9753
+ buy: { required: true, type: Number },
9754
+ get: { required: true, type: Number },
9755
+ unit: { required: true, type: String }
9756
+ },
9757
+ { _id: false }
9758
+ );
9759
+ var couponCodeSchema = new MongooseSchema26(
9760
+ {
9761
+ code: { required: true, type: String },
9762
+ qrCode: { required: true, type: ResourceImageTypeSchema }
9763
+ },
9764
+ { _id: false }
9765
+ );
9766
+ var couponParticipantUserSchema = new MongooseSchema26(
9767
+ {
9768
+ couponCount: { default: 0, required: true, type: Number },
9769
+ couponRedeemedAt: { default: null, required: false, type: Date },
9770
+ userId: {
9771
+ ref: "User",
9772
+ required: true,
9773
+ type: import_mongoose26.default.Schema.Types.ObjectId
9774
+ }
9775
+ },
9776
+ { timestamps: true }
9777
+ );
9778
+ var productCouponSchema = new MongooseSchema26(
9779
+ {
9780
+ active: { default: true, required: true, type: Boolean },
9781
+ couponCode: { required: true, type: couponCodeSchema },
9782
+ couponDescription: { required: true, type: String },
9783
+ couponOption: { required: true, type: couponOptionSchema },
9784
+ endDate: { required: true, type: Date },
9785
+ participantProduct: { required: true, type: vendorProductTypeSchema },
9786
+ participantUsers: {
9787
+ default: null,
9788
+ required: false,
9789
+ type: [couponParticipantUserSchema]
9790
+ },
9791
+ startDate: { required: true, type: Date }
9792
+ },
9793
+ { timestamps: true }
9794
+ );
9795
+ var schema18 = new MongooseSchema26(
9796
+ {
9797
+ active: { default: true, required: true, type: Boolean },
9798
+ deletedAt: { default: null, required: false, type: Date },
9799
+ productCoupons: { required: false, type: [productCouponSchema] }
9800
+ },
9801
+ { timestamps: true }
9802
+ );
9803
+ var CouponModel = import_mongoose26.default.models.Coupon || import_mongoose26.default.model("Coupon", schema18);
9804
+
9640
9805
  // src/service/promoCode/constants.ts
9641
9806
  var ACTIVE_NOT_DELETED_FILTER = {
9642
9807
  active: true,
@@ -9707,7 +9872,7 @@ var SHARE_RESOURCE_LABEL2 = {
9707
9872
  school: "School"
9708
9873
  };
9709
9874
 
9710
- // node_modules/@timardex/cluemart-shared/dist/chunk-ILILH7E2.mjs
9875
+ // node_modules/@timardex/cluemart-shared/dist/chunk-7TL4ZSUO.mjs
9711
9876
  var PROMO_CODE_PREFIX2 = "CM-";
9712
9877
  var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
9713
9878
  var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
@@ -9809,7 +9974,7 @@ var gameScreenIdentifierList2 = [
9809
9974
  }
9810
9975
  ];
9811
9976
 
9812
- // node_modules/@timardex/cluemart-shared/dist/chunk-LBEJECG3.mjs
9977
+ // node_modules/@timardex/cluemart-shared/dist/chunk-4G4OFSBZ.mjs
9813
9978
  var import_dayjs4 = __toESM(require("dayjs"), 1);
9814
9979
  var statusOptions2 = [
9815
9980
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -11222,7 +11387,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
11222
11387
  }
11223
11388
 
11224
11389
  // src/service/database.ts
11225
- var import_mongoose29 = __toESM(require("mongoose"));
11390
+ var import_mongoose30 = __toESM(require("mongoose"));
11226
11391
  var connectToDatabase = async ({
11227
11392
  appName,
11228
11393
  dbName,
@@ -11235,7 +11400,7 @@ var connectToDatabase = async ({
11235
11400
  // Fallback to MongoDB Atlas connection string
11236
11401
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
11237
11402
  );
11238
- await import_mongoose29.default.connect(mongoUri);
11403
+ await import_mongoose30.default.connect(mongoUri);
11239
11404
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
11240
11405
  console.log(
11241
11406
  `${connectionType} connected from server/src/service/database.ts`
@@ -11248,7 +11413,7 @@ var connectToDatabase = async ({
11248
11413
 
11249
11414
  // src/types/index.ts
11250
11415
  var import_express = __toESM(require("express"));
11251
- var import_mongoose30 = __toESM(require("mongoose"));
11416
+ var import_mongoose31 = __toESM(require("mongoose"));
11252
11417
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
11253
11418
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
11254
11419
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -11378,15 +11543,15 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
11378
11543
  }
11379
11544
 
11380
11545
  // src/service/objectIdToString.ts
11381
- var import_mongoose33 = __toESM(require("mongoose"));
11546
+ var import_mongoose34 = __toESM(require("mongoose"));
11382
11547
  function isValidObjectId(value) {
11383
- return import_mongoose33.default.Types.ObjectId.isValid(value);
11548
+ return import_mongoose34.default.Types.ObjectId.isValid(value);
11384
11549
  }
11385
11550
  function convertObjectIdsToStrings(obj) {
11386
11551
  if (obj === null || obj === void 0) {
11387
11552
  return obj;
11388
11553
  }
11389
- if (obj instanceof import_mongoose33.default.Types.ObjectId) {
11554
+ if (obj instanceof import_mongoose34.default.Types.ObjectId) {
11390
11555
  return obj.toString();
11391
11556
  }
11392
11557
  if (obj instanceof Date) {
@@ -11578,6 +11743,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
11578
11743
  ChatModel,
11579
11744
  ChatReportModel,
11580
11745
  ContactDetailsSchema,
11746
+ CouponModel,
11581
11747
  EnumPubSubEvents,
11582
11748
  EventInfoModel,
11583
11749
  EventModel,
@@ -11633,6 +11799,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
11633
11799
  updateRelationDatesToUnavailable,
11634
11800
  updateSingleDateTimeStatus,
11635
11801
  updateVendorBasedOnUserLicense,
11636
- userLicenseSchema
11802
+ userLicenseSchema,
11803
+ vendorProductTypeSchema
11637
11804
  });
11638
11805
  //# sourceMappingURL=index.cjs.map