import {z} from 'zod' export type PricelistItem = {typedId?: string | undefined, listLabel?: string | undefined, resultPrice?: (number | null) | undefined, priceChangePct?: (number | null) | undefined, attribute83?: (string | null) | undefined, attribute82?: (string | null) | undefined, attribute81?: (string | null) | undefined, attribute80?: (string | null) | undefined, attribute89?: (string | null) | undefined, attribute88?: (string | null) | undefined, sku?: string | undefined, attribute87?: (string | null) | undefined, attribute86?: (string | null) | undefined, calculationResults?: (Array<{resultName?: string | undefined, resultLabel?: string | undefined, result?: string | undefined, excludeFromExport?: boolean | undefined, warnings?: Array | undefined, alertMessage?: string | undefined, alertType?: ('CRITICAL' | 'RED' | 'YELLOW') | undefined, displayOptions?: number | undefined, formatType?: ('NUMERIC' | 'NUMERIC_LONG' | 'MONEY' | 'PERCENT' | 'TEXT' | 'MONEY_EUR' | 'MONEY_USD' | 'MONEY_GBP' | 'MONEY_JPY' | 'MONEY_CHF' | 'MONEY_PLN' | 'DATETIME' | 'DATE' | 'INTEGER' | 'LINK' | 'COMPLEX' | 'SPARKLINE') | undefined, suffix?: string | undefined, resultType?: string | undefined, cssProperties?: string | undefined, userGroup?: string | undefined, resultGroup?: string | undefined, overrideValueOptions?: (Array) | undefined, overrideAllowEmpty?: boolean | undefined, labelTranslations?: string | undefined, overridable?: boolean | undefined, overridden?: boolean | undefined, resultDescription?: string | undefined}>) | undefined, attribute85?: (string | null) | undefined, attribute84?: (string | null) | undefined, unitOfMeasure?: string | undefined, targetDate?: string | undefined, allowedOverrides?: string | undefined, version?: number | undefined, alerts?: (string | null) | undefined, attribute9?: (string | null) | undefined, attribute94?: (string | null) | undefined, attribute8?: (string | null) | undefined, attribute93?: (string | null) | undefined, attribute92?: (string | null) | undefined, attribute91?: (string | null) | undefined, attribute5: unknown, attribute90?: (string | null) | undefined, attribute4?: (string | null) | undefined, attribute7?: (string | null) | undefined, attribute6?: (string | null) | undefined, attribute1?: (string | null) | undefined, attribute14?: (string | null) | undefined, attribute13?: (string | null) | undefined, attribute3?: (string | null) | undefined, attribute12?: (string | null) | undefined, attribute2?: (string | null) | undefined, attribute11?: (string | null) | undefined, attribute99?: (string | null) | undefined, attribute10?: (string | null) | undefined, attribute98?: (string | null) | undefined, attribute97?: (string | null) | undefined, attribute96?: (string | null) | undefined, attribute95?: (string | null) | undefined, updateDate?: string | undefined, itemExtensions?: (Record | null) | undefined, attribute19?: (string | null) | undefined, attribute18?: (string | null) | undefined, attribute17?: (string | null) | undefined, attribute16?: (string | null) | undefined, attribute15?: (string | null) | undefined, manualOverrides?: (string | null) | undefined, attribute25?: (string | null) | undefined, attribute24?: (string | null) | undefined, currency?: string | undefined, attribute23?: (string | null) | undefined, attribute22?: (string | null) | undefined, attribute21?: (string | null) | undefined, attribute20?: (string | null) | undefined, createDate?: string | undefined, attribute29?: (string | null) | undefined, attribute28?: (string | null) | undefined, attribute27?: (string | null) | undefined, attribute26?: (string | null) | undefined, completeResultsAvailable?: boolean | undefined, attribute36?: (string | null) | undefined, attribute35?: (string | null) | undefined, attribute34?: (string | null) | undefined, attribute33?: (string | null) | undefined, attribute32?: (string | null) | undefined, attribute31?: (string | null) | undefined, attribute30?: (string | null) | undefined, key2?: (string | null) | undefined, attribute39?: (string | null) | undefined, lastUpdateDate?: string | undefined, attribute38?: (string | null) | undefined, attribute37?: (string | null) | undefined, attribute47?: (string | null) | undefined, attribute46?: (string | null) | undefined, attribute45?: (string | null) | undefined, attribute44?: (string | null) | undefined, attribute43?: (string | null) | undefined, attribute42?: (string | null) | undefined, attribute41?: (string | null) | undefined, attribute40?: (string | null) | undefined, priceChange?: (number | null) | undefined, updatedBy?: number | undefined, attribute49?: (string | null) | undefined, attribute48?: (string | null) | undefined, attribute50?: (string | null) | undefined, attribute100?: (string | null) | undefined, calculatedResultPrice?: (number | null) | undefined, attribute58?: (string | null) | undefined, attribute57?: (string | null) | undefined, attribute56?: (string | null) | undefined, attribute55?: (string | null) | undefined, attribute54?: (string | null) | undefined, attribute53?: (string | null) | undefined, attribute52?: (string | null) | undefined, allCalculationResults?: Array<{[key: string]: string}> | undefined, attribute51?: (string | null) | undefined, attribute59?: (string | null) | undefined, attribute61?: (string | null) | undefined, attribute60?: (string | null) | undefined, previousPrice?: (number | null) | undefined, attribute69?: (string | null) | undefined, attribute68?: (string | null) | undefined, attribute67?: (string | null) | undefined, attribute66?: (string | null) | undefined, attribute65?: (string | null) | undefined, attribute64?: (string | null) | undefined, attribute63?: (string | null) | undefined, attribute62?: (string | null) | undefined, workStatus?: (string | null) | undefined, manualResultPrice?: (number | null) | undefined, comments?: string | undefined, pricelistId?: number | undefined, warnings?: string | undefined, approvalState?: number | undefined, label?: string | undefined, attribute72?: (string | null) | undefined, attribute71?: (string | null) | undefined, attribute70?: (string | null) | undefined, createdBy?: number | undefined, attribute79?: (string | null) | undefined, attribute78?: (string | null) | undefined, attribute77?: (string | null) | undefined, attribute76?: (string | null) | undefined, attribute75?: (string | null) | undefined, attribute74?: (string | null) | undefined, lastUpdateBy?: number | undefined, attribute73?: (string | null) | undefined}; export type CreateApiPricelistmanagerUpdateIdArgs = {body: {data: {typedId: string, comments?: string | undefined, manualResultPrice?: string | undefined}, oldValues: PricelistItem, operationType?: string | undefined, textMatchStyle?: string | undefined}}; export type CreateApiPricelistmanagerUpdateIdOptions = {baseUrl?: string | undefined, basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const pricelistItem = z.object({typedId: z.string().optional(), listLabel: z.string().optional(), resultPrice: z.number().nullable().optional(), priceChangePct: z.number().nullable().optional(), attribute83: z.string().max(70).nullable().optional(), attribute82: z.string().max(70).nullable().optional(), attribute81: z.string().max(70).nullable().optional(), attribute80: z.string().max(70).nullable().optional(), attribute89: z.string().max(70).nullable().optional(), attribute88: z.string().max(70).nullable().optional(), sku: z.string().max(255).optional(), attribute87: z.string().max(70).nullable().optional(), attribute86: z.string().max(70).nullable().optional(), calculationResults: z.array(z.object({resultName: z.string().optional(), resultLabel: z.string().optional(), result: z.string().optional(), excludeFromExport: z.boolean().optional(), warnings: z.array(z.string()).optional(), alertMessage: z.string().optional(), alertType: z.enum(["CRITICAL", "RED", "YELLOW"]).optional(), displayOptions: z.number().int().optional(), formatType: z.enum(["NUMERIC", "NUMERIC_LONG", "MONEY", "PERCENT", "TEXT", "MONEY_EUR", "MONEY_USD", "MONEY_GBP", "MONEY_JPY", "MONEY_CHF", "MONEY_PLN", "DATETIME", "DATE", "INTEGER", "LINK", "COMPLEX", "SPARKLINE"]).optional(), suffix: z.string().optional(), resultType: z.string().optional(), cssProperties: z.string().optional(), userGroup: z.string().optional(), resultGroup: z.string().optional(), overrideValueOptions: z.array(z.string().nullable()).optional(), overrideAllowEmpty: z.boolean().optional(), labelTranslations: z.string().optional(), overridable: z.boolean().optional(), overridden: z.boolean().optional(), resultDescription: z.string().optional()})).optional(), attribute85: z.string().max(70).nullable().optional(), attribute84: z.string().max(70).nullable().optional(), unitOfMeasure: z.string().max(255).optional(), targetDate: z.string().optional(), allowedOverrides: z.string().max(1300).optional(), version: z.number().int().optional(), alerts: z.string().nullable().optional(), attribute9: z.string().max(70).nullable().optional(), attribute94: z.string().max(70).nullable().optional(), attribute8: z.string().max(70).nullable().optional(), attribute93: z.string().max(70).nullable().optional(), attribute92: z.string().max(70).nullable().optional(), attribute91: z.string().max(70).nullable().optional(), attribute5: z.unknown(), attribute90: z.string().max(70).nullable().optional(), attribute4: z.string().max(70).nullable().optional(), attribute7: z.string().max(70).nullable().optional(), attribute6: z.string().max(70).nullable().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(), attribute99: z.string().max(70).nullable().optional(), attribute10: z.string().max(70).nullable().optional(), attribute98: z.string().max(70).nullable().optional(), attribute97: z.string().max(70).nullable().optional(), attribute96: z.string().max(70).nullable().optional(), attribute95: z.string().max(70).nullable().optional(), updateDate: z.string().optional(), itemExtensions: z.object({}).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(), manualOverrides: z.string().nullable().optional(), attribute25: z.string().max(70).nullable().optional(), attribute24: z.string().max(70).nullable().optional(), currency: z.string().max(255).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(), completeResultsAvailable: z.boolean().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(), key2: z.string().nullable().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(), priceChange: z.number().nullable().optional(), updatedBy: z.number().int().optional(), attribute49: z.string().max(70).nullable().optional(), attribute48: z.string().max(70).nullable().optional(), attribute50: z.string().max(70).nullable().optional(), attribute100: z.string().max(70).nullable().optional(), calculatedResultPrice: z.number().nullable().optional(), attribute58: z.string().max(70).nullable().optional(), attribute57: z.string().max(70).nullable().optional(), attribute56: z.string().max(70).nullable().optional(), attribute55: z.string().max(70).nullable().optional(), attribute54: z.string().max(70).nullable().optional(), attribute53: z.string().max(70).nullable().optional(), attribute52: z.string().max(70).nullable().optional(), allCalculationResults: z.array(z.record(z.string(), z.string())).optional(), attribute51: z.string().max(70).nullable().optional(), attribute59: z.string().max(70).nullable().optional(), attribute61: z.string().max(70).nullable().optional(), attribute60: z.string().max(70).nullable().optional(), previousPrice: z.number().nullable().optional(), attribute69: z.string().max(70).nullable().optional(), attribute68: z.string().max(70).nullable().optional(), attribute67: z.string().max(70).nullable().optional(), attribute66: z.string().max(70).nullable().optional(), attribute65: z.string().max(70).nullable().optional(), attribute64: z.string().max(70).nullable().optional(), attribute63: z.string().max(70).nullable().optional(), attribute62: z.string().max(70).nullable().optional(), workStatus: z.string().max(15).nullable().optional(), manualResultPrice: z.number().nullable().optional(), comments: z.string().max(255).optional(), pricelistId: z.number().int().optional(), warnings: z.string().optional(), approvalState: z.number().int().optional(), label: z.string().max(255).optional(), attribute72: z.string().max(70).nullable().optional(), attribute71: z.string().max(70).nullable().optional(), attribute70: z.string().max(70).nullable().optional(), createdBy: z.number().int().optional(), attribute79: z.string().max(70).nullable().optional(), attribute78: z.string().max(70).nullable().optional(), attribute77: z.string().max(70).nullable().optional(), attribute76: z.string().max(70).nullable().optional(), attribute75: z.string().max(70).nullable().optional(), attribute74: z.string().max(70).nullable().optional(), lastUpdateBy: z.number().int().optional(), attribute73: z.string().max(70).nullable().optional()}); export const createApiPricelistmanagerUpdateIdResponse = z.object({response: z.object({node: z.string().optional(), data: z.array(pricelistItem).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 }; /** * Update a Pricelist Detail * * POST /pricelistmanager.update/{id} * * Also accepts auth: X-PriceFx-jwt */ export const createApiPricelistmanagerUpdateId = async (args: CreateApiPricelistmanagerUpdateIdArgs, options?: CreateApiPricelistmanagerUpdateIdOptions) => { 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 (basic !== undefined) headers.set('authorization', `Basic ${btoa(`${basic.username}:${basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/pricelistmanager.update/${encodeURIComponent(String(args.id))}${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(createApiPricelistmanagerUpdateIdResponse, await res.json()) };