@lyxa.ai/core 1.0.9 → 1.0.11

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 (37) hide show
  1. package/dist/libraries/auth/index.d.ts +65 -2
  2. package/dist/libraries/auth/index.js +208 -7
  3. package/dist/libraries/auth/index.js.map +1 -1
  4. package/dist/libraries/auth/refreshtoken.d.ts +15 -0
  5. package/dist/libraries/auth/refreshtoken.js +96 -0
  6. package/dist/libraries/auth/refreshtoken.js.map +1 -0
  7. package/dist/libraries/auth/repository.d.ts +18 -0
  8. package/dist/libraries/auth/repository.js +47 -0
  9. package/dist/libraries/auth/repository.js.map +1 -0
  10. package/dist/libraries/index.d.ts +2 -0
  11. package/dist/libraries/index.js +4 -0
  12. package/dist/libraries/index.js.map +1 -1
  13. package/dist/libraries/mongo/models/address.model.d.ts +19 -0
  14. package/dist/libraries/mongo/models/address.model.js +91 -0
  15. package/dist/libraries/mongo/models/address.model.js.map +1 -0
  16. package/dist/libraries/mongo/models/duration.model.d.ts +4 -0
  17. package/dist/libraries/mongo/models/duration.model.js +27 -0
  18. package/dist/libraries/mongo/models/duration.model.js.map +1 -0
  19. package/dist/libraries/mongo/models/work-hour.model.d.ts +4 -5
  20. package/dist/libraries/mongo/models/work-hour.model.js +9 -5
  21. package/dist/libraries/mongo/models/work-hour.model.js.map +1 -1
  22. package/dist/libraries/trpc/context.d.ts +4 -0
  23. package/dist/libraries/trpc/context.js +4 -1
  24. package/dist/libraries/trpc/context.js.map +1 -1
  25. package/dist/libraries/trpc/middlewares/auth.d.ts +11 -2
  26. package/dist/libraries/trpc/middlewares/auth.js +54 -9
  27. package/dist/libraries/trpc/middlewares/auth.js.map +1 -1
  28. package/dist/utilities/enum.d.ts +8 -0
  29. package/dist/utilities/enum.js +11 -1
  30. package/dist/utilities/enum.js.map +1 -1
  31. package/dist/utilities/validation/common-validation.d.ts +233 -36
  32. package/dist/utilities/validation/common-validation.js +44 -16
  33. package/dist/utilities/validation/common-validation.js.map +1 -1
  34. package/dist/utilities/validation/global-validation.d.ts +3 -4
  35. package/dist/utilities/validation/global-validation.js +48 -42
  36. package/dist/utilities/validation/global-validation.js.map +1 -1
  37. package/package.json +1 -1
@@ -0,0 +1,91 @@
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.UserAddress = exports.Address = void 0;
13
+ const typegoose_1 = require("@typegoose/typegoose");
14
+ const enum_1 = require("../../../utilities/enum");
15
+ class Address {
16
+ address;
17
+ description;
18
+ city;
19
+ state;
20
+ country;
21
+ geoLocationType;
22
+ coordinates;
23
+ latitude;
24
+ longitude;
25
+ }
26
+ exports.Address = Address;
27
+ __decorate([
28
+ (0, typegoose_1.prop)({ required: true, type: String }),
29
+ __metadata("design:type", String)
30
+ ], Address.prototype, "address", void 0);
31
+ __decorate([
32
+ (0, typegoose_1.prop)({ type: String }),
33
+ __metadata("design:type", String)
34
+ ], Address.prototype, "description", void 0);
35
+ __decorate([
36
+ (0, typegoose_1.prop)({ required: true, type: String }),
37
+ __metadata("design:type", String)
38
+ ], Address.prototype, "city", void 0);
39
+ __decorate([
40
+ (0, typegoose_1.prop)({ required: true, type: String }),
41
+ __metadata("design:type", String)
42
+ ], Address.prototype, "state", void 0);
43
+ __decorate([
44
+ (0, typegoose_1.prop)({ required: true, type: String }),
45
+ __metadata("design:type", String)
46
+ ], Address.prototype, "country", void 0);
47
+ __decorate([
48
+ (0, typegoose_1.prop)({ type: String, enum: enum_1.GeoLocationType, default: enum_1.GeoLocationType.POINT }),
49
+ __metadata("design:type", String)
50
+ ], Address.prototype, "geoLocationType", void 0);
51
+ __decorate([
52
+ (0, typegoose_1.prop)({ required: true, type: () => [Number] }),
53
+ __metadata("design:type", Array)
54
+ ], Address.prototype, "coordinates", void 0);
55
+ __decorate([
56
+ (0, typegoose_1.prop)({ required: true, type: Number }),
57
+ __metadata("design:type", Number)
58
+ ], Address.prototype, "latitude", void 0);
59
+ __decorate([
60
+ (0, typegoose_1.prop)({ required: true, type: Number }),
61
+ __metadata("design:type", Number)
62
+ ], Address.prototype, "longitude", void 0);
63
+ class UserAddress extends Address {
64
+ addressLabel;
65
+ apartment;
66
+ buildingName;
67
+ deliveryOption;
68
+ instructions;
69
+ }
70
+ exports.UserAddress = UserAddress;
71
+ __decorate([
72
+ (0, typegoose_1.prop)({ required: true, type: String }),
73
+ __metadata("design:type", String)
74
+ ], UserAddress.prototype, "addressLabel", void 0);
75
+ __decorate([
76
+ (0, typegoose_1.prop)({ required: true, type: String }),
77
+ __metadata("design:type", String)
78
+ ], UserAddress.prototype, "apartment", void 0);
79
+ __decorate([
80
+ (0, typegoose_1.prop)({ required: true, type: String }),
81
+ __metadata("design:type", String)
82
+ ], UserAddress.prototype, "buildingName", void 0);
83
+ __decorate([
84
+ (0, typegoose_1.prop)({ type: String }),
85
+ __metadata("design:type", String)
86
+ ], UserAddress.prototype, "deliveryOption", void 0);
87
+ __decorate([
88
+ (0, typegoose_1.prop)({ type: String }),
89
+ __metadata("design:type", String)
90
+ ], UserAddress.prototype, "instructions", void 0);
91
+ //# sourceMappingURL=address.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address.model.js","sourceRoot":"/","sources":["libraries/mongo/models/address.model.ts"],"names":[],"mappings":";;;;;;;;;;;;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Y,CAAU;IAGtB,SAAS,CAAU;IAGnB,YAAY,CAAU;IAGtB,cAAc,CAAU;IAGxB,YAAY,CAAU;CAC9B;AAfD,kCAeC;AAbQ;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDACV;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACb;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDACV;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDACQ;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;iDACM","sourcesContent":["import { prop } from \"@typegoose/typegoose\";\r\nimport { GeoLocationType } from \"../../../utilities/enum\";\r\n\r\nexport class Address {\r\n @prop({ required: true, type: String })\r\n public address!: string;\r\n\r\n @prop({ type: String })\r\n public description?: string;\r\n\r\n @prop({ required: true, type: String })\r\n public city!: string;\r\n\r\n @prop({ required: true, type: String })\r\n public state!: string;\r\n\r\n @prop({ required: true, type: String })\r\n public country!: string;\r\n\r\n @prop({ type: String, enum: GeoLocationType, default: GeoLocationType.POINT })\r\n public geoLocationType!: GeoLocationType;\r\n\r\n @prop({ required: true, type: () => [Number] })\r\n public coordinates!: number[];\r\n\r\n @prop({ required: true, type: Number })\r\n public latitude!: number;\r\n\r\n @prop({ required: true, type: Number })\r\n public longitude!: number;\r\n}\r\n\r\nexport class UserAddress extends Address {\r\n @prop({ required: true, type: String })\r\n public addressLabel!: string;\r\n\r\n @prop({ required: true, type: String })\r\n public apartment!: string;\r\n\r\n @prop({ required: true, type: String })\r\n public buildingName!: string;\r\n\r\n @prop({ type: String })\r\n public deliveryOption?: string;\r\n\r\n @prop({ type: String })\r\n public instructions?: string;\r\n}\r\n"]}
@@ -0,0 +1,4 @@
1
+ export declare class Duration {
2
+ start: Date;
3
+ end?: Date;
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.Duration = void 0;
13
+ const typegoose_1 = require("@typegoose/typegoose");
14
+ class Duration {
15
+ start;
16
+ end;
17
+ }
18
+ exports.Duration = Duration;
19
+ __decorate([
20
+ (0, typegoose_1.prop)({ required: true, type: Date, default: new Date() }),
21
+ __metadata("design:type", Date)
22
+ ], Duration.prototype, "start", void 0);
23
+ __decorate([
24
+ (0, typegoose_1.prop)({ type: Date }),
25
+ __metadata("design:type", Date)
26
+ ], Duration.prototype, "end", void 0);
27
+ //# sourceMappingURL=duration.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.model.js","sourceRoot":"/","sources":["libraries/mongo/models/duration.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA8G;AAG9G,MAAa,QAAQ;IAEb,KAAK,CAAQ;IAGb,GAAG,CAAQ;CAClB;AAND,4BAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC;8BAC3C,IAAI;uCAAC;AAGb;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;8BACR,IAAI;qCAAC","sourcesContent":["import { getModelForClass, index, modelOptions, mongoose, prop, ReturnModelType } from '@typegoose/typegoose';\r\n\r\n\r\nexport class Duration {\r\n\t@prop({ required: true, type: Date, default: new Date() })\r\n\tpublic start!: Date;\r\n\r\n\t@prop({ type: Date })\r\n\tpublic end?: Date;\r\n}"]}
@@ -1,18 +1,17 @@
1
- import { WeekDay, WorkStatus } from "../../../utilities/enum";
1
+ import { HolidayWorkStatus, WeekDay, WorkStatus } from "../../../utilities/enum";
2
2
  declare class StartEndTime {
3
- start?: string;
4
- end?: string;
3
+ start: string;
4
+ end: string;
5
5
  }
6
6
  export declare class NormalHour {
7
7
  day: WeekDay;
8
8
  status: WorkStatus;
9
9
  openingHours?: StartEndTime[];
10
10
  }
11
- type HolidayWorkStatus = Exclude<WorkStatus, WorkStatus.OPEN>;
12
11
  export declare class HolidayHour {
13
12
  date?: Date;
14
13
  status: HolidayWorkStatus;
15
- closingHour?: StartEndTime[];
14
+ closingHour?: StartEndTime;
16
15
  }
17
16
  export declare class WorkHourSetting {
18
17
  normalHours?: NormalHour[];
@@ -17,11 +17,11 @@ class StartEndTime {
17
17
  end;
18
18
  }
19
19
  __decorate([
20
- (0, typegoose_1.prop)({ type: String }),
20
+ (0, typegoose_1.prop)({ required: true, type: String }),
21
21
  __metadata("design:type", String)
22
22
  ], StartEndTime.prototype, "start", void 0);
23
23
  __decorate([
24
- (0, typegoose_1.prop)({ type: String }),
24
+ (0, typegoose_1.prop)({ required: true, type: String }),
25
25
  __metadata("design:type", String)
26
26
  ], StartEndTime.prototype, "end", void 0);
27
27
  class NormalHour {
@@ -49,16 +49,20 @@ class HolidayHour {
49
49
  }
50
50
  exports.HolidayHour = HolidayHour;
51
51
  __decorate([
52
- (0, typegoose_1.prop)({ type: Date }),
52
+ (0, typegoose_1.prop)({ required: true, type: Date }),
53
53
  __metadata("design:type", Date)
54
54
  ], HolidayHour.prototype, "date", void 0);
55
55
  __decorate([
56
- (0, typegoose_1.prop)({ required: true, type: String, enum: [enum_1.WorkStatus.CLOSED, enum_1.WorkStatus.FULL_DAY] }),
56
+ (0, typegoose_1.prop)({
57
+ required: true,
58
+ type: String,
59
+ enum: enum_1.HolidayWorkStatus
60
+ }),
57
61
  __metadata("design:type", String)
58
62
  ], HolidayHour.prototype, "status", void 0);
59
63
  __decorate([
60
64
  (0, typegoose_1.prop)({ type: StartEndTime }),
61
- __metadata("design:type", Array)
65
+ __metadata("design:type", StartEndTime)
62
66
  ], HolidayHour.prototype, "closingHour", void 0);
63
67
  class WorkHourSetting {
64
68
  normalHours;
@@ -1 +1 @@
1
- {"version":3,"file":"work-hour.model.js","sourceRoot":"/","sources":["libraries/mongo/models/work-hour.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,kDAA8D;AAE9D,MAAM,YAAY;IAEV,KAAK,CAAU;IAGf,GAAG,CAAU;CACpB;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CACD;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCACH;AAGrB,MAAa,UAAU;IAEf,GAAG,CAAW;IAGd,MAAM,CAAc;IAGpB,YAAY,CAAkB;CACrC;AATD,gCASC;AAPO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAO,EAAE,CAAC;;uCAC/C;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAU,EAAE,CAAC;;0CAC9B;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;gDACb;AAKtC,MAAa,WAAW;IAEhB,IAAI,CAAQ;IAGZ,MAAM,CAAqB;IAG3B,WAAW,CAAkB;CACpC;AATD,kCASC;AAPO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;8BACP,IAAI;yCAAC;AAGZ;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,iBAAU,CAAC,MAAM,EAAE,iBAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;;2CACrD;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;;gDACO;AAGrC,MAAa,eAAe;IAEpB,WAAW,CAAgB;IAG3B,YAAY,CAAiB;CACpC;AAND,0CAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;oDACd;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;qDACb","sourcesContent":["import { prop } from \"@typegoose/typegoose\";\r\nimport { WeekDay, WorkStatus } from \"../../../utilities/enum\";\r\n\r\nclass StartEndTime {\r\n\t@prop({ type: String })\r\n\tpublic start?: string;\r\n\r\n\t@prop({ type: String })\r\n\tpublic end?: string;\r\n}\r\n\r\nexport class NormalHour {\r\n\t@prop({ required: true, unique: true, type: Number, enum: WeekDay })\r\n\tpublic day!: WeekDay;\r\n\r\n\t@prop({ required: true, type: String, enum: WorkStatus })\r\n\tpublic status!: WorkStatus;\r\n\r\n\t@prop({ type: () => [StartEndTime], default: [] })\r\n\tpublic openingHours?: StartEndTime[];\r\n}\r\n\r\ntype HolidayWorkStatus = Exclude<WorkStatus, WorkStatus.OPEN>;\r\n\r\nexport class HolidayHour {\r\n\t@prop({ type: Date })\r\n\tpublic date?: Date;\r\n\r\n\t@prop({ required: true, type: String, enum: [WorkStatus.CLOSED, WorkStatus.FULL_DAY] })\r\n\tpublic status!: HolidayWorkStatus;\r\n\r\n\t@prop({ type: StartEndTime })\r\n\tpublic closingHour?: StartEndTime[];\r\n}\r\n\r\nexport class WorkHourSetting {\r\n\t@prop({ type: () => [NormalHour], default: [] })\r\n\tpublic normalHours?: NormalHour[];\r\n\r\n\t@prop({ type: () => [HolidayHour], default: [] })\r\n\tpublic holidayHours?: HolidayHour[];\r\n}\r\n"]}
1
+ {"version":3,"file":"work-hour.model.js","sourceRoot":"/","sources":["libraries/mongo/models/work-hour.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,kDAIiC;AAEjC,MAAM,YAAY;IAET,KAAK,CAAU;IAGf,GAAG,CAAU;CACrB;AAJQ;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CACjB;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCACnB;AAGtB,MAAa,UAAU;IAEd,GAAG,CAAW;IAGd,MAAM,CAAc;IAGpB,YAAY,CAAkB;CACtC;AATD,gCASC;AAPQ;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAO,EAAE,CAAC;;uCAC/C;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAU,EAAE,CAAC;;0CAC9B;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;gDACb;AAGvC,MAAa,WAAW;IAEf,IAAI,CAAQ;IAOZ,MAAM,CAAqB;IAG3B,WAAW,CAAgB;CACnC;AAbD,kCAaC;AAXQ;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;8BACvB,IAAI;yCAAC;AAOZ;IALN,IAAA,gBAAI,EAAC;QACJ,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,wBAAiB;KACxB,CAAC;;2CACgC;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BACR,YAAY;gDAAC;AAGpC,MAAa,eAAe;IAEnB,WAAW,CAAgB;IAG3B,YAAY,CAAiB;CACrC;AAND,0CAMC;AAJQ;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;oDACd;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;qDACb","sourcesContent":["import { prop } from \"@typegoose/typegoose\";\r\nimport {\r\n HolidayWorkStatus,\r\n WeekDay,\r\n WorkStatus\r\n} from \"../../../utilities/enum\";\r\n\r\nclass StartEndTime {\r\n @prop({ required: true, type: String })\r\n public start!: string;\r\n\r\n @prop({ required: true, type: String })\r\n public end!: string;\r\n}\r\n\r\nexport class NormalHour {\r\n @prop({ required: true, unique: true, type: Number, enum: WeekDay })\r\n public day!: WeekDay;\r\n\r\n @prop({ required: true, type: String, enum: WorkStatus })\r\n public status!: WorkStatus;\r\n\r\n @prop({ type: () => [StartEndTime], default: [] })\r\n public openingHours?: StartEndTime[];\r\n}\r\n\r\nexport class HolidayHour {\r\n @prop({ required: true, type: Date })\r\n public date?: Date;\r\n\r\n @prop({\r\n required: true,\r\n type: String,\r\n enum: HolidayWorkStatus\r\n })\r\n public status!: HolidayWorkStatus;\r\n\r\n @prop({ type: StartEndTime })\r\n public closingHour?: StartEndTime;\r\n}\r\n\r\nexport class WorkHourSetting {\r\n @prop({ type: () => [NormalHour], default: [] })\r\n public normalHours?: NormalHour[];\r\n\r\n @prop({ type: () => [HolidayHour], default: [] })\r\n public holidayHours?: HolidayHour[];\r\n}\r\n"]}
@@ -1,6 +1,7 @@
1
1
  import { CreateHTTPContextOptions } from "@trpc/server/dist/adapters/standalone";
2
2
  import { AuthEntityType } from "../auth";
3
3
  import jwt from "jsonwebtoken";
4
+ import { TokenType } from "../auth";
4
5
  export interface EntityContext extends jwt.JwtPayload {
5
6
  id: string;
6
7
  type: AuthEntityType;
@@ -9,6 +10,9 @@ export interface EntityContext extends jwt.JwtPayload {
9
10
  export interface LyxaContextParams {
10
11
  entity?: EntityContext;
11
12
  requestId?: string;
13
+ tokenType?: TokenType;
14
+ usedRefreshToken?: boolean;
15
+ tokenRenewed?: boolean;
12
16
  }
13
17
  export declare const createLyxaContext: (opts: CreateHTTPContextOptions) => Promise<CreateHTTPContextOptions & LyxaContextParams>;
14
18
  export type LyxaContext = Awaited<ReturnType<typeof createLyxaContext>>;
@@ -5,7 +5,10 @@ const createLyxaContext = async (opts) => {
5
5
  return {
6
6
  ...opts,
7
7
  entity: undefined,
8
- requestId: undefined
8
+ requestId: undefined,
9
+ tokenType: undefined,
10
+ usedRefreshToken: false,
11
+ tokenRenewed: false
9
12
  };
10
13
  };
11
14
  exports.createLyxaContext = createLyxaContext;
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"/","sources":["libraries/trpc/context.ts"],"names":[],"mappings":";;;AAeO,MAAM,iBAAiB,GAAG,KAAK,EAAE,IAA8B,EAAyD,EAAE;IAC7H,OAAO;QACH,GAAG,IAAI;QACP,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,SAAS;KACvB,CAAC;AACN,CAAC,CAAA;AANY,QAAA,iBAAiB,qBAM7B","sourcesContent":["import {CreateHTTPContextOptions} from \"@trpc/server/dist/adapters/standalone\";\r\nimport {AuthEntityType} from \"../auth\";\r\nimport jwt from \"jsonwebtoken\";\r\n\r\nexport interface EntityContext extends jwt.JwtPayload {\r\n id: string,\r\n type: AuthEntityType,\r\n parameters: Record<string, unknown>\r\n}\r\n\r\nexport interface LyxaContextParams {\r\n entity?: EntityContext,\r\n requestId?: string,\r\n}\r\n\r\nexport const createLyxaContext = async (opts: CreateHTTPContextOptions): Promise<CreateHTTPContextOptions & LyxaContextParams> => {\r\n return {\r\n ...opts,\r\n entity: undefined,\r\n requestId: undefined\r\n };\r\n}\r\n\r\nexport type LyxaContext = Awaited<ReturnType<typeof createLyxaContext>>;\r\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"/","sources":["libraries/trpc/context.ts"],"names":[],"mappings":";;;AAmBO,MAAM,iBAAiB,GAAG,KAAK,EAAE,IAA8B,EAAyD,EAAE;IAC7H,OAAO;QACH,GAAG,IAAI;QACP,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,gBAAgB,EAAE,KAAK;QACvB,YAAY,EAAE,KAAK;KACtB,CAAC;AACN,CAAC,CAAA;AATY,QAAA,iBAAiB,qBAS7B","sourcesContent":["import { CreateHTTPContextOptions } from \"@trpc/server/dist/adapters/standalone\";\r\nimport { AuthEntityType } from \"../auth\";\r\nimport jwt from \"jsonwebtoken\";\r\nimport { TokenType } from \"../auth\";\r\n\r\nexport interface EntityContext extends jwt.JwtPayload {\r\n id: string,\r\n type: AuthEntityType,\r\n parameters: Record<string, unknown>\r\n}\r\n\r\nexport interface LyxaContextParams {\r\n entity?: EntityContext,\r\n requestId?: string,\r\n tokenType?: TokenType,\r\n usedRefreshToken?: boolean,\r\n tokenRenewed?: boolean\r\n}\r\n\r\nexport const createLyxaContext = async (opts: CreateHTTPContextOptions): Promise<CreateHTTPContextOptions & LyxaContextParams> => {\r\n return {\r\n ...opts,\r\n entity: undefined,\r\n requestId: undefined,\r\n tokenType: undefined,\r\n usedRefreshToken: false,\r\n tokenRenewed: false\r\n };\r\n}\r\n\r\nexport type LyxaContext = Awaited<ReturnType<typeof createLyxaContext>>;\r\n"]}
@@ -1,5 +1,10 @@
1
- import { AuthEntityType } from "../../auth";
2
- export declare function createAuthenticatedProcedure(entityTypes: AuthEntityType[]): import("@trpc/server").ProcedureBuilder<{
1
+ import { AuthEntityType, TokenType } from "../../auth";
2
+ interface AuthOptions {
3
+ entityTypes: AuthEntityType[];
4
+ allowRefreshToken?: boolean;
5
+ autoRefresh?: boolean;
6
+ }
7
+ export declare function createAuthenticatedProcedure(options: AuthOptions): import("@trpc/server").ProcedureBuilder<{
3
8
  _config: import("@trpc/server").RootConfig<{
4
9
  ctx: import("@trpc/server/dist/adapters/standalone").CreateHTTPContextOptions & import("../context").LyxaContextParams;
5
10
  meta: object;
@@ -10,11 +15,15 @@ export declare function createAuthenticatedProcedure(entityTypes: AuthEntityType
10
15
  _ctx_out: {
11
16
  requestId: string | undefined;
12
17
  res: import("http").ServerResponse<import("http").IncomingMessage>;
18
+ tokenType: TokenType | undefined;
13
19
  entity: import("../context").EntityContext | undefined;
14
20
  req: import("http").IncomingMessage;
21
+ usedRefreshToken: boolean | undefined;
22
+ tokenRenewed: boolean | undefined;
15
23
  };
16
24
  _input_in: typeof import("@trpc/server").unsetMarker;
17
25
  _input_out: typeof import("@trpc/server").unsetMarker;
18
26
  _output_in: typeof import("@trpc/server").unsetMarker;
19
27
  _output_out: typeof import("@trpc/server").unsetMarker;
20
28
  }>;
29
+ export {};
@@ -4,21 +4,66 @@ exports.createAuthenticatedProcedure = createAuthenticatedProcedure;
4
4
  const server_1 = require("@trpc/server");
5
5
  const index_1 = require("../index");
6
6
  const auth_1 = require("../../auth");
7
- function createAuthenticatedProcedure(entityTypes) {
7
+ function createAuthenticatedProcedure(options) {
8
+ const { entityTypes, allowRefreshToken = true, autoRefresh = true } = options;
8
9
  return index_1.publicProcedure.use(async ({ ctx, next }) => {
9
10
  const authHeader = ctx.req.headers["authorization"];
11
+ const refreshTokenHeader = ctx.req.headers["x-refresh-token"];
10
12
  if (!authHeader) {
11
- throw new server_1.TRPCError({ code: "UNAUTHORIZED", message: "No header" });
13
+ throw new server_1.TRPCError({ code: "UNAUTHORIZED", message: "No authorization header" });
12
14
  }
13
- const token = authHeader.replace(/^Bearer\s+/, '');
14
- if (!token) {
15
- throw new server_1.TRPCError({ code: 'UNAUTHORIZED', message: 'Missing token' });
15
+ const accessToken = authHeader.replace(/^Bearer\s+/, '');
16
+ let refreshToken = "";
17
+ if (refreshTokenHeader) {
18
+ refreshToken = typeof refreshTokenHeader === 'string'
19
+ ? refreshTokenHeader.replace(/^Bearer\s+/, '')
20
+ : refreshTokenHeader[0].replace(/^Bearer\s+/, '');
16
21
  }
17
- const jwtToken = await (0, auth_1.verifyToken)(entityTypes, token);
18
- if (!jwtToken) {
19
- throw new server_1.TRPCError({ code: 'UNAUTHORIZED', message: 'Could not decode token based on given types' });
22
+ if (!accessToken) {
23
+ throw new server_1.TRPCError({ code: 'UNAUTHORIZED', message: 'Missing access token' });
24
+ }
25
+ let entity = await (0, auth_1.verifyAccessToken)(entityTypes, accessToken);
26
+ if (entity) {
27
+ ctx.entity = entity;
28
+ ctx.tokenType = auth_1.TokenType.ACCESS;
29
+ ctx.usedRefreshToken = false;
30
+ ctx.tokenRenewed = false;
31
+ return next({ ctx });
32
+ }
33
+ if (!allowRefreshToken || !refreshToken) {
34
+ throw new server_1.TRPCError({
35
+ code: 'UNAUTHORIZED',
36
+ message: 'Invalid access token'
37
+ });
38
+ }
39
+ const renewalResult = await (0, auth_1.handleTokenRenewal)(refreshToken);
40
+ if (!renewalResult.success) {
41
+ const errorMessage = renewalResult.tokenStatus === 'revoked'
42
+ ? 'Refresh token has been revoked'
43
+ : 'Invalid refresh token';
44
+ throw new server_1.TRPCError({
45
+ code: 'UNAUTHORIZED',
46
+ message: errorMessage
47
+ });
48
+ }
49
+ if (!entityTypes.includes(renewalResult.entity.type)) {
50
+ throw new server_1.TRPCError({
51
+ code: 'UNAUTHORIZED',
52
+ message: 'Unauthorized entity type'
53
+ });
54
+ }
55
+ ctx.entity = renewalResult.entity;
56
+ ctx.tokenType = auth_1.TokenType.REFRESH;
57
+ ctx.usedRefreshToken = true;
58
+ ctx.tokenRenewed = renewalResult.tokenStatus === 'expired';
59
+ if (autoRefresh && renewalResult.newTokens) {
60
+ if (renewalResult.newTokens.accessToken) {
61
+ ctx.res.setHeader('X-New-Access-Token', renewalResult.newTokens.accessToken);
62
+ }
63
+ if (renewalResult.newTokens.refreshToken) {
64
+ ctx.res.setHeader('X-New-Refresh-Token', renewalResult.newTokens.refreshToken);
65
+ }
20
66
  }
21
- ctx.entity = jwtToken;
22
67
  return next({ ctx });
23
68
  });
24
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"/","sources":["libraries/trpc/middlewares/auth.ts"],"names":[],"mappings":";;AAQA,oEAwBC;AAhCD,yCAAuC;AACvC,oCAAyC;AACzC,qCAAuD;AAMvD,SAAgB,4BAA4B,CAAC,WAA6B;IACtE,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;QAEpD,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,MAAM,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAEnD,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,MAAM,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAA,kBAAW,EAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAEvD,IAAG,CAAC,QAAQ,EAAE,CAAC;YACX,MAAM,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,6CAA6C,EAAE,CAAC,CAAC;QAC1G,CAAC;QAED,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC;QAEtB,OAAO,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {TRPCError} from '@trpc/server';\r\nimport {publicProcedure} from \"../index\";\r\nimport {AuthEntityType, verifyToken} from \"../../auth\";\r\n\r\n/**\r\n * A factory that creates an authenticated procedure, optionally restricting\r\n * the entity to a list of specific types (e.g. AuthEntityType.USER).\r\n */\r\nexport function createAuthenticatedProcedure(entityTypes: AuthEntityType[]) {\r\n return publicProcedure.use(async ({ ctx, next }) => {\r\n const authHeader = ctx.req.headers[\"authorization\"];\r\n\r\n if (!authHeader) {\r\n throw new TRPCError({ code: \"UNAUTHORIZED\", message: \"No header\" });\r\n }\r\n\r\n const token = authHeader.replace(/^Bearer\\s+/, '');\r\n\r\n if (!token) {\r\n throw new TRPCError({ code: 'UNAUTHORIZED', message: 'Missing token' });\r\n }\r\n\r\n const jwtToken = await verifyToken(entityTypes, token);\r\n\r\n if(!jwtToken) {\r\n throw new TRPCError({ code: 'UNAUTHORIZED', message: 'Could not decode token based on given types' });\r\n }\r\n\r\n ctx.entity = jwtToken;\r\n\r\n return next({ ctx });\r\n });\r\n}\r\n"]}
1
+ {"version":3,"file":"auth.js","sourceRoot":"/","sources":["libraries/trpc/middlewares/auth.ts"],"names":[],"mappings":";;A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AC;YACzC,IAAI,aAAa,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;gBACtC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,EAAE,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YACjF,CAAC;YAED,IAAI,aAAa,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;gBACvC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,qBAAqB,EAAE,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;YACnF,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { TRPCError } from '@trpc/server';\r\nimport { publicProcedure } from \"../index\";\r\nimport {\r\n AuthEntityType,\r\n verifyAccessToken,\r\n validateRefreshToken,\r\n signAccessToken,\r\n TokenType, refreshTokens, handleTokenRenewal\r\n} from \"../../auth\";\r\n\r\ninterface AuthOptions {\r\n entityTypes: AuthEntityType[];\r\n allowRefreshToken?: boolean;\r\n autoRefresh?: boolean;\r\n}\r\n\r\n/**\r\n * A factory that creates an authenticated procedure, optionally allowing\r\n * refresh tokens and auto-refreshing expired access tokens.\r\n */\r\nexport function createAuthenticatedProcedure(options: AuthOptions) {\r\n const { entityTypes, allowRefreshToken = true, autoRefresh = true } = options;\r\n\r\n return publicProcedure.use(async ({ ctx, next }) => {\r\n const authHeader = ctx.req.headers[\"authorization\"];\r\n const refreshTokenHeader = ctx.req.headers[\"x-refresh-token\"];\r\n\r\n if (!authHeader) {\r\n throw new TRPCError({ code: \"UNAUTHORIZED\", message: \"No authorization header\" });\r\n }\r\n\r\n const accessToken = authHeader.replace(/^Bearer\\s+/, '');\r\n let refreshToken = \"\";\r\n\r\n if (refreshTokenHeader) {\r\n refreshToken = typeof refreshTokenHeader === 'string'\r\n ? refreshTokenHeader.replace(/^Bearer\\s+/, '')\r\n : refreshTokenHeader[0].replace(/^Bearer\\s+/, '');\r\n }\r\n\r\n if (!accessToken) {\r\n throw new TRPCError({ code: 'UNAUTHORIZED', message: 'Missing access token' });\r\n }\r\n\r\n let entity = await verifyAccessToken(entityTypes, accessToken);\r\n\r\n if (entity) {\r\n ctx.entity = entity;\r\n ctx.tokenType = TokenType.ACCESS;\r\n ctx.usedRefreshToken = false;\r\n ctx.tokenRenewed = false;\r\n return next({ ctx });\r\n }\r\n\r\n if (!allowRefreshToken || !refreshToken) {\r\n throw new TRPCError({\r\n code: 'UNAUTHORIZED',\r\n message: 'Invalid access token'\r\n });\r\n }\r\n\r\n const renewalResult = await handleTokenRenewal(refreshToken);\r\n\r\n if (!renewalResult.success) {\r\n const errorMessage = renewalResult.tokenStatus === 'revoked'\r\n ? 'Refresh token has been revoked'\r\n : 'Invalid refresh token';\r\n\r\n throw new TRPCError({\r\n code: 'UNAUTHORIZED',\r\n message: errorMessage\r\n });\r\n }\r\n\r\n if (!entityTypes.includes(renewalResult.entity!.type)) {\r\n throw new TRPCError({\r\n code: 'UNAUTHORIZED',\r\n message: 'Unauthorized entity type'\r\n });\r\n }\r\n\r\n ctx.entity = renewalResult.entity;\r\n ctx.tokenType = TokenType.REFRESH;\r\n ctx.usedRefreshToken = true;\r\n\r\n ctx.tokenRenewed = renewalResult.tokenStatus === 'expired';\r\n\r\n if (autoRefresh && renewalResult.newTokens) {\r\n if (renewalResult.newTokens.accessToken) {\r\n ctx.res.setHeader('X-New-Access-Token', renewalResult.newTokens.accessToken);\r\n }\r\n\r\n if (renewalResult.newTokens.refreshToken) {\r\n ctx.res.setHeader('X-New-Refresh-Token', renewalResult.newTokens.refreshToken);\r\n }\r\n }\r\n\r\n return next({ ctx });\r\n });\r\n}\r\n"]}
@@ -25,6 +25,10 @@ export declare enum WorkStatus {
25
25
  CLOSED = "closed",
26
26
  FULL_DAY = "full_day"
27
27
  }
28
+ export declare enum HolidayWorkStatus {
29
+ CLOSED = "closed",
30
+ FULL_DAY = "full_day"
31
+ }
28
32
  export declare enum ValueType {
29
33
  PERCENTAGE = "percentage",
30
34
  FIXED = "fixed"
@@ -51,3 +55,7 @@ export declare enum RatingAccountType {
51
55
  SHOP = "shop",
52
56
  RIDER = "rider"
53
57
  }
58
+ export declare enum GeoLocationType {
59
+ POINT = "point",
60
+ POLYGON = "polygon"
61
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RatingAccountType = exports.SubscriptionPackage = exports.PaidCurrency = exports.PaymentStatus = exports.PaymentMethod = exports.ValueType = exports.WorkStatus = exports.WeekDay = exports.ItemType = exports.Status = void 0;
3
+ exports.GeoLocationType = exports.RatingAccountType = exports.SubscriptionPackage = exports.PaidCurrency = exports.PaymentStatus = exports.PaymentMethod = exports.ValueType = exports.HolidayWorkStatus = exports.WorkStatus = exports.WeekDay = exports.ItemType = exports.Status = void 0;
4
4
  var Status;
5
5
  (function (Status) {
6
6
  Status["ACTIVE"] = "active";
@@ -32,6 +32,11 @@ var WorkStatus;
32
32
  WorkStatus["CLOSED"] = "closed";
33
33
  WorkStatus["FULL_DAY"] = "full_day";
34
34
  })(WorkStatus || (exports.WorkStatus = WorkStatus = {}));
35
+ var HolidayWorkStatus;
36
+ (function (HolidayWorkStatus) {
37
+ HolidayWorkStatus["CLOSED"] = "closed";
38
+ HolidayWorkStatus["FULL_DAY"] = "full_day";
39
+ })(HolidayWorkStatus || (exports.HolidayWorkStatus = HolidayWorkStatus = {}));
35
40
  var ValueType;
36
41
  (function (ValueType) {
37
42
  ValueType["PERCENTAGE"] = "percentage";
@@ -64,4 +69,9 @@ var RatingAccountType;
64
69
  RatingAccountType["SHOP"] = "shop";
65
70
  RatingAccountType["RIDER"] = "rider";
66
71
  })(RatingAccountType || (exports.RatingAccountType = RatingAccountType = {}));
72
+ var GeoLocationType;
73
+ (function (GeoLocationType) {
74
+ GeoLocationType["POINT"] = "point";
75
+ GeoLocationType["POLYGON"] = "polygon";
76
+ })(GeoLocationType || (exports.GeoLocationType = GeoLocationType = {}));
67
77
  //# sourceMappingURL=enum.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"/","sources":["utilities/enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,MAGX;AAHD,WAAY,MAAM;IACjB,2BAAiB,CAAA;IACjB,+BAAqB,CAAA;AACtB,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB;AAED,IAAY,QAQX;AARD,WAAY,QAAQ;IACnB,yBAAa,CAAA;IACb,+BAAmB,CAAA;IACnB,iCAAqB,CAAA;IACrB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,uBAAW,CAAA;IACX,6CAAiC,CAAA;AAClC,CAAC,EARW,QAAQ,wBAAR,QAAQ,QAQnB;AAED,IAAY,OAQX;AARD,WAAY,OAAO;IAClB,yCAAU,CAAA;IACV,yCAAU,CAAA;IACV,2CAAW,CAAA;IACX,+CAAa,CAAA;IACb,6CAAY,CAAA;IACZ,yCAAU,CAAA;IACV,6CAAY,CAAA;AACb,CAAC,EARW,OAAO,uBAAP,OAAO,QAQlB;AAED,IAAY,UAIX;AAJD,WAAY,UAAU;IACrB,2BAAa,CAAA;IACb,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;AACtB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACpB,sCAAyB,CAAA;IACzB,4BAAe,CAAA;AAChB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACxB,8BAAa,CAAA;IACb,8BAAa,CAAA;AACd,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,IAAY,aAIX;AAJD,WAAY,aAAa;IACxB,8BAAa,CAAA;IACb,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;AAClB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAED,IAAY,YAIX;AAJD,WAAY,YAAY;IACvB,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,+BAAe,CAAA;AAChB,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAED,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC9B,0CAAmB,CAAA;IACnB,wCAAiB,CAAA;AAClB,CAAC,EAHW,mBAAmB,mCAAnB,mBAAmB,QAG9B;AAED,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC5B,kCAAa,CAAA;IACb,oCAAe,CAAA;AAChB,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B","sourcesContent":["export enum Status {\r\n\tACTIVE = 'active',\r\n\tINACTIVE = 'inactive',\r\n}\r\n\r\nexport enum ItemType {\r\n\tFOOD = 'food',\r\n\tGROCERY = 'grocery',\r\n\tPHARMACY = 'pharmacy',\r\n\tCOFFEE = 'coffee',\r\n\tFLOWER = 'flower',\r\n\tPET = 'pet',\r\n\tHEALTHY_CORNER = 'healthy_corner',\r\n}\r\n\r\nexport enum WeekDay {\r\n\tSunday = 0,\r\n\tMonday = 1,\r\n\tTuesday = 2,\r\n\tWednesday = 3,\r\n\tThursday = 4,\r\n\tFriday = 5,\r\n\tSaturday = 6,\r\n}\r\n\r\nexport enum WorkStatus {\r\n\tOPEN = 'open',\r\n\tCLOSED = 'closed',\r\n\tFULL_DAY = 'full_day',\r\n}\r\n\r\nexport enum ValueType {\r\n\tPERCENTAGE = 'percentage',\r\n\tFIXED = 'fixed',\r\n}\r\n\r\nexport enum PaymentMethod {\r\n\tCASH = 'cash',\r\n\tCARD = 'card',\r\n}\r\n\r\nexport enum PaymentStatus {\r\n\tPAID = 'paid',\r\n\tPENDING = 'pending',\r\n\tFAILED = 'failed',\r\n}\r\n\r\nexport enum PaidCurrency {\r\n\tBASE = 'base',\r\n\tSECONDARY = 'secondary',\r\n\tMIXED = 'mixed',\r\n}\r\n\r\nexport enum SubscriptionPackage {\r\n\tMONTHLY = 'monthly',\r\n\tYEARLY = 'yearly',\r\n}\r\n\r\nexport enum RatingAccountType {\r\n\tSHOP = 'shop',\r\n\tRIDER = 'rider',\r\n}"]}
1
+ {"version":3,"file":"enum.js","sourceRoot":"/","sources":["utilities/enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,+BAAqB,CAAA;AACvB,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB;AAED,IAAY,QAQX;AARD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,+BAAmB,CAAA;IACnB,iCAAqB,CAAA;IACrB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,uBAAW,CAAA;IACX,6CAAiC,CAAA;AACnC,CAAC,EARW,QAAQ,wBAAR,QAAQ,QAQnB;AAED,IAAY,OAQX;AARD,WAAY,OAAO;IACjB,yCAAU,CAAA;IACV,yCAAU,CAAA;IACV,2CAAW,CAAA;IACX,+CAAa,CAAA;IACb,6CAAY,CAAA;IACZ,yCAAU,CAAA;IACV,6CAAY,CAAA;AACd,CAAC,EARW,OAAO,uBAAP,OAAO,QAQlB;AAED,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;AACvB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAED,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,sCAA0B,CAAA;IAC1B,0CAA8B,CAAA;AAChC,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,sCAAyB,CAAA;IACzB,4BAAe,CAAA;AACjB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,8BAAa,CAAA;AACf,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAED,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,+BAAe,CAAA;AACjB,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAED,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,wCAAiB,CAAA;AACnB,CAAC,EAHW,mBAAmB,mCAAnB,mBAAmB,QAG9B;AAED,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,kCAAa,CAAA;IACb,oCAAe,CAAA;AACjB,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,sCAAmB,CAAA;AACrB,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B","sourcesContent":["export enum Status {\r\n ACTIVE = \"active\",\r\n INACTIVE = \"inactive\"\r\n}\r\n\r\nexport enum ItemType {\r\n FOOD = \"food\",\r\n GROCERY = \"grocery\",\r\n PHARMACY = \"pharmacy\",\r\n COFFEE = \"coffee\",\r\n FLOWER = \"flower\",\r\n PET = \"pet\",\r\n HEALTHY_CORNER = \"healthy_corner\"\r\n}\r\n\r\nexport enum WeekDay {\r\n Sunday = 0,\r\n Monday = 1,\r\n Tuesday = 2,\r\n Wednesday = 3,\r\n Thursday = 4,\r\n Friday = 5,\r\n Saturday = 6\r\n}\r\n\r\nexport enum WorkStatus {\r\n OPEN = \"open\",\r\n CLOSED = \"closed\",\r\n FULL_DAY = \"full_day\"\r\n}\r\n\r\nexport enum HolidayWorkStatus {\r\n CLOSED = WorkStatus.CLOSED,\r\n FULL_DAY = WorkStatus.FULL_DAY\r\n}\r\n\r\nexport enum ValueType {\r\n PERCENTAGE = \"percentage\",\r\n FIXED = \"fixed\"\r\n}\r\n\r\nexport enum PaymentMethod {\r\n CASH = \"cash\",\r\n CARD = \"card\"\r\n}\r\n\r\nexport enum PaymentStatus {\r\n PAID = \"paid\",\r\n PENDING = \"pending\",\r\n FAILED = \"failed\"\r\n}\r\n\r\nexport enum PaidCurrency {\r\n BASE = \"base\",\r\n SECONDARY = \"secondary\",\r\n MIXED = \"mixed\"\r\n}\r\n\r\nexport enum SubscriptionPackage {\r\n MONTHLY = \"monthly\",\r\n YEARLY = \"yearly\"\r\n}\r\n\r\nexport enum RatingAccountType {\r\n SHOP = \"shop\",\r\n RIDER = \"rider\"\r\n}\r\n\r\nexport enum GeoLocationType {\r\n POINT = \"point\",\r\n POLYGON = \"polygon\"\r\n}\r\n"]}