@dropins/tools 1.3.0-alpha01 → 1.3.0-alpha02

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,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{d as f}from"../../chunks/cjs.js";let o=null,a=null,r=null;function C(){o=null,a=null,r=null}function u(){return new URL(`${window.location.origin}/config.json`)}function c(n,t){return t.split(".").reduce((e,i)=>{if(!Object.prototype.hasOwnProperty.call(e,i)){console.warn(`Property ${t} does not exist in the object`);return}return e[i]},n)}function m(n){const t=document.cookie.split(";");let e;return t.forEach(i=>{const[l,s]=i.trim().split("=");l===n&&(e=decodeURIComponent(s))}),e}function g(n=o){return n?Object.keys(n==null?void 0:n.public).sort((e,i)=>{const l=e.split("/").filter(Boolean).length;return i.split("/").filter(Boolean).length-l}).find(e=>window.location.pathname===e||window.location.pathname.startsWith(e))??"/":(console.warn("No config found. Please call initializeConfig() first."),"/")}function d(){return o?Object.keys(o.public).filter(n=>n!=="default"):(console.warn("No config found. Please call initializeConfig() first."),[])}function y(){return d().length>=1}function S(n){if(!r)throw new Error("Configuration not initialized. Call initializeConfig() first.");const t=r.headers??{};return{...t.all??{},...t[n]??{}}}function w(n,t){var i;const e=(i=n.public)==null?void 0:i.default;return t==="/"||!n.public[t]?e:f(e,n.public[t])}async function p(){try{const n=window.sessionStorage.getItem("config");if(!n)throw new Error("No config in session storage");const t=JSON.parse(n);if(!t[":expiry"]||t[":expiry"]<Math.round(Date.now()/1e3))throw new Error("Config expired");return t}catch{const t=await fetch(u());if(!t.ok)throw new Error("Failed to fetch config");const e=await t.json();return e[":expiry"]=Math.round(Date.now()/1e3)+7200,window.sessionStorage.setItem("config",JSON.stringify(e)),e}}async function z(){return o=await p(),a=g(o),r=w(o,a),r}function N(n){if(!r)throw new Error("Configuration not initialized. Call initializeConfig() first.");return c(r,n)}export{N as getConfigValue,m as getCookie,S as getHeaders,d as getListOfRootPaths,g as getRootPath,z as initializeConfig,y as isMultistore,C as resetConfig};
3
+ import{d as u}from"../../chunks/cjs.js";function f(t,n){try{return n.split(".").reduce((e,i)=>{if(!Object.prototype.hasOwnProperty.call(e,i))throw Error();return e[i]},t)}catch{console.warn(`Property ${n} does not exist in the object`);return}}let o=null,l=null,r=null;function p(){o=null,l=null,r=null}function s(t=o){return t?Object.keys(t==null?void 0:t.public).sort((e,i)=>{const a=e.split("/").filter(Boolean).length;return i.split("/").filter(Boolean).length-a}).find(e=>window.location.pathname===e||window.location.pathname.startsWith(e))??"/":(console.warn("No config found. Please call initializeConfig() first."),"/")}function c(){return o?Object.keys(o.public).filter(t=>t!=="default"):(console.warn("No config found. Please call initializeConfig() first."),[])}function C(){return c().length>=1}function w(t){if(!r)throw new Error("Configuration not initialized. Call initializeConfig() first.");const n=r.headers??{};return{...n.all??{},...n[t]??{}}}function g(t,n){var i;const e=(i=t.public)==null?void 0:i.default;return n==="/"||!t.public[n]?e:u(e,t.public[n])}function m(t){return o=t,l=s(o),r=g(o,l),r}function P(t){if(!r)throw new Error("Configuration not initialized. Call initializeConfig() first.");return f(r,t)}export{P as getConfigValue,w as getHeaders,c as getListOfRootPaths,s as getRootPath,m as initializeConfig,C as isMultistore,p as resetConfig};
4
4
  //# sourceMappingURL=configs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configs.js","sources":["/@dropins/tools/src/lib/aem/configs.ts"],"sourcesContent":["import { deepmerge } from '../deepmerge';\n\ninterface ConfigHeaders {\n all?: Record<string, string>;\n [key: string]: Record<string, string> | undefined;\n}\n\ninterface ConfigPublic {\n default: ConfigRoot;\n [key: string]: ConfigRoot;\n}\n\ninterface ConfigRoot {\n headers?: ConfigHeaders;\n [key: string]: any;\n}\n\ninterface Config {\n public: ConfigPublic;\n [key: string]: any;\n}\n\n// Private state\nlet config: Config | null = null;\nlet rootPath: string | null = null;\nlet rootConfig: ConfigRoot | null = null;\n\n/**\n * Reset the config state\n */\nfunction resetConfig() {\n config = null;\n rootPath = null;\n rootConfig = null;\n}\n\n/**\n * Builds the URL for the config file.\n *\n * @returns {URL} - The URL for the config file.\n */\nfunction buildConfigURL() {\n return new URL(`${window.location.origin}/config.json`);\n}\n\n/**\n * Retrieves a value from a config object using dot notation.\n *\n * @param {Object} obj - The config object.\n * @param {string} key - The key to retrieve (supports dot notation).\n * @returns {any} - The value of the key.\n */\nfunction getValue(obj: Record<string, any>, key: string): any {\n return key.split('.').reduce((current: Record<string, any>, part: string) => {\n if (!Object.prototype.hasOwnProperty.call(current, part)) {\n console.warn(`Property ${key} does not exist in the object`);\n return undefined;\n }\n return current[part];\n }, obj);\n}\n\n/**\n * Get cookie\n * @param {string} cookieName - The name of the cookie to get\n * @returns {string} - The value of the cookie\n */\nfunction getCookie(cookieName: string): string | undefined {\n const cookies = document.cookie.split(';');\n let foundValue;\n\n cookies.forEach((cookie) => {\n const [name, value] = cookie.trim().split('=');\n if (name === cookieName) {\n foundValue = decodeURIComponent(value);\n }\n });\n\n return foundValue;\n}\n\n/**\n * Get root path\n * @param {Object} [configObj=config] - The config object.\n * @returns {string} - The root path.\n */\nfunction getRootPath(configObj: Config | null = config): string {\n if (!configObj) {\n console.warn('No config found. Please call initializeConfig() first.');\n return '/';\n }\n\n const value = Object.keys(configObj?.public)\n // Sort by number of non-empty segments to find the deepest path\n .sort((a, b) => {\n const aSegments = a.split('/').filter(Boolean).length;\n const bSegments = b.split('/').filter(Boolean).length;\n return bSegments - aSegments;\n })\n .find(\n (key) =>\n window.location.pathname === key ||\n window.location.pathname.startsWith(key)\n );\n\n return value ?? '/';\n}\n\n/**\n * Get list of root paths from public config\n * @returns {Array} - The list of root paths.\n */\nfunction getListOfRootPaths(): string[] {\n if (!config) {\n console.warn('No config found. Please call initializeConfig() first.');\n return [];\n }\n\n return Object.keys(config.public).filter((root) => root !== 'default');\n}\n\n/**\n * Checks if the public config contains more than \"default\"\n * @returns {boolean} - true if public config contains more than \"default\"\n */\nfunction isMultistore(): boolean {\n return getListOfRootPaths().length >= 1;\n}\n\n/**\n * Retrieves headers from config entries like commerce.headers.pdp.my-header, etc and\n * returns as object of all headers like { my-header: value, ... }\n * @param {string} scope - The scope of the headers to retrieve.\n * @returns {Object} - The headers.\n */\nfunction getHeaders(scope: string): Record<string, string> {\n if (!rootConfig) {\n throw new Error(\n 'Configuration not initialized. Call initializeConfig() first.'\n );\n }\n const headers = rootConfig.headers ?? {};\n return {\n ...(headers.all ?? {}),\n ...(headers[scope] ?? {}),\n };\n}\n\n/**\n * Applies config overrides from metadata.\n *\n * @param {Object} [configObj=config] - The base config.\n * @param {string} [root=rootPath] - The root path.\n * @returns {Object} - The config with overrides applied.\n */\nfunction applyConfigOverrides(\n configObj: Config | null,\n root: string | null\n): ConfigRoot {\n const defaultConfig = configObj!.public?.default;\n\n if (root === '/' || !configObj!.public[root as keyof ConfigPublic])\n return defaultConfig;\n\n return deepmerge(\n defaultConfig,\n configObj!.public[root as keyof ConfigPublic]\n );\n}\n\n/**\n * Fetches config from remote and saves in session, then returns it, otherwise\n * returns if it already exists.\n *\n * @returns {Promise<Object>} - The config JSON from session storage\n */\nasync function getConfigFromSession(): Promise<Config> {\n try {\n const configJSON = window.sessionStorage.getItem('config');\n if (!configJSON) {\n throw new Error('No config in session storage');\n }\n\n const parsedConfig = JSON.parse(configJSON);\n if (\n !parsedConfig[':expiry'] ||\n parsedConfig[':expiry'] < Math.round(Date.now() / 1000)\n ) {\n throw new Error('Config expired');\n }\n return parsedConfig;\n } catch (e) {\n const config = await fetch(buildConfigURL());\n if (!config.ok) throw new Error('Failed to fetch config');\n const configJSON = await config.json();\n configJSON[':expiry'] = Math.round(Date.now() / 1000) + 7200;\n window.sessionStorage.setItem('config', JSON.stringify(configJSON));\n return configJSON;\n }\n}\n\n/**\n * Initializes the configuration system.\n * @returns {Promise<void>}\n */\nasync function initializeConfig(): Promise<ConfigRoot> {\n config = await getConfigFromSession();\n rootPath = getRootPath(config);\n rootConfig = applyConfigOverrides(config, rootPath);\n return rootConfig;\n}\n\n/**\n * Retrieves a configuration value.\n *\n * @param {string} configParam - The configuration parameter to retrieve.\n * @returns {string|undefined} - The value of the configuration parameter, or undefined.\n */\nfunction getConfigValue(configParam: string): any {\n if (!rootConfig) {\n throw new Error(\n 'Configuration not initialized. Call initializeConfig() first.'\n );\n }\n return getValue(rootConfig, configParam);\n}\n\nexport {\n initializeConfig,\n getCookie,\n getRootPath,\n getListOfRootPaths,\n isMultistore,\n getConfigValue,\n getHeaders,\n resetConfig,\n};\n"],"names":["config","rootPath","rootConfig","resetConfig","buildConfigURL","getValue","obj","key","current","part","getCookie","cookieName","cookies","foundValue","cookie","name","value","getRootPath","configObj","a","b","aSegments","getListOfRootPaths","root","isMultistore","getHeaders","scope","headers","applyConfigOverrides","defaultConfig","_a","deepmerge","getConfigFromSession","configJSON","parsedConfig","initializeConfig","getConfigValue","configParam"],"mappings":"wCAuBA,IAAIA,EAAwB,KACxBC,EAA0B,KAC1BC,EAAgC,KAKpC,SAASC,GAAc,CACZH,EAAA,KACEC,EAAA,KACEC,EAAA,IACf,CAOA,SAASE,GAAiB,CACxB,OAAO,IAAI,IAAI,GAAG,OAAO,SAAS,MAAM,cAAc,CACxD,CASA,SAASC,EAASC,EAA0BC,EAAkB,CAC5D,OAAOA,EAAI,MAAM,GAAG,EAAE,OAAO,CAACC,EAA8BC,IAAiB,CAC3E,GAAI,CAAC,OAAO,UAAU,eAAe,KAAKD,EAASC,CAAI,EAAG,CAChD,QAAA,KAAK,YAAYF,CAAG,+BAA+B,EACpD,MAAA,CAET,OAAOC,EAAQC,CAAI,GAClBH,CAAG,CACR,CAOA,SAASI,EAAUC,EAAwC,CACzD,MAAMC,EAAU,SAAS,OAAO,MAAM,GAAG,EACrC,IAAAC,EAEI,OAAAD,EAAA,QAASE,GAAW,CACpB,KAAA,CAACC,EAAMC,CAAK,EAAIF,EAAO,KAAK,EAAE,MAAM,GAAG,EACzCC,IAASJ,IACXE,EAAa,mBAAmBG,CAAK,EAC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,SAAS,EAAI,KAAK,MAAM,KAAK,IAAI,EAAI,GAAI,EAEhD,MAAA,IAAI,MAAM,gBAAgB,EAE3B,OAAAA,OACG,CACV,MAAMlC,EAAS,MAAM,MAAMI,GAAgB,EAC3C,GAAI,CAACJ,EAAO,GAAU,MAAA,IAAI,MAAM,wBAAwB,EAClD,MAAAiC,EAAa,MAAMjC,EAAO,KAAK,EAC1B,OAAAiC,EAAA,SAAS,EAAI,KAAK,MAAM,KAAK,IAAI,EAAI,GAAI,EAAI,KACxD,OAAO,eAAe,QAAQ,SAAU,KAAK,UAAUA,CAAU,CAAC,EAC3DA,CAAA,CAEX,CAMA,eAAeE,GAAwC,CACrD,OAAAnC,EAAS,MAAMgC,EAAqB,EACpC/B,EAAWgB,EAAYjB,CAAM,EAChBE,EAAA0B,EAAqB5B,EAAQC,CAAQ,EAC3CC,CACT,CAQA,SAASkC,EAAeC,EAA0B,CAChD,GAAI,CAACnC,EACH,MAAM,IAAI,MACR,+DACF,EAEK,OAAAG,EAASH,EAAYmC,CAAW,CACzC"}
1
+ {"version":3,"file":"configs.js","sources":["/@dropins/tools/src/lib/get-path-value.ts","/@dropins/tools/src/lib/aem/configs.ts"],"sourcesContent":["/**\n * Retrieves a value from a config object using dot notation.\n *\n * @param {Object} obj - The config object.\n * @param {string} key - The key to retrieve (supports dot notation).\n * @returns {any} - The value of the key.\n */\nexport function getPathValue(obj: Record<string, any>, key: string): any {\n try {\n return key\n .split('.')\n .reduce((current: Record<string, any>, part: string) => {\n if (!Object.prototype.hasOwnProperty.call(current, part)) {\n throw Error();\n }\n return current[part];\n }, obj);\n } catch {\n console.warn(`Property ${key} does not exist in the object`);\n return undefined;\n }\n}\n","import { deepmerge } from '../deepmerge';\nimport { getPathValue } from '../get-path-value';\n\ninterface ConfigHeaders {\n all?: Record<string, string>;\n [key: string]: Record<string, string> | undefined;\n}\n\ninterface ConfigPublic {\n default: ConfigRoot;\n [key: string]: ConfigRoot;\n}\n\ninterface ConfigRoot {\n headers?: ConfigHeaders;\n [key: string]: any;\n}\n\ninterface Config {\n public: ConfigPublic;\n [key: string]: any;\n}\n\n// Private state\nlet config: Config | null = null;\nlet rootPath: string | null = null;\nlet rootConfig: ConfigRoot | null = null;\n\n/**\n * Reset the config state\n */\nfunction resetConfig() {\n config = null;\n rootPath = null;\n rootConfig = null;\n}\n\n/**\n * Get root path\n * @param {Object} [configObj=config] - The config object.\n * @returns {string} - The root path.\n */\nfunction getRootPath(configObj: Config | null = config): string {\n if (!configObj) {\n console.warn('No config found. Please call initializeConfig() first.');\n return '/';\n }\n\n const value = Object.keys(configObj?.public)\n // Sort by number of non-empty segments to find the deepest path\n .sort((a, b) => {\n const aSegments = a.split('/').filter(Boolean).length;\n const bSegments = b.split('/').filter(Boolean).length;\n return bSegments - aSegments;\n })\n .find(\n (key) =>\n window.location.pathname === key ||\n window.location.pathname.startsWith(key)\n );\n\n return value ?? '/';\n}\n\n/**\n * Get list of root paths from public config\n * @returns {Array} - The list of root paths.\n */\nfunction getListOfRootPaths(): string[] {\n if (!config) {\n console.warn('No config found. Please call initializeConfig() first.');\n return [];\n }\n\n return Object.keys(config.public).filter((root) => root !== 'default');\n}\n\n/**\n * Checks if the public config contains more than \"default\"\n * @returns {boolean} - true if public config contains more than \"default\"\n */\nfunction isMultistore(): boolean {\n return getListOfRootPaths().length >= 1;\n}\n\n/**\n * Retrieves headers from config entries like commerce.headers.pdp.my-header, etc and\n * returns as object of all headers like { my-header: value, ... }\n * @param {string} scope - The scope of the headers to retrieve.\n * @returns {Object} - The headers.\n */\nfunction getHeaders(scope: string): Record<string, string> {\n if (!rootConfig) {\n throw new Error(\n 'Configuration not initialized. Call initializeConfig() first.'\n );\n }\n const headers = rootConfig.headers ?? {};\n return {\n ...(headers.all ?? {}),\n ...(headers[scope] ?? {}),\n };\n}\n\n/**\n * Applies config overrides from metadata.\n *\n * @param {Object} [configObj] - The base config.\n * @param {string} [root] - The root path.\n * @returns {Object} - The config with overrides applied.\n */\nfunction applyConfigOverrides(\n configObj: Config | null,\n root: string | null\n): ConfigRoot {\n const defaultConfig = configObj!.public?.default;\n\n if (root === '/' || !configObj!.public[root as keyof ConfigPublic])\n return defaultConfig;\n\n return deepmerge(\n defaultConfig,\n configObj!.public[root as keyof ConfigPublic]\n );\n}\n\n/**\n * Initializes the configuration system.\n * @returns {Object} The initialized root configuration\n */\nfunction initializeConfig(configObj: Config): ConfigRoot {\n config = configObj;\n rootPath = getRootPath(config);\n rootConfig = applyConfigOverrides(config, rootPath);\n return rootConfig;\n}\n\n/**\n * Retrieves a configuration value.\n *\n * @param {string} configParam - The configuration parameter to retrieve.\n * @returns {string|undefined} - The value of the configuration parameter, or undefined.\n */\nfunction getConfigValue(configParam: string): any {\n if (!rootConfig) {\n throw new Error(\n 'Configuration not initialized. Call initializeConfig() first.'\n );\n }\n return getPathValue(rootConfig, configParam);\n}\n\nexport {\n initializeConfig,\n getRootPath,\n getListOfRootPaths,\n isMultistore,\n getConfigValue,\n getHeaders,\n resetConfig,\n};\n"],"names":["getPathValue","obj","key","current","part","config","rootPath","rootConfig","resetConfig","getRootPath","configObj","a","b","aSegments","getListOfRootPaths","root","isMultistore","getHeaders","scope","headers","applyConfigOverrides","defaultConfig","_a","deepmerge","initializeConfig","getConfigValue","configParam"],"mappings":"wCAOgB,SAAAA,EAAaC,EAA0BC,EAAkB,CACnE,GAAA,CACF,OAAOA,EACJ,MAAM,GAAG,EACT,OAAO,CAACC,EAA8BC,IAAiB,CACtD,GAAI,CAAC,OAAO,UAAU,eAAe,KAAKD,EAASC,CAAI,EACrD,MAAM,MAAM,EAEd,OAAOD,EAAQC,CAAI,GAClBH,CAAG,CAAA,MACF,CACE,QAAA,KAAK,YAAYC,CAAG,+BAA+B,EACpD,MAAA,CAEX,CCGA,IAAIG,EAAwB,KACxBC,EAA0B,KAC1BC,EAAgC,KAKpC,SAASC,GAAc,CACZH,EAAA,KACEC,EAAA,KACEC,EAAA,IACf,CAOA,SAASE,EAAYC,EAA2BL,EAAgB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 @@
1
- {"name": "@dropins/tools", "version": "1.3.0-alpha01", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/tools", "version": "1.3.0-alpha02", "license": "SEE LICENSE IN LICENSE.md"}
@@ -18,12 +18,6 @@ interface Config {
18
18
  * Reset the config state
19
19
  */
20
20
  declare function resetConfig(): void;
21
- /**
22
- * Get cookie
23
- * @param {string} cookieName - The name of the cookie to get
24
- * @returns {string} - The value of the cookie
25
- */
26
- declare function getCookie(cookieName: string): string | undefined;
27
21
  /**
28
22
  * Get root path
29
23
  * @param {Object} [configObj=config] - The config object.
@@ -49,9 +43,9 @@ declare function isMultistore(): boolean;
49
43
  declare function getHeaders(scope: string): Record<string, string>;
50
44
  /**
51
45
  * Initializes the configuration system.
52
- * @returns {Promise<void>}
46
+ * @returns {Object} The initialized root configuration
53
47
  */
54
- declare function initializeConfig(): Promise<ConfigRoot>;
48
+ declare function initializeConfig(configObj: Config): ConfigRoot;
55
49
  /**
56
50
  * Retrieves a configuration value.
57
51
  *
@@ -59,5 +53,5 @@ declare function initializeConfig(): Promise<ConfigRoot>;
59
53
  * @returns {string|undefined} - The value of the configuration parameter, or undefined.
60
54
  */
61
55
  declare function getConfigValue(configParam: string): any;
62
- export { initializeConfig, getCookie, getRootPath, getListOfRootPaths, isMultistore, getConfigValue, getHeaders, resetConfig, };
56
+ export { initializeConfig, getRootPath, getListOfRootPaths, isMultistore, getConfigValue, getHeaders, resetConfig, };
63
57
  //# sourceMappingURL=configs.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Get cookie
3
+ * @param {string} cookieName - The name of the cookie to get
4
+ * @returns {string} - The value of the cookie
5
+ */
6
+ export declare function getCookie(cookieName: string): string | undefined;
7
+ //# sourceMappingURL=get-cookie.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Retrieves a value from a config object using dot notation.
3
+ *
4
+ * @param {Object} obj - The config object.
5
+ * @param {string} key - The key to retrieve (supports dot notation).
6
+ * @returns {any} - The value of the key.
7
+ */
8
+ export declare function getPathValue(obj: Record<string, any>, key: string): any;
9
+ //# sourceMappingURL=get-path-value.d.ts.map