b23-lib 3.9.9 → 3.10.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/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import {b as b$3}from'./chunk-AMIRIUMH.mjs';export{d as Fetch,b as Logger,c as ResponseUtility}from'./chunk-AMIRIUMH.mjs';import {f,b as b$2}from'./chunk-4PTWJI6J.mjs';export{a as Utils}from'./chunk-4PTWJI6J.mjs';import'./chunk-7RAIVZKB.mjs';import'./chunk-UIQH5QIR.mjs';import {q,j,a,b as b$1,c,d as d$1}from'./chunk-PL5HGCWN.mjs';import'./chunk-O6BLQQO7.mjs';import'./chunk-UXZBULDS.mjs';var m={$id:"standards",definitions:{lowercaseText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]*$"},lowercaseText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,10}$"},lowercaseText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,16}$"},lowercaseText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,30}$"},lowercaseText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,50}$"},lowercaseText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,256}$"},text:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).*$"},text10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,10}$"},text16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,16}$"},text30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,30}$"},text50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,50}$"},text256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,256}$"},requiredText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).+$"},requiredText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,10}$"},requiredText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,16}$"},requiredText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,30}$"},requiredText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,50}$"},requiredText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,256}$"},url:{type:"string",pattern:"^https://[^\\s/$.?#].[^\\s]*$",maxLength:2048},uuid:{type:"string",minLength:1,pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"},productKey:{type:"string",pattern:f.productKeyRegex.source},productSku:{type:"string",pattern:f.productSKURegex.source},productType:{type:"string",enum:Object.values(q)},genderCategory:{type:"string",enum:Object.values(j)},price:{type:"object",properties:{amount:{type:"number",minimum:0},currency:{$ref:"#/definitions/currency"}},additionalProperties:!1,required:["amount","currency"]},color:{type:"object",properties:{name:{type:"string"},hex:{type:"string"}},additionalProperties:!1,required:["name"]},attributeValue:{oneOf:[{type:"string"},{$ref:"#/definitions/color"}]},selectionAttributes:{type:"object",properties:{color:{$ref:"#/definitions/color"}},required:["color"],additionalProperties:{$ref:"#/definitions/attributeValue"}},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},company:{$ref:"#/definitions/text50"},phone:{type:"string",pattern:"^[0-9]{10}$"},e164Phone:{type:"string",pattern:"^\\+[1-9]\\d{1,14}$"},email:{type:"string",pattern:"^[^\\s]+@[^\\s]+\\.[^\\s]+$"},addressLine1:{$ref:"#/definitions/requiredText50"},addressLine2:{$ref:"#/definitions/text50"},city:{$ref:"#/definitions/requiredText30"},postalCode:{$ref:"#/definitions/requiredText16"},state:{type:"string",enum:["AP","AR","AS","BR","CT","GA","GJ","HR","HP","JH","KA","KL","MP","MH","MN","ML","MZ","NL","OR","PB","RJ","SK","TN","TG","TR","UP","UT","WB","AN","CH","DH","LD","DL","PY","LA","JK"]},country:{type:"string",enum:Object.values(a)},currency:{type:"string",enum:Object.values(b$1)},locale:{type:"string",enum:Object.values(c)},language:{type:"string",enum:Object.values(d$1)},localeOrLanguage:{type:"string",enum:[...Object.values(c),...Object.values(d$1)]},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},company:{$ref:"standards#/definitions/company"},phone:{$ref:"standards#/definitions/phone"},email:{$ref:"standards#/definitions/email"},addressLine1:{$ref:"standards#/definitions/addressLine1"},addressLine2:{$ref:"standards#/definitions/addressLine2"},city:{$ref:"standards#/definitions/city"},postalCode:{$ref:"standards#/definitions/postalCode"},state:{$ref:"standards#/definitions/state"},country:{$ref:"standards#/definitions/country"}},required:["firstName","lastName","phone","email","addressLine1","postalCode","state","country"]}}};var g={$id:"TieredPrices",definitions:{pricingType:{enum:Object.values(b$2)},tier:{type:"object",properties:{enabled:{type:"boolean"},minQuantity:{type:"integer",minimum:1},unitPrice:{$ref:"standards#/definitions/price"}},required:["minQuantity","unitPrice"]},volumeTieredPrice:{type:"object",properties:{type:{const:"volume"},currency:{$ref:"standards#/definitions/currency"},baseUnitPrice:{$ref:"standards#/definitions/price"},taxCategory:{$ref:"standards#/definitions/requiredText"},isTaxInclusive:{type:"boolean"},tiers:{type:"array",items:{$ref:"TieredPrices#/definitions/tier"}}},required:["taxCategory","baseUnitPrice"]},selectionTieredPrice:{type:"object",properties:{type:{const:"selection"},currency:{$ref:"standards#/definitions/currency"},taxCategory:{$ref:"standards#/definitions/requiredText"},isTaxInclusive:{type:"boolean"},selections:{type:"array",items:{type:"object",properties:{selectionAttributes:{$ref:"standards#/definitions/selectionAttributes"},baseUnitPrice:{$ref:"standards#/definitions/price"},tiers:{type:"array",items:{$ref:"TieredPrices#/definitions/tier"}}},required:["selectionAttributes","baseUnitPrice"]}}},required:["type","taxCategory","currency"]},tieredPrice:{anyOf:[{$ref:"TieredPrices#/definitions/volumeTieredPrice"},{$ref:"TieredPrices#/definitions/selectionTieredPrice"}]}}};var T={getStandardSchemaDefinition(){return m},getTieredPriceSchemaDefinition(){return g}},b=T;var d=class{cache=new Map;maxSize;ttl;cleanupInterval;constructor(e=1e3,t=5*60*1e3){if(!Number.isFinite(e)||e<1)throw new RangeError("maxSize must be a finite number greater than or equal to 1.");if(!Number.isFinite(t)||t<1)throw new RangeError("ttl must be a finite number greater than or equal to 1.");this.maxSize=e,this.ttl=t,this.cleanupInterval=setInterval(()=>this.cleanup(),60*1e3),this.cleanupInterval.unref&&this.cleanupInterval.unref();}cleanup(){let e=Date.now();for(let[t,r]of this.cache.entries())e>=r.expiry&&this.cache.delete(t);}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r);}this.cache.set(e,{value:t,expiry:Date.now()+this.ttl});}get(e){let t=this.cache.get(e);if(t){if(Date.now()>=t.expiry){this.cache.delete(e);return}return this.cache.delete(e),b$3.logMessage("MemoryCache.get",`Successfully read cache data for key: ${e}`),this.cache.set(e,t),t.value}}dispose(){clearInterval(this.cleanupInterval);}},P=d;
1
+ import {b as b$3}from'./chunk-XZFALA7N.mjs';export{d as Fetch,b as Logger,c as ResponseUtility}from'./chunk-XZFALA7N.mjs';import {f,b as b$2}from'./chunk-4PTWJI6J.mjs';export{a as Utils}from'./chunk-4PTWJI6J.mjs';import'./chunk-7RAIVZKB.mjs';import'./chunk-UIQH5QIR.mjs';import {q,j,a,b as b$1,c,d as d$1}from'./chunk-PL5HGCWN.mjs';import'./chunk-O6BLQQO7.mjs';import'./chunk-UXZBULDS.mjs';var m={$id:"standards",definitions:{lowercaseText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]*$"},lowercaseText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,10}$"},lowercaseText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,16}$"},lowercaseText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,30}$"},lowercaseText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,50}$"},lowercaseText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$)[a-z]{0,256}$"},text:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).*$"},text10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,10}$"},text16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,16}$"},text30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,30}$"},text50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,50}$"},text256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{0,256}$"},requiredText:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).+$"},requiredText10:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,10}$"},requiredText16:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,16}$"},requiredText30:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,30}$"},requiredText50:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,50}$"},requiredText256:{type:"string",pattern:"^(?!\\s)(?!.*\\s$).{1,256}$"},url:{type:"string",pattern:"^https://[^\\s/$.?#].[^\\s]*$",maxLength:2048},uuid:{type:"string",minLength:1,pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"},productKey:{type:"string",pattern:f.productKeyRegex.source},productSku:{type:"string",pattern:f.productSKURegex.source},productType:{type:"string",enum:Object.values(q)},genderCategory:{type:"string",enum:Object.values(j)},price:{type:"object",properties:{amount:{type:"number",minimum:0},currency:{$ref:"#/definitions/currency"}},additionalProperties:!1,required:["amount","currency"]},color:{type:"object",properties:{name:{type:"string"},hex:{type:"string"}},additionalProperties:!1,required:["name"]},attributeValue:{oneOf:[{type:"string"},{$ref:"#/definitions/color"}]},selectionAttributes:{type:"object",properties:{color:{$ref:"#/definitions/color"}},required:["color"],additionalProperties:{$ref:"#/definitions/attributeValue"}},firstName:{$ref:"#/definitions/requiredText30"},lastName:{$ref:"#/definitions/text30"},company:{$ref:"#/definitions/text50"},phone:{type:"string",pattern:"^[0-9]{10}$"},e164Phone:{type:"string",pattern:"^\\+[1-9]\\d{1,14}$"},email:{type:"string",pattern:"^[^\\s]+@[^\\s]+\\.[^\\s]+$"},addressLine1:{$ref:"#/definitions/requiredText50"},addressLine2:{$ref:"#/definitions/text50"},city:{$ref:"#/definitions/requiredText30"},postalCode:{$ref:"#/definitions/requiredText16"},state:{type:"string",enum:["AP","AR","AS","BR","CT","GA","GJ","HR","HP","JH","KA","KL","MP","MH","MN","ML","MZ","NL","OR","PB","RJ","SK","TN","TG","TR","UP","UT","WB","AN","CH","DH","LD","DL","PY","LA","JK"]},country:{type:"string",enum:Object.values(a)},currency:{type:"string",enum:Object.values(b$1)},locale:{type:"string",enum:Object.values(c)},language:{type:"string",enum:Object.values(d$1)},localeOrLanguage:{type:"string",enum:[...Object.values(c),...Object.values(d$1)]},addressType:{type:"string",enum:["shipping","billing","billing&shipping"]},address:{type:"object",properties:{firstName:{$ref:"standards#/definitions/firstName"},lastName:{$ref:"standards#/definitions/lastName"},company:{$ref:"standards#/definitions/company"},phone:{$ref:"standards#/definitions/phone"},email:{$ref:"standards#/definitions/email"},addressLine1:{$ref:"standards#/definitions/addressLine1"},addressLine2:{$ref:"standards#/definitions/addressLine2"},city:{$ref:"standards#/definitions/city"},postalCode:{$ref:"standards#/definitions/postalCode"},state:{$ref:"standards#/definitions/state"},country:{$ref:"standards#/definitions/country"}},required:["firstName","lastName","phone","email","addressLine1","postalCode","state","country"]}}};var g={$id:"TieredPrices",definitions:{pricingType:{enum:Object.values(b$2)},tier:{type:"object",properties:{enabled:{type:"boolean"},minQuantity:{type:"integer",minimum:1},unitPrice:{$ref:"standards#/definitions/price"}},required:["minQuantity","unitPrice"]},volumeTieredPrice:{type:"object",properties:{type:{const:"volume"},currency:{$ref:"standards#/definitions/currency"},baseUnitPrice:{$ref:"standards#/definitions/price"},taxCategory:{$ref:"standards#/definitions/requiredText"},isTaxInclusive:{type:"boolean"},tiers:{type:"array",items:{$ref:"TieredPrices#/definitions/tier"}}},required:["taxCategory","baseUnitPrice"]},selectionTieredPrice:{type:"object",properties:{type:{const:"selection"},currency:{$ref:"standards#/definitions/currency"},taxCategory:{$ref:"standards#/definitions/requiredText"},isTaxInclusive:{type:"boolean"},selections:{type:"array",items:{type:"object",properties:{selectionAttributes:{$ref:"standards#/definitions/selectionAttributes"},baseUnitPrice:{$ref:"standards#/definitions/price"},tiers:{type:"array",items:{$ref:"TieredPrices#/definitions/tier"}}},required:["selectionAttributes","baseUnitPrice"]}}},required:["type","taxCategory","currency"]},tieredPrice:{anyOf:[{$ref:"TieredPrices#/definitions/volumeTieredPrice"},{$ref:"TieredPrices#/definitions/selectionTieredPrice"}]}}};var T={getStandardSchemaDefinition(){return m},getTieredPriceSchemaDefinition(){return g}},b=T;var d=class{cache=new Map;maxSize;ttl;cleanupInterval;constructor(e=1e3,t=5*60*1e3){if(!Number.isFinite(e)||e<1)throw new RangeError("maxSize must be a finite number greater than or equal to 1.");if(!Number.isFinite(t)||t<1)throw new RangeError("ttl must be a finite number greater than or equal to 1.");this.maxSize=e,this.ttl=t,this.cleanupInterval=setInterval(()=>this.cleanup(),60*1e3),this.cleanupInterval.unref&&this.cleanupInterval.unref();}cleanup(){let e=Date.now();for(let[t,r]of this.cache.entries())e>=r.expiry&&this.cache.delete(t);}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r);}this.cache.set(e,{value:t,expiry:Date.now()+this.ttl});}get(e){let t=this.cache.get(e);if(t){if(Date.now()>=t.expiry){this.cache.delete(e);return}return this.cache.delete(e),b$3.logMessage("MemoryCache.get",`Successfully read cache data for key: ${e}`),this.cache.set(e,t),t.value}}dispose(){clearInterval(this.cleanupInterval);}},P=d;
2
2
  export{P as MemoryCache,b as Schema};//# sourceMappingURL=index.mjs.map
3
3
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b23-lib",
3
- "version": "3.9.9",
3
+ "version": "3.10.1",
4
4
  "description": "This repo hold common classes, type and util functiona",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,2 +0,0 @@
1
- import S from'util';var i=Object.freeze({INVALID_UUID:"Invalid UUID",INVALID_EMAIL:"Invalid Email",INVALID_TOKEN:"Invalid Token",TOKEN_EXPIRED:"Token Expired",INVALID_VERIFIER:"Invalid Verifier",INVALID_PERMISSIONS:"Invalid Permissions",INVALID_AUTH_TYPE:"Invalid Authorization Type",USER_PRIVATE_KEY_NOT_FOUND:"User Private Key Not Found",USER_PUBLIC_KEY_NOT_FOUND:"User Public Key Not Found",ANONYMOUS_PRIVATE_KEY_NOT_FOUND:"Anonymous Private Key Not Found",ANONYMOUS_PUBLIC_KEY_NOT_FOUND:"Anonymous Public Key Not Found",SYSTEM_PRIVATE_KEY_NOT_FOUND:"System Private Key Not Found",SYSTEM_PUBLIC_KEY_NOT_FOUND:"System Public Key Not Found",ADMIN_PRIVATE_KEY_NOT_FOUND:"Admin Private Key Not Found",ADMIN_PUBLIC_KEY_NOT_FOUND:"Admin Public Key Not Found",SECRET_TOKEN_NOT_FOUND:"Secret Token Not Found",ANONYMOUS_SESSION_NOT_ALLOWED:"Anonymous Session Not Allowed",USER_SESSION_NOT_ALLOWED:"User Session Not Allowed",SYSTEM_SESSION_NOT_ALLOWED:"System Session Not Allowed",CDN_SESSION_NOT_ALLOWED:"CDN Session Not Allowed",INTERNAL_SERVER_ERROR:"Internal Server Error",SOMETHING_WENT_WRONG:"Something went wrong",AUTH_CONTEXT_NOT_INITIALIZED:"Auth Context not Initialized"});var a={logException:(s,t)=>{console.error(`Exception Occurred in Function: ${s}, Error: ${a.inspect(t)}`);},logError:(s,t)=>{console.error(`Error Occurred in Function: ${s}, Error: ${a.inspect(t)}`);},logWarning:(s,t)=>{console.warn(`Warning in Function: ${s} - ${a.inspect(t)}`);},logMessage:(s,t)=>{console.log(`Message in Function: ${s} - ${a.inspect(t)}`);},logInvalidPayload:(s,t)=>{console.error(`Invalid Payload received for Function: ${s}, Error: ${a.inspect(t)}`);},inspect:s=>typeof s=="string"?s:S.inspect(s)},o=a;var y={handleException:(s,t,r)=>{t.knownError?(t.logError&&o.logError(s,t),r.status(t.status).json({status:t.status,error:t.error})):t.status&&t.error?(o.logException(s,t),r.status(t.status).json({error:t.errorMessage||JSON.stringify(t.error),status:t.status})):(o.logException(s,t),r.status(500).json({status:500,error:i.INTERNAL_SERVER_ERROR}));},generateResponse:(s,t,r)=>({status:s,data:t,error:r}),generateError:(s,t,r=!0,E=!1)=>({status:s,error:t,knownError:r,logError:E})},P=y;var p=async(s,t,r="GET",E={},_)=>{let c={method:r,headers:{"Content-Type":"application/json",...E}};r!=="GET"&&_&&(c.body=JSON.stringify(_));let n=`${s}${t?"/"+t:""}`,O=n.includes("api.xetile.com")||n.includes("localhost");try{let e=await fetch(n,c);if(!e.ok){let u,N=await e.text();try{u=JSON.parse(N);}catch{u={status:e.status,error:N||e.statusText},o.logWarning("Fetch",`Failed to parse error response body as JSON for URL-${n}. Raw text: ${N}`);}throw {status:e.status,statusText:e.statusText,error:u}}let I=await e.json();return o.logMessage("Fetch",`API call successful: URL-${n}, Status- ${e.status}`),{status:e.status,statusText:e.statusText,data:O?I.data:I}}catch(e){throw o.logError("Fetch",`API call failed: URL-${n}, Status- ${e.status||500}, Error- ${o.inspect(e.error||e)}`),{status:e.status||500,statusText:e.statusText||i.INTERNAL_SERVER_ERROR,error:e.error||{status:e.status||500,error:e.statusText||i.SOMETHING_WENT_WRONG}}}},$=p;export{i as a,o as b,P as c,$ as d};//# sourceMappingURL=chunk-AMIRIUMH.mjs.map
2
- //# sourceMappingURL=chunk-AMIRIUMH.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/enums/ErrorTypes.ts","../src/Logger/index.ts","../src/Utils/response.ts","../src/Utils/fetch.ts"],"names":["ErrorTypes_default","Logger","functionName","error","message","errorMessage","context","util","Logger_default","ResponseUtility","res","status","data","knownError","logError","response_default","Fetch","baseURL","endpoint","method","headers","payload","options","completeURL","isInternalAPI","response","errorBody","errorText","body","err","fetch_default"],"mappings":"oBAAOA,IAAAA,CAAAA,CAAQ,MAAO,CAAA,MAAA,CAAO,CACzB,YAAA,CAAc,eACd,aAAe,CAAA,eAAA,CACf,aAAe,CAAA,eAAA,CACf,aAAe,CAAA,eAAA,CACf,iBAAkB,kBAClB,CAAA,mBAAA,CAAqB,qBACrB,CAAA,iBAAA,CAAmB,4BACnB,CAAA,0BAAA,CAA4B,4BAC5B,CAAA,yBAAA,CAA2B,2BAC3B,CAAA,+BAAA,CAAiC,iCACjC,CAAA,8BAAA,CAAgC,gCAChC,CAAA,4BAAA,CAA8B,+BAC9B,2BAA6B,CAAA,6BAAA,CAC7B,2BAA6B,CAAA,6BAAA,CAC7B,0BAA4B,CAAA,4BAAA,CAC5B,uBAAwB,wBACxB,CAAA,6BAAA,CAA+B,+BAC/B,CAAA,wBAAA,CAA0B,0BAC1B,CAAA,0BAAA,CAA4B,6BAC5B,uBAAyB,CAAA,yBAAA,CACzB,qBAAuB,CAAA,uBAAA,CACvB,oBAAsB,CAAA,sBAAA,CACtB,4BAA8B,CAAA,8BAClC,CAAC,ECvBD,IAAMC,EAAS,CACb,YAAA,CAAc,CAACC,CAAAA,CAAsBC,CAAe,GAAA,CAClD,QAAQ,KAAM,CAAA,CAAA,gCAAA,EAAmCD,CAAY,CAAA,SAAA,EAAYD,CAAO,CAAA,OAAA,CAAQE,CAAK,CAAC,CAAA,CAAE,EAClG,CAAA,CAEA,QAAU,CAAA,CAACD,CAAsBC,CAAAA,CAAAA,GAAe,CAC9C,OAAA,CAAQ,KAAM,CAAA,CAAA,4BAAA,EAA+BD,CAAY,CAAA,SA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aM,UAAAA,EAAAA,CAAAA,CAAI,MAAU,EAAA,GAAG,CAAYrB,SAAAA,EAAAA,CAAAA,CAAO,OAAQqB,CAAAA,CAAAA,CAAI,KAASA,EAAAA,CAAG,CAAC,CAAA,CAAE,EAClI,CACJ,MAAA,CAAQA,CAAI,CAAA,MAAA,EAAU,GACtB,CAAA,UAAA,CAAYA,CAAI,CAAA,UAAA,EAAc7B,CAAW,CAAA,qBAAA,CACzC,KAAO6B,CAAAA,CAAAA,CAAI,KAAS,EAAA,CAClB,OAAQA,CAAI,CAAA,MAAA,EAAU,GACtB,CAAA,KAAA,CAAOA,CAAI,CAAA,UAAA,EAAc7B,CAAW,CAAA,oBACtC,CACF,CACF,CACF,CAAA,CAEO8B,CAAQd,CAAAA","file":"chunk-AMIRIUMH.mjs","sourcesContent":["export default Object.freeze({\r\n INVALID_UUID: \"Invalid UUID\",\r\n INVALID_EMAIL: \"Invalid Email\",\r\n INVALID_TOKEN: \"Invalid Token\",\r\n TOKEN_EXPIRED: \"Token Expired\",\r\n INVALID_VERIFIER: \"Invalid Verifier\",\r\n INVALID_PERMISSIONS: \"Invalid Permissions\",\r\n INVALID_AUTH_TYPE: \"Invalid Authorization Type\",\r\n USER_PRIVATE_KEY_NOT_FOUND: \"User Private Key Not Found\",\r\n USER_PUBLIC_KEY_NOT_FOUND: \"User Public Key Not Found\",\r\n ANONYMOUS_PRIVATE_KEY_NOT_FOUND: \"Anonymous Private Key Not Found\",\r\n ANONYMOUS_PUBLIC_KEY_NOT_FOUND: \"Anonymous Public Key Not Found\",\r\n SYSTEM_PRIVATE_KEY_NOT_FOUND: \"System Private Key Not Found\",\r\n SYSTEM_PUBLIC_KEY_NOT_FOUND: \"System Public Key Not Found\",\r\n ADMIN_PRIVATE_KEY_NOT_FOUND: \"Admin Private Key Not Found\",\r\n ADMIN_PUBLIC_KEY_NOT_FOUND: \"Admin Public Key Not Found\",\r\n SECRET_TOKEN_NOT_FOUND: \"Secret Token Not Found\",\r\n ANONYMOUS_SESSION_NOT_ALLOWED: \"Anonymous Session Not Allowed\",\r\n USER_SESSION_NOT_ALLOWED: \"User Session Not Allowed\",\r\n SYSTEM_SESSION_NOT_ALLOWED: \"System Session Not Allowed\",\r\n CDN_SESSION_NOT_ALLOWED: \"CDN Session Not Allowed\",\r\n INTERNAL_SERVER_ERROR: \"Internal Server Error\",\r\n SOMETHING_WENT_WRONG: 'Something went wrong',\r\n AUTH_CONTEXT_NOT_INITIALIZED: 'Auth Context not Initialized'\r\n})","import util from 'util';\r\nconst Logger = {\r\n logException: (functionName: string, error: any) => {\r\n console.error(`Exception Occurred in Function: ${functionName}, Error: ${Logger.inspect(error)}`);\r\n },\r\n\r\n logError: (functionName: string, error: any) => {\r\n console.error(`Error Occurred in Function: ${functionName}, Error: ${Logger.inspect(error)}`);\r\n },\r\n\r\n logWarning: (functionName: string, message: any) => {\r\n console.warn(`Warning in Function: ${functionName} - ${Logger.inspect(message)}`);\r\n },\r\n\r\n logMessage: (functionName: string, message: any) => {\r\n console.log(`Message in Function: ${functionName} - ${Logger.inspect(message)}`);\r\n },\r\n\r\n logInvalidPayload: (functionName: string, errorMessage: string) => {\r\n console.error(`Invalid Payload received for Function: ${functionName}, Error: ${Logger.inspect(errorMessage)}`);\r\n },\r\n\r\n inspect: (context: any) => {\r\n return (typeof context === \"string\" ? context : util.inspect(context));\r\n }\r\n}\r\n\r\nexport default Logger;","import ErrorTypes from \"../enums/ErrorTypes\";\r\nimport Logger from \"../Logger\";\r\n\r\nexport const ResponseUtility = {\r\n handleException: (functionName: string, error: any, res: any) => {\r\n if (error.knownError) {\r\n error.logError && Logger.logError(functionName, error);\r\n res.status(error.status).json({\r\n status: error.status,\r\n error: error.error\r\n });\r\n } else if(error.status && error.error) {\r\n Logger.logException(functionName, error);\r\n res.status(error.status).json({\r\n error: error.errorMessage || JSON.stringify(error.error),\r\n status: error.status,\r\n });\r\n } else {\r\n Logger.logException(functionName, error);\r\n res.status(500).json({\r\n status: 500,\r\n error: ErrorTypes.INTERNAL_SERVER_ERROR\r\n })\r\n }\r\n },\r\n\r\n generateResponse: (status: number, data?: any, error?: string) => {\r\n return {\r\n status,\r\n data,\r\n error\r\n }\r\n },\r\n\r\n generateError: (status: number, error: string, knownError: Boolean = true, logError: boolean = false) => {\r\n return {\r\n status,\r\n error,\r\n knownError,\r\n logError\r\n }\r\n }\r\n}\r\n\r\nexport default ResponseUtility;","\"use client\";\r\n\r\nimport ErrorTypes from \"../enums/ErrorTypes\";\r\nimport Logger from \"../Logger\";\r\n\r\nexport type ErrorType = {\r\n status: number;\r\n statusText: string;\r\n error: any;\r\n};\r\n\r\nexport type SuccessType = {\r\n status: number;\r\n statusText: string;\r\n data: any;\r\n};\r\n\r\n/**\r\n * Makes an HTTP request to the specified endpoint using the provided parameters.\r\n *\r\n * @param {string} baseURL - The base URL of the API.\r\n * @param {string} endpoint - The specific endpoint to call.\r\n * @param {'GET' | 'POST' | 'PATCH' | 'DELETE'} [method='GET'] - The HTTP method to use for the request.\r\n * @param {Record<string, string>} [headers={}] - Additional headers to include in the request.\r\n * @param {any} [payload] - The payload to send with the request, if applicable.\r\n * @returns {Promise<SuccessType>} - A promise that resolves to the response data if the request is successful.\r\n * @throws {ErrorType} - Throws an error if the request fails.\r\n */\r\nconst Fetch = async (\r\n baseURL: string,\r\n endpoint: string,\r\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE' = 'GET',\r\n headers: Record<string, string> = {},\r\n payload?: any,\r\n): Promise<SuccessType> => {\r\n const options: RequestInit = {\r\n method,\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n ...headers,\r\n },\r\n };\r\n\r\n if (method !== 'GET' && payload) {\r\n options.body = JSON.stringify(payload);\r\n }\r\n\r\n const completeURL = `${baseURL}${endpoint ? ('/' + endpoint) : ''}`;\r\n const isInternalAPI = completeURL.includes('api.xetile.com') || completeURL.includes('localhost');\r\n \r\n try {\r\n const response: any = await fetch(completeURL, options);\r\n\r\n if (!response.ok) {\r\n let errorBody: any;\r\n const errorText = await response.text();\r\n\r\n try {\r\n errorBody = JSON.parse(errorText);\r\n } catch (parseError) {\r\n errorBody = {\r\n status: response.status,\r\n error: errorText || response.statusText\r\n };\r\n Logger.logWarning('Fetch', `Failed to parse error response body as JSON for URL-${completeURL}. Raw text: ${errorText}`);\r\n }\r\n\r\n throw {\r\n status: response.status,\r\n statusText: response.statusText,\r\n error: errorBody\r\n } as ErrorType;\r\n }\r\n\r\n const body = await response.json();\r\n\r\n Logger.logMessage('Fetch', `API call successful: URL-${completeURL}, Status- ${response.status}`);\r\n return {\r\n status: response.status,\r\n statusText: response.statusText,\r\n data: isInternalAPI ? body.data : body,\r\n } as SuccessType;\r\n } catch (err: any) {\r\n \r\n Logger.logError('Fetch', `API call failed: URL-${completeURL}, Status- ${err.status || 500}, Error- ${Logger.inspect(err.error || err)}`);\r\n throw {\r\n status: err.status || 500,\r\n statusText: err.statusText || ErrorTypes.INTERNAL_SERVER_ERROR,\r\n error: err.error || {\r\n status: err.status || 500,\r\n error: err.statusText || ErrorTypes.SOMETHING_WENT_WRONG,\r\n }\r\n } as ErrorType;\r\n }\r\n};\r\n\r\nexport default Fetch;\r\n"]}