hookwright 2.3.2 → 2.3.4

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 +10 -4
  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: "2.3.2",
27
+ version: "2.3.4",
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",
@@ -1830,10 +1830,13 @@ var COMMON_FIELDS3 = [
1830
1830
  { source: "request.line_items[].original_product.image.src", target: "returnProduct.image" },
1831
1831
  { source: "request.line_items[].original_product.price", target: "returnProduct.totalPrice", note: "summed across the lines, times quantity; a zero marks a freebie" },
1832
1832
  { source: "request.line_items[].original_product.sku", target: "returnProduct.sku" },
1833
+ { source: "request.line_items[].original_product.product_id", target: "returnProduct.productId" },
1834
+ { source: "request.line_items[].original_product.variant_id", target: "returnProduct.variantId" },
1833
1835
  { source: "request.line_items[].reason", target: "reason" },
1834
1836
  { source: "request.line_items[].quantity", target: "returnProduct.quantity" },
1835
1837
  { source: "request.line_items[].presentment_price.actual_amount", target: "pricing.totalPrice" },
1836
1838
  { source: "request.line_items[].presentment_price.currency", target: "pricing.currency" },
1839
+ { source: "request.line_items[].presentment_price.total_tax", target: "pricing.totalTax" },
1837
1840
  { source: "request.line_items[].return_fee.price_set.presentment_money.amount", target: "pricing.returnFee" },
1838
1841
  { source: "request.line_items[].refund.status", target: "refund.status" },
1839
1842
  { source: "request.line_items[].refund.requested_mode", target: "refund.requestedMode" },
@@ -1847,7 +1850,9 @@ var EXCHANGE_FIELDS = [
1847
1850
  { source: "request.line_items[].exchange_product.title", target: "exchangeProduct.name", note: "exchanges only \u2014 returns never carry it" },
1848
1851
  { source: "request.line_items[].exchange_product.price", target: "exchangeProduct.totalPrice + pricing.priceDifference", note: "both summed across the lines, times quantity; the difference is signed, positive means the shopper owes more" },
1849
1852
  { source: "request.line_items[].exchange_product.image.src", target: "exchangeProduct.image" },
1850
- { source: "request.line_items[].exchange_product.sku", target: "exchangeProduct.sku" }
1853
+ { source: "request.line_items[].exchange_product.sku", target: "exchangeProduct.sku" },
1854
+ { source: "request.line_items[].exchange_product.product_id", target: "exchangeProduct.productId" },
1855
+ { source: "request.line_items[].exchange_product.variant_id", target: "exchangeProduct.variantId" }
1851
1856
  ];
1852
1857
  var fieldMap6 = COMMON_FIELDS3;
1853
1858
  function fieldMapFor2(eventName) {
@@ -1895,6 +1900,7 @@ function buildPayload6(ctx) {
1895
1900
  const qty = def.requestType === "exchange" ? repl?.quantity ?? sel?.quantity ?? 1 : sel?.quantity ?? 1;
1896
1901
  const originalPrice = money2(sel?.variant?.price ?? 0);
1897
1902
  const exchangePrice = money2(repl?.variant?.price ?? 0);
1903
+ const refundedAmount = def.requestType === "exchange" ? Math.max(money2((originalPrice - exchangePrice) * qty), 0) : money2(originalPrice * qty);
1898
1904
  return {
1899
1905
  id: Number(sel?.variant?.id ?? sel?.product?.id ?? 0),
1900
1906
  refund: {
@@ -1903,8 +1909,8 @@ function buildPayload6(ctx) {
1903
1909
  meta: { discount_code: ctx.couponCode ?? `RP${String(now.getTime()).slice(-7)}` },
1904
1910
  status: def.status === "requested" ? "pending" : "refunded",
1905
1911
  refunded_amount: {
1906
- shop_money: { amount: originalPrice, currency_code: currency },
1907
- presentment_money: { amount: originalPrice, currency_code: currency }
1912
+ shop_money: { amount: refundedAmount, currency_code: currency },
1913
+ presentment_money: { amount: refundedAmount, currency_code: currency }
1908
1914
  },
1909
1915
  refunded_at: at,
1910
1916
  comment: null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hookwright",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
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",