import {z} from 'zod' export type Contact = {type?: ('primary' | 'customerRelations' | 'orderInquiry' | 'department' | 'shipping' | 'receiving' | 'hazmat') | undefined, name?: string | undefined, phoneNumber?: string | undefined, faxNumber?: string | undefined, email?: string | undefined}; export type Party = {name?: string | undefined, additionalName1?: string | undefined, additionalName2?: string | undefined, identificationCode?: string | undefined, identificationCodeType?: ('sendersId' | 'receiversId' | 'duns' | 'pantCode' | 'dunsPlus4' | 'drugEnforcementAdmin' | 'telephone' | 'federalReserveRouting' | 'standardAddressSAN' | 'healthIndustryHIN' | 'warehouse' | 'schoolId' | 'memberId' | 'stateLicenseId' | 'globalLocationId') | undefined, addressLine1?: string | undefined, addressLine2?: string | undefined, addressLine3?: string | undefined, addressLine4?: string | undefined, city?: string | undefined, stateOrProvinceCode?: string | undefined, postalCode?: string | undefined, countryCode?: string | undefined, zoneType?: ('residential' | 'commercial') | undefined, contacts?: Array | undefined}; export type Parties = {buyer?: Party | undefined, shipTo?: Party | undefined, billTo?: Party | undefined, shipFrom?: Party | undefined, accountsPayable?: Party | undefined, soldTo?: Party | undefined, supplier?: Party | undefined}; export type Dates = {cancelAfterDate?: string | undefined, customerOrderDate?: string | undefined, earliestDeliveryDate?: string | undefined, earliestShipDate?: string | undefined, latestShipDate?: string | undefined, latestDeliveryDate?: string | undefined, pickupDate?: string | undefined, promotionStartDate?: string | undefined, purchaseOrderDate?: string | undefined, requestedDeliveryDate?: string | undefined, requestedShipDate?: string | undefined, requestedDeliveryWeekOfDate?: string | undefined}; export type ReferenceDetail = {value?: string | undefined, description?: string | undefined}; export type References = {accountNumber?: ReferenceDetail | undefined, arrivalCode?: ReferenceDetail | undefined, associatedPurchaseOrderNumber?: ReferenceDetail | undefined, reservationNumber?: ReferenceDetail | undefined, customerOrderNumber?: ReferenceDetail | undefined, deliveryReference?: ReferenceDetail | undefined, divisionId?: ReferenceDetail | undefined, departmentNumber?: ReferenceDetail | undefined, internalCustomerNumber?: ReferenceDetail | undefined, vendorNumber?: ReferenceDetail | undefined, merchandiseTypeCode?: ReferenceDetail | undefined, promotionNumber?: ReferenceDetail | undefined, storeNumber?: ReferenceDetail | undefined, thirdPartyReferenceNumber?: ReferenceDetail | undefined, warehouseStorageLocation?: ReferenceDetail | undefined, shipmentNumber?: ReferenceDetail | undefined, invoiceNumber?: ReferenceDetail | undefined}; export type TermsOfSale = {type?: ('basic' | 'basicDiscountOffered' | 'discountNotApplicable' | 'endOfMonth' | 'endOfMonth10' | 'instant' | 'mutuallyDefined') | undefined, basisDate?: ('invoiceDate' | 'receiptOfGoods' | 'deliveryDate' | 'shipDate' | 'mutuallyDefined' | 'gageApprovalDate' | 'specifiedDate' | 'acceptanceDate' | 'invoiceTransmissionDate' | 'effectiveDate') | undefined, discountPercent?: string | undefined, discountDaysDue?: number | undefined, discountDueDate?: string | undefined, dayOfMonth?: number | undefined, netDaysDue?: number | undefined, netDueDate?: string | undefined, discountAmount?: string | undefined, description?: string | undefined, paymentMethodType?: ('check' | 'letterOfCredit' | 'wireTransfer' | 'corporateTradePayment' | 'specialAccount' | 'directPayOthers') | undefined}; export type RoutingDetails = {sequenceType?: ('origin' | '1stAfterOrigin' | '4thAfterOrigin' | 'haulage') | undefined, standardCarrierAlphaCode?: string | undefined, customCarrierCode?: string | undefined, transportationMethod?: ('air' | 'airExpress' | 'airFreightForward' | 'backhaul' | 'bestWay' | 'commonCarrier' | 'consolidation' | 'customerPickup' | 'expeditedTruck' | 'lessThanTrailerLoad' | 'mail' | 'ocean' | 'oceanContainerized' | 'parcelPost' | 'privateCarrier' | 'rail' | 'shipperAgent' | 'supplierTruck' | 'mutuallyDefined') | undefined, locationType?: ('inStore' | 'receiversLocation' | 'allPoints' | 'portOfArrival' | 'portOfEmbarkation' | 'origin' | 'mutuallyDefined') | undefined, location?: string | undefined, description?: string | undefined, serviceLevel?: ('deliveryConfirmation' | 'doorService' | 'economy' | 'eveningService' | 'expedited' | 'firstClass' | 'ground' | 'groundHundredWeight' | 'international' | 'metro' | 'morning' | 'nextDayAir' | 'nextDayHundredWeight' | 'nextDayEvening' | 'nextDayMorning1030' | 'nextDayMorning930' | 'overnight' | 'poBoxZipCode' | 'priorityMail' | 'priorityMailInsured' | 'proofOfDelivery' | 'sameDay' | 'saturdayService' | 'secondDay' | 'secondDayHundredWeight' | 'secondDayAir' | 'standard' | 'standardGround' | 'threeDay') | undefined, orderStatus?: ('shipCompleteOnDate' | 'complete' | 'partialShipment' | 'shipPartialBackorderToShipOnDate' | 'partialShipOnDate' | 'shipped' | 'backordered' | 'mutuallyDefined' | 'availableScheduledToShip' | 'availableNoShipSchedule' | 'multiPickup' | 'availableToShipUnBilledQuantity' | 'stopOff') | undefined, transitDirectionType?: ('buyerToSeller' | 'sellerToBuyer' | 'subcontractorToSeller' | 'sellerToDropShipLocation' | 'sellToForwarder' | 'sellerToSubcontractor' | 'mutuallyDefined') | undefined, transitTimeType?: ('calendarDays' | 'hours' | 'workingDays') | undefined, transitTime?: string | undefined}; export type FOBDetails = {methodOfPayment?: ('airCollect' | 'airPrepaid' | 'paidByBuyer' | 'collect' | 'mutuallyAgreed' | 'portOfCall' | 'halfPrepaid' | 'mixed' | 'serviceFreightNoCharge' | 'advancePrepaid' | 'customerPickupBackhaul' | 'prepaidChargeCustomer' | 'prepaidBySeller' | 'paidBySeller' | 'pickup' | 'thirdPartyPay') | undefined, locationType?: ('cityAndState' | 'country' | 'destination' | 'origin' | 'stateProvince' | 'warehouse') | undefined, locationDescription?: string | undefined, titlePassageType?: ('cityAndState' | 'country' | 'destination' | 'origin' | 'stateProvince' | 'warehouse') | undefined, titlePassageDescription?: string | undefined, transportationTermsSource?: ('incoTerms' | 'tradeTerms' | 'mutuallyDefined') | undefined, transportationTerms?: ('costAndFreight' | 'costInsuranceAndFreight' | 'carriageAndInsurancePaidTo' | 'carriagePaidTo' | 'deliveredAtFrontier' | 'deliverDutyPaid' | 'deliverDutyUnpaid' | 'deliveredDutyUnpaid' | 'deliveredExQuay' | 'deliveredExShip' | 'domesticallySupplied' | 'exQuay' | 'exShip' | 'exWorks' | 'freeAlongsideShip' | 'freeCarrier' | 'freightCarriageInsurancePaidTo' | 'freightCarriagePaidTo' | 'freeOnBoard' | 'freeOnRail' | 'freePnTruck' | 'nonPrivilegedForeign' | 'privilegedForeign' | 'mutuallyDefined') | undefined, riskOfLoss?: ('toDestinationBuyer' | 'toFreightEqPointSeller' | 'toPoolPointSeller' | 'toDestinationSeller' | 'mutuallyDefined') | undefined, description?: string | undefined}; export type SpecialHandlingDetails = {handlingType?: string | undefined, description?: string | undefined, materialId?: string | undefined, materialClass?: string | undefined, conditionResponse?: boolean | undefined}; export type CarrierDetails = {routing?: Array | undefined, freeOnBoard?: Array | undefined, specialHandling?: Array | undefined}; export type NoteDetail = {description?: string | undefined, text?: Array | undefined}; export type Notes = {general?: NoteDetail | undefined, orderInstructions?: NoteDetail | undefined, shippingInstructions?: NoteDetail | undefined, giftMessage?: NoteDetail | undefined, packingSlipMessage?: NoteDetail | undefined}; export type HeaderMonetaryAmounts = {net?: string | undefined, gross?: string | undefined, discount?: string | undefined, freight?: string | undefined}; export type Conditions = {type?: string | undefined, description?: string | undefined}; export type Quantity = {value?: string | undefined, unitOfMeasure?: ('ball' | 'assortment' | 'ocularInsertSystem' | 'bundle' | 'bag' | 'bottle' | 'belt' | 'box' | 'cell' | 'case' | 'card' | 'container' | 'can' | 'cartridge' | 'cassette' | 'carton' | 'coil' | 'combo' | 'drum' | 'display' | 'dozen' | 'each' | 'knots' | 'order' | 'flakeTon' | 'foot' | 'gallon' | 'gram' | 'person' | 'kit' | 'pound' | 'linearFoot' | 'monetaryValue' | 'milliliter' | 'meter' | 'ounce' | 'threePack' | 'sixPack' | 'pail' | 'pairInches' | 'piece' | 'pad' | 'palletLift' | 'packPAK' | 'package' | 'palletUnitLoad' | 'pair' | 'pint' | 'quart' | 'reel' | 'roll' | 'section' | 'squareFoot' | 'sheet' | 'set' | 'syringe' | 'tube' | 'tote' | 'thousand' | 'unit' | 'vial') | undefined}; export type PricingInfo = {priceType?: ('retail' | 'wholesale' | 'promotional' | 'contract') | undefined, price?: string | undefined, quantity?: string | undefined}; export type ProductIdDetail = {type?: string | undefined, value?: string | undefined}; export type ProductIds = {buyerItemNumber?: string | undefined, vendorItemNumber?: string | undefined, gtin12?: string | undefined, gtin13?: string | undefined, gtin14?: string | undefined, caseCode?: string | undefined, drugCode?: string | undefined, standardBookNumber?: string | undefined, buyerItemIds?: Array | undefined, vendorItemIds?: Array | undefined}; export type ProductAttributes = {description?: string | undefined, colorCode?: string | undefined, colorDescription?: string | undefined, sizeCode?: string | undefined, sizeDescription?: string | undefined, materialCode?: string | undefined, materialDescription?: string | undefined, processCode?: string | undefined, processDescription?: string | undefined, height?: string | undefined, width?: string | undefined}; export type PhysicalDetails = {numberOfUnits?: string | undefined, packageForm?: ('carton' | 'case' | 'pallet' | 'bag' | 'box' | 'bundle' | 'drum' | 'roll') | undefined, weight?: string | undefined, weightUnit?: ('pound' | 'kilogram' | 'ounce' | 'gram') | undefined, volume?: string | undefined, volumeUnit?: string | undefined}; export type PackagingDetails = {packagingCode?: string | undefined, packagingDescription?: string | undefined}; export type DestinationQuantity = {identificationCode?: string | undefined, identificationCodeType?: string | undefined, quantity?: string | undefined}; export type AllowanceCharge = {type?: string | undefined, amount?: string | undefined, percent?: string | undefined, description?: string | undefined}; export type MonetaryAmounts = {lineTotal?: string | undefined, unitPrice?: string | undefined, extendedPrice?: string | undefined}; export type SublineItem = {sublineId?: string | undefined, quantity?: Quantity | undefined, productIds?: ProductIds | undefined, productAttributes?: ProductAttributes | undefined}; export type Paperwork = {type?: string | undefined, description?: string | undefined, required?: boolean | undefined}; export type POLineItem = {purchaseOrderLineId?: string | undefined, quantity?: Quantity | undefined, unitCostPrice?: string | undefined, unitPriceBasis?: string | undefined, additionalPricing?: Array | undefined, productIds?: ProductIds | undefined, productAttributes?: ProductAttributes | undefined, outerPack?: PhysicalDetails | undefined, innerPack?: PhysicalDetails | undefined, packaging?: Array | undefined, dates?: Dates | undefined, references?: References | undefined, destinationQuantities?: Array | undefined, allowances?: Array | undefined, charges?: Array | undefined, monetaryAmounts?: MonetaryAmounts | undefined, sublineItems?: Array | undefined, notes?: Notes | undefined, paperwork?: Array | undefined, conditionsAndRestrictions?: Array | undefined, carrierDetails?: CarrierDetails | undefined}; export type Type850PURCHASEORDER = {purpose?: ('original' | 'cancellation' | 'change' | 'replace' | 'confirmation') | undefined, purchaseOrderType?: ('blanketEstimated' | 'blanketFirm' | 'dropship' | 'release' | 'rushOrder' | 'standalone') | undefined, purchaseOrderNumber?: string | undefined, purchaseOrderDate?: string | undefined, contractNumber?: string | undefined, releaseNumber?: string | undefined, acknowledgmentType?: string | undefined, parties?: Parties | undefined, dates?: Dates | undefined, references?: References | undefined, termsOfSale?: TermsOfSale | undefined, carrierDetails?: CarrierDetails | undefined, notes?: Notes | undefined, monetaryAmounts?: HeaderMonetaryAmounts | undefined, conditionsAndRestrictions?: Array | undefined, lineItems?: Array | undefined}; export type POAckDates = {estimatedDeliveryDate?: string | undefined, requestedPickupDate?: string | undefined, scheduledShipDate?: string | undefined}; export type POAckAction = {status?: ('accepted' | 'rejected' | 'backordered') | undefined, statusReasonCode?: string | undefined, statusNote?: NoteDetail | undefined, quantity?: Quantity | undefined, scheduledShipDate?: string | undefined, estimatedDeliveryDate?: string | undefined, unitCostPrice?: string | undefined, substitutedItem?: ({productIds?: ProductIds | undefined}) | undefined}; export type POAckLineItem = {purchaseOrderLineId?: string | undefined, productIds?: ProductIds | undefined, productAttributes?: ProductAttributes | undefined, actions?: Array | undefined}; export type Type855PURCHASEORDERACKNOWLEDGMENT = {purchaseOrderNumber?: string | undefined, status?: ('accepted' | 'rejected') | undefined, statusReasonCode?: ('discontinued' | 'invalidAddress' | 'invalidBillToCode' | 'invalidItemNumber' | 'invalidPrice' | 'invalidItemQuantity' | 'invalidShipFrom' | 'invalidShipMethod' | 'invalidShipToName' | 'invalidShipToAddress1' | 'invalidShipToAddress2' | 'invalidShipToCity' | 'invalidShipToStateOrProvince' | 'invalidShipToPostalCode' | 'invalidShipToCountry' | 'itemRecall' | 'itemSetupIssue' | 'mainlandOnly' | 'missingLineItemId' | 'missingOrderId' | 'missingShipId' | 'naturalDisaster' | 'outOfStock' | 'seasonalOrEndOfLife' | 'shippingInFull' | 'systemIssue' | 'taxNexusIssue' | 'transportationIssuePrepaid' | 'transportationIssueCollect' | 'undeliverableAddress' | 'weather') | undefined, statusNote?: NoteDetail | undefined, dates?: POAckDates | undefined, parties?: ({shipFrom?: Party | undefined, supplier?: Party | undefined}) | undefined, termsOfSale?: TermsOfSale | undefined, lineItems?: Array | undefined}; export type CarrierWeightDetails = {packageForm?: ('bag' | 'carton' | 'pallet') | undefined, packageMaterial?: ('corrugated' | 'plastic' | 'plasticVacuumed' | 'standard' | 'wood') | undefined, weightUOM?: ('pound' | 'kilogram') | undefined, grossWeight?: string | undefined, netWeight?: string | undefined}; export type EquipmentDetails = {equipmentType?: ('reefer' | 'trailer') | undefined, equipmentId?: string | undefined, sealNumber?: string | undefined}; export type AsnReferences = {appointmentNumber?: ReferenceDetail | undefined, billOfLadingNumber?: ReferenceDetail | undefined, loadPlanningNumber?: ReferenceDetail | undefined, pickupReferenceNumber?: ReferenceDetail | undefined, proNumber?: ReferenceDetail | undefined, trackingNumber?: ReferenceDetail | undefined, vendorNumber?: ReferenceDetail | undefined}; export type ShipmentParties = {shipFrom?: Party | undefined, shipTo?: Party | undefined, supplier?: Party | undefined}; export type AsnItemReferences = {heatCode?: ReferenceDetail | undefined, billOfMaterial?: ReferenceDetail | undefined, barCode?: ReferenceDetail | undefined}; export type AsnItem = {purchaseOrderLineId?: string | undefined, productIds?: ProductIds | undefined, productAttributes?: ProductAttributes | undefined, references?: AsnItemReferences | undefined, lotNumber?: string | undefined, coilNumber?: string | undefined, quantityShipped?: Quantity | undefined, expirationDate?: string | undefined, manufactureDate?: string | undefined, countryOfOrigin?: string | undefined, outerPack?: PhysicalDetails | undefined, innerPack?: PhysicalDetails | undefined}; export type AsnCarton = {trackingNumber?: string | undefined, serialShippingId?: string | undefined, cartonPhysicalDetails?: PhysicalDetails | undefined, specialHandling?: Array | undefined, items?: Array | undefined}; export type AsnPallet = {palletType?: ('chep' | 'iGps' | 'peco' | 'whiteWood' | 'hardWood' | 'aluminum' | 'specifiedByDOT' | 'metal' | 'standard' | 'steel' | 'wood' | 'slipsheet' | 'softWood') | undefined, trackingNumber?: string | undefined, serialShippingId?: string | undefined, layersPerPallet?: number | undefined, cartonsPerLayer?: number | undefined, palletExchangeType?: ('noExchangeOrReturn' | 'exchange' | 'return' | 'customerPurchase' | 'thirdPartyExchange') | undefined, palletPhysicalDetails?: PhysicalDetails | undefined, cartons?: Array | undefined, items?: Array | undefined}; export type AsnOrder = {purchaseOrderNumber?: string | undefined, releaseNumber?: string | undefined, purchaseOrderDate?: string | undefined, customerOrderNumber?: string | undefined, parties?: ({markFor?: Party | undefined}) | undefined, pallets?: Array | undefined, cartons?: Array | undefined, items?: Array | undefined}; export type Type856SHIPNOTICEMANIFEST = {purpose?: ('original' | 'cancellation' | 'change') | undefined, shipmentId?: string | undefined, carrierDetails?: ({quantityAndWeight?: Array | undefined, routing?: Array | undefined, equipment?: EquipmentDetails | undefined, freeOnBoard?: Array | undefined, specialHandling?: Array | undefined}) | undefined, references?: AsnReferences | undefined, dates?: ({shipDate?: string | undefined, deliveryDate?: string | undefined}) | undefined, shippingPaymentTerms?: ('prepaidBySeller' | 'collect') | undefined, parties?: ShipmentParties | undefined, allowances?: Array | undefined, charges?: Array | undefined, orders?: Array | undefined}; export type InvoiceParties = {buyer?: Party | undefined, shipTo?: Party | undefined, billTo?: Party | undefined, accountsReceivable?: Party | undefined, accountsPayable?: Party | undefined}; export type InvoiceDates = {shipDate?: string | undefined, deliveryDate?: string | undefined, termsNetDueDate?: string | undefined, termsDiscountDueDate?: string | undefined}; export type TaxDetails = {amount?: string | undefined, percent?: string | undefined, taxIdNumber?: string | undefined, locationId?: string | undefined, exemptionCode?: ('exempt' | 'notExempt' | 'notTaxable') | undefined, jurisdictionType?: string | undefined, jurisdictionCode?: string | undefined, assignedId?: string | undefined}; export type InvoiceLineItem = {purchaseOrderLineId?: string | undefined, quantityInvoiced?: Quantity | undefined, unitPrice?: string | undefined, extendedPrice?: string | undefined, productIds?: ProductIds | undefined, productAttributes?: ProductAttributes | undefined, shipDate?: string | undefined, allowances?: Array | undefined, charges?: Array | undefined, taxes?: Array | undefined, notes?: Notes | undefined}; export type InvoiceTaxes = {harmonizedSalesTax?: TaxDetails | undefined, goodsAndServicesTax?: TaxDetails | undefined, stateProvincialTax?: TaxDetails | undefined, stateProvincialGoodsTax?: TaxDetails | undefined, localTax?: TaxDetails | undefined}; export type Type810INVOICE = {invoiceNumber?: string | undefined, invoiceDate?: string | undefined, invoiceType?: ('invoice' | 'creditMemo' | 'debitMemo') | undefined, purchaseOrderNumber?: string | undefined, purchaseOrderDate?: string | undefined, shipmentIdentification?: string | undefined, originalInvoiceNumber?: string | undefined, parties?: InvoiceParties | undefined, termsOfSale?: TermsOfSale | undefined, dates?: InvoiceDates | undefined, references?: References | undefined, lineItems?: Array | undefined, allowances?: Array | undefined, charges?: Array | undefined, taxes?: InvoiceTaxes | undefined, invoiceTotal?: string | undefined, invoiceSalesTotal?: string | undefined, invoiceTermsDiscount?: string | undefined}; export type InventoryParties = {inventoryLocation?: Party | undefined, buyer?: Party | undefined, supplier?: Party | undefined}; export type InventoryDates = {reportStartDate?: string | undefined, reportEndDate?: string | undefined}; export type InventoryQuantity = {locationId?: string | undefined, type?: ('available' | 'allocated' | 'incoming' | 'unavailable' | 'onHand' | 'committed') | undefined, quantity?: string | undefined, availableDate?: string | undefined}; export type InventoryLineItem = {lineNumber?: string | undefined, productIds?: ProductIds | undefined, productAttributes?: ProductAttributes | undefined, itemStatus?: ('inStock' | 'outOfStock' | 'discontinued' | 'backorder') | undefined, unitOfMeasure?: string | undefined, inventoryQuantities?: Array | undefined, unlimitedAvailability?: boolean | undefined, unitCostPrice?: string | undefined, references?: References | undefined}; export type Type846INVENTORYADVICE = {purpose?: ('full' | 'incremental') | undefined, reportType?: 'sellerInventory' | undefined, reportNumber?: string | undefined, reportDate?: string | undefined, parties?: InventoryParties | undefined, references?: References | undefined, dates?: InventoryDates | undefined, sellersCurrency?: ({currencyCode?: string | undefined}) | undefined, notes?: Notes | undefined, lineItems?: Array | undefined}; export type POChangeLineItem = {purchaseOrderLineId?: string | undefined, changeReason?: ('changeToItem' | 'addItem' | 'deleteItem' | 'priceChange' | 'quantityChange') | undefined, originalQuantity?: Quantity | undefined, changeInQuantity?: Quantity | undefined, quantity?: Quantity | undefined, unitCostPrice?: string | undefined, unitPriceBasis?: string | undefined, productIds?: ProductIds | undefined, productAttributes?: ProductAttributes | undefined, dates?: Dates | undefined, notes?: Notes | undefined}; export type Type860PURCHASEORDERCHANGE = {purpose?: ('change' | 'cancellation') | undefined, purchaseOrderType?: ('blanketEstimated' | 'blanketFirm' | 'dropship' | 'release' | 'rushOrder' | 'standalone') | undefined, purchaseOrderChangeType?: ('order' | 'standing') | undefined, purchaseOrderNumber?: string | undefined, purchaseOrderDate?: string | undefined, purchaseOrderChangeDate?: string | undefined, changeSequenceNumber?: string | undefined, acknowledgmentType?: ('withDetail' | 'withoutDetail') | undefined, parties?: Parties | undefined, references?: References | undefined, dates?: Dates | undefined, notes?: Notes | undefined, termsOfSale?: TermsOfSale | undefined, carrierDetails?: CarrierDetails | undefined, buyersCurrency?: ({currencyCode?: string | undefined}) | undefined, lineItems?: Array | undefined}; export type CreateTransactionBodyV4Dto = {type: '850_PURCHASE_ORDER' | '855_PURCHASE_ORDER_ACKNOWLEDGMENT' | '856_SHIP_NOTICE_MANIFEST' | '810_INVOICE' | '846_INVENTORY_ADVICE' | '860_PURCHASE_ORDER_CHANGE', stream: 'test' | 'live', senderId: string, receiverId: string, message: Type850PURCHASEORDER | Type855PURCHASEORDERACKNOWLEDGMENT | Type856SHIPNOTICEMANIFEST | Type810INVOICE | Type846INVENTORYADVICE | Type860PURCHASEORDERCHANGE}; export type CreateApiTransactionsArgs = {'orderful-api-version'?: string | undefined, body: CreateTransactionBodyV4Dto}; export type CreateApiTransactionsOptions = {baseUrl?: string | undefined, APIKEY?: string | undefined, fetch?: typeof fetch | undefined}; export const validationErrorDto = z.object({payloadPaths: z.array(z.string()).nullable(), errorMessage: z.string(), outputPath: z.string()}); export const createTransactionResponseV4Dto = z.object({id: z.string(), status: z.enum(["FAILED", "ACCEPTED"]), detail: z.string(), validationErrors: z.array(validationErrorDto).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 }; /** * Create a Transaction * * POST /transactions */ export const createApiTransactions = async (args: CreateApiTransactionsArgs, options?: CreateApiTransactionsOptions) => { const {baseUrl = "https://api.orderful.com", fetch: fetchFn = fetch, APIKEY} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['orderful-api-version'] != null) headers.set("orderful-api-version", String(args['orderful-api-version'])) if (APIKEY !== undefined) headers.set("orderful-api-key", APIKEY) const url = `${baseUrl.replace(/\/+$/, '')}/transactions${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(createTransactionResponseV4Dto, await res.json()) };