@lyxa.ai/core 1.0.131 → 1.0.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libraries/mongo/models/admin-access-control.model.d.ts +2 -1
- package/dist/libraries/mongo/models/admin-access-control.model.js +9 -0
- package/dist/libraries/mongo/models/admin-access-control.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/trip-leg.mode.d.ts +2 -2
- package/dist/libraries/mongo/models/embedded/trip-leg.mode.js +1 -1
- package/dist/libraries/mongo/models/embedded/trip-leg.mode.js.map +1 -1
- package/dist/libraries/mongo/models/user.model.d.ts +2 -1
- package/dist/libraries/mongo/models/user.model.js +9 -0
- package/dist/libraries/mongo/models/user.model.js.map +1 -1
- package/dist/utilities/currency.d.ts +4 -2
- package/dist/utilities/currency.js +8 -7
- package/dist/utilities/currency.js.map +1 -1
- package/dist/utilities/validation/common-validation.d.ts +7 -7
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Ref } from '@typegoose/typegoose';
|
|
2
2
|
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
|
-
import { AdminRole } from '../../../utilities/enum';
|
|
3
|
+
import { AdminRole, ShopOnlineStatus } from '../../../utilities/enum';
|
|
4
4
|
import { Admin } from './admin.model';
|
|
5
5
|
export declare class AdminAccessControl extends TimeStamps {
|
|
6
6
|
email: string;
|
|
7
7
|
password: string;
|
|
8
8
|
admin: Ref<Admin>;
|
|
9
9
|
role: AdminRole;
|
|
10
|
+
onlineStatus?: ShopOnlineStatus;
|
|
10
11
|
}
|
|
@@ -27,6 +27,7 @@ let AdminAccessControl = class AdminAccessControl extends defaultClasses_1.TimeS
|
|
|
27
27
|
password;
|
|
28
28
|
admin;
|
|
29
29
|
role;
|
|
30
|
+
onlineStatus;
|
|
30
31
|
};
|
|
31
32
|
exports.AdminAccessControl = AdminAccessControl;
|
|
32
33
|
__decorate([
|
|
@@ -45,6 +46,14 @@ __decorate([
|
|
|
45
46
|
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.AdminRole }),
|
|
46
47
|
__metadata("design:type", String)
|
|
47
48
|
], AdminAccessControl.prototype, "role", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typegoose_1.prop)({
|
|
51
|
+
type: String,
|
|
52
|
+
enum: enum_1.ShopOnlineStatus,
|
|
53
|
+
default: enum_1.ShopOnlineStatus.OFFLINE,
|
|
54
|
+
}),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], AdminAccessControl.prototype, "onlineStatus", void 0);
|
|
48
57
|
exports.AdminAccessControl = AdminAccessControl = __decorate([
|
|
49
58
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
50
59
|
if (this.isModified('password')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-access-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/admin-access-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,4EAAqE;AACrE,wDAA8B;AAC9B,
|
|
1
|
+
{"version":3,"file":"admin-access-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/admin-access-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,4EAAqE;AACrE,wDAA8B;AAC9B,kDAAsE;AACtE,+CAAsC;AAGtC,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,IAAI,GAAG,MAAM,kBAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,OAAO,kBAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC;AAmBM,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,2BAAU;IAE1C,KAAK,CAAU;IAGf,QAAQ,CAAU;IAGlB,KAAK,CAAc;IAGnB,IAAI,CAAa;IAOjB,YAAY,CAAoB;CACvC,CAAA;AAnBY,gDAAkB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AY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,qBAAqB,EAAE,EAAE,CAAC;GAC1D,kBAAkB,CAmB9B","sourcesContent":["import { modelOptions, prop, pre, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport bcrypt from 'bcryptjs';\nimport { AdminRole, ShopOnlineStatus } from '../../../utilities/enum';\nimport { Admin } from './admin.model';\nimport { Query } from 'mongoose';\n\nasync function hashPassword(password: string): Promise<string> {\n\tconst salt = await bcrypt.genSalt(10);\n\treturn bcrypt.hash(password, salt);\n}\n\n@pre<AdminAccessControl>('save', async function (next) {\n\tif (this.isModified('password')) {\n\t\tthis.password = await hashPassword(this.password);\n\t}\n\tnext();\n})\n\n@pre<Query<any, AdminAccessControl>>('findOneAndUpdate', async function (next) {\n\tconst update = this.getUpdate() as Record<string, any>;\n\tif (update?.password) {\n\t\tupdate.password = await hashPassword(update.password);\n\t\tthis.setUpdate(update);\n\t}\n\tnext();\n})\n\n@modelOptions({ schemaOptions: { collection: 'adminAccessControls' } })\nexport class AdminAccessControl extends TimeStamps {\n\t@prop({ required: true, type: String, unique: true })\n\tpublic email!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic password!: string;\n\n\t@prop({ required: true, ref: () => Admin })\n\tpublic admin!: Ref<Admin>;\n\n\t@prop({ required: true, type: String, enum: AdminRole })\n\tpublic role!: AdminRole;\n\n\t@prop({\n\t\ttype: String,\n\t\tenum: ShopOnlineStatus,\n\t\tdefault: ShopOnlineStatus.OFFLINE,\n\t})\n\tpublic onlineStatus?: ShopOnlineStatus;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref, mongoose } from '@typegoose/typegoose';
|
|
2
2
|
import { Rider } from '../rider.model';
|
|
3
|
-
import { FaqAccountType, DeliveryStatus,
|
|
3
|
+
import { FaqAccountType, DeliveryStatus, ItemType } from '../../../../utilities/enum';
|
|
4
4
|
import { User } from '../user.model';
|
|
5
5
|
import { Shop } from '../shop.model';
|
|
6
6
|
import { IDistance, IDuration } from '../../../map/interfaces/IMapService';
|
|
@@ -14,7 +14,7 @@ export declare class TripLeg {
|
|
|
14
14
|
orders?: mongoose.Types.ObjectId[];
|
|
15
15
|
user?: Ref<User>;
|
|
16
16
|
shop?: Ref<Shop>;
|
|
17
|
-
shopType?:
|
|
17
|
+
shopType?: ItemType;
|
|
18
18
|
status?: DeliveryStatus;
|
|
19
19
|
totalDistance?: IDistance;
|
|
20
20
|
totalDuration?: IDuration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trip-leg.mode.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/trip-leg.mode.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2D;AAC3D,gDAAuC;AACvC,gDAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"trip-leg.mode.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/trip-leg.mode.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2D;AAC3D,gDAAuC;AACvC,gDAAuC;AACvC,qDAAsF;AACtF,8CAAqC;AACrC,8CAAqC;AAGrC,MAAa,OAAO;IAEnB,IAAI,CAAU;IAGd,OAAO,CAAU;IAGjB,QAAQ,CAAU;IAGlB,SAAS,CAAU;IAOnB,IAAI,CAAkB;IAGtB,KAAK,CAAc;IAGnB,MAAM,CAA6B;IAGnC,IAAI,CAAa;IAGjB,IAAI,CAAa;IAMjB,QAAQ,CAAY;IAQpB,MAAM,CAAkB;IAGxB,aAAa,CAAa;IAG1B,aAAa,CAAa;IAG1B,qBAAqB,CAAc;IAGnC,QAAQ,CAAa;IAGrB,QAAQ,CAAa;IAKrB,gBAAgB,CAAc;CAC9B;AAjED,0BAiEC;AA/DA;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qCACT;AAGd;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAA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BAAI,GAAE;;yCACc;AAKrB;IAHC,IAAA,gBAAI,EAAC;QACL,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;KAChB,CAAC;;iDAC4B","sourcesContent":["import { Ref, prop, mongoose } from '@typegoose/typegoose';\nimport { Order } from '../order.model';\nimport { Rider } from '../rider.model';\nimport { FaqAccountType, DeliveryStatus, ItemType } from '../../../../utilities/enum';\nimport { User } from '../user.model';\nimport { Shop } from '../shop.model';\nimport { IDistance, IDuration } from '../../../map/interfaces/IMapService';\n\nexport class TripLeg {\n\t@prop({ type: String })\n\tname?: string;\n\n\t@prop({ type: String })\n\taddress?: string;\n\n\t@prop({ required: true, type: Number })\n\tlatitude?: number;\n\n\t@prop({ required: true, type: Number })\n\tlongitude?: number;\n\n\t@prop({\n\t\ttype: String,\n\t\tenum: FaqAccountType,\n\t\tdefault: FaqAccountType.RIDER,\n\t})\n\ttype?: FaqAccountType;\n\n\t@prop({ ref: () => Rider })\n\trider?: Ref<Rider>;\n\n\t@prop({ ref: () => Order })\n\torders?: mongoose.Types.ObjectId[];\n\n\t@prop({ ref: () => User })\n\tuser?: Ref<User>;\n\n\t@prop({ ref: () => Shop })\n\tshop?: Ref<Shop>;\n\n\t@prop({\n\t\ttype: String,\n\t\tenum: ItemType,\n\t})\n\tshopType?: ItemType;\n\n\t@prop({\n\t\ttype: String,\n\t\tenum: DeliveryStatus,\n\t\tdefault: DeliveryStatus.PENDING,\n\t\trequired: true,\n\t})\n\tstatus?: DeliveryStatus;\n\n\t@prop()\n\ttotalDistance?: IDistance;\n\n\t@prop()\n\ttotalDuration?: IDuration;\n\n\t@prop({ type: [[Number]] })\n\ttotalOverviewPolyline?: number[][];\n\n\t@prop()\n\tdistance?: IDistance;\n\n\t@prop()\n\tduration?: IDuration;\n\n\t@prop({\n\t\ttype: [[Number]],\n\t})\n\toverviewPolyline?: number[][];\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import { Shop } from './shop.model';
|
|
|
6
6
|
import { UserAddress } from './shared/address.model';
|
|
7
7
|
import { Coupon } from './coupon.model';
|
|
8
8
|
import { Subscription } from './subscription.model';
|
|
9
|
-
import { Status } from '../../../utilities/enum';
|
|
9
|
+
import { ShopOnlineStatus, Status } from '../../../utilities/enum';
|
|
10
10
|
import { OTPFields } from './embedded/otp-fields.model';
|
|
11
11
|
export declare class User extends TimeStamps {
|
|
12
12
|
coreUser: Ref<CoreUser>;
|
|
@@ -28,6 +28,7 @@ export declare class User extends TimeStamps {
|
|
|
28
28
|
phoneNumber?: string;
|
|
29
29
|
phoneOtpInfo?: OTPFields;
|
|
30
30
|
isPhoneVerified?: boolean;
|
|
31
|
+
onlineStatus?: ShopOnlineStatus;
|
|
31
32
|
static updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number): Promise<(mongoose.Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, User, import("@typegoose/typegoose/lib/types").BeAnyObject> & Omit<User & {
|
|
32
33
|
_id: mongoose.Types.ObjectId;
|
|
33
34
|
} & {
|
|
@@ -41,6 +41,7 @@ let User = User_1 = class User extends defaultClasses_1.TimeStamps {
|
|
|
41
41
|
phoneNumber;
|
|
42
42
|
phoneOtpInfo;
|
|
43
43
|
isPhoneVerified;
|
|
44
|
+
onlineStatus;
|
|
44
45
|
static async updateWallet(userId, amount) {
|
|
45
46
|
return this.findByIdAndUpdate(userId, { $inc: { walletBalance: amount } }, { new: true });
|
|
46
47
|
}
|
|
@@ -122,6 +123,14 @@ __decorate([
|
|
|
122
123
|
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
123
124
|
__metadata("design:type", Boolean)
|
|
124
125
|
], User.prototype, "isPhoneVerified", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
(0, typegoose_1.prop)({
|
|
128
|
+
type: String,
|
|
129
|
+
enum: enum_1.ShopOnlineStatus,
|
|
130
|
+
default: enum_1.ShopOnlineStatus.OFFLINE,
|
|
131
|
+
}),
|
|
132
|
+
__metadata("design:type", String)
|
|
133
|
+
], User.prototype, "onlineStatus", void 0);
|
|
125
134
|
exports.User = User = User_1 = __decorate([
|
|
126
135
|
(0, typegoose_1.index)({ location: '2dsphere' }),
|
|
127
136
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'users' } })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.model.js","sourceRoot":"/","sources":["libraries/mongo/models/user.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,oDAAiG;AACjG,4EAAqE;AACrE,uDAA6C;AAC7C,mDAA0C;AAC1C,6CAAoC;AACpC,0DAAqD;AACrD,iDAAwC;AACxC,6DAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"user.model.js","sourceRoot":"/","sources":["libraries/mongo/models/user.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,oDAAiG;AACjG,4EAAqE;AACrE,uDAA6C;AAC7C,mDAA0C;AAC1C,6CAAoC;AACpC,0DAAqD;AACrD,iDAAwC;AACxC,6DAAoD;AACpD,kDAAmE;AACnE,kEAAwD;AAIjD,IAAM,IAAI,YAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,QAAQ,CAAiB;IAGzB,gBAAgB,CAAkB;IAGlC,aAAa,CAAe;IAG5B,SAAS,CAAiB;IAG1B,MAAM,CAAU;IAGhB,cAAc,CAAU;IAGxB,eAAe,CAAQ;IAGvB,aAAa,CAAU;IAGvB,OAAO,CAAiB;IAGxB,yBAAyB,CAAU;IAGnC,kBAAkB,CAAU;IAG5B,iCAAiC,CAAU;IAG3C,qBAAqB,CAAW;IAGhC,YAAY,CAAe;IAG3B,YAAY,CAAqB;IAGjC,YAAY,CAAW;IAGvB,WAAW,CAAU;IAGrB,YAAY,CAAa;IAGzB,eAAe,CAAW;IAO1B,YAAY,CAAoB;IAEhC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAqC,MAAc,EAAE,MAAc;QAClG,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE,IAAI,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import { index, modelOptions, mongoose, prop, Ref, ReturnModelType } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CoreUser } from './core-user.model';\nimport { Product } from './product.model';\nimport { Shop } from './shop.model';\nimport { UserAddress } from './shared/address.model';\nimport { Coupon } from './coupon.model';\nimport { Subscription } from './subscription.model';\nimport { ShopOnlineStatus, Status } from '../../../utilities/enum';\nimport { OTPFields } from './embedded/otp-fields.model';\n\n@index({ location: '2dsphere' })\n@modelOptions({ schemaOptions: { collection: 'users' } })\nexport class User extends TimeStamps {\n\t@prop({ required: true, ref: () => CoreUser })\n\tpublic coreUser!: Ref<CoreUser>;\n\n\t@prop({ type: () => [String], ref: () => Product })\n\tpublic favoriteProducts?: Ref<Product>[];\n\n\t@prop({ type: () => [String], ref: () => Shop })\n\tpublic favoriteShops?: Ref<Shop>[];\n\n\t@prop({ type: () => [UserAddress] })\n\tpublic addresses?: UserAddress[];\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic orderCompleted?: number;\n\n\t@prop({ type: Date })\n\tpublic repeatedOrderAt?: Date;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic walletBalance?: number;\n\n\t@prop({ ref: () => Coupon })\n\tpublic coupons?: Ref<Coupon>[];\n\n\t@prop({ type: String })\n\tpublic newUserCouponDiscountType?: string;\n\n\t@prop({ type: Number })\n\tpublic newUserCouponValue?: number;\n\n\t@prop({ type: Number })\n\tpublic newUserCouponMaximumDiscountLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isNewUserCouponShowed?: boolean;\n\n\t@prop({ ref: () => Coupon })\n\tpublic referralCode?: Ref<Coupon>;\n\n\t@prop({ type: String, ref: () => Subscription })\n\tpublic subscription?: Ref<Subscription>;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSubscribed?: boolean;\n\n\t@prop({ type: String, unique: true, sparse: true })\n\tpublic phoneNumber?: string;\n\n\t@prop({ type: () => OTPFields })\n\tpublic phoneOtpInfo?: OTPFields;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isPhoneVerified?: boolean;\n\n\t@prop({\n\t\ttype: String,\n\t\tenum: ShopOnlineStatus,\n\t\tdefault: ShopOnlineStatus.OFFLINE,\n\t})\n\tpublic onlineStatus?: ShopOnlineStatus;\n\n\tpublic static async updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number) {\n\t\treturn this.findByIdAndUpdate(userId, { $inc: { walletBalance: amount } }, { new: true });\n\t}\n}\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { PaidCurrency } from './enum';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
2
|
+
export declare const getRoundingFactor: (currency: PaidCurrency) => Promise<number>;
|
|
3
|
+
export declare const getExchangeRate: () => Promise<number>;
|
|
4
|
+
export declare const roundCurrency: (amount: number, currency: PaidCurrency, roundingFactor?: number) => Promise<number>;
|
|
5
|
+
export declare const convertToSecondary: (amount: number, exchangeRate?: number, roundTo?: number) => Promise<number>;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToSecondary = exports.roundCurrency = void 0;
|
|
3
|
+
exports.convertToSecondary = exports.roundCurrency = exports.getExchangeRate = exports.getRoundingFactor = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
const enum_1 = require("./enum");
|
|
6
6
|
const DEFAULT_ROUNDING_FACTOR = 0.01;
|
|
7
7
|
const DEFAULT_EXCHANGE_RATE = 1;
|
|
8
8
|
const getRoundingFactor = async (currency) => {
|
|
9
|
-
const settingsService = (0, __1.getLibraries)().getCachedSettingsService();
|
|
10
9
|
const setting = (await (0, __1.getLibraries)().getCachedSettingsService().getSettings());
|
|
11
10
|
const currencySetting = setting.currencySetting;
|
|
12
11
|
let roundingFactor;
|
|
@@ -25,19 +24,21 @@ const getRoundingFactor = async (currency) => {
|
|
|
25
24
|
}
|
|
26
25
|
return roundingFactor || DEFAULT_ROUNDING_FACTOR;
|
|
27
26
|
};
|
|
27
|
+
exports.getRoundingFactor = getRoundingFactor;
|
|
28
28
|
const getExchangeRate = async () => {
|
|
29
29
|
const settings = (await (0, __1.getLibraries)().getCachedSettingsService().getSettings());
|
|
30
30
|
const currencySetting = settings.currencySetting;
|
|
31
31
|
return currencySetting?.exchangeRate || DEFAULT_EXCHANGE_RATE;
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
exports.getExchangeRate = getExchangeRate;
|
|
34
|
+
const roundCurrency = async (amount, currency, roundingFactor) => {
|
|
35
|
+
roundingFactor = roundingFactor ?? (await (0, exports.getRoundingFactor)(currency));
|
|
35
36
|
return Math.round(amount / roundingFactor) * roundingFactor;
|
|
36
37
|
};
|
|
37
38
|
exports.roundCurrency = roundCurrency;
|
|
38
|
-
const convertToSecondary = async (amount) => {
|
|
39
|
-
|
|
40
|
-
return (0, exports.roundCurrency)(amount *
|
|
39
|
+
const convertToSecondary = async (amount, exchangeRate, roundTo) => {
|
|
40
|
+
exchangeRate = exchangeRate ?? (await (0, exports.getExchangeRate)());
|
|
41
|
+
return (0, exports.roundCurrency)(amount * (await (0, exports.getExchangeRate)()), enum_1.PaidCurrency.SECONDARY, roundTo);
|
|
41
42
|
};
|
|
42
43
|
exports.convertToSecondary = convertToSecondary;
|
|
43
44
|
//# sourceMappingURL=currency.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/currency.ts"],"names":[],"mappings":";;;AAAA,0BAAkC;AAGlC,iCAAsC;AAEtC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,qBAAqB,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/currency.ts"],"names":[],"mappings":";;;AAAA,0BAAkC;AAGlC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AI,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;AAC7D,CAAC,CAAC;AAPW,QAAA,aAAa,iBAOxB;AAEK,MAAM,kBAAkB,GAAG,KAAK,EACtC,MAAc,EACd,YAAqB,EACrB,OAAgB,EACE,EAAE;IACpB,YAAY,GAAG,YAAY,IAAI,CAAC,MAAM,IAAA,uBAAe,GAAE,CAAC,CAAC;IACzD,OAAO,IAAA,qBAAa,EAAC,MAAM,GAAG,CAAC,MAAM,IAAA,uBAAe,GAAE,CAAC,EAAE,mBAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC3F,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B","sourcesContent":["import { getLibraries } from '..';\n\nimport { Setting } from '../libraries/mongo/models';\nimport { PaidCurrency } from './enum';\n\nconst DEFAULT_ROUNDING_FACTOR = 0.01;\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\troundingFactor = roundingFactor ?? (await getRoundingFactor(currency));\n\treturn Math.round(amount / roundingFactor) * roundingFactor;\n};\n\nexport const convertToSecondary = async (\n\tamount: number,\n\texchangeRate?: number,\n\troundTo?: number\n): Promise<number> => {\n\texchangeRate = exchangeRate ?? (await getExchangeRate());\n\treturn roundCurrency(amount * (await getExchangeRate()), PaidCurrency.SECONDARY, roundTo);\n};\n"]}
|
|
@@ -90,7 +90,7 @@ export declare const AddressSchema: z.ZodObject<{
|
|
|
90
90
|
zone?: string | import("mongoose").Types.ObjectId | undefined;
|
|
91
91
|
}>;
|
|
92
92
|
export type AddressDTO = DTO<typeof AddressSchema>;
|
|
93
|
-
export declare const UserAddressSchema: z.ZodObject<
|
|
93
|
+
export declare const UserAddressSchema: z.ZodObject<{
|
|
94
94
|
address: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
95
95
|
description: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
96
96
|
city: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
@@ -109,13 +109,13 @@ export declare const UserAddressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
109
109
|
latitude: z.ZodNumber;
|
|
110
110
|
longitude: z.ZodNumber;
|
|
111
111
|
zone: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
|
|
112
|
-
}
|
|
112
|
+
} & {
|
|
113
113
|
addressLabel: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
114
114
|
apartment: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
115
115
|
buildingName: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
116
116
|
deliveryOption: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
117
117
|
instructions: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
118
|
-
}
|
|
118
|
+
}, "strip", z.ZodTypeAny, {
|
|
119
119
|
location: {
|
|
120
120
|
type: GeoLocationType;
|
|
121
121
|
coordinates: [number, number];
|
|
@@ -153,7 +153,7 @@ export declare const UserAddressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
153
153
|
instructions?: string | undefined;
|
|
154
154
|
}>;
|
|
155
155
|
export type UserAddressDTO = DTO<typeof UserAddressSchema>;
|
|
156
|
-
export declare const CourierAddressSchema: z.ZodObject<
|
|
156
|
+
export declare const CourierAddressSchema: z.ZodObject<{
|
|
157
157
|
address: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
158
158
|
description: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
159
159
|
city: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
@@ -172,16 +172,16 @@ export declare const CourierAddressSchema: z.ZodObject<z.objectUtil.extendShape<
|
|
|
172
172
|
latitude: z.ZodNumber;
|
|
173
173
|
longitude: z.ZodNumber;
|
|
174
174
|
zone: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
|
|
175
|
-
}
|
|
175
|
+
} & {
|
|
176
176
|
addressLabel: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
177
177
|
apartment: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
178
178
|
buildingName: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
179
179
|
deliveryOption: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
180
180
|
instructions: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
181
|
-
}
|
|
181
|
+
} & {
|
|
182
182
|
name: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
183
183
|
phoneNumber: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
184
|
-
}
|
|
184
|
+
}, "strip", z.ZodTypeAny, {
|
|
185
185
|
name: string;
|
|
186
186
|
location: {
|
|
187
187
|
type: GeoLocationType;
|