UNPKG

@simpleapps-com/augur-api

Version:

TypeScript client library for Augur microservices API endpoints

99 lines 4.14 kB
import { z } from 'zod'; import { BaseResponseSchema, BaseGetParamsSchema } from '../../../core/schemas'; // Customer record schema - based on Customer.json export const CustomerSchema = z.object({ customerId: z.coerce.number(), companyId: z.string().max(8), customerName: z.string().max(255).nullable(), class1Id: z.string().max(8).nullable(), class2Id: z.string().max(8).nullable(), class3Id: z.string().max(8).nullable(), class4Id: z.string().max(8).nullable(), class5Id: z.string().max(8).nullable(), webEnabledFlag: z.string().max(1), deleteFlag: z.string().max(1), salesRepId: z.string().max(16).nullable(), poNoRequired: z.string().max(1), termsId: z.string().max(2).nullable(), taxableFlag: z.string().max(1), termsDesc: z.string().nullable(), userDefined: z.object({}).passthrough(), // Allows any additional properties }); export const CustomerListParamsSchema = BaseGetParamsSchema.extend({ class5Id: z.string().optional(), limit: z.coerce.number().optional(), offset: z.coerce.number().optional(), orderBy: z.string().optional(), q: z.string().optional(), }); export const CustomerLookupParamsSchema = BaseGetParamsSchema.extend({ q: z.string(), limit: z.coerce.number().optional(), offset: z.coerce.number().optional(), }); // Customer lookup record schema - based on Customer.json export const CustomerLookupSchema = z.object({ customerId: z.coerce.number(), customerName: z.string().max(255).nullable(), }); // Customer contact record schema - based on Customer.json export const CustomerContactSchema = z.object({ id: z.string(), emailAddress: z.string().nullable(), firstName: z.string(), lastName: z.string(), addressId: z.coerce.number(), addressClass5Id: z.string().nullable(), }); // Pagination options schema - based on Customer.json export const PaginationOptionsSchema = z.object({ limit: z.coerce.number().min(1).default(10), offset: z.coerce.number().min(0).default(0), filterList: z .object({ delete_flag: z.array(z.string()).optional(), customer_type_cd: z.coerce.number().optional(), }) .passthrough(), // Allow additional filters }); // Web allowance schema - based on Contacts.json export const WebAllowanceSchema = z.object({ webAllowance: z.number(), orderStartDate: z.string().nullable(), // Y-m-d format or null id: z.string(), customerId: z.coerce.number(), }); // Salesrep customer schema - based on Contacts.json export const SalesrepCustomerSchema = z.object({ customerId: z.coerce.number(), companyId: z.string().max(8), customerName: z.string().max(255).nullable(), class1Id: z.string().max(8).nullable(), class2Id: z.string().max(8).nullable(), class3Id: z.string().max(8).nullable(), class4Id: z.string().max(8).nullable(), class5Id: z.string().max(8).nullable(), webEnabledFlag: z.string().max(1), deleteFlag: z.string().max(1), salesRepId: z.string().max(16).nullable(), poNoRequired: z.string().max(1), termsId: z.string().max(2).nullable(), taxableFlag: z.string().max(1), termsDesc: z.string().nullable(), userDefined: z.object({}).passthrough(), }); // Data refresh schemas export const DataRefreshResponseSchema = z.object({ message: z.string(), timestamp: z.string(), jobId: z.string(), }); // Response schemas using BaseResponseSchema (8-field format) export const CustomerListResponseSchema = BaseResponseSchema(z.array(CustomerSchema)); export const CustomerResponseSchema = BaseResponseSchema(CustomerSchema); export const CustomerLookupResponseSchema = BaseResponseSchema(z.array(CustomerLookupSchema)); export const CustomerContactsResponseSchema = BaseResponseSchema(z.array(CustomerContactSchema)); export const SalesrepCustomersResponseSchema = BaseResponseSchema(z.array(SalesrepCustomerSchema)); export const WebAllowanceResponseSchema = BaseResponseSchema(WebAllowanceSchema); export const DataRefreshResponseSchemaResponse = BaseResponseSchema(DataRefreshResponseSchema); //# sourceMappingURL=customers.js.map