@lyxa.ai/core 1.0.47 → 1.0.49

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 (31) hide show
  1. package/dist/libraries/mongo/models/embedded/customer-support-batches.model.d.ts +4 -0
  2. package/dist/libraries/mongo/models/embedded/customer-support-batches.model.js +27 -0
  3. package/dist/libraries/mongo/models/embedded/customer-support-batches.model.js.map +1 -0
  4. package/dist/libraries/mongo/models/embedded/customer-support-numbers.model.d.ts +4 -0
  5. package/dist/libraries/mongo/models/embedded/customer-support-numbers.model.js +27 -0
  6. package/dist/libraries/mongo/models/embedded/customer-support-numbers.model.js.map +1 -0
  7. package/dist/libraries/mongo/models/embedded/order-pricing.model.d.ts +4 -0
  8. package/dist/libraries/mongo/models/embedded/order-pricing.model.js +20 -0
  9. package/dist/libraries/mongo/models/embedded/order-pricing.model.js.map +1 -1
  10. package/dist/libraries/mongo/models/embedded/payout-setting.model.js.map +1 -1
  11. package/dist/libraries/mongo/models/embedded/rider-batches.model.d.ts +4 -0
  12. package/dist/libraries/mongo/models/embedded/rider-batches.model.js +27 -0
  13. package/dist/libraries/mongo/models/embedded/rider-batches.model.js.map +1 -0
  14. package/dist/libraries/mongo/models/favourite.model.d.ts +2 -2
  15. package/dist/libraries/mongo/models/favourite.model.js +2 -2
  16. package/dist/libraries/mongo/models/favourite.model.js.map +1 -1
  17. package/dist/libraries/mongo/models/order.model.d.ts +1 -3
  18. package/dist/libraries/mongo/models/order.model.js +0 -6
  19. package/dist/libraries/mongo/models/order.model.js.map +1 -1
  20. package/dist/libraries/mongo/models/product-marketing.model.js.map +1 -1
  21. package/dist/libraries/mongo/models/setting.model.d.ts +6 -1
  22. package/dist/libraries/mongo/models/setting.model.js +17 -4
  23. package/dist/libraries/mongo/models/setting.model.js.map +1 -1
  24. package/dist/libraries/mongo/models/tag.model.js +53 -0
  25. package/dist/libraries/mongo/models/tag.model.js.map +1 -1
  26. package/dist/libraries/secrets/index.js +4 -2
  27. package/dist/libraries/secrets/index.js.map +1 -1
  28. package/dist/libraries/trpc/middlewares/publicUserDecoder.d.ts +39 -0
  29. package/dist/libraries/trpc/middlewares/publicUserDecoder.js +74 -0
  30. package/dist/libraries/trpc/middlewares/publicUserDecoder.js.map +1 -0
  31. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ export declare class CustomerSupportBatchesSettings {
2
+ phoneNumber?: string;
3
+ whatsappNumber?: string;
4
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CustomerSupportBatchesSettings = void 0;
13
+ const typegoose_1 = require("@typegoose/typegoose");
14
+ class CustomerSupportBatchesSettings {
15
+ phoneNumber;
16
+ whatsappNumber;
17
+ }
18
+ exports.CustomerSupportBatchesSettings = CustomerSupportBatchesSettings;
19
+ __decorate([
20
+ (0, typegoose_1.prop)({ type: String, default: 0, min: 0 }),
21
+ __metadata("design:type", String)
22
+ ], CustomerSupportBatchesSettings.prototype, "phoneNumber", void 0);
23
+ __decorate([
24
+ (0, typegoose_1.prop)({ type: String, default: 0, min: 0 }),
25
+ __metadata("design:type", String)
26
+ ], CustomerSupportBatchesSettings.prototype, "whatsappNumber", void 0);
27
+ //# sourceMappingURL=customer-support-batches.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-support-batches.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/customer-support-batches.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,8BAA8B;IAE1C,WAAW,CAAU;IAGrB,cAAc,CAAU;CACxB;AAND,wEAMC;AAJA;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;mEACtB;AAGrB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;sEACnB","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class CustomerSupportBatchesSettings {\n\t@prop({ type: String, default: 0, min: 0 })\n\tphoneNumber?: string;\n\n\t@prop({ type: String, default: 0, min: 0 })\n\twhatsappNumber?: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare class CustomerSupport {
2
+ phoneNumber?: string;
3
+ whatsAppNumber?: number;
4
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CustomerSupport = void 0;
13
+ const typegoose_1 = require("@typegoose/typegoose");
14
+ class CustomerSupport {
15
+ phoneNumber;
16
+ whatsAppNumber;
17
+ }
18
+ exports.CustomerSupport = CustomerSupport;
19
+ __decorate([
20
+ (0, typegoose_1.prop)({ type: String }),
21
+ __metadata("design:type", String)
22
+ ], CustomerSupport.prototype, "phoneNumber", void 0);
23
+ __decorate([
24
+ (0, typegoose_1.prop)({ type: Number, default: 0, min: 0 }),
25
+ __metadata("design:type", Number)
26
+ ], CustomerSupport.prototype, "whatsAppNumber", void 0);
27
+ //# sourceMappingURL=customer-support-numbers.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-support-numbers.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/customer-support-numbers.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,eAAe;IAE3B,WAAW,CAAU;IAGrB,cAAc,CAAU;CACxB;AAND,0CAMC;AAJA;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACF;AAGrB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;uDACnB","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class CustomerSupport {\n\t@prop({ type: String })\n\tphoneNumber?: string;\n\n\t@prop({ type: Number, default: 0, min: 0 })\n\twhatsAppNumber?: number; // in mins\n}\n"]}
@@ -1,6 +1,10 @@
1
1
  export declare class OrderPricing {
2
2
  subtotal?: number;
3
3
  secondarySubtotal?: number;
4
+ discount?: number;
5
+ secondaryDiscount?: number;
6
+ couponDiscount?: number;
7
+ secondaryCouponDiscount?: number;
4
8
  deliveryFee?: number;
5
9
  secondaryDeliveryFee?: number;
6
10
  riderTips?: number;
@@ -14,6 +14,10 @@ const typegoose_1 = require("@typegoose/typegoose");
14
14
  class OrderPricing {
15
15
  subtotal;
16
16
  secondarySubtotal;
17
+ discount;
18
+ secondaryDiscount;
19
+ couponDiscount;
20
+ secondaryCouponDiscount;
17
21
  deliveryFee;
18
22
  secondaryDeliveryFee;
19
23
  riderTips;
@@ -34,6 +38,22 @@ __decorate([
34
38
  (0, typegoose_1.prop)({ type: Number, default: 0 }),
35
39
  __metadata("design:type", Number)
36
40
  ], OrderPricing.prototype, "secondarySubtotal", void 0);
41
+ __decorate([
42
+ (0, typegoose_1.prop)({ type: Number, default: 0 }),
43
+ __metadata("design:type", Number)
44
+ ], OrderPricing.prototype, "discount", void 0);
45
+ __decorate([
46
+ (0, typegoose_1.prop)({ type: Number, default: 0 }),
47
+ __metadata("design:type", Number)
48
+ ], OrderPricing.prototype, "secondaryDiscount", void 0);
49
+ __decorate([
50
+ (0, typegoose_1.prop)({ type: Number, default: 0 }),
51
+ __metadata("design:type", Number)
52
+ ], OrderPricing.prototype, "couponDiscount", void 0);
53
+ __decorate([
54
+ (0, typegoose_1.prop)({ type: Number, default: 0 }),
55
+ __metadata("design:type", Number)
56
+ ], OrderPricing.prototype, "secondaryCouponDiscount", void 0);
37
57
  __decorate([
38
58
  (0, typegoose_1.prop)({ type: Number, default: 0 }),
39
59
  __metadata("design:type", Number)
@@ -1 +1 @@
1
- {"version":3,"file":"order-pricing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/order-pricing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,YAAY;IAExB,QAAQ,CAAU;IAGlB,iBAAiB,CAAU;IAG3B,WAAW,CAAU;IAGrB,oBAAoB,CAAU;IAG9B,SAAS,CAAU;IAGnB,kBAAkB,CAAU;IAG5B,KAAK,CAAU;IAGf,cAAc,CAAU;IAGxB,MAAM,CAAU;IAGhB,eAAe,CAAU;IAGzB,UAAU,CAAU;IAGpB,mBAAmB,CAAU;CAC7B;AApCD,oCAoCC;AAlCA;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8CACjB;AAGlB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACR;AAG3B;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;iDACd;AAGrB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;0DACL;AAG9B;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+CAChB;AAGnB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;wDACP;AAG5B;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;2CACpB;AAGf;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;oDACX;AAGxB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;4CACnB;AAGhB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;qDACV;AAGzB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gDACf;AAGpB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;yDACN","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tsubtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondarySubtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tdeliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryDeliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\triderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryRiderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\ttotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryTotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\twallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpaidAmount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryPaidAmount?: number;\n}\n"]}
1
+ {"version":3,"file":"order-pricing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/order-pricing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,YAAY;IAExB,QAAQ,CAAU;IAGlB,iBAAiB,CAAU;IAG3B,QAAQ,CAAU;IAGlB,iBAAiB,CAAU;IAG3B,cAAc,CAAU;IAGxB,uBAAuB,CAAU;IAGjC,WAAW,CAAU;IAGrB,oBAAoB,CAAU;IAG9B,SAAS,CAAU;IAGnB,kBAAkB,CAAU;IAG5B,KAAK,CAAU;IAGf,cAAc,CAAU;IAGxB,MAAM,CAAU;IAGhB,eAAe,CAAU;IAGzB,UAAU,CAAU;IAGpB,mBAAmB,CAAU;CAC7B;AAhDD,oCAgDC;AA9CA;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8CACjB;AAGlB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACR;AAG3B;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,C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AAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;yDACN","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tsubtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondarySubtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tdiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tcouponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryCouponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tdeliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryDeliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\triderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryRiderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\ttotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryTotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\twallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpaidAmount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tsecondaryPaidAmount?: number;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"payout-setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/payout-setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,qDAAqD;AAErD,MAAa,aAAa;IAEzB,WAAW,CAAW;IAGtB,cAAc,CAAU;CACxB;AAND,sCAMC;AAJA;IADC,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAO,EAAE,CAAC;;kDAChC;AAGtB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;qDACnB","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { WeekDay } from '../../../../utilities/enum';\n\nexport class PayoutSetting {\n\t@prop({ required: true, type: Number, enum: WeekDay })\n\tissuanceDay!: WeekDay;\n\n\t@prop({ type: Number, min: 1, default: 1 })\n\toverDuePeriods?: number;\n}\n"]}
1
+ {"version":3,"file":"payout-setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/payout-setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,qDAAqD;AAErD,MAAc,aAAa;IAE1B,WAAW,CAAW;IAGtB,cAAc,CAAU;CACxB;AAND,sCAMC;AAJA;IADC,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAO,EAAE,CAAC;;kDAChC;AAGtB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;qDACnB","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { WeekDay } from '../../../../utilities/enum';\n\nexport class PayoutSetting {\n\t@prop({ required: true, type: Number, enum: WeekDay })\n\tissuanceDay!: WeekDay;\n\n\t@prop({ type: Number, min: 1, default: 1 })\n\toverDuePeriods?: number;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare class RiderBatchesSettings {
2
+ riderBatch?: number;
3
+ delayTime?: number;
4
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RiderBatchesSettings = void 0;
13
+ const typegoose_1 = require("@typegoose/typegoose");
14
+ class RiderBatchesSettings {
15
+ riderBatch;
16
+ delayTime;
17
+ }
18
+ exports.RiderBatchesSettings = RiderBatchesSettings;
19
+ __decorate([
20
+ (0, typegoose_1.prop)({ type: Number, default: 0, min: 0 }),
21
+ __metadata("design:type", Number)
22
+ ], RiderBatchesSettings.prototype, "riderBatch", void 0);
23
+ __decorate([
24
+ (0, typegoose_1.prop)({ type: Number, default: 0, min: 0 }),
25
+ __metadata("design:type", Number)
26
+ ], RiderBatchesSettings.prototype, "delayTime", void 0);
27
+ //# sourceMappingURL=rider-batches.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rider-batches.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/rider-batches.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,oBAAoB;IAEhC,UAAU,CAAU;IAGpB,SAAS,CAAU;CACnB;AAND,oDAMC;AAJA;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;wDACvB;AAGpB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;uDACxB","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class RiderBatchesSettings {\n\t@prop({ type: Number, default: 0, min: 0 })\n\triderBatch?: number;\n\n\t@prop({ type: Number, default: 0, min: 0 })\n\tdelayTime?: number; // in mins\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { Ref } from '@typegoose/typegoose';
2
2
  import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
3
3
  import { FavouriteType } from '../../../utilities/enum';
4
- import { CoreUser } from './core-user.model';
4
+ import { User } from './user.model';
5
5
  import { Product } from './product.model';
6
6
  import { Shop } from './shop.model';
7
7
  export declare class Favourite extends TimeStamps {
8
- user: Ref<CoreUser>;
8
+ user: Ref<User>;
9
9
  favouriteType: FavouriteType;
10
10
  shop?: Ref<Shop>;
11
11
  product?: Ref<Product>;
@@ -13,7 +13,7 @@ exports.Favourite = void 0;
13
13
  const typegoose_1 = require("@typegoose/typegoose");
14
14
  const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
15
15
  const enum_1 = require("../../../utilities/enum");
16
- const core_user_model_1 = require("./core-user.model");
16
+ const user_model_1 = require("./user.model");
17
17
  const product_model_1 = require("./product.model");
18
18
  const shop_model_1 = require("./shop.model");
19
19
  let Favourite = class Favourite extends defaultClasses_1.TimeStamps {
@@ -24,7 +24,7 @@ let Favourite = class Favourite extends defaultClasses_1.TimeStamps {
24
24
  };
25
25
  exports.Favourite = Favourite;
26
26
  __decorate([
27
- (0, typegoose_1.prop)({ required: true, ref: () => core_user_model_1.CoreUser }),
27
+ (0, typegoose_1.prop)({ required: true, ref: () => user_model_1.User }),
28
28
  __metadata("design:type", Object)
29
29
  ], Favourite.prototype, "user", void 0);
30
30
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"favourite.model.js","sourceRoot":"/","sources":["libraries/mongo/models/favourite.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAwD;AACxD,uDAA6C;AAC7C,mDAA0C;AAC1C,6CAAoC;AAG7B,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,2BAAU;IAEjC,IAAI,CAAiB;IAGrB,aAAa,CAAiB;IAG9B,IAAI,CAAa;IAGjB,OAAO,CAAgB;CAC9B,CAAA;AAZY,8BAAS;AAEd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,0BAAQ,EAAE,CAAC;;uCAClB;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,oBAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACT;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;uCACF;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,uBAAO,EAAE,CAAC;;0CACC;oBAXlB,SAAS;IADrB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,CAAC;GACjD,SAAS,CAYrB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { FavouriteType } from '../../../utilities/enum';\nimport { CoreUser } from './core-user.model';\nimport { Product } from './product.model';\nimport { Shop } from './shop.model';\n\n@modelOptions({ schemaOptions: { collection: 'favourites' } })\nexport class Favourite extends TimeStamps {\n\t@prop({ required: true, ref: () => CoreUser })\n\tpublic user!: Ref<CoreUser>;\n\n\t@prop({ enum: FavouriteType, required: true })\n\tpublic favouriteType!: FavouriteType;\n\n\t@prop({ ref: () => Shop })\n\tpublic shop?: Ref<Shop>;\n\n\t@prop({ ref: () => Product })\n\tpublic product?: Ref<Product>;\n}\n"]}
1
+ {"version":3,"file":"favourite.model.js","sourceRoot":"/","sources":["libraries/mongo/models/favourite.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAwD;AACxD,6CAAoC;AACpC,mDAA0C;AAC1C,6CAAoC;AAG7B,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,2BAAU;IAEjC,IAAI,CAAa;IAGjB,aAAa,CAAiB;IAG9B,IAAI,CAAa;IAGjB,OAAO,CAAgB;CAC9B,CAAA;AAZY,8BAAS;AAEd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;uCAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,oBAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACT;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;uCACF;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,uBAAO,EAAE,CAAC;;0CACC;oBAXlB,SAAS;IADrB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,CAAC;GACjD,SAAS,CAYrB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { FavouriteType } from '../../../utilities/enum';\nimport { User } from './user.model';\nimport { Product } from './product.model';\nimport { Shop } from './shop.model';\n\n@modelOptions({ schemaOptions: { collection: 'favourites' } })\nexport class Favourite extends TimeStamps {\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ enum: FavouriteType, required: true })\n\tpublic favouriteType!: FavouriteType;\n\n\t@prop({ ref: () => Shop })\n\tpublic shop?: Ref<Shop>;\n\n\t@prop({ ref: () => Product })\n\tpublic product?: Ref<Product>;\n}\n"]}
@@ -2,7 +2,6 @@ import { Ref } from '@typegoose/typegoose';
2
2
  import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
3
3
  import { OrderType } from '../../../utilities/enum';
4
4
  import { OrderCancel } from './embedded/order-cancel.model';
5
- import { OrderPricing } from './embedded/order-pricing.model';
6
5
  import { User } from './user.model';
7
6
  export declare class Order extends TimeStamps {
8
7
  orderId: string;
@@ -11,8 +10,7 @@ export declare class Order extends TimeStamps {
11
10
  instruction?: string;
12
11
  note?: string;
13
12
  scheduledFor?: Date;
14
- pricing: OrderPricing;
15
- orderCancel: OrderCancel;
13
+ orderCancel?: OrderCancel;
16
14
  isLateOrder?: boolean;
17
15
  isUrgentOrder?: boolean;
18
16
  }
@@ -14,7 +14,6 @@ const typegoose_1 = require("@typegoose/typegoose");
14
14
  const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
15
15
  const enum_1 = require("../../../utilities/enum");
16
16
  const order_cancel_model_1 = require("./embedded/order-cancel.model");
17
- const order_pricing_model_1 = require("./embedded/order-pricing.model");
18
17
  const user_model_1 = require("./user.model");
19
18
  let Order = class Order extends defaultClasses_1.TimeStamps {
20
19
  orderId;
@@ -23,7 +22,6 @@ let Order = class Order extends defaultClasses_1.TimeStamps {
23
22
  instruction;
24
23
  note;
25
24
  scheduledFor;
26
- pricing;
27
25
  orderCancel;
28
26
  isLateOrder;
29
27
  isUrgentOrder;
@@ -53,10 +51,6 @@ __decorate([
53
51
  (0, typegoose_1.prop)({ type: Date }),
54
52
  __metadata("design:type", Date)
55
53
  ], Order.prototype, "scheduledFor", void 0);
56
- __decorate([
57
- (0, typegoose_1.prop)({ type: () => order_pricing_model_1.OrderPricing }),
58
- __metadata("design:type", order_pricing_model_1.OrderPricing)
59
- ], Order.prototype, "pricing", void 0);
60
54
  __decorate([
61
55
  (0, typegoose_1.prop)({ type: () => order_cancel_model_1.OrderCancel }),
62
56
  __metadata("design:type", order_cancel_model_1.OrderCancel)
@@ -1 +1 @@
1
- {"version":3,"file":"order.model.js","sourceRoot":"/","sources":["libraries/mongo/models/order.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAgF;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AAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;0CACX;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;4CACT;gBA/BnB,KAAK;IAdjB,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE;YACd,UAAU,EAAE,QAAQ;YACpB,gBAAgB,EAAE,WAAW;YAC7B,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC1B,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5B;QACD,OAAO,EAAE,EAAE,UAAU,EAAE,oBAAQ,CAAC,KAAK,EAAE;KACvC,CAAC;IACD,IAAA,iBAAK,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IACxB,IAAA,iBAAK,EAAC,EAAE,WAAW,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IACxC,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IACjC,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAClC,IAAA,iBAAK,EAAC,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;GACvB,KAAK,CAgCjB","sourcesContent":["import { prop, Ref, modelOptions, index, Severity } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { OrderType } from '../../../utilities/enum';\nimport { OrderCancel } from './embedded/order-cancel.model';\nimport { OrderPricing } from './embedded/order-pricing.model';\nimport { User } from './user.model';\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'orders',\n\t\tdiscriminatorKey: 'orderType',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: { allowMixed: Severity.ALLOW },\n})\n@index({ createdAt: -1 })\n@index({ orderStatus: 1, createdAt: -1 })\n@index({ user: 1, createdAt: -1 })\n@index({ shop: 1, orderStatus: 1 })\n@index({ rider: 1, orderStatus: 1 })\nexport class Order extends TimeStamps {\n\t@prop({ required: true, type: String, unique: true })\n\tpublic orderId: string;\n\n\t@prop({ type: String, enum: OrderType, default: OrderType.REGULAR })\n\tpublic orderType?: OrderType;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user: Ref<User>;\n\n\t@prop({ type: String })\n\tpublic instruction?: string;\n\n\t@prop({ type: String })\n\tpublic note?: string;\n\n\t@prop({ type: Date })\n\tpublic scheduledFor?: Date;\n\n\t@prop({ type: () => OrderPricing })\n\tpublic pricing: OrderPricing;\n\n\t// payment: OrderPayment; This should be a virtual field to understand if the payment is done or not\n\n\t@prop({ type: () => OrderCancel })\n\tpublic orderCancel: OrderCancel;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLateOrder?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isUrgentOrder?: boolean;\n}\n"]}
1
+ {"version":3,"file":"order.model.js","sourceRoot":"/","sources":["libraries/mongo/models/order.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAgF;AAChF,4EAAqE;AACrE,kDAAoD;AACpD,sEAA4D;AAC5D,6CAAoC;AAgB7B,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQ,2BAAU;IAE7B,OAAO,CAAS;IAGhB,SAAS,CAAa;IAGtB,IAAI,CAAY;IAGhB,WAAW,CAAU;IAGrB,IAAI,CAAU;IAGd,YAAY,CAAQ;IAGpB,WAAW,CAAe;IAG1B,WAAW,CAAW;IAGtB,aAAa,CAAW;CAC/B,CAAA;AA3BY,sBAAK;AAEV;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;sCAC9B;AAGhB;IADN,IAAA,gBAAI,EAAC,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AK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IACjC,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAClC,IAAA,iBAAK,EAAC,EAAE,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;GACvB,KAAK,CA2BjB","sourcesContent":["import { prop, Ref, modelOptions, index, Severity } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { OrderType } from '../../../utilities/enum';\nimport { OrderCancel } from './embedded/order-cancel.model';\nimport { User } from './user.model';\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'orders',\n\t\tdiscriminatorKey: 'orderType',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: { allowMixed: Severity.ALLOW },\n})\n@index({ createdAt: -1 })\n@index({ orderStatus: 1, createdAt: -1 })\n@index({ user: 1, createdAt: -1 })\n@index({ shop: 1, orderStatus: 1 })\n@index({ rider: 1, orderStatus: 1 })\nexport class Order extends TimeStamps {\n\t@prop({ required: true, type: String, unique: true })\n\tpublic orderId: string;\n\n\t@prop({ type: String, enum: OrderType, default: OrderType.REGULAR })\n\tpublic orderType?: OrderType;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user: Ref<User>;\n\n\t@prop({ type: String })\n\tpublic instruction?: string;\n\n\t@prop({ type: String })\n\tpublic note?: string;\n\n\t@prop({ type: Date })\n\tpublic scheduledFor?: Date;\n\n\t@prop({ type: () => OrderCancel })\n\tpublic orderCancel?: OrderCancel;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLateOrder?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isUrgentOrder?: boolean;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"product-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/product-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,kDAAoD;AACpD,iFAAsE;AACtE,uDAA8C;AAC9C,mDAA0C;AAGnC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAErB,OAAO,CAAgB;IAGvB,SAAS,CAAkB;IAG3B,oBAAoB,CAA6B;IAGjD,SAAS,CAAa;IAGtB,KAAK,CAAU;CACtB,CAAA;AAfY,4CAAgB;AAErB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,uBAAO,EAAE,CAAC;;iDACf;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,2BAAS,EAAE,CAAC;;mDACb;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,mDAAoB,EAAE,CAAC;;8DACc;AAGjD;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAS,EAAE,OAAO,EAAE,gBAAS,CAAC,UAAU,EAAE,CAAC;;mDAC1C;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CACjB;2BAdV,gBAAgB;IAD5B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,EAAE,CAAC;GACxD,gBAAgB,CAe5B","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { ValueType } from '../../../utilities/enum';\nimport { LoyaltyPointCategory } from './loyalty-point-category.model';\nimport { Marketing } from './marketing.model';\nimport { Product } from './product.model';\n\n@modelOptions({ schemaOptions: { collection: 'productMarketings' } })\nexport class ProductMarketing {\n\t@prop({ required: true, ref: () => Product })\n\tpublic product!: Ref<Product>;\n\n\t@prop({ required: true, ref: () => Marketing })\n\tpublic marketing!: Ref<Marketing>;\n\n\t@prop({ ref: () => LoyaltyPointCategory }) // this field only for loyalty marketing\n\tpublic loyaltyPointCategory?: Ref<LoyaltyPointCategory>;\n\n\t@prop({ type: String, enum: ValueType, default: ValueType.PERCENTAGE })\n\tpublic valueType?: ValueType;\n\n\t@prop({ required: true, type: Number })\n\tpublic value!: number;\n}\n"]}
1
+ {"version":3,"file":"product-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/product-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,kDAAoD;AACpD,iFAAsE;AACtE,uDAA8C;AAC9C,mDAA0C;AAInC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAErB,OAAO,CAAgB;IAGvB,SAAS,CAAkB;IAG3B,oBAAoB,CAA6B;IAGjD,SAAS,CAAa;IAGtB,KAAK,CAAU;CACtB,CAAA;AAfY,4CAAgB;AAErB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,uBAAO,EAAE,CAAC;;iDACf;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,2BAAS,EAAE,CAAC;;mDACb;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,mDAAoB,EAAE,CAAC;;8DACc;AAGjD;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAS,EAAE,OAAO,EAAE,gBAAS,CAAC,UAAU,EAAE,CAAC;;mDAC1C;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CACjB;2BAdV,gBAAgB;IAD5B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,EAAE,CAAC;GACxD,gBAAgB,CAe5B","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { ValueType } from '../../../utilities/enum';\nimport { LoyaltyPointCategory } from './loyalty-point-category.model';\nimport { Marketing } from './marketing.model';\nimport { Product } from './product.model';\nimport { MicroPercentRange } from 'firebase-admin/lib/remote-config/remote-config-api';\n\n@modelOptions({ schemaOptions: { collection: 'productMarketings' } })\nexport class ProductMarketing {\n\t@prop({ required: true, ref: () => Product })\n\tpublic product!: Ref<Product>;\n\n\t@prop({ required: true, ref: () => Marketing })\n\tpublic marketing!: Ref<Marketing>;\n\n\t@prop({ ref: () => LoyaltyPointCategory })\n\tpublic loyaltyPointCategory?: Ref<LoyaltyPointCategory>;\n\n\t@prop({ type: String, enum: ValueType, default: ValueType.PERCENTAGE })\n\tpublic valueType?: ValueType;\n\n\t@prop({ required: true, type: Number })\n\tpublic value!: number;\n}\n\n"]}
@@ -8,6 +8,9 @@ import { PayoutSetting } from './embedded/payout-setting.model';
8
8
  import { RiderSetting } from './embedded/rider-setting.model';
9
9
  import { ServiceFeeSetting } from './embedded/service-fee-setting.model';
10
10
  import { WorkHourSetting } from './shared/work-hour.model';
11
+ import { RiderBatchesSettings } from './embedded/rider-batches.model';
12
+ import { CustomerSupport } from './embedded/customer-support-numbers.model';
13
+ import { CustomerSupportBatchesSettings } from './embedded/customer-support-batches.model';
11
14
  export declare class Setting extends TimeStamps {
12
15
  deliveryCharges: DeliveryCharge[];
13
16
  serviceFeeSetting?: ServiceFeeSetting;
@@ -19,11 +22,13 @@ export declare class Setting extends TimeStamps {
19
22
  payLimitForUser?: number;
20
23
  vatPercentage?: number;
21
24
  riderSearchRanges?: number[];
25
+ riderBatches?: RiderBatchesSettings[];
22
26
  nearByShopDistance?: number;
23
27
  nearByShopDistanceInHomeScreen?: number;
24
28
  units?: string[];
25
29
  currencySetting?: CurrencySetting;
26
30
  paymentMethods?: PaymentMethod[];
27
31
  isGroupOrderEnabled?: boolean;
28
- customerSupportPhoneNumber?: string;
32
+ customerSupport?: CustomerSupport;
33
+ customerSupportBatches?: CustomerSupportBatchesSettings[];
29
34
  }
@@ -21,6 +21,9 @@ const payout_setting_model_1 = require("./embedded/payout-setting.model");
21
21
  const rider_setting_model_1 = require("./embedded/rider-setting.model");
22
22
  const service_fee_setting_model_1 = require("./embedded/service-fee-setting.model");
23
23
  const work_hour_model_1 = require("./shared/work-hour.model");
24
+ const rider_batches_model_1 = require("./embedded/rider-batches.model");
25
+ const customer_support_numbers_model_1 = require("./embedded/customer-support-numbers.model");
26
+ const customer_support_batches_model_1 = require("./embedded/customer-support-batches.model");
24
27
  let Setting = class Setting extends defaultClasses_1.TimeStamps {
25
28
  deliveryCharges;
26
29
  serviceFeeSetting;
@@ -32,13 +35,15 @@ let Setting = class Setting extends defaultClasses_1.TimeStamps {
32
35
  payLimitForUser;
33
36
  vatPercentage;
34
37
  riderSearchRanges;
38
+ riderBatches;
35
39
  nearByShopDistance;
36
40
  nearByShopDistanceInHomeScreen;
37
41
  units;
38
42
  currencySetting;
39
43
  paymentMethods;
40
44
  isGroupOrderEnabled;
41
- customerSupportPhoneNumber;
45
+ customerSupport;
46
+ customerSupportBatches;
42
47
  };
43
48
  exports.Setting = Setting;
44
49
  __decorate([
@@ -81,6 +86,10 @@ __decorate([
81
86
  (0, typegoose_1.prop)({ type: () => [Number], default: [] }),
82
87
  __metadata("design:type", Array)
83
88
  ], Setting.prototype, "riderSearchRanges", void 0);
89
+ __decorate([
90
+ (0, typegoose_1.prop)({ type: () => [rider_batches_model_1.RiderBatchesSettings], default: [] }),
91
+ __metadata("design:type", Array)
92
+ ], Setting.prototype, "riderBatches", void 0);
84
93
  __decorate([
85
94
  (0, typegoose_1.prop)({ type: Number, default: Infinity }),
86
95
  __metadata("design:type", Number)
@@ -106,9 +115,13 @@ __decorate([
106
115
  __metadata("design:type", Boolean)
107
116
  ], Setting.prototype, "isGroupOrderEnabled", void 0);
108
117
  __decorate([
109
- (0, typegoose_1.prop)({ type: String }),
110
- __metadata("design:type", String)
111
- ], Setting.prototype, "customerSupportPhoneNumber", void 0);
118
+ (0, typegoose_1.prop)({ type: customer_support_numbers_model_1.CustomerSupport }),
119
+ __metadata("design:type", customer_support_numbers_model_1.CustomerSupport)
120
+ ], Setting.prototype, "customerSupport", void 0);
121
+ __decorate([
122
+ (0, typegoose_1.prop)({ type: () => [customer_support_batches_model_1.CustomerSupportBatchesSettings], default: [] }),
123
+ __metadata("design:type", Array)
124
+ ], Setting.prototype, "customerSupportBatches", void 0);
112
125
  exports.Setting = Setting = __decorate([
113
126
  (0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'settings' } })
114
127
  ], Setting);
@@ -1 +1 @@
1
- {"version":3,"file":"setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,4EAAqE;AACrE,kDAAwD;AACxD,sGAA2F;AAC3F,4FAA0E;AAC1E,4EAAkE;AAClE,8EAAoE;AACpE,0EAAgE;AAChE,wEAA8D;AAC9D,oFAAyE;AACzE,8DAA2D;AAGpD,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,2BAAU;IAE/B,eAAe,CAAmB;IAGlC,iBAAiB,CAAqB;IAGtC,aAAa,CAAiB;IAG9B,eAAe,CAAmB;IAGlC,cAAc,CAAkB;IAGhC,YAAY,CAAgB;IAG5B,0BAA0B,CAA8B;IAGxD,eAAe,CAAU;IAGzB,aAAa,CAAU;IAGvB,iBAAiB,CAAY;IAG7B,kBAAkB,CAAU;IAG5B,8BAA8B,CAAU;IAGxC,KAAK,CAAY;IAGjB,eAAe,CAAmB;IAGlC,cAAc,CAAmB;IAGjC,mBAAmB,CAAW;IAG9B,0BAA0B,CAAU;CAC3C,CAAA;AAnDY,0BAAO;AAEZ;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,C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sCACpB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,wCAAe,EAAE,CAAC;8BACP,wCAAe;gDAAC;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,oBAAa,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;+CACzB;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;oDACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2DACoB;kBAlD/B,OAAO;IADnB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC;GAC/C,OAAO,CAmDnB","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { PaymentMethod } from '../../../utilities/enum';\nimport { BusinessDevelopmentSetting } from './embedded/business-development-setting.model';\nimport { DeliveryCharge } from './embedded/delivery-charge-setting.model';\nimport { CourierSetting } from './embedded/courier-setting.model';\nimport { CurrencySetting } from './embedded/currency-setting.model';\nimport { PayoutSetting } from './embedded/payout-setting.model';\nimport { RiderSetting } from './embedded/rider-setting.model';\nimport { ServiceFeeSetting } from './embedded/service-fee-setting.model';\nimport { WorkHourSetting } from './shared/work-hour.model';\n\n@modelOptions({ schemaOptions: { collection: 'settings' } })\nexport class Setting extends TimeStamps {\n\t@prop({ type: () => [DeliveryCharge] })\n\tpublic deliveryCharges: DeliveryCharge[];\n\n\t@prop({ type: ServiceFeeSetting })\n\tpublic serviceFeeSetting?: ServiceFeeSetting;\n\n\t@prop({ type: PayoutSetting })\n\tpublic payoutSetting?: PayoutSetting;\n\n\t@prop({ type: WorkHourSetting })\n\tpublic workHourSetting?: WorkHourSetting;\n\n\t@prop({ type: CourierSetting })\n\tpublic courierSetting?: CourierSetting;\n\n\t@prop({ type: RiderSetting })\n\tpublic riderSetting?: RiderSetting;\n\n\t@prop({ type: BusinessDevelopmentSetting })\n\tpublic businessDevelopmentSetting?: BusinessDevelopmentSetting;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic payLimitForUser?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic vatPercentage?: number;\n\n\t@prop({ type: () => [Number], default: [] })\n\tpublic riderSearchRanges?: number[];\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic nearByShopDistance?: number;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic nearByShopDistanceInHomeScreen?: number;\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic units?: string[];\n\n\t@prop({ type: CurrencySetting })\n\tpublic currencySetting?: CurrencySetting;\n\n\t@prop({ type: () => [String], enum: PaymentMethod, default: [] })\n\tpublic paymentMethods?: PaymentMethod[];\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isGroupOrderEnabled?: boolean;\n\n\t@prop({ type: String })\n\tpublic customerSupportPhoneNumber?: string;\n}\n"]}
1
+ {"version":3,"file":"setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,4EAAqE;AACrE,kDAAwD;AACxD,sGAA2F;AAC3F,4FAA0E;AAC1E,4EAAkE;AAClE,8EAAoE;AACpE,0EAAgE;AAChE,wEAA8D;AAC9D,oFAAyE;AACzE,8DAA2D;AAC3D,wEAAsE;AACtE,8FAA4E;AAC5E,8FAA2F;AAGpF,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,2BAAU;IAE/B,eAAe,CAAmB;IAGlC,iBAAiB,CAAqB;IAGtC,aAAa,CAAiB;IAG9B,eAAe,CAAmB;IAGlC,cAAc,CAAkB;IAGhC,YAAY,CAAgB;IAG5B,0BAA0B,CAA8B;IAGxD,eAAe,CAAU;IAGzB,aAA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AA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,0CAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;6CACb;AAGtC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;mDACP;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;+DACK;AAGxC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;sCACpB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,wCAAe,EAAE,CAAC;8BACP,wCAAe;gDAAC;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,oBAAa,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;+CACzB;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;oDACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,gDAAe,EAAE,CAAC;8BACP,gDAAe;gDAAC;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,+DAA8B,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;uDACH;kBAxDrD,OAAO;IADnB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC;GAC/C,OAAO,CAyDnB","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { PaymentMethod } from '../../../utilities/enum';\nimport { BusinessDevelopmentSetting } from './embedded/business-development-setting.model';\nimport { DeliveryCharge } from './embedded/delivery-charge-setting.model';\nimport { CourierSetting } from './embedded/courier-setting.model';\nimport { CurrencySetting } from './embedded/currency-setting.model';\nimport { PayoutSetting } from './embedded/payout-setting.model';\nimport { RiderSetting } from './embedded/rider-setting.model';\nimport { ServiceFeeSetting } from './embedded/service-fee-setting.model';\nimport { WorkHourSetting } from './shared/work-hour.model';\nimport { RiderBatchesSettings } from './embedded/rider-batches.model';\nimport { CustomerSupport } from './embedded/customer-support-numbers.model';\nimport { CustomerSupportBatchesSettings } from './embedded/customer-support-batches.model';\n\n@modelOptions({ schemaOptions: { collection: 'settings' } })\nexport class Setting extends TimeStamps {\n\t@prop({ type: () => [DeliveryCharge] })\n\tpublic deliveryCharges: DeliveryCharge[];\n\n\t@prop({ type: ServiceFeeSetting })\n\tpublic serviceFeeSetting?: ServiceFeeSetting;\n\n\t@prop({ type: PayoutSetting })\n\tpublic payoutSetting?: PayoutSetting;\n\n\t@prop({ type: WorkHourSetting })\n\tpublic workHourSetting?: WorkHourSetting;\n\n\t@prop({ type: CourierSetting })\n\tpublic courierSetting?: CourierSetting;\n\n\t@prop({ type: RiderSetting })\n\tpublic riderSetting?: RiderSetting;\n\n\t@prop({ type: BusinessDevelopmentSetting })\n\tpublic businessDevelopmentSetting?: BusinessDevelopmentSetting;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic payLimitForUser?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic vatPercentage?: number;\n\n\t@prop({ type: () => [Number], default: [] })\n\tpublic riderSearchRanges?: number[];\n\n\t@prop({ type: () => [RiderBatchesSettings], default: [] })\n\tpublic riderBatches?: RiderBatchesSettings[];\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic nearByShopDistance?: number;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic nearByShopDistanceInHomeScreen?: number;\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic units?: string[];\n\n\t@prop({ type: CurrencySetting })\n\tpublic currencySetting?: CurrencySetting;\n\n\t@prop({ type: () => [String], enum: PaymentMethod, default: [] })\n\tpublic paymentMethods?: PaymentMethod[];\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isGroupOrderEnabled?: boolean;\n\n\t@prop({ type: CustomerSupport })\n\tpublic customerSupport?: CustomerSupport;\n\n\t@prop({ type: () => [CustomerSupportBatchesSettings], default: [] })\n\tpublic customerSupportBatches?: CustomerSupportBatchesSettings[];\n}\n"]}
@@ -57,6 +57,7 @@ exports.Tag = Tag = __decorate([
57
57
  {
58
58
  $match: {
59
59
  itemType: this.itemType,
60
+ status: enum_1.Status.ACTIVE,
60
61
  deletedAt: null,
61
62
  },
62
63
  },
@@ -73,6 +74,58 @@ exports.Tag = Tag = __decorate([
73
74
  return next(error);
74
75
  }
75
76
  }
77
+ if (this.isModified('status') && this.status === enum_1.Status.ACTIVE) {
78
+ const original = await _1.TagModel.findById(this._id);
79
+ if (original && original.status !== enum_1.Status.ACTIVE) {
80
+ try {
81
+ const maxSortingOrder = await _1.TagModel.aggregate([
82
+ {
83
+ $match: {
84
+ itemType: this.itemType,
85
+ status: enum_1.Status.ACTIVE,
86
+ deletedAt: null,
87
+ },
88
+ },
89
+ {
90
+ $group: {
91
+ _id: null,
92
+ maxSortingOrder: { $max: '$sortingOrder' },
93
+ },
94
+ },
95
+ ]).exec();
96
+ this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
97
+ }
98
+ catch (error) {
99
+ return next(error);
100
+ }
101
+ }
102
+ }
103
+ next();
104
+ }),
105
+ (0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
106
+ const update = this.getUpdate();
107
+ if (update?.status === enum_1.Status.ACTIVE) {
108
+ const tag = await this.model.findOne(this.getQuery());
109
+ if (tag && tag.status !== enum_1.Status.ACTIVE) {
110
+ const maxSortingOrder = await _1.TagModel.aggregate([
111
+ {
112
+ $match: {
113
+ itemType: tag.itemType,
114
+ status: enum_1.Status.ACTIVE,
115
+ deletedAt: null,
116
+ },
117
+ },
118
+ {
119
+ $group: {
120
+ _id: null,
121
+ maxSortingOrder: { $max: '$sortingOrder' },
122
+ },
123
+ },
124
+ ]).exec();
125
+ update.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
126
+ this.setUpdate(update);
127
+ }
128
+ }
76
129
  next();
77
130
  })
78
131
  ], Tag);
@@ -1 +1 @@
1
- {"version":3,"file":"tag.model.js","sourceRoot":"/","sources":["libraries/mongo/models/tag.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,kDAA2D;AAC3D,wBAA6B;AAiCtB,IAAM,GAAG,GAAT,MAAM,GAAG;IAER,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,QAAQ,CAAY;IAGpB,MAAM,CAAU;IAGhB,SAAS,CAAW;IAGpB,YAAY,CAAU;CAC7B,CAAA;AAlBY,kBAAG;AAER;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCACD;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAQ,EAAE,CAAC;;qCAC5B;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;mCACtC;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;sCACZ;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCACM;cAjBjB,GAAG;IA/Bf,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IACvD,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAC/F,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACpC,IAAA,eAAG,EAAM,MAAM,EAAE,KAAK,WAAW,IAAI;QAErC,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,WAAW,EAAE,CAAC;YAC5D,IAAI,CAAC;gBAEJ,MAAM,eAAe,GAAG,MAAM,WAAQ,CAAC,SAAS,CAA8B;oBAC7E;wBACC,MAAM,EAAE;4BACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;4BACvB,SAAS,EAAE,IAAI;yBACf;qBACD;oBACD;wBACC,MAAM,EAAE;4BACP,GAAG,EAAE,IAAI;4BACT,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;yBAC1C;qBACD;iBACD,CAAC,CAAC,IAAI,EAAE,CAAC;gBAGV,IAAI,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACrE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,KAAc,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,GAAG,CAkBf","sourcesContent":["import { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { ItemType, Status } from '../../../utilities/enum';\nimport { TagModel } from '.';\n\n@modelOptions({ schemaOptions: { collection: 'tags' } })\n@Index({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@Index({ itemType: 1, deletedAt: 1 })\n@pre<Tag>('save', async function (next) {\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\n\t\ttry {\n\t\t\t// Find the maximum sortingOrder for tags with the same itemType that aren't deleted\n\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\titemType: this.itemType,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t} catch (error) {\n\t\t\treturn next(error as Error);\n\t\t}\n\t}\n\tnext();\n})\nexport class Tag {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType?: ItemType;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Boolean, default: true })\n\tpublic isVisible?: boolean;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
1
+ {"version":3,"file":"tag.model.js","sourceRoot":"/","sources":["libraries/mongo/models/tag.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,kDAA2D;AAC3D,wBAA6B;AAsGtB,IAAM,GAAG,GAAT,MAAM,GAAG;IAER,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,QAAQ,CAAY;IAGpB,MAAM,CAAU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ItemType, Status } from '../../../utilities/enum';\nimport { TagModel } from '.';\nimport { Query } from 'mongoose';\n\n@modelOptions({ schemaOptions: { collection: 'tags' } })\n@Index({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@Index({ itemType: 1, deletedAt: 1 })\n@pre<Tag>('save', async function (next) {\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\n\t\ttry {\n\t\t\t// Find the maximum sortingOrder for tags with the same itemType that aren't deleted\n\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\titemType: this.itemType,\n\t\t\t\t\t\tstatus: Status.ACTIVE,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t} catch (error) {\n\t\t\treturn next(error as Error);\n\t\t}\n\t}\n\n\t// Add this code to handle status change from inactive to active\n\tif (this.isModified('status') && this.status === Status.ACTIVE) {\n\t\t// Check if status was previously inactive\n\t\tconst original = await TagModel.findById(this._id);\n\t\tif (original && original.status !== Status.ACTIVE) {\n\t\t\ttry {\n\t\t\t\t// Find the maximum sortingOrder for active tags with the same itemType\n\t\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\titemType: this.itemType,\n\t\t\t\t\t\t\tstatus: Status.ACTIVE,\n\t\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t]).exec();\n\n\t\t\t\t// Set the sortingOrder to max + 1 (or 0 if no items found)\n\t\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t\t} catch (error) {\n\t\t\t\treturn next(error as Error);\n\t\t\t}\n\t\t}\n\t}\n\n\tnext();\n})\n@pre<Tag>('findOneAndUpdate', async function (this: Query<any, Tag>, next) {\n\tconst update = this.getUpdate() as any;\n\n\tif (update?.status === Status.ACTIVE) {\n\t\t// Get current document (before update)\n\t\tconst tag = await this.model.findOne(this.getQuery());\n\n\t\tif (tag && tag.status !== Status.ACTIVE) {\n\t\t\t// Find the maximum sortingOrder for active tags with the same itemType\n\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\titemType: tag.itemType,\n\t\t\t\t\t\tstatus: Status.ACTIVE,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tupdate.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\n\t\t\t// Inject the new sortingOrder into the update\n\t\t\tthis.setUpdate(update);\n\t\t}\n\t}\n\n\tnext();\n})\nexport class Tag {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType?: ItemType;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Boolean, default: true })\n\tpublic isVisible?: boolean;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
@@ -34,10 +34,12 @@ let SecretManagerService = class SecretManagerService {
34
34
  });
35
35
  }
36
36
  async getKey(key) {
37
- const environmentTransformedKey = this._configurationService.options.environment + '_' + key;
37
+ console.log(key, 'key---');
38
+ const environmentTransformedKey = this._configurationService?.options?.environment + '_' + key;
38
39
  console.log('Attempting to fetch the following secret key: ' + environmentTransformedKey);
39
40
  try {
40
- const data = await this._redisManager.getCachedObjectByGroup(this._configurationService.options.environment + '_KEYS', key);
41
+ console.log('Fetching from Redis...', this?._configurationService?.options?.environment + '_KEYS');
42
+ const data = await this._redisManager.getCachedObjectByGroup(this?._configurationService?.options?.environment + '_KEYS', key);
41
43
  if (data != undefined) {
42
44
  return data;
43
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/secrets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA0E;AAC1E,mCAAiC;AACjC,oCAAwC;AACxC,oDAAwD;AAGjD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IACxB,qBAAqB,CAAwB;IAC7C,aAAa,CAAgB;IAC7B,OAAO,CAA8B;IAE7C,YAAY,oBAA0C,EAAE,YAA0B;QACjF,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,2CAA0B,CAAC;YAC7C,WAAW,EAAE;gBACZ,SAAS,EAAE,uBAAuB;gBAClC,cAAc,EAAE,0CAA0C;gBAC1D,IAAI,EAAE,iBAAiB;gBACvB,eAAe,EAAE,gBAAgB;gBACjC,SAAS,EAAE,gBAAgB;gBAC3B,WAAW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AAoB;IADhC,IAAA,gBAAO,GAAE;qCAMyB,oCAAoB,EAAgB,oBAAY;GALtE,oBAAoB,CA2DhC","sourcesContent":["import { SecretManagerServiceClient } from '@google-cloud/secret-manager';\nimport { Service } from 'typedi';\nimport { RedisService } from '../redis';\nimport { ConfigurationService } from '../configuration';\n\n@Service()\nexport class SecretManagerService {\n\tprivate _configurationService!: ConfigurationService;\n\tprivate _redisManager!: RedisService;\n\tprivate _client!: SecretManagerServiceClient;\n\n\tconstructor(configurationService: ConfigurationService, redisManager: RedisService) {\n\t\tthis._configurationService = configurationService;\n\t\tthis._redisManager = redisManager;\n\t\tthis._client = new SecretManagerServiceClient({\n\t\t\tcredentials: {\n\t\t\t\tclient_id: '107840895824406590900',\n\t\t\t\tprivate_key_id: 'ece1ebdfde57414700f23f1f4014f5e83d4f7644',\n\t\t\t\ttype: 'service_account',\n\t\t\t\tuniverse_domain: 'googleapis.com',\n\t\t\t\tprojectId: 'for-poc-325210',\n\t\t\t\tprivate_key:\n\t\t\t\t\t'-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDPTk9M5nCDYJhC\\nLuyP+gqBXIHPrXegygco5tB50Y7Q9s/f4hm+xp/usYy5UCYyFVNjZ2mdjWQcr3Ta\\nT3GZV9OiHej8ejveY0iyFBi0IlfGNm9blYlOIyQT4i6MoevNul7u4EQL8bid/sp/\\nJ/XPNC+Jnk8Ke2G9FdfDYs+1O6Nf37HuPUmMwLAzcyl+k1v9UzInrgNPj+nactY7\\nEPCVSM6XcZI3UL86n574iQBvUXsMpUt3csYVOxPap1Vd1TBEo1k85jZepMvaXHoK\\nJUwQT7p1F1D0weVKJ1BjwQgmADZWfUKdwRyS8zFPbUGeptlA2XlxyVMasGzCCMi4\\n6jzJGC81AgMBAAECggEAXoaLnDn7Fbym0I7K6T+PKLtAqaykPpnAOAM/DjzijR/t\\nW12idZ3l8RXeX+VO9UlKE6pkuyVsf7P1a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o87+fLCdSdc38L+j4T\\nBnuwIcY6n4LF+3yAPIF1rnrIBFRqzPta7epYPXHtUTvWOkEkKzNmsFVCZKF7nQjS\\ns/ucyyfUssPsTznYW3gXf3To\\n-----END PRIVATE KEY-----\\n',\n\t\t\t\tclient_email: 'lyxa-core@for-poc-325210.iam.gserviceaccount.com',\n\t\t\t},\n\t\t});\n\t}\n\n\tpublic async getKey(key: string): Promise<string | undefined> {\n\t\tconst environmentTransformedKey = this._configurationService.options.environment + '_' + key;\n\n\t\tconsole.log('Attempting to fetch the following secret key: ' + environmentTransformedKey);\n\n\t\ttry {\n\t\t\tconst data = await this._redisManager.getCachedObjectByGroup<string>(\n\t\t\t\tthis._configurationService.options.environment + '_KEYS',\n\t\t\t\tkey\n\t\t\t);\n\n\t\t\tif (data != undefined) {\n\t\t\t\treturn data;\n\t\t\t}\n\n\t\t\tconst [accessResponse] = await this._client.accessSecretVersion({\n\t\t\t\tname: 'projects/899369746265/secrets/' + environmentTransformedKey + '/versions/latest',\n\t\t\t});\n\n\t\t\tconst val = accessResponse.payload!.data!.toString();\n\n\t\t\tawait this.setKey(key, val);\n\n\t\t\treturn val;\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t}\n\t}\n\n\tpublic async setKey(key: string, value: string): Promise<string> {\n\t\tawait this._redisManager.setCachedObjectByGroup<string>(\n\t\t\tthis._configurationService.options.environment + '_KEYS',\n\t\t\tkey,\n\t\t\tvalue\n\t\t);\n\t\treturn value;\n\t}\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/secrets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAA0E;AAC1E,mCAAiC;AACjC,oCAAwC;AACxC,oDAAwD;AAGjD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IACxB,qBAAqB,CAAwB;IAC7C,aAAa,CAAgB;IAC7B,OAAO,CAA8B;IAE7C,YAAY,oBAA0C,EAAE,YAA0B;QACjF,IAAI,CAAC,qB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C;YAErD,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAE5B,OAAO,GAAG,CAAC;QACZ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,KAAa;QAC7C,MAAM,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAC9C,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,EACxD,GAAG,EACH,KAAK,CACL,CAAC;QACF,OAAO,KAAK,CAAC;IACd,CAAC;CACD,CAAA;AA7DY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,gBAAO,GAAE;qCAMyB,oCAAoB,EAAgB,oBAAY;GALtE,oBAAoB,CA6DhC","sourcesContent":["import { SecretManagerServiceClient } from '@google-cloud/secret-manager';\nimport { Service } from 'typedi';\nimport { RedisService } from '../redis';\nimport { ConfigurationService } from '../configuration';\n\n@Service()\nexport class SecretManagerService {\n\tprivate _configurationService!: ConfigurationService;\n\tprivate _redisManager!: RedisService;\n\tprivate _client!: SecretManagerServiceClient;\n\n\tconstructor(configurationService: ConfigurationService, redisManager: RedisService) {\n\t\tthis._configurationService = configurationService;\n\t\tthis._redisManager = redisManager;\n\t\tthis._client = new SecretManagerServiceClient({\n\t\t\tcredentials: {\n\t\t\t\tclient_id: '107840895824406590900',\n\t\t\t\tprivate_key_id: 'ece1ebdfde57414700f23f1f4014f5e83d4f7644',\n\t\t\t\ttype: 'service_account',\n\t\t\t\tuniverse_domain: 'googleapis.com',\n\t\t\t\tprojectId: 'for-poc-325210',\n\t\t\t\tprivate_key:\n\t\t\t\t\t'-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDPTk9M5nCDYJhC\\nLuyP+gqBXIHPrXegygco5tB50Y7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hrCbUfX8FFEh6ZL3A2zgzXhN\\nZmBtaqfew3URf47UICy894MrCyYi2gSOZCfoz2vu+egLt0QBw/lCOQ4dD1gM/u+B\\nP5wifI14eIb2dLCZBV/83F5n24zo4gjBSNfS/6Jcbs/KvbAfjCptTkX10wKBgDxb\\nwy5WtlRVcqxaf50ilWzr8I/7fH7YceYDG4EbKxTHD0m+BOjbhrlmAlMO2sIUM3WK\\nfpmPCZiuLyCTmuC+kd8xK5ap79h3libgh/2/ReUpvdBhm+PQDOLC4CtCPYdtIn7T\\nP57jN8dRLXJokIIIBw+nH32dS62AQ9oXWYvZ1UKzAoGBAOWOSphZMnPlLeLN54/4\\nwKPI+D6G1JhzqQrUf8Z99J7m3r3ya+0ug5gRGQCoSRfqz9o87+fLCdSdc38L+j4T\\nBnuwIcY6n4LF+3yAPIF1rnrIBFRqzPta7epYPXHtUTvWOkEkKzNmsFVCZKF7nQjS\\ns/ucyyfUssPsTznYW3gXf3To\\n-----END PRIVATE KEY-----\\n',\n\t\t\t\tclient_email: 'lyxa-core@for-poc-325210.iam.gserviceaccount.com',\n\t\t\t},\n\t\t});\n\t}\n\n\tpublic async getKey(key: string): Promise<string | undefined> {\n\t\tconsole.log(key, 'key---');\n\t\tconst environmentTransformedKey = this._configurationService?.options?.environment + '_' + key;\n\n\t\tconsole.log('Attempting to fetch the following secret key: ' + environmentTransformedKey);\n\n\t\ttry {\n\t\t\tconsole.log('Fetching from Redis...', this?._configurationService?.options?.environment + '_KEYS');\n\t\t\tconst data = await this._redisManager.getCachedObjectByGroup<string>(\n\t\t\t\tthis?._configurationService?.options?.environment + '_KEYS',\n\t\t\t\tkey\n\t\t\t);\n\n\t\t\tif (data != undefined) {\n\t\t\t\treturn data;\n\t\t\t}\n\n\t\t\tconst [accessResponse] = await this._client.accessSecretVersion({\n\t\t\t\tname: 'projects/899369746265/secrets/' + environmentTransformedKey + '/versions/latest',\n\t\t\t});\n\n\t\t\tconst val = accessResponse.payload!.data!.toString();\n\n\t\t\tawait this.setKey(key, val);\n\n\t\t\treturn val;\n\t\t} catch (e) {\n\t\t\tconsole.error(e);\n\t\t}\n\t}\n\n\tpublic async setKey(key: string, value: string): Promise<string> {\n\t\tawait this._redisManager.setCachedObjectByGroup<string>(\n\t\t\tthis._configurationService.options.environment + '_KEYS',\n\t\t\tkey,\n\t\t\tvalue\n\t\t);\n\t\treturn value;\n\t}\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import { AuthEntityType, TokenType } from '../../auth';
2
+ interface AuthOptions {
3
+ entityTypes: AuthEntityType[];
4
+ allowRefreshToken?: boolean;
5
+ autoRefresh?: boolean;
6
+ }
7
+ export declare function publicUserDecoder(options: AuthOptions): import("@trpc/server").ProcedureBuilder<{
8
+ _config: import("@trpc/server").RootConfig<{
9
+ ctx: import("@trpc/server/dist/adapters/standalone").CreateHTTPContextOptions & import("../context").LyxaContextParams;
10
+ meta: object;
11
+ errorShape: {
12
+ message: string;
13
+ data: {
14
+ stack: undefined;
15
+ path: undefined;
16
+ code: import("@trpc/server/rpc").TRPC_ERROR_CODE_KEY;
17
+ httpStatus: number;
18
+ };
19
+ stack: undefined;
20
+ code: import("@trpc/server/rpc").TRPC_ERROR_CODE_NUMBER;
21
+ };
22
+ transformer: import("@trpc/server").DefaultDataTransformer;
23
+ }>;
24
+ _meta: object;
25
+ _ctx_out: {
26
+ requestId: string | undefined;
27
+ res: import("http").ServerResponse<import("http").IncomingMessage>;
28
+ tokenType: TokenType | undefined;
29
+ entity: import("../context").EntityContext | undefined;
30
+ req: import("http").IncomingMessage;
31
+ usedRefreshToken: boolean | undefined;
32
+ tokenRenewed: boolean | undefined;
33
+ };
34
+ _input_in: typeof import("@trpc/server").unsetMarker;
35
+ _input_out: typeof import("@trpc/server").unsetMarker;
36
+ _output_in: typeof import("@trpc/server").unsetMarker;
37
+ _output_out: typeof import("@trpc/server").unsetMarker;
38
+ }>;
39
+ export {};
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publicUserDecoder = publicUserDecoder;
4
+ const server_1 = require("@trpc/server");
5
+ const index_1 = require("../index");
6
+ const auth_1 = require("../../auth");
7
+ function publicUserDecoder(options) {
8
+ const { entityTypes, allowRefreshToken = true, autoRefresh = true } = options;
9
+ return index_1.publicProcedure.use(async ({ ctx, next }) => {
10
+ const authHeader = ctx.req.headers['authorization'];
11
+ if (!authHeader) {
12
+ return next({ ctx });
13
+ }
14
+ else {
15
+ const refreshTokenHeader = ctx.req.headers['x-refresh-token'];
16
+ if (!authHeader) {
17
+ throw new server_1.TRPCError({ code: 'UNAUTHORIZED', message: 'No authorization header' });
18
+ }
19
+ const accessToken = authHeader.replace(/^Bearer\s+/, '');
20
+ let refreshToken = '';
21
+ if (refreshTokenHeader) {
22
+ refreshToken =
23
+ typeof refreshTokenHeader === 'string'
24
+ ? refreshTokenHeader.replace(/^Bearer\s+/, '')
25
+ : refreshTokenHeader[0].replace(/^Bearer\s+/, '');
26
+ }
27
+ if (!accessToken) {
28
+ throw new server_1.TRPCError({ code: 'UNAUTHORIZED', message: 'Missing access token' });
29
+ }
30
+ let entity = await (0, auth_1.verifyAccessToken)(entityTypes, accessToken);
31
+ if (entity) {
32
+ ctx.entity = entity;
33
+ ctx.tokenType = auth_1.TokenType.ACCESS;
34
+ ctx.usedRefreshToken = false;
35
+ ctx.tokenRenewed = false;
36
+ return next({ ctx });
37
+ }
38
+ if (!allowRefreshToken || !refreshToken) {
39
+ throw new server_1.TRPCError({
40
+ code: 'UNAUTHORIZED',
41
+ message: 'Invalid access token',
42
+ });
43
+ }
44
+ const renewalResult = await (0, auth_1.handleTokenRenewal)(refreshToken);
45
+ if (!renewalResult.success) {
46
+ const errorMessage = renewalResult.tokenStatus === 'revoked' ? 'Refresh token has been revoked' : 'Invalid refresh token';
47
+ throw new server_1.TRPCError({
48
+ code: 'UNAUTHORIZED',
49
+ message: errorMessage,
50
+ });
51
+ }
52
+ if (!entityTypes.includes(renewalResult.entity.type)) {
53
+ throw new server_1.TRPCError({
54
+ code: 'UNAUTHORIZED',
55
+ message: 'Unauthorized entity type',
56
+ });
57
+ }
58
+ ctx.entity = renewalResult.entity;
59
+ ctx.tokenType = auth_1.TokenType.REFRESH;
60
+ ctx.usedRefreshToken = true;
61
+ ctx.tokenRenewed = renewalResult.tokenStatus === 'expired';
62
+ if (autoRefresh && renewalResult.newTokens) {
63
+ if (renewalResult.newTokens.accessToken) {
64
+ ctx.res.setHeader('X-New-Access-Token', renewalResult.newTokens.accessToken);
65
+ }
66
+ if (renewalResult.newTokens.refreshToken) {
67
+ ctx.res.setHeader('X-New-Refresh-Token', renewalResult.newTokens.refreshToken);
68
+ }
69
+ }
70
+ return next({ ctx });
71
+ }
72
+ });
73
+ }
74
+ //# sourceMappingURL=publicUserDecoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicUserDecoder.js","sourceRoot":"/","sources":["libraries/trpc/middlewares/publicUserDecoder.ts"],"names":[],"mappings":";;AAmBA,8CAmFC;AAtGD,yCAAyC;AACzC,oCAA2C;AAC3C,qCAKoB;AAYpB,SAAgB,iBAAiB,CAAC,OAAoB;IAClD,MAAM,EAAE,WAAW,EAAE,iBAAiB,GAAG,IAAI,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAE9E,OAAO,uBAAe,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE;QAC/C,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACpD,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,OAAO,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACJ,MAAM,kBAAkB,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAE9D,IAAI,CAAC,UAAU,EAAE,CAAC;gBACd,MAAM,IAAI,kBA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../index';\nimport {\n AuthEntityType,\n verifyAccessToken,\n TokenType,\n handleTokenRenewal,\n} from '../../auth';\n\ninterface AuthOptions {\n entityTypes: AuthEntityType[];\n allowRefreshToken?: boolean;\n autoRefresh?: boolean;\n}\n\n/**\n * A factory that creates an authenticated procedure, optionally allowing\n * refresh tokens and auto-refreshing expired access tokens.\n */\nexport function publicUserDecoder(options: AuthOptions) {\n const { entityTypes, allowRefreshToken = true, autoRefresh = true } = options;\n\n return publicProcedure.use(async ({ ctx, next }) => {\n const authHeader = ctx.req.headers['authorization'];\n if (!authHeader) {\n return next({ ctx });\n } else {\n const refreshTokenHeader = ctx.req.headers['x-refresh-token'];\n\n if (!authHeader) {\n throw new TRPCError({ code: 'UNAUTHORIZED', message: 'No authorization header' });\n }\n\n const accessToken = authHeader.replace(/^Bearer\\s+/, '');\n let refreshToken = '';\n\n if (refreshTokenHeader) {\n refreshToken =\n typeof refreshTokenHeader === 'string'\n ? refreshTokenHeader.replace(/^Bearer\\s+/, '')\n : refreshTokenHeader[0].replace(/^Bearer\\s+/, '');\n }\n\n if (!accessToken) {\n throw new TRPCError({ code: 'UNAUTHORIZED', message: 'Missing access token' });\n }\n\n let entity = await verifyAccessToken(entityTypes, accessToken);\n\n if (entity) {\n ctx.entity = entity;\n ctx.tokenType = TokenType.ACCESS;\n ctx.usedRefreshToken = false;\n ctx.tokenRenewed = false;\n return next({ ctx });\n }\n\n if (!allowRefreshToken || !refreshToken) {\n throw new TRPCError({\n code: 'UNAUTHORIZED',\n message: 'Invalid access token',\n });\n }\n\n const renewalResult = await handleTokenRenewal(refreshToken);\n\n if (!renewalResult.success) {\n const errorMessage =\n renewalResult.tokenStatus === 'revoked' ? 'Refresh token has been revoked' : 'Invalid refresh token';\n\n throw new TRPCError({\n code: 'UNAUTHORIZED',\n message: errorMessage,\n });\n }\n\n if (!entityTypes.includes(renewalResult.entity!.type)) {\n throw new TRPCError({\n code: 'UNAUTHORIZED',\n message: 'Unauthorized entity type',\n });\n }\n\n ctx.entity = renewalResult.entity;\n ctx.tokenType = TokenType.REFRESH;\n ctx.usedRefreshToken = true;\n\n ctx.tokenRenewed = renewalResult.tokenStatus === 'expired';\n\n if (autoRefresh && renewalResult.newTokens) {\n if (renewalResult.newTokens.accessToken) {\n ctx.res.setHeader('X-New-Access-Token', renewalResult.newTokens.accessToken);\n }\n\n if (renewalResult.newTokens.refreshToken) {\n ctx.res.setHeader('X-New-Refresh-Token', renewalResult.newTokens.refreshToken);\n }\n }\n\n return next({ ctx });\n }\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.0.47",
3
+ "version": "1.0.49",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",