import {z} from 'zod' export type CreateApiCustomermanagerFetchCXCustomerMasterExtensionNameArgs = {output?: ('json' | 'xls' | 'csv' | 'pdf') | undefined, useColumnNames?: ('true' | 'false') | undefined, body: {endRow?: number | undefined, oldValues: unknown, operationType?: string | undefined, startRow?: number | undefined, textMatchStyle?: string | undefined, data?: ({_constructor?: string | undefined, operator?: string | undefined, criteria?: (Array<{fieldName?: string | undefined, operator?: string | undefined, value?: string | undefined}>) | undefined}) | undefined, sortBy?: Array> | undefined}}; export type CreateApiCustomermanagerFetchCXCustomerMasterExtensionNameOptions = {baseUrl?: string | undefined, basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const cX3 = z.object({typedId: z.string().optional(), createdBy: z.number().int().optional(), lastUpdateDate: z.string().optional(), name: z.string().max(255).optional(), customerId: z.string().max(255).optional(), attribute1: z.unknown(), attribute3: z.unknown(), attribute2: z.unknown(), version: z.number().int().optional(), createDate: z.string().optional(), lastUpdateBy: z.number().int().optional()}); export const cX6 = z.object({typedId: z.string().optional(), lastUpdateDate: z.string().optional(), version: z.number().int().optional(), attribute5: z.string().max(255).optional(), createdBy: z.number().int().optional(), attribute4: z.string().max(255).optional(), attribute6: z.string().max(255).optional(), name: z.string().max(255).optional(), customerId: z.string().max(255).optional(), attribute1: z.string().max(255).optional(), attribute3: z.string().max(255).optional(), attribute2: z.string().max(255).optional(), createDate: z.string().optional(), lastUpdateBy: z.number().int().optional()}); export const cX8 = z.object({typedId: z.string().optional(), lastUpdateDate: z.string().optional(), version: z.number().int().optional(), attribute8: z.string().max(255).optional(), attribute5: z.string().max(255).optional(), createdBy: z.number().int().optional(), attribute4: z.string().max(255).optional(), attribute7: z.string().max(255).optional(), attribute6: z.string().max(255).optional(), name: z.string().max(255).optional(), customerId: z.string().max(255).optional(), attribute1: z.string().max(255).optional(), attribute3: z.string().max(255).optional(), attribute2: z.string().max(255).optional(), createDate: z.string().optional(), lastUpdateBy: z.number().int().optional()}); export const cX10 = z.object({typedId: z.string().optional(), lastUpdateDate: z.string().optional(), version: z.number().int().optional(), attribute9: z.string().max(255).optional(), attribute8: z.string().max(255).optional(), attribute5: z.string().max(255).optional(), createdBy: z.number().int().optional(), attribute4: z.string().max(255).optional(), attribute7: z.string().max(255).optional(), attribute6: z.string().max(255).optional(), name: z.string().max(255).optional(), customerId: z.string().max(255).optional(), attribute1: z.string().max(255).optional(), attribute3: z.string().max(255).optional(), attribute2: z.string().max(255).optional(), attribute10: z.string().max(255).optional(), createDate: z.string().optional(), lastUpdateBy: z.number().int().optional()}); export const cX20 = z.object({typedId: z.string().optional(), attribute19: z.string().max(255).optional(), attribute18: z.string().max(255).optional(), attribute17: z.string().max(255).optional(), lastUpdateDate: z.string().optional(), attribute16: z.string().max(255).optional(), attribute15: z.string().max(255).optional(), customerId: z.string().max(255).optional(), attribute20: z.string().max(255).optional(), createDate: z.string().optional(), version: z.number().int().optional(), attribute9: z.string().max(255).optional(), attribute8: z.string().max(255).optional(), attribute5: z.string().max(255).optional(), createdBy: z.number().int().optional(), attribute4: z.string().max(255).optional(), attribute7: z.string().max(255).optional(), attribute6: z.string().max(255).optional(), name: z.string().max(255).optional(), attribute1: z.string().max(255).optional(), attribute14: z.string().max(255).optional(), attribute13: z.string().max(255).optional(), attribute3: z.string().max(255).optional(), attribute12: z.string().max(255).optional(), attribute2: z.string().max(255).optional(), attribute11: z.string().max(255).optional(), attribute10: z.string().max(255).optional(), lastUpdateBy: z.number().int().optional()}); export const cX30 = z.object({typedId: z.string().optional(), attribute19: z.string().max(255).optional(), attribute18: z.string().max(255).optional(), attribute17: z.string().max(255).optional(), lastUpdateDate: z.string().optional(), attribute16: z.string().max(255).optional(), attribute15: z.string().max(255).optional(), customerId: z.string().max(255).optional(), attribute25: z.string().max(255).optional(), attribute24: z.string().max(255).optional(), attribute23: z.string().max(255).optional(), attribute22: z.string().max(255).optional(), attribute21: z.string().max(255).optional(), attribute20: z.string().max(255).optional(), createDate: z.string().optional(), attribute29: z.string().max(255).optional(), attribute28: z.string().max(255).optional(), attribute27: z.string().max(255).optional(), attribute26: z.string().max(255).optional(), version: z.number().int().optional(), attribute9: z.string().max(255).optional(), attribute8: z.string().max(255).optional(), attribute5: z.string().max(255).optional(), createdBy: z.number().int().optional(), attribute4: z.string().max(255).optional(), attribute7: z.string().max(255).optional(), attribute6: z.string().max(255).optional(), name: z.string().max(255).optional(), attribute1: z.string().max(255).optional(), attribute14: z.string().max(255).optional(), attribute13: z.string().max(255).optional(), attribute3: z.string().max(255).optional(), attribute12: z.string().max(255).optional(), attribute2: z.string().max(255).optional(), attribute11: z.string().max(255).optional(), attribute10: z.string().max(255).optional(), attribute30: z.string().max(255).optional(), lastUpdateBy: z.number().int().optional()}); export const cX50 = z.object({typedId: z.string().optional(), attribute39: z.string().max(70).nullable().optional(), lastUpdateDate: z.string().optional(), attribute38: z.string().max(70).nullable().optional(), attribute37: z.string().max(70).nullable().optional(), attribute47: z.string().max(70).nullable().optional(), attribute46: z.string().max(70).nullable().optional(), attribute45: z.string().max(70).nullable().optional(), attribute44: z.string().max(70).nullable().optional(), attribute43: z.string().max(70).nullable().optional(), attribute42: z.string().max(70).nullable().optional(), attribute41: z.string().max(70).nullable().optional(), attribute40: z.string().max(70).nullable().optional(), attribute49: z.string().max(70).nullable().optional(), attribute48: z.string().max(70).nullable().optional(), version: z.number().int().optional(), attribute9: z.string().max(70).nullable().optional(), attribute50: z.string().max(70).nullable().optional(), attribute8: z.string().max(70).nullable().optional(), attribute5: z.unknown(), attribute4: z.string().max(70).nullable().optional(), attribute7: z.string().max(70).nullable().optional(), attribute6: z.string().max(70).nullable().optional(), name: z.string().max(255).optional(), attribute1: z.string().max(70).nullable().optional(), attribute14: z.string().max(70).nullable().optional(), attribute13: z.string().max(70).nullable().optional(), attribute3: z.string().max(70).nullable().optional(), attribute12: z.string().max(70).nullable().optional(), attribute2: z.string().max(70).nullable().optional(), attribute11: z.string().max(70).nullable().optional(), attribute10: z.string().max(70).nullable().optional(), attribute19: z.string().max(70).nullable().optional(), attribute18: z.string().max(70).nullable().optional(), attribute17: z.string().max(70).nullable().optional(), attribute16: z.string().max(70).nullable().optional(), attribute15: z.string().max(70).nullable().optional(), customerId: z.string().max(255).optional(), attribute25: z.string().max(70).nullable().optional(), attribute24: z.string().max(70).nullable().optional(), attribute23: z.string().max(70).nullable().optional(), attribute22: z.string().max(70).nullable().optional(), attribute21: z.string().max(70).nullable().optional(), attribute20: z.string().max(70).nullable().optional(), createDate: z.string().optional(), attribute29: z.string().max(70).nullable().optional(), attribute28: z.string().max(70).nullable().optional(), attribute27: z.string().max(70).nullable().optional(), attribute26: z.string().max(70).nullable().optional(), createdBy: z.number().int().optional(), attribute36: z.string().max(70).nullable().optional(), attribute35: z.string().max(70).nullable().optional(), attribute34: z.string().max(70).nullable().optional(), attribute33: z.string().max(70).nullable().optional(), attribute32: z.string().max(70).nullable().optional(), attribute31: z.string().max(70).nullable().optional(), attribute30: z.string().max(70).nullable().optional(), lastUpdateBy: z.number().int().optional()}); export const createApiCustomermanagerFetchCXCustomerMasterExtensionNameResponse = z.object({response: z.object({node: z.string().optional(), data: z.array(z.union([cX3, cX6, cX8, cX10, cX20, cX30, cX50])).optional(), endRow: z.number().int().optional(), totalRows: z.number().int().optional(), status: z.number().int().optional()}).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * List Customer Extension Objects * * POST /customermanager.fetch/*/CX/{CustomerMasterExtensionName} * * Also accepts auth: X-PriceFx-jwt */ export const createApiCustomermanagerFetchCXCustomerMasterExtensionName = async (args: CreateApiCustomermanagerFetchCXCustomerMasterExtensionNameArgs, options?: CreateApiCustomermanagerFetchCXCustomerMasterExtensionNameOptions) => { const {baseUrl = "https://companynode.pricefx.com/pricefx/companypartition", fetch: fetchFn = fetch, basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.output != null) query.append("output", String(args.output)) if (args.useColumnNames != null) query.append("useColumnNames", String(args.useColumnNames)) if (basic !== undefined) headers.set('authorization', `Basic ${btoa(`${basic.username}:${basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/customermanager.fetch/*/CX/${encodeURIComponent(String(args.CustomerMasterExtensionName))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiCustomermanagerFetchCXCustomerMasterExtensionNameResponse, await res.json()) };