hookwright 1.13.0 → 2.0.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.
Files changed (2) hide show
  1. package/dist/cli.js +34 -20
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -24,7 +24,7 @@ var init_package = __esm({
24
24
  "package.json"() {
25
25
  package_default = {
26
26
  name: "hookwright",
27
- version: "1.13.0",
27
+ version: "2.0.0",
28
28
  description: "Build real, signed e-commerce webhooks from a live Shopify catalogue \u2014 interactive terminal UI, no backend",
29
29
  keywords: [
30
30
  "webhook",
@@ -1807,26 +1807,40 @@ function selectionFor4(eventName) {
1807
1807
  return eventDef3(eventName).selection;
1808
1808
  }
1809
1809
  var COMMON_FIELDS3 = [
1810
- { source: "request_type", target: "\xABgate\xBB + requestType", required: true, note: "return or exchange" },
1811
- { source: "status", target: "\xABgate\xBB + status", required: true, note: "requested, approved, received, inspected or rejected" },
1812
- { source: "customer.phone", target: "phone", required: true, note: "missing phone is rejected on every event" },
1813
- { source: "customer.address.country_code", target: "phone region" },
1814
- { source: "request_number", target: "requestNumber" },
1815
- { source: "order.name", target: "order.name" },
1816
- { source: "line_items[].original_product.title", target: "product.name", required: true, note: "the first PAID line wins; freebies rank last" },
1817
- { source: "line_items[].original_product.image.src", target: "product.image" },
1818
- { source: "line_items[].original_product.price", target: "product.price", note: "a zero price marks the line a freebie" },
1819
- { source: "line_items[].reason", target: "reason" },
1820
- { source: "line_items[].presentment_price.actual_amount", target: "pricing.totalPrice" },
1821
- { source: "line_items[].return_fee.price_set\u2026amount", target: "pricing.returnFee" },
1822
- { source: "line_items[].refund.status", target: "refund.status" },
1823
- { source: "line_items[].refund.meta.discount_code", target: "refund.discountCode", note: "only present once store credit is issued" },
1824
- { source: "line_items[].shipping[0].awb", target: "shipping.awb" },
1825
- { source: "approved/received/inspected/rejected.created_at", target: "timeline.*" }
1810
+ { source: "request.request_type", target: "\xABgate\xBB + requestType", required: true, note: "return or exchange" },
1811
+ { source: "request.status", target: "\xABgate\xBB + status", required: true, note: "requested, approved, received, inspected or rejected" },
1812
+ { source: "request.customer.phone", target: "phone", required: true, note: "missing phone is rejected on every event" },
1813
+ { source: "request.customer.address.country_code", target: "phone region" },
1814
+ { source: "request.customer.name", target: "customer.name" },
1815
+ { source: "request.customer.email", target: "customer.email", note: "null on some real requests" },
1816
+ { source: "request.request_number", target: "requestNumber" },
1817
+ { source: "request.id", target: "requestId" },
1818
+ { source: "request.manual_request", target: "manualRequest" },
1819
+ { source: "request.smart_exchange", target: "smartExchange" },
1820
+ { source: "request.order.name", target: "order.name" },
1821
+ { source: "request.order.id", target: "order.id" },
1822
+ { source: "request.line_items[].original_product.title", target: "product.name + product.details", required: true, note: "the first PAID line wins; freebies rank last" },
1823
+ { source: "request.line_items[].original_product.image.src", target: "product.image" },
1824
+ { source: "request.line_items[].original_product.price", target: "product.price", note: "a zero price marks the line a freebie" },
1825
+ { source: "request.line_items[].original_product.sku", target: "product.sku" },
1826
+ { source: "request.line_items[].reason", target: "reason" },
1827
+ { source: "request.line_items[].quantity", target: "product.quantity" },
1828
+ { source: "request.line_items[].presentment_price.actual_amount", target: "pricing.totalPrice" },
1829
+ { source: "request.line_items[].presentment_price.currency", target: "pricing.currency" },
1830
+ { source: "request.line_items[].return_fee.price_set.presentment_money.amount", target: "pricing.returnFee" },
1831
+ { source: "request.line_items[].refund.status", target: "refund.status" },
1832
+ { source: "request.line_items[].refund.requested_mode", target: "refund.requestedMode" },
1833
+ { source: "request.line_items[].refund.meta.discount_code", target: "refund.discountCode", note: "only present once store credit is issued" },
1834
+ { source: "request.line_items[].shipping[0].awb", target: "shipping.awb", note: "absent until a label is raised" },
1835
+ { source: "request.line_items[].shipping[0].tracking_available", target: "shipping.trackingAvailable" },
1836
+ { source: "request.approved.created_at / request.received.created_at / request.inspected.created_at / request.rejected.created_at", target: "timeline.*", note: "whichever steps have happened" },
1837
+ { source: "request.created_at", target: "createdAt" }
1826
1838
  ];
1827
1839
  var EXCHANGE_FIELDS = [
1828
- { source: "line_items[].exchange_product.title", target: "exchangeProduct.name", note: "exchanges only \u2014 returns never carry it" },
1829
- { source: "line_items[].exchange_product.price", target: "exchangeProduct.price + pricing.priceDifference", note: "difference is signed: positive means the shopper owes more" }
1840
+ { source: "request.line_items[].exchange_product.title", target: "exchangeProduct.name", note: "exchanges only \u2014 returns never carry it" },
1841
+ { source: "request.line_items[].exchange_product.price", target: "exchangeProduct.price + pricing.priceDifference", note: "difference is signed: positive means the shopper owes more" },
1842
+ { source: "request.line_items[].exchange_product.image.src", target: "exchangeProduct.image" },
1843
+ { source: "request.line_items[].exchange_product.sku", target: "exchangeProduct.sku" }
1830
1844
  ];
1831
1845
  var fieldMap6 = COMMON_FIELDS3;
1832
1846
  function fieldMapFor2(eventName) {
@@ -1865,7 +1879,7 @@ function buildPayload6(ctx) {
1865
1879
  const cust = config.customer;
1866
1880
  const at = now.toISOString();
1867
1881
  const first = items?.[0];
1868
- const second = items?.[1] ?? first;
1882
+ const second = ctx.exchange ?? items?.[1] ?? first;
1869
1883
  const originalPrice = money2(first?.variant?.price ?? 0);
1870
1884
  const exchangePrice = money2(second?.variant?.price ?? 0);
1871
1885
  const reachedIndex = STATUSES.indexOf(def.status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hookwright",
3
- "version": "1.13.0",
3
+ "version": "2.0.0",
4
4
  "description": "Build real, signed e-commerce webhooks from a live Shopify catalogue — interactive terminal UI, no backend",
5
5
  "keywords": [
6
6
  "webhook",