@labdigital/commercetools-mock 2.65.0 → 2.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1594,8 +1594,9 @@ var OrderUpdateHandler = class extends AbstractUpdateHandler {
1594
1594
  ...getBaseResourceProperties(),
1595
1595
  quantity: item.quantity,
1596
1596
  paymentState: "Initial",
1597
- shipmentState: "Initial",
1598
- comment: item.comment
1597
+ shipmentState: item.shipmentState ?? "Advised",
1598
+ comment: item.comment,
1599
+ custom: createCustomFields(item.custom, context.projectKey, this._storage)
1599
1600
  };
1600
1601
  if (item.customLineItemId) return {
1601
1602
  ...common,
@@ -1649,11 +1650,30 @@ var OrderUpdateHandler = class extends AbstractUpdateHandler {
1649
1650
  };
1650
1651
  }
1651
1652
  }
1653
+ addDelivery(context, resource, { action, items, ...deliveryDraft }) {
1654
+ if (!resource.shippingInfo) throw new Error("Resource has no shipping info");
1655
+ if (!items) throw new Error("Delivery items are required");
1656
+ if (!resource.shippingInfo.deliveries) resource.shippingInfo.deliveries = [];
1657
+ const parcels = deliveryDraft.parcels?.map((p) => ({
1658
+ ...getBaseResourceProperties(),
1659
+ ...p,
1660
+ custom: createCustomFields(p.custom, context.projectKey, this._storage)
1661
+ })) ?? [];
1662
+ const delivery = {
1663
+ ...getBaseResourceProperties(),
1664
+ ...deliveryDraft,
1665
+ parcels,
1666
+ items,
1667
+ address: createAddress(deliveryDraft.address, context.projectKey, this._storage),
1668
+ custom: createCustomFields(deliveryDraft.custom, context.projectKey, this._storage)
1669
+ };
1670
+ resource.shippingInfo.deliveries.push(delivery);
1671
+ }
1652
1672
  setDeliveryCustomField(context, resource, { deliveryId, name, value }) {
1653
1673
  if (!resource.shippingInfo) throw new Error("Resource has no shipping info");
1654
1674
  for (const delivery of resource.shippingInfo.deliveries || []) if (delivery.id === deliveryId && delivery.custom?.fields) delivery.custom.fields[name] = value;
1655
1675
  }
1656
- setLineItemCustomField(context, resource, { lineItemId, lineItemKey, name, value, action }) {
1676
+ setLineItemCustomField(context, resource, { lineItemId, lineItemKey, name, value }) {
1657
1677
  const lineItem = resource.lineItems.find((x) => lineItemId && x.id === lineItemId || lineItemKey && x.key === lineItemKey);
1658
1678
  if (!lineItem) throw new CommercetoolsError({
1659
1679
  code: "General",