@lyxa.ai/core 1.0.75 → 1.0.77

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.
@@ -2,6 +2,6 @@ import { OrderFinance } from './order-finance.model';
2
2
  import { CourierOrderProfit } from '../embedded/profit.model';
3
3
  import { OrderPricing } from './order-pricing.model';
4
4
  export declare class CourierOrderFinance extends OrderFinance {
5
- pricing?: OrderPricing;
5
+ pricing: OrderPricing;
6
6
  companyProfit?: CourierOrderProfit;
7
7
  }
@@ -20,7 +20,7 @@ class CourierOrderFinance extends order_finance_model_1.OrderFinance {
20
20
  }
21
21
  exports.CourierOrderFinance = CourierOrderFinance;
22
22
  __decorate([
23
- (0, typegoose_1.prop)({ type: () => order_pricing_model_1.OrderPricing }),
23
+ (0, typegoose_1.prop)({ required: true, type: () => order_pricing_model_1.OrderPricing }),
24
24
  __metadata("design:type", order_pricing_model_1.OrderPricing)
25
25
  ], CourierOrderFinance.prototype, "pricing", void 0);
26
26
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"courier-order-finance.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/courier-order-finance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,+DAAqD;AACrD,2DAA8D;AAC9D,+DAAqD;AAErD,MAAa,mBAAoB,SAAQ,kCAAY;IAE7C,OAAO,CAAgB;IAGvB,aAAa,CAAsB;CAC1C;AAND,kDAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BAClB,kCAAY;oDAAC;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iCAAkB,EAAE,CAAC;8BAClB,iCAAkB;0DAAC","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { OrderFinance } from './order-finance.model';\nimport { CourierOrderProfit } from '../embedded/profit.model';\nimport { OrderPricing } from './order-pricing.model';\n\nexport class CourierOrderFinance extends OrderFinance {\n\t@prop({ type: () => OrderPricing })\n\tpublic pricing?: OrderPricing;\n\n\t@prop({ type: () => CourierOrderProfit })\n\tpublic companyProfit?: CourierOrderProfit;\n}\n"]}
1
+ {"version":3,"file":"courier-order-finance.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/courier-order-finance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,+DAAqD;AACrD,2DAA8D;AAC9D,+DAAqD;AAErD,MAAa,mBAAoB,SAAQ,kCAAY;IAE7C,OAAO,CAAe;IAGtB,aAAa,CAAsB;CAC1C;AAND,kDAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACnC,kCAAY;oDAAC;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iCAAkB,EAAE,CAAC;8BAClB,iCAAkB;0DAAC","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { OrderFinance } from './order-finance.model';\nimport { CourierOrderProfit } from '../embedded/profit.model';\nimport { OrderPricing } from './order-pricing.model';\n\nexport class CourierOrderFinance extends OrderFinance {\n\t@prop({ required: true, type: () => OrderPricing })\n\tpublic pricing: OrderPricing;\n\n\t@prop({ type: () => CourierOrderProfit })\n\tpublic companyProfit?: CourierOrderProfit;\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  export declare class OrderPricing {
2
- subtotal?: number;
2
+ subtotal: number;
3
3
  secondarySubtotal?: number;
4
- deliveryFee?: number;
4
+ deliveryFee: number;
5
5
  secondaryDeliveryFee?: number;
6
6
  riderTips?: number;
7
7
  secondaryRiderTips?: number;
8
- total?: number;
8
+ total: number;
9
9
  secondaryTotal?: number;
10
10
  wallet?: number;
11
11
  secondaryWallet?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"order-pric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AAE,CAAC;;mEACH;AAGhC;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;4EACM","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tsubtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondarySubtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tdeliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryDeliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\triderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryRiderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\ttotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryTotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\twallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpaidAmount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryPaidAmount?: number;\n}\n\nexport class RegularOrderPricing extends OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tdiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tloyaltyPointDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryLoyaltyPointDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tcouponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryCouponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpunchMarketingDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryPunchMarketingDiscount?: number;\n}\n"]}
1
+ {"version":3,"file":"order-pricing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/order-pricing.model.ts"],"names":[],"mappings":";;;;;;;;;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,OAAO,EAAE,CAAC,EAAE,CAAC;;4EACM","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tsubtotal: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondarySubtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tdeliveryFee: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryDeliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\triderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryRiderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\ttotal: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryTotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\twallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpaidAmount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryPaidAmount?: number;\n}\n\nexport class RegularOrderPricing extends OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tdiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tloyaltyPointDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryLoyaltyPointDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tcouponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryCouponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpunchMarketingDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryPunchMarketingDiscount?: number;\n}\n"]}
@@ -4,7 +4,7 @@ import { Vat } from '../embedded/vat.model';
4
4
  import { CouponDetails, LoyaltyPoint, MarketingCut } from '../embedded/marketing-cut.model';
5
5
  import { RegularOrderPricing } from './order-pricing.model';
6
6
  export declare class RegularOrderFinance extends OrderFinance {
7
- pricing?: RegularOrderPricing;
7
+ pricing: RegularOrderPricing;
8
8
  companyProfit?: RegularOrderProfit;
9
9
  shopProfit?: RegularOrderProfit;
10
10
  vat?: Vat;
@@ -31,7 +31,7 @@ class RegularOrderFinance extends order_finance_model_1.OrderFinance {
31
31
  }
32
32
  exports.RegularOrderFinance = RegularOrderFinance;
33
33
  __decorate([
34
- (0, typegoose_1.prop)({ type: () => order_pricing_model_1.RegularOrderPricing }),
34
+ (0, typegoose_1.prop)({ required: true, type: () => order_pricing_model_1.RegularOrderPricing }),
35
35
  __metadata("design:type", order_pricing_model_1.RegularOrderPricing)
36
36
  ], RegularOrderFinance.prototype, "pricing", void 0);
37
37
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"regular-order-finance.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/regular-order-finance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,+DAAqD;AACrD,2DAA8D;AAC9D,qDAA4C;AAC5C,yEAA4F;AAC5F,+DAA4D;AAE5D,MAAa,mBAAoB,SAAQ,kCAAY;IAE7C,OAAO,CAAuB;IAG9B,aAAa,CAAsB;IAGnC,UAAU,CAAsB;IAGhC,GAAG,CAAO;IAGV,QAAQ,CAAgB;IAGxB,QAAQ,CAAgB;IAGxB,YAAY,CAAgB;IAG5B,MAAM,CAAiB;IAGvB,YAAY,CAAgB;IAG5B,gBAAgB,CAAgB;IAGhC,WAAW,CAAgB;CAClC;AAjCD,kDAiCC;AA/BO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,yCAAmB,EAAE,CAAC;8BACzB,yCAAmB;oDAAC;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iCAAkB,EAAE,CAAC;8BAClB,iCAAkB;0DAAC;AAGnC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iCAAkB,EAAE,CAAC;8BACrB,iCAAkB;uDAAC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,eAAG,EAAE,CAAC;8BACb,eAAG;gDAAC;AAGV;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACjB,kCAAY;qDAAC;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACjB,kCAAY;qDAAC;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACb,kCAAY;yDAAC;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,mCAAa,EAAE,CAAC;8BACpB,mCAAa;mDAAC;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACb,kCAAY;yDAAC;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACT,kCAAY;6DAAC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACd,kCAAY;wDAAC","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { OrderFinance } from './order-finance.model';\nimport { RegularOrderProfit } from '../embedded/profit.model';\nimport { Vat } from '../embedded/vat.model';\nimport { CouponDetails, LoyaltyPoint, MarketingCut } from '../embedded/marketing-cut.model';\nimport { RegularOrderPricing } from './order-pricing.model';\n\nexport class RegularOrderFinance extends OrderFinance {\n\t@prop({ type: () => RegularOrderPricing })\n\tpublic pricing?: RegularOrderPricing;\n\t\n\t@prop({ type: () => RegularOrderProfit })\n\tpublic companyProfit?: RegularOrderProfit;\n\n\t@prop({ type: () => RegularOrderProfit })\n\tpublic shopProfit?: RegularOrderProfit;\n\n\t@prop({ type: () => Vat })\n\tpublic vat?: Vat;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic discount?: MarketingCut;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic buy1get1?: MarketingCut;\n\n\t@prop({ type: () => LoyaltyPoint })\n\tpublic loyaltyPoint?: LoyaltyPoint;\n\n\t@prop({ type: () => CouponDetails })\n\tpublic coupon?: CouponDetails;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic freeDelivery?: MarketingCut;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic replacementOrder?: MarketingCut;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic endorseLoss?: MarketingCut;\n}\n"]}
1
+ {"version":3,"file":"regular-order-finance.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/regular-order-finance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,+DAAqD;AACrD,2DAA8D;AAC9D,qDAA4C;AAC5C,yEAA4F;AAC5F,+DAA4D;AAE5D,MAAa,mBAAoB,SAAQ,kCAAY;IAE7C,OAAO,CAAsB;IAG7B,aAAa,CAAsB;IAGnC,UAAU,CAAsB;IAGhC,GAAG,CAAO;IAGV,QAAQ,CAAgB;IAGxB,QAAQ,CAAgB;IAGxB,YAAY,CAAgB;IAG5B,MAAM,CAAiB;IAGvB,YAAY,CAAgB;IAG5B,gBAAgB,CAAgB;IAGhC,WAAW,CAAgB;CAClC;AAjCD,kDAiCC;AA/BO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,yCAAmB,EAAE,CAAC;8BAC1C,yCAAmB;oDAAC;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iCAAkB,EAAE,CAAC;8BAClB,iCAAkB;0DAAC;AAGnC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iCAAkB,EAAE,CAAC;8BACrB,iCAAkB;uDAAC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,eAAG,EAAE,CAAC;8BACb,eAAG;gDAAC;AAGV;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACjB,kCAAY;qDAAC;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACjB,kCAAY;qDAAC;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACb,kCAAY;yDAAC;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,mCAAa,EAAE,CAAC;8BACpB,mCAAa;mDAAC;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACb,kCAAY;yDAAC;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACT,kCAAY;6DAAC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;8BACd,kCAAY;wDAAC","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { OrderFinance } from './order-finance.model';\nimport { RegularOrderProfit } from '../embedded/profit.model';\nimport { Vat } from '../embedded/vat.model';\nimport { CouponDetails, LoyaltyPoint, MarketingCut } from '../embedded/marketing-cut.model';\nimport { RegularOrderPricing } from './order-pricing.model';\n\nexport class RegularOrderFinance extends OrderFinance {\n\t@prop({ required: true, type: () => RegularOrderPricing })\n\tpublic pricing: RegularOrderPricing;\n\t\n\t@prop({ type: () => RegularOrderProfit })\n\tpublic companyProfit?: RegularOrderProfit;\n\n\t@prop({ type: () => RegularOrderProfit })\n\tpublic shopProfit?: RegularOrderProfit;\n\n\t@prop({ type: () => Vat })\n\tpublic vat?: Vat;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic discount?: MarketingCut;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic buy1get1?: MarketingCut;\n\n\t@prop({ type: () => LoyaltyPoint })\n\tpublic loyaltyPoint?: LoyaltyPoint;\n\n\t@prop({ type: () => CouponDetails })\n\tpublic coupon?: CouponDetails;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic freeDelivery?: MarketingCut;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic replacementOrder?: MarketingCut;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic endorseLoss?: MarketingCut;\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { Schema, Model } from 'mongoose';
2
2
  import { ReturnModelType, mongoose } from '@typegoose/typegoose';
3
3
  import { AnyParamConstructor } from '@typegoose/typegoose/lib/types';
4
+ import { GetByIdInputDTO } from '../../../utilities/validation';
4
5
  export interface SoftDeleteModel<T> extends Model<T> {
5
6
  softDelete(_id: mongoose.Types.ObjectId): Promise<any>;
6
7
  softDeleteOne(filter: object): Promise<any>;
@@ -12,6 +13,7 @@ export interface SoftDeleteModel<T> extends Model<T> {
12
13
  restoreMany(filter?: object): Promise<any>;
13
14
  findWithDeleted(filter?: object): any;
14
15
  findDeleted(filter?: object): any;
16
+ findRecordById(data: GetByIdInputDTO): Promise<any>;
15
17
  }
16
18
  export declare class SoftDeleteBase {
17
19
  deletedAt?: Date | null;
@@ -106,6 +106,17 @@ class SoftDelete {
106
106
  schema.statics.findDeleted = function (filter = {}) {
107
107
  return this.find({ ...filter, deletedAt: { $ne: null } });
108
108
  };
109
+ schema.statics.findRecordById = async function (data) {
110
+ const { _id, select, populate } = data;
111
+ let result = this.findById(_id);
112
+ if (select) {
113
+ result = result.select(select);
114
+ }
115
+ if (populate) {
116
+ result = result.populate(populate);
117
+ }
118
+ return await result.exec();
119
+ };
109
120
  }
110
121
  }
111
122
  exports.SoftDelete = SoftDelete;
@@ -1 +1 @@
1
- {"version":3,"file":"soft-delete-plugin.js","sourceRoot":"/","sources":["libraries/mongo/plugins/soft-delete-plugin.ts"],"names":[],"mappings":";;;AACA,oDAAmF;AAsBnF,MAAa,cAAc;IAC1B,SAAS,CAAe;CACxB;AAFD,wCAEC;AAKD,MAAa,UAAU;IAKf,MAAM,CAAC,aAAa,CAAC,MAAc;QAEzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC;gBACV,SAAS,EAAE;oBACV,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,IAAI;iBACX;aACD,CAAC,CAAC;QACJ,CAAC;QAGD,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAGhC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAGhC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAKM,MAAM,CAAC,aAAa;QAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACrC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,CAAC;IAOM,MAAM,CAAC,WAAW,CACxB,UAAkC;QAElC,MAAM,KAAK,GAAG,IAAA,4BAAgB,EAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,KAAY,CAAC;IACrB,CAAC;IAMO,MAAM,CAAC,kBAAkB,CAAC,MAAc;QAC/C,MAAM,eAAe,GAAG;YACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC;gBAChC,IAAI,CAAC,KAAK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AI,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC,CAAC;QAEF,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,UAAU,MAAM,GAAG,EAAE;YACjD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC;IACH,CAAC;CACD;AA3JD,gCA2JC;AAGM,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAQ,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAA9E,QAAA,gBAAgB,oBAA8D;AACpF,MAAM,qBAAqB,GAAG,GAAS,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;AAA/D,QAAA,qBAAqB,yBAA0C;AACrE,MAAM,qBAAqB,GAAG,CACpC,UAAkC,EAC6B,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAFzF,QAAA,qBAAqB,yBAEoE","sourcesContent":["import { Schema, Query, Model } from 'mongoose';\nimport { getModelForClass, ReturnModelType, mongoose } from '@typegoose/typegoose';\nimport { AnyParamConstructor } from '@typegoose/typegoose/lib/types';\n\n/**\n * Interface for models with soft delete capabilities\n */\nexport interface SoftDeleteModel<T> extends Model<T> {\n\tsoftDelete(_id: mongoose.Types.ObjectId): Promise<any>;\n\tsoftDeleteOne(filter: object): Promise<any>;\n\tsoftDeleteMany(filter?: object): Promise<any>;\n\tdeleteRecord(filter: object, softDelete: boolean): Promise<any>;\n\tdeleteRecords(filter: object, softDelete: boolean): Promise<any>;\n\trestore(_id: mongoose.Types.ObjectId): Promise<any>;\n\trestoreOne(filter: object): Promise<any>;\n\trestoreMany(filter?: object): Promise<any>;\n\tfindWithDeleted(filter?: object): any;\n\tfindDeleted(filter?: object): any;\n}\n\n/**\n * Base class for models with soft delete functionality\n */\nexport class SoftDeleteBase {\n\tdeletedAt?: Date | null;\n}\n\n/**\n * SoftDelete class providing soft deletion functionality for mongoose models\n */\nexport class SoftDelete {\n\t/**\n\t * Apply soft delete plugin to a specific schema\n\t * @param schema Mongoose schema to enhance with soft delete functionality\n\t */\n\tpublic static applyToSchema(schema: Schema): void {\n\t\t// Add deletedAt field if it doesn't exist\n\t\tif (!schema.path('deletedAt')) {\n\t\t\tschema.add({\n\t\t\t\tdeletedAt: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\tdefault: null,\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Add schema middleware\n\t\tthis.addQueryMiddleware(schema);\n\n\t\t// Add instance methods\n\t\tthis.addInstanceMethods(schema);\n\n\t\t// Add static methods\n\t\tthis.addStaticMethods(schema);\n\t}\n\n\t/**\n\t * Apply soft delete plugin globally to all mongoose schemas\n\t */\n\tpublic static applyGlobally(): void {\n\t\tconst mongoose = require('mongoose');\n\t\tmongoose.plugin((schema: Schema) => this.applyToSchema(schema));\n\t}\n\n\t/**\n\t * Create a model with soft delete capabilities and proper TypeScript types\n\t * @param modelClass The class to create a model from\n\t * @returns A model with soft delete functionality\n\t */\n\tpublic static createModel<T extends SoftDeleteBase>(\n\t\tmodelClass: AnyParamConstructor<T>\n\t): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> {\n\t\tconst model = getModelForClass(modelClass);\n\t\treturn model as any; // The plugin adds the methods, we just need to tell TypeScript they exist\n\t}\n\n\t/**\n\t * Add query middleware to filter out soft-deleted documents\n\t * @param schema Schema to add middleware to\n\t */\n\tprivate static addQueryMiddleware(schema: Schema): void {\n\t\tconst queryMiddleware = function (this: Query<any, any>) {\n\t\t\tif (!this.getQuery().deletedAt) {\n\t\t\t\tthis.where({ deletedAt: null });\n\t\t\t}\n\t\t};\n\n\t\t// Apply middleware to relevant query methods\n\t\tschema.pre('find', queryMiddleware);\n\t\tschema.pre('findOne', queryMiddleware);\n\t\tschema.pre('findOneAndUpdate', queryMiddleware);\n\t\tschema.pre('findOneAndDelete', queryMiddleware);\n\t\tschema.pre('findOneAndReplace', queryMiddleware);\n\t\tschema.pre('updateOne', queryMiddleware);\n\t\tschema.pre('updateMany', queryMiddleware);\n\t\t// TypeScript workaround for count hook\n\t\t(schema as any).pre('count', queryMiddleware);\n\t\tschema.pre('countDocuments', queryMiddleware);\n\t\t(schema as any).pre('exists', queryMiddleware);\n\n\t\t// Override findById to respect soft delete\n\t\tschema.statics.findById = function (_id: mongoose.Types.ObjectId, projection?: any, options?: any) {\n\t\t\treturn this.findOne({ _id, deletedAt: null }, projection, options);\n\t\t};\n\t}\n\n\t/**\n\t * Add instance methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addInstanceMethods(schema: Schema): void {\n\t\tschema.methods.softDelete = function () {\n\t\t\tthis.deletedAt = new Date();\n\t\t\treturn this.save();\n\t\t};\n\n\t\tschema.methods.restore = function () {\n\t\t\tthis.deletedAt = null;\n\t\t\treturn this.save();\n\t\t};\n\t}\n\n\t/**\n\t * Add static methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addStaticMethods(schema: Schema): void {\n\t\tschema.statics.softDelete = async function (_id: mongoose.Types.ObjectId) {\n\t\t\tconst result = await this.updateOne({ _id }, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteOne = async function (filter: object) {\n\t\t\tconst result = await this.updateOne(filter, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: new Date() });\n\t\t};\n\n\t\tschema.statics.deleteRecord = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateOne({ ...filter, deletedAt: null }, { deletedAt: new Date() }).lean();\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteOne(filter).lean();\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.deleteRecords = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateMany(\n\t\t\t\t\t{ ...filter, deletedAt: null },\n\t\t\t\t\t{ deletedAt: new Date() }\n\t\t\t\t).lean();\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteMany(filter).lean();\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.restore = function (_id: mongoose.Types.ObjectId) {\n\t\t\treturn this.updateOne({ _id }, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreOne = function (filter: object) {\n\t\t\treturn this.updateOne(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.findWithDeleted = function (filter = {}) {\n\t\t\treturn this.find(filter);\n\t\t};\n\n\t\tschema.statics.findDeleted = function (filter = {}) {\n\t\t\treturn this.find({ ...filter, deletedAt: { $ne: null } });\n\t\t};\n\t}\n}\n\n// Export convenience functions with the same names as before for backward compatibility\nexport const softDeletePlugin = (schema: Schema): void => SoftDelete.applyToSchema(schema);\nexport const applySoftDeletePlugin = (): void => SoftDelete.applyGlobally();\nexport const createSoftDeleteModel = <T extends SoftDeleteBase>(\n\tmodelClass: AnyParamConstructor<T>\n): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> => SoftDelete.createModel(modelClass);\n"]}
1
+ {"version":3,"file":"soft-delete-plugin.js","sourceRoot":"/","sources":["libraries/mongo/plugins/soft-delete-plugin.ts"],"names":[],"mappings":";;;AACA,oDAAmF;AAwBnF,MAAa,cAAc;IAC1B,SAAS,CAAe;CACxB;AAFD,wCAEC;AAKD,MAAa,UAAU;IAKf,MAAM,CAAC,aAAa,CAAC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AAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;YAEvC,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAEhC,IAAI,MAAM,EAAE,CAAC;gBACZ,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAQ,CAAC;YACvC,CAAC;YAED,IAAI,QAAQ,EAAE,CAAC;gBACd,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;YAED,OAAO,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5B,CAAC,CAAC;IACH,CAAC;CACD;AA3KD,gCA2KC;AAGM,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAQ,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAA9E,QAAA,gBAAgB,oBAA8D;AACpF,MAAM,qBAAqB,GAAG,GAAS,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;AAA/D,QAAA,qBAAqB,yBAA0C;AACrE,MAAM,qBAAqB,GAAG,CACpC,UAAkC,EAC6B,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAFzF,QAAA,qBAAqB,yBAEoE","sourcesContent":["import { Schema, Query, Model } from 'mongoose';\nimport { getModelForClass, ReturnModelType, mongoose } from '@typegoose/typegoose';\nimport { AnyParamConstructor } from '@typegoose/typegoose/lib/types';\nimport { GetByIdInputDTO } from '../../../utilities/validation';\n\n/**\n * Interface for models with soft delete capabilities\n */\nexport interface SoftDeleteModel<T> extends Model<T> {\n\tsoftDelete(_id: mongoose.Types.ObjectId): Promise<any>;\n\tsoftDeleteOne(filter: object): Promise<any>;\n\tsoftDeleteMany(filter?: object): Promise<any>;\n\tdeleteRecord(filter: object, softDelete: boolean): Promise<any>;\n\tdeleteRecords(filter: object, softDelete: boolean): Promise<any>;\n\trestore(_id: mongoose.Types.ObjectId): Promise<any>;\n\trestoreOne(filter: object): Promise<any>;\n\trestoreMany(filter?: object): Promise<any>;\n\tfindWithDeleted(filter?: object): any;\n\tfindDeleted(filter?: object): any;\n\tfindRecordById(data: GetByIdInputDTO): Promise<any>;\n}\n\n/**\n * Base class for models with soft delete functionality\n */\nexport class SoftDeleteBase {\n\tdeletedAt?: Date | null;\n}\n\n/**\n * SoftDelete class providing soft deletion functionality for mongoose models\n */\nexport class SoftDelete {\n\t/**\n\t * Apply soft delete plugin to a specific schema\n\t * @param schema Mongoose schema to enhance with soft delete functionality\n\t */\n\tpublic static applyToSchema(schema: Schema): void {\n\t\t// Add deletedAt field if it doesn't exist\n\t\tif (!schema.path('deletedAt')) {\n\t\t\tschema.add({\n\t\t\t\tdeletedAt: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\tdefault: null,\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Add schema middleware\n\t\tthis.addQueryMiddleware(schema);\n\n\t\t// Add instance methods\n\t\tthis.addInstanceMethods(schema);\n\n\t\t// Add static methods\n\t\tthis.addStaticMethods(schema);\n\t}\n\n\t/**\n\t * Apply soft delete plugin globally to all mongoose schemas\n\t */\n\tpublic static applyGlobally(): void {\n\t\tconst mongoose = require('mongoose');\n\t\tmongoose.plugin((schema: Schema) => this.applyToSchema(schema));\n\t}\n\n\t/**\n\t * Create a model with soft delete capabilities and proper TypeScript types\n\t * @param modelClass The class to create a model from\n\t * @returns A model with soft delete functionality\n\t */\n\tpublic static createModel<T extends SoftDeleteBase>(\n\t\tmodelClass: AnyParamConstructor<T>\n\t): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> {\n\t\tconst model = getModelForClass(modelClass);\n\t\treturn model as any; // The plugin adds the methods, we just need to tell TypeScript they exist\n\t}\n\n\t/**\n\t * Add query middleware to filter out soft-deleted documents\n\t * @param schema Schema to add middleware to\n\t */\n\tprivate static addQueryMiddleware(schema: Schema): void {\n\t\tconst queryMiddleware = function (this: Query<any, any>) {\n\t\t\tif (!this.getQuery().deletedAt) {\n\t\t\t\tthis.where({ deletedAt: null });\n\t\t\t}\n\t\t};\n\n\t\t// Apply middleware to relevant query methods\n\t\tschema.pre('find', queryMiddleware);\n\t\tschema.pre('findOne', queryMiddleware);\n\t\tschema.pre('findOneAndUpdate', queryMiddleware);\n\t\tschema.pre('findOneAndDelete', queryMiddleware);\n\t\tschema.pre('findOneAndReplace', queryMiddleware);\n\t\tschema.pre('updateOne', queryMiddleware);\n\t\tschema.pre('updateMany', queryMiddleware);\n\t\t// TypeScript workaround for count hook\n\t\t(schema as any).pre('count', queryMiddleware);\n\t\tschema.pre('countDocuments', queryMiddleware);\n\t\t(schema as any).pre('exists', queryMiddleware);\n\n\t\t// Override findById to respect soft delete\n\t\tschema.statics.findById = function (_id: mongoose.Types.ObjectId, projection?: any, options?: any) {\n\t\t\treturn this.findOne({ _id, deletedAt: null }, projection, options);\n\t\t};\n\t}\n\n\t/**\n\t * Add instance methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addInstanceMethods(schema: Schema): void {\n\t\tschema.methods.softDelete = function () {\n\t\t\tthis.deletedAt = new Date();\n\t\t\treturn this.save();\n\t\t};\n\n\t\tschema.methods.restore = function () {\n\t\t\tthis.deletedAt = null;\n\t\t\treturn this.save();\n\t\t};\n\t}\n\n\t/**\n\t * Add static methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addStaticMethods(schema: Schema): void {\n\t\tschema.statics.softDelete = async function (_id: mongoose.Types.ObjectId) {\n\t\t\tconst result = await this.updateOne({ _id }, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteOne = async function (filter: object) {\n\t\t\tconst result = await this.updateOne(filter, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: new Date() });\n\t\t};\n\n\t\tschema.statics.deleteRecord = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateOne({ ...filter, deletedAt: null }, { deletedAt: new Date() }).lean();\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteOne(filter).lean();\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.deleteRecords = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateMany(\n\t\t\t\t\t{ ...filter, deletedAt: null },\n\t\t\t\t\t{ deletedAt: new Date() }\n\t\t\t\t).lean();\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteMany(filter).lean();\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.restore = function (_id: mongoose.Types.ObjectId) {\n\t\t\treturn this.updateOne({ _id }, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreOne = function (filter: object) {\n\t\t\treturn this.updateOne(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.findWithDeleted = function (filter = {}) {\n\t\t\treturn this.find(filter);\n\t\t};\n\n\t\tschema.statics.findDeleted = function (filter = {}) {\n\t\t\treturn this.find({ ...filter, deletedAt: { $ne: null } });\n\t\t};\n\n\t\tschema.statics.findRecordById = async function (data: GetByIdInputDTO) {\n\t\t\tconst { _id, select, populate } = data;\n\n\t\t\tlet result = this.findById(_id);\n\n\t\t\tif (select) {\n\t\t\t\tresult = result.select(select) as any;\n\t\t\t}\n\n\t\t\tif (populate) {\n\t\t\t\tresult = result.populate(populate);\n\t\t\t}\n\n\t\t\treturn await result.exec();\n\t\t};\n\t}\n}\n\n// Export convenience functions with the same names as before for backward compatibility\nexport const softDeletePlugin = (schema: Schema): void => SoftDelete.applyToSchema(schema);\nexport const applySoftDeletePlugin = (): void => SoftDelete.applyGlobally();\nexport const createSoftDeleteModel = <T extends SoftDeleteBase>(\n\tmodelClass: AnyParamConstructor<T>\n): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> => SoftDelete.createModel(modelClass);\n"]}
@@ -754,3 +754,123 @@ export declare const DeleteSchema: z.ZodObject<{
754
754
  }>;
755
755
  export type DeleteDTO = DTO<typeof DeleteSchema>;
756
756
  export declare const IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
757
+ export declare const GetByIdInputSchema: z.ZodObject<{
758
+ _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
759
+ select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
760
+ populate: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
761
+ path: z.ZodString;
762
+ select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
763
+ match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
764
+ options: z.ZodOptional<z.ZodObject<{
765
+ sort: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<-1>]>>>;
766
+ limit: z.ZodOptional<z.ZodNumber>;
767
+ skip: z.ZodOptional<z.ZodNumber>;
768
+ }, "strip", z.ZodTypeAny, {
769
+ sort?: Record<string, 1 | -1> | undefined;
770
+ skip?: number | undefined;
771
+ limit?: number | undefined;
772
+ }, {
773
+ sort?: Record<string, 1 | -1> | undefined;
774
+ skip?: number | undefined;
775
+ limit?: number | undefined;
776
+ }>>;
777
+ }, "strip", z.ZodTypeAny, {
778
+ path: string;
779
+ match?: Record<string, any> | undefined;
780
+ select?: Record<string, 0 | 1> | undefined;
781
+ options?: {
782
+ sort?: Record<string, 1 | -1> | undefined;
783
+ skip?: number | undefined;
784
+ limit?: number | undefined;
785
+ } | undefined;
786
+ }, {
787
+ path: string;
788
+ match?: Record<string, any> | undefined;
789
+ select?: Record<string, 0 | 1> | undefined;
790
+ options?: {
791
+ sort?: Record<string, 1 | -1> | undefined;
792
+ skip?: number | undefined;
793
+ limit?: number | undefined;
794
+ } | undefined;
795
+ }>, z.ZodArray<z.ZodObject<{
796
+ path: z.ZodString;
797
+ select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>>;
798
+ match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
799
+ options: z.ZodOptional<z.ZodObject<{
800
+ sort: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<-1>]>>>;
801
+ limit: z.ZodOptional<z.ZodNumber>;
802
+ skip: z.ZodOptional<z.ZodNumber>;
803
+ }, "strip", z.ZodTypeAny, {
804
+ sort?: Record<string, 1 | -1> | undefined;
805
+ skip?: number | undefined;
806
+ limit?: number | undefined;
807
+ }, {
808
+ sort?: Record<string, 1 | -1> | undefined;
809
+ skip?: number | undefined;
810
+ limit?: number | undefined;
811
+ }>>;
812
+ }, "strip", z.ZodTypeAny, {
813
+ path: string;
814
+ match?: Record<string, any> | undefined;
815
+ select?: Record<string, 0 | 1> | undefined;
816
+ options?: {
817
+ sort?: Record<string, 1 | -1> | undefined;
818
+ skip?: number | undefined;
819
+ limit?: number | undefined;
820
+ } | undefined;
821
+ }, {
822
+ path: string;
823
+ match?: Record<string, any> | undefined;
824
+ select?: Record<string, 0 | 1> | undefined;
825
+ options?: {
826
+ sort?: Record<string, 1 | -1> | undefined;
827
+ skip?: number | undefined;
828
+ limit?: number | undefined;
829
+ } | undefined;
830
+ }>, "many">]>>;
831
+ }, "strip", z.ZodTypeAny, {
832
+ _id: import("mongoose").Types.ObjectId;
833
+ select?: Record<string, 0 | 1> | undefined;
834
+ populate?: {
835
+ path: string;
836
+ match?: Record<string, any> | undefined;
837
+ select?: Record<string, 0 | 1> | undefined;
838
+ options?: {
839
+ sort?: Record<string, 1 | -1> | undefined;
840
+ skip?: number | undefined;
841
+ limit?: number | undefined;
842
+ } | undefined;
843
+ } | {
844
+ path: string;
845
+ match?: Record<string, any> | undefined;
846
+ select?: Record<string, 0 | 1> | undefined;
847
+ options?: {
848
+ sort?: Record<string, 1 | -1> | undefined;
849
+ skip?: number | undefined;
850
+ limit?: number | undefined;
851
+ } | undefined;
852
+ }[] | undefined;
853
+ }, {
854
+ _id: string | import("mongoose").Types.ObjectId;
855
+ select?: Record<string, 0 | 1> | undefined;
856
+ populate?: {
857
+ path: string;
858
+ match?: Record<string, any> | undefined;
859
+ select?: Record<string, 0 | 1> | undefined;
860
+ options?: {
861
+ sort?: Record<string, 1 | -1> | undefined;
862
+ skip?: number | undefined;
863
+ limit?: number | undefined;
864
+ } | undefined;
865
+ } | {
866
+ path: string;
867
+ match?: Record<string, any> | undefined;
868
+ select?: Record<string, 0 | 1> | undefined;
869
+ options?: {
870
+ sort?: Record<string, 1 | -1> | undefined;
871
+ skip?: number | undefined;
872
+ limit?: number | undefined;
873
+ } | undefined;
874
+ }[] | undefined;
875
+ }>;
876
+ export type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IdSchema = exports.DeleteSchema = exports.UpdateSortingOrderSchema = exports.TokenSchema = exports.createResponseSchema = exports.createPaginatedSchema = exports.LoginSchema = exports.WorkHourSettingSchema = exports.HolidayHourSchema = exports.NormalHourSchema = exports.DurationSchema = exports.CourierAddressSchema = exports.UserAddressSchema = exports.AddressSchema = exports.StringSchema = exports.FilterSchema = void 0;
3
+ exports.GetByIdInputSchema = exports.IdSchema = exports.DeleteSchema = exports.UpdateSortingOrderSchema = exports.TokenSchema = exports.createResponseSchema = exports.createPaginatedSchema = exports.LoginSchema = exports.WorkHourSettingSchema = exports.HolidayHourSchema = exports.NormalHourSchema = exports.DurationSchema = exports.CourierAddressSchema = exports.UserAddressSchema = exports.AddressSchema = exports.StringSchema = exports.FilterSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const global_validation_1 = require("./global-validation");
6
6
  const enum_1 = require("../enum");
@@ -138,4 +138,9 @@ exports.DeleteSchema = zod_1.z.object({
138
138
  softDelete: global_validation_1.ZodValidation.boolean('Soft Delete').default(true),
139
139
  });
140
140
  exports.IdSchema = global_validation_1.ZodValidation.objectId();
141
+ exports.GetByIdInputSchema = zod_1.z.object({
142
+ _id: global_validation_1.ZodValidation.objectId('_id'),
143
+ select: zod_1.z.record(zod_1.z.string(), zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)])).optional(),
144
+ populate: zod_1.z.union([populateSchema, zod_1.z.array(populateSchema)]).optional(),
145
+ });
141
146
  //# sourceMappingURL=common-validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAmC;AACnC,2DAAyD;AACzD,kCAAkF;AAKlF,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACpE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAClD,CAAC;AAKF,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ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Y,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,GAAG,EAAE,iCAAa,CAAC,QAAQ,CAAC,KAAK,CAAC;IAClC,UAAU,EAAE,iCAAa,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;CAC9D,CAAC,CAAC;AAMU,QAAA,QAAQ,GAAG,iCAAa,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import { z, ZodSchema } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport { GeoLocationType, HolidayWorkStatus, WeekDay, WorkStatus } from '../enum';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema = z.object({\n\tpath: z.string(), // required\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tmatch: z.record(z.string(), z.any()).optional(),\n\toptions: z\n\t\t.object({\n\t\t\tsort: sortSchema.optional(),\n\t\t\tlimit: z.number().optional(),\n\t\t\tskip: z.number().optional(),\n\t\t})\n\t\t.optional(),\n});\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City'),\n\tstate: ZodValidation.string('State'),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\nconst StartEndTimeSchema = z.object({\n\tstart: ZodValidation.string('Start'),\n\tend: ZodValidation.string('End'),\n});\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema).default([]),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('newPosition'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n"]}
1
+ {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAmC;AACnC,2DAAyD;AACzD,kCAAkF;AAKlF,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACpE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAClD,CAAC;AAKF,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACxB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACxB,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;IAChC,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;IACjC,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAA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CAAC,CAAC,QAAQ,EAAE;CACvE,CAAC,CAAC","sourcesContent":["import { z, ZodSchema } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport { GeoLocationType, HolidayWorkStatus, WeekDay, WorkStatus } from '../enum';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema = z.object({\n\tpath: z.string(), // required\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tmatch: z.record(z.string(), z.any()).optional(),\n\toptions: z\n\t\t.object({\n\t\t\tsort: sortSchema.optional(),\n\t\t\tlimit: z.number().optional(),\n\t\t\tskip: z.number().optional(),\n\t\t})\n\t\t.optional(),\n});\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City'),\n\tstate: ZodValidation.string('State'),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\nconst StartEndTimeSchema = z.object({\n\tstart: ZodValidation.string('Start'),\n\tend: ZodValidation.string('End'),\n});\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema).default([]),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('newPosition'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n\n/**\n * Schema validation get by id\n */\nexport const GetByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\nexport type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.0.75",
3
+ "version": "1.0.77",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",