@lyxa.ai/types 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.
package/README.md CHANGED
@@ -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
 
package/package.json CHANGED
@@ -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,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,OAA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C,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,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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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 */\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"]}