@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.
- package/lib/cart-store.d.ts +3 -3
- package/lib/currency-rest-client.cjs.js +1 -1
- package/lib/currency-rest-client.es.js +7 -7
- package/lib/currency-sync.d.ts +3 -3
- package/lib/currency.d.ts +7 -7
- package/lib/freemius-order-sync.cjs.js +1 -1
- package/lib/freemius-order-sync.es.js +29 -29
- package/lib/pages/cms/orders/export-actions.d.ts +1 -1
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/server-actions.es.js +16 -16
- package/lib/pages/cms/products/actions.d.ts +205 -6
- package/lib/pages/cms/products/server-actions.d.ts +11 -11
- package/lib/pages/cms/shipping/server-actions.d.ts +6 -6
- package/lib/product-actions.d.ts +255 -4
- package/lib/product-schema.d.ts +1 -1
- package/lib/providers/freemius.cjs.js +2 -2
- package/lib/providers/freemius.es.js +159 -159
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +51 -51
- package/lib/shipping-rate-currency.d.ts +5 -5
- package/lib/stripe/checkout.cjs.js +1 -1
- package/lib/stripe/checkout.es.js +25 -25
- package/lib/stripe/order-sync.cjs.js +1 -1
- package/lib/stripe/order-sync.d.ts +6 -6
- package/lib/stripe/order-sync.es.js +38 -38
- package/package.json +4 -4
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { createClient as
|
|
2
|
-
import { normalizeOrderCustomerDetails as
|
|
3
|
-
import { upsertDefaultUserAddresses as
|
|
4
|
-
import { applyOrderInventoryDeduction as
|
|
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
|
|
7
|
-
import { stripe as
|
|
8
|
-
const
|
|
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
|
|
13
|
+
return D(r, t, {
|
|
14
14
|
auth: {
|
|
15
15
|
autoRefreshToken: !1,
|
|
16
16
|
persistSession: !1
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return r ?
|
|
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
|
|
31
|
+
function B(r) {
|
|
32
32
|
const t = r ?? {};
|
|
33
|
-
return
|
|
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
|
|
46
|
-
expand: [...
|
|
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
|
|
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 ??
|
|
64
|
-
), m = i,
|
|
63
|
+
i.customer_details?.name ?? s.name
|
|
64
|
+
), m = i, A = b(
|
|
65
65
|
m.shipping_details?.address,
|
|
66
|
-
m.shipping_details?.name ??
|
|
67
|
-
), n =
|
|
68
|
-
email: i.customer_details?.email ??
|
|
69
|
-
name: i.customer_details?.name ??
|
|
70
|
-
phone: i.customer_details?.phone ??
|
|
71
|
-
billing:
|
|
72
|
-
shipping:
|
|
73
|
-
}),
|
|
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:
|
|
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
|
-
}),
|
|
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:
|
|
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
|
|
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
|
|
107
|
+
const S = await P({
|
|
108
108
|
orderId: e.id,
|
|
109
109
|
client: t
|
|
110
110
|
});
|
|
111
|
-
return await
|
|
111
|
+
return await w(t, e.id), {
|
|
112
112
|
orderId: e.id,
|
|
113
|
-
alreadyPaid:
|
|
113
|
+
alreadyPaid: T,
|
|
114
114
|
customerDetails: n,
|
|
115
115
|
order: {
|
|
116
116
|
id: e.id,
|
|
117
|
-
invoice_number:
|
|
118
|
-
paid_at:
|
|
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 :
|
|
122
|
-
shipping_total: typeof e.shipping_total == "number" ? e.shipping_total :
|
|
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:
|
|
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.
|
|
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.
|
|
14
|
-
"@nextblock-cms/ui": "^0.9.
|
|
15
|
-
"@nextblock-cms/utils": "^0.9.
|
|
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",
|