@dropins/tools 1.6.0-alpha1 → 1.6.0-alpha2
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/components.js +1 -1
- package/components.js.map +1 -1
- package/fetch-graphql.js +1 -1
- package/fetch-graphql.js.map +1 -1
- package/lib/aem/configs.js +1 -1
- package/lib/aem/configs.js.map +1 -1
- package/package.json +1 -1
- package/types/elsie/src/lib/aem/configs.d.ts +3 -3
- package/types/fetch-graphql/src/index.d.ts +3 -12
- package/types/recaptcha/src/index.d.ts +1 -3
package/fetch-graphql.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
var b=Object.defineProperty;var F=(
|
|
3
|
+
var b=Object.defineProperty;var F=(h,e,t)=>e in h?b(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var r=(h,e,t)=>F(h,typeof e!="symbol"?e+"":e,t);const u={"Content-Type":"application/json",Accept:"application/json"};class H{constructor(){r(this,"_endpoint");r(this,"_fetchGraphQlHeaders",{});r(this,"_beforeHooks",[]);r(this,"_afterHooks",[])}get endpoint(){return this._endpoint}get fetchGraphQlHeaders(){return this._fetchGraphQlHeaders}setEndpoint(e){this._endpoint=e}setFetchGraphQlHeader(e,t){this._fetchGraphQlHeaders={...this.fetchGraphQlHeaders,[e]:t}}removeFetchGraphQlHeader(e){delete this._fetchGraphQlHeaders[e]}getFetchGraphQlHeader(e){return this._fetchGraphQlHeaders[e]}setFetchGraphQlHeaders(e){typeof e=="function"?this._fetchGraphQlHeaders={...this._fetchGraphQlHeaders,...e(this._fetchGraphQlHeaders)}:this._fetchGraphQlHeaders={...e}}addBeforeHook(e){this._beforeHooks.push(e)}addAfterHook(e){this._afterHooks.push(e)}async fetchGraphQl(e,t){const l=this.endpoint,p=this.fetchGraphQlHeaders;if(!l)throw Error('Missing "url"');const s=(t==null?void 0:t.method)??"POST",G=t==null?void 0:t.cache,Q=t==null?void 0:t.signal;let f;const d=new URL(l),o={...u,...p};s==="POST"&&(f=JSON.stringify({query:e,variables:t==null?void 0:t.variables})),s==="GET"&&(d.searchParams.append("query",k(e)),t!=null&&t.variables&&d.searchParams.append("variables",JSON.stringify(t.variables)));let a={method:s,headers:o,body:f,cache:G,signal:Q};return a=await this._beforeHooks.reduce(async(i,c)=>c(await i),Promise.resolve(a)),await fetch(d,a).then(i=>i.json().then(c=>this._afterHooks.reduce(async(g,_)=>_(a,await g),Promise.resolve(c))))}getConfig(){return{endpoint:this.endpoint,fetchGraphQlHeaders:this.fetchGraphQlHeaders}}getMethods(){return{setEndpoint:this.setEndpoint.bind(this),setFetchGraphQlHeader:this.setFetchGraphQlHeader.bind(this),getFetchGraphQlHeader:this.getFetchGraphQlHeader.bind(this),removeFetchGraphQlHeader:this.removeFetchGraphQlHeader.bind(this),setFetchGraphQlHeaders:this.setFetchGraphQlHeaders.bind(this),fetchGraphQl:this.fetchGraphQl.bind(this),getConfig:this.getConfig.bind(this),addBeforeHook:this.addBeforeHook.bind(this),addAfterHook:this.addAfterHook.bind(this)}}}const n=new H;class v extends H{get endpoint(){return this._endpoint??n.endpoint}get fetchGraphQlHeaders(){return this._endpoint?this._fetchGraphQlHeaders:{...this._fetchGraphQlHeaders,...n.fetchGraphQlHeaders}}}function k(h){return h=h.replace(/#.*/g,""),h=h.replace(/\s+/g," "),h.trim()}const{setEndpoint:w,setFetchGraphQlHeaders:E,setFetchGraphQlHeader:P,getFetchGraphQlHeader:y,removeFetchGraphQlHeader:A,fetchGraphQl:C,getConfig:B,addBeforeHook:M,addAfterHook:O}=n.getMethods();export{v as FetchGraphQL,O as addAfterHook,M as addBeforeHook,C as fetchGraphQl,B as getConfig,y as getFetchGraphQlHeader,A as removeFetchGraphQlHeader,w as setEndpoint,P as setFetchGraphQlHeader,E as setFetchGraphQlHeaders};
|
|
4
4
|
//# sourceMappingURL=fetch-graphql.js.map
|
package/fetch-graphql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-graphql.js","sources":["@dropins/tools/src/fetch-graphql/index.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport type Header = { [key: string]: string | null };\n\nexport type FetchOptions = {\n method?: 'GET' | 'POST';\n variables?: { [key: string]: any };\n signal?: AbortSignal;\n cache?:\n | 'default'\n | 'no-store'\n | 'reload'\n | 'no-cache'\n | 'force-cache'\n | 'only-if-cached';\n};\n\nexport type FetchQueryError = Array<{\n message: string;\n extensions: { category: string };\n}>;\n\nexport type BeforeHook = (requestInit: RequestInit) => RequestInit;\nexport type AfterHook<T = any> = (\n requestInit: RequestInit,\n response: { errors?: FetchQueryError; data: T }\n) => { errors?: FetchQueryError; data: T };\n\nconst defaultHeaders = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n};\n\nclass FetchGraphQLMesh {\n public _endpoint?: string;\n\n public _inheritHeaders?: boolean;\n\n get endpoint() {\n return this._endpoint;\n }\n\n get fetchGraphQlHeaders() {\n return this._fetchGraphQlHeaders;\n }\n\n public _fetchGraphQlHeaders: Header = {};\n\n public _beforeHooks: BeforeHook[] = [];\n\n public _afterHooks: AfterHook[] = [];\n\n /**\n * Sets the GraphQL endpoint.\n * @param endpoint - The GraphQL endpoint.\n * @param options - Optional configuration.\n * @param options.inheritHeaders - If true, headers from the global mesh will be inherited.\n */\n public setEndpoint(endpoint: string, options?: { inheritHeaders?: boolean }) {\n this._endpoint = endpoint;\n this._inheritHeaders = options?.inheritHeaders;\n }\n\n /**\n * Sets the GraphQL headers.\n * @param key - The key of the header.\n * @param value - The value of the header.\n */\n public setFetchGraphQlHeader(key: string, value: string | null) {\n this._fetchGraphQlHeaders = {\n ...this.fetchGraphQlHeaders,\n [key]: value,\n };\n }\n /**\n * Removes a specific GraphQL header.\n * @param key - The key of the header.\n */\n public removeFetchGraphQlHeader(key: string) {\n delete this._fetchGraphQlHeaders[key];\n }\n /**\n * Gets the value of a specific GraphQL header.\n * @param key - The key of the header.\n * @returns The value of the header, or undefined if not found.\n */\n public getFetchGraphQlHeader(key: string): string | null | undefined {\n return this._fetchGraphQlHeaders[key];\n }\n /**\n * Sets the GraphQL headers.\n * @param header - The header object or a function that returns a header object.\n * If a function is provided, it will be called with the previous headers.\n * The returned object will be merged with the previous headers.\n * @example\n * ```js\n * // set headers\n * setFetchGraphQlHeaders({ test: 'test' });\n * \n * // merge with previous headers\n * setFetchGraphQlHeaders((prev) => ({\n * ...prev,\n * test: 'test2',\n * }));\n * ```\n */\n public setFetchGraphQlHeaders(header: Header | ((prev: Header) => Header)) {\n if (typeof header === 'function') {\n this._fetchGraphQlHeaders = {\n ...this._fetchGraphQlHeaders,\n ...header(this._fetchGraphQlHeaders),\n };\n } else {\n this._fetchGraphQlHeaders = { ...header };\n }\n }\n /**\n * Adds a hook executed before the GraphQL call.\n * @param hook - The hook function.\n * @example\n * ```js\n * // add before hook\n * addBeforeHook((requestInit) => console.log('About to execute ' + requestInit.method + ' call.'));\n *\n * // modify the requestInit before executing the request\n * addBeforeHook((requestInit) => {method: requestInit.method, body: 'new body'});\n * ```\n */\n public addBeforeHook(hook: BeforeHook): void {\n this._beforeHooks.push(hook);\n }\n /**\n * Adds a hook executed before the GraphQL call.\n * @param hook - The hook function.\n * @example\n * ```js\n * // add before hook\n * addAfterHook((requestInit, response) => console.log(\n * 'The result of ' + requestInit.method + ' call is ' + response.json().body\n * ));\n *\n * // modify the response\n * addAfterHook((requestInit, response) => new Response(JSON.stringify({ ...response, modified: true }));\n * ```\n */\n public addAfterHook(hook: AfterHook): void {\n this._afterHooks.push(hook);\n }\n /**\n * Fetches GraphQL data.\n * @param query - The GraphQL query.\n * @param options - Optional configuration for the fetch request.\n * @returns\n */\n public async fetchGraphQl<T = any>(\n query: string,\n options?: FetchOptions\n ): Promise<{ errors?: FetchQueryError; data: T }> {\n const endpoint = this.endpoint;\n const fetchGraphQlHeaders = this.fetchGraphQlHeaders;\n\n if (!endpoint) throw Error('Missing \"url\"');\n\n const method = options?.method ?? 'POST';\n const cache = options?.cache;\n const signal = options?.signal;\n\n let body;\n const url = new URL(endpoint);\n const headers = {\n ...defaultHeaders,\n ...fetchGraphQlHeaders,\n };\n\n if (method === 'POST') {\n body = JSON.stringify({\n query,\n variables: options?.variables,\n });\n }\n\n if (method === 'GET') {\n url.searchParams.append('query', minimizeGraphQlQuery(query));\n\n if (options?.variables)\n url.searchParams.append('variables', JSON.stringify(options.variables));\n }\n\n let requestInit: RequestInit = {\n method,\n headers,\n body,\n cache,\n signal,\n };\n\n requestInit = await this._beforeHooks.reduce(\n async (prev, hook) => hook(await prev),\n Promise.resolve(requestInit)\n );\n\n return await fetch(url, requestInit).then((r) => r.json().then(\n (response) => this._afterHooks.reduce(\n async (result, hook) => hook(requestInit, await result),\n Promise.resolve(response)\n )\n ));\n }\n /**\n * Gets the configuration.\n */\n public getConfig() {\n return {\n endpoint: this.endpoint,\n fetchGraphQlHeaders: this.fetchGraphQlHeaders,\n };\n }\n\n public getMethods() {\n return {\n setEndpoint: this.setEndpoint.bind(this),\n setFetchGraphQlHeader: this.setFetchGraphQlHeader.bind(this),\n getFetchGraphQlHeader: this.getFetchGraphQlHeader.bind(this),\n removeFetchGraphQlHeader: this.removeFetchGraphQlHeader.bind(this),\n setFetchGraphQlHeaders: this.setFetchGraphQlHeaders.bind(this),\n fetchGraphQl: this.fetchGraphQl.bind(this),\n getConfig: this.getConfig.bind(this),\n addBeforeHook: this.addBeforeHook.bind(this),\n addAfterHook: this.addAfterHook.bind(this),\n };\n }\n}\n\nconst mesh = new FetchGraphQLMesh();\n\n/**\n * `FetchGraphQL` is a class that extends `FetchGraphQLMesh`.\n * It provides methods to get the GraphQL endpoint and headers.\n *\n * @class\n *\n */\nexport class FetchGraphQL extends FetchGraphQLMesh {\n get endpoint() {\n return this._endpoint ?? mesh.endpoint;\n }\n\n get fetchGraphQlHeaders() {\n if (this._endpoint && !this._inheritHeaders) {\n return this._fetchGraphQlHeaders;\n }\n return { ...mesh.fetchGraphQlHeaders, ...this._fetchGraphQlHeaders };\n }\n}\n\nfunction minimizeGraphQlQuery(query: string) {\n // Remove comments\n query = query.replace(/#.*/g, '');\n\n // Remove extra spaces, tabs, and line breaks\n query = query.replace(/\\s+/g, ' ');\n\n return query.trim();\n}\n/**\n * Exports several methods from the `mesh` object.\n *\n * @property {Function} setEndpoint - Sets the GraphQL endpoint.\n * @property {Function} setFetchGraphQlHeaders - Sets the GraphQL headers.\n * @property {Function} setFetchGraphQlHeader - Sets a specific GraphQL header.\n * @property {Function} getFetchGraphQlHeader - Gets the value of a specific GraphQL header.\n * @property {Function} removeFetchGraphQlHeader - Removes a specific GraphQL header.\n * @property {Function} fetchGraphQl - Fetches GraphQL data.\n * @property {Function} getConfig - Gets the configuration.\n */\n\n// Global Mesh instance\nexport const {\n setEndpoint,\n setFetchGraphQlHeaders,\n setFetchGraphQlHeader,\n getFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n fetchGraphQl,\n getConfig,\n addBeforeHook,\n addAfterHook,\n} = mesh.getMethods();\n"],"names":["defaultHeaders","FetchGraphQLMesh","__publicField","endpoint","options","key","value","header","hook","query","fetchGraphQlHeaders","method","cache","signal","body","url","headers","minimizeGraphQlQuery","requestInit","prev","r","response","result","mesh","FetchGraphQL","setEndpoint","setFetchGraphQlHeaders","setFetchGraphQlHeader","getFetchGraphQlHeader","removeFetchGraphQlHeader","fetchGraphQl","getConfig","addBeforeHook","addAfterHook"],"mappings":"oKAmCA,MAAMA,EAAiB,CACrB,eAAgB,mBAChB,OAAQ,kBACV,EAEA,MAAMC,CAAiB,CAAvB,cACSC,EAAA,kBAEAA,EAAA,wBAUAA,EAAA,4BAA+B,CAAC,GAEhCA,EAAA,oBAA6B,CAAC,GAE9BA,EAAA,mBAA2B,CAAC,G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,QAAQ,OAAQ,EAAE,EAGxBA,EAAAA,EAAM,QAAQ,OAAQ,GAAG,EAE1BA,EAAM,KAAK,CACpB,CAca,KAAA,CACX,YAAAgB,EACA,uBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,yBAAAC,EACA,aAAAC,EACA,UAAAC,EACA,cAAAC,EACA,aAAAC,CACF,EAAIV,EAAK,WAAW"}
|
|
1
|
+
{"version":3,"file":"fetch-graphql.js","sources":["@dropins/tools/src/fetch-graphql/index.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport type Header = { [key: string]: string | null };\n\nexport type FetchOptions = {\n method?: 'GET' | 'POST';\n variables?: { [key: string]: any };\n signal?: AbortSignal;\n cache?:\n | 'default'\n | 'no-store'\n | 'reload'\n | 'no-cache'\n | 'force-cache'\n | 'only-if-cached';\n};\n\nexport type FetchQueryError = Array<{\n message: string;\n extensions: { category: string };\n}>;\n\nexport type BeforeHook = (requestInit: RequestInit) => RequestInit;\nexport type AfterHook<T = any> = (\n requestInit: RequestInit,\n response: { errors?: FetchQueryError; data: T }\n) => { errors?: FetchQueryError; data: T };\n\nconst defaultHeaders = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n};\n\nclass FetchGraphQLMesh {\n public _endpoint?: string;\n\n get endpoint() {\n return this._endpoint;\n }\n\n get fetchGraphQlHeaders() {\n return this._fetchGraphQlHeaders;\n }\n\n public _fetchGraphQlHeaders: Header = {};\n\n public _beforeHooks: BeforeHook[] = [];\n\n public _afterHooks: AfterHook[] = [];\n\n /**\n * Sets the GraphQL endpoint.\n * @param endpoint - The GraphQL endpoint.\n */\n public setEndpoint(endpoint: string) {\n this._endpoint = endpoint;\n }\n\n /**\n * Sets the GraphQL headers.\n * @param key - The key of the header.\n * @param value - The value of the header.\n */\n public setFetchGraphQlHeader(key: string, value: string | null) {\n this._fetchGraphQlHeaders = {\n ...this.fetchGraphQlHeaders,\n [key]: value,\n };\n }\n /**\n * Removes a specific GraphQL header.\n * @param key - The key of the header.\n */\n public removeFetchGraphQlHeader(key: string) {\n delete this._fetchGraphQlHeaders[key];\n }\n /**\n * Gets the value of a specific GraphQL header.\n * @param key - The key of the header.\n * @returns The value of the header, or undefined if not found.\n */\n public getFetchGraphQlHeader(key: string): string | null | undefined {\n return this._fetchGraphQlHeaders[key];\n }\n /**\n * Sets the GraphQL headers.\n * @param header - The header object or a function that returns a header object.\n * If a function is provided, it will be called with the previous headers.\n * The returned object will be merged with the previous headers.\n * @example\n * ```js\n * // set headers\n * setFetchGraphQlHeaders({ test: 'test' });\n * \n * // merge with previous headers\n * setFetchGraphQlHeaders((prev) => ({\n * ...prev,\n * test: 'test2',\n * }));\n * ```\n */\n public setFetchGraphQlHeaders(header: Header | ((prev: Header) => Header)) {\n if (typeof header === 'function') {\n this._fetchGraphQlHeaders = {\n ...this._fetchGraphQlHeaders,\n ...header(this._fetchGraphQlHeaders),\n };\n } else {\n this._fetchGraphQlHeaders = { ...header };\n }\n }\n /**\n * Adds a hook executed before the GraphQL call.\n * @param hook - The hook function.\n * @example\n * ```js\n * // add before hook\n * addBeforeHook((requestInit) => console.log('About to execute ' + requestInit.method + ' call.'));\n *\n * // modify the requestInit before executing the request\n * addBeforeHook((requestInit) => {method: requestInit.method, body: 'new body'});\n * ```\n */\n public addBeforeHook(hook: BeforeHook): void {\n this._beforeHooks.push(hook);\n }\n /**\n * Adds a hook executed before the GraphQL call.\n * @param hook - The hook function.\n * @example\n * ```js\n * // add before hook\n * addAfterHook((requestInit, response) => console.log(\n * 'The result of ' + requestInit.method + ' call is ' + response.json().body\n * ));\n *\n * // modify the response\n * addAfterHook((requestInit, response) => new Response(JSON.stringify({ ...response, modified: true }));\n * ```\n */\n public addAfterHook(hook: AfterHook): void {\n this._afterHooks.push(hook);\n }\n /**\n * Fetches GraphQL data.\n * @param query - The GraphQL query.\n * @param options - Optional configuration for the fetch request.\n * @returns\n */\n public async fetchGraphQl<T = any>(\n query: string,\n options?: FetchOptions\n ): Promise<{ errors?: FetchQueryError; data: T }> {\n const endpoint = this.endpoint;\n const fetchGraphQlHeaders = this.fetchGraphQlHeaders;\n\n if (!endpoint) throw Error('Missing \"url\"');\n\n const method = options?.method ?? 'POST';\n const cache = options?.cache;\n const signal = options?.signal;\n\n let body;\n const url = new URL(endpoint);\n const headers = {\n ...defaultHeaders,\n ...fetchGraphQlHeaders,\n };\n\n if (method === 'POST') {\n body = JSON.stringify({\n query,\n variables: options?.variables,\n });\n }\n\n if (method === 'GET') {\n url.searchParams.append('query', minimizeGraphQlQuery(query));\n\n if (options?.variables)\n url.searchParams.append('variables', JSON.stringify(options.variables));\n }\n\n let requestInit: RequestInit = {\n method,\n headers,\n body,\n cache,\n signal,\n };\n\n requestInit = await this._beforeHooks.reduce(\n async (prev, hook) => hook(await prev),\n Promise.resolve(requestInit)\n );\n\n return await fetch(url, requestInit).then((r) => r.json().then(\n (response) => this._afterHooks.reduce(\n async (result, hook) => hook(requestInit, await result),\n Promise.resolve(response)\n )\n ));\n }\n /**\n * Gets the configuration.\n */\n public getConfig() {\n return {\n endpoint: this.endpoint,\n fetchGraphQlHeaders: this.fetchGraphQlHeaders,\n };\n }\n\n public getMethods() {\n return {\n setEndpoint: this.setEndpoint.bind(this),\n setFetchGraphQlHeader: this.setFetchGraphQlHeader.bind(this),\n getFetchGraphQlHeader: this.getFetchGraphQlHeader.bind(this),\n removeFetchGraphQlHeader: this.removeFetchGraphQlHeader.bind(this),\n setFetchGraphQlHeaders: this.setFetchGraphQlHeaders.bind(this),\n fetchGraphQl: this.fetchGraphQl.bind(this),\n getConfig: this.getConfig.bind(this),\n addBeforeHook: this.addBeforeHook.bind(this),\n addAfterHook: this.addAfterHook.bind(this),\n };\n }\n}\n\nconst mesh = new FetchGraphQLMesh();\n\n/**\n * `FetchGraphQL` is a class that extends `FetchGraphQLMesh`.\n * It provides methods to get the GraphQL endpoint and headers.\n *\n * @class\n *\n */\nexport class FetchGraphQL extends FetchGraphQLMesh {\n get endpoint() {\n return this._endpoint ?? mesh.endpoint;\n }\n\n get fetchGraphQlHeaders() {\n return (\n (this._endpoint\n ? this._fetchGraphQlHeaders\n : { ...this._fetchGraphQlHeaders, ...mesh.fetchGraphQlHeaders })\n );\n }\n}\n\nfunction minimizeGraphQlQuery(query: string) {\n // Remove comments\n query = query.replace(/#.*/g, '');\n\n // Remove extra spaces, tabs, and line breaks\n query = query.replace(/\\s+/g, ' ');\n\n return query.trim();\n}\n/**\n * Exports several methods from the `mesh` object.\n *\n * @property {Function} setEndpoint - Sets the GraphQL endpoint.\n * @property {Function} setFetchGraphQlHeaders - Sets the GraphQL headers.\n * @property {Function} setFetchGraphQlHeader - Sets a specific GraphQL header.\n * @property {Function} getFetchGraphQlHeader - Gets the value of a specific GraphQL header.\n * @property {Function} removeFetchGraphQlHeader - Removes a specific GraphQL header.\n * @property {Function} fetchGraphQl - Fetches GraphQL data.\n * @property {Function} getConfig - Gets the configuration.\n */\n\n// Global Mesh instance\nexport const {\n setEndpoint,\n setFetchGraphQlHeaders,\n setFetchGraphQlHeader,\n getFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n fetchGraphQl,\n getConfig,\n addBeforeHook,\n addAfterHook,\n} = mesh.getMethods();\n"],"names":["defaultHeaders","FetchGraphQLMesh","__publicField","endpoint","key","value","header","hook","query","options","fetchGraphQlHeaders","method","cache","signal","body","url","headers","minimizeGraphQlQuery","requestInit","prev","r","response","result","mesh","FetchGraphQL","setEndpoint","setFetchGraphQlHeaders","setFetchGraphQlHeader","getFetchGraphQlHeader","removeFetchGraphQlHeader","fetchGraphQl","getConfig","addBeforeHook","addAfterHook"],"mappings":"oKAmCA,MAAMA,EAAiB,CACrB,eAAgB,mBAChB,OAAQ,kBACV,EAEA,MAAMC,CAAiB,CAAvB,cACSC,EAAA,kBAUAA,EAAA,4BAA+B,CAAC,GAEhCA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,EAGxBA,EAAAA,EAAM,QAAQ,OAAQ,GAAG,EAE1BA,EAAM,KAAK,CACpB,CAca,KAAA,CACX,YAAAiB,EACA,uBAAAC,EACA,sBAAAC,EACA,sBAAAC,EACA,yBAAAC,EACA,aAAAC,EACA,UAAAC,EACA,cAAAC,EACA,aAAAC,CACF,EAAIV,EAAK,WAAW"}
|
package/lib/aem/configs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{g as
|
|
3
|
+
import{g as c}from"../../chunks/get-path-value.js";import{d as s}from"../../chunks/cjs.js";let l=null,f=null,u=null,i=null;function z(){l=null,f=null,u=null,i=null}function g(e=l,t=f){return e?Object.keys(e==null?void 0:e.public).sort((n,r)=>{const o=n.split("/").filter(Boolean).length;return r.split("/").filter(Boolean).length-o}).find(n=>{var r;return window.location.pathname===n||(((r=t==null?void 0:t.match)==null?void 0:r.call(t,n))??window.location.pathname.startsWith(n))})??"/":(console.warn("No config found. Please call initializeConfig() first."),"/")}function h(){return l?Object.keys(l.public).filter(e=>e!=="default"):(console.warn("No config found. Please call initializeConfig() first."),[])}function P(){return h().length>=1}function p(e){if(!i)throw new Error("Configuration not initialized. Call initializeConfig() first.");const t=i.headers??{};return{...t.all??{},...t[e]??{}}}function d(e,t){var n;const a=(n=e.public)==null?void 0:n.default;return t==="/"||!e.public[t]?a:s(a,e.public[t])}function v(e,t){return l=e,f=t??null,u=g(l,{match:t==null?void 0:t.match}),i=d(l,u),i}function S(e){if(!i)throw new Error("Configuration not initialized. Call initializeConfig() first.");return c(i,e)}export{S as getConfigValue,p as getHeaders,h as getListOfRootPaths,g as getRootPath,v as initializeConfig,P as isMultistore,z as resetConfig};
|
|
4
4
|
//# sourceMappingURL=configs.js.map
|
package/lib/aem/configs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configs.js","sources":["/@dropins/tools/src/lib/aem/configs.ts"],"sourcesContent":["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,
|
|
1
|
+
{"version":3,"file":"configs.js","sources":["/@dropins/tools/src/lib/aem/configs.ts"],"sourcesContent":["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 options: { match?: (key: string) => boolean } | 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 options = 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, optionsObj: { match?: (key: string) => boolean } | null = options): 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 (optionsObj?.match?.(key) ?? 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 * @param {Object} configObj - The config object.\n * @param {Object} [options] - The options object.\n * @param {Function} [options.match] - The function to match the path to the config.\n * @returns {Object} The initialized root configuration\n */\nfunction initializeConfig(configObj: Config, optionsObj?: { match?: (key: string) => boolean }): ConfigRoot {\n config = configObj;\n options = optionsObj ?? null;\n rootPath = getRootPath(config, { match: optionsObj?.match });\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":["config","options","rootPath","rootConfig","resetConfig","getRootPath","configObj","optionsObj","a","b","aSegments","key","_a","getListOfRootPaths","root","isMultistore","getHeaders","scope","headers","applyConfigOverrides","defaultConfig","deepmerge","initializeConfig","getConfigValue","configParam","getPathValue"],"mappings":"2FAwBA,IAAIA,EAAwB,KACxBC,EAAuD,KACvDC,EAA0B,KAC1BC,EAAgC,KAKpC,SAASC,GAAc,CACZJ,EAAA,KACCC,EAAA,KACCC,EAAA,KACEC,EAAA,IACf,CAOA,SAASE,EAAYC,EAA2BN,EAAQO,EAA0DN,EAAiB,CACjI,OAAKK,EAKS,OAAO,KAAKA,GAAA,YAAAA,EAAW,MAAM,EAExC,KAAK,CAACE,EAAGC,IAAM,CACd,MAAMC,EAAYF,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,OAE/C,OADkBC,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,OAC5BC,CACpB,CAAA,EACA,KACEC,GAAA,OACC,cAAO,SAAS,WAAaA,MAC5BC,EAAAL,GAAA,YAAAA,EAAY,QAAZ,YAAAK,EAAA,KAAAL,EAAoBI,KAAQ,OAAO,SAAS,SAAS,WAAWA,CAAG,GACxE,GAEc,KAjBd,QAAQ,KAAK,wDAAwD,EAC9D,IAiBX,CAMA,SAASE,GAA+B,CACtC,OAAKb,EAKE,OAAO,KAAKA,EAAO,MAAM,EAAE,OAAQc,GAASA,IAAS,SAAS,GAJnE,QAAQ,KAAK,wDAAwD,EAC9D,CAAC,EAIZ,CAMA,SAASC,GAAwB,CACxB,OAAAF,EAAA,EAAqB,QAAU,CACxC,CAQA,SAASG,EAAWC,EAAuC,CACzD,GAAI,CAACd,EACH,MAAM,IAAI,MACR,+DACF,EAEI,MAAAe,EAAUf,EAAW,SAAW,CAAC,EAChC,MAAA,CACL,GAAIe,EAAQ,KAAO,CAAC,EACpB,GAAIA,EAAQD,CAAK,GAAK,CAAA,CACxB,CACF,CASA,SAASE,EACPb,EACAQ,EACY,OACN,MAAAM,GAAgBR,EAAAN,EAAW,SAAX,YAAAM,EAAmB,QAEzC,OAAIE,IAAS,KAAO,CAACR,EAAW,OAAOQ,CAA0B,EACxDM,EAEFC,EACLD,EACAd,EAAW,OAAOQ,CAA0B,CAC9C,CACF,CASA,SAASQ,EAAiBhB,EAAmBC,EAA+D,CACjG,OAAAP,EAAAM,EACTL,EAAUM,GAAc,KACxBL,EAAWG,EAAYL,EAAQ,CAAE,MAAOO,GAAA,YAAAA,EAAY,MAAO,EAC9CJ,EAAAgB,EAAqBnB,EAAQE,CAAQ,EAC3CC,CACT,CAQA,SAASoB,EAAeC,EAA0B,CAChD,GAAI,CAACrB,EACH,MAAM,IAAI,MACR,+DACF,EAEK,OAAAsB,EAAatB,EAAYqB,CAAW,CAC7C"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/tools", "version": "1.6.0-
|
|
1
|
+
{"name": "@dropins/tools", "version": "1.6.0-alpha2", "license": "SEE LICENSE IN LICENSE.md"}
|
|
@@ -23,9 +23,9 @@ declare function resetConfig(): void;
|
|
|
23
23
|
* @param {Object} [configObj=config] - The config object.
|
|
24
24
|
* @returns {string} - The root path.
|
|
25
25
|
*/
|
|
26
|
-
declare function getRootPath(configObj?: Config | null,
|
|
26
|
+
declare function getRootPath(configObj?: Config | null, optionsObj?: {
|
|
27
27
|
match?: (key: string) => boolean;
|
|
28
|
-
}): string;
|
|
28
|
+
} | null): string;
|
|
29
29
|
/**
|
|
30
30
|
* Get list of root paths from public config
|
|
31
31
|
* @returns {Array} - The list of root paths.
|
|
@@ -50,7 +50,7 @@ declare function getHeaders(scope: string): Record<string, string>;
|
|
|
50
50
|
* @param {Function} [options.match] - The function to match the path to the config.
|
|
51
51
|
* @returns {Object} The initialized root configuration
|
|
52
52
|
*/
|
|
53
|
-
declare function initializeConfig(configObj: Config,
|
|
53
|
+
declare function initializeConfig(configObj: Config, optionsObj?: {
|
|
54
54
|
match?: (key: string) => boolean;
|
|
55
55
|
}): ConfigRoot;
|
|
56
56
|
/**
|
|
@@ -33,7 +33,6 @@ export type AfterHook<T = any> = (requestInit: RequestInit, response: {
|
|
|
33
33
|
};
|
|
34
34
|
declare class FetchGraphQLMesh {
|
|
35
35
|
_endpoint?: string;
|
|
36
|
-
_inheritHeaders?: boolean;
|
|
37
36
|
get endpoint(): string | undefined;
|
|
38
37
|
get fetchGraphQlHeaders(): Header;
|
|
39
38
|
_fetchGraphQlHeaders: Header;
|
|
@@ -42,12 +41,8 @@ declare class FetchGraphQLMesh {
|
|
|
42
41
|
/**
|
|
43
42
|
* Sets the GraphQL endpoint.
|
|
44
43
|
* @param endpoint - The GraphQL endpoint.
|
|
45
|
-
* @param options - Optional configuration.
|
|
46
|
-
* @param options.inheritHeaders - If true, headers from the global mesh will be inherited.
|
|
47
44
|
*/
|
|
48
|
-
setEndpoint(endpoint: string
|
|
49
|
-
inheritHeaders?: boolean;
|
|
50
|
-
}): void;
|
|
45
|
+
setEndpoint(endpoint: string): void;
|
|
51
46
|
/**
|
|
52
47
|
* Sets the GraphQL headers.
|
|
53
48
|
* @param key - The key of the header.
|
|
@@ -129,9 +124,7 @@ declare class FetchGraphQLMesh {
|
|
|
129
124
|
fetchGraphQlHeaders: Header;
|
|
130
125
|
};
|
|
131
126
|
getMethods(): {
|
|
132
|
-
setEndpoint: (endpoint: string
|
|
133
|
-
inheritHeaders?: boolean | undefined;
|
|
134
|
-
} | undefined) => void;
|
|
127
|
+
setEndpoint: (endpoint: string) => void;
|
|
135
128
|
setFetchGraphQlHeader: (key: string, value: string | null) => void;
|
|
136
129
|
getFetchGraphQlHeader: (key: string) => string | null | undefined;
|
|
137
130
|
removeFetchGraphQlHeader: (key: string) => void;
|
|
@@ -170,9 +163,7 @@ export declare class FetchGraphQL extends FetchGraphQLMesh {
|
|
|
170
163
|
* @property {Function} fetchGraphQl - Fetches GraphQL data.
|
|
171
164
|
* @property {Function} getConfig - Gets the configuration.
|
|
172
165
|
*/
|
|
173
|
-
export declare const setEndpoint: (endpoint: string, options?: {
|
|
174
|
-
inheritHeaders?: boolean;
|
|
175
|
-
}) => void, setFetchGraphQlHeaders: (header: Header | ((prev: Header) => Header)) => void, setFetchGraphQlHeader: (key: string, value: string | null) => void, getFetchGraphQlHeader: (key: string) => string | null | undefined, removeFetchGraphQlHeader: (key: string) => void, fetchGraphQl: <T = any>(query: string, options?: FetchOptions) => Promise<{
|
|
166
|
+
export declare const setEndpoint: (endpoint: string) => void, setFetchGraphQlHeaders: (header: Header | ((prev: Header) => Header)) => void, setFetchGraphQlHeader: (key: string, value: string | null) => void, getFetchGraphQlHeader: (key: string) => string | null | undefined, removeFetchGraphQlHeader: (key: string) => void, fetchGraphQl: <T = any>(query: string, options?: FetchOptions) => Promise<{
|
|
176
167
|
errors?: FetchQueryError | undefined;
|
|
177
168
|
data: T;
|
|
178
169
|
}>, getConfig: () => {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ReCaptchaV3Response, PropsFormTypes, ReCaptchaV3Model } from './types/recaptcha.types';
|
|
2
2
|
|
|
3
3
|
export declare const recaptchaFetchApi: {
|
|
4
|
-
setEndpoint: (endpoint: string
|
|
5
|
-
inheritHeaders?: boolean | undefined;
|
|
6
|
-
} | undefined) => void;
|
|
4
|
+
setEndpoint: (endpoint: string) => void;
|
|
7
5
|
setFetchGraphQlHeader: (key: string, value: string | null) => void;
|
|
8
6
|
getFetchGraphQlHeader: (key: string) => string | null | undefined;
|
|
9
7
|
removeFetchGraphQlHeader: (key: string) => void;
|