Initial commit

This commit is contained in:
Jose Selesan
2026-04-08 22:53:11 -03:00
commit 9ae270609d
179 changed files with 28096 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
import { z } from 'zod'
const nonNegativeInt = z.int().nonnegative()
const positiveInt = z.int().positive()
export const planFeatureFlagsSchema = z.object({
onlinePayments: z.boolean().default(false),
publicBookingPage: z.boolean().default(false),
advancedReports: z.boolean().default(false),
whatsappReminders: z.boolean().default(false),
})
export const planRulesV1Schema = z.object({
version: z.literal('v1'),
limits: z.object({
maxCourts: positiveInt,
maxBookingsPerDay: positiveInt,
maxActiveUsers: positiveInt.optional(),
maxConcurrentBookingsPerSlot: positiveInt.optional(),
}),
policies: z
.object({
maxAdvanceBookingDays: positiveInt.optional(),
minCancellationNoticeHours: nonNegativeInt.optional(),
allowOverbooking: z.boolean().default(false),
})
.default({ allowOverbooking: false }),
features: planFeatureFlagsSchema.default({
onlinePayments: false,
publicBookingPage: false,
advancedReports: false,
whatsappReminders: false,
}),
})
export const planRulesSchema = z.discriminatedUnion('version', [planRulesV1Schema])
export const planSchema = z.object({
code: z.string().trim().min(1).max(10),
name: z.string().trim().min(1).max(30),
price: z.number().nonnegative(),
lastUpdatedAt: z.string().datetime(),
rules: planRulesSchema,
})
export const planSummarySchema = z.object({
code: z.string().trim().min(1).max(10),
name: z.string().trim().min(1).max(30),
price: z.number().nonnegative(),
})
export type PlanFeatureFlags = z.infer<typeof planFeatureFlagsSchema>
export type PlanRulesV1 = z.infer<typeof planRulesV1Schema>
export type PlanRules = z.infer<typeof planRulesSchema>
export type Plan = z.infer<typeof planSchema>
export type PlanSummary = z.infer<typeof planSummarySchema>