@salesforce/storefront-next-runtime 0.4.2 → 1.0.0-alpha.1

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.
Files changed (87) hide show
  1. package/README.md +9 -3
  2. package/dist/ComponentContext.js +199 -4
  3. package/dist/ComponentContext.js.map +1 -1
  4. package/dist/DesignComponent.js +2 -2
  5. package/dist/DesignRegion.js +2 -2
  6. package/dist/RegionContext.js +9 -0
  7. package/dist/RegionContext.js.map +1 -0
  8. package/dist/component.types.d.ts +1 -1
  9. package/dist/config.d.ts +34 -221
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/config.js +35 -116
  12. package/dist/config.js.map +1 -1
  13. package/dist/data-store.d.ts +185 -15
  14. package/dist/data-store.d.ts.map +1 -1
  15. package/dist/data-store.js +412 -10
  16. package/dist/data-store.js.map +1 -1
  17. package/dist/defaults.d.ts +106 -0
  18. package/dist/defaults.d.ts.map +1 -0
  19. package/dist/defaults.js +67 -0
  20. package/dist/defaults.js.map +1 -0
  21. package/dist/design-data.d.ts +238 -356
  22. package/dist/design-data.d.ts.map +1 -1
  23. package/dist/design-data.js +459 -30
  24. package/dist/design-data.js.map +1 -1
  25. package/dist/design-mode.d.ts +3 -2
  26. package/dist/design-mode.d.ts.map +1 -1
  27. package/dist/design-react-core.d.ts +5 -15
  28. package/dist/design-react-core.d.ts.map +1 -1
  29. package/dist/design-react-core.js +2 -2
  30. package/dist/design-react.d.ts +2 -2
  31. package/dist/design.d.ts +2 -2
  32. package/dist/events.d.ts +32 -6
  33. package/dist/events.d.ts.map +1 -1
  34. package/dist/i18n-client.d.ts.map +1 -1
  35. package/dist/i18n-client.js.map +1 -1
  36. package/dist/i18n.d.ts +1 -2
  37. package/dist/i18n.d.ts.map +1 -1
  38. package/dist/modeDetection.js +0 -18
  39. package/dist/modeDetection.js.map +1 -1
  40. package/dist/scapi.d.ts +2185 -466
  41. package/dist/scapi.d.ts.map +1 -1
  42. package/dist/scapi.js +1 -1
  43. package/dist/scapi.js.map +1 -1
  44. package/dist/schema.d.ts +17 -15
  45. package/dist/schema.d.ts.map +1 -1
  46. package/dist/security-react.d.ts +34 -0
  47. package/dist/security-react.d.ts.map +1 -0
  48. package/dist/security-react.js +21 -0
  49. package/dist/security-react.js.map +1 -0
  50. package/dist/security.d.ts +61 -0
  51. package/dist/security.d.ts.map +1 -0
  52. package/dist/security.js +304 -0
  53. package/dist/security.js.map +1 -0
  54. package/dist/site-context.d.ts +43 -27
  55. package/dist/site-context.d.ts.map +1 -1
  56. package/dist/site-context.js +2 -2
  57. package/dist/site-context2.js +41 -31
  58. package/dist/site-context2.js.map +1 -1
  59. package/dist/types.d.ts +19 -3
  60. package/dist/types.d.ts.map +1 -1
  61. package/dist/types2.d.ts +89 -63
  62. package/dist/types2.d.ts.map +1 -1
  63. package/dist/types3.d.ts +1 -35
  64. package/dist/types3.d.ts.map +1 -1
  65. package/package.json +15 -20
  66. package/dist/DesignFrame.js +0 -204
  67. package/dist/DesignFrame.js.map +0 -1
  68. package/dist/custom-global-preferences.d.ts +0 -20
  69. package/dist/custom-global-preferences.d.ts.map +0 -1
  70. package/dist/custom-global-preferences.js +0 -31
  71. package/dist/custom-global-preferences.js.map +0 -1
  72. package/dist/custom-site-preferences.d.ts +0 -20
  73. package/dist/custom-site-preferences.d.ts.map +0 -1
  74. package/dist/custom-site-preferences.js +0 -31
  75. package/dist/custom-site-preferences.js.map +0 -1
  76. package/dist/data-store-custom-global-preferences.d.ts +0 -2
  77. package/dist/data-store-custom-global-preferences.js +0 -6
  78. package/dist/data-store-custom-site-preferences.d.ts +0 -2
  79. package/dist/data-store-custom-site-preferences.js +0 -6
  80. package/dist/data-store-gcp-preferences.d.ts +0 -2
  81. package/dist/data-store-gcp-preferences.js +0 -6
  82. package/dist/gcp-preferences.d.ts +0 -52
  83. package/dist/gcp-preferences.d.ts.map +0 -1
  84. package/dist/gcp-preferences.js +0 -64
  85. package/dist/gcp-preferences.js.map +0 -1
  86. package/dist/utils.js +0 -90
  87. package/dist/utils.js.map +0 -1
package/dist/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","names":["dataStoreMiddleware: MiddlewareFunction<Response>"],"sources":["../src/data-store/utils.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 MiddlewareFunction, type RouterContextProvider, createContext } from 'react-router';\nimport {\n DataStore,\n DataStoreNotFoundError,\n DataStoreServiceError,\n DataStoreUnavailableError,\n} from '@salesforce/mrt-utilities/data-store';\nimport { siteContext } from '../site-context';\n\nexport type DataStoreContextKey<T> = ReturnType<typeof createContext<T | null>>;\n\nexport type DataStoreEntryKey = string | ((context: Readonly<RouterContextProvider>) => string);\n\nexport type DataStoreEntry<TValue = unknown> = {\n value?: TValue;\n};\n\nexport type DataStoreMiddlewareOptions<T> = {\n entryKey: DataStoreEntryKey;\n context: DataStoreContextKey<T>;\n transform?: (value: Record<string, unknown>) => T;\n onUnavailable?: 'throw' | 'fallback';\n fallbackValue?: T | ((context: Readonly<RouterContextProvider>) => T);\n};\n\n/**\n * Creates a typed React Router context for data store entries.\n *\n * Initializes the context with `null` so middleware can populate it during requests.\n *\n * @returns React Router context key for data store values\n */\nexport function createDataStoreContext<T>(): DataStoreContextKey<T> {\n return createContext<T | null>(null);\n}\n\n/**\n * Creates a data-store middleware that fetches site preferences from MRT data access layer\n * and stores them in the router context.\n *\n * Environment variables:\n * - `AWS_REGION` (required): AWS region for the data store table (e.g., \"us-east-1\")\n * - `MOBIFY_PROPERTY_ID` (required): MRT property identifier (e.g., \"abcd1234\")\n * - `DEPLOY_TARGET` (required): MRT deploy target (e.g., \"production\")\n *\n * @param options - Middleware options for data store entry and context\n * @returns React Router middleware for server requests\n */\nexport function createDataStoreMiddleware<T>(options: DataStoreMiddlewareOptions<T>): MiddlewareFunction<Response> {\n const { entryKey, context: contextKey, onUnavailable = 'throw', fallbackValue } = options;\n const transform = options.transform ?? ((value: Record<string, unknown>) => value as T);\n\n const dataStoreMiddleware: MiddlewareFunction<Response> = async ({ context }, next) => {\n const resolvedEntryKey = typeof entryKey === 'function' ? entryKey(context) : entryKey;\n try {\n const entry = await getDataStoreEntry(resolvedEntryKey);\n\n if (!entry?.value || typeof entry.value !== 'object') {\n // eslint-disable-next-line no-console\n console.warn(`Data store entry '${resolvedEntryKey}' not found or invalid.`);\n return next();\n }\n context.set(contextKey, transform(entry.value as Record<string, unknown>));\n } catch (error) {\n if (error instanceof DataStoreUnavailableError) {\n if (onUnavailable === 'fallback' && typeof fallbackValue !== 'undefined') {\n const resolvedFallbackValue =\n typeof fallbackValue === 'function'\n ? (fallbackValue as (ctx: Readonly<RouterContextProvider>) => T)(context)\n : fallbackValue;\n context.set(contextKey, resolvedFallbackValue);\n // eslint-disable-next-line no-console\n console.warn(`Data store unavailable for '${resolvedEntryKey}'. Using configured fallback value.`);\n return next();\n }\n throw new Error(\n 'Data store is unavailable. Ensure AWS_REGION, MOBIFY_PROPERTY_ID, and DEPLOY_TARGET are set.'\n );\n }\n if (error instanceof DataStoreNotFoundError) {\n // eslint-disable-next-line no-console\n console.warn(`Data store entry '${resolvedEntryKey}' not found.`);\n return next();\n }\n if (error instanceof DataStoreServiceError) {\n throw new Error(`Data store request failed for '${resolvedEntryKey}'.`);\n }\n throw error;\n }\n\n return next();\n };\n\n return dataStoreMiddleware;\n}\n\n/**\n * Read a data-store entry through the singleton MRT utilities API.\n * The underlying implementation (production DynamoDB vs development pseudo store)\n * is resolved by `@salesforce/mrt-utilities/data-store` export conditions.\n *\n * @param key - Data-store entry key\n * @returns Data-store entry or null when missing/invalid shape\n */\nexport async function getDataStoreEntry<TValue = unknown>(key: string): Promise<DataStoreEntry<TValue> | null> {\n const entry = (await DataStore.getDataStore().getEntry(key)) as DataStoreEntry<TValue> | undefined;\n if (!entry || typeof entry !== 'object') {\n return null;\n }\n return entry;\n}\n\n/**\n * Creates an entryKey function that prefixes the given suffix with the current site ID.\n *\n * @param suffix - The entry key suffix (e.g., \"custom-site-preferences\")\n * @returns A function compatible with `DataStoreMiddlewareOptions.entryKey`\n */\nexport function prefixWithSiteId(suffix: string): (context: Readonly<RouterContextProvider>) => string {\n return (context) => {\n const siteId = context.get(siteContext)?.site?.id;\n if (!siteId)\n throw new Error('Site id not found. Ensure site context middleware runs before data-store middleware.');\n return `${siteId}-${suffix}`;\n };\n}\n"],"mappings":";;;;;;;;;;;;AAgDA,SAAgB,yBAAoD;AAChE,QAAO,cAAwB,KAAK;;;;;;;;;;;;;;AAexC,SAAgB,0BAA6B,SAAsE;CAC/G,MAAM,EAAE,UAAU,SAAS,YAAY,gBAAgB,SAAS,kBAAkB;CAClF,MAAM,YAAY,QAAQ,eAAe,UAAmC;CAE5E,MAAMA,sBAAoD,OAAO,EAAE,WAAW,SAAS;EACnF,MAAM,mBAAmB,OAAO,aAAa,aAAa,SAAS,QAAQ,GAAG;AAC9E,MAAI;GACA,MAAM,QAAQ,MAAM,kBAAkB,iBAAiB;AAEvD,OAAI,CAAC,OAAO,SAAS,OAAO,MAAM,UAAU,UAAU;AAElD,YAAQ,KAAK,qBAAqB,iBAAiB,yBAAyB;AAC5E,WAAO,MAAM;;AAEjB,WAAQ,IAAI,YAAY,UAAU,MAAM,MAAiC,CAAC;WACrE,OAAO;AACZ,OAAI,iBAAiB,2BAA2B;AAC5C,QAAI,kBAAkB,cAAc,OAAO,kBAAkB,aAAa;KACtE,MAAM,wBACF,OAAO,kBAAkB,aAClB,cAA8D,QAAQ,GACvE;AACV,aAAQ,IAAI,YAAY,sBAAsB;AAE9C,aAAQ,KAAK,+BAA+B,iBAAiB,qCAAqC;AAClG,YAAO,MAAM;;AAEjB,UAAM,IAAI,MACN,+FACH;;AAEL,OAAI,iBAAiB,wBAAwB;AAEzC,YAAQ,KAAK,qBAAqB,iBAAiB,cAAc;AACjE,WAAO,MAAM;;AAEjB,OAAI,iBAAiB,sBACjB,OAAM,IAAI,MAAM,kCAAkC,iBAAiB,IAAI;AAE3E,SAAM;;AAGV,SAAO,MAAM;;AAGjB,QAAO;;;;;;;;;;AAWX,eAAsB,kBAAoC,KAAqD;CAC3G,MAAM,QAAS,MAAM,UAAU,cAAc,CAAC,SAAS,IAAI;AAC3D,KAAI,CAAC,SAAS,OAAO,UAAU,SAC3B,QAAO;AAEX,QAAO;;;;;;;;AASX,SAAgB,iBAAiB,QAAsE;AACnG,SAAQ,YAAY;EAChB,MAAM,SAAS,QAAQ,IAAI,YAAY,EAAE,MAAM;AAC/C,MAAI,CAAC,OACD,OAAM,IAAI,MAAM,uFAAuF;AAC3G,SAAO,GAAG,OAAO,GAAG"}