@timardex/cluemart-server-shared 1.1.12 → 1.1.16

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