@lyxa.ai/core 1.1.9 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- export declare class SearchFields {
2
- autocomplete?: string;
3
- fulltext?: string;
1
+ export declare class AutoFullTextSearchFields {
2
+ autocomplete?: string[];
3
+ fulltext?: string[];
4
4
  }
5
5
  export declare class ShopSearchFields {
6
- name?: SearchFields;
7
- products?: SearchFields[];
8
- tags?: SearchFields[];
9
- parentCategories?: SearchFields[];
10
- subCategories?: SearchFields[];
11
- brands?: SearchFields[];
6
+ name?: AutoFullTextSearchFields;
7
+ products?: AutoFullTextSearchFields;
8
+ tags?: AutoFullTextSearchFields;
9
+ parentCategories?: AutoFullTextSearchFields;
10
+ subCategories?: AutoFullTextSearchFields;
11
+ brands?: AutoFullTextSearchFields;
12
12
  }
@@ -9,21 +9,21 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ShopSearchFields = exports.SearchFields = void 0;
12
+ exports.ShopSearchFields = exports.AutoFullTextSearchFields = void 0;
13
13
  const typegoose_1 = require("@typegoose/typegoose");
14
- class SearchFields {
14
+ class AutoFullTextSearchFields {
15
15
  autocomplete;
16
16
  fulltext;
17
17
  }
18
- exports.SearchFields = SearchFields;
18
+ exports.AutoFullTextSearchFields = AutoFullTextSearchFields;
19
19
  __decorate([
20
20
  (0, typegoose_1.prop)({ type: [String] }),
21
- __metadata("design:type", String)
22
- ], SearchFields.prototype, "autocomplete", void 0);
21
+ __metadata("design:type", Array)
22
+ ], AutoFullTextSearchFields.prototype, "autocomplete", void 0);
23
23
  __decorate([
24
24
  (0, typegoose_1.prop)({ type: [String] }),
25
- __metadata("design:type", String)
26
- ], SearchFields.prototype, "fulltext", void 0);
25
+ __metadata("design:type", Array)
26
+ ], AutoFullTextSearchFields.prototype, "fulltext", void 0);
27
27
  class ShopSearchFields {
28
28
  name;
29
29
  products;
@@ -34,27 +34,27 @@ class ShopSearchFields {
34
34
  }
35
35
  exports.ShopSearchFields = ShopSearchFields;
36
36
  __decorate([
37
- (0, typegoose_1.prop)({ type: SearchFields }),
38
- __metadata("design:type", SearchFields)
37
+ (0, typegoose_1.prop)({ type: AutoFullTextSearchFields }),
38
+ __metadata("design:type", AutoFullTextSearchFields)
39
39
  ], ShopSearchFields.prototype, "name", void 0);
40
40
  __decorate([
41
- (0, typegoose_1.prop)({ type: [SearchFields] }),
42
- __metadata("design:type", Array)
41
+ (0, typegoose_1.prop)({ type: AutoFullTextSearchFields }),
42
+ __metadata("design:type", AutoFullTextSearchFields)
43
43
  ], ShopSearchFields.prototype, "products", void 0);
44
44
  __decorate([
45
- (0, typegoose_1.prop)({ type: [SearchFields] }),
46
- __metadata("design:type", Array)
45
+ (0, typegoose_1.prop)({ type: AutoFullTextSearchFields }),
46
+ __metadata("design:type", AutoFullTextSearchFields)
47
47
  ], ShopSearchFields.prototype, "tags", void 0);
48
48
  __decorate([
49
- (0, typegoose_1.prop)({ type: [SearchFields] }),
50
- __metadata("design:type", Array)
49
+ (0, typegoose_1.prop)({ type: AutoFullTextSearchFields }),
50
+ __metadata("design:type", AutoFullTextSearchFields)
51
51
  ], ShopSearchFields.prototype, "parentCategories", void 0);
52
52
  __decorate([
53
- (0, typegoose_1.prop)({ type: [SearchFields] }),
54
- __metadata("design:type", Array)
53
+ (0, typegoose_1.prop)({ type: AutoFullTextSearchFields }),
54
+ __metadata("design:type", AutoFullTextSearchFields)
55
55
  ], ShopSearchFields.prototype, "subCategories", void 0);
56
56
  __decorate([
57
- (0, typegoose_1.prop)({ type: [SearchFields] }),
58
- __metadata("design:type", Array)
57
+ (0, typegoose_1.prop)({ type: AutoFullTextSearchFields }),
58
+ __metadata("design:type", AutoFullTextSearchFields)
59
59
  ], ShopSearchFields.prototype, "brands", void 0);
60
60
  //# sourceMappingURL=shop-search-fields.model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shop-search-fields.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/shop-search-fields.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,MAAa,YAAY;IAEjB,YAAY,CAAU;IAGtB,QAAQ,CAAU;CACzB;AAND,oCAMC;AAJO;IADH,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;;kDACC;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;;8CACA;AAE1B,MAAa,gBAAgB;IAErB,IAAI,CAAgB;IAGpB,QAAQ,CAAkB;IAG1B,IAAI,CAAkB;IAGnB,gBAAgB,CAAkB;IAGlC,aAAa,CAAkB;IAGlC,MAAM,CAAkB;CAC/B;AAlBD,4CAkBC;AAhBO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BACf,YAAY;8CAAC;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;;kDACE;AAG1B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;;8CACF;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;;0DACU;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;;uDACO;AAGlC;IADH,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;;gDACH","sourcesContent":["import { prop } from '@typegoose/typegoose';\nexport class SearchFields {\n @prop({ type: [String] })\n\tpublic autocomplete?: string;\n\n\t@prop({ type: [String] })\n\tpublic fulltext?: string; \n}\nexport class ShopSearchFields {\n\t@prop({ type: SearchFields })\n\tpublic name?: SearchFields;\n\n\t@prop({ type: [SearchFields] })\n\tpublic products?: SearchFields[];\n\n\t@prop({ type: [SearchFields] })\n\tpublic tags?: SearchFields[]; \n\n @prop({ type: [SearchFields] })\n public parentCategories?: SearchFields[]; \n\n @prop({ type: [SearchFields] })\n public subCategories?: SearchFields[]; \n\n @prop({ type: [SearchFields] })\n\tpublic brands?: SearchFields[]; \n}\n"]}
1
+ {"version":3,"file":"shop-search-fields.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/shop-search-fields.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,MAAa,wBAAwB;IAE7B,YAAY,CAAY;IAGxB,QAAQ,CAAY;CAC3B;AAND,4DAMC;AAJO;IADH,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;;8DACG;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;;0DACE;AAE5B,MAAa,gBAAgB;IAErB,IAAI,CAA4B;IAGhC,QAAQ,CAA4B;IAGpC,IAAI,CAA4B;IAG7B,gBAAgB,CAA4B;IAG5C,aAAa,CAA4B;IAG5C,MAAM,CAA4B;CACzC;AAlBD,4CAkBC;AAhBO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;8BAC3B,wBAAwB;8CAAC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;8BACvB,wBAAwB;kDAAC;AAGpC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;8BAC3B,wBAAwB;8CAAC;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;8BACf,wBAAwB;0DAAC;AAG5C;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;8BAClB,wBAAwB;uDAAC;AAG5C;IADH,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;8BAC5B,wBAAwB;gDAAC","sourcesContent":["import { prop } from '@typegoose/typegoose';\nexport class AutoFullTextSearchFields {\n @prop({ type: [String] })\n\tpublic autocomplete?: string[];\n\n\t@prop({ type: [String] })\n\tpublic fulltext?: string[]; \n}\nexport class ShopSearchFields {\n\t@prop({ type: AutoFullTextSearchFields })\n\tpublic name?: AutoFullTextSearchFields;\n\n\t@prop({ type: AutoFullTextSearchFields })\n\tpublic products?: AutoFullTextSearchFields;\n\n\t@prop({ type: AutoFullTextSearchFields })\n\tpublic tags?: AutoFullTextSearchFields; \n\n @prop({ type: AutoFullTextSearchFields })\n public parentCategories?: AutoFullTextSearchFields; \n\n @prop({ type: AutoFullTextSearchFields })\n public subCategories?: AutoFullTextSearchFields; \n\n @prop({ type: AutoFullTextSearchFields })\n\tpublic brands?: AutoFullTextSearchFields; \n}\n"]}
@@ -1,11 +1,12 @@
1
1
  import { Ref } from '@typegoose/typegoose';
2
2
  import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
3
- import { Status } from '../../../utilities/enum';
3
+ import { ServiceType, Status } from '../../../utilities/enum';
4
4
  import { Vendor } from './vendor.model';
5
5
  import { Service } from './service.model';
6
6
  export declare class ServiceCategory extends TimeStamps {
7
7
  name: string;
8
8
  service: Ref<Service>;
9
+ serviceType: ServiceType;
9
10
  vendor: Ref<Vendor>;
10
11
  image?: string;
11
12
  status: Status;
@@ -18,6 +18,7 @@ const service_model_1 = require("./service.model");
18
18
  let ServiceCategory = class ServiceCategory extends defaultClasses_1.TimeStamps {
19
19
  name;
20
20
  service;
21
+ serviceType;
21
22
  vendor;
22
23
  image;
23
24
  status;
@@ -31,6 +32,10 @@ __decorate([
31
32
  (0, typegoose_1.prop)({ required: true, ref: () => service_model_1.Service }),
32
33
  __metadata("design:type", Object)
33
34
  ], ServiceCategory.prototype, "service", void 0);
35
+ __decorate([
36
+ (0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.ServiceType }),
37
+ __metadata("design:type", String)
38
+ ], ServiceCategory.prototype, "serviceType", void 0);
34
39
  __decorate([
35
40
  (0, typegoose_1.prop)({ required: true, ref: () => vendor_model_1.Vendor }),
36
41
  __metadata("design:type", Object)
@@ -1 +1 @@
1
- {"version":3,"file":"service-category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,kDAAiD;AACjD,iDAAwC;AACxC,mDAA0C;AAInC,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,2BAAU;IAEvC,IAAI,CAAU;IAGd,OAAO,CAAe;IAGnB,MAAM,CAAe;IAGxB,KAAK,CAAU;IAGf,MAAM,CAAU;CACvB,CAAA;AAfY,0CAAe;AAEpB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;;6CAC7C;AAGd;IADH,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAC,GAAE,EAAE,CAAC,uBAAO,EAAE,CAAC;;gDACjB;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,qBAAM,EAAE,CAAC;;+CAChB;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACD;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;+CACtC;0BAdX,eAAe;IAF3B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,EAAE,CAAC;GAExD,eAAe,CAe3B","sourcesContent":["import { Index, modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Status } from '../../../utilities/enum';\nimport { Vendor } from './vendor.model';\nimport { Service } from './service.model';\n\n@modelOptions({ schemaOptions: { collection: 'serviceCategories' } })\n\nexport class ServiceCategory extends TimeStamps {\n\t@prop({ required: true, type: String, trim: true, maxlength: 20 })\n\tpublic name!: string;\n\n @prop({ required: true, ref:()=> Service })\n\tpublic service!: Ref<Service>\n\n @prop({ required: true, ref: () => Vendor })\n public vendor!: Ref<Vendor>;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status!: Status;\n}\n"]}
1
+ {"version":3,"file":"service-category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAA8D;AAC9D,iDAAwC;AACxC,mDAA0C;AAInC,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,2BAAU;IAEvC,IAAI,CAAU;IAGd,OAAO,CAAe;IAGtB,WAAW,CAAc;IAGtB,MAAM,CAAe;IAGxB,KAAK,CAAU;IAGf,MAAM,CAAU;CACvB,CAAA;AAlBY,0CAAe;AAEpB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;;6CAC7C;AAGd;IADH,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAC,GAAE,EAAE,CAAC,uBAAO,EAAE,CAAC;;gDACjB;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAW,EAAE,CAAC;;oDAC1B;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,qBAAM,EAAE,CAAC;;+CAChB;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CACD;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;+CACtC;0BAjBX,eAAe;IAF3B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,EAAE,CAAC;GAExD,eAAe,CAkB3B","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ServiceType, Status } from '../../../utilities/enum';\nimport { Vendor } from './vendor.model';\nimport { Service } from './service.model';\n\n@modelOptions({ schemaOptions: { collection: 'serviceCategories' } })\n\nexport class ServiceCategory extends TimeStamps {\n\t@prop({ required: true, type: String, trim: true, maxlength: 20 })\n\tpublic name!: string;\n\n @prop({ required: true, ref:()=> Service })\n\tpublic service!: Ref<Service>\n\n\t@prop({ required: true, type: String, enum: ServiceType })\n\tpublic serviceType!: ServiceType\n\n @prop({ required: true, ref: () => Vendor })\n public vendor!: Ref<Vendor>;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status!: Status;\n}\n"]}
@@ -21,6 +21,10 @@ export declare class UploadService {
21
21
  }>>;
22
22
  downloadFile(filename: string): Promise<Buffer>;
23
23
  deleteFile(filename: string): Promise<void>;
24
+ getPublicUrlFromFilename(filename: string): Promise<{
25
+ status: boolean;
26
+ url: string;
27
+ }>;
24
28
  extractFilenameFromUrl(url: string): string;
25
29
  deleteFileByUrl(url: string): Promise<void>;
26
30
  downloadImage(url: string): Promise<Buffer>;
@@ -38,6 +42,7 @@ export declare class UploadService {
38
42
  width?: number;
39
43
  height?: number;
40
44
  withExtension?: boolean;
45
+ withOriginalFilename?: boolean;
41
46
  }): Promise<{
42
47
  filename: string;
43
48
  url: string;
@@ -128,6 +128,17 @@ class UploadService {
128
128
  }
129
129
  await file.delete();
130
130
  }
131
+ async getPublicUrlFromFilename(filename) {
132
+ const file = this.bucket.file(filename);
133
+ const [exists] = await file.exists();
134
+ if (!exists) {
135
+ return { status: false, url: '' };
136
+ }
137
+ return {
138
+ status: true,
139
+ url: `https://storage.googleapis.com/${this.bucket.name}/${filename}`
140
+ };
141
+ }
131
142
  extractFilenameFromUrl(url) {
132
143
  try {
133
144
  const urlObj = new URL(url);
@@ -208,7 +219,7 @@ class UploadService {
208
219
  });
209
220
  }
210
221
  async uploadFile(buffer, originalFilename, options) {
211
- const newFilename = this.generateFilename(originalFilename);
222
+ const newFilename = options?.withOriginalFilename ? originalFilename : this.generateFilename(originalFilename);
212
223
  const extension = path_1.default.extname(newFilename).toLowerCase();
213
224
  const contentType = mime_types_1.default.lookup(extension) || 'application/octet-stream';
214
225
  if (contentType.startsWith('image/')) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/upload/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,kDAA0B;AAC1B,oDAA4B;AAC5B,gDAAwB;AACxB,uCAA2C;AAC3C,4DAA8B;AAE9B,SAAS,QAAQ,CAAC,KAAa;IAC9B,OAAO,KAAK;SACV,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED,MAAa,aAAa;IACjB,MAAM,CAAC;IACE,WAAW,CAAC;IAE7B,YAAY,UAAmB;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AC,0BAA0B,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;YAC3E,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;CACD;AAnSD,sCAmSC","sourcesContent":["import axios from 'axios';\nimport sharp from 'sharp';\nimport moment from 'moment';\nimport path from 'path';\nimport { getLibraries } from '../../index';\nimport mime from 'mime-types';\n\nfunction makeSlug(input: string): string {\n\treturn input\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, '-')\n\t\t.replace(/(^-|-$)/g, '');\n}\n\nexport class UploadService {\n\tprivate bucket;\n\tprivate readonly websiteName;\n\n\tconstructor(bucketName?: string) {\n\t\tif (!bucketName) {\n\t\t\tbucketName = 'lyxa-global';\n\t\t}\n\n\t\tthis.bucket = getLibraries().getFirebaseService().superApp.storage().bucket(bucketName);\n\t\tthis.websiteName = 'lyxa-' + getLibraries().getConfigurationService().options.tenet;\n\t}\n\n\t/**\n\t * Generates a unique filename using the original filename.\n\t */\n\tprivate generateFilename(originalFilename: string, extension?: string): string {\n\t\tconst nameWithoutExt = path.parse(originalFilename).name;\n\t\tconst newExtension = extension || path.extname(originalFilename);\n\t\tconst timestamp = moment().format('DDMMYYHmmss');\n\t\tconst randomId = Math.floor(Math.random() * 100);\n\t\tconst baseName = `${makeSlug(nameWithoutExt)}-${this.websiteName}-${timestamp}-${randomId}`;\n\t\treturn baseName + newExtension;\n\t}\n\n\t/**\n\t * Uploads an image buffer after processing it with Sharp.\n\t * An optional destinationPath can be provided (e.g., 'images/product.jpg').\n\t */\n\tasync uploadImage(buffer: Buffer, originalFilename: string): Promise<{ filename: string; url: string }> {\n\t\tconst newFilename = this.generateFilename(originalFilename);\n\t\tconst extension = path.extname(newFilename).toLowerCase();\n\t\tlet processedImage: sharp.Sharp;\n\t\tlet contentType: string;\n\t\tif (extension === '.png') {\n\t\t\tprocessedImage = sharp(buffer).png({ quality: 80 });\n\t\t\tcontentType = 'image/png';\n\t\t} else if (extension === '.webp') {\n\t\t\tprocessedImage = sharp(buffer).webp({ quality: 80 });\n\t\t\tcontentType = 'image/webp';\n\t\t} else {\n\t\t\tprocessedImage = sharp(buffer).jpeg({ quality: 80 });\n\t\t\tcontentType = 'image/jpeg';\n\t\t}\n\n\t\tconst file = this.bucket.file(newFilename);\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst blobStream = file.createWriteStream({\n\t\t\t\tresumable: false,\n\t\t\t\tcontentType,\n\t\t\t});\n\n\t\t\tblobStream.on('error', (err: Error) => {\n\t\t\t\treject(err);\n\t\t\t});\n\n\t\t\tblobStream.on('finish', async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait file.makePublic();\n\t\t\t\t\tconst publicUrl = `https://storage.googleapis.com/${this.bucket.name}/${file.name}`;\n\t\t\t\t\tresolve({ filename: file.name, url: publicUrl });\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tprocessedImage.pipe(blobStream);\n\t\t});\n\t}\n\n\t/**\n\t * Transcodes (resizes) an image buffer into multiple resolutions.\n\t * An optional destinationPrefix can be provided to force a specific path or filename base.\n\t *\n\t * For example, if destinationPrefix is 'images/product', then the original might be\n\t * uploaded as 'images/product.jpg' and the resized versions as 'images/product-480.jpg', etc.\n\t */\n\tasync transcodeImage(\n\t\tbuffer: Buffer,\n\t\toriginalFilename: string,\n\t\tresolutions: number[]\n\t): Promise<{\n\t\toriginalUrl: string;\n\t\tresizedResults: Array<{ resolution: number; url: string }>;\n\t}> {\n\t\tconst extension = path.extname(originalFilename);\n\t\tconst contentType = `image/${extension.replace('.', '') || 'jpeg'}`;\n\t\tconst timestamp = moment().format('DDMMYYHmmss');\n\t\tconst randomId = Math.floor(Math.random() * 100);\n\n\t\tconst baseFilename = `${makeSlug(path.parse(originalFilename).name)}-${this.websiteName}-${timestamp}-${randomId}`;\n\n\t\tconst originalFileName = `${baseFilename}${extension}`;\n\t\tconst originalUrl = await this.uploadBuffer(buffer, originalFileName, contentType);\n\n\t\tconst metadata = await sharp(buffer).metadata();\n\t\tconst isLandscape = metadata.width && metadata.height ? metadata.width > metadata.height : true;\n\n\t\tconst resizedResults = await Promise.all(\n\t\t\tresolutions.map(async resolution => {\n\t\t\t\tconst resizeOptions = isLandscape ? { width: resolution } : { height: resolution };\n\t\t\t\tconst formatKey = (extension.replace('.', '') || 'jpeg') as keyof sharp.FormatEnum;\n\t\t\t\tconst resizedBuffer = await sharp(buffer)\n\t\t\t\t\t.resize({\n\t\t\t\t\t\t...resizeOptions,\n\t\t\t\t\t\twithoutEnlargement: true,\n\t\t\t\t\t})\n\t\t\t\t\t.toFormat(formatKey, { quality: 80 })\n\t\t\t\t\t.toBuffer();\n\t\t\t\tconst resizedFilename = `${baseFilename}-${resolution}${extension}`;\n\t\t\t\tconst resizedUrl = await this.uploadBuffer(resizedBuffer, resizedFilename, contentType);\n\t\t\t\treturn { resolution, url: resizedUrl };\n\t\t\t})\n\t\t);\n\n\t\treturn { originalUrl, resizedResults };\n\t}\n\n\t/**\n\t * Helper function to upload a buffer to a specified filename.\n\t */\n\tprivate async uploadBuffer(buffer: Buffer, filename: string, contentType: string): Promise<string> {\n\t\tconst file = this.bucket.file(filename);\n\t\tawait file.save(buffer, {\n\t\t\tresumable: false,\n\t\t\tcontentType,\n\t\t});\n\t\tawait file.makePublic();\n\t\treturn `https://storage.googleapis.com/${this.bucket.name}/${file.name}`;\n\t}\n\n\tasync getListFiles(): Promise<Array<{ name: string; url: string }>> {\n\t\tconst [files] = await this.bucket.getFiles();\n\t\treturn files.map(file => ({\n\t\t\tname: file.name!,\n\t\t\turl: file.metadata.mediaLink!,\n\t\t}));\n\t}\n\n\tasync downloadFile(filename: string): Promise<Buffer> {\n\t\tconst file = this.bucket.file(filename);\n\t\tconst [buffer] = await file.download();\n\t\treturn buffer;\n\t}\n\n\tasync deleteFile(filename: string): Promise<void> {\n\t\tconst file = this.bucket.file(filename);\n\t\tconst [exists] = await file.exists();\n\t\tif (!exists) {\n\t\t\tthrow new Error('File does not exist.');\n\t\t}\n\t\tawait file.delete();\n\t}\n\n\tpublic extractFilenameFromUrl(url: string): string {\n\t\ttry {\n\t\t\tconst urlObj = new URL(url);\n\t\t\tconst pathParts = urlObj.pathname.split('/');\n\t\t\treturn decodeURIComponent(pathParts[pathParts.length - 1]);\n\t\t} catch (err) {\n\t\t\tthrow new Error(`Invalid URL: ${url}`);\n\t\t}\n\t}\n\n\tasync deleteFileByUrl(url: string): Promise<void> {\n\t\tconst filename = this.extractFilenameFromUrl(url);\n\t\tconst file = this.bucket.file(filename);\n\t\tconst [exists] = await file.exists();\n\t\tif (!exists) {\n\t\t\tthrow new Error('File does not exist.');\n\t\t}\n\t\tawait file.delete();\n\t}\n\n\tasync downloadImage(url: string): Promise<Buffer> {\n\t\tconst response = await axios.get(url, { responseType: 'arraybuffer' });\n\t\treturn Buffer.from(response.data, 'binary');\n\t}\n\n\t/**\n\t * Uploads a buffer to Google Cloud Storage and makes it public\n\t */\n\tprivate async uploadToGCS(\n\t\tbuffer: Buffer,\n\t\tfilename: string,\n\t\tcontentType: string\n\t): Promise<{ filename: string; url: string }> {\n\t\tconst file = this.bucket.file(filename);\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\t// Create a write stream to upload the file\n\t\t\tconst blobStream = file.createWriteStream({\n\t\t\t\tresumable: false,\n\t\t\t\tcontentType,\n\t\t\t});\n\n\t\t\tblobStream.on('error', reject);\n\n\t\t\tblobStream.on('finish', async () => {\n\t\t\t\ttry {\n\t\t\t\t\t// Make the file publicly accessible\n\t\t\t\t\tawait file.makePublic();\n\t\t\t\t\tconst publicUrl = `https://storage.googleapis.com/${this.bucket.name}/${file.name}`;\n\t\t\t\t\tresolve({ filename: file.name, url: publicUrl });\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Start uploading the buffer\n\t\t\tblobStream.end(buffer);\n\t\t});\n\t}\n\n\t/**\n\t * Uploads and converts an image to WebP format, resizes if needed, and uploads to GCS\n\t */\n\tasync uploadProcessedImageToWebp(\n\t\tbuffer: Buffer,\n\t\toriginalFilename: string,\n\t\toptions?: { quality?: number; width?: number; height?: number }\n\t): Promise<{ filename: string; url: string }> {\n\t\tconst newFilename = this.generateFilename(originalFilename, '.webp');\n\n\t\tlet width = options?.width;\n\t\tlet height = options?.height;\n\t\tconst quality = options?.quality ?? 80;\n\n\t\t// Get original image dimensions if width or height is missing\n\t\tif (!width || !height) {\n\t\t\tconst imageMetadata = await sharp(buffer).metadata();\n\t\t\twidth = width || imageMetadata.width;\n\t\t\theight = height || imageMetadata.height;\n\t\t}\n\n\t\t// Convert to WebP and resize\n\t\tconst processedImage: sharp.Sharp = sharp(buffer)\n\t\t\t.resize(width, height, { fit: 'inside' })\n\t\t\t.webp({ quality });\n\n\t\tconst file = this.bucket.file(newFilename);\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst blobStream = file.createWriteStream({\n\t\t\t\tresumable: false,\n\t\t\t\tcontentType: 'image/webp',\n\t\t\t});\n\n\t\t\tblobStream.on('error', (err: Error) => {\n\t\t\t\treject(err);\n\t\t\t});\n\n\t\t\tblobStream.on('finish', async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait file.makePublic();\n\t\t\t\t\tconst publicUrl = `https://storage.googleapis.com/${this.bucket.name}/${file.name}`;\n\t\t\t\t\tresolve({ filename: file.name, url: publicUrl });\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tprocessedImage.pipe(blobStream);\n\t\t});\n\t}\n\n\t/**\n\t * Uploads any supported file type to GCS and returns its public URL\n\t */\n\tasync uploadFile(\n\t\tbuffer: Buffer,\n\t\toriginalFilename: string,\n\t\toptions?: { quality?: number; width?: number; height?: number; withExtension?: boolean }\n\t): Promise<{ filename: string; url: string }> {\n\t\tconst newFilename = this.generateFilename(originalFilename);\n\t\tconst extension = path.extname(newFilename).toLowerCase();\n\n\t\t// Guess the MIME type using the mime-types library\n\t\tconst contentType = mime.lookup(extension) || 'application/octet-stream';\n\n\t\t// Special image handling (compression)\n\t\tif (contentType.startsWith('image/')) {\n\t\t\tif (options?.withExtension) {\n\t\t\t\treturn this.uploadImage(buffer, originalFilename);\n\t\t\t} else {\n\t\t\t\treturn this.uploadProcessedImageToWebp(buffer, originalFilename, options);\n\t\t\t}\n\t\t}\n\n\t\treturn this.uploadToGCS(buffer, newFilename, contentType);\n\t}\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/upload/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,kDAA0B;AAC1B,oDAA4B;AAC5B,gDAAwB;AACxB,uCAA2C;AAC3C,4DAA8B;AAE9B,SAAS,QAAQ,CAAC,KAAa;IAC9B,OAAO,KAAK;SACV,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED,MAAa,aAAa;IACjB,MAAM,CAAC;IACE,WAAW,CAAC;IAE7B,YAAY,UAAmB;QAC9B,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,UAAU,GAAG,aAAa,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,IAAA,oBAAY,GAAE,CAAC,kBAAkB,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACxF,IAAI,CAAC,WAAW,GAAG,OAAO,GAAG,IAAA,oBAAY,GAAE,CAAC,uBAAuB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACrF,CAAC;IAKO,gBAAgB,CAAC,gBAAwB,EAAE,SAAkB;QACpE,MAAM,cAAc,GAAG,cAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CA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B,CAAC,CAAC;YACnD,CAAC;iBAAM,CAAC;gBACP,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;YAC3E,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IAC3D,CAAC;CACD;AAjTD,sCAiTC","sourcesContent":["import axios from 'axios';\nimport sharp from 'sharp';\nimport moment from 'moment';\nimport path from 'path';\nimport { getLibraries } from '../../index';\nimport mime from 'mime-types';\n\nfunction makeSlug(input: string): string {\n\treturn input\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, '-')\n\t\t.replace(/(^-|-$)/g, '');\n}\n\nexport class UploadService {\n\tprivate bucket;\n\tprivate readonly websiteName;\n\n\tconstructor(bucketName?: string) {\n\t\tif (!bucketName) {\n\t\t\tbucketName = 'lyxa-global';\n\t\t}\n\n\t\tthis.bucket = getLibraries().getFirebaseService().superApp.storage().bucket(bucketName);\n\t\tthis.websiteName = 'lyxa-' + getLibraries().getConfigurationService().options.tenet;\n\t}\n\n\t/**\n\t * Generates a unique filename using the original filename.\n\t */\n\tprivate generateFilename(originalFilename: string, extension?: string): string {\n\t\tconst nameWithoutExt = path.parse(originalFilename).name;\n\t\tconst newExtension = extension || path.extname(originalFilename);\n\t\tconst timestamp = moment().format('DDMMYYHmmss');\n\t\tconst randomId = Math.floor(Math.random() * 100);\n\t\tconst baseName = `${makeSlug(nameWithoutExt)}-${this.websiteName}-${timestamp}-${randomId}`;\n\t\treturn baseName + newExtension;\n\t}\n\n\t/**\n\t * Uploads an image buffer after processing it with Sharp.\n\t * An optional destinationPath can be provided (e.g., 'images/product.jpg').\n\t */\n\tasync uploadImage(buffer: Buffer, originalFilename: string): Promise<{ filename: string; url: string }> {\n\t\tconst newFilename = this.generateFilename(originalFilename);\n\t\tconst extension = path.extname(newFilename).toLowerCase();\n\t\tlet processedImage: sharp.Sharp;\n\t\tlet contentType: string;\n\t\tif (extension === '.png') {\n\t\t\tprocessedImage = sharp(buffer).png({ quality: 80 });\n\t\t\tcontentType = 'image/png';\n\t\t} else if (extension === '.webp') {\n\t\t\tprocessedImage = sharp(buffer).webp({ quality: 80 });\n\t\t\tcontentType = 'image/webp';\n\t\t} else {\n\t\t\tprocessedImage = sharp(buffer).jpeg({ quality: 80 });\n\t\t\tcontentType = 'image/jpeg';\n\t\t}\n\n\t\tconst file = this.bucket.file(newFilename);\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst blobStream = file.createWriteStream({\n\t\t\t\tresumable: false,\n\t\t\t\tcontentType,\n\t\t\t});\n\n\t\t\tblobStream.on('error', (err: Error) => {\n\t\t\t\treject(err);\n\t\t\t});\n\n\t\t\tblobStream.on('finish', async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait file.makePublic();\n\t\t\t\t\tconst publicUrl = `https://storage.googleapis.com/${this.bucket.name}/${file.name}`;\n\t\t\t\t\tresolve({ filename: file.name, url: publicUrl });\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tprocessedImage.pipe(blobStream);\n\t\t});\n\t}\n\n\t/**\n\t * Transcodes (resizes) an image buffer into multiple resolutions.\n\t * An optional destinationPrefix can be provided to force a specific path or filename base.\n\t *\n\t * For example, if destinationPrefix is 'images/product', then the original might be\n\t * uploaded as 'images/product.jpg' and the resized versions as 'images/product-480.jpg', etc.\n\t */\n\tasync transcodeImage(\n\t\tbuffer: Buffer,\n\t\toriginalFilename: string,\n\t\tresolutions: number[]\n\t): Promise<{\n\t\toriginalUrl: string;\n\t\tresizedResults: Array<{ resolution: number; url: string }>;\n\t}> {\n\t\tconst extension = path.extname(originalFilename);\n\t\tconst contentType = `image/${extension.replace('.', '') || 'jpeg'}`;\n\t\tconst timestamp = moment().format('DDMMYYHmmss');\n\t\tconst randomId = Math.floor(Math.random() * 100);\n\n\t\tconst baseFilename = `${makeSlug(path.parse(originalFilename).name)}-${this.websiteName}-${timestamp}-${randomId}`;\n\n\t\tconst originalFileName = `${baseFilename}${extension}`;\n\t\tconst originalUrl = await this.uploadBuffer(buffer, originalFileName, contentType);\n\n\t\tconst metadata = await sharp(buffer).metadata();\n\t\tconst isLandscape = metadata.width && metadata.height ? metadata.width > metadata.height : true;\n\n\t\tconst resizedResults = await Promise.all(\n\t\t\tresolutions.map(async resolution => {\n\t\t\t\tconst resizeOptions = isLandscape ? { width: resolution } : { height: resolution };\n\t\t\t\tconst formatKey = (extension.replace('.', '') || 'jpeg') as keyof sharp.FormatEnum;\n\t\t\t\tconst resizedBuffer = await sharp(buffer)\n\t\t\t\t\t.resize({\n\t\t\t\t\t\t...resizeOptions,\n\t\t\t\t\t\twithoutEnlargement: true,\n\t\t\t\t\t})\n\t\t\t\t\t.toFormat(formatKey, { quality: 80 })\n\t\t\t\t\t.toBuffer();\n\t\t\t\tconst resizedFilename = `${baseFilename}-${resolution}${extension}`;\n\t\t\t\tconst resizedUrl = await this.uploadBuffer(resizedBuffer, resizedFilename, contentType);\n\t\t\t\treturn { resolution, url: resizedUrl };\n\t\t\t})\n\t\t);\n\n\t\treturn { originalUrl, resizedResults };\n\t}\n\n\t/**\n\t * Helper function to upload a buffer to a specified filename.\n\t */\n\tprivate async uploadBuffer(buffer: Buffer, filename: string, contentType: string): Promise<string> {\n\t\tconst file = this.bucket.file(filename);\n\t\tawait file.save(buffer, {\n\t\t\tresumable: false,\n\t\t\tcontentType,\n\t\t});\n\t\tawait file.makePublic();\n\t\treturn `https://storage.googleapis.com/${this.bucket.name}/${file.name}`;\n\t}\n\n\tasync getListFiles(): Promise<Array<{ name: string; url: string }>> {\n\t\tconst [files] = await this.bucket.getFiles();\n\t\treturn files.map(file => ({\n\t\t\tname: file.name!,\n\t\t\turl: file.metadata.mediaLink!,\n\t\t}));\n\t}\n\n\tasync downloadFile(filename: string): Promise<Buffer> {\n\t\tconst file = this.bucket.file(filename);\n\t\tconst [buffer] = await file.download();\n\t\treturn buffer;\n\t}\n\n\tasync deleteFile(filename: string): Promise<void> {\n\t\tconst file = this.bucket.file(filename);\n\t\tconst [exists] = await file.exists();\n\t\tif (!exists) {\n\t\t\tthrow new Error('File does not exist.');\n\t\t}\n\t\tawait file.delete();\n\t}\n\n\tasync getPublicUrlFromFilename(filename: string): Promise<{status: boolean, url: string}> {\n\t\tconst file = this.bucket.file(filename);\n\t\tconst [exists] = await file.exists();\n\n\t\tif (!exists) {\n\t\t\treturn {status: false, url: ''};\n\t\t}\n\n\t\treturn {\n\t\t\tstatus: true,\n\t\t\turl: `https://storage.googleapis.com/${this.bucket.name}/${filename}`\n\t\t};\n\t}\n\n\tpublic extractFilenameFromUrl(url: string): string {\n\t\ttry {\n\t\t\tconst urlObj = new URL(url);\n\t\t\tconst pathParts = urlObj.pathname.split('/');\n\t\t\treturn decodeURIComponent(pathParts[pathParts.length - 1]);\n\t\t} catch (err) {\n\t\t\tthrow new Error(`Invalid URL: ${url}`);\n\t\t}\n\t}\n\n\tasync deleteFileByUrl(url: string): Promise<void> {\n\t\tconst filename = this.extractFilenameFromUrl(url);\n\t\tconst file = this.bucket.file(filename);\n\t\tconst [exists] = await file.exists();\n\t\tif (!exists) {\n\t\t\tthrow new Error('File does not exist.');\n\t\t}\n\t\tawait file.delete();\n\t}\n\n\tasync downloadImage(url: string): Promise<Buffer> {\n\t\tconst response = await axios.get(url, { responseType: 'arraybuffer' });\n\t\treturn Buffer.from(response.data, 'binary');\n\t}\n\n\t/**\n\t * Uploads a buffer to Google Cloud Storage and makes it public\n\t */\n\tprivate async uploadToGCS(\n\t\tbuffer: Buffer,\n\t\tfilename: string,\n\t\tcontentType: string\n\t): Promise<{ filename: string; url: string }> {\n\t\tconst file = this.bucket.file(filename);\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\t// Create a write stream to upload the file\n\t\t\tconst blobStream = file.createWriteStream({\n\t\t\t\tresumable: false,\n\t\t\t\tcontentType,\n\t\t\t});\n\n\t\t\tblobStream.on('error', reject);\n\n\t\t\tblobStream.on('finish', async () => {\n\t\t\t\ttry {\n\t\t\t\t\t// Make the file publicly accessible\n\t\t\t\t\tawait file.makePublic();\n\t\t\t\t\tconst publicUrl = `https://storage.googleapis.com/${this.bucket.name}/${file.name}`;\n\t\t\t\t\tresolve({ filename: file.name, url: publicUrl });\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Start uploading the buffer\n\t\t\tblobStream.end(buffer);\n\t\t});\n\t}\n\n\t/**\n\t * Uploads and converts an image to WebP format, resizes if needed, and uploads to GCS\n\t */\n\tasync uploadProcessedImageToWebp(\n\t\tbuffer: Buffer,\n\t\toriginalFilename: string,\n\t\toptions?: { quality?: number; width?: number; height?: number }\n\t): Promise<{ filename: string; url: string }> {\n\t\tconst newFilename = this.generateFilename(originalFilename, '.webp');\n\n\t\tlet width = options?.width;\n\t\tlet height = options?.height;\n\t\tconst quality = options?.quality ?? 80;\n\n\t\t// Get original image dimensions if width or height is missing\n\t\tif (!width || !height) {\n\t\t\tconst imageMetadata = await sharp(buffer).metadata();\n\t\t\twidth = width || imageMetadata.width;\n\t\t\theight = height || imageMetadata.height;\n\t\t}\n\n\t\t// Convert to WebP and resize\n\t\tconst processedImage: sharp.Sharp = sharp(buffer)\n\t\t\t.resize(width, height, { fit: 'inside' })\n\t\t\t.webp({ quality });\n\n\t\tconst file = this.bucket.file(newFilename);\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst blobStream = file.createWriteStream({\n\t\t\t\tresumable: false,\n\t\t\t\tcontentType: 'image/webp',\n\t\t\t});\n\n\t\t\tblobStream.on('error', (err: Error) => {\n\t\t\t\treject(err);\n\t\t\t});\n\n\t\t\tblobStream.on('finish', async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait file.makePublic();\n\t\t\t\t\tconst publicUrl = `https://storage.googleapis.com/${this.bucket.name}/${file.name}`;\n\t\t\t\t\tresolve({ filename: file.name, url: publicUrl });\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tprocessedImage.pipe(blobStream);\n\t\t});\n\t}\n\n\t/**\n\t * Uploads any supported file type to GCS and returns its public URL\n\t */\n\tasync uploadFile(\n\t\tbuffer: Buffer,\n\t\toriginalFilename: string,\n\t\toptions?: { quality?: number; width?: number; height?: number; withExtension?: boolean, withOriginalFilename?: boolean }\n\t): Promise<{ filename: string; url: string }> {\n\t\tconst newFilename = options?.withOriginalFilename ? originalFilename : this.generateFilename(originalFilename);\n\t\tconst extension = path.extname(newFilename).toLowerCase();\n\n\t\t// Guess the MIME type using the mime-types library\n\t\tconst contentType = mime.lookup(extension) || 'application/octet-stream';\n\n\t\t// Special image handling (compression)\n\t\tif (contentType.startsWith('image/')) {\n\t\t\tif (options?.withExtension) {\n\t\t\t\treturn this.uploadImage(buffer, originalFilename);\n\t\t\t} else {\n\t\t\t\treturn this.uploadProcessedImageToWebp(buffer, originalFilename, options);\n\t\t\t}\n\t\t}\n\n\t\treturn this.uploadToGCS(buffer, newFilename, contentType);\n\t}\n}\n"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.1.9
25
+ Version: 1.1.11
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -304,15 +304,27 @@ export declare const DurationSchema: z.ZodObject<{
304
304
  export declare const NormalHourSchema: z.ZodObject<{
305
305
  day: z.ZodNativeEnum<typeof WeekDay>;
306
306
  status: z.ZodNativeEnum<typeof WorkStatus>;
307
- openingHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
308
- start: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
309
- end: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
307
+ openingHours: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodEffects<z.ZodObject<{
308
+ start: z.ZodEffects<z.ZodString, string, string>;
309
+ end: z.ZodEffects<z.ZodString, string, string>;
310
310
  }, "strip", z.ZodTypeAny, {
311
311
  end: string;
312
312
  start: string;
313
313
  }, {
314
314
  end: string;
315
315
  start: string;
316
+ }>, {
317
+ end: string;
318
+ start: string;
319
+ }, {
320
+ end: string;
321
+ start: string;
322
+ }>, {
323
+ end: string;
324
+ start: string;
325
+ }, {
326
+ end: string;
327
+ start: string;
316
328
  }>, "many">>;
317
329
  }, "strip", z.ZodTypeAny, {
318
330
  day: WeekDay;
@@ -332,15 +344,27 @@ export declare const NormalHourSchema: z.ZodObject<{
332
344
  export declare const HolidayHourSchema: z.ZodObject<{
333
345
  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>;
334
346
  status: z.ZodNativeEnum<typeof HolidayWorkStatus>;
335
- closingHour: z.ZodObject<{
336
- start: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
337
- end: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
347
+ closingHour: z.ZodEffects<z.ZodEffects<z.ZodObject<{
348
+ start: z.ZodEffects<z.ZodString, string, string>;
349
+ end: z.ZodEffects<z.ZodString, string, string>;
338
350
  }, "strip", z.ZodTypeAny, {
339
351
  end: string;
340
352
  start: string;
341
353
  }, {
342
354
  end: string;
343
355
  start: string;
356
+ }>, {
357
+ end: string;
358
+ start: string;
359
+ }, {
360
+ end: string;
361
+ start: string;
362
+ }>, {
363
+ end: string;
364
+ start: string;
365
+ }, {
366
+ end: string;
367
+ start: string;
344
368
  }>;
345
369
  }, "strip", z.ZodTypeAny, {
346
370
  date: Date;
@@ -361,15 +385,27 @@ export declare const WorkHourSettingSchema: z.ZodObject<{
361
385
  normalHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
362
386
  day: z.ZodNativeEnum<typeof WeekDay>;
363
387
  status: z.ZodNativeEnum<typeof WorkStatus>;
364
- openingHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
365
- start: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
366
- end: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
388
+ openingHours: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodEffects<z.ZodObject<{
389
+ start: z.ZodEffects<z.ZodString, string, string>;
390
+ end: z.ZodEffects<z.ZodString, string, string>;
367
391
  }, "strip", z.ZodTypeAny, {
368
392
  end: string;
369
393
  start: string;
370
394
  }, {
371
395
  end: string;
372
396
  start: string;
397
+ }>, {
398
+ end: string;
399
+ start: string;
400
+ }, {
401
+ end: string;
402
+ start: string;
403
+ }>, {
404
+ end: string;
405
+ start: string;
406
+ }, {
407
+ end: string;
408
+ start: string;
373
409
  }>, "many">>;
374
410
  }, "strip", z.ZodTypeAny, {
375
411
  day: WeekDay;
@@ -389,15 +425,27 @@ export declare const WorkHourSettingSchema: z.ZodObject<{
389
425
  holidayHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
390
426
  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>;
391
427
  status: z.ZodNativeEnum<typeof HolidayWorkStatus>;
392
- closingHour: z.ZodObject<{
393
- start: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
394
- end: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
428
+ closingHour: z.ZodEffects<z.ZodEffects<z.ZodObject<{
429
+ start: z.ZodEffects<z.ZodString, string, string>;
430
+ end: z.ZodEffects<z.ZodString, string, string>;
395
431
  }, "strip", z.ZodTypeAny, {
396
432
  end: string;
397
433
  start: string;
398
434
  }, {
399
435
  end: string;
400
436
  start: string;
437
+ }>, {
438
+ end: string;
439
+ start: string;
440
+ }, {
441
+ end: string;
442
+ start: string;
443
+ }>, {
444
+ end: string;
445
+ start: string;
446
+ }, {
447
+ end: string;
448
+ start: string;
401
449
  }>;
402
450
  }, "strip", z.ZodTypeAny, {
403
451
  date: Date;
@@ -87,9 +87,22 @@ exports.DurationSchema = zod_1.z.object({
87
87
  start: global_validation_1.ZodValidation.date('Start'),
88
88
  end: global_validation_1.ZodValidation.date('End').optional(),
89
89
  });
90
- const StartEndTimeSchema = zod_1.z.object({
91
- start: global_validation_1.ZodValidation.string('Start'),
92
- end: global_validation_1.ZodValidation.string('End'),
90
+ const TimeStringSchema = zod_1.z
91
+ .string()
92
+ .regex(/^(?:[01]\d|2[0-3])[0-5]\d$/, 'Time must be in HHmm format (e.g., 0930)')
93
+ .refine(time => parseInt(time) <= 2359, { message: 'Invalid time, must be less than or equal to 2359' });
94
+ const StartEndTimeSchema = zod_1.z
95
+ .object({
96
+ start: TimeStringSchema,
97
+ end: TimeStringSchema,
98
+ })
99
+ .refine(data => parseInt(data.end) > parseInt(data.start), {
100
+ message: 'End time must be later than start time',
101
+ path: ['end'],
102
+ })
103
+ .refine(data => parseInt(data.end) <= 2359, {
104
+ message: 'End time cannot exceed 11:59 PM',
105
+ path: ['end'],
93
106
  });
94
107
  exports.NormalHourSchema = zod_1.z.object({
95
108
  day: global_validation_1.ZodValidation.enumType(enum_1.WeekDay, 'Day'),
@@ -1 +1 @@
1
- {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAA8F;AAM9F,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG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AAc,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACvE,CAAC,CAAC;AAGU,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IAClC,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC9E,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,OAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACvE,CAAC,CAAC;AAIH,MAAM,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,iCAAa,CAAC,GAAG,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE,iCAAa,CAAC,MAAM,CAAC,SAAS,CAAC;CACxC,CAAC,CAAC;AAEU,QAAA,2BAA2B,GAAG,IAAA,4BAAoB,EAAC,mBAAmB,CAAC,CAAC;AAGxE,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,QAAQ,EAAE,iCAAa,CAAC,MAAM,CAAC,WAAW,CAAC;IAC3C,MAAM,EAAE,iCAAa,CAAC,QAAQ,CAAC,iBAAU,EAAE,QAAQ,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport { ActionType, GeoLocationType, HolidayWorkStatus, WeekDay, WorkStatus } from '../enum';\nimport { mongoose } from '@typegoose/typegoose';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema: z.ZodType<any> = z.lazy(() =>\n\tz.object({\n\t\tpath: z.string(), // required\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tmatch: z.record(z.string(), z.any()).optional(),\n\t\toptions: z\n\t\t\t.object({\n\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\tlimit: z.number().optional(),\n\t\t\t\tskip: z.number().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n);\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City'),\n\tstate: ZodValidation.string('State').optional(),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\nexport type AddressDTO = DTO<typeof AddressSchema>;\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\nexport type UserAddressDTO = DTO<typeof UserAddressSchema>;\n\n/**\n * Regular order address validation schema.\n * Provides validation for address-related fields.\n *\n */\nexport const RegularOrderAddressSchema = UserAddressSchema.extend({\n\t_id: ZodValidation.objectId('ID of the user address'),\n});\nexport type RegularOrderAddressDTO = DTO<typeof RegularOrderAddressSchema>;\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\nexport type CourierAddressDTO = DTO<typeof CourierAddressSchema>;\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\nconst StartEndTimeSchema = z.object({\n\tstart: ZodValidation.string('Start'),\n\tend: ZodValidation.string('End'),\n});\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema).default([]),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\nexport type PaginatedDTO<T> = {\n\tmetadata: DTO<typeof metadataSchema>;\n\tdocuments: T[];\n};\n\nexport type ResponseDTO<T> = {\n\tsuccess: boolean;\n\tmessage: string;\n\tdata?: T;\n};\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('New position'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n\n/**\n * Schema validation get by id\n */\nexport const GetByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\nexport type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;\n\nexport const GetOneQuerySchema = z.object({\n\tquery: MongoQuerySchema.optional(),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\n\nexport type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;\n\nconst ShareableLinkSchema = z.object({\n\tlink: ZodValidation.url('Link'),\n\tmessage: ZodValidation.string('Message'),\n});\n\nexport const ShareableLinkResponseSchema = createResponseSchema(ShareableLinkSchema);\nexport type ShareableLinkDTO = DTO<typeof ShareableLinkSchema>;\n\nexport const UpdateFcmTokenInputSchema = z.object({\n\tfcmToken: ZodValidation.string('Fcm token'),\n\taction: ZodValidation.enumType(ActionType, 'Action'),\n});\nexport type UpdateFcmTokenInputDTO = DTO<typeof UpdateFcmTokenInputSchema>;\n"]}
1
+ {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAA8F;AAM9F,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACpE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAClD,CAAC;AAKF,MAAM,oBAAoB,GAAG,OAAC,CAA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CAAC,WAAW,CAAC;IAC3C,MAAM,EAAE,iCAAa,CAAC,QAAQ,CAAC,iBAAU,EAAE,QAAQ,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport { ActionType, GeoLocationType, HolidayWorkStatus, WeekDay, WorkStatus } from '../enum';\nimport { mongoose } from '@typegoose/typegoose';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema: z.ZodType<any> = z.lazy(() =>\n\tz.object({\n\t\tpath: z.string(), // required\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tmatch: z.record(z.string(), z.any()).optional(),\n\t\toptions: z\n\t\t\t.object({\n\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\tlimit: z.number().optional(),\n\t\t\t\tskip: z.number().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n);\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City'),\n\tstate: ZodValidation.string('State').optional(),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\nexport type AddressDTO = DTO<typeof AddressSchema>;\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\nexport type UserAddressDTO = DTO<typeof UserAddressSchema>;\n\n/**\n * Regular order address validation schema.\n * Provides validation for address-related fields.\n *\n */\nexport const RegularOrderAddressSchema = UserAddressSchema.extend({\n\t_id: ZodValidation.objectId('ID of the user address'),\n});\nexport type RegularOrderAddressDTO = DTO<typeof RegularOrderAddressSchema>;\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\nexport type CourierAddressDTO = DTO<typeof CourierAddressSchema>;\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\n\nconst TimeStringSchema = z\n\t.string()\n\t.regex(/^(?:[01]\\d|2[0-3])[0-5]\\d$/, 'Time must be in HHmm format (e.g., 0930)')\n\t.refine(time => parseInt(time) <= 2359, { message: 'Invalid time, must be less than or equal to 2359' });\n\nconst StartEndTimeSchema = z\n\t.object({\n\t\tstart: TimeStringSchema,\n\t\tend: TimeStringSchema,\n\t})\n\t.refine(data => parseInt(data.end) > parseInt(data.start), {\n\t\tmessage: 'End time must be later than start time',\n\t\tpath: ['end'], \n\t})\n\t.refine(data => parseInt(data.end) <= 2359, {\n\t\tmessage: 'End time cannot exceed 11:59 PM',\n\t\tpath: ['end'],\n\t});\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema).default([]),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\nexport type PaginatedDTO<T> = {\n\tmetadata: DTO<typeof metadataSchema>;\n\tdocuments: T[];\n};\n\nexport type ResponseDTO<T> = {\n\tsuccess: boolean;\n\tmessage: string;\n\tdata?: T;\n};\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('New position'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n\n/**\n * Schema validation get by id\n */\nexport const GetByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\nexport type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;\n\nexport const GetOneQuerySchema = z.object({\n\tquery: MongoQuerySchema.optional(),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\n\nexport type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;\n\nconst ShareableLinkSchema = z.object({\n\tlink: ZodValidation.url('Link'),\n\tmessage: ZodValidation.string('Message'),\n});\n\nexport const ShareableLinkResponseSchema = createResponseSchema(ShareableLinkSchema);\nexport type ShareableLinkDTO = DTO<typeof ShareableLinkSchema>;\n\nexport const UpdateFcmTokenInputSchema = z.object({\n\tfcmToken: ZodValidation.string('Fcm token'),\n\taction: ZodValidation.enumType(ActionType, 'Action'),\n});\nexport type UpdateFcmTokenInputDTO = DTO<typeof UpdateFcmTokenInputSchema>;\n"]}
@@ -304,15 +304,27 @@ export declare const DurationSchema: z.ZodObject<{
304
304
  export declare const NormalHourSchema: z.ZodObject<{
305
305
  day: z.ZodNativeEnum<typeof WeekDay>;
306
306
  status: z.ZodNativeEnum<typeof WorkStatus>;
307
- openingHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
308
- start: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
309
- end: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
307
+ openingHours: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodEffects<z.ZodObject<{
308
+ start: z.ZodEffects<z.ZodString, string, string>;
309
+ end: z.ZodEffects<z.ZodString, string, string>;
310
310
  }, "strip", z.ZodTypeAny, {
311
311
  end: string;
312
312
  start: string;
313
313
  }, {
314
314
  end: string;
315
315
  start: string;
316
+ }>, {
317
+ end: string;
318
+ start: string;
319
+ }, {
320
+ end: string;
321
+ start: string;
322
+ }>, {
323
+ end: string;
324
+ start: string;
325
+ }, {
326
+ end: string;
327
+ start: string;
316
328
  }>, "many">>;
317
329
  }, "strip", z.ZodTypeAny, {
318
330
  status: WorkStatus;
@@ -332,15 +344,27 @@ export declare const NormalHourSchema: z.ZodObject<{
332
344
  export declare const HolidayHourSchema: z.ZodObject<{
333
345
  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>;
334
346
  status: z.ZodNativeEnum<typeof HolidayWorkStatus>;
335
- closingHour: z.ZodObject<{
336
- start: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
337
- end: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
347
+ closingHour: z.ZodEffects<z.ZodEffects<z.ZodObject<{
348
+ start: z.ZodEffects<z.ZodString, string, string>;
349
+ end: z.ZodEffects<z.ZodString, string, string>;
338
350
  }, "strip", z.ZodTypeAny, {
339
351
  end: string;
340
352
  start: string;
341
353
  }, {
342
354
  end: string;
343
355
  start: string;
356
+ }>, {
357
+ end: string;
358
+ start: string;
359
+ }, {
360
+ end: string;
361
+ start: string;
362
+ }>, {
363
+ end: string;
364
+ start: string;
365
+ }, {
366
+ end: string;
367
+ start: string;
344
368
  }>;
345
369
  }, "strip", z.ZodTypeAny, {
346
370
  status: HolidayWorkStatus;
@@ -361,15 +385,27 @@ export declare const WorkHourSettingSchema: z.ZodObject<{
361
385
  normalHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
362
386
  day: z.ZodNativeEnum<typeof WeekDay>;
363
387
  status: z.ZodNativeEnum<typeof WorkStatus>;
364
- openingHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
365
- start: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
366
- end: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
388
+ openingHours: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodEffects<z.ZodObject<{
389
+ start: z.ZodEffects<z.ZodString, string, string>;
390
+ end: z.ZodEffects<z.ZodString, string, string>;
367
391
  }, "strip", z.ZodTypeAny, {
368
392
  end: string;
369
393
  start: string;
370
394
  }, {
371
395
  end: string;
372
396
  start: string;
397
+ }>, {
398
+ end: string;
399
+ start: string;
400
+ }, {
401
+ end: string;
402
+ start: string;
403
+ }>, {
404
+ end: string;
405
+ start: string;
406
+ }, {
407
+ end: string;
408
+ start: string;
373
409
  }>, "many">>;
374
410
  }, "strip", z.ZodTypeAny, {
375
411
  status: WorkStatus;
@@ -389,15 +425,27 @@ export declare const WorkHourSettingSchema: z.ZodObject<{
389
425
  holidayHours: z.ZodDefault<z.ZodArray<z.ZodObject<{
390
426
  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>;
391
427
  status: z.ZodNativeEnum<typeof HolidayWorkStatus>;
392
- closingHour: z.ZodObject<{
393
- start: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
394
- end: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
428
+ closingHour: z.ZodEffects<z.ZodEffects<z.ZodObject<{
429
+ start: z.ZodEffects<z.ZodString, string, string>;
430
+ end: z.ZodEffects<z.ZodString, string, string>;
395
431
  }, "strip", z.ZodTypeAny, {
396
432
  end: string;
397
433
  start: string;
398
434
  }, {
399
435
  end: string;
400
436
  start: string;
437
+ }>, {
438
+ end: string;
439
+ start: string;
440
+ }, {
441
+ end: string;
442
+ start: string;
443
+ }>, {
444
+ end: string;
445
+ start: string;
446
+ }, {
447
+ end: string;
448
+ start: string;
401
449
  }>;
402
450
  }, "strip", z.ZodTypeAny, {
403
451
  status: HolidayWorkStatus;
@@ -87,9 +87,22 @@ exports.DurationSchema = zod_1.z.object({
87
87
  start: global_validation_1.ZodValidation.date('Start'),
88
88
  end: global_validation_1.ZodValidation.date('End').optional(),
89
89
  });
90
- const StartEndTimeSchema = zod_1.z.object({
91
- start: global_validation_1.ZodValidation.string('Start'),
92
- end: global_validation_1.ZodValidation.string('End'),
90
+ const TimeStringSchema = zod_1.z
91
+ .string()
92
+ .regex(/^(?:[01]\d|2[0-3])[0-5]\d$/, 'Time must be in HHmm format (e.g., 0930)')
93
+ .refine(time => parseInt(time) <= 2359, { message: 'Invalid time, must be less than or equal to 2359' });
94
+ const StartEndTimeSchema = zod_1.z
95
+ .object({
96
+ start: TimeStringSchema,
97
+ end: TimeStringSchema,
98
+ })
99
+ .refine(data => parseInt(data.end) > parseInt(data.start), {
100
+ message: 'End time must be later than start time',
101
+ path: ['end'],
102
+ })
103
+ .refine(data => parseInt(data.end) <= 2359, {
104
+ message: 'End time cannot exceed 11:59 PM',
105
+ path: ['end'],
93
106
  });
94
107
  exports.NormalHourSchema = zod_1.z.object({
95
108
  day: global_validation_1.ZodValidation.enumType(enum_1.WeekDay, 'Day'),
@@ -1 +1 @@
1
- {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAA8F;AAM9F,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACpE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAClD,CAAC;AAKF,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,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,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C,MAAM,CAAC,SAAS,CAAC;CACxC,CAAC,CAAC;AAEU,QAAA,2BAA2B,GAAG,IAAA,4BAAoB,EAAC,mBAAmB,CAAC,CAAC;AAGxE,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,QAAQ,EAAE,iCAAa,CAAC,MAAM,CAAC,WAAW,CAAC;IAC3C,MAAM,EAAE,iCAAa,CAAC,QAAQ,CAAC,iBAAU,EAAE,QAAQ,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport { ActionType, GeoLocationType, HolidayWorkStatus, WeekDay, WorkStatus } from '../enum';\nimport { mongoose } from '@typegoose/typegoose';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema: z.ZodType<any> = z.lazy(() =>\n\tz.object({\n\t\tpath: z.string(), // required\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tmatch: z.record(z.string(), z.any()).optional(),\n\t\toptions: z\n\t\t\t.object({\n\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\tlimit: z.number().optional(),\n\t\t\t\tskip: z.number().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n);\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City'),\n\tstate: ZodValidation.string('State').optional(),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\nexport type AddressDTO = DTO<typeof AddressSchema>;\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\nexport type UserAddressDTO = DTO<typeof UserAddressSchema>;\n\n/**\n * Regular order address validation schema.\n * Provides validation for address-related fields.\n *\n */\nexport const RegularOrderAddressSchema = UserAddressSchema.extend({\n\t_id: ZodValidation.objectId('ID of the user address'),\n});\nexport type RegularOrderAddressDTO = DTO<typeof RegularOrderAddressSchema>;\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\nexport type CourierAddressDTO = DTO<typeof CourierAddressSchema>;\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\nconst StartEndTimeSchema = z.object({\n\tstart: ZodValidation.string('Start'),\n\tend: ZodValidation.string('End'),\n});\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema).default([]),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\nexport type PaginatedDTO<T> = {\n\tmetadata: DTO<typeof metadataSchema>;\n\tdocuments: T[];\n};\n\nexport type ResponseDTO<T> = {\n\tsuccess: boolean;\n\tmessage: string;\n\tdata?: T;\n};\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('New position'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n\n/**\n * Schema validation get by id\n */\nexport const GetByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\nexport type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;\n\nexport const GetOneQuerySchema = z.object({\n\tquery: MongoQuerySchema.optional(),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\n\nexport type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;\n\nconst ShareableLinkSchema = z.object({\n\tlink: ZodValidation.url('Link'),\n\tmessage: ZodValidation.string('Message'),\n});\n\nexport const ShareableLinkResponseSchema = createResponseSchema(ShareableLinkSchema);\nexport type ShareableLinkDTO = DTO<typeof ShareableLinkSchema>;\n\nexport const UpdateFcmTokenInputSchema = z.object({\n\tfcmToken: ZodValidation.string('Fcm token'),\n\taction: ZodValidation.enumType(ActionType, 'Action'),\n});\nexport type UpdateFcmTokenInputDTO = DTO<typeof UpdateFcmTokenInputSchema>;\n"]}
1
+ {"version":3,"file":"common-validation.js","sourceRoot":"/","sources":["utilities/validation/common-validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,2DAAyD;AACzD,kCAA8F;AAM9F,MAAM,gBAAgB,GAAmC,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACpE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAClD,CAAC;AAKF,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,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,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,OAAC,CAAC,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C,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC9E,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,OAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACvE,CAAC,CAAC;AAIH,MAAM,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,iCAAa,CAAC,GAAG,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE,iCAAa,CAAC,MAAM,CAAC,SAAS,CAAC;CACxC,CAAC,CAAC;AAEU,QAAA,2BAA2B,GAAG,IAAA,4BAAoB,EAAC,mBAAmB,CAAC,CAAC;AAGxE,QAAA,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,QAAQ,EAAE,iCAAa,CAAC,MAAM,CAAC,WAAW,CAAC;IAC3C,MAAM,EAAE,iCAAa,CAAC,QAAQ,CAAC,iBAAU,EAAE,QAAQ,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from './global-validation';\nimport { ActionType, GeoLocationType, HolidayWorkStatus, WeekDay, WorkStatus } from '../enum';\nimport { mongoose } from '@typegoose/typegoose';\n\n/**\n * Define MongoDB query schema (fields + operators) using lazy evaluation to avoid circular dependency\n */\nconst MongoQuerySchema: z.ZodType<Record<string, any>> = z.lazy(() =>\n\tz.record(z.union([z.any(), MongoOperatorsSchema]))\n);\n\n/**\n * Define allowed MongoDB query operators\n */\nconst MongoOperatorsSchema = z.object({\n\t$eq: z.any().optional(),\n\t$ne: z.any().optional(),\n\t$gt: z.any().optional(),\n\t$gte: z.any().optional(),\n\t$lt: z.any().optional(),\n\t$lte: z.any().optional(),\n\t$in: z.array(z.any()).optional(),\n\t$nin: z.array(z.any()).optional(),\n\t$exists: z.boolean().optional(),\n\t$regex: z.string().optional(),\n\t$and: z.array(MongoQuerySchema).optional(),\n\t$or: z.array(MongoQuerySchema).optional(),\n\t$not: MongoQuerySchema.optional(),\n\t$nor: z.array(MongoQuerySchema).optional(),\n});\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nconst populateSchema: z.ZodType<any> = z.lazy(() =>\n\tz.object({\n\t\tpath: z.string(), // required\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tmatch: z.record(z.string(), z.any()).optional(),\n\t\toptions: z\n\t\t\t.object({\n\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\tlimit: z.number().optional(),\n\t\t\t\tskip: z.number().optional(),\n\t\t\t})\n\t\t\t.optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t})\n);\n\n/**\n * Define the filter schema using MongoQuerySchema\n */\nexport const FilterSchema = z\n\t.object({\n\t\tsize: z\n\t\t\t.number()\n\t\t\t.min(1, { message: 'Size must be greater than 0.' })\n\t\t\t.max(100, { message: 'Size cannot exceed 100.' })\n\t\t\t.optional()\n\t\t\t.default(10),\n\t\tpage: z.number().min(1, { message: 'Page number must be at least 1.' }).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t\tquery: MongoQuerySchema.optional(),\n\t\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\t\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n\t\tsearch: z.object({ searchKey: z.string(), searchFields: z.array(z.string()).optional() }).optional(),\n\t})\n\t.optional();\n\n/**\n * Infer TypeScript type from Zod schema\n */\nexport type FilterDTO = z.infer<typeof FilterSchema>;\n\n/**\n * Define String schema\n */\nexport const StringSchema = z.string().min(1, 'String cannot be empty').max(255, 'String is too long');\n\n/**\n * Common address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: AddressSchema\n * });\n * ```\n */\nexport const AddressSchema = z.object({\n\taddress: ZodValidation.string('Address'),\n\tdescription: ZodValidation.string('Description').optional(),\n\tcity: ZodValidation.string('City'),\n\tstate: ZodValidation.string('State').optional(),\n\tcountry: ZodValidation.string('Country'),\n\tlocation: z.object({\n\t\ttype: ZodValidation.enumType(GeoLocationType, 'GeoLocationType').default(GeoLocationType.POINT),\n\t\tcoordinates: z.tuple([\n\t\t\tZodValidation.number('Longitude', { min: -180, max: 180 }),\n\t\t\tZodValidation.number('Latitude', { min: -90, max: 90 }),\n\t\t]),\n\t}),\n\tlatitude: ZodValidation.number('Latitude', { min: -90, max: 90 }),\n\tlongitude: ZodValidation.number('Longitude', { min: -180, max: 180 }),\n\tzone: ZodValidation.objectId('Zone').optional(),\n});\nexport type AddressDTO = DTO<typeof AddressSchema>;\n\n/**\n * Common user address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const userSchema = z.object({\n * name: z.string(),\n * address: UserAddressSchema\n * });\n * ```\n */\nexport const UserAddressSchema = AddressSchema.extend({\n\taddressLabel: ZodValidation.string('Address Label'),\n\tapartment: ZodValidation.string('Apartment'),\n\tbuildingName: ZodValidation.string('Building Name'),\n\tdeliveryOption: ZodValidation.string('Delivery Option').optional(),\n\tinstructions: ZodValidation.string('Instructions').optional(),\n});\nexport type UserAddressDTO = DTO<typeof UserAddressSchema>;\n\n/**\n * Regular order address validation schema.\n * Provides validation for address-related fields.\n *\n */\nexport const RegularOrderAddressSchema = UserAddressSchema.extend({\n\t_id: ZodValidation.objectId('ID of the user address'),\n});\nexport type RegularOrderAddressDTO = DTO<typeof RegularOrderAddressSchema>;\n\n/**\n * Common courier address validation schema that can be reused across models.\n * Provides validation for address-related fields.\n *\n * @example\n * ```typescript\n * const courierAddressSchema = z.object({\n * name: z.string(),\n * address: courierAddressSchema\n * });\n * ```\n */\nexport const CourierAddressSchema = UserAddressSchema.extend({\n\tname: ZodValidation.string('Name'),\n\tphoneNumber: ZodValidation.string('Phone Number'),\n});\nexport type CourierAddressDTO = DTO<typeof CourierAddressSchema>;\n\n/**\n * Common duration validation schema that can be reused across models.\n * Provides validation for duration fields.\n *\n * @example\n * ```typescript\n * const subscriptionSchema = z.object({\n * fee: z.number(),\n * duration: DurationSchema\n * });\n * ```\n */\nexport const DurationSchema = z.object({\n\tstart: ZodValidation.date('Start'),\n\tend: ZodValidation.date('End').optional(),\n});\n\n/**\n * Common Work Hour validation schema that can be reused across models.\n * Provides validation for workHourSetting fields.\n *\n * @example\n * ```typescript\n * const settingSchema = z.object({\n * vat: z.number(),\n * workHourSetting: WorkHourSettingSchema\n * });\n * ```\n */\n\nconst TimeStringSchema = z\n\t.string()\n\t.regex(/^(?:[01]\\d|2[0-3])[0-5]\\d$/, 'Time must be in HHmm format (e.g., 0930)')\n\t.refine(time => parseInt(time) <= 2359, { message: 'Invalid time, must be less than or equal to 2359' });\n\nconst StartEndTimeSchema = z\n\t.object({\n\t\tstart: TimeStringSchema,\n\t\tend: TimeStringSchema,\n\t})\n\t.refine(data => parseInt(data.end) > parseInt(data.start), {\n\t\tmessage: 'End time must be later than start time',\n\t\tpath: ['end'], \n\t})\n\t.refine(data => parseInt(data.end) <= 2359, {\n\t\tmessage: 'End time cannot exceed 11:59 PM',\n\t\tpath: ['end'],\n\t});\n\nexport const NormalHourSchema = z.object({\n\tday: ZodValidation.enumType(WeekDay, 'Day'),\n\tstatus: ZodValidation.enumType(WorkStatus, 'Status'),\n\topeningHours: ZodValidation.array(StartEndTimeSchema).default([]),\n});\n\nexport const HolidayHourSchema = z.object({\n\tdate: ZodValidation.date('Date'),\n\tstatus: ZodValidation.enumType(HolidayWorkStatus, 'Status'),\n\tclosingHour: StartEndTimeSchema,\n});\n\nexport const WorkHourSettingSchema = z.object({\n\tnormalHours: ZodValidation.array(NormalHourSchema).default([]),\n\tholidayHours: ZodValidation.array(HolidayHourSchema).default([]),\n});\n\n/**\n * Schema for validating user login credentials.\n * This schema ensures that the provided email and password meet the required validation rules.\n *\n * @example\n * ```typescript\n * const credentials = {\n * email: 'user@example.com',\n * password: 'securePassword123',\n * };\n * ```\n */\nexport const LoginSchema = z.object({\n\temail: ZodValidation.email('Email', {\n\t\trequiredMessage: 'Please enter a valid email address.',\n\t\tinvalidMessage: 'Please enter a valid email address.',\n\t}),\n\tpassword: ZodValidation.string('Password', { requiredMessage: 'Please enter password' }),\n});\nexport type LoginDTO = DTO<typeof LoginSchema>;\n\nconst metadataSchema = z.object({\n\tpage: ZodValidation.number(),\n\tsize: ZodValidation.number(),\n\ttotalElements: ZodValidation.number(),\n\ttotalPages: ZodValidation.number(),\n});\nexport const createPaginatedSchema = <T>(documentSchema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tmetadata: metadataSchema.optional(),\n\t\tdocuments: ZodValidation.array(documentSchema),\n\t});\n\nexport const createResponseSchema = <T>(schema: z.ZodSchema<T>) =>\n\tz.object({\n\t\tsuccess: ZodValidation.boolean(),\n\t\tmessage: ZodValidation.string(),\n\t\tdata: z.union([createPaginatedSchema(schema), schema]).optional(),\n\t});\n\nexport type PaginatedDTO<T> = {\n\tmetadata: DTO<typeof metadataSchema>;\n\tdocuments: T[];\n};\n\nexport type ResponseDTO<T> = {\n\tsuccess: boolean;\n\tmessage: string;\n\tdata?: T;\n};\n\n/**\n * Schema for validating token data, typically used for authentication.\n * This schema ensures that the provided access token and refresh token are valid strings.\n *\n * @example\n * ```typescript\n * const tokens = {\n * accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * };\n * ```\n */\nexport const TokenSchema = z.object({\n\taccessToken: ZodValidation.string('AccessToken'),\n\trefreshToken: ZodValidation.string('RefreshToken'),\n});\n\n/**\n * Schema validation for sorting order\n */\nexport const UpdateSortingOrderSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tnewPosition: ZodValidation.number('New position'),\n});\nexport type UpdateSortingOrderDTO = DTO<typeof UpdateSortingOrderSchema>;\n\n/**\n * Schema validation for delete\n */\nexport const DeleteSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tsoftDelete: ZodValidation.boolean('Soft Delete').default(true),\n});\nexport type DeleteDTO = DTO<typeof DeleteSchema>;\n\n/**\n * Schema validation for Id\n */\nexport const IdSchema = ZodValidation.objectId();\n\n/**\n * Schema validation get by id\n */\nexport const GetByIdInputSchema = z.object({\n\t_id: ZodValidation.objectId('_id'),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\nexport type GetByIdInputDTO = DTO<typeof GetByIdInputSchema>;\n\nexport const GetOneQuerySchema = z.object({\n\tquery: MongoQuerySchema.optional(),\n\tselect: z.record(z.string(), z.union([z.literal(0), z.literal(1)])).optional(),\n\tpopulate: z.union([populateSchema, z.array(populateSchema)]).optional(),\n});\n\nexport type GetOneQueryDTO = DTO<typeof GetOneQuerySchema>;\n\nconst ShareableLinkSchema = z.object({\n\tlink: ZodValidation.url('Link'),\n\tmessage: ZodValidation.string('Message'),\n});\n\nexport const ShareableLinkResponseSchema = createResponseSchema(ShareableLinkSchema);\nexport type ShareableLinkDTO = DTO<typeof ShareableLinkSchema>;\n\nexport const UpdateFcmTokenInputSchema = z.object({\n\tfcmToken: ZodValidation.string('Fcm token'),\n\taction: ZodValidation.enumType(ActionType, 'Action'),\n});\nexport type UpdateFcmTokenInputDTO = DTO<typeof UpdateFcmTokenInputSchema>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",