@lyxa.ai/core 1.1.36 → 1.1.39

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.
Files changed (32) hide show
  1. package/dist/libraries/mongo/models/cart.model.d.ts +0 -2
  2. package/dist/libraries/mongo/models/cart.model.js +0 -10
  3. package/dist/libraries/mongo/models/cart.model.js.map +1 -1
  4. package/dist/libraries/mongo/models/coupon.model.d.ts +2 -0
  5. package/dist/libraries/mongo/models/coupon.model.js +6 -0
  6. package/dist/libraries/mongo/models/coupon.model.js.map +1 -1
  7. package/dist/libraries/mongo/models/embedded/currency.model.d.ts +0 -1
  8. package/dist/libraries/mongo/models/embedded/currency.model.js +0 -5
  9. package/dist/libraries/mongo/models/embedded/currency.model.js.map +1 -1
  10. package/dist/libraries/mongo/models/user.model.d.ts +1 -1
  11. package/dist/types/README.md +1 -1
  12. package/dist/types/package.json +1 -1
  13. package/dist/types/utilities/shared/currency.d.ts +4 -1
  14. package/dist/types/utilities/shared/currency.js +17 -13
  15. package/dist/types/utilities/shared/currency.js.map +1 -1
  16. package/dist/types/utilities/validation/common-validation.d.ts +2 -78
  17. package/dist/types/utilities/validation/global-validation.d.ts +14 -38
  18. package/dist/utilities/currency.d.ts +2 -6
  19. package/dist/utilities/currency.js +14 -52
  20. package/dist/utilities/currency.js.map +1 -1
  21. package/dist/utilities/pipelines/common-pipeline-functions.d.ts +2 -5
  22. package/dist/utilities/pipelines/common-pipeline-functions.js +23 -19
  23. package/dist/utilities/pipelines/common-pipeline-functions.js.map +1 -1
  24. package/dist/utilities/pipelines/product-pipeline-stages.d.ts +2 -2
  25. package/dist/utilities/pipelines/product-pipeline-stages.js +21 -29
  26. package/dist/utilities/pipelines/product-pipeline-stages.js.map +1 -1
  27. package/dist/utilities/shared/currency.d.ts +4 -1
  28. package/dist/utilities/shared/currency.js +17 -13
  29. package/dist/utilities/shared/currency.js.map +1 -1
  30. package/dist/utilities/validation/common-validation.d.ts +2 -78
  31. package/dist/utilities/validation/global-validation.d.ts +14 -38
  32. package/package.json +1 -1
@@ -21,8 +21,6 @@ export declare class Cart extends TimeStamps {
21
21
  cartId: string;
22
22
  title?: string;
23
23
  exchangeRate?: number;
24
- roundTo?: number;
25
- secondaryRoundTo?: number;
26
24
  user: Ref<User>;
27
25
  parent: Ref<Parent>;
28
26
  shop: Ref<Shop>;
@@ -68,8 +68,6 @@ let Cart = class Cart extends defaultClasses_1.TimeStamps {
68
68
  cartId;
69
69
  title;
70
70
  exchangeRate;
71
- roundTo;
72
- secondaryRoundTo;
73
71
  user;
74
72
  parent;
75
73
  shop;
@@ -95,14 +93,6 @@ __decorate([
95
93
  (0, typegoose_1.prop)({ type: Number, default: 0 }),
96
94
  __metadata("design:type", Number)
97
95
  ], Cart.prototype, "exchangeRate", void 0);
98
- __decorate([
99
- (0, typegoose_1.prop)({ type: Number, default: 0.01 }),
100
- __metadata("design:type", Number)
101
- ], Cart.prototype, "roundTo", void 0);
102
- __decorate([
103
- (0, typegoose_1.prop)({ type: Number, default: 1000 }),
104
- __metadata("design:type", Number)
105
- ], Cart.prototype, "secondaryRoundTo", void 0);
106
96
  __decorate([
107
97
  (0, typegoose_1.prop)({ required: true, ref: () => user_model_1.User }),
108
98
  __metadata("design:type", Object)
@@ -1 +1 @@
1
- {"version":3,"file":"cart.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cart.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAqF;AACrF,6CAAoC;AACpC,iDAAwC;AACxC,4EAAqE;AACrE,kDAA8F;AAC9F,0DAAsE;AAEtE,6CAAoC;AACpC,uDAA6C;AAC7C,kEAAwE;AACxE,wBAA8B;AAC9B,0DAAiD;AAEjD,MAAa,QAAQ;IAEb,IAAI,CAAU;IAGd,UAAU,CAAc;IAGxB,MAAM,CAAU;IAGhB,QAAQ,CAAY;IAGpB,OAAO,CAAW;IAGlB,IAAI,CAAU;IAGd,cAAc,CAAW;IAGzB,sBAAsB,CAAU;CACv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AAU,CAAC,MAAM,EAAE,iBAAU,CAAC,MAAM,CAAC,EAAE;YACvD,SAAS,EAAE,IAAI;SACf;KACD,CACD;IACA,IAAA,eAAG,EAAO,MAAM,EAAE,KAAK,WAAW,IAAI;QAEtC,MAAM,0CAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,YAAS,EAAE,QAAQ,CAAC,CAAC;QAE/D,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,IAAI,CAyDhB","sourcesContent":["import { prop, Ref, index, modelOptions, Severity, pre } from '@typegoose/typegoose';\nimport { Shop } from './shop.model';\nimport { Parent } from './parent.model';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CartStatus, ChargeType, ItemType, PaymentPreference } from '../../../utilities/enum';\nimport { Address, RegularOrderAddress } from './shared/address.model';\nimport { Coupon } from './coupon.model';\nimport { User } from './user.model';\nimport { LineItem } from './line-item.model';\nimport { handlePreSaveForUniqueId } from '../utilities/unique-id.hooks';\nimport { CartModel } from '.';\nimport { Charge } from './embedded/charge.model';\n\nexport class ShopSnap {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: String, enum: ChargeType, default: ChargeType.CUSTOM })\n\tpublic chargeType!: ChargeType;\n\n\t@prop({ required: true, type: Charge })\n\tpublic charge!: Charge;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ required: true, type: Address })\n\tpublic address!: Address;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isShopDelivery?: boolean;\n\n\t@prop({ type: Number, default: 10 })\n\tpublic defaultPreparationTime?: number;\n}\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'carts',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: {\n\t\tallowMixed: Severity.ALLOW,\n\t},\n})\n@index({ user: 1 })\n@index({ shop: 1 })\n@index({ status: 1 })\n@index(\n\t{ user: 1, shop: 1 },\n\t{\n\t\tunique: true,\n\t\tpartialFilterExpression: {\n\t\t\tstatus: { $in: [CartStatus.ACTIVE, CartStatus.LOCKED] },\n\t\t\tdeletedAt: null,\n\t\t},\n\t}\n)\n@pre<Cart>('save', async function (next) {\n\t// Generate unique id if not exists\n\tawait handlePreSaveForUniqueId.call(this, CartModel, 'cartId');\n\n\tnext();\n})\nexport class Cart extends TimeStamps {\n\t@prop({ type: String, unique: true, index: true })\n\tpublic cartId: string;\n\n\t@prop({ trim: true, maxlength: 100 })\n\tpublic title?: string;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic exchangeRate?: number;\n\n\t@prop({ type: Number, default: 0.01 })\n\tpublic roundTo?: number;\n\n\t@prop({ type: Number, default: 1000 })\n\tpublic secondaryRoundTo?: number;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ required: true, ref: () => Parent })\n\tpublic parent: Ref<Parent>;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ type: ShopSnap })\n\tpublic shopSnap?: ShopSnap;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isGroupOrder?: boolean;\n\n\t@prop({ type: String, enum: PaymentPreference })\n\tpublic paymentPreference?: PaymentPreference;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic spendingLimitForGuest?: number;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic secondarySpendingLimitForGuest?: number;\n\n\t@prop({\n\t\tenum: CartStatus,\n\t\ttype: String,\n\t\tdefault: CartStatus.ACTIVE,\n\t\trequired: true,\n\t})\n\tpublic status!: CartStatus;\n\n\t@prop({ type: String, trim: true })\n\tpublic couponCode?: string;\n\n\t@prop({\n\t\tref: () => LineItem,\n\t\tforeignField: 'cart',\n\t\tlocalField: '_id',\n\t})\n\tpublic lineItems: Ref<LineItem>[];\n}\n"]}
1
+ {"version":3,"file":"cart.model.js","sourceRoot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A,iBAAK,EACL,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EACpB;QACC,MAAM,EAAE,IAAI;QACZ,uBAAuB,EAAE;YACxB,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,iBAAU,CAAC,MAAM,EAAE,iBAAU,CAAC,MAAM,CAAC,EAAE;YACvD,SAAS,EAAE,IAAI;SACf;KACD,CACD;IACA,IAAA,eAAG,EAAO,MAAM,EAAE,KAAK,WAAW,IAAI;QAEtC,MAAM,0CAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,YAAS,EAAE,QAAQ,CAAC,CAAC;QAE/D,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,IAAI,CAmDhB","sourcesContent":["import { prop, Ref, index, modelOptions, Severity, pre } from '@typegoose/typegoose';\nimport { Shop } from './shop.model';\nimport { Parent } from './parent.model';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CartStatus, ChargeType, ItemType, PaymentPreference } from '../../../utilities/enum';\nimport { Address, RegularOrderAddress } from './shared/address.model';\nimport { Coupon } from './coupon.model';\nimport { User } from './user.model';\nimport { LineItem } from './line-item.model';\nimport { handlePreSaveForUniqueId } from '../utilities/unique-id.hooks';\nimport { CartModel } from '.';\nimport { Charge } from './embedded/charge.model';\n\nexport class ShopSnap {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: String, enum: ChargeType, default: ChargeType.CUSTOM })\n\tpublic chargeType!: ChargeType;\n\n\t@prop({ required: true, type: Charge })\n\tpublic charge!: Charge;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ required: true, type: Address })\n\tpublic address!: Address;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isShopDelivery?: boolean;\n\n\t@prop({ type: Number, default: 10 })\n\tpublic defaultPreparationTime?: number;\n}\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'carts',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: {\n\t\tallowMixed: Severity.ALLOW,\n\t},\n})\n@index({ user: 1 })\n@index({ shop: 1 })\n@index({ status: 1 })\n@index(\n\t{ user: 1, shop: 1 },\n\t{\n\t\tunique: true,\n\t\tpartialFilterExpression: {\n\t\t\tstatus: { $in: [CartStatus.ACTIVE, CartStatus.LOCKED] },\n\t\t\tdeletedAt: null,\n\t\t},\n\t}\n)\n@pre<Cart>('save', async function (next) {\n\t// Generate unique id if not exists\n\tawait handlePreSaveForUniqueId.call(this, CartModel, 'cartId');\n\n\tnext();\n})\nexport class Cart extends TimeStamps {\n\t@prop({ type: String, unique: true, index: true })\n\tpublic cartId: string;\n\n\t@prop({ trim: true, maxlength: 100 })\n\tpublic title?: string;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic exchangeRate?: number;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ required: true, ref: () => Parent })\n\tpublic parent: Ref<Parent>;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ type: ShopSnap })\n\tpublic shopSnap?: ShopSnap;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isGroupOrder?: boolean;\n\n\t@prop({ type: String, enum: PaymentPreference })\n\tpublic paymentPreference?: PaymentPreference;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic spendingLimitForGuest?: number;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic secondarySpendingLimitForGuest?: number;\n\n\t@prop({\n\t\tenum: CartStatus,\n\t\ttype: String,\n\t\tdefault: CartStatus.ACTIVE,\n\t\trequired: true,\n\t})\n\tpublic status!: CartStatus;\n\n\t@prop({ type: String, trim: true })\n\tpublic couponCode?: string;\n\n\t@prop({\n\t\tref: () => LineItem,\n\t\tforeignField: 'cart',\n\t\tlocalField: '_id',\n\t})\n\tpublic lineItems: Ref<LineItem>[];\n}\n"]}
@@ -1,10 +1,12 @@
1
1
  import { Ref } from '@typegoose/typegoose';
2
2
  import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
3
3
  import { CouponType } from '../../../utilities/enum';
4
+ import { Admin } from './admin.model';
4
5
  export declare class Coupon extends TimeStamps {
5
6
  code: string;
6
7
  couponType: CouponType;
7
8
  orderLimitPerUser?: number | null;
8
9
  previousVersions?: Ref<Coupon>[];
9
10
  updatedVersion?: Ref<Coupon>;
11
+ createdBy?: Ref<Admin>;
10
12
  }
@@ -13,12 +13,14 @@ exports.Coupon = void 0;
13
13
  const typegoose_1 = require("@typegoose/typegoose");
14
14
  const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
15
15
  const enum_1 = require("../../../utilities/enum");
16
+ const admin_model_1 = require("./admin.model");
16
17
  let Coupon = class Coupon extends defaultClasses_1.TimeStamps {
17
18
  code;
18
19
  couponType;
19
20
  orderLimitPerUser;
20
21
  previousVersions;
21
22
  updatedVersion;
23
+ createdBy;
22
24
  };
23
25
  exports.Coupon = Coupon;
24
26
  __decorate([
@@ -41,6 +43,10 @@ __decorate([
41
43
  (0, typegoose_1.prop)({ ref: () => Coupon }),
42
44
  __metadata("design:type", Object)
43
45
  ], Coupon.prototype, "updatedVersion", void 0);
46
+ __decorate([
47
+ (0, typegoose_1.prop)({ ref: () => admin_model_1.Admin }),
48
+ __metadata("design:type", Object)
49
+ ], Coupon.prototype, "createdBy", void 0);
44
50
  exports.Coupon = Coupon = __decorate([
45
51
  (0, typegoose_1.modelOptions)({
46
52
  schemaOptions: { collection: 'coupons', discriminatorKey: 'couponType' },
@@ -1 +1 @@
1
- {"version":3,"file":"coupon.model.js","sourceRoot":"/","sources":["libraries/mongo/models/coupon.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAqD;AAK9C,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,2BAAU;IAE9B,IAAI,CAAU;IAGd,UAAU,CAAc;IAGxB,iBAAiB,CAAiB;IAGlC,gBAAgB,CAAiB;IAGjC,cAAc,CAAe;CACpC,CAAA;AAfY,wBAAM;AAEX;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oCAC/C;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAU,EAAE,CAAC;;0CAC1B;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;iDACG;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;;gDACY;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;;8CACQ;iBAdxB,MAAM;IAHlB,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE;KACxE,CAAC;GACW,MAAM,CAelB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CouponType } from '../../../utilities/enum';\n\n@modelOptions({\n\tschemaOptions: { collection: 'coupons', discriminatorKey: 'couponType' },\n})\nexport class Coupon extends TimeStamps {\n\t@prop({ required: true, uppercase: true, trim: true, type: String })\n\tpublic code!: string;\n\n\t@prop({ required: true, type: String, enum: CouponType })\n\tpublic couponType!: CouponType;\n\n\t@prop({ type: Number, default: null })\n\tpublic orderLimitPerUser?: number | null;\n\n\t@prop({ ref: () => Coupon })\n\tpublic previousVersions?: Ref<Coupon>[];\n\n\t@prop({ ref: () => Coupon })\n\tpublic updatedVersion?: Ref<Coupon>;\n}\n"]}
1
+ {"version":3,"file":"coupon.model.js","sourceRoot":"/","sources":["libraries/mongo/models/coupon.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAqD;AACrD,+CAAsC;AAK/B,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,2BAAU;IAE9B,IAAI,CAAU;IAGd,UAAU,CAAc;IAGxB,iBAAiB,CAAiB;IAGlC,gBAAgB,CAAiB;IAGjC,cAAc,CAAe;IAG7B,SAAS,CAAc;CAE9B,CAAA;AAnBY,wBAAM;AAEX;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oCAC/C;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAU,EAAE,CAAC;;0CAC1B;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;iDACG;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;;gDACY;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;;8CACQ;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,mBAAK,EAAE,CAAC;;yCACG;iBAjBlB,MAAM;IAHlB,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE;KACxE,CAAC;GACW,MAAM,CAmBlB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CouponType } from '../../../utilities/enum';\nimport { Admin } from './admin.model';\n\n@modelOptions({\n\tschemaOptions: { collection: 'coupons', discriminatorKey: 'couponType' },\n})\nexport class Coupon extends TimeStamps {\n\t@prop({ required: true, uppercase: true, trim: true, type: String })\n\tpublic code!: string;\n\n\t@prop({ required: true, type: String, enum: CouponType })\n\tpublic couponType!: CouponType;\n\n\t@prop({ type: Number, default: null })\n\tpublic orderLimitPerUser?: number | null;\n\n\t@prop({ ref: () => Coupon })\n\tpublic previousVersions?: Ref<Coupon>[];\n\n\t@prop({ ref: () => Coupon })\n\tpublic updatedVersion?: Ref<Coupon>;\n\n\t@prop({ ref: () => Admin })\n\tpublic createdBy?: Ref<Admin>;\n\t\n}\n"]}
@@ -2,5 +2,4 @@ export declare class Currency {
2
2
  symbol?: string;
3
3
  name: string;
4
4
  code?: string;
5
- roundTo?: number;
6
5
  }
@@ -15,7 +15,6 @@ class Currency {
15
15
  symbol;
16
16
  name;
17
17
  code;
18
- roundTo;
19
18
  }
20
19
  exports.Currency = Currency;
21
20
  __decorate([
@@ -30,8 +29,4 @@ __decorate([
30
29
  (0, typegoose_1.prop)({ type: String }),
31
30
  __metadata("design:type", String)
32
31
  ], Currency.prototype, "code", void 0);
33
- __decorate([
34
- (0, typegoose_1.prop)({ type: Number, default: 0.01 }),
35
- __metadata("design:type", Number)
36
- ], Currency.prototype, "roundTo", void 0);
37
32
  //# sourceMappingURL=currency.model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/currency.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,QAAQ;IAEb,MAAM,CAAU;IAGhB,IAAI,CAAU;IAGd,IAAI,CAAU;IAGd,OAAO,CAAU;CACxB;AAZD,4BAYC;AAVO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wCACA;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sCACF;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;yCACd","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class Currency {\n\t@prop({ type: String })\n\tpublic symbol?: string;\n\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic code?: string;\n\n\t@prop({ type: Number, default: 0.01 })\n\tpublic roundTo?: number;\n}\n"]}
1
+ {"version":3,"file":"currency.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/currency.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,QAAQ;IAEb,MAAM,CAAU;IAGhB,IAAI,CAAU;IAGd,IAAI,CAAU;CACrB;AATD,4BASC;AAPO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wCACA;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sCACF","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class Currency {\n\t@prop({ type: String })\n\tpublic symbol?: string;\n\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic code?: string;\n}\n"]}
@@ -32,7 +32,7 @@ export declare class User extends TimeStamps {
32
32
  isPhoneVerified?: boolean;
33
33
  onlineStatus?: OnlineStatus;
34
34
  fcmTokens?: string[];
35
- static updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number): Promise<(import("mongoose").Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, User, import("@typegoose/typegoose/lib/types").BeAnyObject> & Omit<User & {
35
+ static updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number): Promise<(import("mongoose").Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, User, import("@typegoose/typegoose/lib/types").BeAnyObject, {}> & Omit<User & {
36
36
  _id: import("mongoose").Types.ObjectId;
37
37
  } & {
38
38
  __v: number;
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.1.36
25
+ Version: 1.1.39
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.1.36",
3
+ "version": "1.1.39",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -1,2 +1,5 @@
1
+ export declare const BaseCurrencyRoundTo = 0.01;
2
+ export declare const SecondaryCurrencyRoundTo = 1000;
1
3
  export declare const roundCurrencySync: (amount: number, roundingFactor: number) => number;
2
- export declare const convertToSecondarySync: (price: number, exchangeRate: number, roundTo: number) => number | null;
4
+ export declare const roundBaseCurrency: (amount: number) => number;
5
+ export declare const roundSecondaryCurrency: (amount: number) => number;
@@ -1,23 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToSecondarySync = exports.roundCurrencySync = void 0;
3
+ exports.roundSecondaryCurrency = exports.roundBaseCurrency = exports.roundCurrencySync = exports.SecondaryCurrencyRoundTo = exports.BaseCurrencyRoundTo = void 0;
4
+ exports.BaseCurrencyRoundTo = 0.01;
5
+ exports.SecondaryCurrencyRoundTo = 1000;
4
6
  const roundCurrencySync = (amount, roundingFactor) => {
5
- if (amount == 0)
7
+ if (typeof amount !== 'number' ||
8
+ isNaN(amount) ||
9
+ typeof roundingFactor !== 'number' ||
10
+ roundingFactor <= 0 ||
11
+ amount === 0) {
6
12
  return 0;
7
- const rounded = Math.ceil(amount / roundingFactor) * roundingFactor;
13
+ }
8
14
  const decimals = (roundingFactor.toString().split('.')[1] || '').length;
15
+ const rounded = Math.round(amount / roundingFactor) * roundingFactor;
9
16
  return Number(rounded.toFixed(decimals));
10
17
  };
11
18
  exports.roundCurrencySync = roundCurrencySync;
12
- const convertToSecondarySync = (price, exchangeRate, roundTo) => {
13
- if (price == 0)
14
- return 0;
15
- if (price == null)
16
- return null;
17
- const amount = price * exchangeRate;
18
- if (!roundTo)
19
- return amount;
20
- return (0, exports.roundCurrencySync)(amount, roundTo);
19
+ const roundBaseCurrency = (amount) => {
20
+ return (0, exports.roundCurrencySync)(amount, exports.BaseCurrencyRoundTo);
21
+ };
22
+ exports.roundBaseCurrency = roundBaseCurrency;
23
+ const roundSecondaryCurrency = (amount) => {
24
+ return (0, exports.roundCurrencySync)(amount, exports.SecondaryCurrencyRoundTo);
21
25
  };
22
- exports.convertToSecondarySync = convertToSecondarySync;
26
+ exports.roundSecondaryCurrency = roundSecondaryCurrency;
23
27
  //# sourceMappingURL=currency.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AAAO,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IACpE,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AALW,QAAA,iBAAiB,qBAK5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,YAAoB,EAAE,OAAe,EAAE,EAAE;IAC9F,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IAC5B,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AANW,QAAA,sBAAsB,0BAMjC","sourcesContent":["export const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (amount == 0) return 0;\n\tconst rounded = Math.ceil(amount / roundingFactor) * roundingFactor;\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\treturn Number(rounded.toFixed(decimals));\n};\n\nexport const convertToSecondarySync = (price: number, exchangeRate: number, roundTo: number) => {\n\tif (price == 0) return 0;\n\tif (price == null) return null;\n\tconst amount = price * exchangeRate;\n\tif (!roundTo) return amount;\n\treturn roundCurrencySync(amount, roundTo);\n};"]}
1
+ {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AACa,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAC3B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAGtC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,cAAc,KAAK,QAAQ;QAClC,cAAc,IAAI,CAAC;QACnB,MAAM,KAAK,CAAC,EACX,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IAErE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAfW,QAAA,iBAAiB,qBAe5B;AAGK,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE;IAC3D,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,2BAAmB,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChE,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,gCAAwB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC","sourcesContent":["// === Currency Rounding Constants ===\nexport const BaseCurrencyRoundTo = 0.01;\nexport const SecondaryCurrencyRoundTo = 1000;\n\n// === Safely rounds a number to the nearest rounding unit ===\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof roundingFactor !== 'number' ||\n\t\troundingFactor <= 0 ||\n\t\tamount === 0\n\t) {\n\t\treturn 0;\n\t}\n\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\tconst rounded = Math.round(amount / roundingFactor) * roundingFactor;\n\n\treturn Number(rounded.toFixed(decimals));\n};\n\n// === Specific rounding functions for base and secondary currencies ===\nexport const roundBaseCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, BaseCurrencyRoundTo);\n};\n\nexport const roundSecondaryCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, SecondaryCurrencyRoundTo);\n};\n"]}
@@ -647,7 +647,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
647
647
  totalPages: number;
648
648
  } | undefined;
649
649
  }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
650
- }>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
650
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
651
651
  success: z.ZodBoolean;
652
652
  message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
653
653
  data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -685,83 +685,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
685
685
  totalPages: number;
686
686
  } | undefined;
687
687
  }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
688
- }>, any>[k]; } : never, z.baseObjectInputType<{
689
- success: z.ZodBoolean;
690
- message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
691
- data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
692
- metadata: z.ZodOptional<z.ZodObject<{
693
- page: z.ZodNumber;
694
- size: z.ZodNumber;
695
- totalElements: z.ZodNumber;
696
- totalPages: z.ZodNumber;
697
- }, "strip", z.ZodTypeAny, {
698
- size: number;
699
- page: number;
700
- totalElements: number;
701
- totalPages: number;
702
- }, {
703
- size: number;
704
- page: number;
705
- totalElements: number;
706
- totalPages: number;
707
- }>>;
708
- documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
709
- }, "strip", z.ZodTypeAny, {
710
- documents: T[];
711
- metadata?: {
712
- size: number;
713
- page: number;
714
- totalElements: number;
715
- totalPages: number;
716
- } | undefined;
717
- }, {
718
- documents: T[];
719
- metadata?: {
720
- size: number;
721
- page: number;
722
- totalElements: number;
723
- totalPages: number;
724
- } | undefined;
725
- }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
726
- }> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
727
- success: z.ZodBoolean;
728
- message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
729
- data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
730
- metadata: z.ZodOptional<z.ZodObject<{
731
- page: z.ZodNumber;
732
- size: z.ZodNumber;
733
- totalElements: z.ZodNumber;
734
- totalPages: z.ZodNumber;
735
- }, "strip", z.ZodTypeAny, {
736
- size: number;
737
- page: number;
738
- totalElements: number;
739
- totalPages: number;
740
- }, {
741
- size: number;
742
- page: number;
743
- totalElements: number;
744
- totalPages: number;
745
- }>>;
746
- documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
747
- }, "strip", z.ZodTypeAny, {
748
- documents: T[];
749
- metadata?: {
750
- size: number;
751
- page: number;
752
- totalElements: number;
753
- totalPages: number;
754
- } | undefined;
755
- }, {
756
- documents: T[];
757
- metadata?: {
758
- size: number;
759
- page: number;
760
- totalElements: number;
761
- totalPages: number;
762
- } | undefined;
763
- }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
764
- }>[k_1]; } : never>;
688
+ }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
765
689
  export type PaginatedDTO<T> = {
766
690
  metadata: DTO<typeof metadataSchema>;
767
691
  documents: T[];
@@ -76,34 +76,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
76
76
  private baseSchema;
77
77
  constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
78
78
  private createBaseSchema;
79
- getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
79
+ getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
80
80
  getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
81
81
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
82
- }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
82
+ }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
83
83
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
84
- }>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
84
+ }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
85
85
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
86
- }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
87
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
88
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
89
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
90
- }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
91
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
92
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
86
+ }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">>;
93
87
  getIdSchema(): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
94
88
  getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
95
89
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
96
- }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
97
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
98
- }>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
99
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
100
- }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
101
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
102
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
90
+ }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
103
91
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
104
- }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
92
+ }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
105
93
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
106
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
94
+ }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
107
95
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
108
96
  }, "strict", z.ZodTypeAny, {
109
97
  [x: string]: any;
@@ -126,34 +114,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
126
114
  [x: string]: any;
127
115
  }>;
128
116
  getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
129
- BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
117
+ BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
130
118
  EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
131
119
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
132
- }> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
120
+ }> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<T_3[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
133
121
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
134
- }>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
122
+ }> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<T_4[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
135
123
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
136
- }> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<z.objectUtil.extendShape<T, {
137
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
138
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
139
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
140
- }> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
141
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
142
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
124
+ }> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<T_5[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
143
125
  IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
144
126
  UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
145
127
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
146
- }> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
147
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
148
- }>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
149
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
150
- }> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
151
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
152
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
128
+ }> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<T_6[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
153
129
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
154
- }> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<z.objectUtil.extendShape<T, {
130
+ }> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<T_7[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
155
131
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
156
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
132
+ }> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<T_8[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
157
133
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
158
134
  }, "strict", z.ZodTypeAny, {
159
135
  [x: string]: any;
@@ -1,7 +1,3 @@
1
- import { PaidCurrency } from './enum';
2
- export declare const getRoundingFactor: (currency: PaidCurrency) => Promise<number>;
3
1
  export declare const getExchangeRate: () => Promise<number>;
4
- export declare const roundCurrency: (amount: number, currency: PaidCurrency, roundingFactor?: number) => Promise<number>;
5
- export declare const roundCurrencySync: (amount: number, roundingFactor: number) => number;
6
- export declare const convertToSecondary: (amount: number, exchangeRate?: number, roundTo?: number) => Promise<number>;
7
- export declare const convertToSecondarySync: (price: number, exchangeRate: number, roundTo: number) => number | undefined;
2
+ export declare const convertToBase: (amount: number) => Promise<number>;
3
+ export declare const convertToSecondary: (amount: number) => Promise<number>;
@@ -1,67 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToSecondarySync = exports.convertToSecondary = exports.roundCurrencySync = exports.roundCurrency = exports.getExchangeRate = exports.getRoundingFactor = void 0;
3
+ exports.convertToSecondary = exports.convertToBase = exports.getExchangeRate = void 0;
4
4
  const __1 = require("..");
5
- const enum_1 = require("./enum");
6
- const DEFAULT_ROUNDING_FACTOR = 0.1;
7
- const DEFAULT_EXCHANGE_RATE = 1;
8
- const getRoundingFactor = async (currency) => {
9
- const setting = (await (0, __1.getLibraries)().getCachedSettingsService().getSettings());
10
- const currencySetting = setting.currencySetting;
11
- let roundingFactor;
12
- if (currencySetting) {
13
- switch (currency) {
14
- case enum_1.PaidCurrency.BASE:
15
- roundingFactor = currencySetting.baseCurrency?.roundTo;
16
- break;
17
- case enum_1.PaidCurrency.SECONDARY:
18
- roundingFactor = currencySetting.secondaryCurrency?.roundTo;
19
- break;
20
- default:
21
- roundingFactor = DEFAULT_ROUNDING_FACTOR;
22
- break;
23
- }
24
- }
25
- return roundingFactor || DEFAULT_ROUNDING_FACTOR;
26
- };
27
- exports.getRoundingFactor = getRoundingFactor;
5
+ const shared_1 = require("./shared");
6
+ const DEFAULT_EXCHANGE_RATE = 0;
28
7
  const getExchangeRate = async () => {
29
8
  const settings = (await (0, __1.getLibraries)().getCachedSettingsService().getSettings());
30
9
  const currencySetting = settings.currencySetting;
31
10
  return currencySetting?.exchangeRate || DEFAULT_EXCHANGE_RATE;
32
11
  };
33
12
  exports.getExchangeRate = getExchangeRate;
34
- const roundCurrency = async (amount, currency, roundingFactor) => {
35
- if (amount == 0)
36
- return 0;
37
- roundingFactor = roundingFactor ?? (await (0, exports.getRoundingFactor)(currency));
38
- return (0, exports.roundCurrencySync)(amount, roundingFactor);
39
- };
40
- exports.roundCurrency = roundCurrency;
41
- const roundCurrencySync = (amount, roundingFactor) => {
42
- if (amount == 0)
13
+ const convertToBase = async (amount) => {
14
+ if (typeof amount !== 'number' || isNaN(amount)) {
43
15
  return 0;
44
- const rounded = Math.ceil(amount / roundingFactor) * roundingFactor;
45
- const decimals = (roundingFactor.toString().split('.')[1] || '').length;
46
- return Number(rounded.toFixed(decimals));
16
+ }
17
+ const exchangeRate = await (0, exports.getExchangeRate)();
18
+ return (0, shared_1.roundBaseCurrency)(amount / exchangeRate);
47
19
  };
48
- exports.roundCurrencySync = roundCurrencySync;
49
- const convertToSecondary = async (amount, exchangeRate, roundTo) => {
50
- if (amount == 0)
20
+ exports.convertToBase = convertToBase;
21
+ const convertToSecondary = async (amount) => {
22
+ if (typeof amount !== 'number' || isNaN(amount)) {
51
23
  return 0;
52
- exchangeRate = exchangeRate ?? (await (0, exports.getExchangeRate)());
53
- return (0, exports.roundCurrency)(amount * exchangeRate, enum_1.PaidCurrency.SECONDARY, roundTo);
24
+ }
25
+ const exchangeRate = await (0, exports.getExchangeRate)();
26
+ return (0, shared_1.roundSecondaryCurrency)(amount * exchangeRate);
54
27
  };
55
28
  exports.convertToSecondary = convertToSecondary;
56
- const convertToSecondarySync = (price, exchangeRate, roundTo) => {
57
- if (price == 0)
58
- return 0;
59
- if (price == null)
60
- return undefined;
61
- const amount = price * exchangeRate;
62
- if (!roundTo)
63
- return amount;
64
- return (0, exports.roundCurrencySync)(amount, roundTo);
65
- };
66
- exports.convertToSecondarySync = convertToSecondarySync;
67
29
  //# sourceMappingURL=currency.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/currency.ts"],"names":[],"mappings":";;;AAEA,0BAAkC;AAGlC,iCAAsC;AAEtC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEzB,MAAM,iBAAiB,GAAG,KAAK,EAAE,QAAsB,EAAmB,EAAE;IAClF,MAAM,OAAO,GAAG,CAAC,MAAM,IAAA,gBAAY,GAAE,CAAC,wBAAwB,EAAE,CAAC,WAAW,EAAE,CAAY,CAAC;IAC3F,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAChD,IAAI,cAAkC,CAAC;IACvC,IAAI,eAAe,EAAE,CAAC;QACrB,QAAQ,QAAQ,EAAE,CAAC;YAClB,KAAK,mBAAY,CAAC,IAAI;gBACrB,cAAc,GAAG,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC;gBACvD,MAAM;YACP,KAAK,mBAAY,CAAC,SAAS;gBAC1B,cAAc,GAAG,eAAe,CAAC,iBAAiB,EAAE,OAAO,CAAC;gBAC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AAC;AALW,QAAA,iBAAiB,qBAK5B;AAEK,MAAM,kBAAkB,GAAG,KAAK,EACtC,MAAc,EACd,YAAqB,EACrB,OAAgB,EACE,EAAE;IACpB,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC1B,YAAY,GAAG,YAAY,IAAI,CAAC,MAAM,IAAA,uBAAe,GAAE,CAAC,CAAC;IACzD,OAAO,IAAA,qBAAa,EAAC,MAAM,GAAG,YAAY,EAAE,mBAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC9E,CAAC,CAAC;AARW,QAAA,kBAAkB,sBAQ7B;AAEK,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,YAAoB,EAAE,OAAe,EAAE,EAAE;IAC9F,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,SAAS,CAAA;IACnC,MAAM,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IAC5B,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AANW,QAAA,sBAAsB,0BAMjC","sourcesContent":["// In the future, we need to move this in the currency folder and there we need to make a seperation between sync and async functions\n\nimport { getLibraries } from '..';\n\nimport { Setting } from '../libraries/mongo/models';\nimport { PaidCurrency } from './enum';\n\nconst DEFAULT_ROUNDING_FACTOR = 0.1;\nconst DEFAULT_EXCHANGE_RATE = 1;\n\nexport const getRoundingFactor = async (currency: PaidCurrency): Promise<number> => {\n\tconst setting = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\tconst currencySetting = setting.currencySetting;\n\tlet roundingFactor: number | undefined;\n\tif (currencySetting) {\n\t\tswitch (currency) {\n\t\t\tcase PaidCurrency.BASE:\n\t\t\t\troundingFactor = currencySetting.baseCurrency?.roundTo;\n\t\t\t\tbreak;\n\t\t\tcase PaidCurrency.SECONDARY:\n\t\t\t\troundingFactor = currencySetting.secondaryCurrency?.roundTo;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\troundingFactor = DEFAULT_ROUNDING_FACTOR;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn roundingFactor || DEFAULT_ROUNDING_FACTOR;\n};\n\nexport const getExchangeRate = async (): Promise<number> => {\n\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\tconst currencySetting = settings.currencySetting;\n\treturn currencySetting?.exchangeRate || DEFAULT_EXCHANGE_RATE;\n};\n\nexport const roundCurrency = async (\n\tamount: number,\n\tcurrency: PaidCurrency,\n\troundingFactor?: number\n): Promise<number> => {\n\tif (amount == 0) return 0;\n\troundingFactor = roundingFactor ?? (await getRoundingFactor(currency));\n\treturn roundCurrencySync(amount, roundingFactor);\n};\n\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (amount == 0) return 0;\n\tconst rounded = Math.ceil(amount / roundingFactor) * roundingFactor;\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\treturn Number(rounded.toFixed(decimals));\n};\n\nexport const convertToSecondary = async (\n\tamount: number,\n\texchangeRate?: number,\n\troundTo?: number\n): Promise<number> => {\n\tif (amount == 0) return 0;\n\texchangeRate = exchangeRate ?? (await getExchangeRate());\n\treturn roundCurrency(amount * exchangeRate, PaidCurrency.SECONDARY, roundTo);\n};\n\nexport const convertToSecondarySync = (price: number, exchangeRate: number, roundTo: number) => {\n\tif (price == 0) return 0;\n\tif (price == null) return undefined\n\tconst amount = price * exchangeRate;\n\tif (!roundTo) return amount;\n\treturn roundCurrencySync(amount, roundTo);\n};\n"]}
1
+ {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/currency.ts"],"names":[],"mappings":";;;AAAA,0BAAkC;AAElC,qCAAqE;AAErE,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEzB,MAAM,eAAe,GAAG,KAAK,IAAqB,EAAE;IAC1D,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,gBAAY,GAAE,CAAC,wBAAwB,EAAE,CAAC,WAAW,EAAE,CAAY,CAAC;IAC5F,MAAM,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;IACjD,OAAO,eAAe,EAAE,YAAY,IAAI,qBAAqB,CAAC;AAC/D,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B;AAEK,MAAM,aAAa,GAAG,KAAK,EAAE,MAAc,EAAmB,EAAE;IACtE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,uBAAe,GAAE,CAAC;IAC7C,OAAO,IAAA,0BAAiB,EAAC,MAAM,GAAG,YAAY,CAAC,CAAC;AACjD,CAAC,CAAC;AAPW,QAAA,aAAa,iBAOxB;AAEK,MAAM,kBAAkB,GAAG,KAAK,EAAE,MAAc,EAAmB,EAAE;IAC3E,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,uBAAe,GAAE,CAAC;IAC7C,OAAO,IAAA,+BAAsB,EAAC,MAAM,GAAG,YAAY,CAAC,CAAC;AACtD,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B","sourcesContent":["import { getLibraries } from '..';\nimport { Setting } from '../libraries/mongo/models';\nimport { roundBaseCurrency, roundSecondaryCurrency } from './shared';\n\nconst DEFAULT_EXCHANGE_RATE = 0;\n\nexport const getExchangeRate = async (): Promise<number> => {\n\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\tconst currencySetting = settings.currencySetting;\n\treturn currencySetting?.exchangeRate || DEFAULT_EXCHANGE_RATE;\n};\n\nexport const convertToBase = async (amount: number): Promise<number> => {\n\tif (typeof amount !== 'number' || isNaN(amount)) {\n\t\treturn 0;\n\t}\n\n\tconst exchangeRate = await getExchangeRate();\n\treturn roundBaseCurrency(amount / exchangeRate);\n};\n\nexport const convertToSecondary = async (amount: number): Promise<number> => {\n\tif (typeof amount !== 'number' || isNaN(amount)) {\n\t\treturn 0;\n\t}\n\n\tconst exchangeRate = await getExchangeRate();\n\treturn roundSecondaryCurrency(amount * exchangeRate);\n};\n"]}
@@ -1,5 +1,2 @@
1
- export declare const getSecondaryCurrencyStage: ({ valuePath, exchangeRate, roundTo, }: {
2
- valuePath: string;
3
- exchangeRate: number;
4
- roundTo: number;
5
- }) => any;
1
+ export declare const getRoundBaseCurrencyStage: (value: any) => Record<string, any>;
2
+ export declare const getRoundSecondaryCurrencyStage: (value: any) => Record<string, any>;
@@ -1,29 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSecondaryCurrencyStage = void 0;
4
- const getSecondaryCurrencyStage = ({ valuePath, exchangeRate, roundTo, }) => {
3
+ exports.getRoundSecondaryCurrencyStage = exports.getRoundBaseCurrencyStage = void 0;
4
+ const getRoundBaseCurrencyStage = (value) => {
5
5
  return {
6
6
  $cond: [
7
- { $ifNull: [valuePath, false] },
7
+ { $ne: [value, null] },
8
8
  {
9
- $function: {
10
- body: function (price, exchangeRate, roundTo) {
11
- if (price == null)
12
- return null;
13
- const amount = price * exchangeRate;
14
- if (!roundTo)
15
- return amount;
16
- const rounded = Math.ceil(amount / roundTo) * roundTo;
17
- const decimals = (roundTo.toString().split('.')[1] || '').length;
18
- return Number(rounded.toFixed(decimals));
19
- }.toString(),
20
- args: [valuePath, exchangeRate, roundTo],
21
- lang: 'js',
22
- },
9
+ $round: [value, 2],
23
10
  },
24
- null,
11
+ 0,
25
12
  ],
26
13
  };
27
14
  };
28
- exports.getSecondaryCurrencyStage = getSecondaryCurrencyStage;
15
+ exports.getRoundBaseCurrencyStage = getRoundBaseCurrencyStage;
16
+ const getRoundSecondaryCurrencyStage = (value) => {
17
+ return {
18
+ $cond: [
19
+ { $ne: [value, null] },
20
+ {
21
+ $multiply: [
22
+ {
23
+ $round: [{ $divide: [value, 1000] }, 0],
24
+ },
25
+ 1000,
26
+ ],
27
+ },
28
+ 0,
29
+ ],
30
+ };
31
+ };
32
+ exports.getRoundSecondaryCurrencyStage = getRoundSecondaryCurrencyStage;
29
33
  //# sourceMappingURL=common-pipeline-functions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common-pipeline-functions.js","sourceRoot":"/","sources":["utilities/pipelines/common-pipeline-functions.ts"],"names":[],"mappings":";;;AAAO,MAAM,yBAAyB,GAAG,CAAC,EACzC,SAAS,EACT,YAAY,EACZ,OAAO,GAKP,EAAO,EAAE;IACT,OAAO;QACN,KAAK,EAAE;YACN,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YAC/B;gBACC,SAAS,EAAE;oBACV,IAAI,EAAE,UAAU,KAAa,EAAE,YAAoB,EAAE,OAAe;wBACnE,IAAI,KAAK,IAAI,IAAI;4BAAE,OAAO,IAAI,CAAC;wBAC/B,MAAM,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;wBACpC,IAAI,CAAC,OAAO;4BAAE,OAAO,MAAM,CAAC;wBAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;wBACtD,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;wBACjE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAC1C,CAAC,CAAC,QAAQ,EAAE;oBACZ,IAAI,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC;oBACxC,IAAI,EAAE,IAAI;iBACV;aACD;YACD,IAAI;SACJ;KACD,CAAC;AACH,CAAC,CAAC;AA7BW,QAAA,yBAAyB,6BA6BpC","sourcesContent":["export const getSecondaryCurrencyStage = ({\n\tvaluePath,\n\texchangeRate,\n\troundTo,\n}: {\n\tvaluePath: string;\n\texchangeRate: number;\n\troundTo: number;\n}): any => {\n\treturn {\n\t\t$cond: [\n\t\t\t{ $ifNull: [valuePath, false] },\n\t\t\t{\n\t\t\t\t$function: {\n\t\t\t\t\tbody: function (price: number, exchangeRate: number, roundTo: number) {\n\t\t\t\t\t\tif (price == null) return null;\n\t\t\t\t\t\tconst amount = price * exchangeRate;\n\t\t\t\t\t\tif (!roundTo) return amount;\n\t\t\t\t\t\tconst rounded = Math.ceil(amount / roundTo) * roundTo;\n\t\t\t\t\t\tconst decimals = (roundTo.toString().split('.')[1] || '').length;\n\t\t\t\t\t\treturn Number(rounded.toFixed(decimals));\n\t\t\t\t\t}.toString(),\n\t\t\t\t\targs: [valuePath, exchangeRate, roundTo],\n\t\t\t\t\tlang: 'js',\n\t\t\t\t},\n\t\t\t},\n\t\t\tnull,\n\t\t],\n\t};\n};\n"]}
1
+ {"version":3,"file":"common-pipeline-functions.js","sourceRoot":"/","sources":["utilities/pipelines/common-pipeline-functions.ts"],"names":[],"mappings":";;;AAQO,MAAM,yBAAyB,GAAG,CAAC,KAAU,EAAuB,EAAE;IAC5E,OAAO;QACN,KAAK,EAAE;YACN,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE;YACtB;gBACC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;aAClB;YACD,CAAC;SACD;KACD,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,yBAAyB,6BAUpC;AAcK,MAAM,8BAA8B,GAAG,CAAC,KAAU,EAAuB,EAAE;IACjF,OAAO;QACN,KAAK,EAAE;YACN,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE;YACtB;gBACC,SAAS,EAAE;oBACV;wBACC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;qBACvC;oBACD,IAAI;iBACJ;aACD;YACD,CAAC;SACD;KACD,CAAC;AACH,CAAC,CAAC;AAfW,QAAA,8BAA8B,kCAezC","sourcesContent":["/**\n * Rounds a base currency value to 2 decimal places inside an aggregation pipeline.\n *\n * ✅ Use when:\n * - You want to round a monetary value like USD, BDT, etc. to 2 decimals.\n *\n * Example: 123.456 → 123.46\n */\nexport const getRoundBaseCurrencyStage = (value: any): Record<string, any> => {\n\treturn {\n\t\t$cond: [\n\t\t\t{ $ne: [value, null] },\n\t\t\t{\n\t\t\t\t$round: [value, 2],\n\t\t\t},\n\t\t\t0,\n\t\t],\n\t};\n};\n\n/**\n * Rounds a numeric value to the nearest thousand (secondary currency rounding).\n *\n * ✅ Use when:\n * - You’re working with a secondary currency (e.g., large denomination or summary view)\n * - You want rounding like: 123456 → 123000\n *\n * 🧠 Logic:\n * - Divide by 1000\n * - Round to nearest integer\n * - Multiply back by 1000\n */\nexport const getRoundSecondaryCurrencyStage = (value: any): Record<string, any> => {\n\treturn {\n\t\t$cond: [\n\t\t\t{ $ne: [value, null] },\n\t\t\t{\n\t\t\t\t$multiply: [\n\t\t\t\t\t{\n\t\t\t\t\t\t$round: [{ $divide: [value, 1000] }, 0],\n\t\t\t\t\t},\n\t\t\t\t\t1000,\n\t\t\t\t],\n\t\t\t},\n\t\t\t0,\n\t\t],\n\t};\n};\n"]}
@@ -1,4 +1,4 @@
1
1
  import { PipelineStage } from 'mongoose';
2
- export declare function addProductMarketingInfo(exchangeRate: number, secondaryCurrencyRoundTo: number, secondaryCurrencyName: string): PipelineStage[];
3
- export declare function addSecondaryCurrencyToPriceBreakdowns(exchangeRate: number, secondaryCurrencyRoundTo: number): PipelineStage;
2
+ export declare function addProductMarketingInfo(exchangeRate: number, secondaryCurrencyName: string): PipelineStage[];
3
+ export declare function addSecondaryCurrencyToPriceBreakdowns(exchangeRate: number): PipelineStage;
4
4
  export declare function addDiscountAmountsToPriceBreakdowns(): PipelineStage;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addProductMarketingInfo = addProductMarketingInfo;
4
4
  exports.addSecondaryCurrencyToPriceBreakdowns = addSecondaryCurrencyToPriceBreakdowns;
5
5
  exports.addDiscountAmountsToPriceBreakdowns = addDiscountAmountsToPriceBreakdowns;
6
- const common_pipeline_functions_1 = require("./common-pipeline-functions");
7
6
  const enum_1 = require("../enum");
8
- function addProductMarketingInfo(exchangeRate, secondaryCurrencyRoundTo, secondaryCurrencyName) {
7
+ const common_pipeline_functions_1 = require("./common-pipeline-functions");
8
+ function addProductMarketingInfo(exchangeRate, secondaryCurrencyName) {
9
9
  return [
10
10
  {
11
11
  $lookup: {
@@ -45,10 +45,8 @@ function addProductMarketingInfo(exchangeRate, secondaryCurrencyRoundTo, seconda
45
45
  secondaryCurrencyValue: {
46
46
  $cond: [
47
47
  { $eq: ['$valueType', 'fixed'] },
48
- (0, common_pipeline_functions_1.getSecondaryCurrencyStage)({
49
- valuePath: '$value',
50
- exchangeRate,
51
- roundTo: secondaryCurrencyRoundTo,
48
+ (0, common_pipeline_functions_1.getRoundSecondaryCurrencyStage)({
49
+ $multiply: ['$value', exchangeRate],
52
50
  }),
53
51
  '$$REMOVE',
54
52
  ],
@@ -119,7 +117,7 @@ function addProductMarketingInfo(exchangeRate, secondaryCurrencyRoundTo, seconda
119
117
  },
120
118
  ];
121
119
  }
122
- function addSecondaryCurrencyToPriceBreakdowns(exchangeRate, secondaryCurrencyRoundTo) {
120
+ function addSecondaryCurrencyToPriceBreakdowns(exchangeRate) {
123
121
  return {
124
122
  $addFields: {
125
123
  priceBreakdowns: {
@@ -130,18 +128,14 @@ function addSecondaryCurrencyToPriceBreakdowns(exchangeRate, secondaryCurrencyRo
130
128
  $mergeObjects: [
131
129
  '$$breakdown',
132
130
  {
133
- secondaryPrice: (0, common_pipeline_functions_1.getSecondaryCurrencyStage)({
134
- valuePath: '$$breakdown.price',
135
- exchangeRate,
136
- roundTo: secondaryCurrencyRoundTo,
131
+ secondaryPrice: (0, common_pipeline_functions_1.getRoundSecondaryCurrencyStage)({
132
+ $multiply: ['$$breakdown.price', exchangeRate],
137
133
  }),
138
134
  secondaryDiscountAmount: {
139
135
  $cond: [
140
136
  { $gt: ['$productMarketing', null] },
141
- (0, common_pipeline_functions_1.getSecondaryCurrencyStage)({
142
- valuePath: '$$breakdown.discountAmount',
143
- exchangeRate,
144
- roundTo: secondaryCurrencyRoundTo,
137
+ (0, common_pipeline_functions_1.getRoundSecondaryCurrencyStage)({
138
+ $multiply: ['$$breakdown.discountAmount', exchangeRate],
145
139
  }),
146
140
  '$$REMOVE',
147
141
  ],
@@ -149,10 +143,8 @@ function addSecondaryCurrencyToPriceBreakdowns(exchangeRate, secondaryCurrencyRo
149
143
  secondaryDiscountedPrice: {
150
144
  $cond: [
151
145
  { $gt: ['$productMarketing', null] },
152
- (0, common_pipeline_functions_1.getSecondaryCurrencyStage)({
153
- valuePath: '$$breakdown.discountedPrice',
154
- exchangeRate,
155
- roundTo: secondaryCurrencyRoundTo,
146
+ (0, common_pipeline_functions_1.getRoundSecondaryCurrencyStage)({
147
+ $multiply: ['$$breakdown.discountedPrice', exchangeRate],
156
148
  }),
157
149
  '$$REMOVE',
158
150
  ],
@@ -183,14 +175,14 @@ function addDiscountAmountsToPriceBreakdowns() {
183
175
  $cond: [
184
176
  { $eq: ['$productMarketing.valueType', enum_1.ValueType.FIXED] },
185
177
  '$productMarketing.value',
186
- {
178
+ (0, common_pipeline_functions_1.getRoundBaseCurrencyStage)({
187
179
  $multiply: [
188
- '$productMarketing.value',
180
+ '$$breakdown.price',
189
181
  {
190
- $divide: ['$$breakdown.price', 100],
182
+ $divide: ['$productMarketing.value', 100],
191
183
  },
192
184
  ],
193
- },
185
+ }),
194
186
  ],
195
187
  },
196
188
  '$$REMOVE',
@@ -199,25 +191,25 @@ function addDiscountAmountsToPriceBreakdowns() {
199
191
  discountedPrice: {
200
192
  $cond: [
201
193
  { $gt: ['$productMarketing', null] },
202
- {
194
+ (0, common_pipeline_functions_1.getRoundBaseCurrencyStage)({
203
195
  $subtract: [
204
196
  '$$breakdown.price',
205
197
  {
206
198
  $cond: [
207
199
  { $eq: ['$productMarketing.valueType', enum_1.ValueType.FIXED] },
208
200
  '$productMarketing.value',
209
- {
201
+ (0, common_pipeline_functions_1.getRoundBaseCurrencyStage)({
210
202
  $multiply: [
211
- '$productMarketing.value',
203
+ '$$breakdown.price',
212
204
  {
213
- $divide: ['$$breakdown.price', 100],
205
+ $divide: ['$productMarketing.value', 100],
214
206
  },
215
207
  ],
216
- },
208
+ }),
217
209
  ],
218
210
  },
219
211
  ],
220
- },
212
+ }),
221
213
  '$$REMOVE',
222
214
  ],
223
215
  },
@@ -1 +1 @@
1
- {"version":3,"file":"product-pipeline-stages.js","sourceRoot":"/","sources":["utilities/pipelines/product-pipeline-stages.ts"],"names":[],"mappings":";;AAIA,0DAsHC;AAED,sFAgDC;AAED,kFAkEC;AA/OD,2EAAwE;AACxE,kCAAmD;AAEnD,SAAgB,uBAAuB,CACtC,YAAoB,EACpB,wBAAgC,EAChC,qBAA6B;IAE7B,OAAO;QACN;YACC,OAAO,EAAE;gBACR,IAAI,EAAE,mBAAmB;gBACzB,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE;gBAC3C,QAAQ,EAAE;oBACT;wBACC,MAAM,EAAE;4BACP,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE;yBAC3C;qBACD;oBACD;wBACC,OAAO,EAAE;4BACR,IAAI,EAAE,YAAY;4BAClB,UAAU,EAAE,WAAW;4BACvB,YAAY,EAAE,KAAK;4BACnB,EAAE,EAAE,WAAW;yBACf;qBACD;oBACD;wBACC,OAAO,EAAE,YAAY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B;gEACzB;oEACC,OAAO,EAAE,CAAC,mBAAmB,EAAE,GAAG,CAAC;iEACnC;6DACD;yDACD;qDACD;iDACD;6CACD;yCACD;wCACD,UAAU;qCACV;iCACD;6BACD;yBACD;qBACD;iBACD;aACD;SACD;KACD,CAAC;AACH,CAAC","sourcesContent":["import { PipelineStage } from 'mongoose';\nimport { getSecondaryCurrencyStage } from './common-pipeline-functions';\nimport { MarketingType, ValueType } from '../enum';\n\nexport function addProductMarketingInfo(\n\texchangeRate: number,\n\tsecondaryCurrencyRoundTo: number,\n\tsecondaryCurrencyName: string\n): PipelineStage[] {\n\treturn [\n\t\t{\n\t\t\t$lookup: {\n\t\t\t\tfrom: 'productMarketings',\n\t\t\t\tlet: { productId: '$_id', now: new Date() },\n\t\t\t\tpipeline: [\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$expr: { $eq: ['$product', '$$productId'] },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$lookup: {\n\t\t\t\t\t\t\tfrom: 'marketings',\n\t\t\t\t\t\t\tlocalField: 'marketing',\n\t\t\t\t\t\t\tforeignField: '_id',\n\t\t\t\t\t\t\tas: 'marketing',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$unwind: '$marketing',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$expr: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{ $eq: ['$marketing.status', 'active'] },\n\t\t\t\t\t\t\t\t\t{ $eq: ['$marketing.pausedAt', null] },\n\t\t\t\t\t\t\t\t\t{ $lte: ['$marketing.duration.start', '$$now'] },\n\t\t\t\t\t\t\t\t\t{ $gte: ['$marketing.duration.end', '$$now'] },\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t// Compute and add secondary currency values to coupon documents\n\t\t\t\t\t{\n\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\tsecondaryCurrencyValue: {\n\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t{ $eq: ['$valueType', 'fixed'] },\n\t\t\t\t\t\t\t\t\tgetSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\tvaluePath: '$value',\n\t\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.BUY1GET1] },\n\t\t\t\t\t\t\t\t\t\t\tthen: 'Buy 1 Get 1',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.PUNCH_MARKETING] },\n\t\t\t\t\t\t\t\t\t\t\tthen: 'Punch',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.DISCOUNT] },\n\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$concat: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsecondaryCurrencyName,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t' ',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ $toString: '$secondaryCurrencyValue' },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.PERCENTAGE] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$concat: [{ $toString: '$value' }, '%'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\tdefault: 'Discount',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tdefault: '$marketing.marketingType',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\tmarketing: '$marketing._id',\n\t\t\t\t\t\t\tisBuy1Get1: '$isBuy1Get1',\n\t\t\t\t\t\t\tvalueType: '$valueType',\n\t\t\t\t\t\t\tvalue: '$value',\n\t\t\t\t\t\t\tsecondaryCurrencyValue: '$secondaryCurrencyValue',\n\t\t\t\t\t\t\tlabel: '$label',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tas: 'productMarketing',\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t$unwind: { path: '$productMarketing', preserveNullAndEmptyArrays: true },\n\t\t},\n\t];\n}\n\nexport function addSecondaryCurrencyToPriceBreakdowns(\n\texchangeRate: number,\n\tsecondaryCurrencyRoundTo: number\n): PipelineStage {\n\treturn {\n\t\t$addFields: {\n\t\t\tpriceBreakdowns: {\n\t\t\t\t$map: {\n\t\t\t\t\tinput: '$priceBreakdowns',\n\t\t\t\t\tas: 'breakdown',\n\t\t\t\t\tin: {\n\t\t\t\t\t\t$mergeObjects: [\n\t\t\t\t\t\t\t'$$breakdown',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsecondaryPrice: getSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\tvaluePath: '$$breakdown.price',\n\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tsecondaryDiscountAmount: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] },\n\t\t\t\t\t\t\t\t\t\tgetSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\tvaluePath: '$$breakdown.discountAmount',\n\t\t\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tsecondaryDiscountedPrice: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] },\n\t\t\t\t\t\t\t\t\t\tgetSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\tvaluePath: '$$breakdown.discountedPrice',\n\t\t\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport function addDiscountAmountsToPriceBreakdowns(): PipelineStage {\n\treturn {\n\t\t$addFields: {\n\t\t\tpriceBreakdowns: {\n\t\t\t\t$map: {\n\t\t\t\t\tinput: '$priceBreakdowns',\n\t\t\t\t\tas: 'breakdown',\n\t\t\t\t\tin: {\n\t\t\t\t\t\t$mergeObjects: [\n\t\t\t\t\t\t\t'$$breakdown',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdiscountAmount: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] }, // checks existence\n\t\t\t\t\t\t\t\t\t\t// if valueType is fixed, use value directly\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t\t\t{ $eq: ['$productMarketing.valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t// if valueType is percentage, calculate percentage of price\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t$multiply: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$divide: ['$$breakdown.price', 100],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // omit field if productMarketing is missing\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t// Add discounted price\n\t\t\t\t\t\t\t\tdiscountedPrice: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] }, // checks existence\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t$subtract: [\n\t\t\t\t\t\t\t\t\t\t\t\t'$$breakdown.price',\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ $eq: ['$productMarketing.valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$multiply: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$divide: ['$$breakdown.price', 100],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // omit field if productMarketing is missing\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"product-pipeline-stages.js","sourceRoot":"/","sources":["utilities/pipelines/product-pipeline-stages.ts"],"names":[],"mappings":";;AAIA,0DAmHC;AAED,sFAwCC;AAED,kFAkEC;AApOD,kCAAmD;AACnD,2EAAwG;AAExG,SAAgB,uBAAuB,CACtC,YAAoB,EACpB,qBAA6B;IAE7B,OAAO;QACN;YACC,OAAO,EAAE;gBACR,IAAI,EAAE,mBAAmB;gBACzB,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE;gBAC3C,QAAQ,EAAE;oBACT;wBACC,MAAM,EAAE;4BACP,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE;yBAC3C;qBACD;oBACD;wBACC,OAAO,EAAE;4BACR,IAAI,EAAE,YAAY;4BAClB,UAAU,EAAE,WAAW;4BACvB,YAAY,EAAE,KAAK;4BACnB,EAAE,EAAE,WAAW;yBACf;qBACD;oBACD;wBACC,OAAO,EAAE,YAAY;qBACrB;oBACD;wBACC,MAAM,EAAE;4BACP,KAAK,EAAE;gCACN,IAAI,EAAE;oCACL,EAAE,GAAG,EAAE,CAAC,mBAAmB,EAAE,QAAQ,CAAC,EAAE;oCACxC,EAAE,GAAG,EAAE,CAAC,qBAAqB,EAAE,IAAI,CAAC,EAAE;oCACtC,EAAE,IAAI,EAAE,CAAC,2BAA2B,EAAE,OAAO,CAAC,EAAE;oCAChD,EAAE,IAAI,EAAE,CAAC,yBAAyB,EAAE,OAA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B,mCAAmC;IAClD,OAAO;QACN,UAAU,EAAE;YACX,eAAe,EAAE;gBAChB,IAAI,EAAE;oBACL,KAAK,EAAE,kBAAkB;oBACzB,EAAE,EAAE,WAAW;oBACf,EAAE,EAAE;wBACH,aAAa,EAAE;4BACd,aAAa;4BACb;gCACC,cAAc,EAAE;oCACf,KAAK,EAAE;wCACN,EAAE,GAAG,EAAE,CAAC,mBAAmB,EAAE,IAAI,CAAC,EAAE;wCAEpC;4CACC,KAAK,EAAE;gDACN,EAAE,GAAG,EAAE,CAAC,6BAA6B,EAAE,gBAAS,CAAC,KAAK,CAAC,EAAE;gDACzD,yBAAyB;gDAEzB,IAAA,qDAAyB,EAAC;oDACzB,SAAS,EAAE;wDACV,mBAAmB;wDACnB;4DACC,OAAO,EAAE,CAAC,yBAAyB,EAAE,GAAG,CAAC;yDACzC;qDACD;iDACD,CAAC;6CACF;yCACD;wCACD,UAAU;qCACV;iCACD;gCAED,eAAe,EAAE;oCAChB,KAAK,EAAE;wCACN,EAAE,GAAG,EAAE,CAAC,mBAAmB,EAAE,IAAI,CAAC,EAAE;wCACpC,IAAA,qDAAyB,EAAC;4CACzB,SAAS,EAAE;gDACV,mBAAmB;gDACnB;oDACC,KAAK,EAAE;wDACN,EAAE,GAAG,EAAE,CAAC,6BAA6B,EAAE,gBAAS,CAAC,KAAK,CAAC,EAAE;wDACzD,yBAAyB;wDACzB,IAAA,qDAAyB,EAAC;4DACzB,SAAS,EAAE;gEACV,mBAAmB;gEACnB;oEACC,OAAO,EAAE,CAAC,yBAAyB,EAAE,GAAG,CAAC;iEACzC;6DACD;yDACD,CAAC;qDACF;iDACD;6CACD;yCACD,CAAC;wCACF,UAAU;qCACV;iCACD;6BACD;yBACD;qBACD;iBACD;aACD;SACD;KACD,CAAC;AACH,CAAC","sourcesContent":["import { PipelineStage } from 'mongoose';\nimport { MarketingType, ValueType } from '../enum';\nimport { getRoundBaseCurrencyStage, getRoundSecondaryCurrencyStage } from './common-pipeline-functions';\n\nexport function addProductMarketingInfo(\n\texchangeRate: number,\n\tsecondaryCurrencyName: string\n): PipelineStage[] {\n\treturn [\n\t\t{\n\t\t\t$lookup: {\n\t\t\t\tfrom: 'productMarketings',\n\t\t\t\tlet: { productId: '$_id', now: new Date() },\n\t\t\t\tpipeline: [\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$expr: { $eq: ['$product', '$$productId'] },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$lookup: {\n\t\t\t\t\t\t\tfrom: 'marketings',\n\t\t\t\t\t\t\tlocalField: 'marketing',\n\t\t\t\t\t\t\tforeignField: '_id',\n\t\t\t\t\t\t\tas: 'marketing',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$unwind: '$marketing',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$expr: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{ $eq: ['$marketing.status', 'active'] },\n\t\t\t\t\t\t\t\t\t{ $eq: ['$marketing.pausedAt', null] },\n\t\t\t\t\t\t\t\t\t{ $lte: ['$marketing.duration.start', '$$now'] },\n\t\t\t\t\t\t\t\t\t{ $gte: ['$marketing.duration.end', '$$now'] },\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t// Compute and add secondary currency values to coupon documents\n\t\t\t\t\t{\n\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\tsecondaryCurrencyValue: {\n\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t{ $eq: ['$valueType', 'fixed'] },\n\t\t\t\t\t\t\t\t\tgetRoundSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t$multiply: ['$value', exchangeRate],\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.BUY1GET1] },\n\t\t\t\t\t\t\t\t\t\t\tthen: 'Buy 1 Get 1',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.PUNCH_MARKETING] },\n\t\t\t\t\t\t\t\t\t\t\tthen: 'Punch',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.DISCOUNT] },\n\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$concat: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsecondaryCurrencyName,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t' ',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ $toString: '$secondaryCurrencyValue' },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.PERCENTAGE] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$concat: [{ $toString: '$value' }, '%'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\tdefault: 'Discount',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tdefault: '$marketing.marketingType',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\tmarketing: '$marketing._id',\n\t\t\t\t\t\t\tisBuy1Get1: '$isBuy1Get1',\n\t\t\t\t\t\t\tvalueType: '$valueType',\n\t\t\t\t\t\t\tvalue: '$value',\n\t\t\t\t\t\t\tsecondaryCurrencyValue: '$secondaryCurrencyValue',\n\t\t\t\t\t\t\tlabel: '$label',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tas: 'productMarketing',\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t$unwind: { path: '$productMarketing', preserveNullAndEmptyArrays: true },\n\t\t},\n\t];\n}\n\nexport function addSecondaryCurrencyToPriceBreakdowns(exchangeRate: number): PipelineStage {\n\treturn {\n\t\t$addFields: {\n\t\t\tpriceBreakdowns: {\n\t\t\t\t$map: {\n\t\t\t\t\tinput: '$priceBreakdowns',\n\t\t\t\t\tas: 'breakdown',\n\t\t\t\t\tin: {\n\t\t\t\t\t\t$mergeObjects: [\n\t\t\t\t\t\t\t'$$breakdown',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsecondaryPrice: getRoundSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t$multiply: ['$$breakdown.price', exchangeRate],\n\t\t\t\t\t\t\t\t}),\n\n\t\t\t\t\t\t\t\tsecondaryDiscountAmount: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] },\n\t\t\t\t\t\t\t\t\t\tgetRoundSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\t$multiply: ['$$breakdown.discountAmount', exchangeRate],\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tsecondaryDiscountedPrice: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] },\n\t\t\t\t\t\t\t\t\t\tgetRoundSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\t$multiply: ['$$breakdown.discountedPrice', exchangeRate],\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport function addDiscountAmountsToPriceBreakdowns(): PipelineStage {\n\treturn {\n\t\t$addFields: {\n\t\t\tpriceBreakdowns: {\n\t\t\t\t$map: {\n\t\t\t\t\tinput: '$priceBreakdowns',\n\t\t\t\t\tas: 'breakdown',\n\t\t\t\t\tin: {\n\t\t\t\t\t\t$mergeObjects: [\n\t\t\t\t\t\t\t'$$breakdown',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdiscountAmount: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] }, // checks existence\n\t\t\t\t\t\t\t\t\t\t// if valueType is fixed, use value directly\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t\t\t{ $eq: ['$productMarketing.valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t// if valueType is percentage, calculate percentage of price\n\t\t\t\t\t\t\t\t\t\t\t\tgetRoundBaseCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\t\t\t$multiply: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$$breakdown.price',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$divide: ['$productMarketing.value', 100],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // omit field if productMarketing is missing\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t// Add discounted price\n\t\t\t\t\t\t\t\tdiscountedPrice: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] }, // checks existence\n\t\t\t\t\t\t\t\t\t\tgetRoundBaseCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\t$subtract: [\n\t\t\t\t\t\t\t\t\t\t\t\t'$$breakdown.price',\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ $eq: ['$productMarketing.valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetRoundBaseCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$multiply: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$$breakdown.price',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$divide: ['$productMarketing.value', 100],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // omit field if productMarketing is missing\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n"]}
@@ -1,2 +1,5 @@
1
+ export declare const BaseCurrencyRoundTo = 0.01;
2
+ export declare const SecondaryCurrencyRoundTo = 1000;
1
3
  export declare const roundCurrencySync: (amount: number, roundingFactor: number) => number;
2
- export declare const convertToSecondarySync: (price: number, exchangeRate: number, roundTo: number) => number | null;
4
+ export declare const roundBaseCurrency: (amount: number) => number;
5
+ export declare const roundSecondaryCurrency: (amount: number) => number;
@@ -1,23 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToSecondarySync = exports.roundCurrencySync = void 0;
3
+ exports.roundSecondaryCurrency = exports.roundBaseCurrency = exports.roundCurrencySync = exports.SecondaryCurrencyRoundTo = exports.BaseCurrencyRoundTo = void 0;
4
+ exports.BaseCurrencyRoundTo = 0.01;
5
+ exports.SecondaryCurrencyRoundTo = 1000;
4
6
  const roundCurrencySync = (amount, roundingFactor) => {
5
- if (amount == 0)
7
+ if (typeof amount !== 'number' ||
8
+ isNaN(amount) ||
9
+ typeof roundingFactor !== 'number' ||
10
+ roundingFactor <= 0 ||
11
+ amount === 0) {
6
12
  return 0;
7
- const rounded = Math.ceil(amount / roundingFactor) * roundingFactor;
13
+ }
8
14
  const decimals = (roundingFactor.toString().split('.')[1] || '').length;
15
+ const rounded = Math.round(amount / roundingFactor) * roundingFactor;
9
16
  return Number(rounded.toFixed(decimals));
10
17
  };
11
18
  exports.roundCurrencySync = roundCurrencySync;
12
- const convertToSecondarySync = (price, exchangeRate, roundTo) => {
13
- if (price == 0)
14
- return 0;
15
- if (price == null)
16
- return null;
17
- const amount = price * exchangeRate;
18
- if (!roundTo)
19
- return amount;
20
- return (0, exports.roundCurrencySync)(amount, roundTo);
19
+ const roundBaseCurrency = (amount) => {
20
+ return (0, exports.roundCurrencySync)(amount, exports.BaseCurrencyRoundTo);
21
+ };
22
+ exports.roundBaseCurrency = roundBaseCurrency;
23
+ const roundSecondaryCurrency = (amount) => {
24
+ return (0, exports.roundCurrencySync)(amount, exports.SecondaryCurrencyRoundTo);
21
25
  };
22
- exports.convertToSecondarySync = convertToSecondarySync;
26
+ exports.roundSecondaryCurrency = roundSecondaryCurrency;
23
27
  //# sourceMappingURL=currency.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AAAO,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IACpE,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AALW,QAAA,iBAAiB,qBAK5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,YAAoB,EAAE,OAAe,EAAE,EAAE;IAC9F,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IAC5B,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AANW,QAAA,sBAAsB,0BAMjC","sourcesContent":["export const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (amount == 0) return 0;\n\tconst rounded = Math.ceil(amount / roundingFactor) * roundingFactor;\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\treturn Number(rounded.toFixed(decimals));\n};\n\nexport const convertToSecondarySync = (price: number, exchangeRate: number, roundTo: number) => {\n\tif (price == 0) return 0;\n\tif (price == null) return null;\n\tconst amount = price * exchangeRate;\n\tif (!roundTo) return amount;\n\treturn roundCurrencySync(amount, roundTo);\n};"]}
1
+ {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AACa,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAC3B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAGtC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,cAAc,KAAK,QAAQ;QAClC,cAAc,IAAI,CAAC;QACnB,MAAM,KAAK,CAAC,EACX,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IAErE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAfW,QAAA,iBAAiB,qBAe5B;AAGK,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE;IAC3D,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,2BAAmB,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChE,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,gCAAwB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC","sourcesContent":["// === Currency Rounding Constants ===\nexport const BaseCurrencyRoundTo = 0.01;\nexport const SecondaryCurrencyRoundTo = 1000;\n\n// === Safely rounds a number to the nearest rounding unit ===\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof roundingFactor !== 'number' ||\n\t\troundingFactor <= 0 ||\n\t\tamount === 0\n\t) {\n\t\treturn 0;\n\t}\n\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\tconst rounded = Math.round(amount / roundingFactor) * roundingFactor;\n\n\treturn Number(rounded.toFixed(decimals));\n};\n\n// === Specific rounding functions for base and secondary currencies ===\nexport const roundBaseCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, BaseCurrencyRoundTo);\n};\n\nexport const roundSecondaryCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, SecondaryCurrencyRoundTo);\n};\n"]}
@@ -647,7 +647,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
647
647
  totalPages: number;
648
648
  } | undefined;
649
649
  }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
650
- }>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
650
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
651
651
  success: z.ZodBoolean;
652
652
  message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
653
653
  data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -685,83 +685,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
685
685
  totalPages: number;
686
686
  } | undefined;
687
687
  }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
688
- }>, any>[k]; } : never, z.baseObjectInputType<{
689
- success: z.ZodBoolean;
690
- message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
691
- data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
692
- metadata: z.ZodOptional<z.ZodObject<{
693
- page: z.ZodNumber;
694
- size: z.ZodNumber;
695
- totalElements: z.ZodNumber;
696
- totalPages: z.ZodNumber;
697
- }, "strip", z.ZodTypeAny, {
698
- page: number;
699
- size: number;
700
- totalElements: number;
701
- totalPages: number;
702
- }, {
703
- page: number;
704
- size: number;
705
- totalElements: number;
706
- totalPages: number;
707
- }>>;
708
- documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
709
- }, "strip", z.ZodTypeAny, {
710
- documents: T[];
711
- metadata?: {
712
- page: number;
713
- size: number;
714
- totalElements: number;
715
- totalPages: number;
716
- } | undefined;
717
- }, {
718
- documents: T[];
719
- metadata?: {
720
- page: number;
721
- size: number;
722
- totalElements: number;
723
- totalPages: number;
724
- } | undefined;
725
- }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
726
- }> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
727
- success: z.ZodBoolean;
728
- message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
729
- data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
730
- metadata: z.ZodOptional<z.ZodObject<{
731
- page: z.ZodNumber;
732
- size: z.ZodNumber;
733
- totalElements: z.ZodNumber;
734
- totalPages: z.ZodNumber;
735
- }, "strip", z.ZodTypeAny, {
736
- page: number;
737
- size: number;
738
- totalElements: number;
739
- totalPages: number;
740
- }, {
741
- page: number;
742
- size: number;
743
- totalElements: number;
744
- totalPages: number;
745
- }>>;
746
- documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
747
- }, "strip", z.ZodTypeAny, {
748
- documents: T[];
749
- metadata?: {
750
- page: number;
751
- size: number;
752
- totalElements: number;
753
- totalPages: number;
754
- } | undefined;
755
- }, {
756
- documents: T[];
757
- metadata?: {
758
- page: number;
759
- size: number;
760
- totalElements: number;
761
- totalPages: number;
762
- } | undefined;
763
- }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
764
- }>[k_1]; } : never>;
688
+ }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
765
689
  export type PaginatedDTO<T> = {
766
690
  metadata: DTO<typeof metadataSchema>;
767
691
  documents: T[];
@@ -76,34 +76,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
76
76
  private baseSchema;
77
77
  constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
78
78
  private createBaseSchema;
79
- getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
79
+ getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
80
80
  getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
81
81
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
82
- }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
82
+ }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
83
83
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
84
- }>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
84
+ }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
85
85
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
86
- }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
87
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
88
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
89
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
90
- }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
91
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
92
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
86
+ }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">>;
93
87
  getIdSchema(): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
94
88
  getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
95
89
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
96
- }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
97
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
98
- }>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
99
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
100
- }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
101
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
102
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
90
+ }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
103
91
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
104
- }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
92
+ }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
105
93
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
106
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
94
+ }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
107
95
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
108
96
  }, "strict", z.ZodTypeAny, {
109
97
  [x: string]: any;
@@ -126,34 +114,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
126
114
  [x: string]: any;
127
115
  }>;
128
116
  getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
129
- BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
117
+ BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
130
118
  EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
131
119
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
132
- }> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
120
+ }> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<T_3[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
133
121
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
134
- }>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
122
+ }> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<T_4[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
135
123
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
136
- }> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<z.objectUtil.extendShape<T, {
137
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
138
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
139
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
140
- }> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
141
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
142
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
124
+ }> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<T_5[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
143
125
  IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
144
126
  UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
145
127
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
146
- }> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
147
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
148
- }>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
149
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
150
- }> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
151
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
152
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
128
+ }> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<T_6[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
153
129
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
154
- }> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<z.objectUtil.extendShape<T, {
130
+ }> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<T_7[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
155
131
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
156
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
132
+ }> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<T_8[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
157
133
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
158
134
  }, "strict", z.ZodTypeAny, {
159
135
  [x: string]: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.1.36",
3
+ "version": "1.1.39",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",