fast-simon-sdk 1.6.142 → 1.6.143

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,3 +1,3 @@
1
1
  export declare function hasCompanyLocationProvider(): boolean;
2
2
  export declare function readMerchantCompanyLocation(): string | undefined;
3
- export declare function getCompanyLocationContext(hasShopifyMarkets: boolean): string | undefined;
3
+ export declare function getCompanyLocationContext(hasShopifyMarkets: boolean | undefined): string | undefined;
@@ -5,18 +5,23 @@
5
5
  location it evaluates the buyer as an ordinary shopper in their market, and on a store that
6
6
  restricts products to a B2B catalog the buyer's own catalog is hidden from them (ZD 114806).
7
7
 
8
- The historic source is window.__FAST_CUSTOMER_DETAILS.customer_current_location, read here and
9
- in 21 other files across the frontends and written by NOTHING we ship -- no SDK code, no theme
10
- extension, no init option. So the parameter has never gone out on Shopify B2B unless a merchant
11
- populated that global themselves, which nothing documents. `companyLocationProvider` is the
12
- supported channel; the global stays as a fallback so a storefront already setting it keeps
13
- working.
8
+ The historic source is window.__FAST_CUSTOMER_DETAILS.customer_current_location, read across
9
+ the frontends and written by NOTHING we ship -- no SDK code, no theme extension, no init
10
+ option. So the parameter has never gone out on Shopify B2B unless a merchant populated that
11
+ global themselves, which nothing documents. `companyLocationProvider` is the supported
12
+ channel; the global stays as a fallback so a storefront already setting it keeps working.
14
13
 
15
- Mirrors __fast_options.cartTokenProvider in ./cartToken deliberately, including resolving on
16
- every CALL rather than at init: a B2B buyer switches location mid-session (Shopify's location
17
- picker, or masquerading between companies), and a value pinned at boot would keep serving the
18
- previous location's catalog. This is the same reason BigCommerce B2B reads customer_group_id
19
- from the live storefront context instead of the app JWT. */
14
+ Mirrors the SDK's __fast_options.cartTokenProvider deliberately, including resolving on every
15
+ CALL rather than at init: a B2B buyer switches location mid-session (Shopify's location picker,
16
+ or masquerading between companies), and a value pinned at boot would keep serving the previous
17
+ location's catalog. This is the same reason BigCommerce B2B reads customer_group_id from the
18
+ live storefront context instead of the app JWT.
19
+
20
+ Read straight off `window` rather than through this package's options store: the provider is
21
+ called per request and must not depend on store hydration order.
22
+
23
+ ⚠️ HAND-MAINTAINED COPY, one per frontend package, exactly as getCustomerGroupId.ts is.
24
+ Keep the copies identical -- grep `companyLocationProvider` before changing one. */
20
25
  Object.defineProperty(exports, "__esModule", { value: true });
21
26
  exports.hasCompanyLocationProvider = hasCompanyLocationProvider;
22
27
  exports.readMerchantCompanyLocation = readMerchantCompanyLocation;
@@ -79,11 +84,19 @@ function getCompanyLocationContext(hasShopifyMarkets) {
79
84
  var _a;
80
85
  if (!hasShopifyMarkets)
81
86
  return undefined;
82
- /* A configured provider is AUTHORITATIVE, exactly as cartTokenProvider is: it returns undefined
83
- for a shopper who is not buying on behalf of a company, and falling back to the global there
84
- would send the previous or another shopper's location, which serves the wrong catalog. */
87
+ /* Read the provider FIRST, exactly as resolveCartToken does, so a misconfigured one still
88
+ warns. Gating this call on hasCompanyLocationProvider() instead would make the "set but not
89
+ a function" warning unreachable from the only entry point anyone calls. */
90
+ var fromProvider = readMerchantCompanyLocation();
91
+ if (fromProvider)
92
+ return fromProvider;
93
+ /* A WORKING provider is AUTHORITATIVE: it returns undefined for a shopper who is not buying on
94
+ behalf of a company, and falling back to the global there would send the previous or another
95
+ shopper's location, which serves the wrong catalog. A misconfigured provider is not a working
96
+ one, so it falls through to the global below having already warned -- the same treatment
97
+ resolveCartToken gives a non-function provider. */
85
98
  if (hasCompanyLocationProvider())
86
- return readMerchantCompanyLocation();
99
+ return undefined;
87
100
  var fromGlobal = (_a = window === null || window === void 0 ? void 0 : window.__FAST_CUSTOMER_DETAILS) === null || _a === void 0 ? void 0 : _a.customer_current_location;
88
101
  if (fromGlobal === undefined || fromGlobal === null)
89
102
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"companyLocation.js","sourceRoot":"","sources":["../../src/utils/companyLocation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;8DAiB8D;;AAQ9D,gEAEC;A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