@lyxa.ai/core 1.1.31-alpha.5 → 1.1.32

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 (33) hide show
  1. package/dist/libraries/mongo/models/cart.model.d.ts +2 -0
  2. package/dist/libraries/mongo/models/cart.model.js +10 -0
  3. package/dist/libraries/mongo/models/cart.model.js.map +1 -1
  4. package/dist/libraries/mongo/models/embedded/currency.model.d.ts +1 -0
  5. package/dist/libraries/mongo/models/embedded/currency.model.js +5 -0
  6. package/dist/libraries/mongo/models/embedded/currency.model.js.map +1 -1
  7. package/dist/libraries/mongo/models/user.model.d.ts +1 -1
  8. package/dist/libraries/socket/core/socket-event-registry.js.map +1 -1
  9. package/dist/libraries/trpc/middlewares/createSocketSubscriptionProcedure.d.ts +19 -10
  10. package/dist/libraries/trpc/middlewares/createSocketSubscriptionProcedure.js +30 -29
  11. package/dist/libraries/trpc/middlewares/createSocketSubscriptionProcedure.js.map +1 -1
  12. package/dist/types/README.md +1 -1
  13. package/dist/types/package.json +1 -1
  14. package/dist/types/utilities/shared/currency.d.ts +1 -4
  15. package/dist/types/utilities/shared/currency.js +13 -17
  16. package/dist/types/utilities/shared/currency.js.map +1 -1
  17. package/dist/types/utilities/validation/common-validation.d.ts +78 -2
  18. package/dist/types/utilities/validation/global-validation.d.ts +38 -14
  19. package/dist/utilities/currency.d.ts +6 -2
  20. package/dist/utilities/currency.js +52 -14
  21. package/dist/utilities/currency.js.map +1 -1
  22. package/dist/utilities/pipelines/common-pipeline-functions.d.ts +5 -2
  23. package/dist/utilities/pipelines/common-pipeline-functions.js +19 -23
  24. package/dist/utilities/pipelines/common-pipeline-functions.js.map +1 -1
  25. package/dist/utilities/pipelines/product-pipeline-stages.d.ts +2 -2
  26. package/dist/utilities/pipelines/product-pipeline-stages.js +29 -21
  27. package/dist/utilities/pipelines/product-pipeline-stages.js.map +1 -1
  28. package/dist/utilities/shared/currency.d.ts +1 -4
  29. package/dist/utilities/shared/currency.js +13 -17
  30. package/dist/utilities/shared/currency.js.map +1 -1
  31. package/dist/utilities/validation/common-validation.d.ts +78 -2
  32. package/dist/utilities/validation/global-validation.d.ts +38 -14
  33. package/package.json +1 -1
@@ -21,6 +21,8 @@ export declare class Cart extends TimeStamps {
21
21
  cartId: string;
22
22
  title?: string;
23
23
  exchangeRate?: number;
24
+ roundTo?: number;
25
+ secondaryRoundTo?: number;
24
26
  user: Ref<User>;
25
27
  parent: Ref<Parent>;
26
28
  shop: Ref<Shop>;
@@ -68,6 +68,8 @@ let Cart = class Cart extends defaultClasses_1.TimeStamps {
68
68
  cartId;
69
69
  title;
70
70
  exchangeRate;
71
+ roundTo;
72
+ secondaryRoundTo;
71
73
  user;
72
74
  parent;
73
75
  shop;
@@ -93,6 +95,14 @@ __decorate([
93
95
  (0, typegoose_1.prop)({ type: Number, default: 0 }),
94
96
  __metadata("design:type", Number)
95
97
  ], 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);
96
106
  __decorate([
97
107
  (0, typegoose_1.prop)({ required: true, ref: () => user_model_1.User }),
98
108
  __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,CA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,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
+ {"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,M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pB,IAAA,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,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"]}
@@ -2,4 +2,5 @@ export declare class Currency {
2
2
  symbol?: string;
3
3
  name: string;
4
4
  code?: string;
5
+ roundTo?: number;
5
6
  }
@@ -15,6 +15,7 @@ class Currency {
15
15
  symbol;
16
16
  name;
17
17
  code;
18
+ roundTo;
18
19
  }
19
20
  exports.Currency = Currency;
20
21
  __decorate([
@@ -29,4 +30,8 @@ __decorate([
29
30
  (0, typegoose_1.prop)({ type: String }),
30
31
  __metadata("design:type", String)
31
32
  ], 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);
32
37
  //# 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;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"]}
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"]}
@@ -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;
@@ -1 +1 @@
1
- {"version":3,"file":"socket-event-registry.js","sourceRoot":"/","sources":["libraries/socket/core/socket-event-registry.ts"],"names":[],"mappings":";;;AAGA,2EAAiE;AAajE,MAAa,YAAY;IACxB,MAAM,CAAC,eAAe,CAA4B,SAAY;QAC7D,OAAO,oCAAQ,CAAC,SAAS,CAAgB,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,kBAAkB,CAA4B,eAAkB,EAAE,KAAkB;QAC1F,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;QACtE,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClD,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC,cAAc,CAAC,IAAI,SAAS,CAAC;QACtD,OAAO,GAAG,eAAe,IAAI,GAAG,EAAE,CAAC;IACpC,CAAC;IAEM,MAAM,CAAC,WAAW,CAA4B,eAAkB,EAAE,IAAkB;QAC1F,MAAM,EAAE,IAAI,EAAE,GAAG,oCAAQ,CAAC,eAAe,CAAC,CAAC;QAC3C,OAAO,IAAI,IAAI,CAAC,IAAI,CAAgB,CAAC;IACtC,CAAC;CAED;AAjBD,oCAiBC","sourcesContent":["import { z } from 'zod';\nimport { SocketEventType } from '../../../utilities/enum';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\nimport { Registry, REGISTRY } from './socket-event-registry.map';\nimport { EventRegistry } from '../../event/decorators/metadata';\n\ninterface EventRegistration<TEvent extends BaseSocketEvent<any, any>> {\n\tctor: new (payload: z.input<TEvent['outputSchema']>) => TEvent;\n\tschemas: { input: TEvent['inputSchema']; output: TEvent['outputSchema'] };\n\tidentifier?: (input: z.infer<TEvent['inputSchema']>) => string;\n}\n\ntype InputFor<T extends SocketEventType> = z.infer<Registry[T]['schemas']['input']>;\ntype OutputFor<T extends SocketEventType> = z.infer<Registry[T]['schemas']['output']>;\ntype EventFor<T extends SocketEventType> = InstanceType<Registry[T]['ctor']>;\n\nexport class EventFactory {\n\tstatic getRegistration<T extends SocketEventType>(eventType: T) {\n\t\treturn REGISTRY[eventType] as Registry[T];\n\t}\n\n\tstatic getSubscriptionKey<T extends SocketEventType>(SocketEventType: T, input: InputFor<T>) {\n\t\tconst { identifier, schemas } = this.getRegistration(SocketEventType);\n\t\tconst validatedInput = schemas.input.parse(input);\n\t\tconst key = identifier?.(validatedInput) ?? 'default';\n\t\treturn `${SocketEventType}:${key}`;\n\t}\n\n\tpublic static createEvent<T extends SocketEventType>(SocketEventType: T, data: OutputFor<T>): EventFor<T> {\n\t\tconst { ctor } = REGISTRY[SocketEventType];\n\t\treturn new ctor(data) as EventFor<T>;\n\t}\n\n}\n\nexport type { Registry, EventFor, InputFor, OutputFor, EventRegistration };\n"]}
1
+ {"version":3,"file":"socket-event-registry.js","sourceRoot":"/","sources":["libraries/socket/core/socket-event-registry.ts"],"names":[],"mappings":";;;AAGA,2EAA+D;AAiB/D,MAAa,YAAY;IACrB,MAAM,CAAC,eAAe,CAA4B,SAAY;QAC1D,OAAO,oCAAQ,CAAC,SAAS,CAAgB,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,kBAAkB,CAA4B,eAAkB,EAAE,KAAkB;QACvF,MAAM,EAAC,UAAU,EAAE,OAAO,EAAC,GAAG,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;QACpE,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClD,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC,cAAc,CAAC,IAAI,SAAS,CAAC;QACtD,OAAO,GAAG,eAAe,IAAI,GAAG,EAAE,CAAC;IACvC,CAAC;IAEM,MAAM,CAAC,WAAW,CAA4B,eAAkB,EAAE,IAAkB;QACvF,MAAM,EAAC,IAAI,EAAC,GAAG,oCAAQ,CAAC,eAAe,CAAC,CAAC;QACzC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAgB,CAAC;IACzC,CAAC;CAEJ;AAjBD,oCAiBC","sourcesContent":["import {z} from 'zod';\nimport {SocketEventType} from '../../../utilities/enum';\nimport {BaseSocketEvent} from '../BaseSocketEvent';\nimport {Registry, REGISTRY} from './socket-event-registry.map';\nimport {TrackedData} from \"@trpc/server/unstable-core-do-not-import\";\n\ninterface EventRegistration<TEvent extends BaseSocketEvent<any, any>> {\n ctor: new (payload: z.input<TEvent['outputSchema']>) => TEvent;\n schemas: { input: TEvent['inputSchema']; output: TEvent['outputSchema'] };\n identifier?: (input: z.infer<TEvent['inputSchema']>) => string;\n}\n\ntype InputFor<T extends SocketEventType> =\n z.infer<Registry[T]['schemas']['input']>;\ntype OutputFor<T extends SocketEventType> =\n z.infer<Registry[T]['schemas']['output']>;\ntype EventFor<T extends SocketEventType> =\n InstanceType<Registry[T]['ctor']>;\n\n\nexport class EventFactory {\n static getRegistration<T extends SocketEventType>(eventType: T) {\n return REGISTRY[eventType] as Registry[T];\n }\n\n static getSubscriptionKey<T extends SocketEventType>(SocketEventType: T, input: InputFor<T>) {\n const {identifier, schemas} = this.getRegistration(SocketEventType);\n const validatedInput = schemas.input.parse(input);\n const key = identifier?.(validatedInput) ?? 'default';\n return `${SocketEventType}:${key}`;\n }\n\n public static createEvent<T extends SocketEventType>(SocketEventType: T, data: OutputFor<T>): EventFor<T> {\n const {ctor} = REGISTRY[SocketEventType];\n return new ctor(data) as EventFor<T>;\n }\n\n}\n\nexport type {Registry, EventFor, InputFor, OutputFor, EventRegistration};\n"]}
@@ -1,12 +1,21 @@
1
1
  import { SocketEventType } from '../../../utilities/enum';
2
- import { AuthEntityType } from '../../auth';
3
2
  import { OutputFor } from '../../socket';
4
- export declare function createSocketSubscriptionProcedure<T extends SocketEventType>({ eventType, entityTypes, getId, }: {
5
- eventType: T;
6
- entityTypes: AuthEntityType[];
7
- getId: (out: OutputFor<T>) => string;
8
- }): import("@trpc/server").TRPCSubscriptionProcedure<{
9
- input: unknown;
10
- output: AsyncIterable<import("@trpc/server/dist/unstable-core-do-not-import.d-C8vB_hCN.cjs").TrackedData<unknown>, void, unknown>;
11
- meta: object;
12
- }>;
3
+ interface SubscriptionContext {
4
+ entity?: {
5
+ id: string;
6
+ };
7
+ signal?: AbortSignal;
8
+ }
9
+ interface SubscriptionOpts<TInput = any> {
10
+ ctx: SubscriptionContext;
11
+ input: TInput;
12
+ }
13
+ interface CreateSubscriptionOptions<TEventType extends SocketEventType> {
14
+ eventType: TEventType;
15
+ ctx: SubscriptionContext;
16
+ input: any;
17
+ getTrackingId?: (payload: OutputFor<TEventType>) => string;
18
+ }
19
+ export declare function createSocketSubscription<TEventType extends SocketEventType>(options: CreateSubscriptionOptions<TEventType>): AsyncGenerator<import("@trpc/server").TrackedEnvelope<OutputFor<TEventType>>, void, unknown>;
20
+ export declare function socketSubscription<TEventType extends SocketEventType>(eventType: TEventType, getTrackingId?: (payload: OutputFor<TEventType>) => string): (opts: SubscriptionOpts) => AsyncGenerator<import("@trpc/server").TrackedEnvelope<OutputFor<TEventType>>, void, unknown>;
21
+ export {};
@@ -1,40 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSocketSubscriptionProcedure = createSocketSubscriptionProcedure;
4
- const auth_1 = require("./auth");
3
+ exports.createSocketSubscription = createSocketSubscription;
4
+ exports.socketSubscription = socketSubscription;
5
5
  const socket_1 = require("../../socket");
6
6
  const crypto_1 = require("crypto");
7
7
  const instance_utils_1 = require("../../../utilities/instance.utils");
8
8
  const ws_1 = require("ws");
9
9
  const server_1 = require("@trpc/server");
10
- function createSocketSubscriptionProcedure({ eventType, entityTypes, getId, }) {
10
+ async function* createSocketSubscription(options) {
11
+ const { eventType, ctx, input, getTrackingId } = options;
11
12
  const registration = socket_1.EventFactory.getRegistration(eventType);
12
- const { schemas } = registration;
13
- return (0, auth_1.createAuthenticatedProcedure)({ entityTypes })
14
- .input(schemas.input)
15
- .output((0, socket_1.zAsyncIterable)({
16
- yield: schemas.output,
17
- tracked: true,
18
- }))
19
- .subscription(async function* (opts) {
20
- const socketId = (0, crypto_1.randomUUID)();
21
- const localEE = new socket_1.LocalEventEmitter(socketId);
22
- const entityId = opts.ctx.entity.id;
23
- const eventKey = socket_1.EventFactory.getSubscriptionKey(eventType, opts.input);
24
- const instanceId = (0, instance_utils_1.getInstanceId)();
25
- const socketInfo = { socketId, eventKey, instanceId };
26
- await (0, socket_1.connectEntityToSocketEvent)(entityId, socketInfo);
27
- socket_1.LocalSubs.bind(entityId, eventKey, localEE);
28
- opts.signal?.addEventListener('abort', () => {
29
- socket_1.LocalSubs.unbind(entityId, eventKey, localEE);
30
- (0, socket_1.disconnectEntityFromSocketEvent)(entityId, socketInfo).catch(console.error);
31
- });
32
- for await (const [data] of (0, ws_1.on)(localEE.ee, eventKey, {
33
- signal: opts.signal,
34
- })) {
35
- const payload = data;
36
- yield (0, server_1.tracked)(getId(payload), payload);
37
- }
13
+ const socketId = (0, crypto_1.randomUUID)();
14
+ const localEE = new socket_1.LocalEventEmitter(socketId);
15
+ const entityId = ctx.entity.id;
16
+ const eventKey = socket_1.EventFactory.getSubscriptionKey(eventType, input);
17
+ const instanceId = (0, instance_utils_1.getInstanceId)();
18
+ const socketInfo = { socketId, eventKey, instanceId };
19
+ await (0, socket_1.connectEntityToSocketEvent)(entityId, socketInfo);
20
+ socket_1.LocalSubs.bind(entityId, eventKey, localEE);
21
+ ctx.signal?.addEventListener('abort', () => {
22
+ socket_1.LocalSubs.unbind(entityId, eventKey, localEE);
23
+ (0, socket_1.disconnectEntityFromSocketEvent)(entityId, socketInfo).catch(console.error);
24
+ });
25
+ for await (const [data] of (0, ws_1.on)(localEE.ee, eventKey, { signal: ctx.signal })) {
26
+ const payload = data;
27
+ const id = getTrackingId
28
+ ? getTrackingId(payload)
29
+ : payload._id?.toString() ?? (0, crypto_1.randomUUID)();
30
+ yield (0, server_1.tracked)(id, payload);
31
+ }
32
+ }
33
+ function socketSubscription(eventType, getTrackingId) {
34
+ return (opts) => createSocketSubscription({
35
+ eventType,
36
+ ctx: opts.ctx,
37
+ input: opts.input,
38
+ getTrackingId,
38
39
  });
39
40
  }
40
41
  //# sourceMappingURL=createSocketSubscriptionProcedure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createSocketSubscriptionProcedure.js","sourceRoot":"/","sources":["libraries/trpc/middlewares/createSocketSubscriptionProcedure.ts"],"names":[],"mappings":";;AAiBA,8EA+CC;AA9DD,iCAAsD;AACtD,yCAQsB;AACtB,mCAAoC;AACpC,sEAAkE;AAClE,2BAAwB;AACxB,yCAAuC;AAEvC,SAAgB,iCAAiC,CAA4B,EAC5E,SAAS,EACT,WAAW,EACX,KAAK,GAKL;IACA,MAAM,YAAY,GAAG,qBAAY,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAC7D,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IAEjC,OAAO,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC;SAClD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;SACpB,MAAM,CACN,IAAA,uBAAc,EAAC;QACd,KAAK,EAAE,OAAO,CAAC,MAAM;QACrB,OAAO,EAAE,IAAI;KACb,CAAC,CACF;SACA,YAAY,CAAC,KAAK,SAAS,CAAC,EAAE,IAAI;QAClC,MAAM,QAAQ,GAAG,IAAA,mBAAU,GAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,IAAI,0BAAiB,CAAC,QAAQ,CAAC,CAAC;QAEhD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,MAAO,CAAC,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,qBAAY,CAAC,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAExE,MAAM,UAAU,GAAG,IAAA,8BAAa,GAAE,CAAC;QACnC,MAAM,UAAU,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;QAEtD,MAAM,IAAA,mCAA0B,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACvD,kBAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAC3C,kBAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAA,wCAA+B,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;QAIH,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAA,OAAE,EAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE;YACnD,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CAAC,EAAE,CAAC;YACJ,MAAM,OAAO,GAAG,IAAW,CAAC;YAC5B,MAAM,IAAA,gBAAO,EAAC,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QACxC,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { SocketEventType } from '../../../utilities/enum';\nimport { AuthEntityType } from '../../auth';\nimport { createAuthenticatedProcedure } from './auth';\nimport {\n\tconnectEntityToSocketEvent,\n\tdisconnectEntityFromSocketEvent,\n\tEventFactory,\n\tLocalEventEmitter,\n\tLocalSubs,\n\tOutputFor,\n\tzAsyncIterable,\n} from '../../socket';\nimport { randomUUID } from 'crypto';\nimport { getInstanceId } from '../../../utilities/instance.utils';\nimport { on } from 'ws';\nimport { tracked } from '@trpc/server';\n\nexport function createSocketSubscriptionProcedure<T extends SocketEventType>({\n\teventType,\n\tentityTypes,\n\tgetId,\n}: {\n\teventType: T;\n\tentityTypes: AuthEntityType[];\n\tgetId: (out: OutputFor<T>) => string;\n}) {\n\tconst registration = EventFactory.getRegistration(eventType);\n\tconst { schemas } = registration;\n\n\treturn createAuthenticatedProcedure({ entityTypes })\n\t\t.input(schemas.input)\n\t\t.output(\n\t\t\tzAsyncIterable({\n\t\t\t\tyield: schemas.output,\n\t\t\t\ttracked: true,\n\t\t\t})\n\t\t)\n\t\t.subscription(async function* (opts) {\n\t\t\tconst socketId = randomUUID();\n\t\t\tconst localEE = new LocalEventEmitter(socketId);\n\n\t\t\tconst entityId = opts.ctx.entity!.id;\n\t\t\tconst eventKey = EventFactory.getSubscriptionKey(eventType, opts.input);\n\n\t\t\tconst instanceId = getInstanceId();\n\t\t\tconst socketInfo = { socketId, eventKey, instanceId };\n\n\t\t\tawait connectEntityToSocketEvent(entityId, socketInfo);\n\t\t\tLocalSubs.bind(entityId, eventKey, localEE);\n\n\t\t\topts.signal?.addEventListener('abort', () => {\n\t\t\t\tLocalSubs.unbind(entityId, eventKey, localEE);\n\t\t\t\tdisconnectEntityFromSocketEvent(entityId, socketInfo).catch(console.error);\n\t\t\t});\n\n\t\t\ttype Out = OutputFor<T>;\n\n\t\t\tfor await (const [data] of on(localEE.ee, eventKey, {\n\t\t\t\tsignal: opts.signal,\n\t\t\t})) {\n\t\t\t\tconst payload = data as Out;\n\t\t\t\tyield tracked(getId(payload), payload);\n\t\t\t}\n\t\t});\n}"]}
1
+ {"version":3,"file":"createSocketSubscriptionProcedure.js","sourceRoot":"/","sources":["libraries/trpc/middlewares/createSocketSubscriptionProcedure.ts"],"names":[],"mappings":";;AA+BA,4DAgCC;AAED,gDAWC;AA3ED,yCAOsB;AACtB,mCAAkC;AAClC,sEAAgE;AAChE,2BAAsB;AACtB,yCAAqC;AAmB9B,KAAK,SAAS,CAAC,CAAC,wBAAwB,CAC3C,OAA8C;IAE9C,MAAM,EAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAC,GAAG,OAAO,CAAC;IAEvD,MAAM,YAAY,GAAG,qBAAY,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC9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ACrB,aAA0D;IAE1D,OAAO,CAAC,IAAsB,EAAE,EAAE,CAC9B,wBAAwB,CAAC;QACrB,SAAS;QACT,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,aAAa;KAChB,CAAC,CAAC;AACX,CAAC","sourcesContent":["import {SocketEventType} from '../../../utilities/enum';\nimport {\n connectEntityToSocketEvent,\n disconnectEntityFromSocketEvent,\n EventFactory,\n LocalEventEmitter,\n LocalSubs,\n OutputFor,\n} from '../../socket';\nimport {randomUUID} from 'crypto';\nimport {getInstanceId} from '../../../utilities/instance.utils';\nimport {on} from 'ws';\nimport {tracked} from '@trpc/server';\n\ninterface SubscriptionContext {\n entity?: { id: string };\n signal?: AbortSignal;\n}\n\ninterface SubscriptionOpts<TInput = any> {\n ctx: SubscriptionContext;\n input: TInput;\n}\n\ninterface CreateSubscriptionOptions<TEventType extends SocketEventType> {\n eventType: TEventType;\n ctx: SubscriptionContext;\n input: any;\n getTrackingId?: (payload: OutputFor<TEventType>) => string;\n}\n\nexport async function* createSocketSubscription<TEventType extends SocketEventType>(\n options: CreateSubscriptionOptions<TEventType>\n) {\n const {eventType, ctx, input, getTrackingId} = options;\n\n const registration = EventFactory.getRegistration(eventType);\n const socketId = randomUUID();\n const localEE = new LocalEventEmitter(socketId);\n\n const entityId = ctx.entity!.id;\n const eventKey = EventFactory.getSubscriptionKey(eventType, input);\n\n const instanceId = getInstanceId();\n const socketInfo = {socketId, eventKey, instanceId};\n\n await connectEntityToSocketEvent(entityId, socketInfo);\n LocalSubs.bind(entityId, eventKey, localEE);\n\n ctx.signal?.addEventListener('abort', () => {\n LocalSubs.unbind(entityId, eventKey, localEE);\n disconnectEntityFromSocketEvent(entityId, socketInfo).catch(console.error);\n });\n\n type Out = OutputFor<TEventType>;\n for await (const [data] of on(localEE.ee, eventKey, {signal: ctx.signal})) {\n const payload = data as Out;\n const id = getTrackingId\n ? getTrackingId(payload)\n : (payload as any)._id?.toString() ?? randomUUID();\n\n yield tracked(id, payload);\n }\n}\n\nexport function socketSubscription<TEventType extends SocketEventType>(\n eventType: TEventType,\n getTrackingId?: (payload: OutputFor<TEventType>) => string\n) {\n return (opts: SubscriptionOpts) =>\n createSocketSubscription({\n eventType,\n ctx: opts.ctx,\n input: opts.input,\n getTrackingId,\n });\n}\n\n/**\n * @Example\n * const socketRouterTwo = createTRPCRouter({\n * onMessage: createAuthenticatedProcedure({entityTypes: [AuthEntityType.CRM]})\n * .input(ChatroomMessageSendSocketInputSchema)\n * .output(\n * zAsyncIterable({\n * yield: ChatroomMessageSendOutputSchema,\n * tracked: true,\n * })\n * )\n * .subscription(socketSubscription(SocketEventType.CHATROOM_MESSAGE_SEND)),\n *\n * onChatMessage: createAuthenticatedProcedure({entityTypes: [AuthEntityType.CRM]})\n * .input(ChatlistMessageSendSocketInputSchema)\n * .output(\n * zAsyncIterable({\n * yield: ChatlistMessageSendSocketOutputSchema,\n * tracked: true,\n * })\n * )\n * .subscription(socketSubscription(SocketEventType.CHATLIST_MESSAGE_RECEIVED)),\n * });\n */\n\n"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.1.31-alpha.5
25
+ Version: 1.1.32
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.1.31-alpha.5",
3
+ "version": "1.1.32",
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,5 +1,2 @@
1
- export declare const BaseCurrencyRoundTo = 0.01;
2
- export declare const SecondaryCurrencyRoundTo = 1000;
3
1
  export declare const roundCurrencySync: (amount: number, roundingFactor: number) => number;
4
- export declare const roundBaseCurrency: (amount: number) => number;
5
- export declare const roundSecondaryCurrency: (amount: number) => number;
2
+ export declare const convertToSecondarySync: (price: number, exchangeRate: number, roundTo: number) => number | null;
@@ -1,27 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.roundSecondaryCurrency = exports.roundBaseCurrency = exports.roundCurrencySync = exports.SecondaryCurrencyRoundTo = exports.BaseCurrencyRoundTo = void 0;
4
- exports.BaseCurrencyRoundTo = 0.01;
5
- exports.SecondaryCurrencyRoundTo = 1000;
3
+ exports.convertToSecondarySync = exports.roundCurrencySync = void 0;
6
4
  const roundCurrencySync = (amount, roundingFactor) => {
7
- if (typeof amount !== 'number' ||
8
- isNaN(amount) ||
9
- typeof roundingFactor !== 'number' ||
10
- roundingFactor <= 0 ||
11
- amount === 0) {
5
+ if (amount == 0)
12
6
  return 0;
13
- }
7
+ const rounded = Math.ceil(amount / roundingFactor) * roundingFactor;
14
8
  const decimals = (roundingFactor.toString().split('.')[1] || '').length;
15
- const rounded = Math.round(amount / roundingFactor) * roundingFactor;
16
9
  return Number(rounded.toFixed(decimals));
17
10
  };
18
11
  exports.roundCurrencySync = roundCurrencySync;
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);
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);
25
21
  };
26
- exports.roundSecondaryCurrency = roundSecondaryCurrency;
22
+ exports.convertToSecondarySync = convertToSecondarySync;
27
23
  //# sourceMappingURL=currency.js.map
@@ -1 +1 @@
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"]}
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};"]}
@@ -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]: T_1[k]; } : never, z.baseObjectInputType<{
650
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
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,7 +685,83 @@ 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
- }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
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>;
689
765
  export type PaginatedDTO<T> = {
690
766
  metadata: DTO<typeof metadataSchema>;
691
767
  documents: T[];
@@ -76,22 +76,34 @@ 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]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[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]: 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>;
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<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
82
+ }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<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
- }> 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, {
84
+ }>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<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_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">>;
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">>;
87
93
  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>]>;
88
94
  getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
89
95
  _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_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
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, {
91
103
  _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
- }> 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, {
104
+ }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
93
105
  _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>]>;
94
- }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
106
+ }>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
95
107
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
96
108
  }, "strict", z.ZodTypeAny, {
97
109
  [x: string]: any;
@@ -114,22 +126,34 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
114
126
  [x: string]: any;
115
127
  }>;
116
128
  getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
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>;
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>;
118
130
  EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
119
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>]>;
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, {
132
+ }> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
121
133
  _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>]>;
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, {
134
+ }>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
123
135
  _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>]>;
124
- }> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<T_5[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
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">>;
125
143
  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>]>;
126
144
  UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
127
145
  _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>]>;
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, {
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, {
129
153
  _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>]>;
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, {
154
+ }> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<z.objectUtil.extendShape<T, {
131
155
  _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_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<T_8[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
156
+ }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
133
157
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
134
158
  }, "strict", z.ZodTypeAny, {
135
159
  [x: string]: any;
@@ -1,3 +1,7 @@
1
+ import { PaidCurrency } from './enum';
2
+ export declare const getRoundingFactor: (currency: PaidCurrency) => Promise<number>;
1
3
  export declare const getExchangeRate: () => Promise<number>;
2
- export declare const convertToBase: (amount: number) => Promise<number>;
3
- export declare const convertToSecondary: (amount: number) => 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;