@lyxa.ai/core 1.1.69 → 1.1.72
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/base/base-coupon.model.d.ts +4 -0
- package/dist/libraries/mongo/models/base/base-coupon.model.js +20 -0
- package/dist/libraries/mongo/models/base/base-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/chat-room.model.d.ts +2 -0
- package/dist/libraries/mongo/models/chat-room.model.js +6 -0
- package/dist/libraries/mongo/models/chat-room.model.js.map +1 -1
- package/dist/libraries/mongo/models/coupon.model.d.ts +1 -0
- package/dist/libraries/mongo/models/coupon.model.js +5 -0
- package/dist/libraries/mongo/models/coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/buy1-get1-marketing.model.d.ts +1 -0
- package/dist/libraries/mongo/models/providers/buy1-get1-marketing.model.js +5 -0
- package/dist/libraries/mongo/models/providers/buy1-get1-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/discount-marketing.model.d.ts +2 -0
- package/dist/libraries/mongo/models/providers/discount-marketing.model.js +10 -0
- package/dist/libraries/mongo/models/providers/discount-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/free-delivery-marketing.model.d.ts +1 -0
- package/dist/libraries/mongo/models/providers/free-delivery-marketing.model.js +5 -0
- package/dist/libraries/mongo/models/providers/free-delivery-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/ticket.model.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/utilities/time.d.ts +4 -0
- package/dist/utilities/time.js +76 -0
- package/dist/utilities/time.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,10 +5,14 @@ export declare class BaseCoupon extends Coupon {
|
|
|
5
5
|
valueType: ValueType;
|
|
6
6
|
value: number;
|
|
7
7
|
maxDiscountLimit?: number | null;
|
|
8
|
+
isMaxDiscountLimitEnabled?: boolean;
|
|
8
9
|
duration: Duration;
|
|
9
10
|
spendLimit?: number | null;
|
|
11
|
+
isSpendLimitEnabled?: boolean;
|
|
10
12
|
totalOrderLimit?: number | null;
|
|
13
|
+
isTotalOrderLimitEnabled?: boolean;
|
|
11
14
|
minOrderValue?: number | null;
|
|
15
|
+
isMinOrderValueEnabled?: boolean;
|
|
12
16
|
forNewUserOnly?: boolean;
|
|
13
17
|
status?: Status;
|
|
14
18
|
expirationReason?: CouponExpirationReason;
|
|
@@ -18,10 +18,14 @@ class BaseCoupon extends coupon_model_1.Coupon {
|
|
|
18
18
|
valueType;
|
|
19
19
|
value;
|
|
20
20
|
maxDiscountLimit;
|
|
21
|
+
isMaxDiscountLimitEnabled;
|
|
21
22
|
duration;
|
|
22
23
|
spendLimit;
|
|
24
|
+
isSpendLimitEnabled;
|
|
23
25
|
totalOrderLimit;
|
|
26
|
+
isTotalOrderLimitEnabled;
|
|
24
27
|
minOrderValue;
|
|
28
|
+
isMinOrderValueEnabled;
|
|
25
29
|
forNewUserOnly;
|
|
26
30
|
status;
|
|
27
31
|
expirationReason;
|
|
@@ -39,6 +43,10 @@ __decorate([
|
|
|
39
43
|
(0, typegoose_1.prop)({ type: Number, default: null }),
|
|
40
44
|
__metadata("design:type", Object)
|
|
41
45
|
], BaseCoupon.prototype, "maxDiscountLimit", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
48
|
+
__metadata("design:type", Boolean)
|
|
49
|
+
], BaseCoupon.prototype, "isMaxDiscountLimitEnabled", void 0);
|
|
42
50
|
__decorate([
|
|
43
51
|
(0, typegoose_1.prop)({ required: true, type: duration_model_1.Duration }),
|
|
44
52
|
__metadata("design:type", duration_model_1.Duration)
|
|
@@ -47,14 +55,26 @@ __decorate([
|
|
|
47
55
|
(0, typegoose_1.prop)({ type: Number, default: null }),
|
|
48
56
|
__metadata("design:type", Object)
|
|
49
57
|
], BaseCoupon.prototype, "spendLimit", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
60
|
+
__metadata("design:type", Boolean)
|
|
61
|
+
], BaseCoupon.prototype, "isSpendLimitEnabled", void 0);
|
|
50
62
|
__decorate([
|
|
51
63
|
(0, typegoose_1.prop)({ type: Number, default: null }),
|
|
52
64
|
__metadata("design:type", Object)
|
|
53
65
|
], BaseCoupon.prototype, "totalOrderLimit", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
68
|
+
__metadata("design:type", Boolean)
|
|
69
|
+
], BaseCoupon.prototype, "isTotalOrderLimitEnabled", void 0);
|
|
54
70
|
__decorate([
|
|
55
71
|
(0, typegoose_1.prop)({ type: Number, default: null }),
|
|
56
72
|
__metadata("design:type", Object)
|
|
57
73
|
], BaseCoupon.prototype, "minOrderValue", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
76
|
+
__metadata("design:type", Boolean)
|
|
77
|
+
], BaseCoupon.prototype, "isMinOrderValueEnabled", void 0);
|
|
58
78
|
__decorate([
|
|
59
79
|
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
60
80
|
__metadata("design:type", Boolean)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-coupon.model.js","sourceRoot":"/","sources":["libraries/mongo/models/base/base-coupon.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,qDAAuF;AACvF,6DAAoD;AACpD,kDAAyC;AAEzC,MAAa,UAAW,SAAQ,qBAAM;IAE9B,SAAS,CAAa;IAGtB,KAAK,CAAU;IAGf,gBAAgB,CAAiB;IAGjC,QAAQ,CAAY;IAGpB,UAAU,CAAiB;IAG3B,eAAe,CAAiB;IAGhC,aAAa,CAAiB;IAG9B,cAAc,CAAW;IAGzB,MAAM,CAAU;IAGhB,gBAAgB,CAA0B;CACjD;
|
|
1
|
+
{"version":3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ACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;mDACC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;4DACE;AAGnC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;iDACD;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;0DACA;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;kDACR;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;0CACtC;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,6BAAsB,EAAE,CAAC;;oDACJ","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { CouponExpirationReason, Status, ValueType } from '../../../../utilities/enum';\nimport { Duration } from '../shared/duration.model';\nimport { Coupon } from '../coupon.model';\n\nexport class BaseCoupon extends Coupon {\n\t@prop({ required: true, type: String, enum: ValueType })\n\tpublic valueType!: ValueType;\n\n\t@prop({ required: true, type: Number })\n\tpublic value!: number;\n\n\t@prop({ type: Number, default: null }) // applicable when valueType percentage\n\tpublic maxDiscountLimit?: number | null;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isMaxDiscountLimitEnabled?: boolean;\n\n\t@prop({ required: true, type: Duration })\n\tpublic duration!: Duration;\n\n\t@prop({ type: Number, default: null })\n\tpublic spendLimit?: number | null;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSpendLimitEnabled?: boolean;\n\n\t@prop({ type: Number, default: null })\n\tpublic totalOrderLimit?: number | null;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isTotalOrderLimitEnabled?: boolean;\n\n\t@prop({ type: Number, default: null })\n\tpublic minOrderValue?: number | null;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isMinOrderValueEnabled?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic forNewUserOnly?: boolean;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: String, enum: CouponExpirationReason })\n\tpublic expirationReason?: CouponExpirationReason;\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import { Shop } from './shop.model';
|
|
|
7
7
|
import { Admin } from './admin.model';
|
|
8
8
|
import { Rider } from './rider.model';
|
|
9
9
|
import { Types } from 'mongoose';
|
|
10
|
+
import { Order } from './order.model';
|
|
10
11
|
declare class LastMessage extends TimeStamps {
|
|
11
12
|
_id: Types.ObjectId;
|
|
12
13
|
content: string;
|
|
@@ -19,6 +20,7 @@ export declare class Chatroom extends TimeStamps {
|
|
|
19
20
|
lastMessage?: LastMessage;
|
|
20
21
|
isActive?: boolean;
|
|
21
22
|
lastMessageAt?: Date;
|
|
23
|
+
order?: Ref<Order>;
|
|
22
24
|
messageCount?: number;
|
|
23
25
|
}
|
|
24
26
|
export {};
|
|
@@ -15,6 +15,7 @@ const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
|
15
15
|
const chat_participant_model_1 = require("./embedded/chat-participant.model");
|
|
16
16
|
const enum_1 = require("../../../utilities/enum");
|
|
17
17
|
const mongoose_1 = require("mongoose");
|
|
18
|
+
const order_model_1 = require("./order.model");
|
|
18
19
|
class LastMessage extends defaultClasses_1.TimeStamps {
|
|
19
20
|
_id;
|
|
20
21
|
content;
|
|
@@ -43,6 +44,7 @@ let Chatroom = class Chatroom extends defaultClasses_1.TimeStamps {
|
|
|
43
44
|
lastMessage;
|
|
44
45
|
isActive;
|
|
45
46
|
lastMessageAt;
|
|
47
|
+
order;
|
|
46
48
|
messageCount;
|
|
47
49
|
};
|
|
48
50
|
exports.Chatroom = Chatroom;
|
|
@@ -66,6 +68,10 @@ __decorate([
|
|
|
66
68
|
(0, typegoose_1.prop)({ type: Date }),
|
|
67
69
|
__metadata("design:type", Date)
|
|
68
70
|
], Chatroom.prototype, "lastMessageAt", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, typegoose_1.prop)({ ref: () => order_model_1.Order }),
|
|
73
|
+
__metadata("design:type", Object)
|
|
74
|
+
], Chatroom.prototype, "order", void 0);
|
|
69
75
|
__decorate([
|
|
70
76
|
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
71
77
|
__metadata("design:type", Number)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-room.model.js","sourceRoot":"/","sources":["libraries/mongo/models/chat-room.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,8EAAoE;AACpE,kDAAgE;AAKhE,uCAAiC;
|
|
1
|
+
{"version":3,"file":"chat-room.model.js","sourceRoot":"/","sources":["libraries/mongo/models/chat-room.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,8EAAoE;AACpE,kDAAgE;AAKhE,uCAAiC;AACjC,+CAAsC;AAEtC,MAAM,WAAY,SAAQ,2BAAU;IAE5B,GAAG,CAAkB;IAGrB,OAAO,CAAU;IAGjB,UAAU,CAAW;IAGrB,MAAM,CAAoC;CACjD;AAVO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,gBAAK,CAAC,QAAQ,EAAE,CAAC;8BAClB,gBAAK,CAAC,QAAQ;wCAAC;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACf;AAGjB;IADN,IAAA,gBAAI,EAAC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C,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAC/B,IAAA,iBAAK,EAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,CAAC;IACxD,IAAA,iBAAK,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACpB,IAAA,iBAAK,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IACxB,IAAA,iBAAK,EAAC,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC;IAC3B,IAAA,iBAAK,EAAC,EAAE,gCAAgC,EAAE,CAAC,EAAE,CAAC;GAClC,QAAQ,CAqBpB","sourcesContent":["import { index, modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ChatParticipant } from './embedded/chat-participant.model';\nimport { ChatroomType, UserRef } from '../../../utilities/enum';\nimport { User } from './user.model';\nimport { Shop } from './shop.model';\nimport { Admin } from './admin.model';\nimport { Rider } from './rider.model';\nimport { Types } from 'mongoose';\nimport { Order } from './order.model';\n\nclass LastMessage extends TimeStamps {\n\t@prop({ type: Types.ObjectId })\n\tpublic _id!: Types.ObjectId;\n\n\t@prop({ required: true, type: String })\n\tpublic content!: string;\n\n\t@prop({ required: true, type: String, enum: UserRef })\n\tpublic senderType!: UserRef;\n\n\t@prop({ refPath: 'senderType' })\n\tpublic sender!: Ref<User | Admin | Shop | Rider>;\n}\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'chatrooms',\n\t\ttimestamps: true,\n\t},\n})\n@index({ type: 1, isActive: 1 })\n@index({ 'participants.ref': 1, 'participants.type': 1 })\n@index({ ticket: 1 })\n@index({ createdAt: -1 })\n@index({ messageCount: -1 })\n@index({ 'participants.lastReadMessageAt': 1 })\nexport class Chatroom extends TimeStamps {\n\t@prop({ enum: ChatroomType, required: true })\n\ttype!: ChatroomType;\n\n\t@prop({ type: () => [ChatParticipant], required: true })\n\tparticipants!: ChatParticipant[];\n\n\t@prop({ type: LastMessage })\n\tlastMessage?: LastMessage;\n\n\t@prop({ type: Boolean, default: true })\n\tisActive?: boolean;\n\n\t@prop({ type: Date })\n\tlastMessageAt?: Date;\n\n\t@prop({ ref: () => Order })\n\tpublic order?: Ref<Order>;\n\n\t@prop({ type: Number, default: 0 })\n\tmessageCount?: number;\n}\n"]}
|
|
@@ -18,6 +18,7 @@ let Coupon = class Coupon extends defaultClasses_1.TimeStamps {
|
|
|
18
18
|
code;
|
|
19
19
|
couponType;
|
|
20
20
|
orderLimitPerUser;
|
|
21
|
+
isOrderLimitPerUserEnabled;
|
|
21
22
|
previousVersions;
|
|
22
23
|
updatedVersion;
|
|
23
24
|
createdBy;
|
|
@@ -35,6 +36,10 @@ __decorate([
|
|
|
35
36
|
(0, typegoose_1.prop)({ type: Number, default: null }),
|
|
36
37
|
__metadata("design:type", Object)
|
|
37
38
|
], Coupon.prototype, "orderLimitPerUser", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
41
|
+
__metadata("design:type", Boolean)
|
|
42
|
+
], Coupon.prototype, "isOrderLimitPerUserEnabled", void 0);
|
|
38
43
|
__decorate([
|
|
39
44
|
(0, typegoose_1.prop)({ ref: () => Coupon }),
|
|
40
45
|
__metadata("design:type", Array)
|
|
@@ -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;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;
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,EAAE,YAAY,EAAE;KACxE,CAAC;GACW,MAAM,CAsBlB","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({ type: Boolean, default: false })\n\tpublic isOrderLimitPerUserEnabled?: boolean;\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"]}
|
|
@@ -20,6 +20,7 @@ class Buy1Get1Marketing extends marketing_model_1.Marketing {
|
|
|
20
20
|
isEntireMenu;
|
|
21
21
|
products;
|
|
22
22
|
spendLimit;
|
|
23
|
+
isSpendLimitEnabled;
|
|
23
24
|
isOnlyForSubscriber;
|
|
24
25
|
categories;
|
|
25
26
|
}
|
|
@@ -40,6 +41,10 @@ __decorate([
|
|
|
40
41
|
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
41
42
|
__metadata("design:type", Number)
|
|
42
43
|
], Buy1Get1Marketing.prototype, "spendLimit", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
46
|
+
__metadata("design:type", Boolean)
|
|
47
|
+
], Buy1Get1Marketing.prototype, "isSpendLimitEnabled", void 0);
|
|
43
48
|
__decorate([
|
|
44
49
|
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
45
50
|
__metadata("design:type", Boolean)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buy1-get1-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/buy1-get1-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAA2D;AAC3D,wDAA+C;AAC/C,wEAA8D;AAC9D,gEAAsD;AAEtD,MAAa,iBAAkB,SAAQ,2BAAS;IACxC,aAAa,GAAG,oBAAa,CAAC,QAAiB,CAAC;IAGhD,YAAY,CAAW;IAOvB,QAAQ,CAAwB;IAGhC,UAAU,CAAU;IAGpB,mBAAmB,CAAW;IAG9B,UAAU,CAAsB;CACvC;
|
|
1
|
+
{"version":3,"file":"buy1-get1-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/buy1-get1-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAA2D;AAC3D,wDAA+C;AAC/C,wEAA8D;AAC9D,gEAAsD;AAEtD,MAAa,iBAAkB,SAAQ,2BAAS;IACxC,aAAa,GAAG,oBAAa,CAAC,QAAiB,CAAC;IAGhD,YAAY,CAAW;IAOvB,QAAQ,CAAwB;IAGhC,UAAU,CAAU;IAGpB,mBAAmB,CAAW;IAG9B,mBAAmB,CAAW;IAG9B,UAAU,CAAsB;CACvC;AAxBD,8CAwBC;AApBO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;uDACV;AAOvB;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,0CAAgB;QAC3B,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,KAAK;KACjB,CAAC;;mDACqC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;qDACR;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8DACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8DACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;;qDACK","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { MarketingType } from '../../../../utilities/enum';\nimport { Marketing } from '../marketing.model';\nimport { ProductMarketing } from '../product-marketing.model';\nimport { ShopCategory } from '../shop-category.model';\n\nexport class Buy1Get1Marketing extends Marketing {\n\tpublic marketingType = MarketingType.BUY1GET1 as const;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isEntireMenu?: boolean;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'marketing',\n\t\tlocalField: '_id',\n\t})\n\tpublic products: Ref<ProductMarketing>;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSpendLimitEnabled?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isOnlyForSubscriber?: boolean;\n\n\t@prop({ ref: () => ShopCategory })\n\tpublic categories: Ref<ShopCategory>[];\n}\n"]}
|
|
@@ -10,7 +10,9 @@ export declare class DiscountMarketing extends Marketing {
|
|
|
10
10
|
value?: number;
|
|
11
11
|
products: Ref<ProductMarketing>;
|
|
12
12
|
maxDiscountPerOrder?: number;
|
|
13
|
+
isMaxDiscountPerOrderEnabled?: boolean;
|
|
13
14
|
spendLimit?: number;
|
|
15
|
+
isSpendLimitEnabled?: boolean;
|
|
14
16
|
isOnlyForSubscriber?: boolean;
|
|
15
17
|
categoryValue?: number;
|
|
16
18
|
categoryValueType?: ValueType;
|
|
@@ -22,7 +22,9 @@ class DiscountMarketing extends marketing_model_1.Marketing {
|
|
|
22
22
|
value;
|
|
23
23
|
products;
|
|
24
24
|
maxDiscountPerOrder;
|
|
25
|
+
isMaxDiscountPerOrderEnabled;
|
|
25
26
|
spendLimit;
|
|
27
|
+
isSpendLimitEnabled;
|
|
26
28
|
isOnlyForSubscriber;
|
|
27
29
|
categoryValue;
|
|
28
30
|
categoryValueType;
|
|
@@ -53,10 +55,18 @@ __decorate([
|
|
|
53
55
|
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
54
56
|
__metadata("design:type", Number)
|
|
55
57
|
], DiscountMarketing.prototype, "maxDiscountPerOrder", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
60
|
+
__metadata("design:type", Boolean)
|
|
61
|
+
], DiscountMarketing.prototype, "isMaxDiscountPerOrderEnabled", void 0);
|
|
56
62
|
__decorate([
|
|
57
63
|
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
58
64
|
__metadata("design:type", Number)
|
|
59
65
|
], DiscountMarketing.prototype, "spendLimit", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
68
|
+
__metadata("design:type", Boolean)
|
|
69
|
+
], DiscountMarketing.prototype, "isSpendLimitEnabled", void 0);
|
|
60
70
|
__decorate([
|
|
61
71
|
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
62
72
|
__metadata("design:type", Boolean)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discount-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/discount-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAsE;AACtE,wDAA+C;AAC/C,wEAA8D;AAC9D,gEAAsD;AAEtD,MAAa,iBAAkB,SAAQ,2BAAS;IACxC,aAAa,GAAG,oBAAa,CAAC,QAAiB,CAAC;IAGhD,YAAY,CAAW;IAGvB,SAAS,CAAa;IAGtB,KAAK,CAAU;IAOf,QAAQ,CAAwB;IAGhC,mBAAmB,CAAU;IAG7B,UAAU,CAAU;IAGpB,mBAAmB,CAAW;IAG9B,aAAa,CAAU;IAGvB,iBAAiB,CAAa;IAG9B,UAAU,CAAsB;CACvC;
|
|
1
|
+
{"version":3,"file":"discount-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/discount-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAsE;AACtE,wDAA+C;AAC/C,wEAA8D;AAC9D,gEAAsD;AAEtD,MAAa,iBAAkB,SAAQ,2BAAS;IACxC,aAAa,GAAG,oBAAa,CAAC,QAAiB,CAAC;IAGhD,YAAY,CAAW;IAGvB,SAAS,CAAa;IAGtB,KAAK,CAAU;IAOf,QAAQ,CAAwB;IAGhC,mBAAmB,CAAU;IAG7B,4BAA4B,CAAW;IAGvC,UAAU,CAAU;IAGpB,mBAAmB,CAAW;IAG9B,mBAAmB,CAAW;IAG9B,aAAa,CAAU;IAGvB,iBAAiB,CAAa;IAG9B,UAAU,CAAsB;CACvC;AA1CD,8CA0CC;AAtCO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;uDACV;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAS,EAAE,CAAC;;oDACX;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACD;AAOf;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,0CAAgB;QAC3B,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,KAAK;KACjB,CAAC;;mDACqC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8DACC;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;uEACM;AAGvC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;qDACR;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8DACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8DACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;wDACL;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAS,EAAE,OAAO,EAAE,gBAAS,CAAC,UAAU,EAAE,CAAC;;4DAClC;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;;qDACK","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { MarketingType, ValueType } from '../../../../utilities/enum';\nimport { Marketing } from '../marketing.model';\nimport { ProductMarketing } from '../product-marketing.model';\nimport { ShopCategory } from '../shop-category.model';\n\nexport class DiscountMarketing extends Marketing {\n\tpublic marketingType = MarketingType.DISCOUNT as const;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isEntireMenu?: boolean;\n\n\t@prop({ type: String, enum: ValueType })\n\tpublic valueType?: ValueType;\n\n\t@prop({ type: Number })\n\tpublic value?: number;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'marketing',\n\t\tlocalField: '_id',\n\t})\n\tpublic products: Ref<ProductMarketing>;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic maxDiscountPerOrder?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isMaxDiscountPerOrderEnabled?: boolean;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSpendLimitEnabled?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isOnlyForSubscriber?: boolean;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic categoryValue?: number;\n\n\t@prop({ type: String, enum: ValueType, default: ValueType.PERCENTAGE })\n\tpublic categoryValueType?: ValueType;\n\n\t@prop({ ref: () => ShopCategory })\n\tpublic categories: Ref<ShopCategory>[];\n}"]}
|
|
@@ -16,10 +16,15 @@ const marketing_model_1 = require("../marketing.model");
|
|
|
16
16
|
class FreeDeliveryMarketing extends marketing_model_1.Marketing {
|
|
17
17
|
marketingType = enum_1.MarketingType.FREE_DELIVERY;
|
|
18
18
|
spendLimit;
|
|
19
|
+
isSpendLimitEnabled;
|
|
19
20
|
}
|
|
20
21
|
exports.FreeDeliveryMarketing = FreeDeliveryMarketing;
|
|
21
22
|
__decorate([
|
|
22
23
|
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
23
24
|
__metadata("design:type", Number)
|
|
24
25
|
], FreeDeliveryMarketing.prototype, "spendLimit", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
28
|
+
__metadata("design:type", Boolean)
|
|
29
|
+
], FreeDeliveryMarketing.prototype, "isSpendLimitEnabled", void 0);
|
|
25
30
|
//# sourceMappingURL=free-delivery-marketing.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"free-delivery-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/free-delivery-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,qDAA2D;AAC3D,wDAA+C;AAE/C,MAAa,qBAAsB,SAAQ,2BAAS;IAC5C,aAAa,GAAG,oBAAa,CAAC,aAAsB,CAAC;IAGrD,UAAU,CAAU;
|
|
1
|
+
{"version":3,"file":"free-delivery-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/free-delivery-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,qDAA2D;AAC3D,wDAA+C;AAE/C,MAAa,qBAAsB,SAAQ,2BAAS;IAC5C,aAAa,GAAG,oBAAa,CAAC,aAAsB,CAAC;IAGrD,UAAU,CAAU;IAGpB,mBAAmB,CAAW;CACrC;AARD,sDAQC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;yDACR;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;kEACH","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { MarketingType } from '../../../../utilities/enum';\nimport { Marketing } from '../marketing.model';\n\nexport class FreeDeliveryMarketing extends Marketing {\n\tpublic marketingType = MarketingType.FREE_DELIVERY as const;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSpendLimitEnabled?: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticket.model.js","sourceRoot":"/","sources":["libraries/mongo/models/ticket.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AAGrE,+CAAsC;AACtC,+CAAsC;AACtC,kDAA4E;AAC5E,uDAA6C;AAC7C,+DAAqD;AACrD,iEAAuD;AAahD,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,2BAAU;IAE9B,QAAQ,CAAU;IAGlB,IAAI,CAAc;IAGlB,MAAM,CAAgB;IAGtB,KAAK,CAAU;IAGf,aAAa,CAAsB;IAGnC,MAAM,CAAoB;IAG1B,UAAU,CAAW;IAGrB,KAAK,CAAc;IAGnB,aA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AC;IACtC,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAC1C,IAAA,iBAAK,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC9C,IAAA,iBAAK,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IACxB,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;GACV,MAAM,CAyDlB","sourcesContent":["import { index, modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { User } from './user.model';\nimport { Shop } from './shop.model';\nimport { Order } from './order.model';\nimport { Admin } from './admin.model';\nimport { TicketStatus, TicketType, UserRef } from '../../../utilities/enum';\nimport { Chatroom } from './chat-room.model';\nimport { TicketAction } from './ticket-action.model';\nimport { SupportReason } from './support-reason.model';\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'tickets',\n\t\ttimestamps: true,\n\t},\n})\n@index({ assignedAgent: 1, status: 1 })\n@index({ type: 1, status: 1, priority: 1 })\n@index({ client: 1, clientType: 1, status: 1 })\n@index({ createdAt: -1 })\n@index({ chatroom: 1 })\nexport class Ticket extends TimeStamps {\n\t@prop({ required: true, type: String, unique: true })\n\tpublic ticketId!: string;\n\n\t@prop({ required: true, type: String, enum: TicketType })\n\tpublic type!: TicketType;\n\n\t@prop({ required: true, type: String, enum: TicketStatus, default: TicketStatus.PENDING })\n\tpublic status!: TicketStatus;\n\n\t@prop({ type: String, required: true })\n\tpublic title!: string;\n\n\t@prop({ ref: () => SupportReason, required: false })\n\tpublic supportReason?: Ref<SupportReason>;\n\n\t@prop({ refPath: 'clientType', required: true })\n\tpublic client!: Ref<User | Shop>;\n\n\t@prop({ required: true, type: String, enum: UserRef })\n\tpublic clientType!: User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E,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;8CACR;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACI;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;sCACjB;iBAxDtB,MAAM;IAXlB,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE;YACd,UAAU,EAAE,SAAS;YACrB,UAAU,EAAE,IAAI;SAChB;KACD,CAAC;IACD,IAAA,iBAAK,EAAC,EAAE,aAAa,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACtC,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAC1C,IAAA,iBAAK,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC9C,IAAA,iBAAK,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IACxB,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;GACV,MAAM,CAyDlB","sourcesContent":["import { index, modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { User } from './user.model';\nimport { Shop } from './shop.model';\nimport { Order } from './order.model';\nimport { Admin } from './admin.model';\nimport { TicketStatus, TicketType, UserRef } from '../../../utilities/enum';\nimport { Chatroom } from './chat-room.model';\nimport { TicketAction } from './ticket-action.model';\nimport { SupportReason } from './support-reason.model';\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'tickets',\n\t\ttimestamps: true,\n\t},\n})\n@index({ assignedAgent: 1, status: 1 })\n@index({ type: 1, status: 1, priority: 1 })\n@index({ client: 1, clientType: 1, status: 1 })\n@index({ createdAt: -1 })\n@index({ chatroom: 1 })\nexport class Ticket extends TimeStamps {\n\t@prop({ required: true, type: String, unique: true })\n\tpublic ticketId!: string;\n\n\t@prop({ required: true, type: String, enum: TicketType })\n\tpublic type!: TicketType;\n\n\t@prop({ required: true, type: String, enum: TicketStatus, default: TicketStatus.PENDING })\n\tpublic status!: TicketStatus;\n\n\t@prop({ type: String, required: true })\n\tpublic title!: string;\n\n\t@prop({ ref: () => SupportReason, required: false })\n\tpublic supportReason?: Ref<SupportReason>;\n\n\t@prop({ refPath: 'clientType', required: true })\n\tpublic client!: Ref<User | Shop>;\n\n\t@prop({ required: true, type: String, enum: UserRef })\n\tpublic clientType!: UserRef;\n\n\t@prop({ ref: () => Order })\n\tpublic order?: Ref<Order>; // DEPRECATED\n\n\t@prop({ ref: () => Admin })\n\tpublic assignedAgent?: Ref<Admin>;\n\n\t@prop({ type: Date })\n\tpublic assignedAt?: Date;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic assignmentAttempts?: number;\n\n\t@prop({ ref: () => Chatroom, required: true })\n\tpublic chatroom!: Ref<Chatroom>;\n\n\t@prop({ type: Date })\n\tpublic resolvedAt?: Date;\n\n\t@prop({ type: String, enum: UserRef })\n\tpublic resolvedBy?: UserRef;\n\n\t@prop({ type: Date })\n\tpublic closedAt?: Date;\n\n\t@prop({ type: Number })\n\tpublic resolutionTimeMinutes?: number;\n\n\t@prop({ type: Number, min: 1, max: 5 })\n\tpublic customerRating?: number;\n\n\t@prop({ type: Number })\n\tpublic agentScore?: number;\n\n\t@prop({ ref: () => TicketAction, required: false })\n\tpublic action?: Ref<TicketAction>;\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
package/dist/utilities/time.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare const LyxaTimezone = "Asia/Dhaka";
|
|
2
2
|
export declare const convertTimeToUTC: (timeStr: string, zone?: string) => string;
|
|
3
3
|
export declare const convertTimeFromUTC: (utcTimeStr: string, zone?: string) => string;
|
|
4
|
+
export declare function normalizeWorkingHourTimeFormat(data: any): any;
|
|
5
|
+
export declare function deNormalizeWorkingHourTimeFormat(data: any): any;
|
|
6
|
+
export declare function parseTime(time: string): number;
|
|
7
|
+
export declare function formatTimeString(time: string): string;
|
package/dist/utilities/time.js
CHANGED
|
@@ -4,9 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.convertTimeFromUTC = exports.convertTimeToUTC = exports.LyxaTimezone = void 0;
|
|
7
|
+
exports.normalizeWorkingHourTimeFormat = normalizeWorkingHourTimeFormat;
|
|
8
|
+
exports.deNormalizeWorkingHourTimeFormat = deNormalizeWorkingHourTimeFormat;
|
|
9
|
+
exports.parseTime = parseTime;
|
|
10
|
+
exports.formatTimeString = formatTimeString;
|
|
7
11
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
12
|
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
9
13
|
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
14
|
+
const error_common_1 = require("./error-common");
|
|
10
15
|
dayjs_1.default.extend(utc_1.default);
|
|
11
16
|
dayjs_1.default.extend(timezone_1.default);
|
|
12
17
|
exports.LyxaTimezone = 'Asia/Dhaka';
|
|
@@ -36,4 +41,75 @@ const convertTimeFromUTC = (utcTimeStr, zone = 'Asia/Beirut') => {
|
|
|
36
41
|
.format('HHmm');
|
|
37
42
|
};
|
|
38
43
|
exports.convertTimeFromUTC = convertTimeFromUTC;
|
|
44
|
+
function normalizeWorkingHourTimeFormat(data) {
|
|
45
|
+
const timeRegex = /^(\d{1,2}):(\d{1,2})$/;
|
|
46
|
+
const convert = (timeStr) => {
|
|
47
|
+
const match = timeStr.match(timeRegex);
|
|
48
|
+
if (!match)
|
|
49
|
+
return timeStr;
|
|
50
|
+
const hours = match[1].padStart(2, '0');
|
|
51
|
+
const minutes = match[2].padStart(2, '0');
|
|
52
|
+
return `${hours}${minutes}`;
|
|
53
|
+
};
|
|
54
|
+
const transform = (obj) => {
|
|
55
|
+
if (Array.isArray(obj)) {
|
|
56
|
+
return obj.map(transform);
|
|
57
|
+
}
|
|
58
|
+
else if (typeof obj === 'object' && obj !== null) {
|
|
59
|
+
for (const key in obj) {
|
|
60
|
+
if (typeof obj[key] === 'string' && timeRegex.test(obj[key])) {
|
|
61
|
+
obj[key] = convert(obj[key]);
|
|
62
|
+
}
|
|
63
|
+
else if (typeof obj[key] === 'object') {
|
|
64
|
+
obj[key] = transform(obj[key]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return obj;
|
|
69
|
+
};
|
|
70
|
+
return transform(JSON.parse(JSON.stringify(data)));
|
|
71
|
+
}
|
|
72
|
+
function deNormalizeWorkingHourTimeFormat(data) {
|
|
73
|
+
const timeRegex = /^(\d{2})(\d{2})$/;
|
|
74
|
+
const convert = (timeStr) => {
|
|
75
|
+
const match = timeStr.match(timeRegex);
|
|
76
|
+
if (!match)
|
|
77
|
+
return timeStr;
|
|
78
|
+
const hours = String(Number(match[1]));
|
|
79
|
+
const minutes = String(Number(match[2])).padStart(2, '0');
|
|
80
|
+
return `${hours}:${minutes}`;
|
|
81
|
+
};
|
|
82
|
+
const transform = (obj) => {
|
|
83
|
+
if (Array.isArray(obj)) {
|
|
84
|
+
return obj.map(transform);
|
|
85
|
+
}
|
|
86
|
+
else if (typeof obj === 'object' && obj !== null) {
|
|
87
|
+
for (const key in obj) {
|
|
88
|
+
if (typeof obj[key] === 'string' && timeRegex.test(obj[key])) {
|
|
89
|
+
obj[key] = convert(obj[key]);
|
|
90
|
+
}
|
|
91
|
+
else if (typeof obj[key] === 'object') {
|
|
92
|
+
obj[key] = transform(obj[key]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return obj;
|
|
97
|
+
};
|
|
98
|
+
return transform(JSON.parse(JSON.stringify(data)));
|
|
99
|
+
}
|
|
100
|
+
function parseTime(time) {
|
|
101
|
+
const [hh, mm] = formatTimeString(time).split(":").map(Number);
|
|
102
|
+
if (isNaN(hh) || isNaN(mm) ||
|
|
103
|
+
hh < 0 || hh > 23 ||
|
|
104
|
+
mm < 0 || mm > 59) {
|
|
105
|
+
(0, error_common_1.badRequestError)(`Invalid time format: ${formatTimeString(time)}`);
|
|
106
|
+
}
|
|
107
|
+
return hh * 60 + mm;
|
|
108
|
+
}
|
|
109
|
+
function formatTimeString(time) {
|
|
110
|
+
if (!/^\d{4}$/.test(time)) {
|
|
111
|
+
(0, error_common_1.badRequestError)(`Invalid time format: ${time}`);
|
|
112
|
+
}
|
|
113
|
+
return time.slice(0, 2) + ":" + time.slice(2);
|
|
114
|
+
}
|
|
39
115
|
//# sourceMappingURL=time.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"/","sources":["utilities/time.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"/","sources":["utilities/time.ts"],"names":[],"mappings":";;;;;;AAyCA,wEA4BC;AAED,4EA2BC;AAED,8BAWC;AAGD,4CAKC;AAvHD,kDAA0B;AAC1B,2DAAmC;AACnC,qEAA6C;AAC7C,iDAAiD;AAEjD,eAAK,CAAC,MAAM,CAAC,aAAG,CAAC,CAAC;AAClB,eAAK,CAAC,MAAM,CAAC,kBAAQ,CAAC,CAAC;AAEV,QAAA,YAAY,GAAG,YAAY,CAAC;AAIlC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,IAAI,GAAG,aAAa,EAAE,EAAE;IACtE,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,O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,IAAI,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,SAAgB,SAAS,CAAC,IAAY;IACpC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/D,IACE,KAAK,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACtB,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE;QACjB,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,EACjB,CAAC;QACD,IAAA,8BAAe,EAAC,wBAAwB,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACtB,CAAC;AAGD,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,IAAA,8BAAe,EAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport timezone from 'dayjs/plugin/timezone';\nimport { badRequestError } from './error-common';\n\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\nexport const LyxaTimezone = 'Asia/Dhaka';\n\n// input: timeStr: 1500\n// output: 1200\nexport const convertTimeToUTC = (timeStr: string, zone = 'Asia/Beirut') => {\n const hour = Number(timeStr.slice(0, 2));\n const minute = Number(timeStr.slice(2));\n return dayjs()\n .tz(zone)\n .set('hour', hour)\n .set('minute', minute)\n .set('second', 0)\n .set('millisecond', 0)\n .utc()\n .format('HHmm');\n};\n\n// input: timeStr: 1200\n// output: 1500\nexport const convertTimeFromUTC = (utcTimeStr: string, zone = 'Asia/Beirut') => {\n const hour = Number(utcTimeStr.slice(0, 2));\n const minute = Number(utcTimeStr.slice(2));\n return dayjs()\n .utc()\n .set('hour', hour)\n .set('minute', minute)\n .set('second', 0)\n .set('millisecond', 0)\n .tz(zone)\n .format('HHmm');\n};\n\n\nexport function normalizeWorkingHourTimeFormat(data: any) {\n\tconst timeRegex = /^(\\d{1,2}):(\\d{1,2})$/;\n\n\tconst convert = (timeStr: string) => {\n\t\tconst match = timeStr.match(timeRegex);\n\t\tif (!match) return timeStr;\n\t\tconst hours = match[1].padStart(2, '0');\n\t\tconst minutes = match[2].padStart(2, '0');\n\t\treturn `${hours}${minutes}`;\n\t};\n\n\tconst transform: any = (obj: any) => {\n\t\t\n\t\tif (Array.isArray(obj)) {\n\t\t\treturn obj.map(transform);\n\t\t} else if (typeof obj === 'object' && obj !== null) {\n\t\t\tfor (const key in obj) {\n\t\t\t\tif (typeof obj[key] === 'string' && timeRegex.test(obj[key])) {\n\t\t\t\t\tobj[key] = convert(obj[key]);\n\t\t\t\t} else if (typeof obj[key] === 'object') {\n\t\t\t\t\tobj[key] = transform(obj[key]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn obj;\n\t};\n\n\treturn transform(JSON.parse(JSON.stringify(data))); // deep copy to avoid mutation\n}\n\nexport function deNormalizeWorkingHourTimeFormat(data: any) {\n\tconst timeRegex = /^(\\d{2})(\\d{2})$/;\n\n\tconst convert = (timeStr: string) => {\n\t\tconst match = timeStr.match(timeRegex);\n\t\tif (!match) return timeStr;\n\t\tconst hours = String(Number(match[1])); // remove leading zero\n\t\tconst minutes = String(Number(match[2])).padStart(2, '0');\n\t\treturn `${hours}:${minutes}`;\n\t};\n\n\tconst transform: any = (obj: any) => {\n\t\tif (Array.isArray(obj)) {\n\t\t\treturn obj.map(transform);\n\t\t} else if (typeof obj === 'object' && obj !== null) {\n\t\t\tfor (const key in obj) {\n\t\t\t\tif (typeof obj[key] === 'string' && timeRegex.test(obj[key])) {\n\t\t\t\t\tobj[key] = convert(obj[key]);\n\t\t\t\t} else if (typeof obj[key] === 'object') {\n\t\t\t\t\tobj[key] = transform(obj[key]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn obj;\n\t};\n\t// return transform(JSON.parse((data)));\n\treturn transform(JSON.parse(JSON.stringify(data)));\n}\n\nexport function parseTime(time: string): number {\n const [hh, mm] = formatTimeString(time).split(\":\").map(Number);\n if (\n isNaN(hh) || isNaN(mm) ||\n hh < 0 || hh > 23 ||\n mm < 0 || mm > 59\n ) {\n badRequestError(`Invalid time format: ${formatTimeString(time)}`);\n }\n\n return hh * 60 + mm;\n}\n\n// i/p: 0600, o/p: 06:00 \nexport function formatTimeString(time: string): string {\n if (!/^\\d{4}$/.test(time)) {\n badRequestError(`Invalid time format: ${time}`);\n }\n return time.slice(0, 2) + \":\" + time.slice(2);\n}\n\n"]}
|