@pradip1995/segment-primitives 0.4.6 → 0.4.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pradip1995/segment-primitives",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,6 +22,10 @@
22
22
  "./product-selection-context": "./src/product-selection-context.tsx",
23
23
  "./is-next-redirect": "./src/is-next-redirect.ts"
24
24
  },
25
+ "scripts": {
26
+ "typecheck": "tsc --noEmit",
27
+ "lint": "tsc --noEmit"
28
+ },
25
29
  "peerDependencies": {
26
30
  "@medusajs/types": "^2.0.0",
27
31
  "@pradip1995/commerce-core": "^4.0.0",
@@ -36,9 +40,5 @@
36
40
  "@types/react": "^19",
37
41
  "react": "19.0.3",
38
42
  "typescript": "^5.7.2"
39
- },
40
- "scripts": {
41
- "typecheck": "tsc --noEmit",
42
- "lint": "tsc --noEmit"
43
43
  }
44
- }
44
+ }
@@ -64,3 +64,23 @@ export function safeErrorMessage(err: unknown, fallback: string): string {
64
64
  export function isNextRedirectMessage(value: unknown): boolean {
65
65
  return typeof value === "string" && textLooksLikeControlFlow(value)
66
66
  }
67
+
68
+ const SHIPPING_PROFILE_RE = /shipping profiles that are not satisfied/i
69
+ const RSC_DIGEST_RE =
70
+ /Server Components render|digest property is included on this error/i
71
+
72
+ /**
73
+ * Maps checkout/payment failures to an actionable message.
74
+ * Production Next.js often replaces the Medusa shipping-profile error with an RSC digest.
75
+ */
76
+ export function checkoutPaymentErrorMessage(err: unknown): string {
77
+ const fallback = "Payment could not be started."
78
+ const msg = safeErrorMessage(err, fallback)
79
+ if (SHIPPING_PROFILE_RE.test(msg)) {
80
+ return "This product has no shipping profile, so checkout cannot complete. In Medusa Admin, open the product and assign the Default shipping profile (the same one used by Express/Standard shipping)."
81
+ }
82
+ if (RSC_DIGEST_RE.test(msg)) {
83
+ return "Checkout could not complete. If this happens only for one product, assign it a shipping profile in Medusa Admin (same profile as your shipping methods) and try again."
84
+ }
85
+ return msg
86
+ }
@@ -13,12 +13,6 @@ export function resolveMediaUrl(
13
13
  if (!trimmed) return null
14
14
 
15
15
  if (trimmed.startsWith("/")) {
16
- const isBackendUpload =
17
- trimmed.startsWith("/static/") || trimmed.startsWith("/uploads/")
18
- if (isBackendUpload) {
19
- const base = mediaBackendBase()
20
- if (base) return `${base.replace(/\/$/, "")}${trimmed}`
21
- }
22
16
  return trimmed
23
17
  }
24
18
 
@@ -149,4 +143,3 @@ export function resolveCartLineItemImage(item: CartLineImageSource): string | nu
149
143
 
150
144
  return null
151
145
  }
152
-