"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.queryParamsSchema = exports.filterParamsSchema = exports.paginatedResponseSchema = exports.paginationParamsSchema = exports.apiResponseSchema = exports.apiErrorResponseSchema = exports.apiSuccessResponseSchema = exports.subscriptionBillingCycleEnum = exports.billingCycleEnum = exports.categoryEnum = exports.priorityEnum = exports.statusEnum = exports.genderEnum = exports.percentageSchema = exports.moneyAmountSchema = exports.dateSchema = exports.timestampSchema = exports.currencyCodeSchema = exports.countryCodeSchema = exports.phoneSchema = exports.nameSchema = exports.passwordSchema = exports.emailSchema = void 0; const zod_1 = require("zod"); exports.emailSchema = zod_1.z .string() .email("Please enter a valid email address") .toLowerCase() .trim(); exports.passwordSchema = zod_1.z .string() .min(8, "Password must be at least 8 characters") .regex(/[A-Z]/, "Password must contain at least one uppercase letter") .regex(/[a-z]/, "Password must contain at least one lowercase letter") .regex(/[0-9]/, "Password must contain at least one number") .regex(/[^A-Za-z0-9]/, "Password must contain at least one special character"); exports.nameSchema = zod_1.z.string().min(1, "Name is required").max(100, "Name must be less than 100 characters").trim(); exports.phoneSchema = zod_1.z .string() .regex(/^[+]?[0-9\s\-()]{7,20}$/u, "Please enter a valid phone number") .trim(); exports.countryCodeSchema = zod_1.z.string().length(2, "Country code must be 2 characters"); exports.currencyCodeSchema = zod_1.z.string().length(3, "Currency code must be 3 characters"); exports.timestampSchema = zod_1.z.string().datetime("Invalid timestamp format"); exports.dateSchema = zod_1.z.string().date("Invalid date format"); exports.moneyAmountSchema = zod_1.z.number().int().nonnegative("Amount must be non-negative"); exports.percentageSchema = zod_1.z.number().min(0).max(100, "Percentage must be between 0 and 100"); exports.genderEnum = zod_1.z.enum(["male", "female", "other"]); exports.statusEnum = zod_1.z.enum(["active", "inactive", "pending", "suspended"]); exports.priorityEnum = zod_1.z.enum(["low", "medium", "high", "urgent"]); exports.categoryEnum = zod_1.z.enum(["technical", "billing", "account", "general"]); exports.billingCycleEnum = zod_1.z.enum(["Monthly", "Quarterly", "Annually", "Onetime", "Free"]); exports.subscriptionBillingCycleEnum = zod_1.z.enum([ "Monthly", "Quarterly", "Semi-Annually", "Annually", "Biennially", "Triennially", "One-time", "Free", ]); const apiSuccessResponseSchema = (dataSchema) => zod_1.z.object({ success: zod_1.z.literal(true), data: dataSchema, }); exports.apiSuccessResponseSchema = apiSuccessResponseSchema; exports.apiErrorResponseSchema = zod_1.z.object({ success: zod_1.z.literal(false), error: zod_1.z.object({ code: zod_1.z.string(), message: zod_1.z.string(), details: zod_1.z.unknown().optional(), }), }); const apiResponseSchema = (dataSchema) => zod_1.z.discriminatedUnion("success", [ (0, exports.apiSuccessResponseSchema)(dataSchema), exports.apiErrorResponseSchema, ]); exports.apiResponseSchema = apiResponseSchema; exports.paginationParamsSchema = zod_1.z.object({ page: zod_1.z.coerce.number().int().positive().optional().default(1), limit: zod_1.z.coerce.number().int().positive().max(100).optional().default(20), offset: zod_1.z.coerce.number().int().nonnegative().optional(), }); const paginatedResponseSchema = (itemSchema) => zod_1.z.object({ items: zod_1.z.array(itemSchema), total: zod_1.z.number().int().nonnegative(), page: zod_1.z.number().int().positive(), limit: zod_1.z.number().int().positive(), hasMore: zod_1.z.boolean(), }); exports.paginatedResponseSchema = paginatedResponseSchema; exports.filterParamsSchema = zod_1.z.object({ search: zod_1.z.string().optional(), sortBy: zod_1.z.string().optional(), sortOrder: zod_1.z.enum(["asc", "desc"]).optional(), }); exports.queryParamsSchema = exports.paginationParamsSchema.merge(exports.filterParamsSchema); //# sourceMappingURL=schema.js.map