fast-simon-sdk 1.6.142 → 1.6.144

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;
@@ -40,7 +45,7 @@ function readMerchantCompanyLocation() {
40
45
  if (typeof fn !== "function") {
41
46
  if (!warnedNotFunction) {
42
47
  warnedNotFunction = true;
43
- console.warn("[FastSimon] __fast_options.companyLocationProvider is set but is not a function; ignoring.");
48
+ console.warn("[Fast Simon] __fast_options.companyLocationProvider is set but is not a function; ignoring.");
44
49
  }
45
50
  return undefined;
46
51
  }
@@ -51,7 +56,7 @@ function readMerchantCompanyLocation() {
51
56
  catch (err) {
52
57
  if (!warnedThrew) {
53
58
  warnedThrew = true;
54
- console.warn("[FastSimon] __fast_options.companyLocationProvider threw:", err);
59
+ console.warn("[Fast Simon] __fast_options.companyLocationProvider threw:", err);
55
60
  }
56
61
  return undefined;
57
62
  }
@@ -59,12 +64,14 @@ function readMerchantCompanyLocation() {
59
64
  not a misconfiguration -- the same provider runs for B2C and B2B visitors alike. */
60
65
  if (value === undefined || value === null)
61
66
  return undefined;
62
- /* Numbers are accepted: Shopify exposes the location as a GID string, but a merchant reading
63
- the id off their own data layer can reasonably hand us the bare numeric id. */
67
+ /* Numbers are accepted because the likeliest source hands one over: Liquid's
68
+ `customer.current_location.id` is a NUMBER, and rendering it into the page is the cheapest
69
+ way for a Shopify theme to supply this. The GraphQL APIs give the `gid://` string form for
70
+ the same location, so both spellings reach us and both are sent verbatim. */
64
71
  if (typeof value !== "string" && typeof value !== "number") {
65
72
  if (!warnedNonString) {
66
73
  warnedNonString = true;
67
- console.warn("[FastSimon] __fast_options.companyLocationProvider returned a non-string value; ignoring. Got:", value);
74
+ console.warn("[Fast Simon] __fast_options.companyLocationProvider returned a non-string value; ignoring. Got:", value);
68
75
  }
69
76
  return undefined;
70
77
  }
@@ -79,11 +86,19 @@ function getCompanyLocationContext(hasShopifyMarkets) {
79
86
  var _a;
80
87
  if (!hasShopifyMarkets)
81
88
  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. */
89
+ /* Read the provider FIRST, exactly as resolveCartToken does, so a misconfigured one still
90
+ warns. Gating this call on hasCompanyLocationProvider() instead would make the "set but not
91
+ a function" warning unreachable from the only entry point anyone calls. */
92
+ var fromProvider = readMerchantCompanyLocation();
93
+ if (fromProvider)
94
+ return fromProvider;
95
+ /* A WORKING provider is AUTHORITATIVE: it returns undefined for a shopper who is not buying on
96
+ behalf of a company, and falling back to the global there would send the previous or another
97
+ shopper's location, which serves the wrong catalog. A misconfigured provider is not a working
98
+ one, so it falls through to the global below having already warned -- the same treatment
99
+ resolveCartToken gives a non-function provider. */
85
100
  if (hasCompanyLocationProvider())
86
- return readMerchantCompanyLocation();
101
+ return undefined;
87
102
  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
103
  if (fromGlobal === undefined || fromGlobal === null)
89
104
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"companyLocation.js","sourceRoot":"","sources":["../../src/utils/companyLocation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;8DAiB8D;;AAQ9D,gEAEC;AAGD,kEA2CC;AAID,8DAaC;AAvED;wFACwF;AACxF,IAAI,iBAAiB,GAAG,KAAK,CAAC;AAC9B,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B,SAAgB,0BAA0B;;IACtC,OAAO,OAAO,CAA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