@@ -2,7 +2,10 @@ import { z } from 'zod';
22import { fromZodError } from 'zod-validation-error' ;
33import { FathomApiError } from './http' ;
44
5- // Common validation schemas
5+ /**
6+ * Pagination schema
7+ * This schema validates the pagination parameters for API requests.
8+ */
69export const paginationSchema : z . ZodObject < {
710 limit : z . ZodOptional < z . ZodNumber > ;
811 starting_after : z . ZodOptional < z . ZodString > ;
@@ -13,7 +16,10 @@ export const paginationSchema: z.ZodObject<{
1316 ending_before : z . string ( ) . optional ( ) ,
1417} ) . strict ( ) ;
1518
16- // Site validation schemas
19+ /**
20+ * Site schema
21+ * This schema validates the site data for creating a site.
22+ */
1723export const createSiteSchema : z . ZodEffects < z . ZodObject < {
1824 name : z . ZodString ;
1925 sharing : z . ZodOptional < z . ZodEnum < [ "none" , "private" , "public" ] > > ;
@@ -32,6 +38,10 @@ export const createSiteSchema: z.ZodEffects<z.ZodObject<{
3238 path : [ 'share_password' ] ,
3339} ) ;
3440
41+ /**
42+ * Site schema
43+ * This schema validates the optional fields for updating a site.
44+ */
3545export const updateSiteSchema : z . ZodEffects < z . ZodObject < {
3646 name : z . ZodOptional < z . ZodString > ;
3747 sharing : z . ZodOptional < z . ZodEnum < [ "none" , "private" , "public" ] > > ;
@@ -50,13 +60,20 @@ export const updateSiteSchema: z.ZodEffects<z.ZodObject<{
5060 path : [ 'share_password' ] ,
5161} ) ;
5262
53- // Event validation schemas
63+ /**
64+ * Event schema
65+ * This schema validates the event data for creating an event.
66+ */
5467export const createEventSchema : z . ZodObject < {
5568 name : z . ZodString ;
5669} > = z . object ( {
5770 name : z . string ( ) . min ( 1 ) . max ( 255 ) ,
5871} ) . strict ( ) ;
5972
73+ /**
74+ * Update event schema
75+ * This schema validates the event data for updating an event.
76+ */
6077export const updateEventSchema : z . ZodObject < {
6178 name : z . ZodString ;
6279} > = z . object ( {
@@ -76,6 +93,10 @@ const aggregationFilterSchema: z.ZodObject<{
7693 value : z . string ( ) ,
7794} ) . strict ( ) ;
7895
96+ /**
97+ * Aggregation report validation schema
98+ * This schema validates the parameters for an aggregation report.
99+ */
79100export const aggregationParamsSchema : z . ZodObject < {
80101 entity : z . ZodEnum < [ "pageview" , "event" ] > ;
81102 entity_id : z . ZodString ;
@@ -106,7 +127,10 @@ export const aggregationParamsSchema: z.ZodObject<{
106127 filters : z . array ( aggregationFilterSchema ) . optional ( ) ,
107128} ) . strict ( ) ;
108129
109- // Current visitors validation schema
130+ /**
131+ * Current visitors validation schema
132+ * This schema validates the parameters for retrieving current visitors at a site.
133+ */
110134export const currentVisitorsParamsSchema : z . ZodObject < {
111135 site_id : z . ZodString ;
112136 detailed : z . ZodOptional < z . ZodBoolean > ;
@@ -115,7 +139,10 @@ export const currentVisitorsParamsSchema: z.ZodObject<{
115139 detailed : z . boolean ( ) . optional ( ) ,
116140} ) . strict ( ) ;
117141
118- // Client options validation
142+ /**
143+ * Client options schema
144+ * This schema validates the options for creating a client.
145+ */
119146export const clientOptionsSchema : z . ZodObject < {
120147 token : z . ZodString ;
121148 version : z . ZodOptional < z . ZodEnum < [ "v1" ] > > ;
@@ -150,5 +177,14 @@ export function validate<T>(
150177}
151178
152179// Rename exports inline to match the names expected by other files
180+ /**
181+ * Aggregation schema
182+ * @alias aggregationParamsSchema
183+ */
153184export const aggregationSchema = aggregationParamsSchema ;
185+
186+ /**
187+ * Current visitors schema
188+ * @alias currentVisitorsParamsSchema
189+ */
154190export const currentVisitorsSchema = currentVisitorsParamsSchema ;
0 commit comments