@beamimpact/web-sdk 1.37.0 → 1.37.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.
- package/README.md +21 -1
- package/dist/chunks/{_share-dialog-dependencies-Ex1exJdU.esm.js → _share-dialog-dependencies-FheD3_vQ.esm.js} +2 -2
- package/dist/chunks/_share-dialog-dependencies-FheD3_vQ.esm.js.map +1 -0
- package/dist/chunks/{_share-dialog-dependencies-GOqKRBIc.esm.js → _share-dialog-dependencies-l35ECwOP.esm.js} +2 -2
- package/dist/chunks/_share-dialog-dependencies-l35ECwOP.esm.js.map +1 -0
- package/dist/chunks/{cart-contents-Cdq4ob0J.esm.d.ts → cart-contents-IOhdr24g.esm.d.ts} +1 -1
- package/dist/chunks/events-Y8fYvSqM.esm.js +2 -0
- package/dist/chunks/{events-5IECSF-x.esm.js.map → events-Y8fYvSqM.esm.js.map} +1 -1
- package/dist/chunks/{events-3-Mzl-dS.esm.d.ts → events-j-SJ9Cot.esm.d.ts} +17 -3
- package/dist/chunks/{index-SZxnIRAX.esm.d.ts → index-3F_Wjm5v.esm.d.ts} +1 -1
- package/dist/chunks/{index-9gijHGwh.esm.js → index-8yrr7ZZv.esm.js} +2 -2
- package/dist/chunks/index-8yrr7ZZv.esm.js.map +1 -0
- package/dist/chunks/index-B2oj1JKu.esm.js +2 -0
- package/dist/chunks/index-B2oj1JKu.esm.js.map +1 -0
- package/dist/chunks/index-E_HMWZ2A.esm.js +2 -0
- package/dist/chunks/index-E_HMWZ2A.esm.js.map +1 -0
- package/dist/chunks/{index-jYAdXbGg.esm.js → index-Gz7Q9nUW.esm.js} +2 -2
- package/dist/chunks/{index-jYAdXbGg.esm.js.map → index-Gz7Q9nUW.esm.js.map} +1 -1
- package/dist/chunks/index-JsXH5Lnc.esm.js +2 -0
- package/dist/chunks/index-JsXH5Lnc.esm.js.map +1 -0
- package/dist/chunks/{index-OnjTwvAw.esm.js → index-Lw32NXij.esm.js} +2 -2
- package/dist/chunks/index-Lw32NXij.esm.js.map +1 -0
- package/dist/chunks/index-RDKeoKqc.esm.js +2 -0
- package/dist/chunks/index-RDKeoKqc.esm.js.map +1 -0
- package/dist/chunks/index-VGoZaoVm.esm.js +2 -0
- package/dist/chunks/index-VGoZaoVm.esm.js.map +1 -0
- package/dist/chunks/{index-9Cs92uGK.esm.d.ts → index-WX8Yyx2u.esm.d.ts} +1 -1
- package/dist/chunks/{index-7-XLaXA4.esm.d.ts → index-mWnpDGl1.esm.d.ts} +1 -1
- package/dist/chunks/{index-U8Oy2aur.esm.js → index-phDmC-TS.esm.js} +2 -2
- package/dist/chunks/index-phDmC-TS.esm.js.map +1 -0
- package/dist/chunks/{index-xRjeUrl2.esm.d.ts → index-s8uQH63W.esm.d.ts} +4 -4
- package/dist/chunks/{index-b3DeBLwb.esm.d.ts → index-slrOT8Gd.esm.d.ts} +1 -1
- package/dist/chunks/{index-wsdeaTHd.esm.js → index-uF-Qtewb.esm.js} +2 -2
- package/dist/chunks/index-uF-Qtewb.esm.js.map +1 -0
- package/dist/chunks/{index-KErjmUlF.esm.js → index-vpkWmZo_.esm.js} +2 -2
- package/dist/chunks/{index-KErjmUlF.esm.js.map → index-vpkWmZo_.esm.js.map} +1 -1
- package/dist/chunks/index-xYLcuL6Z.esm.js +2 -0
- package/dist/chunks/index-xYLcuL6Z.esm.js.map +1 -0
- package/dist/chunks/{index-AhT9jBIr.esm.d.ts → index-yXqJ9Znv.esm.d.ts} +1 -1
- package/dist/chunks/{openapi-spec-WpREPNjl.esm.d.ts → openapi-spec-b529HHW3.esm.d.ts} +7 -7
- package/dist/chunks/order-page-9B0nZVh1.esm.js +2 -0
- package/dist/chunks/order-page-9B0nZVh1.esm.js.map +1 -0
- package/dist/chunks/{order-page-eOCpZ8vN.esm.d.ts → order-page-jkuLE25f.esm.d.ts} +3 -4
- package/dist/chunks/order-page-yM2h67MI.esm.js +2 -0
- package/dist/chunks/order-page-yM2h67MI.esm.js.map +1 -0
- package/dist/chunks/routes-LFjgVNGB.esm.js +2 -0
- package/dist/chunks/routes-LFjgVNGB.esm.js.map +1 -0
- package/dist/chunks/routes-ad0I3Ayc.esm.js +2 -0
- package/dist/chunks/routes-ad0I3Ayc.esm.js.map +1 -0
- package/dist/chunks/{update-cart-8nDxTnnQ.esm.js → update-cart-A2hs4tF8.esm.js} +2 -2
- package/dist/chunks/{update-cart-8nDxTnnQ.esm.js.map → update-cart-A2hs4tF8.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-D4jDrYC0.esm.d.ts → update-cart-EKZbvT8c.esm.d.ts} +1 -1
- package/dist/chunks/{update-cart-_cCsAqH9.esm.js → update-cart-vcujKNky.esm.js} +2 -2
- package/dist/chunks/{update-cart-_cCsAqH9.esm.js.map → update-cart-vcujKNky.esm.js.map} +1 -1
- package/dist/components/community-impact.esm.js +1 -1
- package/dist/components/community-impact.js +1 -1
- package/dist/components/cumulative-impact.esm.js +1 -1
- package/dist/components/cumulative-impact.js +1 -1
- package/dist/components/impact-overview.esm.js +1 -1
- package/dist/components/impact-overview.js +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/post-purchase.d.ts +3 -3
- package/dist/components/post-purchase.esm.js +1 -1
- package/dist/components/post-purchase.js +1 -1
- package/dist/components/redeem-transaction.d.ts +3 -3
- package/dist/components/redeem-transaction.esm.js +1 -1
- package/dist/components/redeem-transaction.js +1 -1
- package/dist/components/select-nonprofit.d.ts +3 -3
- package/dist/components/select-nonprofit.esm.js +19 -19
- package/dist/components/select-nonprofit.esm.js.map +1 -1
- package/dist/components/select-nonprofit.js +19 -19
- package/dist/components/select-nonprofit.js.map +1 -1
- package/dist/components/shopify.d.ts +5 -5
- package/dist/components/shopify.esm.js +1 -1
- package/dist/components/shopify.js +1 -1
- package/dist/components/subscription-management.d.ts +3 -3
- package/dist/components/subscription-management.esm.js +1 -1
- package/dist/components/subscription-management.js +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/beam.esm.js +1 -1
- package/dist/integrations/beam.js +1 -1
- package/dist/integrations/cart.d.ts +3 -3
- package/dist/integrations/cart.esm.js +1 -1
- package/dist/integrations/cart.js +1 -1
- package/dist/integrations/index.d.ts +9 -9
- package/dist/integrations/index.esm.js +1 -1
- package/dist/integrations/index.js +1 -1
- package/dist/integrations/logs.d.ts +2 -2
- package/dist/integrations/logs.esm.js +1 -1
- package/dist/integrations/logs.js +1 -1
- package/dist/integrations/shopify.d.ts +4 -4
- package/dist/integrations/shopify.esm.js +1 -1
- package/dist/integrations/shopify.js +1 -1
- package/dist/integrations/statsig.esm.js +1 -1
- package/dist/integrations/statsig.js +1 -1
- package/dist/integrations/utils.d.ts +3 -3
- package/dist/integrations/utils.esm.js +1 -1
- package/dist/integrations/utils.js +1 -1
- package/dist/react/community-impact.esm.js +1 -1
- package/dist/react/community-impact.js +1 -1
- package/dist/react/cumulative-impact.esm.js +1 -1
- package/dist/react/cumulative-impact.js +1 -1
- package/dist/react/impact-overview.esm.js +1 -1
- package/dist/react/impact-overview.js +1 -1
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.esm.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/post-purchase.d.ts +2 -2
- package/dist/react/post-purchase.esm.js +1 -1
- package/dist/react/post-purchase.js +1 -1
- package/dist/react/redeem-transaction.d.ts +3 -3
- package/dist/react/redeem-transaction.esm.js +1 -1
- package/dist/react/redeem-transaction.js +1 -1
- package/dist/react/select-nonprofit.d.ts +3 -3
- package/dist/react/select-nonprofit.esm.js +1 -1
- package/dist/react/select-nonprofit.js +1 -1
- package/dist/react/subscription-management.d.ts +2 -2
- package/dist/react/subscription-management.esm.js +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/dist/utils/events.d.ts +3 -3
- package/dist/utils/events.esm.js +1 -1
- package/dist/utils/events.js +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/network-listeners.esm.js +1 -1
- package/dist/utils/network-listeners.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/_share-dialog-dependencies-Ex1exJdU.esm.js.map +0 -1
- package/dist/chunks/_share-dialog-dependencies-GOqKRBIc.esm.js.map +0 -1
- package/dist/chunks/events-5IECSF-x.esm.js +0 -2
- package/dist/chunks/index-5AkzIYu3.esm.js +0 -2
- package/dist/chunks/index-5AkzIYu3.esm.js.map +0 -1
- package/dist/chunks/index-8VxiCO_y.esm.js +0 -2
- package/dist/chunks/index-8VxiCO_y.esm.js.map +0 -1
- package/dist/chunks/index-9gijHGwh.esm.js.map +0 -1
- package/dist/chunks/index-OnjTwvAw.esm.js.map +0 -1
- package/dist/chunks/index-U8Oy2aur.esm.js.map +0 -1
- package/dist/chunks/index-a9SRo_pt.esm.js +0 -2
- package/dist/chunks/index-a9SRo_pt.esm.js.map +0 -1
- package/dist/chunks/index-fdm0Zxu6.esm.js +0 -2
- package/dist/chunks/index-fdm0Zxu6.esm.js.map +0 -1
- package/dist/chunks/index-gfShfkGQ.esm.js +0 -2
- package/dist/chunks/index-gfShfkGQ.esm.js.map +0 -1
- package/dist/chunks/index-wsdeaTHd.esm.js.map +0 -1
- package/dist/chunks/index-yEHTVDWu.esm.js +0 -2
- package/dist/chunks/index-yEHTVDWu.esm.js.map +0 -1
- package/dist/chunks/order-page-ZyVxKalS.esm.js +0 -2
- package/dist/chunks/order-page-ZyVxKalS.esm.js.map +0 -1
- package/dist/chunks/order-page-nKOujF0G.esm.js +0 -2
- package/dist/chunks/order-page-nKOujF0G.esm.js.map +0 -1
- package/dist/chunks/routes-S3ZS-od_.esm.js +0 -2
- package/dist/chunks/routes-S3ZS-od_.esm.js.map +0 -1
- package/dist/chunks/routes-jQjZhNH9.esm.js +0 -2
- package/dist/chunks/routes-jQjZhNH9.esm.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routes-S3ZS-od_.esm.js","sources":["../../src/api-sdk/fetch-json.ts","../../src/api-sdk/constants.ts","../../src/api-sdk/v3/make-openapi-method.ts","../../src/api-sdk/v3/routes.ts"],"sourcesContent":["/**\n * Wrapper over window.fetch that expects/returns JSON\n */\nimport { BeamError, NetworkError } from \"../utils/beam-errors\";\nimport { logger } from \"../utils/logger\";\nimport { version as pkgVersion } from \"../../package.json\";\n\nexport async function fetchJson<T = unknown>(url: RequestInfo, options?: RequestInit): Promise<T> {\n const fetchOptions = {\n method: \"GET\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n \"X-Beam-Client\": \"WebSDK\",\n \"X-Beam-Client-Version\": pkgVersion,\n ...options?.headers,\n },\n preflightContinue: true,\n mode: options?.mode || \"cors\",\n body: options?.body != null ? options.body : undefined,\n };\n\n let response;\n try {\n response = await fetch(url, fetchOptions);\n // fetch can throw a TypeError if the server can't be reached, catch and log below\n } catch (err) {\n const error = new BeamError(`Network call failed (${fetchOptions?.method.toUpperCase()} ${url})`);\n error.cause = err;\n logger.error(error, url);\n throw error;\n }\n let body;\n let text;\n // This can throw a SyntaxError if response payload is malformed JSON\n try {\n text = await response.text();\n if (text) {\n // (response can be empty)\n body = JSON.parse(text);\n }\n } catch (err) {\n let error = err as Error;\n if (err instanceof SyntaxError) {\n error = new NetworkError(response, body, `Response invalid. Expected JSON. Received: \"${text}\"`);\n error.cause = err;\n }\n logger.error(error);\n throw error;\n }\n // Translate 4xx, 5xx status to runtime error\n if (!response.ok) {\n const error = new NetworkError(response, body, \"Response was not OK\");\n logger.error(error);\n throw error;\n }\n\n return body;\n}\n","import { LANGUAGES, TUrl } from \"./types\";\n\nexport const DEFAULT_BASE_URL: TUrl = \"https://production-central-backend-ne.beamimpact.com\";\n\nexport const DEFAULT_LOG_URL = \"https://production.beamimpactlogs.com\";\n\nexport const SUPPORTED_LANGUAGES: Record<string, LANGUAGES> = {\n en: \"en\",\n fr: \"fr\",\n de: \"de\",\n es: \"es\",\n it: \"it\",\n pl: \"pl\",\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { fetchJson } from \"../fetch-json\";\nimport { DEFAULT_BASE_URL } from \"../constants\";\nimport { THttpMethod } from \"../types\";\nimport { paths } from \"./openapi-spec\";\n\nexport const makeOpenApiMethod = <\n TPathName extends keyof paths,\n TMethod extends keyof paths[TPathName],\n TStatusCode extends paths[TPathName][TMethod] extends { responses: any }\n ? keyof paths[TPathName][TMethod][\"responses\"]\n : never\n>(\n pathName: TPathName,\n method: TMethod,\n okHttpStatus: TStatusCode\n) => {\n type TRouteSpec = paths[typeof pathName];\n type TRouteMethod = TRouteSpec[typeof method];\n type TParams = \"parameters\" extends keyof TRouteMethod ? TRouteMethod[\"parameters\"] : never;\n type TPathParams = TParams extends { path: any } ? TParams[\"path\"] : Record<string, never>;\n type TQueryParams = TParams extends { query: any } ? TParams[\"query\"] : Record<string, never>;\n type TRequestBody = TRouteMethod extends { requestBody: { content: { \"application/json\": any } } }\n ? TRouteMethod[\"requestBody\"][\"content\"][\"application/json\"]\n : never;\n type TAllResponses = TRouteMethod extends { responses: any } ? TRouteMethod[\"responses\"] : never;\n type TOkResponse = TAllResponses[typeof okHttpStatus] extends { content: { \"application/json\": any } }\n ? TAllResponses[typeof okHttpStatus][\"content\"][\"application/json\"]\n : never;\n const openApi = {\n [pathName]: async function ({\n headers = {},\n baseUrl = DEFAULT_BASE_URL,\n apiRoot = \"/api/v3\",\n pathParams = {},\n queryParams = {},\n requestBody,\n }: {\n baseUrl?: string;\n apiRoot?: string;\n pathParams?: TPathParams;\n queryParams?: TQueryParams;\n requestBody?: TRequestBody;\n headers?: Record<string, string>;\n }) {\n const pathWithParams: string = Object.entries(pathParams).reduce((newPath: string, [k, v]) => {\n return newPath.replace(`{${k}}`, v as string);\n }, pathName as string);\n const cleanQueryParams = JSON.parse(JSON.stringify(queryParams));\n const search = new URLSearchParams(cleanQueryParams as unknown as Record<string, string>).toString();\n const url = baseUrl + apiRoot + pathWithParams + (search && `?${search}`);\n const options = { headers, method: method as THttpMethod, body: JSON.stringify(requestBody) };\n\n return fetchJson<TOkResponse>(url, options);\n },\n };\n\n // Use object to create function with dynamic name, for better stacktraces\n return openApi[pathName];\n};\n","import { makeOpenApiMethod } from \"./make-openapi-method\";\n\nexport const getChainNonprofits = makeOpenApiMethod(\"/chain/{chainId}/nonprofits\", \"get\", 200);\n\nexport const getImpact = makeOpenApiMethod(\"/impact\", \"get\", 200);\n\nexport const getCumulativeImpact = makeOpenApiMethod(\"/chain/{chainId}/cumulativeImpact\", \"get\", 200);\n\nexport const postSelectNonprofit = makeOpenApiMethod(\"/selectNonprofit\", \"post\", 201);\n\nexport const postTransaction = makeOpenApiMethod(\"/transaction\", \"post\", 201);\n\nexport const putTransaction = makeOpenApiMethod(\"/transaction/{transactionId}\", \"put\", 204);\n\nexport const postCart = makeOpenApiMethod(\"/cart\", \"post\", 200);\n\nexport const postChainEligibleNonprofitsForCart = makeOpenApiMethod(\n \"/chain/findEligibleNonprofitsForCart\",\n \"post\",\n 200\n);\n\nexport const postLogs = makeOpenApiMethod(\"/logs\", \"post\", 200);\n\nexport const postExperimentSession = makeOpenApiMethod(\"/experimentSession\", \"post\", 200);\n\nexport const updateSubscription = makeOpenApiMethod(\"/subscriptions/updateSubscriptionNonprofit\", \"post\", 200);\n\nexport const postFindOrCreateSubscription = makeOpenApiMethod(\"/subscriptions/findOrCreateSubscription\", \"post\", 200);\n"],"names":["fetchJson","url","options","fetchOptions","pkgVersion","response","err","error","BeamError","logger","body","text","NetworkError","DEFAULT_BASE_URL","DEFAULT_LOG_URL","SUPPORTED_LANGUAGES","makeOpenApiMethod","pathName","method","okHttpStatus","headers","baseUrl","apiRoot","pathParams","queryParams","requestBody","pathWithParams","newPath","k","v","cleanQueryParams","search","getImpact","getCumulativeImpact","postSelectNonprofit","postTransaction","putTransaction","postCart","postChainEligibleNonprofitsForCart","postLogs","postExperimentSession","updateSubscription","postFindO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AAAC,EAAa,CACb,EAAA,YAAAC,EAAc,CAAA,EACd,YAAAC,CACF,EAOG,CACD,MAAMC,EAAyB,OAAO,QAAQH,CAAU,EAAE,OAAO,CAACI,EAAiB,CAACC,EAAGC,CAAC,IAC/EF,EAAQ,QAAQ,IAAIC,CAAC,IAAKC,CAAW,EAC3CZ,CAAkB,EACfa,EAAmB,KAAK,MAAM,KAAK,UAAUN,CAAW,CAAC,EACzDO,EAAS,IAAI,gBAAgBD,CAAqD,EAAE,SACpF7B,EAAAA,EAAMoB,EAAUC,EAAUI,GAAkBK,GAAU,IAAIA,CAAM,IAChE7B,EAAU,CAAE,QAAAkB,EAAS,OAAQF,EAAuB,KAAM,KAAK,UAAUO,CAAW,CAAE,EAE5F,OAAOzB,EAAuBC,EAAKC,CAAO,CAC5C,CACF,GAGee,CAAQ,ECvDZe,EAAYhB,EAAkB,UAAW,KAAU,EAEnDiB,EAAsBjB,EAAkB,oCAAqC,KAAU,EAEvFkB,EAAsBlB,EAAkB,mBAAoB,MAAW,EAEvEmB,EAAkBnB,EAAkB,eAAgB,MAAW,EAE/DoB,EAAiBpB,EAAkB,+BAAgC,KAAU,EAE7EqB,EAAWrB,EAAkB,QAAS,MAAW,EAEjDsB,EAAqCtB,EAChD,uCACA,MAEF,EAEauB,EAAWvB,EAAkB,QAAS,MAAW,EAEjDwB,EAAwBxB,EAAkB,qBAAsB,MAAW,EAE3EyB,EAAqBzB,EAAkB,6CAA8C,MAAW,EAEhG0B,EAA+B1B,EAAkB,0CAA2C,MAAW"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{B as E,N as l}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as p}from"../utils/logger.esm.js";var w="1.37.0",C={"@lit/react":"1.0.0","@lukeed/uuid":"2.0.0","@shoelace-style/shoelace":"2.11.2",lit:"2.6.1","lodash-es":"4.17.21","lucide-static":"0.292.0"};async function O(s,a){const c={method:"GET",...a,headers:{"Content-Type":"application/json",Accept:"application/json","X-Beam-Client":"WebSDK","X-Beam-Client-Version":w,...a?.headers},preflightContinue:!0,mode:a?.mode||"cors",body:a?.body!=null?a.body:void 0};let r;try{r=await fetch(s,c)}catch(e){const o=new E(`Network call failed (${c?.method.toUpperCase()} ${s})`);throw o.cause=e,p.error(o,s),o}let n,i;try{i=await r.text(),i&&(n=JSON.parse(i))}catch(e){let o=e;throw e instanceof SyntaxError&&(o=new l(r,n,`Response invalid. Expected JSON. Received: "${i}"`),o.cause=e),p.error(o),o}if(!r.ok){const e=new l(r,n,"Response was not OK");throw p.error(e),e}return n}const u="https://production-central-backend-ne.beamimpact.com",v="https://production.beamimpactlogs.com",U={en:"en",fr:"fr",de:"de",es:"es",it:"it",pl:"pl"},t=(s,a,c)=>({[s]:async function({headers:r={},baseUrl:n=u,apiRoot:i="/api/v3",pathParams:e={},queryParams:o={},requestBody:m}){const h=Object.entries(e).reduce((g,[y,N])=>g.replace(`{${y}}`,N),s),f=JSON.parse(JSON.stringify(o)),d=new URLSearchParams(f).toString(),S=n+i+h+(d&&`?${d}`),b={headers:r,method:a,body:JSON.stringify(m)};return O(S,b)}})[s],L=t("/impact","get"),R=t("/chain/{chainId}/cumulativeImpact","get"),T=t("/selectNonprofit","post"),k=t("/transaction","post"),A=t("/transaction/{transactionId}","put"),x=t("/cart","post"),B=t("/chain/findEligibleNonprofitsForCart","post"),J=t("/logs","post"),D=t("/experimentSession","post"),F=t("/subscriptions/updateSubscriptionNonprofit","post"),I=t("/subscriptions/findOrCreateSubscription","post");export{u as D,U as S,v as a,k as b,x as c,J as d,B as e,T as f,L as g,I as h,A as i,R as j,C as k,D as p,F as u};
|
|
2
|
-
//# sourceMappingURL=routes-jQjZhNH9.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routes-jQjZhNH9.esm.js","sources":["../../src/api-sdk/fetch-json.ts","../../src/api-sdk/constants.ts","../../src/api-sdk/v3/make-openapi-method.ts","../../src/api-sdk/v3/routes.ts"],"sourcesContent":["/**\n * Wrapper over window.fetch that expects/returns JSON\n */\nimport { BeamError, NetworkError } from \"../utils/beam-errors\";\nimport { logger } from \"../utils/logger\";\nimport { version as pkgVersion } from \"../../package.json\";\n\nexport async function fetchJson<T = unknown>(url: RequestInfo, options?: RequestInit): Promise<T> {\n const fetchOptions = {\n method: \"GET\",\n ...options,\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n \"X-Beam-Client\": \"WebSDK\",\n \"X-Beam-Client-Version\": pkgVersion,\n ...options?.headers,\n },\n preflightContinue: true,\n mode: options?.mode || \"cors\",\n body: options?.body != null ? options.body : undefined,\n };\n\n let response;\n try {\n response = await fetch(url, fetchOptions);\n // fetch can throw a TypeError if the server can't be reached, catch and log below\n } catch (err) {\n const error = new BeamError(`Network call failed (${fetchOptions?.method.toUpperCase()} ${url})`);\n error.cause = err;\n logger.error(error, url);\n throw error;\n }\n let body;\n let text;\n // This can throw a SyntaxError if response payload is malformed JSON\n try {\n text = await response.text();\n if (text) {\n // (response can be empty)\n body = JSON.parse(text);\n }\n } catch (err) {\n let error = err as Error;\n if (err instanceof SyntaxError) {\n error = new NetworkError(response, body, `Response invalid. Expected JSON. Received: \"${text}\"`);\n error.cause = err;\n }\n logger.error(error);\n throw error;\n }\n // Translate 4xx, 5xx status to runtime error\n if (!response.ok) {\n const error = new NetworkError(response, body, \"Response was not OK\");\n logger.error(error);\n throw error;\n }\n\n return body;\n}\n","import { LANGUAGES, TUrl } from \"./types\";\n\nexport const DEFAULT_BASE_URL: TUrl = \"https://production-central-backend-ne.beamimpact.com\";\n\nexport const DEFAULT_LOG_URL = \"https://production.beamimpactlogs.com\";\n\nexport const SUPPORTED_LANGUAGES: Record<string, LANGUAGES> = {\n en: \"en\",\n fr: \"fr\",\n de: \"de\",\n es: \"es\",\n it: \"it\",\n pl: \"pl\",\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { fetchJson } from \"../fetch-json\";\nimport { DEFAULT_BASE_URL } from \"../constants\";\nimport { THttpMethod } from \"../types\";\nimport { paths } from \"./openapi-spec\";\n\nexport const makeOpenApiMethod = <\n TPathName extends keyof paths,\n TMethod extends keyof paths[TPathName],\n TStatusCode extends paths[TPathName][TMethod] extends { responses: any }\n ? keyof paths[TPathName][TMethod][\"responses\"]\n : never\n>(\n pathName: TPathName,\n method: TMethod,\n okHttpStatus: TStatusCode\n) => {\n type TRouteSpec = paths[typeof pathName];\n type TRouteMethod = TRouteSpec[typeof method];\n type TParams = \"parameters\" extends keyof TRouteMethod ? TRouteMethod[\"parameters\"] : never;\n type TPathParams = TParams extends { path: any } ? TParams[\"path\"] : Record<string, never>;\n type TQueryParams = TParams extends { query: any } ? TParams[\"query\"] : Record<string, never>;\n type TRequestBody = TRouteMethod extends { requestBody: { content: { \"application/json\": any } } }\n ? TRouteMethod[\"requestBody\"][\"content\"][\"application/json\"]\n : never;\n type TAllResponses = TRouteMethod extends { responses: any } ? TRouteMethod[\"responses\"] : never;\n type TOkResponse = TAllResponses[typeof okHttpStatus] extends { content: { \"application/json\": any } }\n ? TAllResponses[typeof okHttpStatus][\"content\"][\"application/json\"]\n : never;\n const openApi = {\n [pathName]: async function ({\n headers = {},\n baseUrl = DEFAULT_BASE_URL,\n apiRoot = \"/api/v3\",\n pathParams = {},\n queryParams = {},\n requestBody,\n }: {\n baseUrl?: string;\n apiRoot?: string;\n pathParams?: TPathParams;\n queryParams?: TQueryParams;\n requestBody?: TRequestBody;\n headers?: Record<string, string>;\n }) {\n const pathWithParams: string = Object.entries(pathParams).reduce((newPath: string, [k, v]) => {\n return newPath.replace(`{${k}}`, v as string);\n }, pathName as string);\n const cleanQueryParams = JSON.parse(JSON.stringify(queryParams));\n const search = new URLSearchParams(cleanQueryParams as unknown as Record<string, string>).toString();\n const url = baseUrl + apiRoot + pathWithParams + (search && `?${search}`);\n const options = { headers, method: method as THttpMethod, body: JSON.stringify(requestBody) };\n\n return fetchJson<TOkResponse>(url, options);\n },\n };\n\n // Use object to create function with dynamic name, for better stacktraces\n return openApi[pathName];\n};\n","import { makeOpenApiMethod } from \"./make-openapi-method\";\n\nexport const getChainNonprofits = makeOpenApiMethod(\"/chain/{chainId}/nonprofits\", \"get\", 200);\n\nexport const getImpact = makeOpenApiMethod(\"/impact\", \"get\", 200);\n\nexport const getCumulativeImpact = makeOpenApiMethod(\"/chain/{chainId}/cumulativeImpact\", \"get\", 200);\n\nexport const postSelectNonprofit = makeOpenApiMethod(\"/selectNonprofit\", \"post\", 201);\n\nexport const postTransaction = makeOpenApiMethod(\"/transaction\", \"post\", 201);\n\nexport const putTransaction = makeOpenApiMethod(\"/transaction/{transactionId}\", \"put\", 204);\n\nexport const postCart = makeOpenApiMethod(\"/cart\", \"post\", 200);\n\nexport const postChainEligibleNonprofitsForCart = makeOpenApiMethod(\n \"/chain/findEligibleNonprofitsForCart\",\n \"post\",\n 200\n);\n\nexport const postLogs = makeOpenApiMethod(\"/logs\", \"post\", 200);\n\nexport const postExperimentSession = makeOpenApiMethod(\"/experimentSession\", \"post\", 200);\n\nexport const updateSubscription = makeOpenApiMethod(\"/subscriptions/updateSubscriptionNonprofit\", \"post\", 200);\n\nexport const postFindOrCreateSubscription = makeOpenApiMethod(\"/subscriptions/findOrCreateSubscription\", \"post\", 200);\n"],"names":["fetchJson","url","options","fetchOptions","pkgVersion","response","err","error","BeamError","logger","body","text","NetworkError","DEFAULT_BASE_URL","DEFAULT_LOG_URL","SUPPORTED_LANGUAGES","makeOpenApiMethod","pathName","method","okHttpStatus","headers","baseUrl","apiRoot","pathParams","queryParams","requestBody","pathWithParams","newPath","k","v","cleanQueryParams","search","getImpact","getCumulativeImpact","postSelectNonprofit","postTransaction","putTransaction","postCart","postChainEligibleNonprofitsForCart","postLogs","postExperimentSession","updateSubscription","postFindOrCreateSubscription"],"mappings":"wQAOA,eAAsBA,EAAuBC,EAAkBC,EAAmC,CAChG,MAAMC,EAAe,CACnB,OAAQ,MACR,GAAGD,EACH,QAAS,CACP,eAAgB,mBAChB,OAAQ,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