/**
* Zod schemas for Location endpoints
*/
import { z } from 'zod';
import { PaginationSchema, ResponseFormatSchema, SortDirectionSchema, IdSchema, NameFilterSchema, OrganizationIdFilterSchema } from './common.js';
/**
* List locations input schema
*/
export const ListLocationsSchema = z.object({
...PaginationSchema.shape,
response_format: ResponseFormatSchema,
organization_id: OrganizationIdFilterSchema,
name: NameFilterSchema,
city: z.string().max(255).optional()
.describe('Filter by city'),
region_id: z.number().int().positive().optional()
.describe('Filter by region ID'),
country_id: z.number().int().positive().optional()
.describe('Filter by country ID'),
psa_id: z.string().optional()
.describe('Filter by PSA integration ID'),
sort: z.enum(['name', 'id', 'updated_at', 'created_at'])
.default('name')
.describe('Field to sort by'),
sort_direction: SortDirectionSchema
}).strict();
export type ListLocationsInput = z.infer<typeof ListLocationsSchema>;
/**
* Get location by ID schema
*/
export const GetLocationSchema = z.object({
id: IdSchema,
response_format: ResponseFormatSchema
}).strict();
export type GetLocationInput = z.infer<typeof GetLocationSchema>;
/**
* Create location schema
*/
export const CreateLocationSchema = z.object({
organization_id: z.number().int().positive()
.describe('Organization ID (required)'),
name: z.string().min(1).max(255)
.describe('Location name (required)'),
primary: z.boolean().optional()
.describe('Is this the primary location'),
address_1: z.string().max(255).optional()
.describe('Address line 1'),
address_2: z.string().max(255).optional()
.describe('Address line 2'),
city: z.string().max(255).optional()
.describe('City'),
postal_code: z.string().max(20).optional()
.describe('Postal/ZIP code'),
region_id: z.number().int().positive().optional()
.describe('Region ID (state/province)'),
country_id: z.number().int().positive().optional()
.describe('Country ID'),
phone: z.string().max(50).optional()
.describe('Phone number'),
fax: z.string().max(50).optional()
.describe('Fax number'),
notes: z.string().max(10000).optional()
.describe('Notes'),
response_format: ResponseFormatSchema
}).strict();
export type CreateLocationInput = z.infer<typeof CreateLocationSchema>;
/**
* Update location schema
*/
export const UpdateLocationSchema = z.object({
id: IdSchema,
organization_id: z.number().int().positive().optional()
.describe('Organization ID'),
name: z.string().min(1).max(255).optional()
.describe('Location name'),
primary: z.boolean().optional()
.describe('Is this the primary location'),
address_1: z.string().max(255).optional().nullable()
.describe('Address line 1'),
address_2: z.string().max(255).optional().nullable()
.describe('Address line 2'),
city: z.string().max(255).optional().nullable()
.describe('City'),
postal_code: z.string().max(20).optional().nullable()
.describe('Postal/ZIP code'),
region_id: z.number().int().positive().optional().nullable()
.describe('Region ID (state/province)'),
country_id: z.number().int().positive().optional().nullable()
.describe('Country ID'),
phone: z.string().max(50).optional().nullable()
.describe('Phone number'),
fax: z.string().max(50).optional().nullable()
.describe('Fax number'),
notes: z.string().max(10000).optional().nullable()
.describe('Notes'),
response_format: ResponseFormatSchema
}).strict();
export type UpdateLocationInput = z.infer<typeof UpdateLocationSchema>;