@positivegrid/pg-mongoose-schema 28.0.0-beta.4 → 28.0.0-beta.6

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
@@ -4757,6 +4757,137 @@ function buildUser(mongoose) {
4757
4757
  follow_platform: 1,
4758
4758
  follow_user_id: 1
4759
4759
  }, { unique: true });
4760
+ const UserPointsSchema = new Schema({
4761
+ user_id: {
4762
+ type: ObjectId,
4763
+ ref: "User",
4764
+ required: true
4765
+ },
4766
+ points: {
4767
+ type: Number,
4768
+ default: 0,
4769
+ min: 0
4770
+ },
4771
+ lifetime_earned: {
4772
+ type: Number,
4773
+ default: 0,
4774
+ min: 0
4775
+ },
4776
+ created_on: {
4777
+ type: Date,
4778
+ default: Date.now
4779
+ },
4780
+ updated_on: {
4781
+ type: Date,
4782
+ default: Date.now
4783
+ }
4784
+ }, { collection: "user_points" });
4785
+ UserPointsSchema.index({ user_id: 1 }, { unique: true });
4786
+ const UserRewardHistorySchema = new Schema({
4787
+ user_point_id: {
4788
+ type: ObjectId,
4789
+ ref: "UserPoints",
4790
+ required: true
4791
+ },
4792
+ point_change: {
4793
+ type: Number,
4794
+ required: true
4795
+ },
4796
+ event: {
4797
+ type: String,
4798
+ required: true
4799
+ },
4800
+ created_on: {
4801
+ type: Date,
4802
+ default: Date.now
4803
+ },
4804
+ updated_on: {
4805
+ type: Date,
4806
+ default: Date.now
4807
+ }
4808
+ }, { collection: "user_reward_history" });
4809
+ UserRewardHistorySchema.index({
4810
+ user_point_id: 1,
4811
+ event: 1
4812
+ }, { unique: true });
4813
+ const RewardPointsRedeemListSchema = new Schema({
4814
+ name: {
4815
+ type: String,
4816
+ required: true
4817
+ },
4818
+ description: { type: String },
4819
+ skus: {
4820
+ type: [String],
4821
+ default: []
4822
+ },
4823
+ discount_percent: {
4824
+ type: Number,
4825
+ required: true
4826
+ },
4827
+ points_required: {
4828
+ type: Number,
4829
+ required: true,
4830
+ min: 0
4831
+ },
4832
+ created_on: {
4833
+ type: Date,
4834
+ default: Date.now
4835
+ }
4836
+ }, { collection: "reward_points_redeem_list" });
4837
+ const UserRedeemRewardPointsRecordSchema = new Schema({
4838
+ user_id: {
4839
+ type: ObjectId,
4840
+ ref: "User",
4841
+ required: true
4842
+ },
4843
+ reward_points_redeem_id: {
4844
+ type: ObjectId,
4845
+ ref: "RewardPointsRedeemList",
4846
+ required: true
4847
+ },
4848
+ discount_code: {
4849
+ type: String,
4850
+ required: true
4851
+ },
4852
+ created_on: {
4853
+ type: Date,
4854
+ default: Date.now
4855
+ }
4856
+ }, { collection: "user_redeem_reward_points_record" });
4857
+ UserRedeemRewardPointsRecordSchema.index({
4858
+ user_id: 1,
4859
+ created_on: -1
4860
+ });
4861
+ const IntermediateUserOrderRewardSchema = new Schema({
4862
+ email: {
4863
+ type: String,
4864
+ required: true,
4865
+ lowercase: true,
4866
+ trim: true
4867
+ },
4868
+ order_id: {
4869
+ type: Number,
4870
+ required: true
4871
+ },
4872
+ price: {
4873
+ type: Number,
4874
+ required: true,
4875
+ min: 0
4876
+ },
4877
+ status: {
4878
+ type: Number,
4879
+ default: 1
4880
+ },
4881
+ created_on: {
4882
+ type: Date,
4883
+ default: Date.now
4884
+ }
4885
+ }, { collection: "intermediate_user_order_reward" });
4886
+ IntermediateUserOrderRewardSchema.index({
4887
+ email: 1,
4888
+ order_id: 1
4889
+ }, { unique: true });
4890
+ IntermediateUserOrderRewardSchema.index({ status: 1 });
4760
4891
  UserSchema.method({
4761
4892
  authenticate(plainText) {
4762
4893
  const passwordArr = this.password.split("$");
@@ -5042,7 +5173,12 @@ function buildUser(mongoose) {
5042
5173
  UserReferral: mongoose.model("UserReferral", UserReferralSchema),
5043
5174
  UserEmailStatus: mongoose.model("UserEmailStatus", UserEmailStatusSchema),
5044
5175
  UserToken: mongoose.model("UserToken", UserTokenSchema),
5045
- UserFollow: mongoose.model("UserFollow", UserFollowSchema)
5176
+ UserFollow: mongoose.model("UserFollow", UserFollowSchema),
5177
+ UserPoints: mongoose.model("UserPoints", UserPointsSchema),
5178
+ UserRewardHistory: mongoose.model("UserRewardHistory", UserRewardHistorySchema),
5179
+ RewardPointsRedeemList: mongoose.model("RewardPointsRedeemList", RewardPointsRedeemListSchema),
5180
+ UserRedeemRewardPointsRecord: mongoose.model("UserRedeemRewardPointsRecord", UserRedeemRewardPointsRecordSchema),
5181
+ IntermediateUserOrderReward: mongoose.model("IntermediateUserOrderReward", IntermediateUserOrderRewardSchema)
5046
5182
  };
5047
5183
  }
5048
5184
  //#endregion
package/dist/index.d.mts CHANGED
@@ -172,6 +172,41 @@ interface IUserFollow {
172
172
  follow_user_id: Schema.Types.ObjectId;
173
173
  follow_platform?: string;
174
174
  }
175
+ interface IUserPoints {
176
+ user_id: Schema.Types.ObjectId;
177
+ points: number;
178
+ lifetime_earned: number;
179
+ created_on: Date;
180
+ updated_on: Date;
181
+ }
182
+ interface IUserRewardHistory {
183
+ user_point_id: Schema.Types.ObjectId;
184
+ point_change: number;
185
+ event: string;
186
+ created_on: Date;
187
+ updated_on: Date;
188
+ }
189
+ interface IRewardPointsRedeemList {
190
+ name: string;
191
+ description?: string;
192
+ skus: string[];
193
+ discount_percent: number;
194
+ points_required: number;
195
+ created_on: Date;
196
+ }
197
+ interface IUserRedeemRewardPointsRecord {
198
+ user_id: Schema.Types.ObjectId;
199
+ reward_points_redeem_id: Schema.Types.ObjectId;
200
+ discount_code: string;
201
+ created_on: Date;
202
+ }
203
+ interface IIntermediateUserOrderReward {
204
+ email: string;
205
+ order_id: number;
206
+ price: number;
207
+ status: number;
208
+ created_on: Date;
209
+ }
175
210
  type SimpleModel$3<T> = Model<T, {}, {}, {}>;
176
211
  interface UserModels {
177
212
  User: UserModel;
@@ -183,6 +218,11 @@ interface UserModels {
183
218
  UserEmailStatus: SimpleModel$3<IUserEmailStatus>;
184
219
  UserToken: UserTokenModel;
185
220
  UserFollow: SimpleModel$3<IUserFollow>;
221
+ UserPoints: SimpleModel$3<IUserPoints>;
222
+ UserRewardHistory: SimpleModel$3<IUserRewardHistory>;
223
+ RewardPointsRedeemList: SimpleModel$3<IRewardPointsRedeemList>;
224
+ UserRedeemRewardPointsRecord: SimpleModel$3<IUserRedeemRewardPointsRecord>;
225
+ IntermediateUserOrderReward: SimpleModel$3<IIntermediateUserOrderReward>;
186
226
  }
187
227
  //#endregion
188
228
  //#region src/models/banks.d.ts
@@ -1291,4 +1331,4 @@ type DemoUserTrackerDoc = HydratedDocument<IDemoUserTracker>;
1291
1331
  type RegistryType = "account" | "hardware" | undefined;
1292
1332
  declare function register(mongoose: Mongoose, type?: RegistryType): void;
1293
1333
  //#endregion
1294
- export { type AccessTokenModel, type ActivationStatusModel, type AdditionalPurchaseModel, AuthError, type AuthorizationCodeDoc, type AuthorizationCodeModel, type B2bDealerModel, type B2bRedeemModel, type B2bRedeemOrderModel, type BankListDoc, type BankListModel, type BankPresetsDoc, type BankPresetsModel, type BanksModels, type BcCartUpdateStatusModel, type CAMPAIGN_TYPE, type CnCouponDoc, type CnCouponMethods, type CnCouponModel, type CnSalesMetaModel, type CountryHardwareSkuModel, type CrashDataModel, type DataSourceType, type DemoUserTrackerDoc, type DemoUserTrackerModel, type DeviceDoc, type DeviceModel, type DeviceModels, type FLAG_EMAIL_EVENTS, type FeaturedListDoc, type FeaturedListModel, type FeaturedListModels, type FeaturedPresetModel, type GenericDataModel, type HardwareActivationConflictModel, type HardwareActivationMetaModel, type HardwareActivationRecordModel, type HardwareModels, type HardwareSeriesNumberModel, type HomeConfigDoc, type HomeConfigModel, type IAccessToken, type IActionButton, type IActivationStatus, type IApikey, type IAuthorizationCode, type IB2bDealer, type IB2bRedeem, type IB2bRedeemOrder, type IBankList, type IBankPresets, type ICampaignUserInfo, type ICnCoupon, type ICountryHardwareSku, type ICouponPromotion, type ICrashData, type IDataSource, type IDemoUserTracker, type IDevice, type IFeaturedList, type IFeaturedListVirtuals, type IFeaturedPreset, type IFreeTrial, type IGearTrialMeta, type IGearTrialRecord, type IGenericData, type IHardwareActivationConflict, type IHardwareActivationMeta, type IHardwareActivationRecord, type IHardwareSeriesNumber, type IHomeConfig, type IIapActivation, type IIapEvent, type IIasBuyOption, type IIasPromotion, type IIasStorePageMeta, type IItemInventoryHistory, type IKeyValue, type ILicense, type ILicenseCampaignMeta, type ILicenseCampaignRecord, type ILicenseVirtuals, type IOauthClient, type IOemRedeemPromotion, type IPartnerCoupon, type IPartnerRedeem, type IPartnerSalesHistory, type IPartnerSalesMeta, type IPgConfig, type IPgLogging, type IPreset, type IPresetVirtuals, type IProduct, type IPromotion, type IPublicAnnouncement, type IPublicAnnouncementFreeTrial, type IPublicAnnouncementUserList, type IPublicAnnouncementUserListLog, type IRedeemCode, type IRefreshToken, type ISection, type ISpecialOffer, type ITierSalesMeta, type ITierSalesRules, type IToneTheme, type IToneThemeFeaturedList, type IToneThemeVirtuals, type IUser, type IUserAddress, type IUserAuth, type IUserEmailStatus, type IUserFollow, type IUserMetadata, type IUserMethods, type IUserProduct, type IUserProductTracker, type IUserProfile, type IUserReferral, type IUserToken, type IUserVirtuals, type IWarehouseInventory, type IYotpoLoyalty, type IYotpoLoyaltyBackup, type IapActivationModel, type IapEventModel, type ItemInventoryHistoryModel, type KeyValueModel, type LICENSE_ADDITION, type LicenseAdditionKey, type LicenseDoc, type LicenseModel, type LicenseUpgradeMetaModel, type OEM_APOGEE_SUPPORT_LICENSE, type OEM_FOCUSRITE_SUPPORT_LICENSE, type OEM_PROMOTION_TYPE, type OEM_PROSONUS_SUPPORT_LICENSE, type OauthClientModel, type OauthModels, type OemRedeemPromotionModel, type PRODUCTS, type PURCHASE_ITEM_TYPE, type ParsedGenericSerialNumber, type ParsedSerialNumber, type ParsedSparkSerialNumber, type PartnerCouponModel, type PartnerModels, type PartnerRedeemModel, type PartnerSalesHistoryModel, type PartnerSalesMetaModel, type PaymentModels, type PgConfigDoc, type PgConfigModel, type PgConfigModels, type PgLoggingModel, type PresetCommentModel, type PresetDoc, type PresetLikeModel, type PresetModel, type PresetModels, type Product, type ProductModel, type PromotionModels, type PublicAnnouncementDoc, type PublicAnnouncementFreeTrialModel, type PublicAnnouncementModel, type PublicAnnouncementUserListModel, type RedeemCodeDoc, type RedeemCodeModel, type RefreshTokenModel, RegistryType, type SaveTrackInput, type SectionType, type SimpleModel, type ToneThemeDoc, type ToneThemeFeaturedListDoc, type ToneThemeFeaturedListModel, type ToneThemeModel, type UserDoc, type UserModel, type UserModels, type UserProductModel, type UserProfileDoc, type UserProfileModel, type UserTokenDoc, type UserTokenModel, type UserTrackModels, type WarehouseInventoryModel, type _buildLicenseTierQuery, type _buildPresetVersionQuery, type _buildSortQuery, type _filterKeyword, type _handlePresetVersion, type _identifyHardwareByModel, type _identifyItemTypeBySku, type _oemMetaToLicenseName, type _parseHardwareSerialNumber, type _parsePageParams, type _queryCompatibilityHandler, register as default, register };
1334
+ export { type AccessTokenModel, type ActivationStatusModel, type AdditionalPurchaseModel, AuthError, type AuthorizationCodeDoc, type AuthorizationCodeModel, type B2bDealerModel, type B2bRedeemModel, type B2bRedeemOrderModel, type BankListDoc, type BankListModel, type BankPresetsDoc, type BankPresetsModel, type BanksModels, type BcCartUpdateStatusModel, type CAMPAIGN_TYPE, type CnCouponDoc, type CnCouponMethods, type CnCouponModel, type CnSalesMetaModel, type CountryHardwareSkuModel, type CrashDataModel, type DataSourceType, type DemoUserTrackerDoc, type DemoUserTrackerModel, type DeviceDoc, type DeviceModel, type DeviceModels, type FLAG_EMAIL_EVENTS, type FeaturedListDoc, type FeaturedListModel, type FeaturedListModels, type FeaturedPresetModel, type GenericDataModel, type HardwareActivationConflictModel, type HardwareActivationMetaModel, type HardwareActivationRecordModel, type HardwareModels, type HardwareSeriesNumberModel, type HomeConfigDoc, type HomeConfigModel, type IAccessToken, type IActionButton, type IActivationStatus, type IApikey, type IAuthorizationCode, type IB2bDealer, type IB2bRedeem, type IB2bRedeemOrder, type IBankList, type IBankPresets, type ICampaignUserInfo, type ICnCoupon, type ICountryHardwareSku, type ICouponPromotion, type ICrashData, type IDataSource, type IDemoUserTracker, type IDevice, type IFeaturedList, type IFeaturedListVirtuals, type IFeaturedPreset, type IFreeTrial, type IGearTrialMeta, type IGearTrialRecord, type IGenericData, type IHardwareActivationConflict, type IHardwareActivationMeta, type IHardwareActivationRecord, type IHardwareSeriesNumber, type IHomeConfig, type IIapActivation, type IIapEvent, type IIasBuyOption, type IIasPromotion, type IIasStorePageMeta, type IIntermediateUserOrderReward, type IItemInventoryHistory, type IKeyValue, type ILicense, type ILicenseCampaignMeta, type ILicenseCampaignRecord, type ILicenseVirtuals, type IOauthClient, type IOemRedeemPromotion, type IPartnerCoupon, type IPartnerRedeem, type IPartnerSalesHistory, type IPartnerSalesMeta, type IPgConfig, type IPgLogging, type IPreset, type IPresetVirtuals, type IProduct, type IPromotion, type IPublicAnnouncement, type IPublicAnnouncementFreeTrial, type IPublicAnnouncementUserList, type IPublicAnnouncementUserListLog, type IRedeemCode, type IRefreshToken, type IRewardPointsRedeemList, type ISection, type ISpecialOffer, type ITierSalesMeta, type ITierSalesRules, type IToneTheme, type IToneThemeFeaturedList, type IToneThemeVirtuals, type IUser, type IUserAddress, type IUserAuth, type IUserEmailStatus, type IUserFollow, type IUserMetadata, type IUserMethods, type IUserPoints, type IUserProduct, type IUserProductTracker, type IUserProfile, type IUserRedeemRewardPointsRecord, type IUserReferral, type IUserRewardHistory, type IUserToken, type IUserVirtuals, type IWarehouseInventory, type IYotpoLoyalty, type IYotpoLoyaltyBackup, type IapActivationModel, type IapEventModel, type ItemInventoryHistoryModel, type KeyValueModel, type LICENSE_ADDITION, type LicenseAdditionKey, type LicenseDoc, type LicenseModel, type LicenseUpgradeMetaModel, type OEM_APOGEE_SUPPORT_LICENSE, type OEM_FOCUSRITE_SUPPORT_LICENSE, type OEM_PROMOTION_TYPE, type OEM_PROSONUS_SUPPORT_LICENSE, type OauthClientModel, type OauthModels, type OemRedeemPromotionModel, type PRODUCTS, type PURCHASE_ITEM_TYPE, type ParsedGenericSerialNumber, type ParsedSerialNumber, type ParsedSparkSerialNumber, type PartnerCouponModel, type PartnerModels, type PartnerRedeemModel, type PartnerSalesHistoryModel, type PartnerSalesMetaModel, type PaymentModels, type PgConfigDoc, type PgConfigModel, type PgConfigModels, type PgLoggingModel, type PresetCommentModel, type PresetDoc, type PresetLikeModel, type PresetModel, type PresetModels, type Product, type ProductModel, type PromotionModels, type PublicAnnouncementDoc, type PublicAnnouncementFreeTrialModel, type PublicAnnouncementModel, type PublicAnnouncementUserListModel, type RedeemCodeDoc, type RedeemCodeModel, type RefreshTokenModel, RegistryType, type SaveTrackInput, type SectionType, type SimpleModel, type ToneThemeDoc, type ToneThemeFeaturedListDoc, type ToneThemeFeaturedListModel, type ToneThemeModel, type UserDoc, type UserModel, type UserModels, type UserProductModel, type UserProfileDoc, type UserProfileModel, type UserTokenDoc, type UserTokenModel, type UserTrackModels, type WarehouseInventoryModel, type _buildLicenseTierQuery, type _buildPresetVersionQuery, type _buildSortQuery, type _filterKeyword, type _handlePresetVersion, type _identifyHardwareByModel, type _identifyItemTypeBySku, type _oemMetaToLicenseName, type _parseHardwareSerialNumber, type _parsePageParams, type _queryCompatibilityHandler, register as default, register };
package/dist/index.mjs CHANGED
@@ -4729,6 +4729,137 @@ function buildUser(mongoose) {
4729
4729
  follow_platform: 1,
4730
4730
  follow_user_id: 1
4731
4731
  }, { unique: true });
4732
+ const UserPointsSchema = new Schema({
4733
+ user_id: {
4734
+ type: ObjectId,
4735
+ ref: "User",
4736
+ required: true
4737
+ },
4738
+ points: {
4739
+ type: Number,
4740
+ default: 0,
4741
+ min: 0
4742
+ },
4743
+ lifetime_earned: {
4744
+ type: Number,
4745
+ default: 0,
4746
+ min: 0
4747
+ },
4748
+ created_on: {
4749
+ type: Date,
4750
+ default: Date.now
4751
+ },
4752
+ updated_on: {
4753
+ type: Date,
4754
+ default: Date.now
4755
+ }
4756
+ }, { collection: "user_points" });
4757
+ UserPointsSchema.index({ user_id: 1 }, { unique: true });
4758
+ const UserRewardHistorySchema = new Schema({
4759
+ user_point_id: {
4760
+ type: ObjectId,
4761
+ ref: "UserPoints",
4762
+ required: true
4763
+ },
4764
+ point_change: {
4765
+ type: Number,
4766
+ required: true
4767
+ },
4768
+ event: {
4769
+ type: String,
4770
+ required: true
4771
+ },
4772
+ created_on: {
4773
+ type: Date,
4774
+ default: Date.now
4775
+ },
4776
+ updated_on: {
4777
+ type: Date,
4778
+ default: Date.now
4779
+ }
4780
+ }, { collection: "user_reward_history" });
4781
+ UserRewardHistorySchema.index({
4782
+ user_point_id: 1,
4783
+ event: 1
4784
+ }, { unique: true });
4785
+ const RewardPointsRedeemListSchema = new Schema({
4786
+ name: {
4787
+ type: String,
4788
+ required: true
4789
+ },
4790
+ description: { type: String },
4791
+ skus: {
4792
+ type: [String],
4793
+ default: []
4794
+ },
4795
+ discount_percent: {
4796
+ type: Number,
4797
+ required: true
4798
+ },
4799
+ points_required: {
4800
+ type: Number,
4801
+ required: true,
4802
+ min: 0
4803
+ },
4804
+ created_on: {
4805
+ type: Date,
4806
+ default: Date.now
4807
+ }
4808
+ }, { collection: "reward_points_redeem_list" });
4809
+ const UserRedeemRewardPointsRecordSchema = new Schema({
4810
+ user_id: {
4811
+ type: ObjectId,
4812
+ ref: "User",
4813
+ required: true
4814
+ },
4815
+ reward_points_redeem_id: {
4816
+ type: ObjectId,
4817
+ ref: "RewardPointsRedeemList",
4818
+ required: true
4819
+ },
4820
+ discount_code: {
4821
+ type: String,
4822
+ required: true
4823
+ },
4824
+ created_on: {
4825
+ type: Date,
4826
+ default: Date.now
4827
+ }
4828
+ }, { collection: "user_redeem_reward_points_record" });
4829
+ UserRedeemRewardPointsRecordSchema.index({
4830
+ user_id: 1,
4831
+ created_on: -1
4832
+ });
4833
+ const IntermediateUserOrderRewardSchema = new Schema({
4834
+ email: {
4835
+ type: String,
4836
+ required: true,
4837
+ lowercase: true,
4838
+ trim: true
4839
+ },
4840
+ order_id: {
4841
+ type: Number,
4842
+ required: true
4843
+ },
4844
+ price: {
4845
+ type: Number,
4846
+ required: true,
4847
+ min: 0
4848
+ },
4849
+ status: {
4850
+ type: Number,
4851
+ default: 1
4852
+ },
4853
+ created_on: {
4854
+ type: Date,
4855
+ default: Date.now
4856
+ }
4857
+ }, { collection: "intermediate_user_order_reward" });
4858
+ IntermediateUserOrderRewardSchema.index({
4859
+ email: 1,
4860
+ order_id: 1
4861
+ }, { unique: true });
4862
+ IntermediateUserOrderRewardSchema.index({ status: 1 });
4732
4863
  UserSchema.method({
4733
4864
  authenticate(plainText) {
4734
4865
  const passwordArr = this.password.split("$");
@@ -5014,7 +5145,12 @@ function buildUser(mongoose) {
5014
5145
  UserReferral: mongoose.model("UserReferral", UserReferralSchema),
5015
5146
  UserEmailStatus: mongoose.model("UserEmailStatus", UserEmailStatusSchema),
5016
5147
  UserToken: mongoose.model("UserToken", UserTokenSchema),
5017
- UserFollow: mongoose.model("UserFollow", UserFollowSchema)
5148
+ UserFollow: mongoose.model("UserFollow", UserFollowSchema),
5149
+ UserPoints: mongoose.model("UserPoints", UserPointsSchema),
5150
+ UserRewardHistory: mongoose.model("UserRewardHistory", UserRewardHistorySchema),
5151
+ RewardPointsRedeemList: mongoose.model("RewardPointsRedeemList", RewardPointsRedeemListSchema),
5152
+ UserRedeemRewardPointsRecord: mongoose.model("UserRedeemRewardPointsRecord", UserRedeemRewardPointsRecordSchema),
5153
+ IntermediateUserOrderReward: mongoose.model("IntermediateUserOrderReward", IntermediateUserOrderRewardSchema)
5018
5154
  };
5019
5155
  }
5020
5156
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@positivegrid/pg-mongoose-schema",
3
- "version": "28.0.0-beta.4",
3
+ "version": "28.0.0-beta.6",
4
4
  "description": "Positive Grid mongoose schema",
5
5
  "author": "Ferrari Lee <shiyung@positivegrid.com>",
6
6
  "homepage": "https://git.positivegrid.com:8443/backend/pg-mongoose-schema",