@nextblock-cms/ecom 0.9.95 → 0.9.99

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.
@@ -1,24 +1,24 @@
1
- import { createClient as A } from "@supabase/supabase-js";
2
- import { normalizeOrderCustomerDetails as x, normalizeCustomerAddress as v } from "../customer.es.js";
3
- import { upsertDefaultUserAddresses as w } from "../customer-addresses.es.js";
4
- import { applyOrderInventoryDeduction as C } from "../order-inventory.es.js";
1
+ import { createClient as D } from "@supabase/supabase-js";
2
+ import { normalizeOrderCustomerDetails as E, normalizeCustomerAddress as I } from "../customer.es.js";
3
+ import { upsertDefaultUserAddresses as C } from "../customer-addresses.es.js";
4
+ import { applyOrderInventoryDeduction as w } from "../order-inventory.es.js";
5
5
  import { normalizeOrderTaxDetails as U, buildOrderTaxDetailsFromStripeSession as R } from "../order-tax-details.es.js";
6
- import { assignInvoiceMetadata as O } from "../invoice-server.es.js";
7
- import { stripe as b } from "./client.es.js";
8
- const P = ["total_details.breakdown"], z = ["data.taxes.rate"];
6
+ import { assignInvoiceMetadata as P } from "../invoice-server.es.js";
7
+ import { stripe as h } from "./client.es.js";
8
+ const O = ["total_details.breakdown"], z = ["data.taxes.rate"];
9
9
  function k() {
10
- const r = process.env.NEXT_PUBLIC_SUPABASE_URL, t = process.env.SUPABASE_SERVICE_ROLE_KEY;
10
+ const r = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, t = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY;
11
11
  if (!r || !t)
12
12
  throw new Error("Missing Supabase Service Role environment variables");
13
- return A(r, t, {
13
+ return D(r, t, {
14
14
  auth: {
15
15
  autoRefreshToken: !1,
16
16
  persistSession: !1
17
17
  }
18
18
  });
19
19
  }
20
- function S(r, t) {
21
- return r ? v({
20
+ function b(r, t) {
21
+ return r ? I({
22
22
  recipient_name: t,
23
23
  line1: r.line1 ?? null,
24
24
  line2: r.line2 ?? null,
@@ -28,9 +28,9 @@ function S(r, t) {
28
28
  country_code: r.country ?? null
29
29
  }) : null;
30
30
  }
31
- function N(r) {
31
+ function B(r) {
32
32
  const t = r ?? {};
33
- return x({
33
+ return E({
34
34
  email: typeof t.email == "string" ? t.email : null,
35
35
  name: typeof t.name == "string" ? t.name : null,
36
36
  phone: typeof t.phone == "string" ? t.phone : null,
@@ -42,8 +42,8 @@ async function H(r) {
42
42
  const t = k();
43
43
  let i = r;
44
44
  try {
45
- i = await b.checkout.sessions.retrieve(r.id, {
46
- expand: [...P]
45
+ i = await h.checkout.sessions.retrieve(r.id, {
46
+ expand: [...O]
47
47
  });
48
48
  } catch (d) {
49
49
  console.error("[Stripe Sync] Failed to rehydrate session tax details:", d);
@@ -58,29 +58,29 @@ async function H(r) {
58
58
  const { data: e, error: u } = await c;
59
59
  if (u || !e)
60
60
  throw new Error(u?.message || "Order lookup failed");
61
- const a = N(e.customer_details), o = U(e.tax_details), E = S(
61
+ const s = B(e.customer_details), o = U(e.tax_details), x = b(
62
62
  i.customer_details?.address,
63
- i.customer_details?.name ?? a.name
64
- ), m = i, D = S(
63
+ i.customer_details?.name ?? s.name
64
+ ), m = i, A = b(
65
65
  m.shipping_details?.address,
66
- m.shipping_details?.name ?? a.name
67
- ), n = x({
68
- email: i.customer_details?.email ?? a.email,
69
- name: i.customer_details?.name ?? a.name,
70
- phone: i.customer_details?.phone ?? a.phone,
71
- billing: a.billing ?? E,
72
- shipping: a.shipping ?? D
73
- }), I = e.status === "paid", T = await b.checkout.sessions.listLineItems(i.id, {
66
+ m.shipping_details?.name ?? s.name
67
+ ), n = E({
68
+ email: i.customer_details?.email ?? s.email,
69
+ name: i.customer_details?.name ?? s.name,
70
+ phone: i.customer_details?.phone ?? s.phone,
71
+ billing: s.billing ?? x,
72
+ shipping: s.shipping ?? A
73
+ }), T = e.status === "paid", v = await h.checkout.sessions.listLineItems(i.id, {
74
74
  limit: 100,
75
75
  expand: [...z]
76
76
  }), l = R({
77
77
  session: i,
78
- lineItems: T.data,
78
+ lineItems: v.data,
79
79
  subtotal: typeof e.subtotal == "number" ? e.subtotal : o?.subtotal ?? 0,
80
80
  shippingTotal: typeof e.shipping_total == "number" ? e.shipping_total : o?.shipping_total ?? 0,
81
81
  fallbackMode: o?.mode ?? "automatic",
82
82
  currency: (i.currency ?? e.currency ?? o?.currency ?? "USD").toUpperCase()
83
- }), s = l.tax_total > 0 || l.lines.length > 0 ? l : o ?? l, _ = s?.tax_total ?? (typeof e.tax_total == "number" ? e.tax_total : 0), y = (i.currency ?? e.currency ?? s?.currency ?? "USD").toUpperCase(), f = {
83
+ }), a = l.tax_total > 0 || l.lines.length > 0 ? l : o ?? l, _ = a?.tax_total ?? (typeof e.tax_total == "number" ? e.tax_total : 0), y = (i.currency ?? e.currency ?? a?.currency ?? "USD").toUpperCase(), f = {
84
84
  status: "paid",
85
85
  stripe_session_id: i.id,
86
86
  payment_intent_id: typeof i.payment_intent == "string" ? i.payment_intent : null,
@@ -89,13 +89,13 @@ async function H(r) {
89
89
  total: typeof i.amount_total == "number" ? i.amount_total : e.total,
90
90
  currency: y,
91
91
  tax_total: _,
92
- tax_details: s
92
+ tax_details: a
93
93
  }, { error: g } = await t.from("orders").update(f).eq("id", e.id);
94
94
  if (g)
95
95
  throw new Error(g.message);
96
96
  if (e.user_id)
97
97
  try {
98
- await w({
98
+ await C({
99
99
  userId: e.user_id,
100
100
  billingAddress: n.billing,
101
101
  shippingAddress: n.shipping,
@@ -104,24 +104,24 @@ async function H(r) {
104
104
  } catch (d) {
105
105
  console.error("[Stripe Sync] Failed to refresh saved customer addresses:", d);
106
106
  }
107
- const h = await O({
107
+ const S = await P({
108
108
  orderId: e.id,
109
109
  client: t
110
110
  });
111
- return await C(t, e.id), {
111
+ return await w(t, e.id), {
112
112
  orderId: e.id,
113
- alreadyPaid: I,
113
+ alreadyPaid: T,
114
114
  customerDetails: n,
115
115
  order: {
116
116
  id: e.id,
117
- invoice_number: h.invoiceNumber,
118
- paid_at: h.paidAt,
117
+ invoice_number: S.invoiceNumber,
118
+ paid_at: S.paidAt,
119
119
  total: f.total,
120
120
  currency: y,
121
- subtotal: typeof e.subtotal == "number" ? e.subtotal : s?.subtotal ?? 0,
122
- shipping_total: typeof e.shipping_total == "number" ? e.shipping_total : s?.shipping_total ?? 0,
121
+ subtotal: typeof e.subtotal == "number" ? e.subtotal : a?.subtotal ?? 0,
122
+ shipping_total: typeof e.shipping_total == "number" ? e.shipping_total : a?.shipping_total ?? 0,
123
123
  tax_total: _,
124
- tax_details: s
124
+ tax_details: a
125
125
  }
126
126
  };
127
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextblock-cms/ecom",
3
- "version": "0.9.95",
3
+ "version": "0.9.99",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -10,9 +10,9 @@
10
10
  },
11
11
  "type": "module",
12
12
  "dependencies": {
13
- "@nextblock-cms/db": "^0.9.95",
14
- "@nextblock-cms/ui": "^0.9.95",
15
- "@nextblock-cms/utils": "^0.9.95",
13
+ "@nextblock-cms/db": "^0.9.99",
14
+ "@nextblock-cms/ui": "^0.9.99",
15
+ "@nextblock-cms/utils": "^0.9.99",
16
16
  "@freemius/checkout": "^1.4.1",
17
17
  "@freemius/sdk": "^0.3.0",
18
18
  "@hookform/resolvers": "^5.2.2",