@salesforce/storefront-next-runtime 0.4.0-alpha.1 → 0.4.0-alpha.2

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/README.md CHANGED
@@ -55,6 +55,9 @@ Utilities and middleware for reading scoped entries from the MRT data access lay
55
55
  - `AWS_REGION` (required): AWS region for the data store table (e.g., `us-east-1`)
56
56
  - `MOBIFY_PROPERTY_ID` (required): MRT property identifier (e.g., `abcd1234`)
57
57
  - `DEPLOY_TARGET` (required): MRT deploy target (e.g., `production`)
58
+ - `SFNEXT_DATA_STORE_UNAVAILABLE_MODE` (optional): controls middleware behavior when MRT data store is unavailable
59
+ - `throw` (default): fail fast by throwing
60
+ - `fallback`: use middleware-defined safe fallback values and continue request execution
58
61
 
59
62
  These are managed by Managed Runtime and are not typically set by SDK consumers directly.
60
63
 
@@ -62,12 +65,7 @@ These are managed by Managed Runtime and are not typically set by SDK consumers
62
65
 
63
66
  The runtime auto-selects the MRT provider when all MRT environment variables are present.
64
67
  If any are missing, it loads a local provider from `@salesforce/storefront-next-dev` in
65
- development or when explicitly allowed.
66
-
67
- Local provider opt-in outside development:
68
-
69
- - `SFNEXT_DATA_STORE_ALLOW_LOCAL` (optional): set to `true` to allow local provider
70
- - `CI` (optional): when set to `true`, allows the local provider
68
+ development.
71
69
 
72
70
  Local provider environment variables (development only):
73
71
 
@@ -1,11 +1,11 @@
1
- import * as react_router2 from "react-router";
1
+ import * as react_router1 from "react-router";
2
2
  import { RouterContextProvider } from "react-router";
3
3
 
4
4
  //#region src/data-store/middleware/custom-global-preferences.d.ts
5
5
 
6
6
  type CustomGlobalPreferences = Record<string, unknown>;
7
7
  declare const DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY = "custom-global-preferences";
8
- declare const customGlobalPreferencesContext: react_router2.RouterContext<CustomGlobalPreferences | null>;
8
+ declare const customGlobalPreferencesContext: react_router1.RouterContext<CustomGlobalPreferences | null>;
9
9
  /**
10
10
  * Read custom global preferences from router context.
11
11
  *
@@ -14,7 +14,7 @@ declare const customGlobalPreferencesContext: react_router2.RouterContext<Custom
14
14
  * @throws Error when the data-store context is not available
15
15
  */
16
16
  declare function getCustomGlobalPreferences(context: Readonly<RouterContextProvider>): CustomGlobalPreferences;
17
- declare const customGlobalPreferencesMiddleware: react_router2.MiddlewareFunction<Response>;
17
+ declare const customGlobalPreferencesMiddleware: react_router1.MiddlewareFunction<Response>;
18
18
  //#endregion
19
19
  export { getCustomGlobalPreferences as a, customGlobalPreferencesMiddleware as i, DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY as n, customGlobalPreferencesContext as r, CustomGlobalPreferences as t };
20
20
  //# sourceMappingURL=custom-global-preferences.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-global-preferences.d.ts","names":[],"sources":["../src/data-store/middleware/custom-global-preferences.ts"],"sourcesContent":[],"mappings":";;;;;KAmBY,uBAAA,GAA0B;cAEzB,qCAAA;cACA,gCAA8B,aAAA,CAAA,cAAA;;;;;;;;iBAS3B,0BAAA,UAAoC,SAAS,yBAAyB;cAYzE,mCAAiC,aAAA,CAAA,mBAAA"}
1
+ {"version":3,"file":"custom-global-preferences.d.ts","names":[],"sources":["../src/data-store/middleware/custom-global-preferences.ts"],"sourcesContent":[],"mappings":";;;;;KAmBY,uBAAA,GAA0B;cAEzB,qCAAA;cACA,gCAA8B,aAAA,CAAA,cAAA;;;;;;;;iBAU3B,0BAAA,UAAoC,SAAS,yBAAyB;cAYzE,mCAAiC,aAAA,CAAA,mBAAA"}
@@ -3,6 +3,7 @@ import { n as createDataStoreMiddleware, t as createDataStoreContext } from "./u
3
3
  //#region src/data-store/middleware/custom-global-preferences.ts
4
4
  const DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY = "custom-global-preferences";
5
5
  const customGlobalPreferencesContext = createDataStoreContext();
6
+ const DATA_STORE_UNAVAILABLE_MODE = process.env.SFNEXT_DATA_STORE_UNAVAILABLE_MODE;
6
7
  /**
7
8
  * Read custom global preferences from router context.
8
9
  *
@@ -20,7 +21,9 @@ function getCustomGlobalPreferences(context) {
20
21
  }
21
22
  const customGlobalPreferencesMiddleware = createDataStoreMiddleware({
22
23
  entryKey: DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY,
23
- context: customGlobalPreferencesContext
24
+ context: customGlobalPreferencesContext,
25
+ onUnavailable: DATA_STORE_UNAVAILABLE_MODE === "fallback" ? "fallback" : "throw",
26
+ fallbackValue: {}
24
27
  });
25
28
 
26
29
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"custom-global-preferences.js","names":[],"sources":["../src/data-store/middleware/custom-global-preferences.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RouterContextProvider } from 'react-router';\nimport { createDataStoreContext, createDataStoreMiddleware } from '../utils';\n\nexport type CustomGlobalPreferences = Record<string, unknown>;\n\nexport const DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY = 'custom-global-preferences';\nexport const customGlobalPreferencesContext = createDataStoreContext<CustomGlobalPreferences>();\n\n/**\n * Read custom global preferences from router context.\n *\n * @param context - Router context provider\n * @returns Custom global preferences data stored by data-store middleware\n * @throws Error when the data-store context is not available\n */\nexport function getCustomGlobalPreferences(context: Readonly<RouterContextProvider>): CustomGlobalPreferences {\n const data = context.get(customGlobalPreferencesContext);\n if (!data) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Custom global preferences context not found. Ensure data-store middleware runs before loaders and the required env vars are set.'\n );\n return {};\n }\n return data;\n}\n\nexport const customGlobalPreferencesMiddleware = createDataStoreMiddleware({\n entryKey: DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY,\n context: customGlobalPreferencesContext,\n});\n"],"mappings":";;;AAqBA,MAAa,wCAAwC;AACrD,MAAa,iCAAiC,wBAAiD;;;;;;;;AAS/F,SAAgB,2BAA2B,SAAmE;CAC1G,MAAM,OAAO,QAAQ,IAAI,+BAA+B;AACxD,KAAI,CAAC,MAAM;AAEP,UAAQ,KACJ,mIACH;AACD,SAAO,EAAE;;AAEb,QAAO;;AAGX,MAAa,oCAAoC,0BAA0B;CACvE,UAAU;CACV,SAAS;CACZ,CAAC"}
1
+ {"version":3,"file":"custom-global-preferences.js","names":[],"sources":["../src/data-store/middleware/custom-global-preferences.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RouterContextProvider } from 'react-router';\nimport { createDataStoreContext, createDataStoreMiddleware } from '../utils';\n\nexport type CustomGlobalPreferences = Record<string, unknown>;\n\nexport const DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY = 'custom-global-preferences';\nexport const customGlobalPreferencesContext = createDataStoreContext<CustomGlobalPreferences>();\nconst DATA_STORE_UNAVAILABLE_MODE = process.env.SFNEXT_DATA_STORE_UNAVAILABLE_MODE;\n\n/**\n * Read custom global preferences from router context.\n *\n * @param context - Router context provider\n * @returns Custom global preferences data stored by data-store middleware\n * @throws Error when the data-store context is not available\n */\nexport function getCustomGlobalPreferences(context: Readonly<RouterContextProvider>): CustomGlobalPreferences {\n const data = context.get(customGlobalPreferencesContext);\n if (!data) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Custom global preferences context not found. Ensure data-store middleware runs before loaders and the required env vars are set.'\n );\n return {};\n }\n return data;\n}\n\nexport const customGlobalPreferencesMiddleware = createDataStoreMiddleware({\n entryKey: DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY,\n context: customGlobalPreferencesContext,\n onUnavailable: DATA_STORE_UNAVAILABLE_MODE === 'fallback' ? 'fallback' : 'throw',\n fallbackValue: {},\n});\n"],"mappings":";;;AAqBA,MAAa,wCAAwC;AACrD,MAAa,iCAAiC,wBAAiD;AAC/F,MAAM,8BAA8B,QAAQ,IAAI;;;;;;;;AAShD,SAAgB,2BAA2B,SAAmE;CAC1G,MAAM,OAAO,QAAQ,IAAI,+BAA+B;AACxD,KAAI,CAAC,MAAM;AAEP,UAAQ,KACJ,mIACH;AACD,SAAO,EAAE;;AAEb,QAAO;;AAGX,MAAa,oCAAoC,0BAA0B;CACvE,UAAU;CACV,SAAS;CACT,eAAe,gCAAgC,aAAa,aAAa;CACzE,eAAe,EAAE;CACpB,CAAC"}
@@ -1,11 +1,11 @@
1
- import * as react_router4 from "react-router";
1
+ import * as react_router0 from "react-router";
2
2
  import { RouterContextProvider } from "react-router";
3
3
 
4
4
  //#region src/data-store/middleware/custom-site-preferences.d.ts
5
5
 
6
6
  type SitePreferences = Record<string, unknown>;
7
7
  declare const DEFAULT_SITE_PREFERENCES_KEY = "site-preferences";
8
- declare const sitePreferencesContext: react_router4.RouterContext<SitePreferences | null>;
8
+ declare const sitePreferencesContext: react_router0.RouterContext<SitePreferences | null>;
9
9
  /**
10
10
  * Read site preferences from router context.
11
11
  *
@@ -14,7 +14,7 @@ declare const sitePreferencesContext: react_router4.RouterContext<SitePreference
14
14
  * @throws Error when the data-store context is not available
15
15
  */
16
16
  declare function getSitePreferences(context: Readonly<RouterContextProvider>): SitePreferences;
17
- declare const customSitePreferencesMiddleware: react_router4.MiddlewareFunction<Response>;
17
+ declare const customSitePreferencesMiddleware: react_router0.MiddlewareFunction<Response>;
18
18
  //#endregion
19
19
  export { sitePreferencesContext as a, getSitePreferences as i, SitePreferences as n, customSitePreferencesMiddleware as r, DEFAULT_SITE_PREFERENCES_KEY as t };
20
20
  //# sourceMappingURL=custom-site-preferences.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom-site-preferences.d.ts","names":[],"sources":["../src/data-store/middleware/custom-site-preferences.ts"],"sourcesContent":[],"mappings":";;;;;KAmBY,eAAA,GAAkB;cAEjB,4BAAA;cACA,wBAAsB,aAAA,CAAA,cAAA;;;;;;;;iBASnB,kBAAA,UAA4B,SAAS,yBAAyB;cAYjE,iCAA+B,aAAA,CAAA,mBAAA"}
1
+ {"version":3,"file":"custom-site-preferences.d.ts","names":[],"sources":["../src/data-store/middleware/custom-site-preferences.ts"],"sourcesContent":[],"mappings":";;;;;KAmBY,eAAA,GAAkB;cAEjB,4BAAA;cACA,wBAAsB,aAAA,CAAA,cAAA;;;;;;;;iBAUnB,kBAAA,UAA4B,SAAS,yBAAyB;cAYjE,iCAA+B,aAAA,CAAA,mBAAA"}
@@ -1,8 +1,9 @@
1
- import { n as createDataStoreMiddleware, r as prefixWithSiteId, t as createDataStoreContext } from "./utils.js";
1
+ import { i as prefixWithSiteId, n as createDataStoreMiddleware, t as createDataStoreContext } from "./utils.js";
2
2
 
3
3
  //#region src/data-store/middleware/custom-site-preferences.ts
4
4
  const DEFAULT_SITE_PREFERENCES_KEY = "site-preferences";
5
5
  const sitePreferencesContext = createDataStoreContext();
6
+ const DATA_STORE_UNAVAILABLE_MODE = process.env.SFNEXT_DATA_STORE_UNAVAILABLE_MODE;
6
7
  /**
7
8
  * Read site preferences from router context.
8
9
  *
@@ -20,7 +21,9 @@ function getSitePreferences(context) {
20
21
  }
21
22
  const customSitePreferencesMiddleware = createDataStoreMiddleware({
22
23
  entryKey: prefixWithSiteId("custom-site-preferences"),
23
- context: sitePreferencesContext
24
+ context: sitePreferencesContext,
25
+ onUnavailable: DATA_STORE_UNAVAILABLE_MODE === "fallback" ? "fallback" : "throw",
26
+ fallbackValue: {}
24
27
  });
25
28
 
26
29
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"custom-site-preferences.js","names":[],"sources":["../src/data-store/middleware/custom-site-preferences.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RouterContextProvider } from 'react-router';\nimport { createDataStoreContext, createDataStoreMiddleware, prefixWithSiteId } from '../utils';\n\nexport type SitePreferences = Record<string, unknown>;\n\nexport const DEFAULT_SITE_PREFERENCES_KEY = 'site-preferences';\nexport const sitePreferencesContext = createDataStoreContext<SitePreferences>();\n\n/**\n * Read site preferences from router context.\n *\n * @param context - Router context provider\n * @returns Site preferences data stored by data-store middleware\n * @throws Error when the data-store context is not available\n */\nexport function getSitePreferences(context: Readonly<RouterContextProvider>): SitePreferences {\n const data = context.get(sitePreferencesContext);\n if (!data) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Data store context not found. Ensure data-store middleware runs before loaders and the required env vars are set.'\n );\n return {};\n }\n return data;\n}\n\nexport const customSitePreferencesMiddleware = createDataStoreMiddleware({\n entryKey: prefixWithSiteId('custom-site-preferences'),\n context: sitePreferencesContext,\n});\n"],"mappings":";;;AAqBA,MAAa,+BAA+B;AAC5C,MAAa,yBAAyB,wBAAyC;;;;;;;;AAS/E,SAAgB,mBAAmB,SAA2D;CAC1F,MAAM,OAAO,QAAQ,IAAI,uBAAuB;AAChD,KAAI,CAAC,MAAM;AAEP,UAAQ,KACJ,oHACH;AACD,SAAO,EAAE;;AAEb,QAAO;;AAGX,MAAa,kCAAkC,0BAA0B;CACrE,UAAU,iBAAiB,0BAA0B;CACrD,SAAS;CACZ,CAAC"}
1
+ {"version":3,"file":"custom-site-preferences.js","names":[],"sources":["../src/data-store/middleware/custom-site-preferences.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RouterContextProvider } from 'react-router';\nimport { createDataStoreContext, createDataStoreMiddleware, prefixWithSiteId } from '../utils';\n\nexport type SitePreferences = Record<string, unknown>;\n\nexport const DEFAULT_SITE_PREFERENCES_KEY = 'site-preferences';\nexport const sitePreferencesContext = createDataStoreContext<SitePreferences>();\nconst DATA_STORE_UNAVAILABLE_MODE = process.env.SFNEXT_DATA_STORE_UNAVAILABLE_MODE;\n\n/**\n * Read site preferences from router context.\n *\n * @param context - Router context provider\n * @returns Site preferences data stored by data-store middleware\n * @throws Error when the data-store context is not available\n */\nexport function getSitePreferences(context: Readonly<RouterContextProvider>): SitePreferences {\n const data = context.get(sitePreferencesContext);\n if (!data) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Data store context not found. Ensure data-store middleware runs before loaders and the required env vars are set.'\n );\n return {};\n }\n return data;\n}\n\nexport const customSitePreferencesMiddleware = createDataStoreMiddleware({\n entryKey: prefixWithSiteId('custom-site-preferences'),\n context: sitePreferencesContext,\n onUnavailable: DATA_STORE_UNAVAILABLE_MODE === 'fallback' ? 'fallback' : 'throw',\n fallbackValue: {},\n});\n"],"mappings":";;;AAqBA,MAAa,+BAA+B;AAC5C,MAAa,yBAAyB,wBAAyC;AAC/E,MAAM,8BAA8B,QAAQ,IAAI;;;;;;;;AAShD,SAAgB,mBAAmB,SAA2D;CAC1F,MAAM,OAAO,QAAQ,IAAI,uBAAuB;AAChD,KAAI,CAAC,MAAM;AAEP,UAAQ,KACJ,oHACH;AACD,SAAO,EAAE;;AAEb,QAAO;;AAGX,MAAa,kCAAkC,0BAA0B;CACrE,UAAU,iBAAiB,0BAA0B;CACrD,SAAS;CACT,eAAe,gCAAgC,aAAa,aAAa;CACzE,eAAe,EAAE;CACpB,CAAC"}
@@ -1,6 +1,6 @@
1
- import "./utils.js";
2
1
  import "./site-context2.js";
3
2
  import "./apply-url-config.js";
3
+ import "./utils.js";
4
4
  import { i as getCustomGlobalPreferences, n as customGlobalPreferencesContext, r as customGlobalPreferencesMiddleware, t as DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY } from "./custom-global-preferences.js";
5
5
 
6
6
  export { DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY, customGlobalPreferencesContext, customGlobalPreferencesMiddleware, getCustomGlobalPreferences };
@@ -1,6 +1,6 @@
1
- import "./utils.js";
2
1
  import "./site-context2.js";
3
2
  import "./apply-url-config.js";
3
+ import "./utils.js";
4
4
  import { i as sitePreferencesContext, n as customSitePreferencesMiddleware, r as getSitePreferences, t as DEFAULT_SITE_PREFERENCES_KEY } from "./custom-site-preferences.js";
5
5
 
6
6
  export { DEFAULT_SITE_PREFERENCES_KEY, customSitePreferencesMiddleware, getSitePreferences, sitePreferencesContext };
@@ -1,6 +1,6 @@
1
- import "./utils.js";
2
1
  import "./site-context2.js";
3
2
  import "./apply-url-config.js";
3
+ import "./utils.js";
4
4
  import { a as getGcpPreferences, i as getGcpApiKey, n as gcpPreferencesContext, r as gcpPreferencesMiddleware, t as DEFAULT_GCP_PREFERENCES_KEY } from "./gcp-preferences.js";
5
5
 
6
6
  export { DEFAULT_GCP_PREFERENCES_KEY, gcpPreferencesContext, gcpPreferencesMiddleware, getGcpApiKey, getGcpPreferences };
@@ -1,59 +1,23 @@
1
1
  import { a as sitePreferencesContext, i as getSitePreferences, n as SitePreferences, t as DEFAULT_SITE_PREFERENCES_KEY } from "./custom-site-preferences.js";
2
2
  import { a as getCustomGlobalPreferences, n as DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY, r as customGlobalPreferencesContext, t as CustomGlobalPreferences } from "./custom-global-preferences.js";
3
3
  import { a as getGcpApiKey, n as GcpPreferences, o as getGcpPreferences, r as gcpPreferencesContext, t as DEFAULT_GCP_PREFERENCES_KEY } from "./gcp-preferences.js";
4
- import * as react_router11 from "react-router";
4
+ import * as react_router7 from "react-router";
5
5
  import { MiddlewareFunction, RouterContextProvider, createContext } from "react-router";
6
- import { DataStoreNotFoundError, DataStoreServiceError, DataStoreUnavailableError } from "@salesforce/mrt-utilities";
6
+ import { DataStore, DataStoreNotFoundError, DataStoreServiceError, DataStoreUnavailableError } from "@salesforce/mrt-utilities/data-store";
7
7
 
8
- //#region src/data-store/provider.d.ts
8
+ //#region src/data-store/utils.d.ts
9
9
 
10
- /**
11
- * Copyright 2026 Salesforce, Inc.
12
- *
13
- * Licensed under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at
16
- *
17
- * http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
24
- */
10
+ type DataStoreContextKey<T> = ReturnType<typeof createContext<T | null>>;
11
+ type DataStoreEntryKey = string | ((context: Readonly<RouterContextProvider>) => string);
25
12
  type DataStoreEntry<TValue = unknown> = {
26
13
  value?: TValue;
27
14
  };
28
- type DataStoreProvider = {
29
- kind: 'mrt' | 'local';
30
- getEntry: <TValue = unknown>(key: string) => Promise<DataStoreEntry<TValue> | null>;
31
- };
32
- /**
33
- * Resolve the default data-store provider based on MRT environment variables.
34
- *
35
- * Environment variables:
36
- * - `AWS_REGION` (required for MRT): AWS region for the data store table (e.g., "us-east-1")
37
- * - `MOBIFY_PROPERTY_ID` (required for MRT): MRT property identifier (e.g., "abcd1234")
38
- * - `DEPLOY_TARGET` (required for MRT): MRT deploy target (e.g., "production")
39
- * - `SFNEXT_DATA_STORE_ALLOW_LOCAL` (optional): allow local provider outside development ("true")
40
- * - `CI` (optional): allow local provider when set to "true"
41
- *
42
- * @returns Provider promise resolved for the current environment.
43
- * @example
44
- * const provider = await getDefaultDataStoreProvider();
45
- * const entry = await provider.getEntry('custom-global-preferences');
46
- */
47
- declare function getDefaultDataStoreProvider(): Promise<DataStoreProvider>;
48
- //#endregion
49
- //#region src/data-store/utils.d.ts
50
- type DataStoreContextKey<T> = ReturnType<typeof createContext<T | null>>;
51
- type DataStoreEntryKey = string | ((context: Readonly<RouterContextProvider>) => string);
52
15
  type DataStoreMiddlewareOptions<T> = {
53
16
  entryKey: DataStoreEntryKey;
54
17
  context: DataStoreContextKey<T>;
55
18
  transform?: (value: Record<string, unknown>) => T;
56
- provider?: DataStoreProvider | Promise<DataStoreProvider>;
19
+ onUnavailable?: 'throw' | 'fallback';
20
+ fallbackValue?: T | ((context: Readonly<RouterContextProvider>) => T);
57
21
  };
58
22
  /**
59
23
  * Creates a typed React Router context for data store entries.
@@ -76,12 +40,21 @@ declare function createDataStoreContext<T>(): DataStoreContextKey<T>;
76
40
  * @returns React Router middleware for server requests
77
41
  */
78
42
  declare function createDataStoreMiddleware<T>(options: DataStoreMiddlewareOptions<T>): MiddlewareFunction<Response>;
43
+ /**
44
+ * Read a data-store entry through the singleton MRT utilities API.
45
+ * The underlying implementation (production DynamoDB vs development pseudo store)
46
+ * is resolved by `@salesforce/mrt-utilities/data-store` export conditions.
47
+ *
48
+ * @param key - Data-store entry key
49
+ * @returns Data-store entry or null when missing/invalid shape
50
+ */
51
+ declare function getDataStoreEntry<TValue = unknown>(key: string): Promise<DataStoreEntry<TValue> | null>;
79
52
  //#endregion
80
53
  //#region src/data-store/middleware/login-preferences.d.ts
81
54
  type LoginPreferences = {
82
55
  emailVerificationEnabled?: boolean;
83
56
  };
84
- declare const loginPreferencesContext: react_router11.RouterContext<LoginPreferences | null>;
57
+ declare const loginPreferencesContext: react_router7.RouterContext<LoginPreferences | null>;
85
58
  /**
86
59
  * Read login preferences from router context.
87
60
  *
@@ -91,7 +64,7 @@ declare const loginPreferencesContext: react_router11.RouterContext<LoginPrefere
91
64
  declare function getLoginPreferences(context: Readonly<RouterContextProvider>): LoginPreferences;
92
65
  //#endregion
93
66
  //#region src/data-store/index.d.ts
94
- declare const dataStoreMiddleware: react_router11.MiddlewareFunction<Response>[];
67
+ declare const dataStoreMiddleware: react_router7.MiddlewareFunction<Response>[];
95
68
  //#endregion
96
- export { type CustomGlobalPreferences, DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY, DEFAULT_GCP_PREFERENCES_KEY, DEFAULT_SITE_PREFERENCES_KEY, type DataStoreContextKey, type DataStoreEntry, type DataStoreEntryKey, type DataStoreMiddlewareOptions, DataStoreNotFoundError, type DataStoreProvider, DataStoreServiceError, DataStoreUnavailableError, type GcpPreferences, type LoginPreferences, type SitePreferences, createDataStoreContext, createDataStoreMiddleware, customGlobalPreferencesContext, dataStoreMiddleware, gcpPreferencesContext, getCustomGlobalPreferences, getDefaultDataStoreProvider, getGcpApiKey, getGcpPreferences, getLoginPreferences, getSitePreferences, loginPreferencesContext, sitePreferencesContext };
69
+ export { type CustomGlobalPreferences, DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY, DEFAULT_GCP_PREFERENCES_KEY, DEFAULT_SITE_PREFERENCES_KEY, DataStore, type DataStoreContextKey, type DataStoreEntry, type DataStoreEntryKey, type DataStoreMiddlewareOptions, DataStoreNotFoundError, DataStoreServiceError, DataStoreUnavailableError, type GcpPreferences, type LoginPreferences, type SitePreferences, createDataStoreContext, createDataStoreMiddleware, customGlobalPreferencesContext, dataStoreMiddleware, gcpPreferencesContext, getCustomGlobalPreferences, getDataStoreEntry, getGcpApiKey, getGcpPreferences, getLoginPreferences, getSitePreferences, loginPreferencesContext, sitePreferencesContext };
97
70
  //# sourceMappingURL=data-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-store.d.ts","names":[],"sources":["../src/data-store/provider.ts","../src/data-store/utils.ts","../src/data-store/middleware/login-preferences.ts","../src/data-store/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;AAmBA;AAIA;;;;;AA+BA;KAnCY;UACA;;ACKA,KDFA,iBAAA,GCEmB;EAAsC,IAAA,EAAA,KAAA,GAAA,OAAA;EAAd,QAAA,EAAA,CAAA,SAAA,OAAA,CAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GDAN,OCAM,CDAE,cCAF,CDAiB,MCAjB,CAAA,GAAA,IAAA,CAAA;CAAlB;;;;;;;AAkBrC;AAgBA;;;;;;;;iBDLgB,2BAAA,CAAA,GAA+B,QAAQ;;;KC7B3C,yBAAyB,kBAAkB,cAAc;AAAzD,KAEA,iBAAA,GAFmB,MAAA,GAAA,CAAA,CAAA,OAAA,EAEqB,QAFrB,CAE8B,qBAF9B,CAAA,EAAA,GAAA,MAAA,CAAA;AAAsC,KAIzD,0BAJyD,CAAA,CAAA,CAAA,GAAA;EAAd,QAAA,EAKzC,iBALyC;EAAlB,OAAA,EAMxB,mBANwB,CAMJ,CANI,CAAA;EAAU,SAAA,CAAA,EAAA,CAAA,KAAA,EAOvB,MAPuB,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAOK,CAPL;EAEnC,QAAA,CAAA,EAMG,iBANc,GAMM,OAN0B,CAMlB,iBANS,CAAA;AAEpD,CAAA;;;;;;;;AAImC,iBAUnB,sBAVmB,CAAA,CAAA,CAAA,CAAA,CAAA,EAUU,mBAVV,CAU8B,CAV9B,CAAA;;AAUnC;AAgBA;;;;;;;;;ACxCA;AAIa,iBDoCG,yBCpCoB,CAAA,CAAA,CAAA,CAAA,OAAA,EDoCkB,0BCpClB,CDoC6C,CCpC7C,CAAA,CAAA,EDoCkD,kBCpClD,CDoCqE,QCpCrE,CAAA;;;KAJxB,gBAAA;;ADMZ,CAAA;AAAqE,cCFxD,uBDEwD,ECFjC,cAAA,CAAA,aDEiC,CCFjC,gBDEiC,GAAA,IAAA,CAAA;;;;AAErE;AAEA;;AAEiC,iBCAjB,mBAAA,CDAiB,OAAA,ECAY,QDAZ,CCAqB,qBDArB,CAAA,CAAA,ECA8C,gBDA9C;;;AAElB,cEiBF,mBFjBE,EEiBiB,cAAA,CAAA,kBFjBjB,CEiBiB,QFjBjB,CAAA,EAAA"}
1
+ {"version":3,"file":"data-store.d.ts","names":[],"sources":["../src/data-store/utils.ts","../src/data-store/middleware/login-preferences.ts","../src/data-store/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAkCc,KATF,mBASE,CAAA,CAAA,CAAA,GATuB,UASvB,CAAA,OATyC,aASzC,CATuD,CASvD,GAAA,IAAA,CAAA,CAAA;AACmB,KARrB,iBAAA,GAQqB,MAAA,GAAA,CAAA,CAAA,OAAA,EARmB,QAQnB,CAR4B,qBAQ5B,CAAA,EAAA,GAAA,MAAA,CAAA;AAApB,KAND,cAMC,CAAA,SAAA,OAAA,CAAA,GAAA;EACW,KAAA,CAAA,EANZ,MAMY;CAA4B;AAEhC,KALR,0BAKQ,CAAA,CAAA,CAAA,GAAA;EAAwB,QAAA,EAJ9B,iBAI8B;EAAT,OAAA,EAHtB,mBAGsB,CAHF,CAGE,CAAA;EAAoC,SAAA,CAAA,EAAA,CAAA,KAAA,EAF/C,MAE+C,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAFnB,CAEmB;EAAC,aAAA,CAAA,EAAA,OAAA,GAAA,UAAA;EAUxD,aAAA,CAAA,EAVI,CAUJ,GAAA,CAAA,CAAA,OAAsB,EAVH,QAU8B,CAVrB,qBAUC,CAAmB,EAAA,GAVO,CAUP,CAAA;AAgBhE,CAAA;;;;;;AAwDA;;AAAgF,iBAxEhE,sBAwEgE,CAAA,CAAA,CAAA,CAAA,CAAA,EAxEnC,mBAwEmC,CAxEf,CAwEe,CAAA;;;;;;ACrGhF;AAIA;AASA;;;;;iBDgCgB,sCAAsC,2BAA2B,KAAK,mBAAmB;;;AETzG;;;;;;iBFiEsB,kDAAkD,QAAQ,eAAe;;;AAtFjF,KCfF,gBAAA,GDeE;EACmB,wBAAA,CAAA,EAAA,OAAA;CAApB;AACW,cCbX,uBDaW,ECbY,aAAA,CAAA,aDaZ,CCbY,gBDaZ,GAAA,IAAA,CAAA;;;;;;;AAYR,iBChBA,mBAAA,CDgBiD,OAApB,EChBA,QDgBA,CChBS,qBDgBU,CAAA,CAAA,EChBe,gBDgBf;;;AAgBsB,cETzE,mBFSyE,EETtD,aAAA,CAAA,kBFSsD,CETtD,QFSsD,CAAA,EAAA"}
@@ -1,13 +1,14 @@
1
- import { i as getDefaultDataStoreProvider, n as createDataStoreMiddleware, r as prefixWithSiteId, t as createDataStoreContext } from "./utils.js";
2
1
  import "./site-context2.js";
3
2
  import "./apply-url-config.js";
3
+ import { i as prefixWithSiteId, n as createDataStoreMiddleware, r as getDataStoreEntry, t as createDataStoreContext } from "./utils.js";
4
4
  import { i as sitePreferencesContext, n as customSitePreferencesMiddleware, r as getSitePreferences, t as DEFAULT_SITE_PREFERENCES_KEY } from "./custom-site-preferences.js";
5
5
  import { i as getCustomGlobalPreferences, n as customGlobalPreferencesContext, r as customGlobalPreferencesMiddleware, t as DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY } from "./custom-global-preferences.js";
6
6
  import { a as getGcpPreferences, i as getGcpApiKey, n as gcpPreferencesContext, r as gcpPreferencesMiddleware, t as DEFAULT_GCP_PREFERENCES_KEY } from "./gcp-preferences.js";
7
- import { DataStoreNotFoundError, DataStoreServiceError, DataStoreUnavailableError } from "@salesforce/mrt-utilities";
7
+ import { DataStore, DataStoreNotFoundError, DataStoreServiceError, DataStoreUnavailableError } from "@salesforce/mrt-utilities/data-store";
8
8
 
9
9
  //#region src/data-store/middleware/login-preferences.ts
10
10
  const loginPreferencesContext = createDataStoreContext();
11
+ const DATA_STORE_UNAVAILABLE_MODE = process.env.SFNEXT_DATA_STORE_UNAVAILABLE_MODE;
11
12
  /**
12
13
  * Read login preferences from router context.
13
14
  *
@@ -25,6 +26,8 @@ function getLoginPreferences(context) {
25
26
  const loginPreferencesMiddleware = createDataStoreMiddleware({
26
27
  entryKey: prefixWithSiteId("login-preferences"),
27
28
  context: loginPreferencesContext,
29
+ onUnavailable: DATA_STORE_UNAVAILABLE_MODE === "fallback" ? "fallback" : "throw",
30
+ fallbackValue: { emailVerificationEnabled: false },
28
31
  transform: (value) => value.data
29
32
  });
30
33
 
@@ -38,5 +41,5 @@ const dataStoreMiddleware = [
38
41
  ];
39
42
 
40
43
  //#endregion
41
- export { DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY, DEFAULT_GCP_PREFERENCES_KEY, DEFAULT_SITE_PREFERENCES_KEY, DataStoreNotFoundError, DataStoreServiceError, DataStoreUnavailableError, createDataStoreContext, createDataStoreMiddleware, customGlobalPreferencesContext, dataStoreMiddleware, gcpPreferencesContext, getCustomGlobalPreferences, getDefaultDataStoreProvider, getGcpApiKey, getGcpPreferences, getLoginPreferences, getSitePreferences, loginPreferencesContext, sitePreferencesContext };
44
+ export { DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY, DEFAULT_GCP_PREFERENCES_KEY, DEFAULT_SITE_PREFERENCES_KEY, DataStore, DataStoreNotFoundError, DataStoreServiceError, DataStoreUnavailableError, createDataStoreContext, createDataStoreMiddleware, customGlobalPreferencesContext, dataStoreMiddleware, gcpPreferencesContext, getCustomGlobalPreferences, getDataStoreEntry, getGcpApiKey, getGcpPreferences, getLoginPreferences, getSitePreferences, loginPreferencesContext, sitePreferencesContext };
42
45
  //# sourceMappingURL=data-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-store.js","names":[],"sources":["../src/data-store/middleware/login-preferences.ts","../src/data-store/index.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RouterContextProvider } from 'react-router';\nimport { createDataStoreContext, createDataStoreMiddleware, prefixWithSiteId } from '../utils';\n\nexport type LoginPreferences = {\n emailVerificationEnabled?: boolean;\n};\n\nexport const loginPreferencesContext = createDataStoreContext<LoginPreferences>();\n\n/**\n * Read login preferences from router context.\n *\n * @param context - Router context provider\n * @returns Login preferences data stored by data-store middleware\n */\nexport function getLoginPreferences(context: Readonly<RouterContextProvider>): LoginPreferences {\n const data = context.get(loginPreferencesContext);\n if (!data) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Login preferences context not found. Ensure data-store middleware runs before loaders and the required env vars are set.'\n );\n return {};\n }\n return data;\n}\n\nexport const loginPreferencesMiddleware = createDataStoreMiddleware<LoginPreferences>({\n entryKey: prefixWithSiteId('login-preferences'),\n context: loginPreferencesContext,\n transform: (value) => value.data as LoginPreferences,\n});\n","/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { createDataStoreMiddleware } from './utils';\nexport { createDataStoreContext } from './utils';\nexport { getDefaultDataStoreProvider } from './provider';\nexport {\n DEFAULT_SITE_PREFERENCES_KEY,\n getSitePreferences,\n sitePreferencesContext,\n} from './middleware/custom-site-preferences';\nexport {\n customGlobalPreferencesContext,\n DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY,\n getCustomGlobalPreferences,\n} from './middleware/custom-global-preferences';\nexport {\n DEFAULT_GCP_PREFERENCES_KEY,\n gcpPreferencesContext,\n getGcpApiKey,\n getGcpPreferences,\n} from './middleware/gcp-preferences';\nexport type { DataStoreMiddlewareOptions } from './utils';\nexport type { SitePreferences } from './middleware/custom-site-preferences';\nexport type { DataStoreContextKey, DataStoreEntryKey } from './utils';\nexport type { DataStoreEntry, DataStoreProvider } from './provider';\nexport type { CustomGlobalPreferences } from './middleware/custom-global-preferences';\nexport { getLoginPreferences, loginPreferencesContext } from './middleware/login-preferences';\nexport type { LoginPreferences } from './middleware/login-preferences';\nexport type { GcpPreferences } from './middleware/gcp-preferences';\nexport { DataStoreNotFoundError, DataStoreServiceError, DataStoreUnavailableError } from '@salesforce/mrt-utilities';\n\nimport { customSitePreferencesMiddleware } from './middleware/custom-site-preferences';\nimport { customGlobalPreferencesMiddleware } from './middleware/custom-global-preferences';\nimport { gcpPreferencesMiddleware } from './middleware/gcp-preferences';\nimport { loginPreferencesMiddleware } from './middleware/login-preferences';\n\nexport const dataStoreMiddleware = [\n customSitePreferencesMiddleware,\n customGlobalPreferencesMiddleware,\n gcpPreferencesMiddleware,\n loginPreferencesMiddleware,\n];\n"],"mappings":";;;;;;;;;AAuBA,MAAa,0BAA0B,wBAA0C;;;;;;;AAQjF,SAAgB,oBAAoB,SAA4D;CAC5F,MAAM,OAAO,QAAQ,IAAI,wBAAwB;AACjD,KAAI,CAAC,MAAM;AAEP,UAAQ,KACJ,2HACH;AACD,SAAO,EAAE;;AAEb,QAAO;;AAGX,MAAa,6BAA6B,0BAA4C;CAClF,UAAU,iBAAiB,oBAAoB;CAC/C,SAAS;CACT,YAAY,UAAU,MAAM;CAC/B,CAAC;;;;ACGF,MAAa,sBAAsB;CAC/B;CACA;CACA;CACA;CACH"}
1
+ {"version":3,"file":"data-store.js","names":[],"sources":["../src/data-store/middleware/login-preferences.ts","../src/data-store/index.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RouterContextProvider } from 'react-router';\nimport { createDataStoreContext, createDataStoreMiddleware, prefixWithSiteId } from '../utils';\n\nexport type LoginPreferences = {\n emailVerificationEnabled?: boolean;\n};\n\nexport const loginPreferencesContext = createDataStoreContext<LoginPreferences>();\nconst DATA_STORE_UNAVAILABLE_MODE = process.env.SFNEXT_DATA_STORE_UNAVAILABLE_MODE;\n\n/**\n * Read login preferences from router context.\n *\n * @param context - Router context provider\n * @returns Login preferences data stored by data-store middleware\n */\nexport function getLoginPreferences(context: Readonly<RouterContextProvider>): LoginPreferences {\n const data = context.get(loginPreferencesContext);\n if (!data) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Login preferences context not found. Ensure data-store middleware runs before loaders and the required env vars are set.'\n );\n return {};\n }\n return data;\n}\n\nexport const loginPreferencesMiddleware = createDataStoreMiddleware<LoginPreferences>({\n entryKey: prefixWithSiteId('login-preferences'),\n context: loginPreferencesContext,\n onUnavailable: DATA_STORE_UNAVAILABLE_MODE === 'fallback' ? 'fallback' : 'throw',\n fallbackValue: { emailVerificationEnabled: false },\n transform: (value) => value.data as LoginPreferences,\n});\n","/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { createDataStoreMiddleware } from './utils';\nexport { createDataStoreContext } from './utils';\nexport { getDataStoreEntry } from './utils';\nexport {\n DEFAULT_SITE_PREFERENCES_KEY,\n getSitePreferences,\n sitePreferencesContext,\n} from './middleware/custom-site-preferences';\nexport {\n customGlobalPreferencesContext,\n DEFAULT_CUSTOM_GLOBAL_PREFERENCES_KEY,\n getCustomGlobalPreferences,\n} from './middleware/custom-global-preferences';\nexport {\n DEFAULT_GCP_PREFERENCES_KEY,\n gcpPreferencesContext,\n getGcpApiKey,\n getGcpPreferences,\n} from './middleware/gcp-preferences';\nexport type { DataStoreMiddlewareOptions } from './utils';\nexport type { SitePreferences } from './middleware/custom-site-preferences';\nexport type { DataStoreContextKey, DataStoreEntryKey } from './utils';\nexport type { DataStoreEntry } from './utils';\nexport type { CustomGlobalPreferences } from './middleware/custom-global-preferences';\nexport { getLoginPreferences, loginPreferencesContext } from './middleware/login-preferences';\nexport type { LoginPreferences } from './middleware/login-preferences';\nexport type { GcpPreferences } from './middleware/gcp-preferences';\nexport { DataStore } from '@salesforce/mrt-utilities/data-store';\nexport {\n DataStoreNotFoundError,\n DataStoreServiceError,\n DataStoreUnavailableError,\n} from '@salesforce/mrt-utilities/data-store';\n\nimport { customSitePreferencesMiddleware } from './middleware/custom-site-preferences';\nimport { customGlobalPreferencesMiddleware } from './middleware/custom-global-preferences';\nimport { gcpPreferencesMiddleware } from './middleware/gcp-preferences';\nimport { loginPreferencesMiddleware } from './middleware/login-preferences';\n\nexport const dataStoreMiddleware = [\n customSitePreferencesMiddleware,\n customGlobalPreferencesMiddleware,\n gcpPreferencesMiddleware,\n loginPreferencesMiddleware,\n];\n"],"mappings":";;;;;;;;;AAuBA,MAAa,0BAA0B,wBAA0C;AACjF,MAAM,8BAA8B,QAAQ,IAAI;;;;;;;AAQhD,SAAgB,oBAAoB,SAA4D;CAC5F,MAAM,OAAO,QAAQ,IAAI,wBAAwB;AACjD,KAAI,CAAC,MAAM;AAEP,UAAQ,KACJ,2HACH;AACD,SAAO,EAAE;;AAEb,QAAO;;AAGX,MAAa,6BAA6B,0BAA4C;CAClF,UAAU,iBAAiB,oBAAoB;CAC/C,SAAS;CACT,eAAe,gCAAgC,aAAa,aAAa;CACzE,eAAe,EAAE,0BAA0B,OAAO;CAClD,YAAY,UAAU,MAAM;CAC/B,CAAC;;;;ACKF,MAAa,sBAAsB;CAC/B;CACA;CACA;CACA;CACH"}
@@ -3,7 +3,7 @@ import { n as ComponentModule, o as FrameworkAdapter } from "./types3.js";
3
3
  import { g as IsomorphicConfiguration } from "./index.js";
4
4
  import { i as RegionDecoratorProps, t as ComponentDecoratorProps } from "./component.types.js";
5
5
  import React$1 from "react";
6
- import * as react_jsx_runtime1 from "react/jsx-runtime";
6
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
7
7
 
8
8
  //#region src/design/react/core/PageDesignerProvider.d.ts
9
9
  type PageDesignerContextType = {
@@ -49,7 +49,7 @@ declare function PageDesignerPageMetadataProvider({
49
49
  children
50
50
  }: React.PropsWithChildren<{
51
51
  page: ShopperExperience.schemas['Page'];
52
- }>): react_jsx_runtime1.JSX.Element;
52
+ }>): react_jsx_runtime0.JSX.Element;
53
53
  //#endregion
54
54
  //#region src/design/react/core/RegionContext.d.ts
55
55
  interface RegionContextType {
@@ -1,4 +1,4 @@
1
- import * as react_router0 from "react-router";
1
+ import * as react_router3 from "react-router";
2
2
  import { RouterContextProvider } from "react-router";
3
3
 
4
4
  //#region src/data-store/middleware/gcp-preferences.d.ts
@@ -15,7 +15,7 @@ type GcpPreferences = {
15
15
  apiKey: string;
16
16
  };
17
17
  declare const DEFAULT_GCP_PREFERENCES_KEY = "gcp";
18
- declare const gcpPreferencesContext: react_router0.RouterContext<GcpPreferences | null>;
18
+ declare const gcpPreferencesContext: react_router3.RouterContext<GcpPreferences | null>;
19
19
  /**
20
20
  * Read the GCP (Google Cloud Platform) preferences object from router context.
21
21
  *
@@ -46,7 +46,7 @@ declare function getGcpApiKey(context: Readonly<RouterContextProvider>): string;
46
46
  * Must run before any loader/middleware that reads `getGcpPreferences(context)`
47
47
  * or `getGcpApiKey(context)`.
48
48
  */
49
- declare const gcpPreferencesMiddleware: react_router0.MiddlewareFunction<Response>;
49
+ declare const gcpPreferencesMiddleware: react_router3.MiddlewareFunction<Response>;
50
50
  //#endregion
51
51
  export { getGcpApiKey as a, gcpPreferencesMiddleware as i, GcpPreferences as n, getGcpPreferences as o, gcpPreferencesContext as r, DEFAULT_GCP_PREFERENCES_KEY as t };
52
52
  //# sourceMappingURL=gcp-preferences.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gcp-preferences.d.ts","names":[],"sources":["../src/data-store/middleware/gcp-preferences.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;KA2BY,cAAA;;;cAIC,2BAAA;cAQA,uBAAqB,aAAA,CAAA,cAAA;;;;;;;;;;;;iBAalB,iBAAA,UAA2B,SAAS,yBAAyB;;;;;;;;;iBAoB7D,YAAA,UAAsB,SAAS;;;;;;;;;;cAalC,0BAAwB,aAAA,CAAA,mBAAA"}
1
+ {"version":3,"file":"gcp-preferences.d.ts","names":[],"sources":["../src/data-store/middleware/gcp-preferences.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;KA2BY,cAAA;;;cAIC,2BAAA;cASA,uBAAqB,aAAA,CAAA,cAAA;;;;;;;;;;;;iBAalB,iBAAA,UAA2B,SAAS,yBAAyB;;;;;;;;;iBAoB7D,YAAA,UAAsB,SAAS;;;;;;;;;;cAalC,0BAAwB,aAAA,CAAA,mBAAA"}
@@ -2,6 +2,7 @@ import { n as createDataStoreMiddleware, t as createDataStoreContext } from "./u
2
2
 
3
3
  //#region src/data-store/middleware/gcp-preferences.ts
4
4
  const DEFAULT_GCP_PREFERENCES_KEY = "gcp";
5
+ const DATA_STORE_UNAVAILABLE_MODE = process.env.SFNEXT_DATA_STORE_UNAVAILABLE_MODE;
5
6
  /**
6
7
  * Map keys inside the `gcp` data store entry. The ECOM MRT sync job writes
7
8
  * to these exact keys; keep in sync with the sync job contract.
@@ -50,6 +51,8 @@ function getGcpApiKey(context) {
50
51
  const gcpPreferencesMiddleware = createDataStoreMiddleware({
51
52
  entryKey: DEFAULT_GCP_PREFERENCES_KEY,
52
53
  context: gcpPreferencesContext,
54
+ onUnavailable: DATA_STORE_UNAVAILABLE_MODE === "fallback" ? "fallback" : "throw",
55
+ fallbackValue: { apiKey: "" },
53
56
  transform: (value) => {
54
57
  const rawKey = value[API_KEY_MAP_KEY];
55
58
  return { apiKey: typeof rawKey === "string" ? rawKey : "" };
@@ -1 +1 @@
1
- {"version":3,"file":"gcp-preferences.js","names":[],"sources":["../src/data-store/middleware/gcp-preferences.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RouterContextProvider } from 'react-router';\nimport { createDataStoreContext, createDataStoreMiddleware } from '../utils';\n\n/**\n * OOTB Google Cloud Platform preferences sourced from the MRT data store.\n *\n * Additional fields (e.g. `projectId`, `region`) may be added here as the\n * ECOM MRT sync job expands the `gcp` entry. Consumers should read the\n * object as a whole via `getGcpPreferences`, or use a specific convenience\n * getter like `getGcpApiKey` for a single field.\n */\nexport type GcpPreferences = {\n apiKey: string;\n};\n\nexport const DEFAULT_GCP_PREFERENCES_KEY = 'gcp';\n\n/**\n * Map keys inside the `gcp` data store entry. The ECOM MRT sync job writes\n * to these exact keys; keep in sync with the sync job contract.\n */\nconst API_KEY_MAP_KEY = 'api-key';\n\nexport const gcpPreferencesContext = createDataStoreContext<GcpPreferences>();\n\n/**\n * Read the GCP (Google Cloud Platform) preferences object from router context.\n *\n * The preferences are sourced from the MRT data store entry `gcp`, which is\n * populated only for storefronts connecting to production ECOM instances.\n * In non-production environments, or when the entry is missing, returns an\n * object whose fields are all empty/default.\n *\n * @param context - Router context provider\n * @returns GCP preferences object; fields are empty/default when the entry is unavailable\n */\nexport function getGcpPreferences(context: Readonly<RouterContextProvider>): GcpPreferences {\n const data = context.get(gcpPreferencesContext);\n if (data === null) {\n // eslint-disable-next-line no-console\n console.warn(\n 'GCP preferences context not found. Ensure gcpPreferencesMiddleware runs before loaders, or expect empty values in environments without the MRT data store entry.'\n );\n return { apiKey: '' };\n }\n return data;\n}\n\n/**\n * Convenience getter for the Google Cloud API key alone.\n *\n * Equivalent to `getGcpPreferences(context).apiKey`.\n *\n * @param context - Router context provider\n * @returns The GCP API key, or an empty string when unavailable\n */\nexport function getGcpApiKey(context: Readonly<RouterContextProvider>): string {\n return getGcpPreferences(context).apiKey;\n}\n\n/**\n * Middleware that reads the OOTB GCP preferences from the MRT data store and\n * stores them in the router context. The entry shape is `{ \"api-key\": string, ... }`\n * under data store key `gcp`. Missing/invalid fields coerce to empty/default values.\n *\n * Only available for storefronts connecting to production ECOM instances.\n * Must run before any loader/middleware that reads `getGcpPreferences(context)`\n * or `getGcpApiKey(context)`.\n */\nexport const gcpPreferencesMiddleware = createDataStoreMiddleware<GcpPreferences>({\n entryKey: DEFAULT_GCP_PREFERENCES_KEY,\n context: gcpPreferencesContext,\n transform: (value) => {\n const rawKey = value[API_KEY_MAP_KEY];\n return { apiKey: typeof rawKey === 'string' ? rawKey : '' };\n },\n});\n"],"mappings":";;;AA+BA,MAAa,8BAA8B;;;;;AAM3C,MAAM,kBAAkB;AAExB,MAAa,wBAAwB,wBAAwC;;;;;;;;;;;;AAa7E,SAAgB,kBAAkB,SAA0D;CACxF,MAAM,OAAO,QAAQ,IAAI,sBAAsB;AAC/C,KAAI,SAAS,MAAM;AAEf,UAAQ,KACJ,mKACH;AACD,SAAO,EAAE,QAAQ,IAAI;;AAEzB,QAAO;;;;;;;;;;AAWX,SAAgB,aAAa,SAAkD;AAC3E,QAAO,kBAAkB,QAAQ,CAAC;;;;;;;;;;;AAYtC,MAAa,2BAA2B,0BAA0C;CAC9E,UAAU;CACV,SAAS;CACT,YAAY,UAAU;EAClB,MAAM,SAAS,MAAM;AACrB,SAAO,EAAE,QAAQ,OAAO,WAAW,WAAW,SAAS,IAAI;;CAElE,CAAC"}
1
+ {"version":3,"file":"gcp-preferences.js","names":[],"sources":["../src/data-store/middleware/gcp-preferences.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RouterContextProvider } from 'react-router';\nimport { createDataStoreContext, createDataStoreMiddleware } from '../utils';\n\n/**\n * OOTB Google Cloud Platform preferences sourced from the MRT data store.\n *\n * Additional fields (e.g. `projectId`, `region`) may be added here as the\n * ECOM MRT sync job expands the `gcp` entry. Consumers should read the\n * object as a whole via `getGcpPreferences`, or use a specific convenience\n * getter like `getGcpApiKey` for a single field.\n */\nexport type GcpPreferences = {\n apiKey: string;\n};\n\nexport const DEFAULT_GCP_PREFERENCES_KEY = 'gcp';\nconst DATA_STORE_UNAVAILABLE_MODE = process.env.SFNEXT_DATA_STORE_UNAVAILABLE_MODE;\n\n/**\n * Map keys inside the `gcp` data store entry. The ECOM MRT sync job writes\n * to these exact keys; keep in sync with the sync job contract.\n */\nconst API_KEY_MAP_KEY = 'api-key';\n\nexport const gcpPreferencesContext = createDataStoreContext<GcpPreferences>();\n\n/**\n * Read the GCP (Google Cloud Platform) preferences object from router context.\n *\n * The preferences are sourced from the MRT data store entry `gcp`, which is\n * populated only for storefronts connecting to production ECOM instances.\n * In non-production environments, or when the entry is missing, returns an\n * object whose fields are all empty/default.\n *\n * @param context - Router context provider\n * @returns GCP preferences object; fields are empty/default when the entry is unavailable\n */\nexport function getGcpPreferences(context: Readonly<RouterContextProvider>): GcpPreferences {\n const data = context.get(gcpPreferencesContext);\n if (data === null) {\n // eslint-disable-next-line no-console\n console.warn(\n 'GCP preferences context not found. Ensure gcpPreferencesMiddleware runs before loaders, or expect empty values in environments without the MRT data store entry.'\n );\n return { apiKey: '' };\n }\n return data;\n}\n\n/**\n * Convenience getter for the Google Cloud API key alone.\n *\n * Equivalent to `getGcpPreferences(context).apiKey`.\n *\n * @param context - Router context provider\n * @returns The GCP API key, or an empty string when unavailable\n */\nexport function getGcpApiKey(context: Readonly<RouterContextProvider>): string {\n return getGcpPreferences(context).apiKey;\n}\n\n/**\n * Middleware that reads the OOTB GCP preferences from the MRT data store and\n * stores them in the router context. The entry shape is `{ \"api-key\": string, ... }`\n * under data store key `gcp`. Missing/invalid fields coerce to empty/default values.\n *\n * Only available for storefronts connecting to production ECOM instances.\n * Must run before any loader/middleware that reads `getGcpPreferences(context)`\n * or `getGcpApiKey(context)`.\n */\nexport const gcpPreferencesMiddleware = createDataStoreMiddleware<GcpPreferences>({\n entryKey: DEFAULT_GCP_PREFERENCES_KEY,\n context: gcpPreferencesContext,\n onUnavailable: DATA_STORE_UNAVAILABLE_MODE === 'fallback' ? 'fallback' : 'throw',\n fallbackValue: { apiKey: '' },\n transform: (value) => {\n const rawKey = value[API_KEY_MAP_KEY];\n return { apiKey: typeof rawKey === 'string' ? rawKey : '' };\n },\n});\n"],"mappings":";;;AA+BA,MAAa,8BAA8B;AAC3C,MAAM,8BAA8B,QAAQ,IAAI;;;;;AAMhD,MAAM,kBAAkB;AAExB,MAAa,wBAAwB,wBAAwC;;;;;;;;;;;;AAa7E,SAAgB,kBAAkB,SAA0D;CACxF,MAAM,OAAO,QAAQ,IAAI,sBAAsB;AAC/C,KAAI,SAAS,MAAM;AAEf,UAAQ,KACJ,mKACH;AACD,SAAO,EAAE,QAAQ,IAAI;;AAEzB,QAAO;;;;;;;;;;AAWX,SAAgB,aAAa,SAAkD;AAC3E,QAAO,kBAAkB,QAAQ,CAAC;;;;;;;;;;;AAYtC,MAAa,2BAA2B,0BAA0C;CAC9E,UAAU;CACV,SAAS;CACT,eAAe,gCAAgC,aAAa,aAAa;CACzE,eAAe,EAAE,QAAQ,IAAI;CAC7B,YAAY,UAAU;EAClB,MAAM,SAAS,MAAM;AACrB,SAAO,EAAE,QAAQ,OAAO,WAAW,WAAW,SAAS,IAAI;;CAElE,CAAC"}