Initial commit
This commit is contained in:
98
packages/api-contract/src/onboarding.ts
Normal file
98
packages/api-contract/src/onboarding.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
const otpSchema = z
|
||||
.string()
|
||||
.trim()
|
||||
.regex(/^\d{6}$/, 'El OTP debe tener 6 digitos numericos.')
|
||||
|
||||
export const onboardingStartSchema = z.object({
|
||||
fullName: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(2, 'El nombre debe tener al menos 2 caracteres.')
|
||||
.max(80, 'El nombre no puede superar los 80 caracteres.'),
|
||||
email: z.email('Ingresa un email valido.'),
|
||||
})
|
||||
|
||||
export const onboardingVerifyOtpSchema = z.object({
|
||||
requestId: z.uuid('El requestId de onboarding no es valido.'),
|
||||
otp: otpSchema,
|
||||
})
|
||||
|
||||
export const onboardingResendOtpSchema = z.object({
|
||||
requestId: z.uuid('El requestId de onboarding no es valido.'),
|
||||
})
|
||||
|
||||
export const onboardingCompleteSchema = z.object({
|
||||
onboardingRequestId: z.uuid('El onboardingRequestId no es valido.'),
|
||||
password: z
|
||||
.string()
|
||||
.min(8, 'La contrasena debe tener al menos 8 caracteres.')
|
||||
.max(72, 'La contrasena no puede superar los 72 caracteres.'),
|
||||
complexName: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(3, 'El nombre del complejo debe tener al menos 3 caracteres.')
|
||||
.max(120, 'El nombre del complejo no puede superar los 120 caracteres.'),
|
||||
physicalAddress: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(5, 'La direccion debe tener al menos 5 caracteres.')
|
||||
.max(200, 'La direccion no puede superar los 200 caracteres.'),
|
||||
planCode: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, 'Debes seleccionar un plan.')
|
||||
.max(10, 'El plan seleccionado no es valido.'),
|
||||
})
|
||||
|
||||
export const onboardingStartResponseSchema = z.object({
|
||||
message: z.string(),
|
||||
requestId: z.uuid(),
|
||||
email: z.email(),
|
||||
expiresAt: z.string().datetime(),
|
||||
cooldownSeconds: z.int().nonnegative(),
|
||||
})
|
||||
|
||||
export const onboardingVerifyOtpResponseSchema = z.object({
|
||||
message: z.string(),
|
||||
verified: z.boolean(),
|
||||
requestId: z.uuid(),
|
||||
email: z.email().nullable(),
|
||||
expiresAt: z.string().datetime().nullable(),
|
||||
remainingAttempts: z.int().nonnegative(),
|
||||
cooldownSeconds: z.int().nonnegative(),
|
||||
})
|
||||
|
||||
export const onboardingResendOtpResponseSchema = z.object({
|
||||
message: z.string(),
|
||||
requestId: z.uuid(),
|
||||
email: z.email(),
|
||||
expiresAt: z.string().datetime(),
|
||||
cooldownSeconds: z.int().nonnegative(),
|
||||
remainingAttempts: z.int().nonnegative(),
|
||||
})
|
||||
|
||||
export const onboardingCompleteResponseSchema = z.object({
|
||||
message: z.string(),
|
||||
userId: z.uuid(),
|
||||
complexId: z.uuid(),
|
||||
complexSlug: z.string(),
|
||||
supabaseUserId: z.uuid(),
|
||||
})
|
||||
|
||||
export type OnboardingStartInput = z.infer<typeof onboardingStartSchema>
|
||||
export type OnboardingVerifyOtpInput = z.infer<typeof onboardingVerifyOtpSchema>
|
||||
export type OnboardingResendOtpInput = z.infer<typeof onboardingResendOtpSchema>
|
||||
export type OnboardingCompleteInput = z.infer<typeof onboardingCompleteSchema>
|
||||
|
||||
export type OnboardingStartResponse = z.infer<typeof onboardingStartResponseSchema>
|
||||
export type OnboardingVerifyOtpResponse = z.infer<
|
||||
typeof onboardingVerifyOtpResponseSchema
|
||||
>
|
||||
export type OnboardingResendOtpResponse = z.infer<
|
||||
typeof onboardingResendOtpResponseSchema
|
||||
>
|
||||
export type OnboardingCompleteResponse = z.infer<
|
||||
typeof onboardingCompleteResponseSchema
|
||||
>
|
||||
Reference in New Issue
Block a user