@lyxa.ai/core 1.0.9 → 1.0.10

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.
@@ -0,0 +1,19 @@
1
+ import { GeoLocationType } from "../../../utilities/enum";
2
+ export declare class Address {
3
+ address: string;
4
+ description?: string;
5
+ city: string;
6
+ state: string;
7
+ country: string;
8
+ geoLocationType: GeoLocationType;
9
+ coordinates: number[];
10
+ latitude: number;
11
+ longitude: number;
12
+ }
13
+ export declare class UserAddress extends Address {
14
+ addressLabel: string;
15
+ apartment: string;
16
+ buildingName: string;
17
+ deliveryOption?: string;
18
+ instructions?: string;
19
+ }
@@ -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":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,kDAA0D;AAE1D,MAAa,OAAO;IAEX,OAAO,CAAU;IAGjB,WAAW,CAAU;IAGrB,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,OAAO,CAAU;IAGjB,eAAe,CAAmB;IAGlC,WAAW,CAAY;IAGvB,QAAQ,CAAU;IAGlB,SAAS,CAAU;CAC3B;AA3BD,0BA2BC;AAzBQ;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wCACf;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACK;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sCACjB;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wCACf;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAe,EAAE,OAAO,EAAE,sBAAe,CAAC,KAAK,EAAE,CAAC;;gDACrC;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;;4CACjB;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCACd;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0CACb;AAG5B,MAAa,WAAY,SAAQ,OAAO;IAE/B,YAAY,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,QA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";\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"]}
@@ -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,CAA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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,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,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"]}
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { GeoLocationType, HolidayWorkStatus, WeekDay, WorkStatus } from "../enum";
2
3
  export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
3
4
  limit: z.ZodDefault<z.ZodNumber>;
4
5
  skip: z.ZodDefault<z.ZodNumber>;
@@ -24,42 +25,238 @@ export declare const FilterSchema: z.ZodOptional<z.ZodObject<{
24
25
  export type FilterDTO = z.infer<typeof FilterSchema>;
25
26
  export declare const StringSchema: z.ZodString;
26
27
  export declare const AddressSchema: z.ZodObject<{
27
- address: z.ZodOptional<z.ZodString>;
28
- addressDescription: z.ZodOptional<z.ZodString>;
29
- locationType: z.ZodDefault<z.ZodEnum<["Point", "Polygon"]>>;
30
- coordinates: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
31
- latitude: z.ZodOptional<z.ZodNumber>;
32
- longitude: z.ZodOptional<z.ZodNumber>;
33
- country: z.ZodOptional<z.ZodString>;
34
- state: z.ZodOptional<z.ZodString>;
35
- city: z.ZodOptional<z.ZodString>;
36
- postCode: z.ZodOptional<z.ZodString>;
37
- note: z.ZodOptional<z.ZodString>;
38
- placeId: z.ZodOptional<z.ZodString>;
28
+ address: z.ZodString;
29
+ description: z.ZodOptional<z.ZodString>;
30
+ city: z.ZodString;
31
+ state: z.ZodString;
32
+ country: z.ZodString;
33
+ geoLocationType: z.ZodDefault<z.ZodNativeEnum<typeof GeoLocationType>>;
34
+ coordinates: z.ZodArray<z.ZodNumber, "many">;
35
+ latitude: z.ZodNumber;
36
+ longitude: z.ZodNumber;
39
37
  }, "strip", z.ZodTypeAny, {
40
- locationType: "Point" | "Polygon";
41
- coordinates: [number, number];
42
- state?: string | undefined;
43
- address?: string | undefined;
44
- country?: string | undefined;
45
- addressDescription?: string | undefined;
46
- latitude?: number | undefined;
47
- longitude?: number | undefined;
48
- city?: string | undefined;
49
- postCode?: string | undefined;
50
- note?: string | undefined;
51
- placeId?: string | undefined;
38
+ state: string;
39
+ address: string;
40
+ country: string;
41
+ city: string;
42
+ geoLocationType: GeoLocationType;
43
+ coordinates: number[];
44
+ latitude: number;
45
+ longitude: number;
46
+ description?: string | undefined;
52
47
  }, {
53
- coordinates: [number, number];
54
- state?: string | undefined;
55
- address?: string | undefined;
56
- country?: string | undefined;
57
- locationType?: "Point" | "Polygon" | undefined;
58
- addressDescription?: string | undefined;
59
- latitude?: number | undefined;
60
- longitude?: number | undefined;
61
- city?: string | undefined;
62
- postCode?: string | undefined;
63
- note?: string | undefined;
64
- placeId?: string | undefined;
48
+ state: string;
49
+ address: string;
50
+ country: string;
51
+ city: string;
52
+ coordinates: number[];
53
+ latitude: number;
54
+ longitude: number;
55
+ description?: string | undefined;
56
+ geoLocationType?: GeoLocationType | undefined;
57
+ }>;
58
+ export declare const UserAddressSchema: z.ZodObject<z.objectUtil.extendShape<{
59
+ address: z.ZodString;
60
+ description: z.ZodOptional<z.ZodString>;
61
+ city: z.ZodString;
62
+ state: z.ZodString;
63
+ country: z.ZodString;
64
+ geoLocationType: z.ZodDefault<z.ZodNativeEnum<typeof GeoLocationType>>;
65
+ coordinates: z.ZodArray<z.ZodNumber, "many">;
66
+ latitude: z.ZodNumber;
67
+ longitude: z.ZodNumber;
68
+ }, {
69
+ addressLabel: z.ZodString;
70
+ apartment: z.ZodString;
71
+ buildingName: z.ZodString;
72
+ deliveryOption: z.ZodOptional<z.ZodString>;
73
+ instructions: z.ZodOptional<z.ZodString>;
74
+ }>, "strip", z.ZodTypeAny, {
75
+ state: string;
76
+ address: string;
77
+ country: string;
78
+ city: string;
79
+ geoLocationType: GeoLocationType;
80
+ coordinates: number[];
81
+ latitude: number;
82
+ longitude: number;
83
+ addressLabel: string;
84
+ apartment: string;
85
+ buildingName: string;
86
+ description?: string | undefined;
87
+ deliveryOption?: string | undefined;
88
+ instructions?: string | undefined;
89
+ }, {
90
+ state: string;
91
+ address: string;
92
+ country: string;
93
+ city: string;
94
+ coordinates: number[];
95
+ latitude: number;
96
+ longitude: number;
97
+ addressLabel: string;
98
+ apartment: string;
99
+ buildingName: string;
100
+ description?: string | undefined;
101
+ geoLocationType?: GeoLocationType | undefined;
102
+ deliveryOption?: string | undefined;
103
+ instructions?: string | undefined;
104
+ }>;
105
+ export declare const DurationSchema: z.ZodObject<{
106
+ start: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
107
+ end: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ start: Date;
110
+ end?: Date | undefined;
111
+ }, {
112
+ start: string | Date;
113
+ end?: string | Date | undefined;
114
+ }>;
115
+ export declare const NormalHourSchema: z.ZodObject<{
116
+ day: z.ZodNativeEnum<typeof WeekDay>;
117
+ status: z.ZodNativeEnum<typeof WorkStatus>;
118
+ openingHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
119
+ start: z.ZodString;
120
+ end: z.ZodString;
121
+ }, "strip", z.ZodTypeAny, {
122
+ end: string;
123
+ start: string;
124
+ }, {
125
+ end: string;
126
+ start: string;
127
+ }>, "many">>;
128
+ }, "strip", z.ZodTypeAny, {
129
+ status: WorkStatus;
130
+ day: WeekDay;
131
+ openingHours: {
132
+ end: string;
133
+ start: string;
134
+ }[];
135
+ }, {
136
+ status: WorkStatus;
137
+ day: WeekDay;
138
+ openingHours?: {
139
+ end: string;
140
+ start: string;
141
+ }[] | undefined;
142
+ }>;
143
+ export declare const HolidayHourSchema: z.ZodObject<{
144
+ date: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
145
+ status: z.ZodNativeEnum<typeof HolidayWorkStatus>;
146
+ closingHour: z.ZodObject<{
147
+ start: z.ZodString;
148
+ end: z.ZodString;
149
+ }, "strip", z.ZodTypeAny, {
150
+ end: string;
151
+ start: string;
152
+ }, {
153
+ end: string;
154
+ start: string;
155
+ }>;
156
+ }, "strip", z.ZodTypeAny, {
157
+ status: HolidayWorkStatus;
158
+ date: Date;
159
+ closingHour: {
160
+ end: string;
161
+ start: string;
162
+ };
163
+ }, {
164
+ status: HolidayWorkStatus;
165
+ date: string | Date;
166
+ closingHour: {
167
+ end: string;
168
+ start: string;
169
+ };
170
+ }>;
171
+ export declare const WrokHourSettingSchema: z.ZodObject<{
172
+ normalHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
173
+ day: z.ZodNativeEnum<typeof WeekDay>;
174
+ status: z.ZodNativeEnum<typeof WorkStatus>;
175
+ openingHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
176
+ start: z.ZodString;
177
+ end: z.ZodString;
178
+ }, "strip", z.ZodTypeAny, {
179
+ end: string;
180
+ start: string;
181
+ }, {
182
+ end: string;
183
+ start: string;
184
+ }>, "many">>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ status: WorkStatus;
187
+ day: WeekDay;
188
+ openingHours: {
189
+ end: string;
190
+ start: string;
191
+ }[];
192
+ }, {
193
+ status: WorkStatus;
194
+ day: WeekDay;
195
+ openingHours?: {
196
+ end: string;
197
+ start: string;
198
+ }[] | undefined;
199
+ }>, "many">>;
200
+ holidayHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
201
+ date: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
202
+ status: z.ZodNativeEnum<typeof HolidayWorkStatus>;
203
+ closingHour: z.ZodObject<{
204
+ start: z.ZodString;
205
+ end: z.ZodString;
206
+ }, "strip", z.ZodTypeAny, {
207
+ end: string;
208
+ start: string;
209
+ }, {
210
+ end: string;
211
+ start: string;
212
+ }>;
213
+ }, "strip", z.ZodTypeAny, {
214
+ status: HolidayWorkStatus;
215
+ date: Date;
216
+ closingHour: {
217
+ end: string;
218
+ start: string;
219
+ };
220
+ }, {
221
+ status: HolidayWorkStatus;
222
+ date: string | Date;
223
+ closingHour: {
224
+ end: string;
225
+ start: string;
226
+ };
227
+ }>, "many">>;
228
+ }, "strip", z.ZodTypeAny, {
229
+ normalHours: {
230
+ status: WorkStatus;
231
+ day: WeekDay;
232
+ openingHours: {
233
+ end: string;
234
+ start: string;
235
+ }[];
236
+ }[];
237
+ holidayHours: {
238
+ status: HolidayWorkStatus;
239
+ date: Date;
240
+ closingHour: {
241
+ end: string;
242
+ start: string;
243
+ };
244
+ }[];
245
+ }, {
246
+ normalHours?: {
247
+ status: WorkStatus;
248
+ day: WeekDay;
249
+ openingHours?: {
250
+ end: string;
251
+ start: string;
252
+ }[] | undefined;
253
+ }[] | undefined;
254
+ holidayHours?: {
255
+ status: HolidayWorkStatus;
256
+ date: string | Date;
257
+ closingHour: {
258
+ end: string;
259
+ start: string;
260
+ };
261
+ }[] | undefined;
65
262
  }>;
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AddressSchema = exports.StringSchema = exports.FilterSchema = void 0;
3
+ exports.WrokHourSettingSchema = exports.HolidayHourSchema = exports.NormalHourSchema = exports.DurationSchema = exports.UserAddressSchema = exports.AddressSchema = exports.StringSchema = exports.FilterSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const global_validation_1 = require("./global-validation");
6
+ const enum_1 = require("../enum");
5
7
  const SortOrderSchema = zod_1.z.union([
6
8
  zod_1.z.literal(1),
7
9
  zod_1.z.literal(-1),
8
10
  zod_1.z.literal("asc"),
9
- zod_1.z.literal("desc"),
11
+ zod_1.z.literal("desc")
10
12
  ]);
11
13
  const MongoQuerySchema = zod_1.z.lazy(() => zod_1.z.record(zod_1.z.union([zod_1.z.any(), MongoOperatorsSchema])));
12
14
  const MongoOperatorsSchema = zod_1.z.object({
@@ -23,7 +25,7 @@ const MongoOperatorsSchema = zod_1.z.object({
23
25
  $and: zod_1.z.array(MongoQuerySchema).optional(),
24
26
  $or: zod_1.z.array(MongoQuerySchema).optional(),
25
27
  $not: MongoQuerySchema.optional(),
26
- $nor: zod_1.z.array(MongoQuerySchema).optional(),
28
+ $nor: zod_1.z.array(MongoQuerySchema).optional()
27
29
  });
28
30
  exports.FilterSchema = zod_1.z
29
31
  .object({
@@ -36,7 +38,7 @@ exports.FilterSchema = zod_1.z
36
38
  sort: zod_1.z.record(zod_1.z.string(), SortOrderSchema).optional(),
37
39
  query: MongoQuerySchema.optional(),
38
40
  select: zod_1.z.array(zod_1.z.string()).optional(),
39
- populate: zod_1.z.array(zod_1.z.string()).optional(),
41
+ populate: zod_1.z.array(zod_1.z.string()).optional()
40
42
  })
41
43
  .optional();
42
44
  exports.StringSchema = zod_1.z
@@ -44,17 +46,43 @@ exports.StringSchema = zod_1.z
44
46
  .min(1, "String cannot be empty")
45
47
  .max(255, "String is too long");
46
48
  exports.AddressSchema = zod_1.z.object({
47
- address: zod_1.z.string().optional(),
48
- addressDescription: zod_1.z.string().optional(),
49
- locationType: zod_1.z.enum(["Point", "Polygon"]).default("Point"),
50
- coordinates: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]),
51
- latitude: zod_1.z.number().optional(),
52
- longitude: zod_1.z.number().optional(),
53
- country: zod_1.z.string().optional(),
54
- state: zod_1.z.string().optional(),
55
- city: zod_1.z.string().optional(),
56
- postCode: zod_1.z.string().optional(),
57
- note: zod_1.z.string().optional(),
58
- placeId: zod_1.z.string().optional(),
49
+ address: global_validation_1.ZodValidation.string("Address"),
50
+ description: global_validation_1.ZodValidation.string("Description").optional(),
51
+ city: global_validation_1.ZodValidation.string("City"),
52
+ state: global_validation_1.ZodValidation.string("State"),
53
+ country: global_validation_1.ZodValidation.string("Country"),
54
+ geoLocationType: global_validation_1.ZodValidation.enumType(enum_1.GeoLocationType, "GeoLocationType").default(enum_1.GeoLocationType.POINT),
55
+ coordinates: global_validation_1.ZodValidation.array(global_validation_1.ZodValidation.number("Coordinate"), "Coordinates", 2, 2),
56
+ latitude: global_validation_1.ZodValidation.number("Latitude"),
57
+ longitude: global_validation_1.ZodValidation.number("Longitude")
58
+ });
59
+ exports.UserAddressSchema = exports.AddressSchema.extend({
60
+ addressLabel: global_validation_1.ZodValidation.string("Address Label"),
61
+ apartment: global_validation_1.ZodValidation.string("Apartment"),
62
+ buildingName: global_validation_1.ZodValidation.string("Building Name"),
63
+ deliveryOption: global_validation_1.ZodValidation.string("Delivery Option").optional(),
64
+ instructions: global_validation_1.ZodValidation.string("Instructions").optional()
65
+ });
66
+ exports.DurationSchema = zod_1.z.object({
67
+ start: global_validation_1.ZodValidation.date("Start"),
68
+ end: global_validation_1.ZodValidation.date("End").optional()
69
+ });
70
+ const StartEndTimeSchema = zod_1.z.object({
71
+ start: global_validation_1.ZodValidation.string("Start"),
72
+ end: global_validation_1.ZodValidation.string("End")
73
+ });
74
+ exports.NormalHourSchema = zod_1.z.object({
75
+ day: global_validation_1.ZodValidation.enumType(enum_1.WeekDay, "Day"),
76
+ status: global_validation_1.ZodValidation.enumType(enum_1.WorkStatus, "Status"),
77
+ openingHours: global_validation_1.ZodValidation.array(StartEndTimeSchema).default([])
78
+ });
79
+ exports.HolidayHourSchema = zod_1.z.object({
80
+ date: global_validation_1.ZodValidation.date("Date"),
81
+ status: global_validation_1.ZodValidation.enumType(enum_1.HolidayWorkStatus, "Status"),
82
+ closingHour: StartEndTimeSchema
83
+ });
84
+ exports.WrokHourSettingSchema = zod_1.z.object({
85
+ normalHours: global_validation_1.ZodValidation.array(exports.NormalHourSchema).default([]),
86
+ holidayHours: global_validation_1.ZodValidation.array(exports.HolidayHourSchema).default([])
59
87
  });
60
88
  //# sourceMappingURL=common-validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"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,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,kBAAkB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzC,YAAY,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IAC3D,WAAW,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\r\n\r\n/**\r\n * Define allowed MongoDB sort orders\r\n */\r\nconst SortOrderSchema = z.union([\r\n z.literal(1),\r\n z.literal(-1),\r\n z.literal(\"asc\"),\r\n z.literal(\"desc\"),\r\n]);\r\n\r\n/**\r\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\r\n */\r\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\r\n z.record(z.union([z.any(), MongoOperatorsSchema]))\r\n);\r\n\r\n/**\r\n * Define allowed MongoDB query operators\r\n */\r\nconst MongoOperatorsSchema = z.object({\r\n $eq: z.any().optional(),\r\n $ne: z.any().optional(),\r\n $gt: z.any().optional(),\r\n $gte: z.any().optional(),\r\n $lt: z.any().optional(),\r\n $lte: z.any().optional(),\r\n $in: z.array(z.any()).optional(),\r\n $nin: z.array(z.any()).optional(),\r\n $exists: z.boolean().optional(),\r\n $regex: z.string().optional(),\r\n $and: z.array(MongoQuerySchema).optional(),\r\n $or: z.array(MongoQuerySchema).optional(),\r\n $not: MongoQuerySchema.optional(),\r\n $nor: z.array(MongoQuerySchema).optional(),\r\n});\r\n\r\n/**\r\n * Define the filter schema using MongoQuerySchema\r\n */\r\nexport const FilterSchema = z\r\n .object({\r\n limit: z\r\n .number()\r\n .min(1, { message: \"Limit must be greater than 0.\" })\r\n .max(100, { message: \"Limit cannot exceed 100.\" })\r\n .default(10),\r\n skip: z.number().min(0, { message: \"Skip cannot be negative.\" }).default(0),\r\n sort: z.record(z.string(), SortOrderSchema).optional(),\r\n query: MongoQuerySchema.optional(),\r\n select: z.array(z.string()).optional(),\r\n populate: z.array(z.string()).optional(),\r\n })\r\n .optional();\r\n\r\n/**\r\n * Infer TypeScript type from Zod schema\r\n */\r\nexport type FilterDTO = z.infer<typeof FilterSchema>;\r\n\r\n/**\r\n * Define String schema\r\n */\r\nexport const StringSchema = z\r\n .string()\r\n .min(1, \"String cannot be empty\")\r\n .max(255, \"String is too long\");\r\n\r\n/**\r\n * Common address validation schema that can be reused across models.\r\n * Provides validation for address-related fields.\r\n *\r\n * @example\r\n * ```typescript\r\n * const userSchema = z.object({\r\n * name: z.string(),\r\n * address: AddressSchema\r\n * });\r\n * ```\r\n */\r\nexport const AddressSchema = z.object({\r\n address: z.string().optional(),\r\n addressDescription: z.string().optional(),\r\n locationType: z.enum([\"Point\", \"Polygon\"]).default(\"Point\"),\r\n coordinates: z.tuple([z.number(), z.number()]),\r\n latitude: z.number().optional(),\r\n longitude: z.number().optional(),\r\n country: z.string().optional(),\r\n state: z.string().optional(),\r\n city: z.string().optional(),\r\n postCode: z.string().optional(),\r\n note: z.string().optional(),\r\n placeId: z.string().optional(),\r\n});\r\n"]}
1
+ {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAoD;AACpD,kCAKiB;AAKjB,MAAM,eAAe,GAAG,OAAC,CAAC,KAAK,CAAC;IAC9B,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACZ,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACb,OAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAChB,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC;CAClB,CAAC,CAAC;AAKH,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACnE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,CACnD,CAAC;AAKF,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACxB,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvB,IAAI,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACxB,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;IAChC,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;IACjC,OAAO,EAAE,OAAC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K,EAAE,iCAAa,CAAC,IAAI,CAAC,OAAO,CAAC;IAClC,GAAG,EAAE,iCAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAC;AAcH,MAAM,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IAClC,KAAK,EAAE,iCAAa,CAAC,MAAM,CAAC,OAAO,CAAC;IACpC,GAAG,EAAE,iCAAa,CAAC,MAAM,CAAC,KAAK,CAAC;CACjC,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,GAAG,EAAE,iCAAa,CAAC,QAAQ,CAAC,cAAO,EAAE,KAAK,CAAC;IAC3C,MAAM,EAAE,iCAAa,CAAC,QAAQ,CAAC,iBAAU,EAAE,QAAQ,CAAC;IACpD,YAAY,EAAE,iCAAa,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAClE,CAAC,CAAC;AAEU,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,iCAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IAChC,MAAM,EAAE,iCAAa,CAAC,QAAQ,CAAC,wBAAiB,EAAE,QAAQ,CAAC;IAC3D,WAAW,EAAE,kBAAkB;CAChC,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,WAAW,EAAE,iCAAa,CAAC,KAAK,CAAC,wBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9D,YAAY,EAAE,iCAAa,CAAC,KAAK,CAAC,yBAAiB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CACjE,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\r\nimport { ZodValidation } from \"./global-validation\";\r\nimport {\r\n GeoLocationType,\r\n HolidayWorkStatus,\r\n WeekDay,\r\n WorkStatus\r\n} from \"../enum\";\r\n\r\n/**\r\n * Define allowed MongoDB sort orders\r\n */\r\nconst SortOrderSchema = z.union([\r\n z.literal(1),\r\n z.literal(-1),\r\n z.literal(\"asc\"),\r\n z.literal(\"desc\")\r\n]);\r\n\r\n/**\r\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\r\n */\r\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\r\n z.record(z.union([z.any(), MongoOperatorsSchema]))\r\n);\r\n\r\n/**\r\n * Define allowed MongoDB query operators\r\n */\r\nconst MongoOperatorsSchema = z.object({\r\n $eq: z.any().optional(),\r\n $ne: z.any().optional(),\r\n $gt: z.any().optional(),\r\n $gte: z.any().optional(),\r\n $lt: z.any().optional(),\r\n $lte: z.any().optional(),\r\n $in: z.array(z.any()).optional(),\r\n $nin: z.array(z.any()).optional(),\r\n $exists: z.boolean().optional(),\r\n $regex: z.string().optional(),\r\n $and: z.array(MongoQuerySchema).optional(),\r\n $or: z.array(MongoQuerySchema).optional(),\r\n $not: MongoQuerySchema.optional(),\r\n $nor: z.array(MongoQuerySchema).optional()\r\n});\r\n\r\n/**\r\n * Define the filter schema using MongoQuerySchema\r\n */\r\nexport const FilterSchema = z\r\n .object({\r\n limit: z\r\n .number()\r\n .min(1, { message: \"Limit must be greater than 0.\" })\r\n .max(100, { message: \"Limit cannot exceed 100.\" })\r\n .default(10),\r\n skip: z.number().min(0, { message: \"Skip cannot be negative.\" }).default(0),\r\n sort: z.record(z.string(), SortOrderSchema).optional(),\r\n query: MongoQuerySchema.optional(),\r\n select: z.array(z.string()).optional(),\r\n populate: z.array(z.string()).optional()\r\n })\r\n .optional();\r\n\r\n/**\r\n * Infer TypeScript type from Zod schema\r\n */\r\nexport type FilterDTO = z.infer<typeof FilterSchema>;\r\n\r\n/**\r\n * Define String schema\r\n */\r\nexport const StringSchema = z\r\n .string()\r\n .min(1, \"String cannot be empty\")\r\n .max(255, \"String is too long\");\r\n\r\n/**\r\n * Common address validation schema that can be reused across models.\r\n * Provides validation for address-related fields.\r\n *\r\n * @example\r\n * ```typescript\r\n * const userSchema = z.object({\r\n * name: z.string(),\r\n * address: AddressSchema\r\n * });\r\n * ```\r\n */\r\nexport const AddressSchema = z.object({\r\n address: ZodValidation.string(\"Address\"),\r\n description: ZodValidation.string(\"Description\").optional(),\r\n city: ZodValidation.string(\"City\"),\r\n state: ZodValidation.string(\"State\"),\r\n country: ZodValidation.string(\"Country\"),\r\n geoLocationType: ZodValidation.enumType(\r\n GeoLocationType,\r\n \"GeoLocationType\"\r\n ).default(GeoLocationType.POINT),\r\n coordinates: ZodValidation.array(\r\n ZodValidation.number(\"Coordinate\"),\r\n \"Coordinates\",\r\n 2,\r\n 2\r\n ),\r\n latitude: ZodValidation.number(\"Latitude\"),\r\n longitude: ZodValidation.number(\"Longitude\")\r\n});\r\n\r\n/**\r\n * Common user address validation schema that can be reused across models.\r\n * Provides validation for address-related fields.\r\n *\r\n * @example\r\n * ```typescript\r\n * const userSchema = z.object({\r\n * name: z.string(),\r\n * address: UserAddressSchema\r\n * });\r\n * ```\r\n */\r\nexport const UserAddressSchema = AddressSchema.extend({\r\n addressLabel: ZodValidation.string(\"Address Label\"),\r\n apartment: ZodValidation.string(\"Apartment\"),\r\n buildingName: ZodValidation.string(\"Building Name\"),\r\n deliveryOption: ZodValidation.string(\"Delivery Option\").optional(),\r\n instructions: ZodValidation.string(\"Instructions\").optional()\r\n});\r\n\r\n/**\r\n * Common duration validation schema that can be reused across models.\r\n * Provides validation for duration fields.\r\n *\r\n * @example\r\n * ```typescript\r\n * const subscriptionSchema = z.object({\r\n * fee: z.number(),\r\n * duration: DurationSchema\r\n * });\r\n * ```\r\n */\r\nexport const DurationSchema = z.object({\r\n start: ZodValidation.date(\"Start\"),\r\n end: ZodValidation.date(\"End\").optional()\r\n});\r\n\r\n/**\r\n * Common Work Hour validation schema that can be reused across models.\r\n * Provides validation for wrokHourSetting fields.\r\n *\r\n * @example\r\n * ```typescript\r\n * const settingSchema = z.object({\r\n * vat: z.number(),\r\n * wrokHourSetting: WrokHourSettingSchema\r\n * });\r\n * ```\r\n */\r\nconst StartEndTimeSchema = z.object({\r\n start: ZodValidation.string(\"Start\"),\r\n end: ZodValidation.string(\"End\")\r\n});\r\n\r\nexport const NormalHourSchema = z.object({\r\n day: ZodValidation.enumType(WeekDay, \"Day\"),\r\n status: ZodValidation.enumType(WorkStatus, \"Status\"),\r\n openingHours: ZodValidation.array(StartEndTimeSchema).default([])\r\n});\r\n\r\nexport const HolidayHourSchema = z.object({\r\n date: ZodValidation.date(\"Date\"),\r\n status: ZodValidation.enumType(HolidayWorkStatus, \"Status\"),\r\n closingHour: StartEndTimeSchema\r\n});\r\n\r\nexport const WrokHourSettingSchema = z.object({\r\n normalHours: ZodValidation.array(NormalHourSchema).default([]),\r\n holidayHours: ZodValidation.array(HolidayHourSchema).default([])\r\n});\r\n"]}
@@ -1,5 +1,5 @@
1
- import { z } from 'zod';
2
- import { mongoose } from '@typegoose/typegoose';
1
+ import { z } from "zod";
2
+ import { mongoose } from "@typegoose/typegoose";
3
3
  export declare class ZodValidation {
4
4
  static objectId(field?: string): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
5
5
  static enumType<T extends z.EnumLike>(enumObj: T, field?: string): z.ZodNativeEnum<T>;
@@ -17,8 +17,7 @@ export declare class ZodValidation {
17
17
  static email(field?: string): z.ZodString;
18
18
  static url(field?: string): z.ZodString;
19
19
  static phoneNumber(field?: string): z.ZodString;
20
- static dateString(field?: string): z.ZodEffects<z.ZodString, string, string>;
21
- static date(field?: string, minDate?: Date, maxDate?: Date): z.ZodDate;
20
+ static date(field?: string, minDate?: Date, maxDate?: Date): z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
22
21
  static boolean(field?: string): z.ZodBoolean;
23
22
  static array<T extends z.ZodTypeAny>(schema: T, field?: string, minItems?: number, maxItems?: number): z.ZodArray<T, "many">;
24
23
  static timestamps(): {
@@ -5,26 +5,28 @@ exports.createSchemaBuilder = createSchemaBuilder;
5
5
  const zod_1 = require("zod");
6
6
  const typegoose_1 = require("@typegoose/typegoose");
7
7
  class ZodValidation {
8
- static objectId(field = 'Field') {
8
+ static objectId(field = "Field") {
9
9
  return zod_1.z.union([
10
10
  zod_1.z
11
11
  .string({ required_error: `${field} is required` })
12
- .refine(val => typegoose_1.mongoose.Types.ObjectId.isValid(val), {
13
- message: `${field} must be a valid ObjectID`,
12
+ .refine((val) => typegoose_1.mongoose.Types.ObjectId.isValid(val), {
13
+ message: `${field} must be a valid ObjectID`
14
+ })
15
+ .transform((val) => new typegoose_1.mongoose.Types.ObjectId(val)),
16
+ zod_1.z.instanceof(typegoose_1.mongoose.Types.ObjectId, {
17
+ message: `${field} must be a valid ObjectID`
14
18
  })
15
- .transform(val => new typegoose_1.mongoose.Types.ObjectId(val)),
16
- zod_1.z.instanceof(typegoose_1.mongoose.Types.ObjectId, { message: `${field} must be a valid ObjectID` }),
17
19
  ], { message: `${field} is required` });
18
20
  }
19
- static enumType(enumObj, field = 'Field') {
21
+ static enumType(enumObj, field = "Field") {
20
22
  return zod_1.z.nativeEnum(enumObj, {
21
- message: `${field} must be one of: ${Object.values(enumObj).join(', ')}`,
23
+ message: `${field} must be one of: ${Object.values(enumObj).join(", ")}`
22
24
  });
23
25
  }
24
- static number(field = 'Field', min, max, options) {
26
+ static number(field = "Field", min, max, options) {
25
27
  let schema = zod_1.z.number({
26
28
  required_error: `${field} is required`,
27
- invalid_type_error: `${field} must be a number`,
29
+ invalid_type_error: `${field} must be a number`
28
30
  });
29
31
  if (min !== undefined) {
30
32
  schema = schema.gte(min, { message: `${field} must be at least ${min}` });
@@ -49,10 +51,10 @@ class ZodValidation {
49
51
  }
50
52
  return schema;
51
53
  }
52
- static string(field = 'Field', minLength, maxLength, regex) {
54
+ static string(field = "Field", minLength, maxLength, regex) {
53
55
  let schema = zod_1.z.string({
54
56
  required_error: `${field} is required`,
55
- invalid_type_error: `${field} must be a string`,
57
+ invalid_type_error: `${field} must be a string`
56
58
  });
57
59
  if (minLength !== undefined) {
58
60
  schema = schema.min(minLength, `${field} value length must be greater than or equal to ${minLength}`);
@@ -65,45 +67,49 @@ class ZodValidation {
65
67
  }
66
68
  return schema;
67
69
  }
68
- static email(field = 'Field') {
70
+ static email(field = "Field") {
69
71
  return zod_1.z
70
72
  .string({ required_error: `${field} is required` })
71
73
  .email(`${field} must be a valid email address`);
72
74
  }
73
- static url(field = 'Field') {
74
- return zod_1.z.string({ required_error: `${field} is required` }).url(`${field} must be a valid URL`);
75
+ static url(field = "Field") {
76
+ return zod_1.z
77
+ .string({ required_error: `${field} is required` })
78
+ .url(`${field} must be a valid URL`);
75
79
  }
76
- static phoneNumber(field = 'Field') {
80
+ static phoneNumber(field = "Field") {
77
81
  return zod_1.z
78
82
  .string({ required_error: `${field} is required` })
79
83
  .regex(/^[+]{1}(?:[0-9\-\\(\\)\\/.]\s?){6,15}[0-9]{1}$/, `${field} must be a valid phone number`);
80
84
  }
81
- static dateString(field = 'Field') {
82
- return zod_1.z.string({ required_error: `${field} is required` }).refine(val => !isNaN(Date.parse(val)), {
83
- message: `${field} must be a valid date format`,
84
- });
85
- }
86
- static date(field = 'Field', minDate, maxDate) {
87
- let schema = zod_1.z.date({
88
- required_error: `${field} is required`,
89
- invalid_type_error: `${field} must be a valid date`,
90
- });
91
- if (minDate !== undefined) {
92
- schema = schema.min(minDate, `${field} must be on or after ${minDate.toISOString()}`);
93
- }
94
- if (maxDate !== undefined) {
95
- schema = schema.max(maxDate, `${field} must be on or before ${maxDate.toISOString()}`);
96
- }
97
- return schema;
85
+ static date(field = "Field", minDate, maxDate) {
86
+ return zod_1.z
87
+ .union([
88
+ zod_1.z
89
+ .string({ required_error: `${field} is required` })
90
+ .refine((val) => {
91
+ const date = new Date(val);
92
+ return !isNaN(date.getTime());
93
+ }, `${field} must be a valid date`)
94
+ .transform((val) => new Date(val)),
95
+ zod_1.z.date({
96
+ required_error: `${field} is required`,
97
+ invalid_type_error: `${field} must be a valid date`
98
+ })
99
+ ], { message: `${field} is required` })
100
+ .refine((val) => minDate === undefined || val >= minDate, `${field} must be on or after ${minDate?.toISOString()}`)
101
+ .refine((val) => maxDate === undefined || val <= maxDate, `${field} must be on or before ${maxDate?.toISOString()}`);
98
102
  }
99
- static boolean(field = 'Field') {
103
+ static boolean(field = "Field") {
100
104
  return zod_1.z.boolean({
101
105
  required_error: `${field} is required`,
102
- invalid_type_error: `${field} must be a boolean`,
106
+ invalid_type_error: `${field} must be a boolean`
103
107
  });
104
108
  }
105
- static array(schema, field = 'Array', minItems, maxItems) {
106
- let arraySchema = zod_1.z.array(schema, { required_error: `${field} is required` });
109
+ static array(schema, field = "Array", minItems, maxItems) {
110
+ let arraySchema = zod_1.z.array(schema, {
111
+ required_error: `${field} is required`
112
+ });
107
113
  if (minItems === 1) {
108
114
  arraySchema = arraySchema.min(1, `${field} cannot be empty`);
109
115
  }
@@ -119,7 +125,7 @@ class ZodValidation {
119
125
  return {
120
126
  createdAt: zod_1.z.date().nullable().optional(),
121
127
  updatedAt: zod_1.z.date().nullable().optional(),
122
- deletedAt: zod_1.z.date().nullable().optional(),
128
+ deletedAt: zod_1.z.date().nullable().optional()
123
129
  };
124
130
  }
125
131
  static trackingFields() {
@@ -127,7 +133,7 @@ class ZodValidation {
127
133
  createdBy: ZodValidation.objectId().optional(),
128
134
  updatedBy: ZodValidation.objectId().optional(),
129
135
  deletedBy: ZodValidation.objectId().optional(),
130
- ...ZodValidation.timestamps(),
136
+ ...ZodValidation.timestamps()
131
137
  };
132
138
  }
133
139
  }
@@ -142,13 +148,13 @@ class SchemaBuilder {
142
148
  if (includeTracking) {
143
149
  this.baseSchema = zod_1.z.object({
144
150
  ...baseFields,
145
- ...ZodValidation.trackingFields(),
151
+ ...ZodValidation.trackingFields()
146
152
  });
147
153
  }
148
154
  else if (includeTimestamps) {
149
155
  this.baseSchema = zod_1.z.object({
150
156
  ...baseFields,
151
- ...ZodValidation.timestamps(),
157
+ ...ZodValidation.timestamps()
152
158
  });
153
159
  }
154
160
  else {
@@ -160,7 +166,7 @@ class SchemaBuilder {
160
166
  }
161
167
  getEntitySchema() {
162
168
  return this.baseSchema.extend({
163
- _id: ZodValidation.objectId(),
169
+ _id: ZodValidation.objectId()
164
170
  });
165
171
  }
166
172
  getIdSchema() {
@@ -185,7 +191,7 @@ class SchemaBuilder {
185
191
  BaseSchema: this.getBaseSchema(),
186
192
  EntitySchema: this.getEntitySchema(),
187
193
  IdSchema: this.getIdSchema(),
188
- UpdateSchema: this.getUpdateSchema(excludeFromUpdate),
194
+ UpdateSchema: this.getUpdateSchema(excludeFromUpdate)
189
195
  };
190
196
  }
191
197
  }
@@ -1 +1 @@
1
- {"version":3,"file":"global-validation.js","sourceRoot":"/","sources":["utilities/validation/global-validation.ts"],"names":[],"mappings":";;;AA4nBA,kDAMC;AAloBD,6BAAwB;AACxB,oDAAgD;AAehD,MAAa,aAAa;IAczB,MAAM,CAAC,QAAQ,CAAC,QAAgB,OAAO;QACtC,OAAO,OAAC,CAAC,KAAK,CACb;YACC,OAAC;iBACC,MAAM,CAAC,EAAE,cAAc,EAAE,GAAG,KAAK,cAAc,EAAE,CAAC;iBAClD,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACpD,OAAO,EAAE,GAAG,KAAK,2BAA2B;aAC5C,CAAC;iBACD,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACpD,OAAC,CAAC,UAAU,CAAC,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,GAAG,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EAAE,eAAe,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import { z } from 'zod';\r\nimport { mongoose } from '@typegoose/typegoose';\r\n\r\n/**\r\n * Enhanced validation utilities for creating robust Zod schemas.\r\n * This class provides a collection of static methods to create common validation patterns.\r\n *\r\n * @example\r\n * ```typescript\r\n * const userSchema = z.object({\r\n * username: ZodValidation.requiredString(\"Username is required\"),\r\n * email: ZodValidation.email(),\r\n * role: ZodValidation.enumType(UserRole)\r\n * });\r\n * ```\r\n */\r\nexport class ZodValidation {\r\n\t/**\r\n\t * Creates a union type that accepts both string ObjectId and mongoose ObjectId instance.\r\n\t * This is useful when dealing with both raw string IDs and Mongoose ObjectId instances.\r\n\t *\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @returns A Zod union schema that accepts both string and ObjectId\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const idSchema = ZodValidation.objectIdUnion();\r\n\t * // Accepts \"507f1f77bcf86cd799439011\" or new mongoose.Types.ObjectId(\"507f1f77bcf86cd799439011\")\r\n\t * ```\r\n\t */\r\n\tstatic objectId(field: string = 'Field') {\r\n\t\treturn z.union(\r\n\t\t\t[\r\n\t\t\t\tz\r\n\t\t\t\t\t.string({ required_error: `${field} is required` })\r\n\t\t\t\t\t.refine(val => mongoose.Types.ObjectId.isValid(val), {\r\n\t\t\t\t\t\tmessage: `${field} must be a valid ObjectID`,\r\n\t\t\t\t\t})\r\n\t\t\t\t\t.transform(val => new mongoose.Types.ObjectId(val)),\r\n\t\t\t\tz.instanceof(mongoose.Types.ObjectId, { message: `${field} must be a valid ObjectID` }),\r\n\t\t\t],\r\n\t\t\t{ message: `${field} is required` }\r\n\t\t);\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an enum validation with custom error message.\r\n\t * This validates that a value is one of the values defined in the enum.\r\n\t *\r\n\t * @template T - Type of the enum\r\n\t * @param enumObj - The enum object to validate against\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @returns A Zod schema that validates against the provided enum\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * enum UserRole { ADMIN = \"admin\", USER = \"user\" }\r\n\t * const roleSchema = ZodValidation.enumType(UserRole, \"Invalid user role\");\r\n\t * ```\r\n\t */\r\n\tstatic enumType<T extends z.EnumLike>(enumObj: T, field: string = 'Field') {\r\n\t\treturn z.nativeEnum(enumObj, {\r\n\t\t\tmessage: `${field} must be one of: ${Object.values(enumObj).join(', ')}`,\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a required number validation with a minimum length.\r\n\t * The number is also trimmed to remove leading/trailing whitespace.\r\n\t *\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @param min - Minimum number (optional)\r\n\t * @param max - MAximum number (optional)\r\n\t * @param options - options (optional)\r\n\t * @returns A Zod schema that validates numbers with minimum length\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const nameSchema = ZodValidation.Number(\"Price\");\r\n\t * ```\r\n\t */\r\n\tstatic number(\r\n\t\tfield: string = 'Field',\r\n\t\tmin?: number,\r\n\t\tmax?: number,\r\n\t\toptions?: {\r\n\t\t\tisInt?: boolean;\r\n\t\t\tisPositive?: boolean;\r\n\t\t\tisNonpositive?: boolean;\r\n\t\t\tisNegative?: boolean;\r\n\t\t\tisNonnegative?: boolean;\r\n\t\t}\r\n\t) {\r\n\t\tlet schema = z.number({\r\n\t\t\trequired_error: `${field} is required`,\r\n\t\t\tinvalid_type_error: `${field} must be a number`,\r\n\t\t});\r\n\t\r\n\t\t// Range validation\r\n\t\tif (min !== undefined) {\r\n\t\t\tschema = schema.gte(min, { message: `${field} must be at least ${min}` });\r\n\t\t}\r\n\t\tif (max !== undefined) {\r\n\t\t\tschema = schema.lte(max, { message: `${field} must be at most ${max}` });\r\n\t\t}\r\n\t\r\n\t\t// Option validation\r\n\t\tif (options?.isInt) {\r\n\t\t\tschema = schema.int({ message: `${field} must be an integer` });\r\n\t\t}\r\n\t\tif (options?.isPositive) {\r\n\t\t\tschema = schema.positive({ message: `${field} must be positive` });\r\n\t\t}\r\n\t\tif (options?.isNonpositive) {\r\n\t\t\tschema = schema.nonpositive({ message: `${field} must be non-positive` });\r\n\t\t}\r\n\t\tif (options?.isNegative) {\r\n\t\t\tschema = schema.negative({ message: `${field} must be negative` });\r\n\t\t}\r\n\t\tif (options?.isNonnegative) {\r\n\t\t\tschema = schema.nonnegative({ message: `${field} must be non-negative` });\r\n\t\t}\r\n\t\r\n\t\treturn schema;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a required string validation with a minimum length.\r\n\t * The string is also trimmed to remove leading/trailing whitespace.\r\n\t *\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @param minLength - Minimum required length (optional)\r\n\t * @param maxLength - Maximum required length (optional)\r\n\t * @param regex - Regular erpression (optional) \r\n\t * @returns A Zod schema that validates strings with minimum length\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const nameSchema = ZodValidation.String(\"Name\");\r\n\t * ```\r\n\t */\r\n\tstatic string(\r\n\t\tfield: string = 'Field',\r\n\t\tminLength?: number,\r\n\t\tmaxLength?: number,\r\n\t\tregex?: { pattern: RegExp; message: string }\r\n\t) {\r\n\t\tlet schema = z.string({\r\n\t\t\trequired_error: `${field} is required`,\r\n\t\t\tinvalid_type_error: `${field} must be a string`,\r\n\t\t});\r\n\t\r\n\t\tif (minLength !== undefined) {\r\n\t\t\tschema = schema.min(minLength, `${field} value length must be greater than or equal to ${minLength}`);\r\n\t\t}\r\n\t\tif (maxLength !== undefined) {\r\n\t\t\tschema = schema.max(maxLength, `${field} value length must be less than or equal to ${maxLength}`);\r\n\t\t}\r\n\t\tif (regex !== undefined) {\r\n\t\t\tschema = schema.regex(regex.pattern, regex.message);\r\n\t\t}\r\n\t\r\n\t\treturn schema;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an email validation.\r\n\t * Validates that the string is a valid email address format.\r\n\t *\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @returns A Zod schema that validates email addresses\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const emailSchema = ZodValidation.email(\"Please enter a valid email\");\r\n\t * ```\r\n\t */\r\n\tstatic email(field: string = 'Field') {\r\n\t\treturn z\r\n\t\t\t.string({ required_error: `${field} is required` })\r\n\t\t\t.email(`${field} must be a valid email address`);\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a URL validation.\r\n\t * Validates that the string is a valid URL format.\r\n\t *\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @returns A Zod schema that validates URLs\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const websiteSchema = ZodValidation.url(\"Please enter a valid URL\");\r\n\t * ```\r\n\t */\r\n\tstatic url(field: string = 'Field') {\r\n\t\treturn z.string({ required_error: `${field} is required` }).url(`${field} must be a valid URL`);\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a phone number validation schema using a regex pattern for global phone numbers.\r\n\t *\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @returns A Zod schema that validates phone numbers\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const phoneSchema = ZodValidation.phoneNumber(\"Phone number\");\r\n\t * ```\r\n\t */\r\n\tstatic phoneNumber(field: string = 'Field') {\r\n\t\treturn z\r\n\t\t\t.string({ required_error: `${field} is required` })\r\n\t\t\t.regex(/^[+]{1}(?:[0-9\\-\\\\(\\\\)\\\\/.]\\s?){6,15}[0-9]{1}$/, `${field} must be a valid phone number`);\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a date string validation that ensures the input is a valid date.\r\n\t * Validates that the string can be parsed as a valid date.\r\n\t *\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @returns A Zod schema that validates date strings\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const birthDateSchema = ZodValidation.dateString(\"Please enter a valid date\");\r\n\t * ```\r\n\t */\r\n\tstatic dateString(field: string = 'Field') {\r\n\t\treturn z.string({ required_error: `${field} is required` }).refine(val => !isNaN(Date.parse(val)), {\r\n\t\t\tmessage: `${field} must be a valid date format`,\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a date validation.\r\n\t * Validates that the input is a JavaScript Date object.\r\n\t *@param field - The name of the field to be included in the error message\r\n\t *@param minDate - Minimum required date (optional)\r\n\t *@param maxDate - Maximum required date (optional)\r\n\t * @returns A Zod schema that validates Date objects\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const createdAtSchema = ZodValidation.date();\r\n\t * ```\r\n\t */\r\n\tstatic date(field: string = 'Field', minDate?: Date, maxDate?: Date) {\r\n\t\tlet schema = z.date({\r\n\t\t\trequired_error: `${field} is required`,\r\n\t\t\tinvalid_type_error: `${field} must be a valid date`,\r\n\t\t});\r\n\t\r\n\t\tif (minDate !== undefined) {\r\n\t\t\tschema = schema.min(minDate, `${field} must be on or after ${minDate.toISOString()}`);\r\n\t\t}\r\n\t\tif (maxDate !== undefined) {\r\n\t\t\tschema = schema.max(maxDate, `${field} must be on or before ${maxDate.toISOString()}`);\r\n\t\t}\r\n\t\r\n\t\treturn schema;\r\n\t}\r\n\r\n\t/**\r\n\t * Creates a boolean validation with an optional default value.\r\n\t *\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @returns A Zod schema that validates booleans\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const isActiveSchema = ZodValidation.boolean(true); // Defaults to true\r\n\t * ```\r\n\t */\r\n\tstatic boolean(field: string = 'Field') {\r\n\t\treturn z.boolean({\r\n\t\t\trequired_error: `${field} is required`,\r\n\t\t\tinvalid_type_error: `${field} must be a boolean`,\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Creates an array validation with optional minimum items constraint.\r\n\t *\r\n\t * @template T - Type of the schema for array items\r\n\t * @param schema - The schema for validating array items\r\n\t * @param field - The name of the field to be included in the error message\r\n\t * @param minItems - Minimum number of items required (optional)\r\n\t * @param maxItems - Maximum number of items required (optional)\r\n\t * @returns A Zod schema that validates arrays\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const tagsSchema = ZodValidation.array(z.string(), \"At least one tag required\", 1);\r\n\t * ```\r\n\t */\r\n\tstatic array<T extends z.ZodTypeAny>(\r\n\t\tschema: T,\r\n\t\tfield: string = 'Array',\r\n\t\tminItems?: number,\r\n\t\tmaxItems?: number\r\n\t) {\r\n\t\tlet arraySchema = z.array(schema, { required_error: `${field} is required` });\r\n\t\r\n\t\tif (minItems === 1) {\r\n\t\t\tarraySchema = arraySchema.min(1, `${field} cannot be empty`);\r\n\t\t}\r\n\t\tif (minItems !== undefined && minItems !== 1) {\r\n\t\t\tarraySchema = arraySchema.min(minItems, `${field} must have at least ${minItems} items`);\r\n\t\t}\r\n\t\tif (maxItems !== undefined) {\r\n\t\t\tarraySchema = arraySchema.max(maxItems, `${field} must have at most ${maxItems} items`);\r\n\t\t}\r\n\t\r\n\t\treturn arraySchema;\r\n\t}\r\n\r\n\t/**\r\n\t * Standard timestamp fields for entities.\r\n\t * Includes createdAt, updatedAt, and deletedAt fields.\r\n\t *\r\n\t * @returns An object containing timestamp field schemas\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const userSchema = z.object({\r\n\t * name: z.string(),\r\n\t * ...ZodValidation.timestamps()\r\n\t * });\r\n\t * ```\r\n\t */\r\n\tstatic timestamps() {\r\n\t\treturn {\r\n\t\t\tcreatedAt: z.date().nullable().optional(),\r\n\t\t\tupdatedAt: z.date().nullable().optional(),\r\n\t\t\tdeletedAt: z.date().nullable().optional(),\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Common fields for tracking model metadata.\r\n\t * Includes timestamps and user tracking fields (createdBy, updatedBy, deletedBy).\r\n\t *\r\n\t * @returns An object containing tracking field schemas\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const postSchema = z.object({\r\n\t * title: z.string(),\r\n\t * content: z.string(),\r\n\t * ...ZodValidation.trackingFields()\r\n\t * });\r\n\t * ```\r\n\t */\r\n\tstatic trackingFields() {\r\n\t\treturn {\r\n\t\t\tcreatedBy: ZodValidation.objectId().optional(),\r\n\t\t\tupdatedBy: ZodValidation.objectId().optional(),\r\n\t\t\tdeletedBy: ZodValidation.objectId().optional(),\r\n\t\t\t...ZodValidation.timestamps(),\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * Represents the common fields to exclude from update operations.\r\n * This is used to specify which fields should not be updateable.\r\n *\r\n * @example\r\n * ```typescript\r\n * const excludeFields: ExcludeFromUpdate = {\r\n * createdAt: true,\r\n * createdBy: true,\r\n * status: true // Prevent status from being updated\r\n * };\r\n * ```\r\n */\r\nexport type ExcludeFromUpdate = {\r\n\tcreatedAt?: true;\r\n\tupdatedAt?: true;\r\n\tdeletedAt?: true;\r\n\tcreatedBy?: true;\r\n\t_id?: true;\r\n} & Record<string, true>;\r\n\r\n/**\r\n * Schema builder for creating consistent CRUD schemas.\r\n * Provides utility methods to generate schemas for create, read, update, and delete operations.\r\n *\r\n * @template T - Type of the base schema shape\r\n *\r\n * @example\r\n * ```typescript\r\n * const userBuilder = new SchemaBuilder({\r\n * name: z.string(),\r\n * email: z.string().email()\r\n * });\r\n *\r\n * const schemas = userBuilder.getAllSchemas();\r\n * ```\r\n */\r\nexport class SchemaBuilder<T extends z.ZodRawShape> {\r\n\tprivate baseSchema: z.ZodObject<T>;\r\n\r\n\t/**\r\n\t * Create a new schema builder\r\n\t *\r\n\t * @param baseFields - The base fields for the schema\r\n\t * @param includeTimestamps - Whether to include timestamp fields (default: true)\r\n\t * @param includeTracking - Whether to include tracking fields (createdBy, etc.) (default: false)\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const userFields = {\r\n\t * name: ZodValidation.requiredString(),\r\n\t * email: ZodValidation.email()\r\n\t * };\r\n\t *\r\n\t * // With timestamps\r\n\t * const builder1 = new SchemaBuilder(userFields);\r\n\t *\r\n\t * // Without timestamps\r\n\t * const builder2 = new SchemaBuilder(userFields, false);\r\n\t *\r\n\t * // With tracking fields\r\n\t * const builder3 = new SchemaBuilder(userFields, true, true);\r\n\t * ```\r\n\t */\r\n\tconstructor(\r\n\t\tbaseFields: T,\r\n\t\tprivate includeTimestamps: boolean = true,\r\n\t\tprivate includeTracking: boolean = false\r\n\t) {\r\n\t\tif (includeTracking) {\r\n\t\t\tthis.baseSchema = z.object({\r\n\t\t\t\t...baseFields,\r\n\t\t\t\t...ZodValidation.trackingFields(),\r\n\t\t\t});\r\n\t\t} else if (includeTimestamps) {\r\n\t\t\tthis.baseSchema = z.object({\r\n\t\t\t\t...baseFields,\r\n\t\t\t\t...ZodValidation.timestamps(),\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\tthis.baseSchema = z.object(baseFields);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Gets the base validation schema without ID.\r\n\t * Used for creating new entities.\r\n\t *\r\n\t * @returns The base schema for creating new entities\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const createUserSchema = userBuilder.getBaseSchema();\r\n\t * ```\r\n\t */\r\n\tgetBaseSchema() {\r\n\t\treturn this.baseSchema;\r\n\t}\r\n\r\n\t/**\r\n\t * Gets the schema for entities with ID.\r\n\t * Used for representing complete entities with their ID.\r\n\t *\r\n\t * @returns The entity schema including ID\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const userSchema = userBuilder.getEntitySchema();\r\n\t * ```\r\n\t */\r\n\tgetEntitySchema() {\r\n\t\treturn this.baseSchema.extend({\r\n\t\t\t_id: ZodValidation.objectId(),\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Gets the schema for validating an entity ID.\r\n\t * Used for validating ID parameters in requests.\r\n\t *\r\n\t * @returns The ID validation schema\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const userIdSchema = userBuilder.getIdSchema();\r\n\t * ```\r\n\t */\r\n\tgetIdSchema() {\r\n\t\treturn ZodValidation.objectId();\r\n\t}\r\n\r\n\t/**\r\n\t * Gets the schema for updating an entity, excluding specified fields.\r\n\t * Creates a partial schema where all fields are optional, and removes\r\n\t * fields that should not be updateable.\r\n\t *\r\n\t * @param excludeFields - Fields to exclude from update operations\r\n\t * @returns The update schema with excluded fields removed\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * // Prevent updating createdAt and status\r\n\t * const updateUserSchema = userBuilder.getUpdateSchema({\r\n\t * createdAt: true,\r\n\t * status: true\r\n\t * });\r\n\t * ```\r\n\t */\r\n\tgetUpdateSchema(excludeFields: ExcludeFromUpdate = { createdAt: true }) {\r\n\t\tconst entitySchema = this.getEntitySchema();\r\n\r\n\t\t// Simple approach - just make everything optional\r\n\t\tif (Object.keys(excludeFields).length === 0) {\r\n\t\t\treturn entitySchema.partial();\r\n\t\t}\r\n\r\n\t\t// For the type-safe approach, we need to create a new schema\r\n\t\t// without the excluded fields and then make it partial\r\n\r\n\t\t// Get all fields from the entity schema\r\n\t\tconst shape = entitySchema._def.shape();\r\n\r\n\t\t// Filter out the fields we want to exclude\r\n\t\tconst filteredShape: z.ZodRawShape = {};\r\n\t\tfor (const key in shape) {\r\n\t\t\tif (!excludeFields[key as keyof typeof excludeFields]) {\r\n\t\t\t\tfilteredShape[key] = shape[key];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Create a new schema with the filtered fields\r\n\t\treturn z.object(filteredShape).partial();\r\n\t}\r\n\r\n\t/**\r\n\t * Gets all common schemas for an entity.\r\n\t * Returns base, entity, ID, and update schemas in a single object.\r\n\t *\r\n\t * @param excludeFromUpdate - Fields to exclude from update operations\r\n\t * @returns Object containing all schemas\r\n\t *\r\n\t * @example\r\n\t * ```typescript\r\n\t * const {\r\n\t * BaseSchema, // For creating\r\n\t * EntitySchema, // For reading\r\n\t * IdSchema, // For validating IDs\r\n\t * UpdateSchema // For updating\r\n\t * } = userBuilder.getAllSchemas();\r\n\t * ```\r\n\t */\r\n\tgetAllSchemas(excludeFromUpdate: ExcludeFromUpdate = { createdAt: true }) {\r\n\t\treturn {\r\n\t\t\tBaseSchema: this.getBaseSchema(),\r\n\t\t\tEntitySchema: this.getEntitySchema(),\r\n\t\t\tIdSchema: this.getIdSchema(),\r\n\t\t\tUpdateSchema: this.getUpdateSchema(excludeFromUpdate),\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * Type helper for creating DTO types from creation schemas.\r\n * Used to derive the type for creating new entities.\r\n *\r\n * @template T - The schema type\r\n *\r\n * @example\r\n * ```typescript\r\n * type CreateUserDTO = CreateDTO<typeof UserValidationSchema>;\r\n * ```\r\n */\r\nexport type CreateDTO<T extends z.ZodType> = z.infer<T>;\r\n\r\n/**\r\n * Type helper for creating DTO types from entity schemas.\r\n * Used to derive the type for complete entities.\r\n *\r\n * @template T - The schema type\r\n *\r\n * @example\r\n * ```typescript\r\n * type UserDTO = EntityDTO<typeof UserSchema>;\r\n * ```\r\n */\r\nexport type EntityDTO<T extends z.ZodType> = z.infer<T>;\r\n\r\n/**\r\n * Type helper for creating DTO types from update schemas.\r\n * Used to derive the type for updating entities.\r\n *\r\n * @template T - The schema type\r\n *\r\n * @example\r\n * ```typescript\r\n * type UpdateUserDTO = UpdateDTO<typeof UpdateUserSchema>;\r\n * ```\r\n */\r\nexport type UpdateDTO<T extends z.ZodType> = z.infer<T>;\r\n\r\n/**\r\n * Type alias for ID DTOs.\r\n * Represents the type of entity IDs (string).\r\n *\r\n * @example\r\n * ```typescript\r\n * type UserIdDTO = IdDTO;\r\n * ```\r\n */\r\nexport type IdDTO = string;\r\n\r\n/**\r\n * Creates a schema builder for an entity.\r\n * Helper function to create a new SchemaBuilder instance.\r\n *\r\n * @template T - Type of the base schema shape\r\n * @param baseFields - Base fields for the entity\r\n * @param includeTimestamps - Whether to include timestamp fields (default: true)\r\n * @param includeTracking - Whether to include tracking fields (default: false)\r\n * @returns A new SchemaBuilder instance\r\n *\r\n * @example\r\n * ```typescript\r\n * const userFields = {\r\n * name: ZodValidation.requiredString(),\r\n * email: ZodValidation.email()\r\n * };\r\n *\r\n * const userSchemaBuilder = createSchemaBuilder(userFields);\r\n * const userSchemaBuilder = createSchemaBuilder(userFields, true, true); // With tracking\r\n * ```\r\n */\r\nexport function createSchemaBuilder<T extends z.ZodRawShape>(\r\n\tbaseFields: T,\r\n\tincludeTimestamps: boolean = true,\r\n\tincludeTracking: boolean = false\r\n) {\r\n\treturn new SchemaBuilder(baseFields, includeTimestamps, includeTracking);\r\n}\r\n"]}
1
+ {"version":3,"file":"global-validation.js","sourceRoot":"/","sources":["utilities/validation/global-validation.ts"],"names":[],"mappings":";;;AA2oBA,kDAMC;AAjpBD,6BAAwB;AACxB,oDAAgD;AAehD,MAAa,aAAa;IAcxB,MAAM,CAAC,QAAQ,CAAC,QAAgB,OAAO;QACrC,OAAO,OAAC,CAAC,KAAK,CACZ;YACE,OAAC;iBACE,MAAM,CAAC,EAAE,cAAc,EAAE,GAAG,KAAK,cAAc,EAAE,CAAC;iBAClD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACrD,OAAO,EAAE,GAAG,KAAK,2BAA2B;aAC7C,CAAC;iBACD,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACvD,OAAC,CAAC,UAAU,CAAC,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACpC,OAAO,EAAE,GAAG,KAAK,2BAA2B;aAC7C,CAAC;SACH,EACD,EAAE,OAAO,EAAE,GAAG,KAAK,cAAc,EAAE,CACpC,CAAC;IACJ,CAAC;IAiBD,MAAM,CAAC,QAAQ,CAAuB,OAAU,EAAE,QAAgB,OAAO;QACvE,OAAO,OAAC,CAAC,UAAU,CAAC,OAAO,EAAE;YAC3B,OAAO,EAAE,GAAG,KAAK,oBAAoB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,I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MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAG5C,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5C,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;QAChC,CAAC;QAMD,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAGxC,MAAM,aAAa,GAAkB,EAAE,CAAC;QACxC,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,aAAa,CAAC,GAAiC,CAAC,EAAE,CAAC;gBACtD,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QAGD,OAAO,OAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3C,CAAC;IAmBD,aAAa,CAAC,oBAAuC,EAAE,SAAS,EAAE,IAAI,EAAE;QACtE,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE;YAChC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE;YACpC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE;YAC5B,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC;SACtD,CAAC;IACJ,CAAC;CACF;AAlKD,sCAkKC;AAyED,SAAgB,mBAAmB,CACjC,UAAa,EACb,oBAA6B,IAAI,EACjC,kBAA2B,KAAK;IAEhC,OAAO,IAAI,aAAa,CAAC,UAAU,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import { z } from \"zod\";\r\nimport { mongoose } from \"@typegoose/typegoose\";\r\n\r\n/**\r\n * Enhanced validation utilities for creating robust Zod schemas.\r\n * This class provides a collection of static methods to create common validation patterns.\r\n *\r\n * @example\r\n * ```typescript\r\n * const userSchema = z.object({\r\n * username: ZodValidation.requiredString(\"Username is required\"),\r\n * email: ZodValidation.email(),\r\n * role: ZodValidation.enumType(UserRole)\r\n * });\r\n * ```\r\n */\r\nexport class ZodValidation {\r\n /**\r\n * Creates a union type that accepts both string ObjectId and mongoose ObjectId instance.\r\n * This is useful when dealing with both raw string IDs and Mongoose ObjectId instances.\r\n *\r\n * @param field - The name of the field to be included in the error message\r\n * @returns A Zod union schema that accepts both string and ObjectId\r\n *\r\n * @example\r\n * ```typescript\r\n * const idSchema = ZodValidation.objectIdUnion();\r\n * // Accepts \"507f1f77bcf86cd799439011\" or new mongoose.Types.ObjectId(\"507f1f77bcf86cd799439011\")\r\n * ```\r\n */\r\n static objectId(field: string = \"Field\") {\r\n return z.union(\r\n [\r\n z\r\n .string({ required_error: `${field} is required` })\r\n .refine((val) => mongoose.Types.ObjectId.isValid(val), {\r\n message: `${field} must be a valid ObjectID`\r\n })\r\n .transform((val) => new mongoose.Types.ObjectId(val)),\r\n z.instanceof(mongoose.Types.ObjectId, {\r\n message: `${field} must be a valid ObjectID`\r\n })\r\n ],\r\n { message: `${field} is required` }\r\n );\r\n }\r\n\r\n /**\r\n * Creates an enum validation with custom error message.\r\n * This validates that a value is one of the values defined in the enum.\r\n *\r\n * @template T - Type of the enum\r\n * @param enumObj - The enum object to validate against\r\n * @param field - The name of the field to be included in the error message\r\n * @returns A Zod schema that validates against the provided enum\r\n *\r\n * @example\r\n * ```typescript\r\n * enum UserRole { ADMIN = \"admin\", USER = \"user\" }\r\n * const roleSchema = ZodValidation.enumType(UserRole, \"Invalid user role\");\r\n * ```\r\n */\r\n static enumType<T extends z.EnumLike>(enumObj: T, field: string = \"Field\") {\r\n return z.nativeEnum(enumObj, {\r\n message: `${field} must be one of: ${Object.values(enumObj).join(\", \")}`\r\n });\r\n }\r\n\r\n /**\r\n * Creates a required number validation with a minimum length.\r\n * The number is also trimmed to remove leading/trailing whitespace.\r\n *\r\n * @param field - The name of the field to be included in the error message\r\n * @param min - Minimum number (optional)\r\n * @param max - MAximum number (optional)\r\n * @param options - options (optional)\r\n * @returns A Zod schema that validates numbers with minimum length\r\n *\r\n * @example\r\n * ```typescript\r\n * const nameSchema = ZodValidation.Number(\"Price\");\r\n * ```\r\n */\r\n static number(\r\n field: string = \"Field\",\r\n min?: number,\r\n max?: number,\r\n options?: {\r\n isInt?: boolean;\r\n isPositive?: boolean;\r\n isNonpositive?: boolean;\r\n isNegative?: boolean;\r\n isNonnegative?: boolean;\r\n }\r\n ) {\r\n let schema = z.number({\r\n required_error: `${field} is required`,\r\n invalid_type_error: `${field} must be a number`\r\n });\r\n\r\n // Range validation\r\n if (min !== undefined) {\r\n schema = schema.gte(min, { message: `${field} must be at least ${min}` });\r\n }\r\n if (max !== undefined) {\r\n schema = schema.lte(max, { message: `${field} must be at most ${max}` });\r\n }\r\n\r\n // Option validation\r\n if (options?.isInt) {\r\n schema = schema.int({ message: `${field} must be an integer` });\r\n }\r\n if (options?.isPositive) {\r\n schema = schema.positive({ message: `${field} must be positive` });\r\n }\r\n if (options?.isNonpositive) {\r\n schema = schema.nonpositive({ message: `${field} must be non-positive` });\r\n }\r\n if (options?.isNegative) {\r\n schema = schema.negative({ message: `${field} must be negative` });\r\n }\r\n if (options?.isNonnegative) {\r\n schema = schema.nonnegative({ message: `${field} must be non-negative` });\r\n }\r\n\r\n return schema;\r\n }\r\n\r\n /**\r\n * Creates a required string validation with a minimum length.\r\n * The string is also trimmed to remove leading/trailing whitespace.\r\n *\r\n * @param field - The name of the field to be included in the error message\r\n * @param minLength - Minimum required length (optional)\r\n * @param maxLength - Maximum required length (optional)\r\n * @param regex - Regular erpression (optional)\r\n * @returns A Zod schema that validates strings with minimum length\r\n *\r\n * @example\r\n * ```typescript\r\n * const nameSchema = ZodValidation.String(\"Name\");\r\n * ```\r\n */\r\n static string(\r\n field: string = \"Field\",\r\n minLength?: number,\r\n maxLength?: number,\r\n regex?: { pattern: RegExp; message: string }\r\n ) {\r\n let schema = z.string({\r\n required_error: `${field} is required`,\r\n invalid_type_error: `${field} must be a string`\r\n });\r\n\r\n if (minLength !== undefined) {\r\n schema = schema.min(\r\n minLength,\r\n `${field} value length must be greater than or equal to ${minLength}`\r\n );\r\n }\r\n if (maxLength !== undefined) {\r\n schema = schema.max(\r\n maxLength,\r\n `${field} value length must be less than or equal to ${maxLength}`\r\n );\r\n }\r\n if (regex !== undefined) {\r\n schema = schema.regex(regex.pattern, regex.message);\r\n }\r\n\r\n return schema;\r\n }\r\n\r\n /**\r\n * Creates an email validation.\r\n * Validates that the string is a valid email address format.\r\n *\r\n * @param field - The name of the field to be included in the error message\r\n * @returns A Zod schema that validates email addresses\r\n *\r\n * @example\r\n * ```typescript\r\n * const emailSchema = ZodValidation.email(\"Please enter a valid email\");\r\n * ```\r\n */\r\n static email(field: string = \"Field\") {\r\n return z\r\n .string({ required_error: `${field} is required` })\r\n .email(`${field} must be a valid email address`);\r\n }\r\n\r\n /**\r\n * Creates a URL validation.\r\n * Validates that the string is a valid URL format.\r\n *\r\n * @param field - The name of the field to be included in the error message\r\n * @returns A Zod schema that validates URLs\r\n *\r\n * @example\r\n * ```typescript\r\n * const websiteSchema = ZodValidation.url(\"Please enter a valid URL\");\r\n * ```\r\n */\r\n static url(field: string = \"Field\") {\r\n return z\r\n .string({ required_error: `${field} is required` })\r\n .url(`${field} must be a valid URL`);\r\n }\r\n\r\n /**\r\n * Creates a phone number validation schema using a regex pattern for global phone numbers.\r\n *\r\n * @param field - The name of the field to be included in the error message\r\n * @returns A Zod schema that validates phone numbers\r\n *\r\n * @example\r\n * ```typescript\r\n * const phoneSchema = ZodValidation.phoneNumber(\"Phone number\");\r\n * ```\r\n */\r\n static phoneNumber(field: string = \"Field\") {\r\n return z\r\n .string({ required_error: `${field} is required` })\r\n .regex(\r\n /^[+]{1}(?:[0-9\\-\\\\(\\\\)\\\\/.]\\s?){6,15}[0-9]{1}$/,\r\n `${field} must be a valid phone number`\r\n );\r\n }\r\n\r\n /**\r\n * Creates a date validation.\r\n * Validates that the input is a JavaScript Date object.\r\n *@param field - The name of the field to be included in the error message\r\n *@param minDate - Minimum required date (optional)\r\n *@param maxDate - Maximum required date (optional)\r\n * @returns A Zod schema that validates Date objects\r\n *\r\n * @example\r\n * ```typescript\r\n * const createdAtSchema = ZodValidation.date();\r\n * ```\r\n */\r\n static date(field: string = \"Field\", minDate?: Date, maxDate?: Date) {\r\n return z\r\n .union(\r\n [\r\n z\r\n .string({ required_error: `${field} is required` })\r\n .refine((val) => {\r\n const date = new Date(val);\r\n return !isNaN(date.getTime());\r\n }, `${field} must be a valid date`)\r\n .transform((val) => new Date(val)),\r\n z.date({\r\n required_error: `${field} is required`,\r\n invalid_type_error: `${field} must be a valid date`\r\n })\r\n ],\r\n { message: `${field} is required` }\r\n )\r\n .refine(\r\n (val) => minDate === undefined || val >= minDate,\r\n `${field} must be on or after ${minDate?.toISOString()}`\r\n )\r\n .refine(\r\n (val) => maxDate === undefined || val <= maxDate,\r\n `${field} must be on or before ${maxDate?.toISOString()}`\r\n );\r\n }\r\n\r\n /**\r\n * Creates a boolean validation with an optional default value.\r\n *\r\n * @param field - The name of the field to be included in the error message\r\n * @returns A Zod schema that validates booleans\r\n *\r\n * @example\r\n * ```typescript\r\n * const isActiveSchema = ZodValidation.boolean(true); // Defaults to true\r\n * ```\r\n */\r\n static boolean(field: string = \"Field\") {\r\n return z.boolean({\r\n required_error: `${field} is required`,\r\n invalid_type_error: `${field} must be a boolean`\r\n });\r\n }\r\n\r\n /**\r\n * Creates an array validation with optional minimum items constraint.\r\n *\r\n * @template T - Type of the schema for array items\r\n * @param schema - The schema for validating array items\r\n * @param field - The name of the field to be included in the error message\r\n * @param minItems - Minimum number of items required (optional)\r\n * @param maxItems - Maximum number of items required (optional)\r\n * @returns A Zod schema that validates arrays\r\n *\r\n * @example\r\n * ```typescript\r\n * const tagsSchema = ZodValidation.array(z.string(), \"At least one tag required\", 1);\r\n * ```\r\n */\r\n static array<T extends z.ZodTypeAny>(\r\n schema: T,\r\n field: string = \"Array\",\r\n minItems?: number,\r\n maxItems?: number\r\n ) {\r\n let arraySchema = z.array(schema, {\r\n required_error: `${field} is required`\r\n });\r\n\r\n if (minItems === 1) {\r\n arraySchema = arraySchema.min(1, `${field} cannot be empty`);\r\n }\r\n if (minItems !== undefined && minItems !== 1) {\r\n arraySchema = arraySchema.min(\r\n minItems,\r\n `${field} must have at least ${minItems} items`\r\n );\r\n }\r\n if (maxItems !== undefined) {\r\n arraySchema = arraySchema.max(\r\n maxItems,\r\n `${field} must have at most ${maxItems} items`\r\n );\r\n }\r\n\r\n return arraySchema;\r\n }\r\n\r\n /**\r\n * Standard timestamp fields for entities.\r\n * Includes createdAt, updatedAt, and deletedAt fields.\r\n *\r\n * @returns An object containing timestamp field schemas\r\n *\r\n * @example\r\n * ```typescript\r\n * const userSchema = z.object({\r\n * name: z.string(),\r\n * ...ZodValidation.timestamps()\r\n * });\r\n * ```\r\n */\r\n static timestamps() {\r\n return {\r\n createdAt: z.date().nullable().optional(),\r\n updatedAt: z.date().nullable().optional(),\r\n deletedAt: z.date().nullable().optional()\r\n };\r\n }\r\n\r\n /**\r\n * Common fields for tracking model metadata.\r\n * Includes timestamps and user tracking fields (createdBy, updatedBy, deletedBy).\r\n *\r\n * @returns An object containing tracking field schemas\r\n *\r\n * @example\r\n * ```typescript\r\n * const postSchema = z.object({\r\n * title: z.string(),\r\n * content: z.string(),\r\n * ...ZodValidation.trackingFields()\r\n * });\r\n * ```\r\n */\r\n static trackingFields() {\r\n return {\r\n createdBy: ZodValidation.objectId().optional(),\r\n updatedBy: ZodValidation.objectId().optional(),\r\n deletedBy: ZodValidation.objectId().optional(),\r\n ...ZodValidation.timestamps()\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Represents the common fields to exclude from update operations.\r\n * This is used to specify which fields should not be updateable.\r\n *\r\n * @example\r\n * ```typescript\r\n * const excludeFields: ExcludeFromUpdate = {\r\n * createdAt: true,\r\n * createdBy: true,\r\n * status: true // Prevent status from being updated\r\n * };\r\n * ```\r\n */\r\nexport type ExcludeFromUpdate = {\r\n createdAt?: true;\r\n updatedAt?: true;\r\n deletedAt?: true;\r\n createdBy?: true;\r\n _id?: true;\r\n} & Record<string, true>;\r\n\r\n/**\r\n * Schema builder for creating consistent CRUD schemas.\r\n * Provides utility methods to generate schemas for create, read, update, and delete operations.\r\n *\r\n * @template T - Type of the base schema shape\r\n *\r\n * @example\r\n * ```typescript\r\n * const userBuilder = new SchemaBuilder({\r\n * name: z.string(),\r\n * email: z.string().email()\r\n * });\r\n *\r\n * const schemas = userBuilder.getAllSchemas();\r\n * ```\r\n */\r\nexport class SchemaBuilder<T extends z.ZodRawShape> {\r\n private baseSchema: z.ZodObject<T>;\r\n\r\n /**\r\n * Create a new schema builder\r\n *\r\n * @param baseFields - The base fields for the schema\r\n * @param includeTimestamps - Whether to include timestamp fields (default: true)\r\n * @param includeTracking - Whether to include tracking fields (createdBy, etc.) (default: false)\r\n *\r\n * @example\r\n * ```typescript\r\n * const userFields = {\r\n * name: ZodValidation.requiredString(),\r\n * email: ZodValidation.email()\r\n * };\r\n *\r\n * // With timestamps\r\n * const builder1 = new SchemaBuilder(userFields);\r\n *\r\n * // Without timestamps\r\n * const builder2 = new SchemaBuilder(userFields, false);\r\n *\r\n * // With tracking fields\r\n * const builder3 = new SchemaBuilder(userFields, true, true);\r\n * ```\r\n */\r\n constructor(\r\n baseFields: T,\r\n private includeTimestamps: boolean = true,\r\n private includeTracking: boolean = false\r\n ) {\r\n if (includeTracking) {\r\n this.baseSchema = z.object({\r\n ...baseFields,\r\n ...ZodValidation.trackingFields()\r\n });\r\n } else if (includeTimestamps) {\r\n this.baseSchema = z.object({\r\n ...baseFields,\r\n ...ZodValidation.timestamps()\r\n });\r\n } else {\r\n this.baseSchema = z.object(baseFields);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the base validation schema without ID.\r\n * Used for creating new entities.\r\n *\r\n * @returns The base schema for creating new entities\r\n *\r\n * @example\r\n * ```typescript\r\n * const createUserSchema = userBuilder.getBaseSchema();\r\n * ```\r\n */\r\n getBaseSchema() {\r\n return this.baseSchema;\r\n }\r\n\r\n /**\r\n * Gets the schema for entities with ID.\r\n * Used for representing complete entities with their ID.\r\n *\r\n * @returns The entity schema including ID\r\n *\r\n * @example\r\n * ```typescript\r\n * const userSchema = userBuilder.getEntitySchema();\r\n * ```\r\n */\r\n getEntitySchema() {\r\n return this.baseSchema.extend({\r\n _id: ZodValidation.objectId()\r\n });\r\n }\r\n\r\n /**\r\n * Gets the schema for validating an entity ID.\r\n * Used for validating ID parameters in requests.\r\n *\r\n * @returns The ID validation schema\r\n *\r\n * @example\r\n * ```typescript\r\n * const userIdSchema = userBuilder.getIdSchema();\r\n * ```\r\n */\r\n getIdSchema() {\r\n return ZodValidation.objectId();\r\n }\r\n\r\n /**\r\n * Gets the schema for updating an entity, excluding specified fields.\r\n * Creates a partial schema where all fields are optional, and removes\r\n * fields that should not be updateable.\r\n *\r\n * @param excludeFields - Fields to exclude from update operations\r\n * @returns The update schema with excluded fields removed\r\n *\r\n * @example\r\n * ```typescript\r\n * // Prevent updating createdAt and status\r\n * const updateUserSchema = userBuilder.getUpdateSchema({\r\n * createdAt: true,\r\n * status: true\r\n * });\r\n * ```\r\n */\r\n getUpdateSchema(excludeFields: ExcludeFromUpdate = { createdAt: true }) {\r\n const entitySchema = this.getEntitySchema();\r\n\r\n // Simple approach - just make everything optional\r\n if (Object.keys(excludeFields).length === 0) {\r\n return entitySchema.partial();\r\n }\r\n\r\n // For the type-safe approach, we need to create a new schema\r\n // without the excluded fields and then make it partial\r\n\r\n // Get all fields from the entity schema\r\n const shape = entitySchema._def.shape();\r\n\r\n // Filter out the fields we want to exclude\r\n const filteredShape: z.ZodRawShape = {};\r\n for (const key in shape) {\r\n if (!excludeFields[key as keyof typeof excludeFields]) {\r\n filteredShape[key] = shape[key];\r\n }\r\n }\r\n\r\n // Create a new schema with the filtered fields\r\n return z.object(filteredShape).partial();\r\n }\r\n\r\n /**\r\n * Gets all common schemas for an entity.\r\n * Returns base, entity, ID, and update schemas in a single object.\r\n *\r\n * @param excludeFromUpdate - Fields to exclude from update operations\r\n * @returns Object containing all schemas\r\n *\r\n * @example\r\n * ```typescript\r\n * const {\r\n * BaseSchema, // For creating\r\n * EntitySchema, // For reading\r\n * IdSchema, // For validating IDs\r\n * UpdateSchema // For updating\r\n * } = userBuilder.getAllSchemas();\r\n * ```\r\n */\r\n getAllSchemas(excludeFromUpdate: ExcludeFromUpdate = { createdAt: true }) {\r\n return {\r\n BaseSchema: this.getBaseSchema(),\r\n EntitySchema: this.getEntitySchema(),\r\n IdSchema: this.getIdSchema(),\r\n UpdateSchema: this.getUpdateSchema(excludeFromUpdate)\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Type helper for creating DTO types from creation schemas.\r\n * Used to derive the type for creating new entities.\r\n *\r\n * @template T - The schema type\r\n *\r\n * @example\r\n * ```typescript\r\n * type CreateUserDTO = CreateDTO<typeof UserValidationSchema>;\r\n * ```\r\n */\r\nexport type CreateDTO<T extends z.ZodType> = z.infer<T>;\r\n\r\n/**\r\n * Type helper for creating DTO types from entity schemas.\r\n * Used to derive the type for complete entities.\r\n *\r\n * @template T - The schema type\r\n *\r\n * @example\r\n * ```typescript\r\n * type UserDTO = EntityDTO<typeof UserSchema>;\r\n * ```\r\n */\r\nexport type EntityDTO<T extends z.ZodType> = z.infer<T>;\r\n\r\n/**\r\n * Type helper for creating DTO types from update schemas.\r\n * Used to derive the type for updating entities.\r\n *\r\n * @template T - The schema type\r\n *\r\n * @example\r\n * ```typescript\r\n * type UpdateUserDTO = UpdateDTO<typeof UpdateUserSchema>;\r\n * ```\r\n */\r\nexport type UpdateDTO<T extends z.ZodType> = z.infer<T>;\r\n\r\n/**\r\n * Type alias for ID DTOs.\r\n * Represents the type of entity IDs (string).\r\n *\r\n * @example\r\n * ```typescript\r\n * type UserIdDTO = IdDTO;\r\n * ```\r\n */\r\nexport type IdDTO = string;\r\n\r\n/**\r\n * Creates a schema builder for an entity.\r\n * Helper function to create a new SchemaBuilder instance.\r\n *\r\n * @template T - Type of the base schema shape\r\n * @param baseFields - Base fields for the entity\r\n * @param includeTimestamps - Whether to include timestamp fields (default: true)\r\n * @param includeTracking - Whether to include tracking fields (default: false)\r\n * @returns A new SchemaBuilder instance\r\n *\r\n * @example\r\n * ```typescript\r\n * const userFields = {\r\n * name: ZodValidation.requiredString(),\r\n * email: ZodValidation.email()\r\n * };\r\n *\r\n * const userSchemaBuilder = createSchemaBuilder(userFields);\r\n * const userSchemaBuilder = createSchemaBuilder(userFields, true, true); // With tracking\r\n * ```\r\n */\r\nexport function createSchemaBuilder<T extends z.ZodRawShape>(\r\n baseFields: T,\r\n includeTimestamps: boolean = true,\r\n includeTracking: boolean = false\r\n) {\r\n return new SchemaBuilder(baseFields, includeTimestamps, includeTracking);\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",