@harnessio/ff-nodejs-server-sdk
Advanced tools
Comparing version 1.3.7 to 1.4.0
@@ -1,5 +0,5 @@ | ||
"use strict";var Ht=Object.create;var ie=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Q=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Ne=(s,e)=>{for(var t in e)ie(s,t,{get:e[t],enumerable:!0})},Ue=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Yt(e))!Jt.call(s,r)&&r!==t&&ie(s,r,{get:()=>e[r],enumerable:!(i=Wt(e,r))||i.enumerable});return s};var P=(s,e,t)=>(t=s!=null?Ht(Qt(s)):{},Ue(e||!s||!s.__esModule?ie(t,"default",{value:s,enumerable:!0}):t,s)),Xt=s=>Ue(ie({},"__esModule",{value:!0}),s);var qe=Q((_i,ze)=>{"use strict";function ve(s){this.message=s}ve.prototype=new Error,ve.prototype.name="InvalidCharacterError";var Ve=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(s){var e=String(s).replace(/=+$/,"");if(e.length%4==1)throw new ve("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,i,r=0,n=0,o="";i=e.charAt(n++);~i&&(t=r%4?64*t+i:i,r++%4)?o+=String.fromCharCode(255&t>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function Zt(s){var e=s.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ve(t).replace(/(.)/g,function(i,r){var n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}(e)}catch{return Ve(e)}}function J(s){this.message=s}function Be(s,e){if(typeof s!="string")throw new J("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(Zt(s.split(".")[t]))}catch(i){throw new J("Invalid token specified: "+i.message)}}J.prototype=new Error,J.prototype.name="InvalidTokenError";var me=Be;me.default=Be,me.InvalidTokenError=J,ze.exports=me});var Ge=Q((Ci,Ke)=>{"use strict";var ei=["ETIMEDOUT","ECONNRESET","EADDRINUSE","ESOCKETTIMEDOUT","ECONNREFUSED","EPIPE","EHOSTUNREACH","EAI_AGAIN"],ti=["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED"];Ke.exports=function(s){return!s||!s.code||ei.indexOf(s.code)!==-1?!0:ti.indexOf(s.code)===-1}});var Ye=Q(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});var ii=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s};L.isNetworkError=Ee;L.isRetryableError=re;L.isSafeRequestError=He;L.isIdempotentRequestError=Se;L.isNetworkOrIdempotentRequestError=Te;L.exponentialDelay=We;L.default=q;var ri=Ge(),si=ni(ri);function ni(s){return s&&s.__esModule?s:{default:s}}var ye="axios-retry";function Ee(s){return!s.response&&!!s.code&&s.code!=="ECONNABORTED"&&(0,si.default)(s)}var $e=["get","head","options"],oi=$e.concat(["put","delete"]);function re(s){return s.code!=="ECONNABORTED"&&(!s.response||s.response.status>=500&&s.response.status<=599)}function He(s){return s.config?re(s)&&$e.indexOf(s.config.method)!==-1:!1}function Se(s){return s.config?re(s)&&oi.indexOf(s.config.method)!==-1:!1}function Te(s){return Ee(s)||Se(s)}function ai(){return 0}function We(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=Math.pow(2,s)*100,t=e*.2*Math.random();return e+t}function je(s){var e=s[ye]||{};return e.retryCount=e.retryCount||0,s[ye]=e,e}function li(s,e){return Object.assign({},e,s[ye])}function ci(s,e){s.defaults.agent===e.agent&&delete e.agent,s.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,s.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}async function hi(s,e,t,i){var r=t.retryCount<s&&e(i);if((typeof r>"u"?"undefined":ii(r))==="object")try{return await r,!0}catch{return!1}return r}function q(s,e){s.interceptors.request.use(function(t){var i=je(t);return i.lastRequestTime=Date.now(),t}),s.interceptors.response.use(null,async function(t){var i=t.config;if(!i)return Promise.reject(t);var r=li(i,e),n=r.retries,o=n===void 0?3:n,l=r.retryCondition,h=l===void 0?Te:l,c=r.retryDelay,a=c===void 0?ai:c,f=r.shouldResetTimeout,g=f===void 0?!1:f,p=je(i);if(await hi(o,h,p,t)){p.retryCount+=1;var v=a(p.retryCount,t);if(ci(s,i),!g&&i.timeout&&p.lastRequestTime){var T=Date.now()-p.lastRequestTime;i.timeout=Math.max(i.timeout-T-v,1)}return i.transformRequest=[function(u){return u}],new Promise(function(u){return setTimeout(function(){return u(s(i))},v)})}return Promise.reject(t)})}q.isNetworkError=Ee;q.isSafeRequestError=He;q.isIdempotentRequestError=Se;q.isNetworkOrIdempotentRequestError=Te;q.exponentialDelay=We;q.isRetryableError=re});var Je=Q((Oi,Qe)=>{"use strict";Qe.exports=Ye().default});var zt=Q((Er,Fe)=>{"use strict";(function(){var s=this;let e=o=>new TextEncoder().encode(o);function t(o,l){typeof o=="string"&&(o=e(o));for(var h=o.length,c=l^h,a=0,f;h>=4;)f=o[a]&255|(o[++a]&255)<<8|(o[++a]&255)<<16|(o[++a]&255)<<24,f=(f&65535)*1540483477+(((f>>>16)*1540483477&65535)<<16),f^=f>>>24,f=(f&65535)*1540483477+(((f>>>16)*1540483477&65535)<<16),c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16)^f,h-=4,++a;switch(h){case 3:c^=(o[a+2]&255)<<16;case 2:c^=(o[a+1]&255)<<8;case 1:c^=o[a]&255,c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16)}return c^=c>>>13,c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16),c^=c>>>15,c>>>0}function i(o,l){typeof o=="string"&&(o=e(o));var h,c,a,f,g,p,v,T,u,d;for(h=o.length&3,c=o.length-h,a=l,g=3432918353,v=461845907,d=0;d<c;)u=o[d]&255|(o[++d]&255)<<8|(o[++d]&255)<<16|(o[++d]&255)<<24,++d,u=(u&65535)*g+(((u>>>16)*g&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*v+(((u>>>16)*v&65535)<<16)&4294967295,a^=u,a=a<<13|a>>>19,f=(a&65535)*5+(((a>>>16)*5&65535)<<16)&4294967295,a=(f&65535)+27492+(((f>>>16)+58964&65535)<<16);switch(u=0,h){case 3:u^=(o[d+2]&255)<<16;case 2:u^=(o[d+1]&255)<<8;case 1:u^=o[d]&255,u=(u&65535)*g+(((u>>>16)*g&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*v+(((u>>>16)*v&65535)<<16)&4294967295,a^=u}return a^=o.length,a^=a>>>16,a=(a&65535)*2246822507+(((a>>>16)*2246822507&65535)<<16)&4294967295,a^=a>>>13,a=(a&65535)*3266489909+(((a>>>16)*3266489909&65535)<<16)&4294967295,a^=a>>>16,a>>>0}var r=i;if(r.v2=t,r.v3=i,typeof Fe<"u")Fe.exports=r;else{var n=s.murmur;r.noConflict=function(){return s.murmur=n,r},s.murmur=r}})()});var xi={};Ne(xi,{Client:()=>W,Event:()=>pe,FileStore:()=>H,LRU:()=>Oe,default:()=>wi});module.exports=Xt(xi);var Gt=P(require("events")),jt=P(qe()),ke=P(require("axios")),Le=P(Je());var F=P(require("axios"));var Xe=P(require("axios")),x="http://localhost/api/1.0".replace(/\/+$/,"");var X=class{constructor(e,t=x,i=Xe.default){this.basePath=t;this.axios=i;e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}},se=class extends Error{constructor(t,i){super(i);this.field=t;this.name="RequiredError"}};var _="https://example.com",R=function(s,e,t){if(t==null)throw new se(e,`Required parameter ${e} was null or undefined when calling ${s}.`)};var k=async function(s,e){if(e&&e.accessToken){let t=typeof e.accessToken=="function"?await e.accessToken():await e.accessToken;s.Authorization="Bearer "+t}};var C=function(s,...e){let t=new URLSearchParams(s.search);for(let i of e)for(let r in i)if(Array.isArray(i[r])){t.delete(r);for(let n of i[r])t.append(r,n)}else t.set(r,i[r]);s.search=t.toString()},Ae=function(s,e,t){let i=typeof s!="string";return(i&&t&&t.isJsonMime?t.isJsonMime(e.headers["Content-Type"]):i)?JSON.stringify(s!==void 0?s:{}):s||""},I=function(s){return s.pathname+s.search+s.hash},O=function(s,e,t,i){return(r=e,n=t)=>{let o={...s.options,url:((i==null?void 0:i.basePath)||n)+s.url};return r.request(o)}};var ui=function(s){return{authenticate:async(e,t={})=>{let i="/client/auth",r=new URL(i,_),n;s&&(n=s.baseOptions);let o={method:"POST",...n,...t},l={},h={};l["Content-Type"]="application/json",C(r,h,t.query);let c=n&&n.headers?n.headers:{};return o.headers={...l,...c,...t.headers},o.data=Ae(e,o,s),{url:I(r),options:o}},getAllSegments:async(e,t,i={})=>{R("getAllSegments","environmentUUID",e);let r="/client/env/{environmentUUID}/target-segments".replace("{environmentUUID}",encodeURIComponent(String(e))),n=new URL(r,_),o;s&&(o=s.baseOptions);let l={method:"GET",...o,...i},h={},c={};await k(h,s),t!==void 0&&(c.cluster=t),C(n,c,i.query);let a=o&&o.headers?o.headers:{};return l.headers={...h,...a,...i.headers},{url:I(n),options:l}},getEvaluationByIdentifier:async(e,t,i,r,n={})=>{R("getEvaluationByIdentifier","environmentUUID",e),R("getEvaluationByIdentifier","feature",t),R("getEvaluationByIdentifier","target",i);let o="/client/env/{environmentUUID}/target/{target}/evaluations/{feature}".replace("{environmentUUID}",encodeURIComponent(String(e))).replace("{feature}",encodeURIComponent(String(t))).replace("{target}",encodeURIComponent(String(i))),l=new URL(o,_),h;s&&(h=s.baseOptions);let c={method:"GET",...h,...n},a={},f={};await k(a,s),r!==void 0&&(f.cluster=r),C(l,f,n.query);let g=h&&h.headers?h.headers:{};return c.headers={...a,...g,...n.headers},{url:I(l),options:c}},getEvaluations:async(e,t,i,r={})=>{R("getEvaluations","environmentUUID",e),R("getEvaluations","target",t);let n="/client/env/{environmentUUID}/target/{target}/evaluations".replace("{environmentUUID}",encodeURIComponent(String(e))).replace("{target}",encodeURIComponent(String(t))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"GET",...l,...r},c={},a={};await k(c,s),i!==void 0&&(a.cluster=i),C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},{url:I(o),options:h}},getFeatureConfig:async(e,t,i={})=>{R("getFeatureConfig","environmentUUID",e);let r="/client/env/{environmentUUID}/feature-configs".replace("{environmentUUID}",encodeURIComponent(String(e))),n=new URL(r,_),o;s&&(o=s.baseOptions);let l={method:"GET",...o,...i},h={},c={};await k(h,s),t!==void 0&&(c.cluster=t),C(n,c,i.query);let a=o&&o.headers?o.headers:{};return l.headers={...h,...a,...i.headers},{url:I(n),options:l}},getFeatureConfigByIdentifier:async(e,t,i,r={})=>{R("getFeatureConfigByIdentifier","identifier",e),R("getFeatureConfigByIdentifier","environmentUUID",t);let n="/client/env/{environmentUUID}/feature-configs/{identifier}".replace("{identifier}",encodeURIComponent(String(e))).replace("{environmentUUID}",encodeURIComponent(String(t))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"GET",...l,...r},c={},a={};await k(c,s),i!==void 0&&(a.cluster=i),C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},{url:I(o),options:h}},getSegmentByIdentifier:async(e,t,i,r={})=>{R("getSegmentByIdentifier","identifier",e),R("getSegmentByIdentifier","environmentUUID",t);let n="/client/env/{environmentUUID}/target-segments/{identifier}".replace("{identifier}",encodeURIComponent(String(e))).replace("{environmentUUID}",encodeURIComponent(String(t))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"GET",...l,...r},c={},a={};await k(c,s),i!==void 0&&(a.cluster=i),C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},{url:I(o),options:h}},stream:async(e,t,i={})=>{R("stream","aPIKey",e);let r="/stream",n=new URL(r,_),o;s&&(o=s.baseOptions);let l={method:"GET",...o,...i},h={},c={};await k(h,s),t!==void 0&&(c.cluster=t),e!=null&&(h["API-Key"]=String(e)),C(n,c,i.query);let a=o&&o.headers?o.headers:{};return l.headers={...h,...a,...i.headers},{url:I(n),options:l}}}},N=function(s){let e=ui(s);return{async authenticate(t,i){let r=await e.authenticate(t,i);return O(r,F.default,x,s)},async getAllSegments(t,i,r){let n=await e.getAllSegments(t,i,r);return O(n,F.default,x,s)},async getEvaluationByIdentifier(t,i,r,n,o){let l=await e.getEvaluationByIdentifier(t,i,r,n,o);return O(l,F.default,x,s)},async getEvaluations(t,i,r,n){let o=await e.getEvaluations(t,i,r,n);return O(o,F.default,x,s)},async getFeatureConfig(t,i,r){let n=await e.getFeatureConfig(t,i,r);return O(n,F.default,x,s)},async getFeatureConfigByIdentifier(t,i,r,n){let o=await e.getFeatureConfigByIdentifier(t,i,r,n);return O(o,F.default,x,s)},async getSegmentByIdentifier(t,i,r,n){let o=await e.getSegmentByIdentifier(t,i,r,n);return O(o,F.default,x,s)},async stream(t,i,r){let n=await e.stream(t,i,r);return O(n,F.default,x,s)}}};var ne=class extends X{authenticate(e,t){return N(this.configuration).authenticate(e,t).then(i=>i(this.axios,this.basePath))}getAllSegments(e,t,i){return N(this.configuration).getAllSegments(e,t,i).then(r=>r(this.axios,this.basePath))}getEvaluationByIdentifier(e,t,i,r,n){return N(this.configuration).getEvaluationByIdentifier(e,t,i,r,n).then(o=>o(this.axios,this.basePath))}getEvaluations(e,t,i,r){return N(this.configuration).getEvaluations(e,t,i,r).then(n=>n(this.axios,this.basePath))}getFeatureConfig(e,t,i){return N(this.configuration).getFeatureConfig(e,t,i).then(r=>r(this.axios,this.basePath))}getFeatureConfigByIdentifier(e,t,i,r){return N(this.configuration).getFeatureConfigByIdentifier(e,t,i,r).then(n=>n(this.axios,this.basePath))}getSegmentByIdentifier(e,t,i,r){return N(this.configuration).getSegmentByIdentifier(e,t,i,r).then(n=>n(this.axios,this.basePath))}stream(e,t,i){return N(this.configuration).stream(e,t,i).then(r=>r(this.axios,this.basePath))}},fi=function(s){return{postMetrics:async(e,t,i,r={})=>{R("postMetrics","environment",e);let n="/metrics/{environment}".replace("{environment}",encodeURIComponent(String(e))),o=new URL(n,_),l;s&&(l=s.baseOptions);let h={method:"POST",...l,...r},c={},a={};await k(c,s),t!==void 0&&(a.cluster=t),c["Content-Type"]="application/json",C(o,a,r.query);let f=l&&l.headers?l.headers:{};return h.headers={...c,...f,...r.headers},h.data=Ae(i,h,s),{url:I(o),options:h}}}},gi=function(s){let e=fi(s);return{async postMetrics(t,i,r,n){let o=await e.postMetrics(t,i,r,n);return O(o,F.default,x,s)}}};var oe=class extends X{postMetrics(e,t,i,r){return gi(this.configuration).postMetrics(e,t,i,r).then(n=>n(this.axios,this.basePath))}};var G=class{constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){let t=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return e!==null&&(t.test(e)||e.toLowerCase()==="application/json-patch+json")}};var ae="1.3.7";var Ze={1e3:"The SDK has successfully initialized",1001:"The SDK has failed to initialize due to an authentication error - defaults will be served",1002:"The SDK has failed to initialize due to a missing or empty API key - defaults will be served",2e3:"Authentication was successful",2001:"Authentication failed with a non-recoverable error",2002:"Authentication attempt failed:",2003:"Authentication failed and max retries have been exceeded",3e3:"Closing SDK",3001:"SDK Closed successfully",4e3:"Polling started, interval:",4001:"Polling stopped",5e3:"SSE stream successfully connected",5001:"SSE stream disconnected, reason:",5002:"SSE event received",5003:"SSE retrying to connect in",5004:"SSE stopped",6e3:"Evaluation successful: ",6001:"Evaluation Failed, returning default variation: ",7e3:"Metrics thread started with request interval:",7001:"Metrics stopped",7002:"Posting metrics failed, reason:",7003:"Metrics posted successfully"};function di(s){return s in Ze?Ze[s]:"Unknown SDK code"}function S(s,e=""){return`SDKCODE:${s}: ${di(s)} ${e}`}function et(s){s.warn(S(1002))}function tt(s,e){e.info(S(4e3,s/1e3+" seconds"))}function be(s){s.info(S(1e3))}function it(s){s.info(S(3e3))}function rt(s){s.info(S(3001))}function Re(s){s.info(S(4001))}function st(s){s.info(S(5e3))}function nt(s){s.debug(S(5002))}function ot(s){s.info(S(5004))}function at(s,e){e.info(S(7e3,s/1e3+" seconds"))}function lt(s){s.info(S(7003))}function ct(s){s.info(S(7001))}function Z(s,e,t,i){i.debug(S(6e3,`result=${s}, flag identifier=${e}, target=${JSON.stringify(t)}`))}function ht(s){s.warn(S(2001))}function ut(s){s.warn(S(1001))}function ft(s,e){e.warn(S(5001,s))}function gt(s,e){e.warn(S(5003,`${s}`))}function dt(s,e){e.warn(S(7002,s))}function D(s,e,t,i){i.warn(S(6001,`default variation used=${t}, flag=${s}, target=${JSON.stringify(e)}`))}var le=class{constructor(e,t,i,r,n,o){this.stopped=!0;this.initialized=!1;this.lastPollTime=0;this.api=i,this.options=r,this.environment=e,this.cluster=t,this.repository=o,this.eventBus=n,this.log=r.logger}poll(){if(this.stopped){this.log.info("PollingProcessor stopped"),Re(this.log);return}let e=new Date().getTime(),t=()=>{let i=new Date().getTime()-e,r=Math.max(this.options.pollInterval-i,0);this.timeout=setTimeout(()=>this.poll(),r)};if(this.lastPollTime>Date.now()-this.options.pollInterval){this.log.info(`Last poll was ${Math.round((Date.now()-this.lastPollTime)/1e3)} seconds ago, skipping flag refresh`),t();return}this.lastPollTime=Date.now(),Promise.all([this.retrieveFlags(),this.retrieveSegments()]).then(()=>{this.initialized||setTimeout(()=>{this.initialized=!0,this.eventBus.emit("poller_ready")},0)}).catch(i=>{this.eventBus.emit("poller_error",{error:i})}).finally(()=>{if(this.stopped){this.log.info("PollingProcessor stopped"),Re(this.log);return}t()})}async retrieveFlags(){try{this.log.debug("Fetching flags started");let e=await this.api.getFeatureConfig(this.environment,this.cluster);this.log.debug("Fetching flags finished"),e.data.forEach(t=>this.repository.setFlag(t.feature,t))}catch(e){throw this.log.error("Error loading flags",e),e}}async retrieveSegments(){try{this.log.debug("Fetching segments started");let e=await this.api.getAllSegments(this.environment,this.cluster);this.log.debug("Fetching segments finished"),e.data.forEach(t=>this.repository.setSegment(t.identifier,t))}catch(e){throw this.log.error("Error loading segments",e),e}}start(){if(!this.stopped){this.log.info("PollingProcessor already started");return}this.log.info("Starting PollingProcessor with request interval: ",this.options.pollInterval),this.stopped=!1,this.poll()}stop(){this.log.info("Stopping PollingProcessor"),this.stopped=!0}close(){this.log.info("Closing PollingProcessor"),this.stop(),clearTimeout(this.timeout),this.log.info("PollingProcessor closed")}};var pt=P(require("https")),mt=P(require("http"));var b=class b{constructor(e,t,i,r,n,o,l,h){this.retryAttempt=0;this.api=e,this.apiKey=t,this.environment=i,this.jwtToken=r,this.options=n,this.cluster=o,this.eventBus=l,this.repository=h,this.log=this.options.logger;let c=5e3,a=1e4;this.retryDelayMs=Math.floor(Math.random()*(a-c)+c)}start(){this.log.info("Starting new StreamProcessor");let e=`${this.options.baseUrl}/stream?cluster=${this.cluster}`,t={headers:{"Cache-Control":"no-cache",Accept:"text/event-stream",Authorization:`Bearer ${this.jwtToken}`,"API-Key":this.apiKey}},i=()=>{this.log.info(`SSE stream connected OK: ${e}`),this.retryAttempt=0,this.readyState=b.CONNECTED,this.eventBus.emit("stream_connected")},r=n=>{if(this.readyState!==b.CLOSED){this.retryAttempt+=1;let o=this.getRandomRetryDelayMs();ft(n,this.log),gt(o,this.log),this.readyState=b.RETRYING,this.eventBus.emit("stream_retrying"),setTimeout(()=>{this.log.info("SSE retrying to connect"),this.connect(e,t,i,r)},o)}};this.connect(e,t,i,r),this.eventBus.emit("stream_ready")}getRandomRetryDelayMs(){let e=this.retryDelayMs*this.retryAttempt;return Math.min(e,6e4)}connect(e,t,i,r){if(this.readyState===b.CONNECTED){this.log.debug("SSE already connected, skip retry");return}let n=e.startsWith("https:");this.log.debug("SSE HTTP start request",e),this.request=(n?pt.default:mt.default).request(e,t,o=>{if(this.log.debug("SSE got HTTP response code",o.statusCode),o.statusCode>=400&&o.statusCode<=599){r(`HTTP code ${o.statusCode}`);return}i(),o.on("data",l=>{nt(this.log),this.processData(l)}).on("close",()=>{r("SSE stream closed")})}).on("error",o=>{r("SSE request failed "+o.message)}).on("timeout",()=>{r("SSE request timed out after "+b.SSE_TIMEOUT_MS+"ms")}).setTimeout(b.SSE_TIMEOUT_MS),this.request.end()}processData(e){e.toString().split(/\r?\n/).forEach(i=>this.processLine(i))}processLine(e){if(e.startsWith("data:")){this.log.debug("SSE GOT:",e.substring(5));let t=JSON.parse(e.substring(5));t.domain==="flag"?this.msgProcessor(t,this.api.getFeatureConfigByIdentifier.bind(this.api),this.repository.setFlag.bind(this.repository),this.repository.deleteFlag.bind(this.repository)):t.domain==="target-segment"&&this.msgProcessor(t,this.api.getSegmentByIdentifier.bind(this.api),this.repository.setSegment.bind(this.repository),this.repository.deleteSegment.bind(this.repository))}}async msgProcessor(e,t,i,r){this.log.info("Processing message",e);try{if(e.event==="create"||e.event==="patch"){let{data:n}=await t(e.identifier,this.environment,this.cluster);i(e.identifier,n)}else e.event==="delete"&&r(e.identifier)}catch(n){throw this.log.error("Error while fetching data with identifier:",e.identifier,n),n}this.log.info("Processing message finished",e)}connected(){return this.readyState===b.CONNECTED}close(){if(this.readyState===b.CLOSED){this.log.info("SteamProcessor already closed");return}this.readyState=b.CLOSED,this.log.info("Closing StreamProcessor"),this.request.destroy(),this.request=void 0,this.eventBus.emit("stream_disconnected"),this.log.info("StreamProcessor closed"),ot(this.log)}};b.CONNECTED=1,b.RETRYING=2,b.CLOSED=3,b.SSE_TIMEOUT_MS=3e4;var ce=b;var Oe={};Ne(Oe,{default:()=>Ie});var ee=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,mi=typeof AbortController=="function",he=mi?AbortController:class{constructor(){this.signal=new vt}abort(e=new Error("This operation was aborted")){this.signal.reason=this.signal.reason||e,this.signal.aborted=!0,this.signal.dispatchEvent({type:"abort",target:this.signal})}},vi=typeof AbortSignal=="function",yi=typeof he.AbortSignal=="function",vt=vi?AbortSignal:yi?he.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,this.onabort(e),this._listeners.forEach(t=>t(e),this))}onabort(){}addEventListener(e,t){e==="abort"&&this._listeners.push(t)}removeEventListener(e,t){e==="abort"&&(this._listeners=this._listeners.filter(i=>i!==t))}},_e=new Set,we=(s,e)=>{let t=`LRU_CACHE_OPTION_${s}`;ue(t)&&Ce(t,`${s} option`,`options.${e}`,$)},xe=(s,e)=>{let t=`LRU_CACHE_METHOD_${s}`;if(ue(t)){let{prototype:i}=$,{get:r}=Object.getOwnPropertyDescriptor(i,s);Ce(t,`${s} method`,`cache.${e}()`,r)}},Ei=(s,e)=>{let t=`LRU_CACHE_PROPERTY_${s}`;if(ue(t)){let{prototype:i}=$,{get:r}=Object.getOwnPropertyDescriptor(i,s);Ce(t,`${s} property`,`cache.${e}`,r)}},yt=(...s)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(...s):console.error(...s)},ue=s=>!_e.has(s),Ce=(s,e,t,i)=>{_e.add(s);let r=`The ${e} is deprecated. Please use ${t} instead.`;yt(r,"DeprecationWarning",s,i)},U=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Et=s=>U(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?j:null:null,j=class extends Array{constructor(e){super(e),this.fill(0)}},Pe=class{constructor(e){if(e===0)return[];let t=Et(e);this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},$=class s{constructor(e={}){let{max:t=0,ttl:i,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:h,dispose:c,disposeAfter:a,noDisposeOnSet:f,noUpdateTTL:g,maxSize:p=0,maxEntrySize:v=0,sizeCalculation:T,fetchMethod:u,fetchContext:d,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:w,ignoreFetchAbort:m}=e,{length:B,maxAge:z,stale:M}=e instanceof s?{}:e;if(t!==0&&!U(t))throw new TypeError("max option must be a nonnegative integer");let K=t?Et(t):Array;if(!K)throw new Error("invalid max value: "+t);if(this.max=t,this.maxSize=p,this.maxEntrySize=v||this.maxSize,this.sizeCalculation=T||B,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(this.fetchMethod=u||null,this.fetchMethod&&typeof this.fetchMethod!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.fetchContext=d,!this.fetchMethod&&d!==void 0)throw new TypeError("cannot set fetchContext without fetchMethod");if(this.keyMap=new Map,this.keyList=new Array(t).fill(null),this.valList=new Array(t).fill(null),this.next=new K(t),this.prev=new K(t),this.head=0,this.tail=0,this.free=new Pe(t),this.initialFill=1,this.size=0,typeof c=="function"&&(this.dispose=c),typeof a=="function"?(this.disposeAfter=a,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!f,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!y,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!m,this.maxEntrySize!==0){if(this.maxSize!==0&&!U(this.maxSize))throw new TypeError("maxSize must be a positive integer if specified");if(!U(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.initializeSizeTracking()}if(this.allowStale=!!h||!!M,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=U(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=i||z||0,this.ttl){if(!U(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let Y="LRU_CACHE_UNBOUNDED";ue(Y)&&(_e.add(Y),yt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Y,s))}M&&we("stale","allowStale"),z&&we("maxAge","ttl"),B&&we("length","sizeCalculation")}getRemainingTTL(e){return this.has(e,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new j(this.max),this.starts=new j(this.max),this.setItemTTL=(i,r,n=ee.now())=>{if(this.starts[i]=r!==0?n:0,this.ttls[i]=r,r!==0&&this.ttlAutopurge){let o=setTimeout(()=>{this.isStale(i)&&this.delete(this.keyList[i])},r+1);o.unref&&o.unref()}},this.updateItemAge=i=>{this.starts[i]=this.ttls[i]!==0?ee.now():0},this.statusTTL=(i,r)=>{i&&(i.ttl=this.ttls[r],i.start=this.starts[r],i.now=e||t(),i.remainingTTL=i.now+i.ttl-i.start)};let e=0,t=()=>{let i=ee.now();if(this.ttlResolution>0){e=i;let r=setTimeout(()=>e=0,this.ttlResolution);r.unref&&r.unref()}return i};this.getRemainingTTL=i=>{let r=this.keyMap.get(i);return r===void 0?0:this.ttls[r]===0||this.starts[r]===0?1/0:this.starts[r]+this.ttls[r]-(e||t())},this.isStale=i=>this.ttls[i]!==0&&this.starts[i]!==0&&(e||t())-this.starts[i]>this.ttls[i]}updateItemAge(e){}statusTTL(e,t){}setItemTTL(e,t,i){}isStale(e){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new j(this.max),this.removeItemSize=e=>{this.calculatedSize-=this.sizes[e],this.sizes[e]=0},this.requireSize=(e,t,i,r)=>{if(this.isBackgroundFetch(t))return 0;if(!U(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(t,e),!U(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.addItemSize=(e,t,i)=>{if(this.sizes[e]=t,this.maxSize){let r=this.maxSize-this.sizes[e];for(;this.calculatedSize>r;)this.evict(!0)}this.calculatedSize+=this.sizes[e],i&&(i.entrySize=t,i.totalCalculatedSize=this.calculatedSize)}}removeItemSize(e){}addItemSize(e,t){}requireSize(e,t,i,r){if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache")}*indexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.tail;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.head));)t=this.prev[t]}*rindexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.head;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.tail));)t=this.next[t]}isValidIndex(e){return e!==void 0&&this.keyMap.get(this.keyList[e])===e}*entries(){for(let e of this.indexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*rentries(){for(let e of this.rindexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*keys(){for(let e of this.indexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*rkeys(){for(let e of this.rindexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*values(){for(let e of this.indexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}*rvalues(){for(let e of this.rindexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}[Symbol.iterator](){return this.entries()}find(e,t){for(let i of this.indexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,this.keyList[i],this))return this.get(this.keyList[i],t)}}forEach(e,t=this){for(let i of this.indexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.keyList[i],this)}}rforEach(e,t=this){for(let i of this.rindexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.keyList[i],this)}}get prune(){return xe("prune","purgeStale"),this.purgeStale}purgeStale(){let e=!1;for(let t of this.rindexes({allowStale:!0}))this.isStale(t)&&(this.delete(this.keyList[t]),e=!0);return e}dump(){let e=[];for(let t of this.indexes({allowStale:!0})){let i=this.keyList[t],r=this.valList[t],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(n===void 0)continue;let o={value:n};if(this.ttls){o.ttl=this.ttls[t];let l=ee.now()-this.starts[t];o.start=Math.floor(Date.now()-l)}this.sizes&&(o.size=this.sizes[t]),e.unshift([i,o])}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let r=Date.now()-i.start;i.start=ee.now()-r}this.set(t,i.value,i)}}dispose(e,t,i){}set(e,t,{ttl:i=this.ttl,start:r,noDisposeOnSet:n=this.noDisposeOnSet,size:o=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,status:c}={}){if(o=this.requireSize(e,t,o,l),this.maxEntrySize&&o>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.delete(e),this;let a=this.size===0?void 0:this.keyMap.get(e);if(a===void 0)a=this.newIndex(),this.keyList[a]=e,this.valList[a]=t,this.keyMap.set(e,a),this.next[this.tail]=a,this.prev[a]=this.tail,this.tail=a,this.size++,this.addItemSize(a,o,c),c&&(c.set="add"),h=!1;else{this.moveToTail(a);let f=this.valList[a];if(t!==f){if(this.isBackgroundFetch(f)?f.__abortController.abort(new Error("replaced")):n||(this.dispose(f,e,"set"),this.disposeAfter&&this.disposed.push([f,e,"set"])),this.removeItemSize(a),this.valList[a]=t,this.addItemSize(a,o,c),c){c.set="replace";let g=f&&this.isBackgroundFetch(f)?f.__staleWhileFetching:f;g!==void 0&&(c.oldValue=g)}}else c&&(c.set="update")}if(i!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),h||this.setItemTTL(a,i,r),this.statusTTL(c,a),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length!==0?this.free.pop():this.initialFill++}pop(){if(this.size){let e=this.valList[this.head];return this.evict(!0),e}}evict(e){let t=this.head,i=this.keyList[t],r=this.valList[t];return this.isBackgroundFetch(r)?r.__abortController.abort(new Error("evicted")):(this.dispose(r,i,"evict"),this.disposeAfter&&this.disposed.push([r,i,"evict"])),this.removeItemSize(t),e&&(this.keyList[t]=null,this.valList[t]=null,this.free.push(t)),this.head=this.next[t],this.keyMap.delete(i),this.size--,t}has(e,{updateAgeOnHas:t=this.updateAgeOnHas,status:i}={}){let r=this.keyMap.get(e);if(r!==void 0)if(this.isStale(r))i&&(i.has="stale",this.statusTTL(i,r));else return t&&this.updateItemAge(r),i&&(i.has="hit"),this.statusTTL(i,r),!0;else i&&(i.has="miss");return!1}peek(e,{allowStale:t=this.allowStale}={}){let i=this.keyMap.get(e);if(i!==void 0&&(t||!this.isStale(i))){let r=this.valList[i];return this.isBackgroundFetch(r)?r.__staleWhileFetching:r}}backgroundFetch(e,t,i,r){let n=t===void 0?void 0:this.valList[t];if(this.isBackgroundFetch(n))return n;let o=new he;i.signal&&i.signal.addEventListener("abort",()=>o.abort(i.signal.reason));let l={signal:o.signal,options:i,context:r},h=(p,v=!1)=>{let{aborted:T}=o.signal,u=i.ignoreFetchAbort&&p!==void 0;return i.status&&(T&&!v?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,u&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),T&&!u&&!v?a(o.signal.reason):(this.valList[t]===g&&(p===void 0?g.__staleWhileFetching?this.valList[t]=g.__staleWhileFetching:this.delete(e):(i.status&&(i.status.fetchUpdated=!0),this.set(e,p,l.options))),p)},c=p=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=p),a(p)),a=p=>{let{aborted:v}=o.signal,T=v&&i.allowStaleOnFetchAbort,u=T||i.allowStaleOnFetchRejection,d=u||i.noDeleteOnFetchRejection;if(this.valList[t]===g&&(!d||g.__staleWhileFetching===void 0?this.delete(e):T||(this.valList[t]=g.__staleWhileFetching)),u)return i.status&&g.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),g.__staleWhileFetching;if(g.__returned===g)throw p},f=(p,v)=>{this.fetchMethod(e,n,l).then(T=>p(T),v),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(p(),i.allowStaleOnFetchAbort&&(p=T=>h(T,!0)))})};i.status&&(i.status.fetchDispatched=!0);let g=new Promise(f).then(h,c);return g.__abortController=o,g.__staleWhileFetching=n,g.__returned=null,t===void 0?(this.set(e,g,{...l.options,status:void 0}),t=this.keyMap.get(e)):this.valList[t]=g,g}isBackgroundFetch(e){return e&&typeof e=="object"&&typeof e.then=="function"&&Object.prototype.hasOwnProperty.call(e,"__staleWhileFetching")&&Object.prototype.hasOwnProperty.call(e,"__returned")&&(e.__returned===e||e.__returned===null)}async fetch(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:l=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:a=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,fetchContext:v=this.fetchContext,forceRefresh:T=!1,status:u,signal:d}={}){if(!this.fetchMethod)return u&&(u.fetch="get"),this.get(e,{allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:u});let E={allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:n,noDisposeOnSet:o,size:l,sizeCalculation:h,noUpdateTTL:c,noDeleteOnFetchRejection:a,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:p,ignoreFetchAbort:g,status:u,signal:d},A=this.keyMap.get(e);if(A===void 0){u&&(u.fetch="miss");let y=this.backgroundFetch(e,A,E,v);return y.__returned=y}else{let y=this.valList[A];if(this.isBackgroundFetch(y)){let M=t&&y.__staleWhileFetching!==void 0;return u&&(u.fetch="inflight",M&&(u.returnedStale=!0)),M?y.__staleWhileFetching:y.__returned=y}let w=this.isStale(A);if(!T&&!w)return u&&(u.fetch="hit"),this.moveToTail(A),i&&this.updateItemAge(A),this.statusTTL(u,A),y;let m=this.backgroundFetch(e,A,E,v),B=m.__staleWhileFetching!==void 0,z=B&&t;return u&&(u.fetch=B&&w?"stale":"refresh",z&&w&&(u.returnedStale=!0)),z?m.__staleWhileFetching:m.__returned=m}}get(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:n}={}){let o=this.keyMap.get(e);if(o!==void 0){let l=this.valList[o],h=this.isBackgroundFetch(l);return this.statusTTL(n,o),this.isStale(o)?(n&&(n.get="stale"),h?(n&&(n.returnedStale=t&&l.__staleWhileFetching!==void 0),t?l.__staleWhileFetching:void 0):(r||this.delete(e),n&&(n.returnedStale=t),t?l:void 0)):(n&&(n.get="hit"),h?l.__staleWhileFetching:(this.moveToTail(o),i&&this.updateItemAge(o),l))}else n&&(n.get="miss")}connect(e,t){this.prev[t]=e,this.next[e]=t}moveToTail(e){e!==this.tail&&(e===this.head?this.head=this.next[e]:this.connect(this.prev[e],this.next[e]),this.connect(this.tail,e),this.tail=e)}get del(){return xe("del","delete"),this.delete}delete(e){let t=!1;if(this.size!==0){let i=this.keyMap.get(e);if(i!==void 0)if(t=!0,this.size===1)this.clear();else{this.removeItemSize(i);let r=this.valList[i];this.isBackgroundFetch(r)?r.__abortController.abort(new Error("deleted")):(this.dispose(r,e,"delete"),this.disposeAfter&&this.disposed.push([r,e,"delete"])),this.keyMap.delete(e),this.keyList[i]=null,this.valList[i]=null,i===this.tail?this.tail=this.prev[i]:i===this.head?this.head=this.next[i]:(this.next[this.prev[i]]=this.next[i],this.prev[this.next[i]]=this.prev[i]),this.size--,this.free.push(i)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return t}clear(){for(let e of this.rindexes({allowStale:!0})){let t=this.valList[e];if(this.isBackgroundFetch(t))t.__abortController.abort(new Error("deleted"));else{let i=this.keyList[e];this.dispose(t,i,"delete"),this.disposeAfter&&this.disposed.push([t,i,"delete"])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return xe("reset","clear"),this.clear}get length(){return Ei("length","size"),this.size}static get AbortController(){return he}static get AbortSignal(){return vt}},Ie=$;var fe=class{trace(e,...t){console.trace(e,...t)}debug(e,...t){console.debug(e,...t)}info(e,...t){console.info(e,...t)}warn(e,...t){console.warn(e,...t)}error(e,...t){console.error(e,...t)}};var St=P(require("keyv")),Tt=require("keyv-file"),H=class{constructor(e={}){this.keyvFile=new Tt.KeyvFile(e),this.keyv=new St.default({store:this.keyvFile})}set(e,t){return this.keyv.set(e,t)}get(e){return this.keyv.get(e)}del(e){return this.keyv.delete(e)}keys(){return Promise.resolve(function*(e){for(let t of e)yield t}(this.keyvFile.keys()))}};var At=100;var bt="featureIdentifier",Rt="featureName",wt="variationIdentifier";var xt="target",Pt="SDK_VERSION",_t="SDK_TYPE",Ct="server",It="SDK_LANGUAGE",Ot="javascript",Ft="global",te="segmentMatch",Dt="in",Lt="equal",kt="gt",Mt="starts_with",Nt="ends_with",Ut="contains",Vt="equal_sensitive",Si="https://config.ff.harness.io/api/1.0",Ti="https://events.ff.harness.io/api/1.0",Ai=1e3,Bt=60*Ai,bi=1*Bt,Ri=1*Bt,V={baseUrl:Si,eventsUrl:Ti,pollInterval:bi,eventsSyncInterval:Ri,enableStream:!0,enableAnalytics:!0,cache:new Ie({max:100}),store:new H,logger:new fe};var qt=P(zt());var ge=class{constructor(e,t){this.query=e,this.log=t}getAttrValue(e,t){var i;return e[t]||((i=e.attributes)==null?void 0:i[t])}findVariation(e,t){return e.find(i=>i.identifier===t)}getNormalizedNumberWithNormalizer(e,t,i){let r=[t,e].join(":");return parseInt((0,qt.default)(r).toString())%i+1}getNormalizedNumber(e,t){return this.getNormalizedNumberWithNormalizer(e,t,At)}isEnabled(e,t,i){let r=this.getAttrValue(e,t);if(!r)return!1;let n=this.getNormalizedNumber(r,t);return i>0&&n<=i}evaluateDistribution(e,t){if(!e)return;let i="",r=0;for(let n of e.variations)if(i=n.variation,r+=n.weight,this.isEnabled(t,e.bucketBy,r))return n.variation;return i}async isTargetIncludedOrExcludedInSegment(e,t){var i,r;for(let n of e){let o=await this.query.getSegment(n);if(o){if((i=o.excluded)!=null&&i.find(l=>l.identifier===t.identifier))return this.log.debug(`Target %s excluded from segment %s via exclude list | ||
`,t.name,o.name),!1;if((r=o.included)!=null&&r.find(l=>l.identifier===t.identifier))return this.log.debug(`Target %s included in segment %s via include list | ||
"use strict";var Ht=Object.create;var ee=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var ge=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Le=(s,e)=>{for(var t in e)ee(s,t,{get:e[t],enumerable:!0})},De=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Yt(e))!Jt.call(s,r)&&r!==t&&ee(s,r,{get:()=>e[r],enumerable:!(i=Wt(e,r))||i.enumerable});return s};var P=(s,e,t)=>(t=s!=null?Ht(Qt(s)):{},De(e||!s||!s.__esModule?ee(t,"default",{value:s,enumerable:!0}):t,s)),Xt=s=>De(ee({},"__esModule",{value:!0}),s);var Ne=ge((Pi,Be)=>{"use strict";function pe(s){this.message=s}pe.prototype=new Error,pe.prototype.name="InvalidCharacterError";var ke=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(s){var e=String(s).replace(/=+$/,"");if(e.length%4==1)throw new pe("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,i,r=0,n=0,o="";i=e.charAt(n++);~i&&(t=r%4?64*t+i:i,r++%4)?o+=String.fromCharCode(255&t>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function Zt(s){var e=s.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ke(t).replace(/(.)/g,function(i,r){var n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}(e)}catch{return ke(e)}}function Y(s){this.message=s}function Me(s,e){if(typeof s!="string")throw new Y("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(Zt(s.split(".")[t]))}catch(i){throw new Y("Invalid token specified: "+i.message)}}Y.prototype=new Error,Y.prototype.name="InvalidTokenError";var de=Me;de.default=Me,de.InvalidTokenError=Y,Be.exports=de});var Ve=ge((_i,Ue)=>{"use strict";var ei=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);Ue.exports=s=>!ei.has(s&&s.code)});var zt=ge((vr,Ce)=>{"use strict";(function(){let s=this,e=n=>new TextEncoder().encode(n);function t(n,o){typeof n=="string"&&(n=e(n));let a=n.length,c=o^a,l=0,h;for(;a>=4;)h=n[l]&255|(n[++l]&255)<<8|(n[++l]&255)<<16|(n[++l]&255)<<24,h=(h&65535)*1540483477+(((h>>>16)*1540483477&65535)<<16),h^=h>>>24,h=(h&65535)*1540483477+(((h>>>16)*1540483477&65535)<<16),c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16)^h,a-=4,++l;switch(a){case 3:c^=(n[l+2]&255)<<16;case 2:c^=(n[l+1]&255)<<8;case 1:c^=n[l]&255,c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16)}return c^=c>>>13,c=(c&65535)*1540483477+(((c>>>16)*1540483477&65535)<<16),c^=c>>>15,c>>>0}function i(n,o){typeof n=="string"&&(n=e(n));let a,c,l,h,f,d,p,S,u,g;for(a=n.length&3,c=n.length-a,l=o,f=3432918353,p=461845907,g=0;g<c;)u=n[g]&255|(n[++g]&255)<<8|(n[++g]&255)<<16|(n[++g]&255)<<24,++g,u=(u&65535)*f+(((u>>>16)*f&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*p+(((u>>>16)*p&65535)<<16)&4294967295,l^=u,l=l<<13|l>>>19,h=(l&65535)*5+(((l>>>16)*5&65535)<<16)&4294967295,l=(h&65535)+27492+(((h>>>16)+58964&65535)<<16);switch(u=0,a){case 3:u^=(n[g+2]&255)<<16;case 2:u^=(n[g+1]&255)<<8;case 1:u^=n[g]&255,u=(u&65535)*f+(((u>>>16)*f&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*p+(((u>>>16)*p&65535)<<16)&4294967295,l^=u}return l^=n.length,l^=l>>>16,l=(l&65535)*2246822507+(((l>>>16)*2246822507&65535)<<16)&4294967295,l^=l>>>13,l=(l&65535)*3266489909+(((l>>>16)*3266489909&65535)<<16)&4294967295,l^=l>>>16,l>>>0}let r=i;if(r.v2=t,r.v3=i,typeof Ce<"u")Ce.exports=r;else{let n=s.murmur;r.noConflict=function(){return s.murmur=n,r},s.murmur=r}})()});var wi={};Le(wi,{Client:()=>H,Event:()=>fe,FileStore:()=>$,LRU:()=>_e,default:()=>Ri});module.exports=Xt(wi);var jt=P(require("events")),Gt=P(Ne()),Ie=P(require("axios"));var Ge=P(Ve(),1);function ze(s,e,t,i,r,n,o){try{var a=s[n](o),c=a.value}catch(l){t(l);return}a.done?e(c):Promise.resolve(c).then(i,r)}function je(s){return function(){var e=this,t=arguments;return new Promise(function(i,r){var n=s.apply(e,t);function o(c){ze(n,i,r,o,a,"next",c)}function a(c){ze(n,i,r,o,a,"throw",c)}o(void 0)})}}function qe(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),t.push.apply(t,i)}return t}function me(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?qe(Object(t),!0).forEach(function(i){ti(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):qe(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function ti(s,e,t){return e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}var $e="axios-retry";function He(s){var e=["ERR_CANCELED","ECONNABORTED"];return!s.response&&!!s.code&&!e.includes(s.code)&&(0,Ge.default)(s)}var We=["get","head","options"],ii=We.concat(["put","delete"]);function ye(s){return s.code!=="ECONNABORTED"&&(!s.response||s.response.status>=500&&s.response.status<=599)}function ri(s){return s.config?ye(s)&&We.indexOf(s.config.method)!==-1:!1}function Ye(s){return s.config?ye(s)&&ii.indexOf(s.config.method)!==-1:!1}function Qe(s){return He(s)||Ye(s)}function si(){return 0}function ni(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:100,i=Math.pow(2,s)*t,r=i*.2*Math.random();return i+r}var oi={retries:3,retryCondition:Qe,retryDelay:si,shouldResetTimeout:!1,onRetry:()=>{}};function ai(s,e){return me(me(me({},oi),e),s[$e])}function Ke(s,e){var t=ai(s,e);return t.retryCount=t.retryCount||0,s[$e]=t,t}function li(s,e){s.defaults.agent===e.agent&&delete e.agent,s.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,s.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}function ci(s,e){return ve.apply(this,arguments)}function ve(){return ve=je(function*(s,e){var{retries:t,retryCondition:i}=s,r=s.retryCount<t&&i(e);if(typeof r=="object")try{var n=yield r;return n!==!1}catch{return!1}return r}),ve.apply(this,arguments)}function _(s,e){var t=s.interceptors.request.use(r=>{var n=Ke(r,e);return n.lastRequestTime=Date.now(),r}),i=s.interceptors.response.use(null,function(){var r=je(function*(n){var{config:o}=n;if(!o)return Promise.reject(n);var a=Ke(o,e);if(yield ci(a,n)){a.retryCount+=1;var{retryDelay:c,shouldResetTimeout:l,onRetry:h}=a,f=c(a.retryCount,n);if(li(s,o),!l&&o.timeout&&a.lastRequestTime){var d=Date.now()-a.lastRequestTime,p=o.timeout-d-f;if(p<=0)return Promise.reject(n);o.timeout=p}return o.transformRequest=[S=>S],yield h(a.retryCount,n,o),new Promise(S=>setTimeout(()=>S(s(o)),f))}return Promise.reject(n)});return function(n){return r.apply(this,arguments)}}());return{requestInterceptorId:t,responseInterceptorId:i}}_.isNetworkError=He;_.isSafeRequestError=ri;_.isIdempotentRequestError=Ye;_.isNetworkOrIdempotentRequestError=Qe;_.exponentialDelay=ni;_.isRetryableError=ye;var L=P(require("axios"));var Je=P(require("axios")),x="http://localhost/api/1.0".replace(/\/+$/,"");var Q=class{constructor(e,t=x,i=Je.default){this.basePath=t;this.axios=i;e&&(this.configuration=e,this.basePath=e.basePath||this.basePath)}},te=class extends Error{constructor(t,i){super(i);this.field=t;this.name="RequiredError"}};var C="https://example.com",R=function(s,e,t){if(t==null)throw new te(e,`Required parameter ${e} was null or undefined when calling ${s}.`)};var k=async function(s,e){if(e&&e.accessToken){let t=typeof e.accessToken=="function"?await e.accessToken():await e.accessToken;s.Authorization="Bearer "+t}};var O=function(s,...e){let t=new URLSearchParams(s.search);for(let i of e)for(let r in i)if(Array.isArray(i[r])){t.delete(r);for(let n of i[r])t.append(r,n)}else t.set(r,i[r]);s.search=t.toString()},Ee=function(s,e,t){let i=typeof s!="string";return(i&&t&&t.isJsonMime?t.isJsonMime(e.headers["Content-Type"]):i)?JSON.stringify(s!==void 0?s:{}):s||""},I=function(s){return s.pathname+s.search+s.hash},F=function(s,e,t,i){return(r=e,n=t)=>{let o={...s.options,url:((i==null?void 0:i.basePath)||n)+s.url};return r.request(o)}};var hi=function(s){return{authenticate:async(e,t={})=>{let i="/client/auth",r=new URL(i,C),n;s&&(n=s.baseOptions);let o={method:"POST",...n,...t},a={},c={};a["Content-Type"]="application/json",O(r,c,t.query);let l=n&&n.headers?n.headers:{};return o.headers={...a,...l,...t.headers},o.data=Ee(e,o,s),{url:I(r),options:o}},getAllSegments:async(e,t,i={})=>{R("getAllSegments","environmentUUID",e);let r="/client/env/{environmentUUID}/target-segments".replace("{environmentUUID}",encodeURIComponent(String(e))),n=new URL(r,C),o;s&&(o=s.baseOptions);let a={method:"GET",...o,...i},c={},l={};await k(c,s),t!==void 0&&(l.cluster=t),O(n,l,i.query);let h=o&&o.headers?o.headers:{};return a.headers={...c,...h,...i.headers},{url:I(n),options:a}},getEvaluationByIdentifier:async(e,t,i,r,n={})=>{R("getEvaluationByIdentifier","environmentUUID",e),R("getEvaluationByIdentifier","feature",t),R("getEvaluationByIdentifier","target",i);let o="/client/env/{environmentUUID}/target/{target}/evaluations/{feature}".replace("{environmentUUID}",encodeURIComponent(String(e))).replace("{feature}",encodeURIComponent(String(t))).replace("{target}",encodeURIComponent(String(i))),a=new URL(o,C),c;s&&(c=s.baseOptions);let l={method:"GET",...c,...n},h={},f={};await k(h,s),r!==void 0&&(f.cluster=r),O(a,f,n.query);let d=c&&c.headers?c.headers:{};return l.headers={...h,...d,...n.headers},{url:I(a),options:l}},getEvaluations:async(e,t,i,r={})=>{R("getEvaluations","environmentUUID",e),R("getEvaluations","target",t);let n="/client/env/{environmentUUID}/target/{target}/evaluations".replace("{environmentUUID}",encodeURIComponent(String(e))).replace("{target}",encodeURIComponent(String(t))),o=new URL(n,C),a;s&&(a=s.baseOptions);let c={method:"GET",...a,...r},l={},h={};await k(l,s),i!==void 0&&(h.cluster=i),O(o,h,r.query);let f=a&&a.headers?a.headers:{};return c.headers={...l,...f,...r.headers},{url:I(o),options:c}},getFeatureConfig:async(e,t,i={})=>{R("getFeatureConfig","environmentUUID",e);let r="/client/env/{environmentUUID}/feature-configs".replace("{environmentUUID}",encodeURIComponent(String(e))),n=new URL(r,C),o;s&&(o=s.baseOptions);let a={method:"GET",...o,...i},c={},l={};await k(c,s),t!==void 0&&(l.cluster=t),O(n,l,i.query);let h=o&&o.headers?o.headers:{};return a.headers={...c,...h,...i.headers},{url:I(n),options:a}},getFeatureConfigByIdentifier:async(e,t,i,r={})=>{R("getFeatureConfigByIdentifier","identifier",e),R("getFeatureConfigByIdentifier","environmentUUID",t);let n="/client/env/{environmentUUID}/feature-configs/{identifier}".replace("{identifier}",encodeURIComponent(String(e))).replace("{environmentUUID}",encodeURIComponent(String(t))),o=new URL(n,C),a;s&&(a=s.baseOptions);let c={method:"GET",...a,...r},l={},h={};await k(l,s),i!==void 0&&(h.cluster=i),O(o,h,r.query);let f=a&&a.headers?a.headers:{};return c.headers={...l,...f,...r.headers},{url:I(o),options:c}},getSegmentByIdentifier:async(e,t,i,r={})=>{R("getSegmentByIdentifier","identifier",e),R("getSegmentByIdentifier","environmentUUID",t);let n="/client/env/{environmentUUID}/target-segments/{identifier}".replace("{identifier}",encodeURIComponent(String(e))).replace("{environmentUUID}",encodeURIComponent(String(t))),o=new URL(n,C),a;s&&(a=s.baseOptions);let c={method:"GET",...a,...r},l={},h={};await k(l,s),i!==void 0&&(h.cluster=i),O(o,h,r.query);let f=a&&a.headers?a.headers:{};return c.headers={...l,...f,...r.headers},{url:I(o),options:c}},stream:async(e,t,i={})=>{R("stream","aPIKey",e);let r="/stream",n=new URL(r,C),o;s&&(o=s.baseOptions);let a={method:"GET",...o,...i},c={},l={};await k(c,s),t!==void 0&&(l.cluster=t),e!=null&&(c["API-Key"]=String(e)),O(n,l,i.query);let h=o&&o.headers?o.headers:{};return a.headers={...c,...h,...i.headers},{url:I(n),options:a}}}},B=function(s){let e=hi(s);return{async authenticate(t,i){let r=await e.authenticate(t,i);return F(r,L.default,x,s)},async getAllSegments(t,i,r){let n=await e.getAllSegments(t,i,r);return F(n,L.default,x,s)},async getEvaluationByIdentifier(t,i,r,n,o){let a=await e.getEvaluationByIdentifier(t,i,r,n,o);return F(a,L.default,x,s)},async getEvaluations(t,i,r,n){let o=await e.getEvaluations(t,i,r,n);return F(o,L.default,x,s)},async getFeatureConfig(t,i,r){let n=await e.getFeatureConfig(t,i,r);return F(n,L.default,x,s)},async getFeatureConfigByIdentifier(t,i,r,n){let o=await e.getFeatureConfigByIdentifier(t,i,r,n);return F(o,L.default,x,s)},async getSegmentByIdentifier(t,i,r,n){let o=await e.getSegmentByIdentifier(t,i,r,n);return F(o,L.default,x,s)},async stream(t,i,r){let n=await e.stream(t,i,r);return F(n,L.default,x,s)}}};var ie=class extends Q{authenticate(e,t){return B(this.configuration).authenticate(e,t).then(i=>i(this.axios,this.basePath))}getAllSegments(e,t,i){return B(this.configuration).getAllSegments(e,t,i).then(r=>r(this.axios,this.basePath))}getEvaluationByIdentifier(e,t,i,r,n){return B(this.configuration).getEvaluationByIdentifier(e,t,i,r,n).then(o=>o(this.axios,this.basePath))}getEvaluations(e,t,i,r){return B(this.configuration).getEvaluations(e,t,i,r).then(n=>n(this.axios,this.basePath))}getFeatureConfig(e,t,i){return B(this.configuration).getFeatureConfig(e,t,i).then(r=>r(this.axios,this.basePath))}getFeatureConfigByIdentifier(e,t,i,r){return B(this.configuration).getFeatureConfigByIdentifier(e,t,i,r).then(n=>n(this.axios,this.basePath))}getSegmentByIdentifier(e,t,i,r){return B(this.configuration).getSegmentByIdentifier(e,t,i,r).then(n=>n(this.axios,this.basePath))}stream(e,t,i){return B(this.configuration).stream(e,t,i).then(r=>r(this.axios,this.basePath))}},ui=function(s){return{postMetrics:async(e,t,i,r={})=>{R("postMetrics","environment",e);let n="/metrics/{environment}".replace("{environment}",encodeURIComponent(String(e))),o=new URL(n,C),a;s&&(a=s.baseOptions);let c={method:"POST",...a,...r},l={},h={};await k(l,s),t!==void 0&&(h.cluster=t),l["Content-Type"]="application/json",O(o,h,r.query);let f=a&&a.headers?a.headers:{};return c.headers={...l,...f,...r.headers},c.data=Ee(i,c,s),{url:I(o),options:c}}}},fi=function(s){let e=ui(s);return{async postMetrics(t,i,r,n){let o=await e.postMetrics(t,i,r,n);return F(o,L.default,x,s)}}};var re=class extends Q{postMetrics(e,t,i,r){return fi(this.configuration).postMetrics(e,t,i,r).then(n=>n(this.axios,this.basePath))}};var K=class{constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){let t=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return e!==null&&(t.test(e)||e.toLowerCase()==="application/json-patch+json")}};var se="1.4.0";var Xe={1e3:"The SDK has successfully initialized",1001:"The SDK has failed to initialize due to an authentication error - defaults will be served",1002:"The SDK has failed to initialize due to a missing or empty API key - defaults will be served",2e3:"Authentication was successful",2001:"Authentication failed with a non-recoverable error",2002:"Authentication attempt failed:",2003:"Authentication failed and max retries have been exceeded",3e3:"Closing SDK",3001:"SDK Closed successfully",4e3:"Polling started, interval:",4001:"Polling stopped",5e3:"SSE stream successfully connected",5001:"SSE stream disconnected, reason:",5002:"SSE event received",5003:"SSE retrying to connect in",5004:"SSE stopped",6e3:"Evaluation successful: ",6001:"Evaluation Failed, returning default variation: ",6002:"BucketBy attribute not found in target attributes, falling back to 'identifier':",7e3:"Metrics thread started with request interval:",7001:"Metrics stopped",7002:"Posting metrics failed, reason:",7003:"Metrics posted successfully"};function gi(s){return s in Xe?Xe[s]:"Unknown SDK code"}function E(s,e=""){return`SDKCODE:${s}: ${gi(s)} ${e}`}function Ze(s){s.warn(E(1002))}function et(s,e){e.info(E(4e3,s/1e3+" seconds"))}function Se(s){s.info(E(1e3))}function tt(s){s.info(E(3e3))}function it(s){s.info(E(3001))}function Te(s){s.info(E(4001))}function rt(s){s.info(E(5e3))}function st(s){s.debug(E(5002))}function nt(s){s.info(E(5004))}function ot(s,e){e.info(E(7e3,s/1e3+" seconds"))}function at(s){s.info(E(7003))}function lt(s){s.info(E(7001))}function J(s,e,t,i){i.debug(E(6e3,`result=${s}, flag identifier=${e}, target=${JSON.stringify(t)}`))}function ct(s){s.warn(E(2001))}function ht(s){s.warn(E(1001))}function ut(s,e){e.warn(E(5001,s))}function ft(s,e){e.warn(E(5003,`${s}`))}function gt(s,e){e.warn(E(7002,s))}function D(s,e,t,i){i.warn(E(6001,`default variation used=${t}, flag=${s}, target=${JSON.stringify(e)}`))}function dt(s,e,t){t.warn(E(6002,`missing=${s}, using value=${e}`))}var ne=class{constructor(e,t,i,r,n,o){this.stopped=!0;this.initialized=!1;this.lastPollTime=0;this.api=i,this.options=r,this.environment=e,this.cluster=t,this.repository=o,this.eventBus=n,this.log=r.logger}poll(){if(this.stopped){this.log.info("PollingProcessor stopped"),Te(this.log);return}let e=new Date().getTime(),t=()=>{let i=new Date().getTime()-e,r=Math.max(this.options.pollInterval-i,0);this.timeout=setTimeout(()=>this.poll(),r)};if(this.lastPollTime>Date.now()-this.options.pollInterval){this.log.info(`Last poll was ${Math.round((Date.now()-this.lastPollTime)/1e3)} seconds ago, skipping flag refresh`),t();return}this.lastPollTime=Date.now(),Promise.all([this.retrieveFlags(),this.retrieveSegments()]).then(()=>{this.initialized||setTimeout(()=>{this.initialized=!0,this.eventBus.emit("poller_ready")},0)}).catch(i=>{this.eventBus.emit("poller_error",{error:i})}).finally(()=>{if(this.stopped){this.log.info("PollingProcessor stopped"),Te(this.log);return}t()})}async retrieveFlags(){try{this.log.debug("Fetching flags started");let e=await this.api.getFeatureConfig(this.environment,this.cluster);this.log.debug("Fetching flags finished"),e.data.forEach(t=>this.repository.setFlag(t.feature,t))}catch(e){throw this.log.error("Error loading flags",e),e}}async retrieveSegments(){try{this.log.debug("Fetching segments started");let e=await this.api.getAllSegments(this.environment,this.cluster);this.log.debug("Fetching segments finished"),e.data.forEach(t=>this.repository.setSegment(t.identifier,t))}catch(e){throw this.log.error("Error loading segments",e),e}}start(){if(!this.stopped){this.log.info("PollingProcessor already started");return}this.log.info("Starting PollingProcessor with request interval: ",this.options.pollInterval),this.stopped=!1,this.poll()}stop(){this.log.info("Stopping PollingProcessor"),this.stopped=!0}close(){this.log.info("Closing PollingProcessor"),this.stop(),clearTimeout(this.timeout),this.log.info("PollingProcessor closed")}};var pt=P(require("https")),mt=P(require("http"));var b=class b{constructor(e,t,i,r,n,o,a,c){this.retryAttempt=0;this.api=e,this.apiKey=t,this.environment=i,this.jwtToken=r,this.options=n,this.cluster=o,this.eventBus=a,this.repository=c,this.log=this.options.logger;let l=5e3,h=1e4;this.retryDelayMs=Math.floor(Math.random()*(h-l)+l)}start(){this.log.info("Starting new StreamProcessor");let e=`${this.options.baseUrl}/stream?cluster=${this.cluster}`,t={headers:{"Cache-Control":"no-cache",Accept:"text/event-stream",Authorization:`Bearer ${this.jwtToken}`,"API-Key":this.apiKey}},i=()=>{this.log.info(`SSE stream connected OK: ${e}`),this.retryAttempt=0,this.readyState=b.CONNECTED,this.eventBus.emit("stream_connected")},r=n=>{if(this.readyState!==b.CLOSED){this.retryAttempt+=1;let o=this.getRandomRetryDelayMs();ut(n,this.log),ft(o,this.log),this.readyState=b.RETRYING,this.eventBus.emit("stream_retrying"),setTimeout(()=>{this.log.info("SSE retrying to connect"),this.connect(e,t,i,r)},o)}};this.connect(e,t,i,r),this.eventBus.emit("stream_ready")}getRandomRetryDelayMs(){let e=this.retryDelayMs*this.retryAttempt;return Math.min(e,6e4)}connect(e,t,i,r){if(this.readyState===b.CONNECTED){this.log.debug("SSE already connected, skip retry");return}let n=e.startsWith("https:");this.log.debug("SSE HTTP start request",e),this.request=(n?pt.default:mt.default).request(e,t,o=>{if(this.log.debug("SSE got HTTP response code",o.statusCode),o.statusCode>=400&&o.statusCode<=599){r(`HTTP code ${o.statusCode}`);return}i(),o.on("data",a=>{st(this.log),this.processData(a)}).on("close",()=>{r("SSE stream closed")})}).on("error",o=>{r("SSE request failed "+o.message)}).on("timeout",()=>{r("SSE request timed out after "+b.SSE_TIMEOUT_MS+"ms")}).setTimeout(b.SSE_TIMEOUT_MS),this.request.end()}processData(e){e.toString().split(/\r?\n/).forEach(i=>this.processLine(i))}processLine(e){if(e.startsWith("data:")){this.log.debug("SSE GOT:",e.substring(5));let t=JSON.parse(e.substring(5));t.domain==="flag"?this.msgProcessor(t,this.api.getFeatureConfigByIdentifier.bind(this.api),this.repository.setFlag.bind(this.repository),this.repository.deleteFlag.bind(this.repository)):t.domain==="target-segment"&&this.msgProcessor(t,this.api.getSegmentByIdentifier.bind(this.api),this.repository.setSegment.bind(this.repository),this.repository.deleteSegment.bind(this.repository))}}async msgProcessor(e,t,i,r){this.log.info("Processing message",e);try{if(e.event==="create"||e.event==="patch"){let{data:n}=await t(e.identifier,this.environment,this.cluster);i(e.identifier,n)}else e.event==="delete"&&r(e.identifier)}catch(n){throw this.log.error("Error while fetching data with identifier:",e.identifier,n),n}this.log.info("Processing message finished",e)}connected(){return this.readyState===b.CONNECTED}close(){if(this.readyState===b.CLOSED){this.log.info("SteamProcessor already closed");return}this.readyState=b.CLOSED,this.log.info("Closing StreamProcessor"),this.request.destroy(),this.request=void 0,this.eventBus.emit("stream_disconnected"),this.log.info("StreamProcessor closed"),nt(this.log)}};b.CONNECTED=1,b.RETRYING=2,b.CLOSED=3,b.SSE_TIMEOUT_MS=3e4;var oe=b;var _e={};Le(_e,{default:()=>Pe});var X=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,pi=typeof AbortController=="function",ae=pi?AbortController:class{constructor(){this.signal=new vt}abort(e=new Error("This operation was aborted")){this.signal.reason=this.signal.reason||e,this.signal.aborted=!0,this.signal.dispatchEvent({type:"abort",target:this.signal})}},mi=typeof AbortSignal=="function",vi=typeof ae.AbortSignal=="function",vt=mi?AbortSignal:vi?ae.AbortController:class{constructor(){this.reason=void 0,this.aborted=!1,this._listeners=[]}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,this.onabort(e),this._listeners.forEach(t=>t(e),this))}onabort(){}addEventListener(e,t){e==="abort"&&this._listeners.push(t)}removeEventListener(e,t){e==="abort"&&(this._listeners=this._listeners.filter(i=>i!==t))}},we=new Set,Ae=(s,e)=>{let t=`LRU_CACHE_OPTION_${s}`;le(t)&&xe(t,`${s} option`,`options.${e}`,G)},be=(s,e)=>{let t=`LRU_CACHE_METHOD_${s}`;if(le(t)){let{prototype:i}=G,{get:r}=Object.getOwnPropertyDescriptor(i,s);xe(t,`${s} method`,`cache.${e}()`,r)}},yi=(s,e)=>{let t=`LRU_CACHE_PROPERTY_${s}`;if(le(t)){let{prototype:i}=G,{get:r}=Object.getOwnPropertyDescriptor(i,s);xe(t,`${s} property`,`cache.${e}`,r)}},yt=(...s)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(...s):console.error(...s)},le=s=>!we.has(s),xe=(s,e,t,i)=>{we.add(s);let r=`The ${e} is deprecated. Please use ${t} instead.`;yt(r,"DeprecationWarning",s,i)},N=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Et=s=>N(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?j:null:null,j=class extends Array{constructor(e){super(e),this.fill(0)}},Re=class{constructor(e){if(e===0)return[];let t=Et(e);this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},G=class s{constructor(e={}){let{max:t=0,ttl:i,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:c,dispose:l,disposeAfter:h,noDisposeOnSet:f,noUpdateTTL:d,maxSize:p=0,maxEntrySize:S=0,sizeCalculation:u,fetchMethod:g,fetchContext:v,noDeleteOnFetchRejection:T,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:w,ignoreFetchAbort:m}=e,{length:V,maxAge:z,stale:M}=e instanceof s?{}:e;if(t!==0&&!N(t))throw new TypeError("max option must be a nonnegative integer");let q=t?Et(t):Array;if(!q)throw new Error("invalid max value: "+t);if(this.max=t,this.maxSize=p,this.maxEntrySize=S||this.maxSize,this.sizeCalculation=u||V,this.sizeCalculation){if(!this.maxSize&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(this.fetchMethod=g||null,this.fetchMethod&&typeof this.fetchMethod!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.fetchContext=v,!this.fetchMethod&&v!==void 0)throw new TypeError("cannot set fetchContext without fetchMethod");if(this.keyMap=new Map,this.keyList=new Array(t).fill(null),this.valList=new Array(t).fill(null),this.next=new q(t),this.prev=new q(t),this.head=0,this.tail=0,this.free=new Re(t),this.initialFill=1,this.size=0,typeof l=="function"&&(this.dispose=l),typeof h=="function"?(this.disposeAfter=h,this.disposed=[]):(this.disposeAfter=null,this.disposed=null),this.noDisposeOnSet=!!f,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!T,this.allowStaleOnFetchRejection=!!y,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!m,this.maxEntrySize!==0){if(this.maxSize!==0&&!N(this.maxSize))throw new TypeError("maxSize must be a positive integer if specified");if(!N(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.initializeSizeTracking()}if(this.allowStale=!!c||!!M,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=N(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=i||z||0,this.ttl){if(!N(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.initializeTTLTracking()}if(this.max===0&&this.ttl===0&&this.maxSize===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.max&&!this.maxSize){let W="LRU_CACHE_UNBOUNDED";le(W)&&(we.add(W),yt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",W,s))}M&&Ae("stale","allowStale"),z&&Ae("maxAge","ttl"),V&&Ae("length","sizeCalculation")}getRemainingTTL(e){return this.has(e,{updateAgeOnHas:!1})?1/0:0}initializeTTLTracking(){this.ttls=new j(this.max),this.starts=new j(this.max),this.setItemTTL=(i,r,n=X.now())=>{if(this.starts[i]=r!==0?n:0,this.ttls[i]=r,r!==0&&this.ttlAutopurge){let o=setTimeout(()=>{this.isStale(i)&&this.delete(this.keyList[i])},r+1);o.unref&&o.unref()}},this.updateItemAge=i=>{this.starts[i]=this.ttls[i]!==0?X.now():0},this.statusTTL=(i,r)=>{i&&(i.ttl=this.ttls[r],i.start=this.starts[r],i.now=e||t(),i.remainingTTL=i.now+i.ttl-i.start)};let e=0,t=()=>{let i=X.now();if(this.ttlResolution>0){e=i;let r=setTimeout(()=>e=0,this.ttlResolution);r.unref&&r.unref()}return i};this.getRemainingTTL=i=>{let r=this.keyMap.get(i);return r===void 0?0:this.ttls[r]===0||this.starts[r]===0?1/0:this.starts[r]+this.ttls[r]-(e||t())},this.isStale=i=>this.ttls[i]!==0&&this.starts[i]!==0&&(e||t())-this.starts[i]>this.ttls[i]}updateItemAge(e){}statusTTL(e,t){}setItemTTL(e,t,i){}isStale(e){return!1}initializeSizeTracking(){this.calculatedSize=0,this.sizes=new j(this.max),this.removeItemSize=e=>{this.calculatedSize-=this.sizes[e],this.sizes[e]=0},this.requireSize=(e,t,i,r)=>{if(this.isBackgroundFetch(t))return 0;if(!N(i))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(i=r(t,e),!N(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.addItemSize=(e,t,i)=>{if(this.sizes[e]=t,this.maxSize){let r=this.maxSize-this.sizes[e];for(;this.calculatedSize>r;)this.evict(!0)}this.calculatedSize+=this.sizes[e],i&&(i.entrySize=t,i.totalCalculatedSize=this.calculatedSize)}}removeItemSize(e){}addItemSize(e,t){}requireSize(e,t,i,r){if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache")}*indexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.tail;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.head));)t=this.prev[t]}*rindexes({allowStale:e=this.allowStale}={}){if(this.size)for(let t=this.head;!(!this.isValidIndex(t)||((e||!this.isStale(t))&&(yield t),t===this.tail));)t=this.next[t]}isValidIndex(e){return e!==void 0&&this.keyMap.get(this.keyList[e])===e}*entries(){for(let e of this.indexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*rentries(){for(let e of this.rindexes())this.valList[e]!==void 0&&this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield[this.keyList[e],this.valList[e]])}*keys(){for(let e of this.indexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*rkeys(){for(let e of this.rindexes())this.keyList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.keyList[e])}*values(){for(let e of this.indexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}*rvalues(){for(let e of this.rindexes())this.valList[e]!==void 0&&!this.isBackgroundFetch(this.valList[e])&&(yield this.valList[e])}[Symbol.iterator](){return this.entries()}find(e,t){for(let i of this.indexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,this.keyList[i],this))return this.get(this.keyList[i],t)}}forEach(e,t=this){for(let i of this.indexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.keyList[i],this)}}rforEach(e,t=this){for(let i of this.rindexes()){let r=this.valList[i],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.keyList[i],this)}}get prune(){return be("prune","purgeStale"),this.purgeStale}purgeStale(){let e=!1;for(let t of this.rindexes({allowStale:!0}))this.isStale(t)&&(this.delete(this.keyList[t]),e=!0);return e}dump(){let e=[];for(let t of this.indexes({allowStale:!0})){let i=this.keyList[t],r=this.valList[t],n=this.isBackgroundFetch(r)?r.__staleWhileFetching:r;if(n===void 0)continue;let o={value:n};if(this.ttls){o.ttl=this.ttls[t];let a=X.now()-this.starts[t];o.start=Math.floor(Date.now()-a)}this.sizes&&(o.size=this.sizes[t]),e.unshift([i,o])}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let r=Date.now()-i.start;i.start=X.now()-r}this.set(t,i.value,i)}}dispose(e,t,i){}set(e,t,{ttl:i=this.ttl,start:r,noDisposeOnSet:n=this.noDisposeOnSet,size:o=0,sizeCalculation:a=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,status:l}={}){if(o=this.requireSize(e,t,o,a),this.maxEntrySize&&o>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.delete(e),this;let h=this.size===0?void 0:this.keyMap.get(e);if(h===void 0)h=this.newIndex(),this.keyList[h]=e,this.valList[h]=t,this.keyMap.set(e,h),this.next[this.tail]=h,this.prev[h]=this.tail,this.tail=h,this.size++,this.addItemSize(h,o,l),l&&(l.set="add"),c=!1;else{this.moveToTail(h);let f=this.valList[h];if(t!==f){if(this.isBackgroundFetch(f)?f.__abortController.abort(new Error("replaced")):n||(this.dispose(f,e,"set"),this.disposeAfter&&this.disposed.push([f,e,"set"])),this.removeItemSize(h),this.valList[h]=t,this.addItemSize(h,o,l),l){l.set="replace";let d=f&&this.isBackgroundFetch(f)?f.__staleWhileFetching:f;d!==void 0&&(l.oldValue=d)}}else l&&(l.set="update")}if(i!==0&&this.ttl===0&&!this.ttls&&this.initializeTTLTracking(),c||this.setItemTTL(h,i,r),this.statusTTL(l,h),this.disposeAfter)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return this}newIndex(){return this.size===0?this.tail:this.size===this.max&&this.max!==0?this.evict(!1):this.free.length!==0?this.free.pop():this.initialFill++}pop(){if(this.size){let e=this.valList[this.head];return this.evict(!0),e}}evict(e){let t=this.head,i=this.keyList[t],r=this.valList[t];return this.isBackgroundFetch(r)?r.__abortController.abort(new Error("evicted")):(this.dispose(r,i,"evict"),this.disposeAfter&&this.disposed.push([r,i,"evict"])),this.removeItemSize(t),e&&(this.keyList[t]=null,this.valList[t]=null,this.free.push(t)),this.head=this.next[t],this.keyMap.delete(i),this.size--,t}has(e,{updateAgeOnHas:t=this.updateAgeOnHas,status:i}={}){let r=this.keyMap.get(e);if(r!==void 0)if(this.isStale(r))i&&(i.has="stale",this.statusTTL(i,r));else return t&&this.updateItemAge(r),i&&(i.has="hit"),this.statusTTL(i,r),!0;else i&&(i.has="miss");return!1}peek(e,{allowStale:t=this.allowStale}={}){let i=this.keyMap.get(e);if(i!==void 0&&(t||!this.isStale(i))){let r=this.valList[i];return this.isBackgroundFetch(r)?r.__staleWhileFetching:r}}backgroundFetch(e,t,i,r){let n=t===void 0?void 0:this.valList[t];if(this.isBackgroundFetch(n))return n;let o=new ae;i.signal&&i.signal.addEventListener("abort",()=>o.abort(i.signal.reason));let a={signal:o.signal,options:i,context:r},c=(p,S=!1)=>{let{aborted:u}=o.signal,g=i.ignoreFetchAbort&&p!==void 0;return i.status&&(u&&!S?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,g&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),u&&!g&&!S?h(o.signal.reason):(this.valList[t]===d&&(p===void 0?d.__staleWhileFetching?this.valList[t]=d.__staleWhileFetching:this.delete(e):(i.status&&(i.status.fetchUpdated=!0),this.set(e,p,a.options))),p)},l=p=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=p),h(p)),h=p=>{let{aborted:S}=o.signal,u=S&&i.allowStaleOnFetchAbort,g=u||i.allowStaleOnFetchRejection,v=g||i.noDeleteOnFetchRejection;if(this.valList[t]===d&&(!v||d.__staleWhileFetching===void 0?this.delete(e):u||(this.valList[t]=d.__staleWhileFetching)),g)return i.status&&d.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),d.__staleWhileFetching;if(d.__returned===d)throw p},f=(p,S)=>{this.fetchMethod(e,n,a).then(u=>p(u),S),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(p(),i.allowStaleOnFetchAbort&&(p=u=>c(u,!0)))})};i.status&&(i.status.fetchDispatched=!0);let d=new Promise(f).then(c,l);return d.__abortController=o,d.__staleWhileFetching=n,d.__returned=null,t===void 0?(this.set(e,d,{...a.options,status:void 0}),t=this.keyMap.get(e)):this.valList[t]=d,d}isBackgroundFetch(e){return e&&typeof e=="object"&&typeof e.then=="function"&&Object.prototype.hasOwnProperty.call(e,"__staleWhileFetching")&&Object.prototype.hasOwnProperty.call(e,"__returned")&&(e.__returned===e||e.__returned===null)}async fetch(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:h=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,fetchContext:S=this.fetchContext,forceRefresh:u=!1,status:g,signal:v}={}){if(!this.fetchMethod)return g&&(g.fetch="get"),this.get(e,{allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:g});let T={allowStale:t,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:n,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:h,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:g,signal:v},A=this.keyMap.get(e);if(A===void 0){g&&(g.fetch="miss");let y=this.backgroundFetch(e,A,T,S);return y.__returned=y}else{let y=this.valList[A];if(this.isBackgroundFetch(y)){let M=t&&y.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",M&&(g.returnedStale=!0)),M?y.__staleWhileFetching:y.__returned=y}let w=this.isStale(A);if(!u&&!w)return g&&(g.fetch="hit"),this.moveToTail(A),i&&this.updateItemAge(A),this.statusTTL(g,A),y;let m=this.backgroundFetch(e,A,T,S),V=m.__staleWhileFetching!==void 0,z=V&&t;return g&&(g.fetch=V&&w?"stale":"refresh",z&&w&&(g.returnedStale=!0)),z?m.__staleWhileFetching:m.__returned=m}}get(e,{allowStale:t=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:n}={}){let o=this.keyMap.get(e);if(o!==void 0){let a=this.valList[o],c=this.isBackgroundFetch(a);return this.statusTTL(n,o),this.isStale(o)?(n&&(n.get="stale"),c?(n&&(n.returnedStale=t&&a.__staleWhileFetching!==void 0),t?a.__staleWhileFetching:void 0):(r||this.delete(e),n&&(n.returnedStale=t),t?a:void 0)):(n&&(n.get="hit"),c?a.__staleWhileFetching:(this.moveToTail(o),i&&this.updateItemAge(o),a))}else n&&(n.get="miss")}connect(e,t){this.prev[t]=e,this.next[e]=t}moveToTail(e){e!==this.tail&&(e===this.head?this.head=this.next[e]:this.connect(this.prev[e],this.next[e]),this.connect(this.tail,e),this.tail=e)}get del(){return be("del","delete"),this.delete}delete(e){let t=!1;if(this.size!==0){let i=this.keyMap.get(e);if(i!==void 0)if(t=!0,this.size===1)this.clear();else{this.removeItemSize(i);let r=this.valList[i];this.isBackgroundFetch(r)?r.__abortController.abort(new Error("deleted")):(this.dispose(r,e,"delete"),this.disposeAfter&&this.disposed.push([r,e,"delete"])),this.keyMap.delete(e),this.keyList[i]=null,this.valList[i]=null,i===this.tail?this.tail=this.prev[i]:i===this.head?this.head=this.next[i]:(this.next[this.prev[i]]=this.next[i],this.prev[this.next[i]]=this.prev[i]),this.size--,this.free.push(i)}}if(this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift());return t}clear(){for(let e of this.rindexes({allowStale:!0})){let t=this.valList[e];if(this.isBackgroundFetch(t))t.__abortController.abort(new Error("deleted"));else{let i=this.keyList[e];this.dispose(t,i,"delete"),this.disposeAfter&&this.disposed.push([t,i,"delete"])}}if(this.keyMap.clear(),this.valList.fill(null),this.keyList.fill(null),this.ttls&&(this.ttls.fill(0),this.starts.fill(0)),this.sizes&&this.sizes.fill(0),this.head=0,this.tail=0,this.initialFill=1,this.free.length=0,this.calculatedSize=0,this.size=0,this.disposed)for(;this.disposed.length;)this.disposeAfter(...this.disposed.shift())}get reset(){return be("reset","clear"),this.clear}get length(){return yi("length","size"),this.size}static get AbortController(){return ae}static get AbortSignal(){return vt}},Pe=G;var ce=class{trace(e,...t){console.trace(e,...t)}debug(e,...t){console.debug(e,...t)}info(e,...t){console.info(e,...t)}warn(e,...t){console.warn(e,...t)}error(e,...t){console.error(e,...t)}};var St=P(require("keyv")),Tt=require("keyv-file"),$=class{constructor(e={}){this.keyvFile=new Tt.KeyvFile(e),this.keyv=new St.default({store:this.keyvFile})}set(e,t){return this.keyv.set(e,t)}get(e){return this.keyv.get(e)}del(e){return this.keyv.delete(e)}keys(){return Promise.resolve(function*(e){for(let t of e)yield t}(this.keyvFile.keys()))}};var At=100;var bt="featureIdentifier",Rt="featureName",wt="variationIdentifier";var xt="target",Pt="SDK_VERSION",_t="SDK_TYPE",Ct="server",Ot="SDK_LANGUAGE",It="javascript",Ft="global",Z="segmentMatch",Lt="in",Dt="equal",kt="gt",Mt="starts_with",Bt="ends_with",Nt="contains",Ut="equal_sensitive",Ei="https://config.ff.harness.io/api/1.0",Si="https://events.ff.harness.io/api/1.0",Ti=1e3,Vt=60*Ti,Ai=1*Vt,bi=1*Vt,U={baseUrl:Ei,eventsUrl:Si,pollInterval:Ai,eventsSyncInterval:bi,enableStream:!0,enableAnalytics:!0,cache:new Pe({max:100}),store:new $,logger:new ce};var qt=P(zt());var he=class{constructor(e,t){this.query=e,this.log=t}getAttrValue(e,t){var i;return e[t]||((i=e.attributes)==null?void 0:i[t])}findVariation(e,t){return e.find(i=>i.identifier===t)}getNormalizedNumberWithNormalizer(e,t,i){let r=[e,t].join(":");return parseInt((0,qt.default)(r).toString())%i+1}getNormalizedNumber(e,t){return this.getNormalizedNumberWithNormalizer(e,t,At)}isEnabled(e,t,i){let r=t,n=this.getAttrValue(e,r);if(!n){if(r="identifier",n=this.getAttrValue(e,r),!n)return!1;dt(t,n==null?void 0:n.toString(),this.log)}let o=this.getNormalizedNumber(r,n);return i>0&&o<=i}evaluateDistribution(e,t){if(!e)return;let i="",r=0;for(let n of e.variations)if(i=n.variation,r+=n.weight,this.isEnabled(t,e.bucketBy,r))return n.variation;return i}async isTargetIncludedOrExcludedInSegment(e,t){var i,r;for(let n of e){let o=await this.query.getSegment(n);if(o){if((i=o.excluded)!=null&&i.find(a=>a.identifier===t.identifier))return this.log.debug(`Target %s excluded from segment %s via exclude list | ||
`,t.name,o.name),!1;if((r=o.included)!=null&&r.find(a=>a.identifier===t.identifier))return this.log.debug(`Target %s included in segment %s via include list | ||
`,t.name,o.name),!0;if(o.rules&&await this.evaluateClauses(o.rules,t))return this.log.debug(`Target %s included in segment %s via rules | ||
`,t.name,o.name),!0}}return!1}async evaluateClause(e,t){var o;if(!(e!=null&&e.op)||!((o=e==null?void 0:e.values)!=null&&o.length))return!1;let i=this.getAttrValue(t,e.attribute),r=i==null?void 0:i.toString();if(e.op!==te&&!r)return!1;let n=e.values[0];switch(e.op){case Dt:for(let l of e.values)if(l==r)return!0;return!1;case Lt:return r.toLowerCase()==n.toLowerCase();case Vt:return r==n;case kt:return r>n;case Mt:return r.startsWith(n);case Nt:return r.endsWith(n);case Ut:return r.includes(n);case te:return await this.isTargetIncludedOrExcludedInSegment(e.values,t)}return!1}async evaluateClauses(e,t){for(let i of e)if(await this.evaluateClause(i,t))return!0;return!1}evaluateRule(e,t){return this.evaluateClauses(e.clauses,t)}async evaluateRules(e,t){if(!t||!e)return;e.sort((r,n)=>r.priority>n.priority?1:-1);let i;for(let r of e)if(await this.evaluateRule(r,t))return r.serve.distribution&&(i=this.evaluateDistribution(r.serve.distribution,t)),r.serve.variation&&(i=r.serve.variation),i}async evaluateVariationMap(e,t){var i;if(!(!t||!e))for(let r of e){if((i=r.targets)==null?void 0:i.find(l=>l.identifier===t.identifier))return r.variation;let o=r.targetSegments;if(o&&await this.isTargetIncludedOrExcludedInSegment(o,t))return r.variation}}async evaluateFlag(e,t){let i=e.offVariation;return e.state==="on"&&(i=await this.evaluateVariationMap(e.variationToTargetMap,t)||await this.evaluateRules(e.rules,t)||this.evaluateDistribution(e.defaultServe.distribution,t)||e.defaultServe.variation),this.findVariation(e.variations,i)}async checkPreRequisite(e,t){if(e.prerequisites){this.log.info("Checking pre requisites %s of parent feature %s",e.prerequisites,e.feature);for(let i of e.prerequisites){let r=await this.query.getFlag(i.feature);if(!r)return this.log.warn("Could not retrieve the pre requisite details of feature flag: %s",e.feature),!0;let n=await this.evaluateFlag(r,t);return this.log.info("Pre requisite flag %s has variation %s for target %s",r.feature,n,t),this.log.info("Pre requisite flag %s should have the variations %s",r.feature,i.variations),i.variations.includes(n.identifier)?await this.checkPreRequisite(r,t):!1}}return!0}async evaluate(e,t,i,r){let n=await this.query.getFlag(e);if(!n||n.kind!==i)return;if(n.prerequisites&&!await this.checkPreRequisite(n,t))return this.findVariation(n.variations,n.offVariation);let o=await this.evaluateFlag(n,t);if(o)return r&&r(n,t,o),o}async boolVariation(e,t,i=!1,r){let n=await this.evaluate(e,t,"boolean",r);if(n){let o=n.value.toLowerCase()==="true";return Z(`${o}`,e,t,this.log),o}return D(e,t,i.toString(),this.log),i}async stringVariation(e,t,i="",r){let n=await this.evaluate(e,t,"string",r);return n?(Z(`${n.value}`,e,t,this.log),n.value):(D(e,t,i.toString(),this.log),i)}async numberVariation(e,t,i=0,r){let n=await this.evaluate(e,t,"int",r);if(n){let o=parseFloat(n.value);return Z(`${o}`,e,t,this.log),o}return D(e,t,i.toString(),this.log),i}async jsonVariation(e,t,i={},r){let n=await this.evaluate(e,t,"json",r);return n?(Z(`${n.value}`,e,t,this.log),JSON.parse(n.value)):(D(e,t,i.toString(),this.log),i)}};var De=(r=>(r.FLAG_STORED="flag_stored",r.FLAG_DELETED="flag_deleted",r.SEGMENT_STORED="segment_stored",r.SEGMENT_DELETED="segment_deleted",r))(De||{}),de=class{constructor(e,t,i){if(!e)throw new Error("Cache is required argument and cannot be undefined");this.eventBus=i,this.cache=e,this.store=t}async setFlag(e,t){if(await this.isFlagOutdated(e,t))return;let i=this.formatFlagKey(e);this.store?(await this.store.set(i,t),this.cache.delete(i)):this.cache.set(i,t),this.eventBus&&this.eventBus.emit("flag_stored",e)}async setSegment(e,t){if(await this.isSegmentOutdated(e,t))return;let i=this.formatSegmentKey(e);this.store?(await this.store.set(i,t),this.cache.delete(i)):this.cache.set(i,t),this.eventBus&&this.eventBus.emit("segment_stored",e)}async deleteFlag(e){let t=this.formatFlagKey(e);this.store&&await this.store.del(t),this.cache.delete(t),this.eventBus&&this.eventBus.emit("flag_deleted",e)}async deleteSegment(e){let t=this.formatSegmentKey(e);this.store&&await this.store.del(t),this.cache.delete(t),this.eventBus&&this.eventBus.emit("segment_deleted",e)}async getFlag(e,t=!0){let i=this.formatFlagKey(e),r=this.cache.get(i);if(r)return r;if(this.store)return r=await this.store.get(i),r&&t&&this.cache.set(i,r),r}async getSegment(e,t=!0){let i=this.formatSegmentKey(e),r=this.cache.get(i);if(r)return r;if(this.store)return r=await this.store.get(i),r&&t&&this.cache.set(i,r),r}async findFlagsBySegment(e){let t=[],i=this.cache.keys();this.store&&(i=await this.store.keys());for(let r of i){let n=await this.getFlag(r);if(!n)return[];for(let o of n==null?void 0:n.rules)for(let l of o==null?void 0:o.clauses)l.op===te&&l.values.includes(e)&&t.push(n.feature)}return t}async isFlagOutdated(e,t){let i=await this.getFlag(e,!1);return(i==null?void 0:i.version)&&i.version>=(t==null?void 0:t.version)}async isSegmentOutdated(e,t){let i=await this.getSegment(e,!1);return(i==null?void 0:i.version)&&i.version>=(t==null?void 0:t.version)}formatFlagKey(e){return`flags/${e}`}formatSegmentKey(e){return`segments/${e}`}};var Kt=(s,e="1",t,i,r,n=!1)=>{let o=new Map,l,h=new G({...t,basePath:i.eventsUrl}),c=new oe(h),a=i.logger,f=(d,E,A)=>{let y={target:d,featureConfig:E,variation:A,count:0},w=g(y),m=o.get(w);m?m.count++:(y.count=1,o.set(w,y))},g=d=>{let E=d.featureConfig.feature,A=d.variation.identifier,y=d.variation.value;return`${E}/${A}/${y}/${Ft}`},p=()=>{var y,w;if(!o){a.debug("No metrics data!");return}let d=[],E=[],A=new Map(o);o.clear();for(let m of A.values()){if(m.target&&!m.target.anonymous){let M=[];m.target.attributes&&(M=Object.entries(m.target.attributes).map(([Me,$t])=>({key:Me,value:$t})));let K=m.target.identifier;m.target.name&&(K=m.target.name);let Y={identifier:m.target.identifier,name:K,attributes:M};d.push(Y)}let B=[{key:bt,value:m.featureConfig.feature},{key:Rt,value:m.featureConfig.feature},{key:wt,value:m.variation.identifier},{key:_t,value:Ct},{key:It,value:Ot},{key:Pt,value:ae},{key:xt,value:(w=(y=m==null?void 0:m.target)==null?void 0:y.identifier)!=null?w:null}],z={timestamp:Date.now(),count:m.count,metricsType:"FFMETRICS",attributes:B};E.push(z)}return{targetData:d,metricsData:E}},v=()=>{if(n)return;let d=p();d&&d.metricsData.length&&d.targetData.length&&(a.debug("Start sending metrics data"),c.postMetrics(s,e,d).then(E=>{a.debug("Metrics server returns: ",E.status),lt(a),E.status>=400&&a.error("Error while sending metrics data with status code: ",E.status)}).catch(E=>{dt(`${E}`,a),a.debug("Metrics server returns error: ",E)}))};return{start:()=>{a.info("Starting MetricsProcessor with request interval: ",i.eventsSyncInterval),l=setInterval(v,i.eventsSyncInterval),r.emit("metrics_ready")},close:()=>{a.info("Closing MetricsProcessor"),clearInterval(l),v(),n=!0,a.info("MetricsProcessor closed"),ct(a)},enqueue:f}};ke.default.defaults.timeout=3e4;(0,Le.default)(ke.default,{retries:3,retryDelay:Le.default.exponentialDelay});var pe=(i=>(i.READY="ready",i.FAILED="failed",i.CHANGED="changed",i))(pe||{}),W=class{constructor(e,t={}){this.cluster="1";this.eventBus=new Gt.default;this.initialized=!1;this.failure=!1;this.pollerReady=!1;this.streamReady=!1;this.metricReady=!1;this.closing=!1;this.sdkKey=e,this.options={...V,...t},this.log=this.options.logger,t.pollInterval<V.pollInterval&&(this.options.pollInterval=V.pollInterval,this.log.warn(`Polling interval cannot be lower than ${V.pollInterval} ms`)),t.eventsSyncInterval<V.eventsSyncInterval&&(this.options.eventsSyncInterval=V.eventsSyncInterval,this.log.warn(`Events sync interval cannot be lower than ${V.eventsSyncInterval} ms`)),this.configuration=new G({basePath:this.options.baseUrl,baseOptions:{headers:{"User-Agent":`NodeJsSDK/${ae}`}}}),this.repository=new de(this.options.cache,this.options.store,this.eventBus),this.evaluator=new ge(this.repository,this.log),this.api=new ne(this.configuration),this.processEvents(),this.run()}processEvents(){this.eventBus.on("poller_ready",()=>{this.initialize(0)}),this.eventBus.on("poller_error",()=>{this.failure=!0,this.eventBus.emit("failed")}),this.eventBus.on("stream_ready",()=>{this.initialize(1)}),this.eventBus.on("stream_retrying",()=>{this.failure=!0,this.log.error("Issue with streaming: falling back to polling while the SDK attempts to reconnect"),this.closing||this.pollProcessor.start()}),this.eventBus.on("stream_error",()=>{this.failure=!0,this.log.error("Unrecoverable issue with streaming: falling back to polling"),this.closing||this.pollProcessor.start(),this.eventBus.emit("failed")}),this.eventBus.on("metrics_ready",()=>{this.initialize(2)}),this.eventBus.on("metrics_error",()=>{this.failure=!0,this.eventBus.emit("failed")}),this.eventBus.on("stream_connected",()=>{this.pollProcessor.stop()}),this.eventBus.on("stream_disconnected",()=>{this.closing||this.pollProcessor.start()});for(let e of Object.values(De))this.eventBus.on(e,t=>{switch(e){case"flag_stored":case"flag_deleted":this.eventBus.emit("changed",t);break;case"segment_stored":case"segment_deleted":this.repository.findFlagsBySegment(t).then(i=>{i.forEach(r=>this.eventBus.emit("changed",r))});break}})}on(e,t){let i=[];for(let r of Object.values(pe))i.push(r);i.includes(e)&&this.eventBus.on(e,t)}off(e,t){e?this.eventBus.off(e,t):this.close()}async authenticate(){if(!this.sdkKey){et(this.log),this.failure=!0;return}try{let e=await this.api.authenticate({apiKey:this.sdkKey});this.authToken=e.data.authToken,this.configuration.accessToken=this.authToken;let t=(0,jt.default)(this.authToken);t.environment||(this.failure=!0,this.log.error('Error while authenticating, err: the JWT token has missing claim "environmentUUID" ')),this.environment=t.environment,this.cluster=t.clusterIdentifier||"1"}catch(e){this.failure=!0,this.log.error("Error while authenticating, err: ",e),ht(this.log),ut(this.log),this.eventBus.emit("failed",e)}}waitForInitialization(){return this.waitForInitializePromise||(this.initialized?(this.waitForInitializePromise=Promise.resolve(this),be(this.log)):!this.initialized&&this.failure?this.waitForInitializePromise=Promise.resolve(this):this.waitForInitializePromise=new Promise((e,t)=>{this.eventBus.once("ready",()=>{setTimeout(()=>e(this),0)}),this.eventBus.once("failed",t)})),this.waitForInitializePromise}initialize(e){switch(e){case 0:this.pollerReady=!0,this.log.debug("PollingProcessor ready"),tt(this.options.pollInterval,this.log);break;case 1:this.streamReady=!0,this.log.debug("StreamingProcessor ready"),st(this.log);break;case 2:this.metricReady=!0,this.log.debug("MetricsProcessor ready"),at(this.options.eventsSyncInterval,this.log);break}this.options.enableStream&&!this.streamReady||this.options.enableAnalytics&&!this.metricReady||this.pollerReady&&this.eventBus.emit("ready")}async run(){await this.authenticate(),!this.failure&&(this.pollProcessor=new le(this.environment,this.cluster,this.api,this.options,this.eventBus,this.repository),this.pollProcessor.start(),this.options.enableStream&&(this.streamProcessor=new ce(this.api,this.sdkKey,this.environment,this.authToken,this.options,this.cluster,this.eventBus,this.repository),this.streamProcessor.start()),this.options.enableAnalytics&&(this.metricsProcessor=Kt(this.environment,this.cluster,this.configuration,this.options,this.eventBus),this.metricsProcessor.start()),this.log.info("finished setting up processors"),this.initialized=!0,be(this.log))}boolVariation(e,t,i=!1){return this.initialized?this.evaluator.boolVariation(e,t,i,(r,n,o)=>{this.metricsProcessor&&this.metricsProcessor.enqueue(n,r,o)}):(D(e,t,i.toString(),this.log),Promise.resolve(i))}stringVariation(e,t,i=""){return this.initialized?this.evaluator.stringVariation(e,t,i,(r,n,o)=>{this.metricsProcessor&&this.metricsProcessor.enqueue(n,r,o)}):(D(e,t,i.toString(),this.log),Promise.resolve(i))}numberVariation(e,t,i=0){return this.initialized?this.evaluator.numberVariation(e,t,i,(r,n,o)=>{this.metricsProcessor&&this.metricsProcessor.enqueue(n,r,o)}):(D(e,t,i.toString(),this.log),Promise.resolve(i))}jsonVariation(e,t,i={}){return this.initialized?this.evaluator.jsonVariation(e,t,i,(r,n,o)=>{this.metricsProcessor&&this.metricsProcessor.enqueue(n,r,o)}):(D(e,t,i.toString(),this.log),Promise.resolve(i))}close(){it(this.log),this.closing=!0,this.pollProcessor.close(),this.streamProcessor&&this.streamProcessor.close(),this.metricsProcessor&&this.metricsProcessor.close(),this.eventBus.removeAllListeners(),this.closing=!1,rt(this.log)}};var wi={instance:void 0,init:function(s,e){this.instance||(this.instance=new W(s,e))},waitForInitialization:function(){return this.instance.waitForInitialization()},boolVariation:function(s,e,t=!1){return this.instance.boolVariation(s,e,t)},stringVariation:function(s,e,t=""){return this.instance.stringVariation(s,e,t)},numberVariation:function(s,e,t=0){return this.instance.numberVariation(s,e,t)},jsonVariation:function(s,e,t=""){return this.instance.jsonVariation(s,e,t)},on:function(s,e){this.instance.on(s,e)},off:function(s,e){this.instance.off(s,e)},close:function(){return this.instance.close()}};0&&(module.exports={Client,Event,FileStore,LRU}); | ||
`,t.name,o.name),!0}}return!1}async evaluateClause(e,t){var o;if(!(e!=null&&e.op)||!((o=e==null?void 0:e.values)!=null&&o.length))return!1;let i=this.getAttrValue(t,e.attribute),r=i==null?void 0:i.toString();if(e.op!==Z&&!r)return!1;let n=e.values[0];switch(e.op){case Lt:for(let a of e.values)if(a==r)return!0;return!1;case Dt:return r.toLowerCase()==n.toLowerCase();case Ut:return r==n;case kt:return r>n;case Mt:return r.startsWith(n);case Bt:return r.endsWith(n);case Nt:return r.includes(n);case Z:return await this.isTargetIncludedOrExcludedInSegment(e.values,t)}return!1}async evaluateClauses(e,t){for(let i of e)if(await this.evaluateClause(i,t))return!0;return!1}evaluateRule(e,t){return this.evaluateClauses(e.clauses,t)}async evaluateRules(e,t){if(!t||!e)return;e.sort((r,n)=>r.priority>n.priority?1:-1);let i;for(let r of e)if(await this.evaluateRule(r,t))return r.serve.distribution&&(i=this.evaluateDistribution(r.serve.distribution,t)),r.serve.variation&&(i=r.serve.variation),i}async evaluateVariationMap(e,t){var i;if(!(!t||!e))for(let r of e){if((i=r.targets)==null?void 0:i.find(a=>a.identifier===t.identifier))return r.variation;let o=r.targetSegments;if(o&&await this.isTargetIncludedOrExcludedInSegment(o,t))return r.variation}}async evaluateFlag(e,t){let i=e.offVariation;return e.state==="on"&&(i=await this.evaluateVariationMap(e.variationToTargetMap,t)||await this.evaluateRules(e.rules,t)||this.evaluateDistribution(e.defaultServe.distribution,t)||e.defaultServe.variation),this.findVariation(e.variations,i)}async checkPreRequisite(e,t){if(e.prerequisites){this.log.info("Checking pre requisites %s of parent feature %s",e.prerequisites,e.feature);for(let i of e.prerequisites){let r=await this.query.getFlag(i.feature);if(!r)return this.log.warn("Could not retrieve the pre requisite details of feature flag: %s",e.feature),!0;let n=await this.evaluateFlag(r,t);return this.log.info("Pre requisite flag %s has variation %s for target %s",r.feature,n,t),this.log.info("Pre requisite flag %s should have the variations %s",r.feature,i.variations),i.variations.includes(n.identifier)?await this.checkPreRequisite(r,t):!1}}return!0}async evaluate(e,t,i,r){let n=await this.query.getFlag(e);if(!n||n.kind!==i)return;if(n.prerequisites&&!await this.checkPreRequisite(n,t))return this.findVariation(n.variations,n.offVariation);let o=await this.evaluateFlag(n,t);if(o)return r&&r(n,t,o),o}async boolVariation(e,t,i=!1,r){let n=await this.evaluate(e,t,"boolean",r);if(n){let o=n.value.toLowerCase()==="true";return J(`${o}`,e,t,this.log),o}return D(e,t,i.toString(),this.log),i}async stringVariation(e,t,i="",r){let n=await this.evaluate(e,t,"string",r);return n?(J(`${n.value}`,e,t,this.log),n.value):(D(e,t,i.toString(),this.log),i)}async numberVariation(e,t,i=0,r){let n=await this.evaluate(e,t,"int",r);if(n){let o=parseFloat(n.value);return J(`${o}`,e,t,this.log),o}return D(e,t,i.toString(),this.log),i}async jsonVariation(e,t,i={},r){let n=await this.evaluate(e,t,"json",r);return n?(J(`${n.value}`,e,t,this.log),JSON.parse(n.value)):(D(e,t,i.toString(),this.log),i)}};var Oe=(r=>(r.FLAG_STORED="flag_stored",r.FLAG_DELETED="flag_deleted",r.SEGMENT_STORED="segment_stored",r.SEGMENT_DELETED="segment_deleted",r))(Oe||{}),ue=class{constructor(e,t,i){if(!e)throw new Error("Cache is required argument and cannot be undefined");this.eventBus=i,this.cache=e,this.store=t}async setFlag(e,t){if(await this.isFlagOutdated(e,t))return;let i=this.formatFlagKey(e);this.store?(await this.store.set(i,t),this.cache.delete(i)):this.cache.set(i,t),this.eventBus&&this.eventBus.emit("flag_stored",e)}async setSegment(e,t){if(await this.isSegmentOutdated(e,t))return;let i=this.formatSegmentKey(e);this.store?(await this.store.set(i,t),this.cache.delete(i)):this.cache.set(i,t),this.eventBus&&this.eventBus.emit("segment_stored",e)}async deleteFlag(e){let t=this.formatFlagKey(e);this.store&&await this.store.del(t),this.cache.delete(t),this.eventBus&&this.eventBus.emit("flag_deleted",e)}async deleteSegment(e){let t=this.formatSegmentKey(e);this.store&&await this.store.del(t),this.cache.delete(t),this.eventBus&&this.eventBus.emit("segment_deleted",e)}async getFlag(e,t=!0){let i=this.formatFlagKey(e),r=this.cache.get(i);if(r)return r;if(this.store)return r=await this.store.get(i),r&&t&&this.cache.set(i,r),r}async getSegment(e,t=!0){let i=this.formatSegmentKey(e),r=this.cache.get(i);if(r)return r;if(this.store)return r=await this.store.get(i),r&&t&&this.cache.set(i,r),r}async findFlagsBySegment(e){let t=[],i=this.cache.keys();this.store&&(i=await this.store.keys());for(let r of i){let n=await this.getFlag(r);if(!n)return[];for(let o of n==null?void 0:n.rules)for(let a of o==null?void 0:o.clauses)a.op===Z&&a.values.includes(e)&&t.push(n.feature)}return t}async isFlagOutdated(e,t){let i=await this.getFlag(e,!1);return(i==null?void 0:i.version)&&i.version>=(t==null?void 0:t.version)}async isSegmentOutdated(e,t){let i=await this.getSegment(e,!1);return(i==null?void 0:i.version)&&i.version>=(t==null?void 0:t.version)}formatFlagKey(e){return`flags/${e}`}formatSegmentKey(e){return`segments/${e}`}};var Kt=(s,e="1",t,i,r,n=!1)=>{let o=new Map,a,c=new K({...t,basePath:i.eventsUrl}),l=new re(c),h=i.logger,f=(v,T,A)=>{let y={target:v,featureConfig:T,variation:A,count:0},w=d(y),m=o.get(w);m?m.count++:(y.count=1,o.set(w,y))},d=v=>{let T=v.featureConfig.feature,A=v.variation.identifier,y=v.variation.value;return`${T}/${A}/${y}/${Ft}`},p=()=>{var y,w;if(!o){h.debug("No metrics data!");return}let v=[],T=[],A=new Map(o);o.clear();for(let m of A.values()){if(m.target&&!m.target.anonymous){let M=[];m.target.attributes&&(M=Object.entries(m.target.attributes).map(([Fe,$t])=>({key:Fe,value:$t})));let q=m.target.identifier;m.target.name&&(q=m.target.name);let W={identifier:m.target.identifier,name:q,attributes:M};v.push(W)}let V=[{key:bt,value:m.featureConfig.feature},{key:Rt,value:m.featureConfig.feature},{key:wt,value:m.variation.identifier},{key:_t,value:Ct},{key:Ot,value:It},{key:Pt,value:se},{key:xt,value:(w=(y=m==null?void 0:m.target)==null?void 0:y.identifier)!=null?w:null}],z={timestamp:Date.now(),count:m.count,metricsType:"FFMETRICS",attributes:V};T.push(z)}return{targetData:v,metricsData:T}},S=()=>{if(n)return;let v=p();v&&v.metricsData.length&&v.targetData.length&&(h.debug("Start sending metrics data"),l.postMetrics(s,e,v).then(T=>{h.debug("Metrics server returns: ",T.status),at(h),T.status>=400&&h.error("Error while sending metrics data with status code: ",T.status)}).catch(T=>{gt(`${T}`,h),h.debug("Metrics server returns error: ",T)}))};return{start:()=>{h.info("Starting MetricsProcessor with request interval: ",i.eventsSyncInterval),a=setInterval(S,i.eventsSyncInterval),r.emit("metrics_ready")},close:()=>{h.info("Closing MetricsProcessor"),clearInterval(a),S(),n=!0,h.info("MetricsProcessor closed"),lt(h)},enqueue:f}};Ie.default.defaults.timeout=3e4;_(Ie.default,{retries:3,retryDelay:_.exponentialDelay});var fe=(i=>(i.READY="ready",i.FAILED="failed",i.CHANGED="changed",i))(fe||{}),H=class{constructor(e,t={}){this.cluster="1";this.eventBus=new jt.default;this.initialized=!1;this.failure=!1;this.pollerReady=!1;this.streamReady=!1;this.metricReady=!1;this.closing=!1;this.sdkKey=e,this.options={...U,...t},this.log=this.options.logger,t.pollInterval<U.pollInterval&&(this.options.pollInterval=U.pollInterval,this.log.warn(`Polling interval cannot be lower than ${U.pollInterval} ms`)),t.eventsSyncInterval<U.eventsSyncInterval&&(this.options.eventsSyncInterval=U.eventsSyncInterval,this.log.warn(`Events sync interval cannot be lower than ${U.eventsSyncInterval} ms`)),this.configuration=new K({basePath:this.options.baseUrl,baseOptions:{headers:{"User-Agent":`NodeJsSDK/${se}`}}}),this.repository=new ue(this.options.cache,this.options.store,this.eventBus),this.evaluator=new he(this.repository,this.log),this.api=new ie(this.configuration),this.processEvents(),this.run()}processEvents(){this.eventBus.on("poller_ready",()=>{this.initialize(0)}),this.eventBus.on("poller_error",()=>{this.failure=!0,this.eventBus.emit("failed")}),this.eventBus.on("stream_ready",()=>{this.initialize(1)}),this.eventBus.on("stream_retrying",()=>{this.failure=!0,this.log.error("Issue with streaming: falling back to polling while the SDK attempts to reconnect"),this.closing||this.pollProcessor.start()}),this.eventBus.on("stream_error",()=>{this.failure=!0,this.log.error("Unrecoverable issue with streaming: falling back to polling"),this.closing||this.pollProcessor.start(),this.eventBus.emit("failed")}),this.eventBus.on("metrics_ready",()=>{this.initialize(2)}),this.eventBus.on("metrics_error",()=>{this.failure=!0,this.eventBus.emit("failed")}),this.eventBus.on("stream_connected",()=>{this.pollProcessor.stop()}),this.eventBus.on("stream_disconnected",()=>{this.closing||this.pollProcessor.start()});for(let e of Object.values(Oe))this.eventBus.on(e,t=>{switch(e){case"flag_stored":case"flag_deleted":this.eventBus.emit("changed",t);break;case"segment_stored":case"segment_deleted":this.repository.findFlagsBySegment(t).then(i=>{i.forEach(r=>this.eventBus.emit("changed",r))});break}})}on(e,t){let i=[];for(let r of Object.values(fe))i.push(r);i.includes(e)&&this.eventBus.on(e,t)}off(e,t){e?this.eventBus.off(e,t):this.close()}async authenticate(){if(!this.sdkKey){Ze(this.log),this.failure=!0;return}try{let e=await this.api.authenticate({apiKey:this.sdkKey});this.authToken=e.data.authToken,this.configuration.accessToken=this.authToken;let t=(0,Gt.default)(this.authToken);t.environment||(this.failure=!0,this.log.error('Error while authenticating, err: the JWT token has missing claim "environmentUUID" ')),this.environment=t.environment,this.cluster=t.clusterIdentifier||"1"}catch(e){this.failure=!0,this.log.error("Error while authenticating, err: ",e),ct(this.log),ht(this.log),this.eventBus.emit("failed",e)}}waitForInitialization(){return this.waitForInitializePromise||(this.initialized?(this.waitForInitializePromise=Promise.resolve(this),Se(this.log)):!this.initialized&&this.failure?this.waitForInitializePromise=Promise.resolve(this):this.waitForInitializePromise=new Promise((e,t)=>{this.eventBus.once("ready",()=>{setTimeout(()=>e(this),0)}),this.eventBus.once("failed",t)})),this.waitForInitializePromise}initialize(e){switch(e){case 0:this.pollerReady=!0,this.log.debug("PollingProcessor ready"),et(this.options.pollInterval,this.log);break;case 1:this.streamReady=!0,this.log.debug("StreamingProcessor ready"),rt(this.log);break;case 2:this.metricReady=!0,this.log.debug("MetricsProcessor ready"),ot(this.options.eventsSyncInterval,this.log);break}this.options.enableStream&&!this.streamReady||this.options.enableAnalytics&&!this.metricReady||this.pollerReady&&this.eventBus.emit("ready")}async run(){await this.authenticate(),!this.failure&&(this.pollProcessor=new ne(this.environment,this.cluster,this.api,this.options,this.eventBus,this.repository),this.pollProcessor.start(),this.options.enableStream&&(this.streamProcessor=new oe(this.api,this.sdkKey,this.environment,this.authToken,this.options,this.cluster,this.eventBus,this.repository),this.streamProcessor.start()),this.options.enableAnalytics&&(this.metricsProcessor=Kt(this.environment,this.cluster,this.configuration,this.options,this.eventBus),this.metricsProcessor.start()),this.log.info("finished setting up processors"),this.initialized=!0,Se(this.log))}boolVariation(e,t,i=!1){return this.initialized?this.evaluator.boolVariation(e,t,i,(r,n,o)=>{this.metricsProcessor&&this.metricsProcessor.enqueue(n,r,o)}):(D(e,t,i.toString(),this.log),Promise.resolve(i))}stringVariation(e,t,i=""){return this.initialized?this.evaluator.stringVariation(e,t,i,(r,n,o)=>{this.metricsProcessor&&this.metricsProcessor.enqueue(n,r,o)}):(D(e,t,i.toString(),this.log),Promise.resolve(i))}numberVariation(e,t,i=0){return this.initialized?this.evaluator.numberVariation(e,t,i,(r,n,o)=>{this.metricsProcessor&&this.metricsProcessor.enqueue(n,r,o)}):(D(e,t,i.toString(),this.log),Promise.resolve(i))}jsonVariation(e,t,i={}){return this.initialized?this.evaluator.jsonVariation(e,t,i,(r,n,o)=>{this.metricsProcessor&&this.metricsProcessor.enqueue(n,r,o)}):(D(e,t,i.toString(),this.log),Promise.resolve(i))}close(){tt(this.log),this.closing=!0,this.pollProcessor.close(),this.streamProcessor&&this.streamProcessor.close(),this.metricsProcessor&&this.metricsProcessor.close(),this.eventBus.removeAllListeners(),this.closing=!1,it(this.log)}};var Ri={instance:void 0,init:function(s,e){this.instance||(this.instance=new H(s,e))},waitForInitialization:function(){return this.instance.waitForInitialization()},boolVariation:function(s,e,t=!1){return this.instance.boolVariation(s,e,t)},stringVariation:function(s,e,t=""){return this.instance.stringVariation(s,e,t)},numberVariation:function(s,e,t=0){return this.instance.numberVariation(s,e,t)},jsonVariation:function(s,e,t=""){return this.instance.jsonVariation(s,e,t)},on:function(s,e){this.instance.on(s,e)},off:function(s,e){this.instance.off(s,e)},close:function(){return this.instance.close()}};0&&(module.exports={Client,Event,FileStore,LRU}); | ||
//# sourceMappingURL=index.js.map |
import { Query, Target } from './types'; | ||
import { FeatureConfig, Variation } from './openapi'; | ||
import { ConsoleLog } from './log'; | ||
declare type Callback = (fc: FeatureConfig, target: Target, variation: Variation) => void; | ||
type Callback = (fc: FeatureConfig, target: Target, variation: Variation) => void; | ||
export declare class Evaluator { | ||
@@ -6,0 +6,0 @@ private query; |
@@ -25,1 +25,2 @@ import { Logger } from './log'; | ||
export declare function warnDefaultVariationServed(flag: string, target: Target, defaultValue: string, logger: Logger): void; | ||
export declare function warnBucketByAttributeNotFound(bucketBy: string, usingValue: string, logger: Logger): void; |
import { Logger } from './log'; | ||
import { FeatureConfig, Segment } from './openapi'; | ||
export declare type Type = boolean | string | number | Record<string, unknown>; | ||
export type Type = boolean | string | number | Record<string, unknown>; | ||
export interface Options { | ||
@@ -5,0 +5,0 @@ baseUrl?: string; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.3.7"; | ||
export declare const VERSION = "1.4.0"; |
{ | ||
"_from": "asynckit@^0.4.0", | ||
"_id": "asynckit@0.4.0", | ||
"_inBundle": false, | ||
"_integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", | ||
"_location": "/asynckit", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "range", | ||
"registry": true, | ||
"raw": "asynckit@^0.4.0", | ||
"name": "asynckit", | ||
"escapedName": "asynckit", | ||
"rawSpec": "^0.4.0", | ||
"saveSpec": null, | ||
"fetchSpec": "^0.4.0" | ||
"name": "asynckit", | ||
"version": "0.4.0", | ||
"description": "Minimal async jobs utility library, with streams support", | ||
"main": "index.js", | ||
"scripts": { | ||
"clean": "rimraf coverage", | ||
"lint": "eslint *.js lib/*.js test/*.js", | ||
"test": "istanbul cover --reporter=json tape -- 'test/test-*.js' | tap-spec", | ||
"win-test": "tape test/test-*.js", | ||
"browser": "browserify -t browserify-istanbul test/lib/browserify_adjustment.js test/test-*.js | obake --coverage | tap-spec", | ||
"report": "istanbul report", | ||
"size": "browserify index.js | size-table asynckit", | ||
"debug": "tape test/test-*.js" | ||
}, | ||
"_requiredBy": [ | ||
"/form-data", | ||
"/jsdom/form-data" | ||
"pre-commit": [ | ||
"clean", | ||
"lint", | ||
"test", | ||
"browser", | ||
"report", | ||
"size" | ||
], | ||
"_resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", | ||
"_shasum": "c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79", | ||
"_spec": "asynckit@^0.4.0", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/form-data", | ||
"author": { | ||
"name": "Alex Indigo", | ||
"email": "iam@alexindigo.com" | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/alexindigo/asynckit.git" | ||
}, | ||
"keywords": [ | ||
"async", | ||
"jobs", | ||
"parallel", | ||
"serial", | ||
"iterator", | ||
"array", | ||
"object", | ||
"stream", | ||
"destroy", | ||
"terminate", | ||
"abort" | ||
], | ||
"author": "Alex Indigo <iam@alexindigo.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/alexindigo/asynckit/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"dependencies": {}, | ||
"deprecated": false, | ||
"description": "Minimal async jobs utility library, with streams support", | ||
"homepage": "https://github.com/alexindigo/asynckit#readme", | ||
"devDependencies": { | ||
@@ -52,42 +62,3 @@ "browserify": "^13.0.0", | ||
}, | ||
"homepage": "https://github.com/alexindigo/asynckit#readme", | ||
"keywords": [ | ||
"async", | ||
"jobs", | ||
"parallel", | ||
"serial", | ||
"iterator", | ||
"array", | ||
"object", | ||
"stream", | ||
"destroy", | ||
"terminate", | ||
"abort" | ||
], | ||
"license": "MIT", | ||
"main": "index.js", | ||
"name": "asynckit", | ||
"pre-commit": [ | ||
"clean", | ||
"lint", | ||
"test", | ||
"browser", | ||
"report", | ||
"size" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/alexindigo/asynckit.git" | ||
}, | ||
"scripts": { | ||
"browser": "browserify -t browserify-istanbul test/lib/browserify_adjustment.js test/test-*.js | obake --coverage | tap-spec", | ||
"clean": "rimraf coverage", | ||
"debug": "tape test/test-*.js", | ||
"lint": "eslint *.js lib/*.js test/*.js", | ||
"report": "istanbul report", | ||
"size": "browserify index.js | size-table asynckit", | ||
"test": "istanbul cover --reporter=json tape -- 'test/test-*.js' | tap-spec", | ||
"win-test": "tape test/test-*.js" | ||
}, | ||
"version": "0.4.0" | ||
"dependencies": {} | ||
} |
{ | ||
"_from": "axios@^1.6.1", | ||
"_id": "axios@1.6.1", | ||
"_inBundle": false, | ||
"_integrity": "sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==", | ||
"_location": "/axios", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "range", | ||
"registry": true, | ||
"raw": "axios@^1.6.1", | ||
"name": "axios", | ||
"escapedName": "axios", | ||
"rawSpec": "^1.6.1", | ||
"saveSpec": null, | ||
"fetchSpec": "^1.6.1" | ||
"name": "axios", | ||
"version": "1.6.1", | ||
"description": "Promise based HTTP client for the browser and node.js", | ||
"main": "index.js", | ||
"exports": { | ||
".": { | ||
"types": { | ||
"require": "./index.d.cts", | ||
"default": "./index.d.ts" | ||
}, | ||
"browser": { | ||
"require": "./dist/browser/axios.cjs", | ||
"default": "./index.js" | ||
}, | ||
"default": { | ||
"require": "./dist/node/axios.cjs", | ||
"default": "./index.js" | ||
} | ||
}, | ||
"./lib/adapters/http.js": "./lib/adapters/http.js", | ||
"./lib/adapters/xhr.js": "./lib/adapters/xhr.js", | ||
"./unsafe/*": "./lib/*", | ||
"./unsafe/core/settle.js": "./lib/core/settle.js", | ||
"./unsafe/core/buildFullPath.js": "./lib/core/buildFullPath.js", | ||
"./unsafe/helpers/isAbsoluteURL.js": "./lib/helpers/isAbsoluteURL.js", | ||
"./unsafe/helpers/buildURL.js": "./lib/helpers/buildURL.js", | ||
"./unsafe/helpers/combineURLs.js": "./lib/helpers/combineURLs.js", | ||
"./unsafe/adapters/http.js": "./lib/adapters/http.js", | ||
"./unsafe/adapters/xhr.js": "./lib/adapters/xhr.js", | ||
"./unsafe/utils.js": "./lib/utils.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"_requiredBy": [ | ||
"/" | ||
], | ||
"_resolved": "https://registry.npmjs.org/axios/-/axios-1.6.1.tgz", | ||
"_shasum": "76550d644bf0a2d469a01f9244db6753208397d7", | ||
"_spec": "axios@^1.6.1", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk", | ||
"author": { | ||
"name": "Matt Zabriskie" | ||
"type": "module", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint && npm run test:exports", | ||
"test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js", | ||
"test:dtslint": "dtslint --localTs node_modules/typescript/lib", | ||
"test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit", | ||
"test:exports": "node bin/ssl_hotfix.js mocha test/module/test.js --timeout 30000 --exit", | ||
"test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run", | ||
"test:karma:firefox": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: Browsers=Firefox karma start karma.conf.cjs --single-run", | ||
"test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs", | ||
"test:build:version": "node ./bin/check-build-version.js", | ||
"start": "node ./sandbox/server.js", | ||
"preversion": "gulp version", | ||
"version": "npm run build && git add dist && git add package.json", | ||
"prepublishOnly": "npm run test:build:version", | ||
"postpublish": "git push && git push --tags", | ||
"build": "gulp clear && cross-env NODE_ENV=production rollup -c -m", | ||
"examples": "node ./examples/server.js", | ||
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | ||
"fix": "eslint --fix lib/**/*.js", | ||
"prepare": "husky install && npm run prepare:hooks", | ||
"prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\"", | ||
"release:dry": "release-it --dry-run --no-npm", | ||
"release:info": "release-it --release-version", | ||
"release:beta:no-npm": "release-it --preRelease=beta --no-npm", | ||
"release:beta": "release-it --preRelease=beta", | ||
"release:no-npm": "release-it --no-npm", | ||
"release:changelog:fix": "node ./bin/injectContributorsList.js && git add CHANGELOG.md", | ||
"release": "release-it" | ||
}, | ||
"browser": { | ||
"./lib/adapters/http.js": "./lib/helpers/null.js", | ||
"./lib/platform/node/index.js": "./lib/platform/browser/index.js", | ||
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js" | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/axios/axios.git" | ||
}, | ||
"keywords": [ | ||
"xhr", | ||
"http", | ||
"ajax", | ||
"promise", | ||
"node" | ||
], | ||
"author": "Matt Zabriskie", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/axios/axios/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"bundlesize": [ | ||
{ | ||
"path": "./dist/axios.min.js", | ||
"threshold": "5kB" | ||
} | ||
], | ||
"commitlint": { | ||
"rules": { | ||
"header-max-length": [ | ||
2, | ||
"always", | ||
130 | ||
] | ||
}, | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Matt Zabriskie", | ||
"url": "https://github.com/mzabriskie" | ||
}, | ||
{ | ||
"name": "Nick Uraltsev", | ||
"url": "https://github.com/nickuraltsev" | ||
}, | ||
{ | ||
"name": "Jay", | ||
"url": "https://github.com/jasonsaayman" | ||
}, | ||
{ | ||
"name": "Dmitriy Mozgovoy", | ||
"url": "https://github.com/DigitalBrainJS" | ||
}, | ||
{ | ||
"name": "Emily Morehouse", | ||
"url": "https://github.com/emilyemorehouse" | ||
}, | ||
{ | ||
"name": "Rubén Norte", | ||
"url": "https://github.com/rubennorte" | ||
}, | ||
{ | ||
"name": "Justin Beckwith", | ||
"url": "https://github.com/JustinBeckwith" | ||
}, | ||
{ | ||
"name": "Martti Laine", | ||
"url": "https://github.com/codeclown" | ||
}, | ||
{ | ||
"name": "Xianming Zhong", | ||
"url": "https://github.com/chinesedfan" | ||
}, | ||
{ | ||
"name": "Rikki Gibson", | ||
"url": "https://github.com/RikkiGibson" | ||
}, | ||
{ | ||
"name": "Remco Haszing", | ||
"url": "https://github.com/remcohaszing" | ||
}, | ||
{ | ||
"name": "Yasu Flores", | ||
"url": "https://github.com/yasuf" | ||
}, | ||
{ | ||
"name": "Ben Carp", | ||
"url": "https://github.com/carpben" | ||
} | ||
], | ||
"dependencies": { | ||
"follow-redirects": "^1.15.0", | ||
"form-data": "^4.0.0", | ||
"proxy-from-env": "^1.1.0" | ||
}, | ||
"deprecated": false, | ||
"description": "Promise based HTTP client for the browser and node.js", | ||
"homepage": "https://axios-http.com", | ||
"devDependencies": { | ||
@@ -174,42 +140,37 @@ "@babel/core": "^7.18.2", | ||
}, | ||
"exports": { | ||
".": { | ||
"types": { | ||
"require": "./index.d.cts", | ||
"default": "./index.d.ts" | ||
}, | ||
"browser": { | ||
"require": "./dist/browser/axios.cjs", | ||
"default": "./index.js" | ||
}, | ||
"default": { | ||
"require": "./dist/node/axios.cjs", | ||
"default": "./index.js" | ||
} | ||
}, | ||
"./lib/adapters/http.js": "./lib/adapters/http.js", | ||
"./lib/adapters/xhr.js": "./lib/adapters/xhr.js", | ||
"./unsafe/*": "./lib/*", | ||
"./unsafe/core/settle.js": "./lib/core/settle.js", | ||
"./unsafe/core/buildFullPath.js": "./lib/core/buildFullPath.js", | ||
"./unsafe/helpers/isAbsoluteURL.js": "./lib/helpers/isAbsoluteURL.js", | ||
"./unsafe/helpers/buildURL.js": "./lib/helpers/buildURL.js", | ||
"./unsafe/helpers/combineURLs.js": "./lib/helpers/combineURLs.js", | ||
"./unsafe/adapters/http.js": "./lib/adapters/http.js", | ||
"./unsafe/adapters/xhr.js": "./lib/adapters/xhr.js", | ||
"./unsafe/utils.js": "./lib/utils.js", | ||
"./package.json": "./package.json" | ||
"browser": { | ||
"./lib/adapters/http.js": "./lib/helpers/null.js", | ||
"./lib/platform/node/index.js": "./lib/platform/browser/index.js", | ||
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js" | ||
}, | ||
"homepage": "https://axios-http.com", | ||
"jsdelivr": "dist/axios.min.js", | ||
"keywords": [ | ||
"xhr", | ||
"http", | ||
"ajax", | ||
"promise", | ||
"node" | ||
"unpkg": "dist/axios.min.js", | ||
"typings": "./index.d.ts", | ||
"dependencies": { | ||
"follow-redirects": "^1.15.0", | ||
"form-data": "^4.0.0", | ||
"proxy-from-env": "^1.1.0" | ||
}, | ||
"bundlesize": [ | ||
{ | ||
"path": "./dist/axios.min.js", | ||
"threshold": "5kB" | ||
} | ||
], | ||
"license": "MIT", | ||
"main": "index.js", | ||
"name": "axios", | ||
"contributors": [ | ||
"Matt Zabriskie (https://github.com/mzabriskie)", | ||
"Nick Uraltsev (https://github.com/nickuraltsev)", | ||
"Jay (https://github.com/jasonsaayman)", | ||
"Dmitriy Mozgovoy (https://github.com/DigitalBrainJS)", | ||
"Emily Morehouse (https://github.com/emilyemorehouse)", | ||
"Rubén Norte (https://github.com/rubennorte)", | ||
"Justin Beckwith (https://github.com/JustinBeckwith)", | ||
"Martti Laine (https://github.com/codeclown)", | ||
"Xianming Zhong (https://github.com/chinesedfan)", | ||
"Rikki Gibson (https://github.com/RikkiGibson)", | ||
"Remco Haszing (https://github.com/remcohaszing)", | ||
"Yasu Flores (https://github.com/yasuf)", | ||
"Ben Carp (https://github.com/carpben)" | ||
], | ||
"sideEffects": false, | ||
"release-it": { | ||
@@ -246,41 +207,14 @@ "git": { | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/axios/axios.git" | ||
}, | ||
"scripts": { | ||
"build": "gulp clear && cross-env NODE_ENV=production rollup -c -m", | ||
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | ||
"examples": "node ./examples/server.js", | ||
"fix": "eslint --fix lib/**/*.js", | ||
"postpublish": "git push && git push --tags", | ||
"prepare": "husky install && npm run prepare:hooks", | ||
"prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\"", | ||
"prepublishOnly": "npm run test:build:version", | ||
"preversion": "gulp version", | ||
"release": "release-it", | ||
"release:beta": "release-it --preRelease=beta", | ||
"release:beta:no-npm": "release-it --preRelease=beta --no-npm", | ||
"release:changelog:fix": "node ./bin/injectContributorsList.js && git add CHANGELOG.md", | ||
"release:dry": "release-it --dry-run --no-npm", | ||
"release:info": "release-it --release-version", | ||
"release:no-npm": "release-it --no-npm", | ||
"start": "node ./sandbox/server.js", | ||
"test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint && npm run test:exports", | ||
"test:build:version": "node ./bin/check-build-version.js", | ||
"test:dtslint": "dtslint --localTs node_modules/typescript/lib", | ||
"test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js", | ||
"test:exports": "node bin/ssl_hotfix.js mocha test/module/test.js --timeout 30000 --exit", | ||
"test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run", | ||
"test:karma:firefox": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: Browsers=Firefox karma start karma.conf.cjs --single-run", | ||
"test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs", | ||
"test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit", | ||
"version": "npm run build && git add dist && git add package.json" | ||
}, | ||
"sideEffects": false, | ||
"type": "module", | ||
"types": "index.d.ts", | ||
"typings": "./index.d.ts", | ||
"unpkg": "dist/axios.min.js", | ||
"version": "1.6.1" | ||
} | ||
"commitlint": { | ||
"rules": { | ||
"header-max-length": [ | ||
2, | ||
"always", | ||
130 | ||
] | ||
}, | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
} | ||
} |
{ | ||
"_from": "combined-stream@^1.0.8", | ||
"_id": "combined-stream@1.0.8", | ||
"_inBundle": false, | ||
"_integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", | ||
"_location": "/combined-stream", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "range", | ||
"registry": true, | ||
"raw": "combined-stream@^1.0.8", | ||
"name": "combined-stream", | ||
"escapedName": "combined-stream", | ||
"rawSpec": "^1.0.8", | ||
"saveSpec": null, | ||
"fetchSpec": "^1.0.8" | ||
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)", | ||
"name": "combined-stream", | ||
"description": "A stream that emits multiple other streams one after another.", | ||
"version": "1.0.8", | ||
"homepage": "https://github.com/felixge/node-combined-stream", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/felixge/node-combined-stream.git" | ||
}, | ||
"_requiredBy": [ | ||
"/form-data", | ||
"/jsdom/form-data" | ||
], | ||
"_resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", | ||
"_shasum": "c3d45a8b34fd730631a110a8a2520682b31d5a7f", | ||
"_spec": "combined-stream@^1.0.8", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/form-data", | ||
"author": { | ||
"name": "Felix Geisendörfer", | ||
"email": "felix@debuggable.com", | ||
"url": "http://debuggable.com/" | ||
"main": "./lib/combined_stream", | ||
"scripts": { | ||
"test": "node test/run.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/felixge/node-combined-stream/issues" | ||
"engines": { | ||
"node": ">= 0.8" | ||
}, | ||
"bundleDependencies": false, | ||
"dependencies": { | ||
"delayed-stream": "~1.0.0" | ||
}, | ||
"deprecated": false, | ||
"description": "A stream that emits multiple other streams one after another.", | ||
"devDependencies": { | ||
"far": "~0.0.7" | ||
}, | ||
"engines": { | ||
"node": ">= 0.8" | ||
}, | ||
"homepage": "https://github.com/felixge/node-combined-stream", | ||
"license": "MIT", | ||
"main": "./lib/combined_stream", | ||
"name": "combined-stream", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/felixge/node-combined-stream.git" | ||
}, | ||
"scripts": { | ||
"test": "node test/run.js" | ||
}, | ||
"version": "1.0.8" | ||
"license": "MIT" | ||
} |
{ | ||
"_from": "debug@^4.1.1", | ||
"_id": "debug@4.3.4", | ||
"_inBundle": false, | ||
"_integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", | ||
"_location": "/debug", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "range", | ||
"registry": true, | ||
"raw": "debug@^4.1.1", | ||
"name": "debug", | ||
"escapedName": "debug", | ||
"rawSpec": "^4.1.1", | ||
"saveSpec": null, | ||
"fetchSpec": "^4.1.1" | ||
"name": "debug", | ||
"version": "4.3.4", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/debug-js/debug.git" | ||
}, | ||
"_requiredBy": [ | ||
"/@babel/core", | ||
"/@babel/traverse", | ||
"/@eslint/eslintrc", | ||
"/@humanwhocodes/config-array", | ||
"/@typescript-eslint/eslint-plugin", | ||
"/@typescript-eslint/parser", | ||
"/@typescript-eslint/typescript-estree", | ||
"/agent-base", | ||
"/eslint", | ||
"/http-proxy-agent", | ||
"/https-proxy-agent", | ||
"/istanbul-lib-source-maps", | ||
"/keyv-file" | ||
"description": "Lightweight debugging utility for Node.js and the browser", | ||
"keywords": [ | ||
"debug", | ||
"log", | ||
"debugger" | ||
], | ||
"_resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", | ||
"_shasum": "1319f6579357f2338d3337d2cdd4914bb5dcc865", | ||
"_spec": "debug@^4.1.1", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/keyv-file", | ||
"author": { | ||
"name": "Josh Junon", | ||
"email": "josh.junon@protonmail.com" | ||
}, | ||
"browser": "./src/browser.js", | ||
"bugs": { | ||
"url": "https://github.com/debug-js/debug/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"files": [ | ||
"src", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"author": "Josh Junon <josh.junon@protonmail.com>", | ||
"contributors": [ | ||
{ | ||
"name": "TJ Holowaychuk", | ||
"email": "tj@vision-media.ca" | ||
}, | ||
{ | ||
"name": "Nathan Rajlich", | ||
"email": "nathan@tootallnate.net", | ||
"url": "http://n8.io" | ||
}, | ||
{ | ||
"name": "Andrew Rhyne", | ||
"email": "rhyneandrew@gmail.com" | ||
} | ||
"TJ Holowaychuk <tj@vision-media.ca>", | ||
"Nathan Rajlich <nathan@tootallnate.net> (http://n8.io)", | ||
"Andrew Rhyne <rhyneandrew@gmail.com>" | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
"lint": "xo", | ||
"test": "npm run test:node && npm run test:browser && npm run lint", | ||
"test:node": "istanbul cover _mocha -- test.js", | ||
"test:browser": "karma start --single-run", | ||
"test:coverage": "cat ./coverage/lcov.info | coveralls" | ||
}, | ||
"dependencies": { | ||
"ms": "2.1.2" | ||
}, | ||
"deprecated": false, | ||
"description": "Lightweight debugging utility for Node.js and the browser", | ||
"devDependencies": { | ||
@@ -79,19 +49,2 @@ "brfs": "^2.0.1", | ||
}, | ||
"engines": { | ||
"node": ">=6.0" | ||
}, | ||
"files": [ | ||
"src", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"homepage": "https://github.com/debug-js/debug#readme", | ||
"keywords": [ | ||
"debug", | ||
"log", | ||
"debugger" | ||
], | ||
"license": "MIT", | ||
"main": "./src/index.js", | ||
"name": "debug", | ||
"peerDependenciesMeta": { | ||
@@ -102,14 +55,7 @@ "supports-color": { | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/debug-js/debug.git" | ||
}, | ||
"scripts": { | ||
"lint": "xo", | ||
"test": "npm run test:node && npm run test:browser && npm run lint", | ||
"test:browser": "karma start --single-run", | ||
"test:coverage": "cat ./coverage/lcov.info | coveralls", | ||
"test:node": "istanbul cover _mocha -- test.js" | ||
}, | ||
"version": "4.3.4" | ||
"main": "./src/index.js", | ||
"browser": "./src/browser.js", | ||
"engines": { | ||
"node": ">=6.0" | ||
} | ||
} |
{ | ||
"_from": "delayed-stream@~1.0.0", | ||
"_id": "delayed-stream@1.0.0", | ||
"_inBundle": false, | ||
"_integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", | ||
"_location": "/delayed-stream", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "range", | ||
"registry": true, | ||
"raw": "delayed-stream@~1.0.0", | ||
"name": "delayed-stream", | ||
"escapedName": "delayed-stream", | ||
"rawSpec": "~1.0.0", | ||
"saveSpec": null, | ||
"fetchSpec": "~1.0.0" | ||
}, | ||
"_requiredBy": [ | ||
"/combined-stream" | ||
], | ||
"_resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", | ||
"_shasum": "df3ae199acadfb7d440aaae0b29e2272b24ec619", | ||
"_spec": "delayed-stream@~1.0.0", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/combined-stream", | ||
"author": { | ||
"name": "Felix Geisendörfer", | ||
"email": "felix@debuggable.com", | ||
"url": "http://debuggable.com/" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/felixge/node-delayed-stream/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)", | ||
"contributors": [ | ||
{ | ||
"name": "Mike Atkins", | ||
"email": "apeherder@gmail.com" | ||
} | ||
"Mike Atkins <apeherder@gmail.com>" | ||
], | ||
"dependencies": {}, | ||
"deprecated": false, | ||
"name": "delayed-stream", | ||
"description": "Buffers events from a stream until you are ready to handle them.", | ||
"devDependencies": { | ||
"fake": "0.2.0", | ||
"far": "0.0.1" | ||
}, | ||
"engines": { | ||
"node": ">=0.4.0" | ||
}, | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/felixge/node-delayed-stream", | ||
"license": "MIT", | ||
"main": "./lib/delayed_stream", | ||
"name": "delayed-stream", | ||
"repository": { | ||
@@ -58,6 +15,14 @@ "type": "git", | ||
}, | ||
"main": "./lib/delayed_stream", | ||
"engines": { | ||
"node": ">=0.4.0" | ||
}, | ||
"scripts": { | ||
"test": "make test" | ||
}, | ||
"version": "1.0.0" | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"fake": "0.2.0", | ||
"far": "0.0.1" | ||
} | ||
} |
@@ -57,3 +57,3 @@ var fs = require('fs') | ||
if (!err) { | ||
retry() | ||
resetQueue() | ||
} | ||
@@ -76,3 +76,3 @@ | ||
fs$closeSync.apply(fs, arguments) | ||
retry() | ||
resetQueue() | ||
} | ||
@@ -119,10 +119,9 @@ | ||
function go$readFile (path, options, cb) { | ||
function go$readFile (path, options, cb, startTime) { | ||
return fs$readFile(path, options, function (err) { | ||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) | ||
enqueue([go$readFile, [path, options, cb]]) | ||
enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()]) | ||
else { | ||
if (typeof cb === 'function') | ||
cb.apply(this, arguments) | ||
retry() | ||
} | ||
@@ -141,10 +140,9 @@ }) | ||
function go$writeFile (path, data, options, cb) { | ||
function go$writeFile (path, data, options, cb, startTime) { | ||
return fs$writeFile(path, data, options, function (err) { | ||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) | ||
enqueue([go$writeFile, [path, data, options, cb]]) | ||
enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]) | ||
else { | ||
if (typeof cb === 'function') | ||
cb.apply(this, arguments) | ||
retry() | ||
} | ||
@@ -164,10 +162,9 @@ }) | ||
function go$appendFile (path, data, options, cb) { | ||
function go$appendFile (path, data, options, cb, startTime) { | ||
return fs$appendFile(path, data, options, function (err) { | ||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) | ||
enqueue([go$appendFile, [path, data, options, cb]]) | ||
enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]) | ||
else { | ||
if (typeof cb === 'function') | ||
cb.apply(this, arguments) | ||
retry() | ||
} | ||
@@ -186,11 +183,14 @@ }) | ||
} | ||
return fs$copyFile(src, dest, flags, function (err) { | ||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) | ||
enqueue([fs$copyFile, [src, dest, flags, cb]]) | ||
else { | ||
if (typeof cb === 'function') | ||
cb.apply(this, arguments) | ||
retry() | ||
} | ||
}) | ||
return go$copyFile(src, dest, flags, cb) | ||
function go$copyFile (src, dest, flags, cb, startTime) { | ||
return fs$copyFile(src, dest, flags, function (err) { | ||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) | ||
enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()]) | ||
else { | ||
if (typeof cb === 'function') | ||
cb.apply(this, arguments) | ||
} | ||
}) | ||
} | ||
} | ||
@@ -200,24 +200,38 @@ | ||
fs.readdir = readdir | ||
var noReaddirOptionVersions = /^v[0-5]\./ | ||
function readdir (path, options, cb) { | ||
var args = [path] | ||
if (typeof options !== 'function') { | ||
args.push(options) | ||
} else { | ||
cb = options | ||
} | ||
args.push(go$readdir$cb) | ||
if (typeof options === 'function') | ||
cb = options, options = null | ||
return go$readdir(args) | ||
var go$readdir = noReaddirOptionVersions.test(process.version) | ||
? function go$readdir (path, options, cb, startTime) { | ||
return fs$readdir(path, fs$readdirCallback( | ||
path, options, cb, startTime | ||
)) | ||
} | ||
: function go$readdir (path, options, cb, startTime) { | ||
return fs$readdir(path, options, fs$readdirCallback( | ||
path, options, cb, startTime | ||
)) | ||
} | ||
function go$readdir$cb (err, files) { | ||
if (files && files.sort) | ||
files.sort() | ||
return go$readdir(path, options, cb) | ||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) | ||
enqueue([go$readdir, [args]]) | ||
function fs$readdirCallback (path, options, cb, startTime) { | ||
return function (err, files) { | ||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) | ||
enqueue([ | ||
go$readdir, | ||
[path, options, cb], | ||
err, | ||
startTime || Date.now(), | ||
Date.now() | ||
]) | ||
else { | ||
if (files && files.sort) | ||
files.sort() | ||
else { | ||
if (typeof cb === 'function') | ||
cb.apply(this, arguments) | ||
retry() | ||
if (typeof cb === 'function') | ||
cb.call(this, err, files) | ||
} | ||
} | ||
@@ -227,6 +241,2 @@ } | ||
function go$readdir (args) { | ||
return fs$readdir.apply(fs, args) | ||
} | ||
if (process.version.substr(0, 4) === 'v0.8') { | ||
@@ -354,10 +364,9 @@ var legStreams = legacy(fs) | ||
function go$open (path, flags, mode, cb) { | ||
function go$open (path, flags, mode, cb, startTime) { | ||
return fs$open(path, flags, mode, function (err, fd) { | ||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) | ||
enqueue([go$open, [path, flags, mode, cb]]) | ||
enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()]) | ||
else { | ||
if (typeof cb === 'function') | ||
cb.apply(this, arguments) | ||
retry() | ||
} | ||
@@ -374,10 +383,76 @@ }) | ||
fs[gracefulQueue].push(elem) | ||
retry() | ||
} | ||
// keep track of the timeout between retry() calls | ||
var retryTimer | ||
// reset the startTime and lastTime to now | ||
// this resets the start of the 60 second overall timeout as well as the | ||
// delay between attempts so that we'll retry these jobs sooner | ||
function resetQueue () { | ||
var now = Date.now() | ||
for (var i = 0; i < fs[gracefulQueue].length; ++i) { | ||
// entries that are only a length of 2 are from an older version, don't | ||
// bother modifying those since they'll be retried anyway. | ||
if (fs[gracefulQueue][i].length > 2) { | ||
fs[gracefulQueue][i][3] = now // startTime | ||
fs[gracefulQueue][i][4] = now // lastTime | ||
} | ||
} | ||
// call retry to make sure we're actively processing the queue | ||
retry() | ||
} | ||
function retry () { | ||
// clear the timer and remove it to help prevent unintended concurrency | ||
clearTimeout(retryTimer) | ||
retryTimer = undefined | ||
if (fs[gracefulQueue].length === 0) | ||
return | ||
var elem = fs[gracefulQueue].shift() | ||
if (elem) { | ||
debug('RETRY', elem[0].name, elem[1]) | ||
elem[0].apply(null, elem[1]) | ||
var fn = elem[0] | ||
var args = elem[1] | ||
// these items may be unset if they were added by an older graceful-fs | ||
var err = elem[2] | ||
var startTime = elem[3] | ||
var lastTime = elem[4] | ||
// if we don't have a startTime we have no way of knowing if we've waited | ||
// long enough, so go ahead and retry this item now | ||
if (startTime === undefined) { | ||
debug('RETRY', fn.name, args) | ||
fn.apply(null, args) | ||
} else if (Date.now() - startTime >= 60000) { | ||
// it's been more than 60 seconds total, bail now | ||
debug('TIMEOUT', fn.name, args) | ||
var cb = args.pop() | ||
if (typeof cb === 'function') | ||
cb.call(null, err) | ||
} else { | ||
// the amount of time between the last attempt and right now | ||
var sinceAttempt = Date.now() - lastTime | ||
// the amount of time between when we first tried, and when we last tried | ||
// rounded up to at least 1 | ||
var sinceStart = Math.max(lastTime - startTime, 1) | ||
// backoff. wait longer than the total time we've been retrying, but only | ||
// up to a maximum of 100ms | ||
var desiredDelay = Math.min(sinceStart * 1.2, 100) | ||
// it's been long enough since the last retry, do it again | ||
if (sinceAttempt >= desiredDelay) { | ||
debug('RETRY', fn.name, args) | ||
fn.apply(null, args.concat([startTime])) | ||
} else { | ||
// if we can't do this job yet, push it to the end of the queue | ||
// and let the next iteration check again | ||
fs[gracefulQueue].push(elem) | ||
} | ||
} | ||
// schedule our next run if one isn't already scheduled | ||
if (retryTimer === undefined) { | ||
retryTimer = setTimeout(retry, 0) | ||
} | ||
} |
{ | ||
"name": "graceful-fs", | ||
"description": "A drop-in replacement for fs, making various improvements.", | ||
"version": "4.2.6", | ||
"version": "4.2.11", | ||
"repository": { | ||
@@ -41,3 +41,3 @@ "type": "git", | ||
"rimraf": "^2.2.8", | ||
"tap": "^12.7.0" | ||
"tap": "^16.3.4" | ||
}, | ||
@@ -50,3 +50,6 @@ "files": [ | ||
"clone.js" | ||
] | ||
], | ||
"tap": { | ||
"reporter": "classic" | ||
} | ||
} |
@@ -74,3 +74,3 @@ var constants = require('constants') | ||
// if lchmod/lchown do not exist, then make them no-ops | ||
if (!fs.lchmod) { | ||
if (fs.chmod && !fs.lchmod) { | ||
fs.lchmod = function (path, mode, cb) { | ||
@@ -81,3 +81,3 @@ if (cb) process.nextTick(cb) | ||
} | ||
if (!fs.lchown) { | ||
if (fs.chown && !fs.lchown) { | ||
fs.lchown = function (path, uid, gid, cb) { | ||
@@ -99,28 +99,34 @@ if (cb) process.nextTick(cb) | ||
if (platform === "win32") { | ||
fs.rename = (function (fs$rename) { return function (from, to, cb) { | ||
var start = Date.now() | ||
var backoff = 0; | ||
fs$rename(from, to, function CB (er) { | ||
if (er | ||
&& (er.code === "EACCES" || er.code === "EPERM") | ||
&& Date.now() - start < 60000) { | ||
setTimeout(function() { | ||
fs.stat(to, function (stater, st) { | ||
if (stater && stater.code === "ENOENT") | ||
fs$rename(from, to, CB); | ||
else | ||
cb(er) | ||
}) | ||
}, backoff) | ||
if (backoff < 100) | ||
backoff += 10; | ||
return; | ||
} | ||
if (cb) cb(er) | ||
}) | ||
}})(fs.rename) | ||
fs.rename = typeof fs.rename !== 'function' ? fs.rename | ||
: (function (fs$rename) { | ||
function rename (from, to, cb) { | ||
var start = Date.now() | ||
var backoff = 0; | ||
fs$rename(from, to, function CB (er) { | ||
if (er | ||
&& (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") | ||
&& Date.now() - start < 60000) { | ||
setTimeout(function() { | ||
fs.stat(to, function (stater, st) { | ||
if (stater && stater.code === "ENOENT") | ||
fs$rename(from, to, CB); | ||
else | ||
cb(er) | ||
}) | ||
}, backoff) | ||
if (backoff < 100) | ||
backoff += 10; | ||
return; | ||
} | ||
if (cb) cb(er) | ||
}) | ||
} | ||
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename) | ||
return rename | ||
})(fs.rename) | ||
} | ||
// if read() returns EAGAIN, then just try it again. | ||
fs.read = (function (fs$read) { | ||
fs.read = typeof fs.read !== 'function' ? fs.read | ||
: (function (fs$read) { | ||
function read (fd, buffer, offset, length, position, callback_) { | ||
@@ -146,3 +152,4 @@ var callback | ||
fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) { | ||
fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync | ||
: (function (fs$readSync) { return function (fd, buffer, offset, length, position) { | ||
var eagCounter = 0 | ||
@@ -206,3 +213,3 @@ while (true) { | ||
function patchLutimes (fs) { | ||
if (constants.hasOwnProperty("O_SYMLINK")) { | ||
if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) { | ||
fs.lutimes = function (path, at, mt, cb) { | ||
@@ -241,3 +248,3 @@ fs.open(path, constants.O_SYMLINK, function (er, fd) { | ||
} else { | ||
} else if (fs.futimes) { | ||
fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) } | ||
@@ -319,4 +326,6 @@ fs.lutimesSync = function () {} | ||
: orig.call(fs, target) | ||
if (stats.uid < 0) stats.uid += 0x100000000 | ||
if (stats.gid < 0) stats.gid += 0x100000000 | ||
if (stats) { | ||
if (stats.uid < 0) stats.uid += 0x100000000 | ||
if (stats.gid < 0) stats.gid += 0x100000000 | ||
} | ||
return stats; | ||
@@ -323,0 +332,0 @@ } |
@@ -33,5 +33,15 @@ # graceful-fs | ||
// now go and do stuff with it... | ||
fs.readFileSync('some-file-or-whatever') | ||
fs.readFile('some-file-or-whatever', (err, data) => { | ||
// Do stuff here. | ||
}) | ||
``` | ||
## Sync methods | ||
This module cannot intercept or handle `EMFILE` or `ENFILE` errors from sync | ||
methods. If you use sync methods which open file descriptors then you are | ||
responsible for dealing with any errors. | ||
This is a known limitation, not a bug. | ||
## Global Patching | ||
@@ -38,0 +48,0 @@ |
{ | ||
"_from": "json-buffer@3.0.1", | ||
"_id": "json-buffer@3.0.1", | ||
"_inBundle": false, | ||
"_integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", | ||
"_location": "/json-buffer", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"registry": true, | ||
"raw": "json-buffer@3.0.1", | ||
"name": "json-buffer", | ||
"escapedName": "json-buffer", | ||
"rawSpec": "3.0.1", | ||
"saveSpec": null, | ||
"fetchSpec": "3.0.1" | ||
}, | ||
"_requiredBy": [ | ||
"/keyv" | ||
], | ||
"_resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", | ||
"_shasum": "9338802a30d3b6605fbe0613e094008ca8c05a13", | ||
"_spec": "json-buffer@3.0.1", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/keyv", | ||
"author": { | ||
"name": "Dominic Tarr", | ||
"email": "dominic.tarr@gmail.com", | ||
"url": "http://dominictarr.com" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/dominictarr/json-buffer/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"deprecated": false, | ||
"name": "json-buffer", | ||
"description": "JSON parse & stringify that supports binary via bops & base64", | ||
"devDependencies": { | ||
"tape": "^4.6.3" | ||
}, | ||
"version": "3.0.1", | ||
"homepage": "https://github.com/dominictarr/json-buffer", | ||
"license": "MIT", | ||
"name": "json-buffer", | ||
"repository": { | ||
@@ -46,5 +10,10 @@ "type": "git", | ||
}, | ||
"devDependencies": { | ||
"tape": "^4.6.3" | ||
}, | ||
"scripts": { | ||
"test": "set -e; for t in test/*.js; do node $t; done" | ||
}, | ||
"author": "Dominic Tarr <dominic.tarr@gmail.com> (http://dominictarr.com)", | ||
"license": "MIT", | ||
"testling": { | ||
@@ -65,4 +34,3 @@ "files": "test/*.js", | ||
] | ||
}, | ||
"version": "3.0.1" | ||
} | ||
} |
{ | ||
"_from": "tslib@^1.9.3", | ||
"_id": "tslib@1.14.1", | ||
"_inBundle": false, | ||
"_integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", | ||
"_location": "/keyv-file/tslib", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "range", | ||
"registry": true, | ||
"raw": "tslib@^1.9.3", | ||
"name": "tslib", | ||
"escapedName": "tslib", | ||
"rawSpec": "^1.9.3", | ||
"saveSpec": null, | ||
"fetchSpec": "^1.9.3" | ||
}, | ||
"_requiredBy": [ | ||
"/keyv-file" | ||
], | ||
"_resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", | ||
"_shasum": "cf2d38bdc34a134bcaf1091c41f6619e2f672d00", | ||
"_spec": "tslib@^1.9.3", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/keyv-file", | ||
"author": { | ||
"name": "Microsoft Corp." | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Microsoft/TypeScript/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"deprecated": false, | ||
"description": "Runtime library for TypeScript helper functions", | ||
"exports": { | ||
".": { | ||
"module": "./tslib.es6.js", | ||
"import": "./modules/index.js", | ||
"default": "./tslib.js" | ||
"author": "Microsoft Corp.", | ||
"homepage": "https://www.typescriptlang.org/", | ||
"version": "1.14.1", | ||
"license": "0BSD", | ||
"description": "Runtime library for TypeScript helper functions", | ||
"keywords": [ | ||
"TypeScript", | ||
"Microsoft", | ||
"compiler", | ||
"language", | ||
"javascript", | ||
"tslib", | ||
"runtime" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/Microsoft/TypeScript/issues" | ||
}, | ||
"./": "./" | ||
}, | ||
"homepage": "https://www.typescriptlang.org/", | ||
"jsnext:main": "tslib.es6.js", | ||
"keywords": [ | ||
"TypeScript", | ||
"Microsoft", | ||
"compiler", | ||
"language", | ||
"javascript", | ||
"tslib", | ||
"runtime" | ||
], | ||
"license": "0BSD", | ||
"main": "tslib.js", | ||
"module": "tslib.es6.js", | ||
"name": "tslib", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Microsoft/tslib.git" | ||
}, | ||
"sideEffects": false, | ||
"typings": "tslib.d.ts", | ||
"version": "1.14.1" | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Microsoft/tslib.git" | ||
}, | ||
"main": "tslib.js", | ||
"module": "tslib.es6.js", | ||
"jsnext:main": "tslib.es6.js", | ||
"typings": "tslib.d.ts", | ||
"sideEffects": false, | ||
"exports": { | ||
".": { | ||
"module": "./tslib.es6.js", | ||
"import": "./modules/index.js", | ||
"default": "./tslib.js" | ||
}, | ||
"./": "./" | ||
} | ||
} |
{ | ||
"_from": "keyv-file@^0.2.0", | ||
"_id": "keyv-file@0.2.0", | ||
"_inBundle": false, | ||
"_integrity": "sha512-zUQ11eZRmilEUpV1gJSj8mBAHjyXpleQo1iCS0khb+GFRhiPfwavWgn4eDUKNlOyMZzmExnISl8HE1hNbim0gw==", | ||
"_location": "/keyv-file", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "range", | ||
"registry": true, | ||
"raw": "keyv-file@^0.2.0", | ||
"name": "keyv-file", | ||
"escapedName": "keyv-file", | ||
"rawSpec": "^0.2.0", | ||
"saveSpec": null, | ||
"fetchSpec": "^0.2.0" | ||
"name": "keyv-file", | ||
"version": "0.2.0", | ||
"description": "File storage adapter for Keyv, using msgpack to serialize data fast and small.", | ||
"main": "lib/index.js", | ||
"typings": "lib/index", | ||
"types": "./lib/index", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "tsc && ava", | ||
"preversion": "yarn test", | ||
"postversion": "git add -A && git push origin master --tags" | ||
}, | ||
"_requiredBy": [ | ||
"/" | ||
"files": [ | ||
"lib" | ||
], | ||
"_resolved": "https://registry.npmjs.org/keyv-file/-/keyv-file-0.2.0.tgz", | ||
"_shasum": "3442b07a00c1d7bd0242f4a91bcf498afbd6ea6a", | ||
"_spec": "keyv-file@^0.2.0", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk", | ||
"author": { | ||
"name": "zaaack" | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/zaaack/keyv-file.git" | ||
}, | ||
"keywords": [ | ||
"keyv", | ||
"fast", | ||
"storage", | ||
"cache", | ||
"simple" | ||
], | ||
"author": "zaaack", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/zaaack/keyv-file/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"dependencies": { | ||
"debug": "^4.1.1", | ||
"fs-extra": "^4.0.1", | ||
"tslib": "^1.9.3" | ||
}, | ||
"deprecated": false, | ||
"description": "File storage adapter for Keyv, using msgpack to serialize data fast and small.", | ||
"homepage": "https://github.com/zaaack/keyv-file#readme", | ||
"devDependencies": { | ||
@@ -48,29 +43,7 @@ "@types/debug": "^0.0.31", | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"homepage": "https://github.com/zaaack/keyv-file#readme", | ||
"keywords": [ | ||
"keyv", | ||
"fast", | ||
"storage", | ||
"cache", | ||
"simple" | ||
], | ||
"license": "MIT", | ||
"main": "lib/index.js", | ||
"name": "keyv-file", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/zaaack/keyv-file.git" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"postversion": "git add -A && git push origin master --tags", | ||
"preversion": "yarn test", | ||
"test": "tsc && ava" | ||
}, | ||
"types": "./lib/index", | ||
"typings": "lib/index", | ||
"version": "0.2.0" | ||
"dependencies": { | ||
"debug": "^4.1.1", | ||
"fs-extra": "^4.0.1", | ||
"tslib": "^1.9.3" | ||
} | ||
} |
{ | ||
"name": "keyv", | ||
"version": "4.0.3", | ||
"description": "Simple key-value storage with support for multiple backends", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "xo && nyc ava test/keyv.js", | ||
"test:full": "xo && nyc ava --serial", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
"xo": { | ||
"extends": "xo-lukechilds" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/lukechilds/keyv.git" | ||
}, | ||
"keywords": [ | ||
"key", | ||
"value", | ||
"store", | ||
"cache", | ||
"ttl" | ||
], | ||
"author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/lukechilds/keyv/issues" | ||
}, | ||
"homepage": "https://github.com/lukechilds/keyv", | ||
"dependencies": { | ||
"json-buffer": "3.0.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^2.2.0", | ||
"coveralls": "^3.0.0", | ||
"eslint-config-xo-lukechilds": "^1.0.0", | ||
"@keyv/mongo": "*", | ||
"@keyv/mysql": "*", | ||
"@keyv/postgres": "*", | ||
"@keyv/redis": "*", | ||
"@keyv/sqlite": "*", | ||
"@keyv/test-suite": "*", | ||
"nyc": "^14.1.1", | ||
"this": "^1.0.2", | ||
"timekeeper": "^2.0.0", | ||
"xo": "^0.25.3" | ||
} | ||
"name": "keyv", | ||
"version": "4.5.4", | ||
"description": "Simple key-value storage with support for multiple backends", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"build": "echo 'No build step required.'", | ||
"prepare": "yarn build", | ||
"test": "xo && c8 ava --serial", | ||
"test:ci": "xo && ava --serial", | ||
"clean": "rm -rf node_modules && rm -rf ./coverage && rm -rf ./test/testdb.sqlite" | ||
}, | ||
"xo": { | ||
"rules": { | ||
"unicorn/prefer-module": 0, | ||
"unicorn/prefer-node-protocol": 0, | ||
"@typescript-eslint/consistent-type-definitions": 0, | ||
"unicorn/no-typeof-undefined": 0, | ||
"unicorn/prefer-event-target": 0 | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jaredwray/keyv.git" | ||
}, | ||
"keywords": [ | ||
"key", | ||
"value", | ||
"store", | ||
"cache", | ||
"ttl" | ||
], | ||
"author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/jaredwray/keyv/issues" | ||
}, | ||
"homepage": "https://github.com/jaredwray/keyv", | ||
"dependencies": { | ||
"json-buffer": "3.0.1" | ||
}, | ||
"devDependencies": { | ||
"@keyv/test-suite": "*", | ||
"eslint": "^8.51.0", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"pify": "^5.0.0", | ||
"timekeeper": "^2.3.1", | ||
"tsd": "^0.29.0" | ||
}, | ||
"tsd": { | ||
"directory": "test" | ||
}, | ||
"types": "./src/index.d.ts", | ||
"files": [ | ||
"src" | ||
] | ||
} |
<h1 align="center"> | ||
<img width="250" src="https://rawgit.com/lukechilds/keyv/master/media/logo.svg" alt="keyv"> | ||
<img width="250" src="https://jaredwray.com/images/keyv.svg" alt="keyv"> | ||
<br> | ||
@@ -9,4 +9,4 @@ <br> | ||
[![Build Status](https://travis-ci.org/lukechilds/keyv.svg?branch=master)](https://travis-ci.org/lukechilds/keyv) | ||
[![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv?branch=master) | ||
[![build](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml/badge.svg)](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml) | ||
[![codecov](https://codecov.io/gh/jaredwray/keyv/branch/main/graph/badge.svg?token=bRzR3RyOXZ)](https://codecov.io/gh/jaredwray/keyv) | ||
[![npm](https://img.shields.io/npm/dm/keyv.svg)](https://www.npmjs.com/package/keyv) | ||
@@ -48,2 +48,3 @@ [![npm](https://img.shields.io/npm/v/keyv.svg)](https://www.npmjs.com/package/keyv) | ||
npm install --save @keyv/mysql | ||
npm install --save @keyv/etcd | ||
``` | ||
@@ -63,2 +64,3 @@ | ||
const keyv = new Keyv('mysql://user:pass@localhost:3306/dbname'); | ||
const keyv = new Keyv('etcd://localhost:2379'); | ||
@@ -106,11 +108,13 @@ // Handle DB connection errors | ||
The official storage adapters are covered by [over 150 integration tests](https://travis-ci.org/lukechilds/keyv/jobs/260418145) to guarantee consistent behaviour. They are lightweight, efficient wrappers over the DB clients making use of indexes and native TTLs where available. | ||
The official storage adapters are covered by [over 150 integration tests](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml) to guarantee consistent behaviour. They are lightweight, efficient wrappers over the DB clients making use of indexes and native TTLs where available. | ||
Database | Adapter | Native TTL | Status | ||
---|---|---|--- | ||
Redis | [@keyv/redis](https://github.com/lukechilds/keyv-redis) | Yes | [![Build Status](https://travis-ci.org/lukechilds/keyv-redis.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-redis) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-redis/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-redis?branch=master) | ||
MongoDB | [@keyv/mongo](https://github.com/lukechilds/keyv-mongo) | Yes | [![Build Status](https://travis-ci.org/lukechilds/keyv-mongo.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mongo) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mongo/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mongo?branch=master) | ||
SQLite | [@keyv/sqlite](https://github.com/lukechilds/keyv-sqlite) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-sqlite.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-sqlite) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-sqlite/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-sqlite?branch=master) | ||
PostgreSQL | [@keyv/postgres](https://github.com/lukechilds/keyv-postgres) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-postgres.svg?branch=master)](https://travis-ci.org/lukechildskeyv-postgreskeyv) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-postgres/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-postgres?branch=master) | ||
MySQL | [@keyv/mysql](https://github.com/lukechilds/keyv-mysql) | No | [![Build Status](https://travis-ci.org/lukechilds/keyv-mysql.svg?branch=master)](https://travis-ci.org/lukechilds/keyv-mysql) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/keyv-mysql/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/keyv-mysql?branch=master) | ||
Database | Adapter | Native TTL | ||
---|---|--- | ||
Redis | [@keyv/redis](https://github.com/jaredwray/keyv/tree/master/packages/redis) | Yes | ||
MongoDB | [@keyv/mongo](https://github.com/jaredwray/keyv/tree/master/packages/mongo) | Yes | ||
SQLite | [@keyv/sqlite](https://github.com/jaredwray/keyv/tree/master/packages/sqlite) | No | ||
PostgreSQL | [@keyv/postgres](https://github.com/jaredwray/keyv/tree/master/packages/postgres) | No | ||
MySQL | [@keyv/mysql](https://github.com/jaredwray/keyv/tree/master/packages/mysql) | No | ||
Etcd | [@keyv/etcd](https://github.com/jaredwray/keyv/tree/master/packages/etcd) | Yes | ||
Memcache | [@keyv/memcache](https://github.com/jaredwray/keyv/tree/master/packages/memcache) | Yes | ||
@@ -149,5 +153,9 @@ ## Third-party Storage Adapters | ||
- [keyv-dynamodb](https://www.npmjs.com/package/keyv-dynamodb) - DynamoDB storage adapter for Keyv | ||
- [keyv-lru](https://www.npmjs.com/package/keyv-lru) - LRU storage adapter for Keyv | ||
- [keyv-null](https://www.npmjs.com/package/keyv-null) - Null storage adapter for Keyv | ||
- [keyv-firestore ](https://github.com/goto-bus-stop/keyv-firestore) – Firebase Cloud Firestore adapter for Keyv | ||
- [keyv-mssql](https://github.com/pmorgan3/keyv-mssql) - Microsoft Sql Server adapter for Keyv | ||
- [keyv-memcache](https://github.com/jaredwray/keyv-memcache) - Memcache storage adapter for Keyv | ||
- [keyv-azuretable](https://github.com/howlowck/keyv-azuretable) - Azure Table Storage/API adapter for Keyv | ||
- [keyv-arango](https://github.com/TimMikeladze/keyv-arango) - ArangoDB storage adapter for Keyv | ||
- [keyv-momento](https://github.com/momentohq/node-keyv-adaptor/) - Momento storage adapter for Keyv | ||
@@ -189,2 +197,38 @@ ## Add Cache Support to your Module | ||
## Compression | ||
Keyv supports `gzip` and `brotli` compression. To enable compression, pass the `compress` option to the constructor. | ||
```js | ||
const KeyvGzip = require('@keyv/compress-gzip'); | ||
const Keyv = require('keyv'); | ||
const keyvGzip = new KeyvGzip(); | ||
const keyv = new Keyv({ compression: KeyvGzip }); | ||
``` | ||
You can also pass a custom compression function to the `compression` option. Following the pattern of the official compression adapters. | ||
### Want to build your own? | ||
Great! Keyv is designed to be easily extended. You can build your own compression adapter by following the pattern of the official compression adapters based on this interface: | ||
```typescript | ||
interface CompressionAdapter { | ||
async compress(value: any, options?: any); | ||
async decompress(value: any, options?: any); | ||
async serialize(value: any); | ||
async deserialize(value: any); | ||
} | ||
``` | ||
In addition to the interface, you can test it with our compression test suite using @keyv/test-suite: | ||
```js | ||
const {keyvCompresstionTests} = require('@keyv/test-suite'); | ||
const KeyvGzip = require('@keyv/compress-gzip'); | ||
keyvCompresstionTests(test, new KeyvGzip()); | ||
``` | ||
## API | ||
@@ -227,2 +271,9 @@ | ||
#### options.compression | ||
Type: `@keyv/compress-<compression_package_name>`<br> | ||
Default: `undefined` | ||
Compression package to use. See [Compression](#compression) for more details. | ||
#### options.serialize | ||
@@ -293,4 +344,94 @@ | ||
#### .iterator() | ||
Iterate over all entries of the current namespace. | ||
Returns a iterable that can be iterated by for-of loops. For example: | ||
```js | ||
// please note that the "await" keyword should be used here | ||
for await (const [key, value] of this.keyv.iterator()) { | ||
console.log(key, value); | ||
}; | ||
``` | ||
# How to Contribute | ||
In this section of the documentation we will cover: | ||
1) How to set up this repository locally | ||
2) How to get started with running commands | ||
3) How to contribute changes using Pull Requests | ||
## Dependencies | ||
This package requires the following dependencies to run: | ||
1) [Yarn V1](https://yarnpkg.com/getting-started/install) | ||
3) [Docker](https://docs.docker.com/get-docker/) | ||
## Setting up your workspace | ||
To contribute to this repository, start by setting up this project locally: | ||
1) Fork this repository into your Git account | ||
2) Clone the forked repository to your local directory using `git clone` | ||
3) Install any of the above missing dependencies | ||
## Launching the project | ||
Once the project is installed locally, you are ready to start up its services: | ||
1) Ensure that your Docker service is running. | ||
2) From the root directory of your project, run the `yarn` command in the command prompt to install yarn. | ||
3) Run the `yarn bootstrap` command to install any necessary dependencies. | ||
4) Run `yarn test:services:start` to start up this project's Docker container. The container will launch all services within your workspace. | ||
## Available Commands | ||
Once the project is running, you can execute a variety of commands. The root workspace and each subpackage contain a `package.json` file with a `scripts` field listing all the commands that can be executed from that directory. This project also supports native `yarn`, and `docker` commands. | ||
Here, we'll cover the primary commands that can be executed from the root directory. Unless otherwise noted, these commands can also be executed from a subpackage. If executed from a subpackage, they will only affect that subpackage, rather than the entire workspace. | ||
### `yarn` | ||
The `yarn` command installs yarn in the workspace. | ||
### `yarn bootstrap` | ||
The `yarn bootstrap` command installs all dependencies in the workspace. | ||
### `yarn test:services:start` | ||
The `yarn test:services:start` command starts up the project's Docker container, launching all services in the workspace. This command must be executed from the root directory. | ||
### `yarn test:services:stop` | ||
The `yarn test:services:stop` command brings down the project's Docker container, halting all services. This command must be executed from the root directory. | ||
### `yarn test` | ||
The `yarn test` command runs all tests in the workspace. | ||
### `yarn clean` | ||
The `yarn clean` command removes yarn and all dependencies installed by yarn. After executing this command, you must repeat the steps in *Setting up your workspace* to rebuild your workspace. | ||
## Contributing Changes | ||
Now that you've set up your workspace, you're ready to contribute changes to the `keyv` repository. | ||
1) Make any changes that you would like to contribute in your local workspace. | ||
2) After making these changes, ensure that the project's tests still pass by executing the `yarn test` command in the root directory. | ||
3) Commit your changes and push them to your forked repository. | ||
4) Navigate to the original `keyv` repository and go the *Pull Requests* tab. | ||
5) Click the *New pull request* button, and open a pull request for the branch in your repository that contains your changes. | ||
6) Once your pull request is created, ensure that all checks have passed and that your branch has no conflicts with the base branch. If there are any issues, resolve these changes in your local repository, and then commit and push them to git. | ||
7) Similarly, respond to any reviewer comments or requests for changes by making edits to your local repository and pushing them to Git. | ||
8) Once the pull request has been reviewed, those with write access to the branch will be able to merge your changes into the `keyv` repository. | ||
If you need more information on the steps to create a pull request, you can find a detailed walkthrough in the [Github documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) | ||
## License | ||
MIT © Luke Childs | ||
MIT © Jared Wray |
@@ -6,5 +6,6 @@ 'use strict'; | ||
const loadStore = opts => { | ||
const loadStore = options => { | ||
const adapters = { | ||
redis: '@keyv/redis', | ||
rediss: '@keyv/redis', | ||
mongodb: '@keyv/mongo', | ||
@@ -15,7 +16,10 @@ mongo: '@keyv/mongo', | ||
postgres: '@keyv/postgres', | ||
mysql: '@keyv/mysql' | ||
mysql: '@keyv/mysql', | ||
etcd: '@keyv/etcd', | ||
offline: '@keyv/offline', | ||
tiered: '@keyv/tiered', | ||
}; | ||
if (opts.adapter || opts.uri) { | ||
const adapter = opts.adapter || /^[^:]*/.exec(opts.uri)[0]; | ||
return new (require(adapters[adapter]))(opts); | ||
if (options.adapter || options.uri) { | ||
const adapter = options.adapter || /^[^:+]*/.exec(options.uri)[0]; | ||
return new (require(adapters[adapter]))(options); | ||
} | ||
@@ -26,27 +30,71 @@ | ||
const iterableAdapters = [ | ||
'sqlite', | ||
'postgres', | ||
'mysql', | ||
'mongo', | ||
'redis', | ||
'tiered', | ||
]; | ||
class Keyv extends EventEmitter { | ||
constructor(uri, opts) { | ||
constructor(uri, {emitErrors = true, ...options} = {}) { | ||
super(); | ||
this.opts = Object.assign( | ||
{ | ||
namespace: 'keyv', | ||
serialize: JSONB.stringify, | ||
deserialize: JSONB.parse | ||
}, | ||
(typeof uri === 'string') ? { uri } : uri, | ||
opts | ||
); | ||
this.opts = { | ||
namespace: 'keyv', | ||
serialize: JSONB.stringify, | ||
deserialize: JSONB.parse, | ||
...((typeof uri === 'string') ? {uri} : uri), | ||
...options, | ||
}; | ||
if (!this.opts.store) { | ||
const adapterOpts = Object.assign({}, this.opts); | ||
this.opts.store = loadStore(adapterOpts); | ||
const adapterOptions = {...this.opts}; | ||
this.opts.store = loadStore(adapterOptions); | ||
} | ||
if (typeof this.opts.store.on === 'function') { | ||
this.opts.store.on('error', err => this.emit('error', err)); | ||
if (this.opts.compression) { | ||
const compression = this.opts.compression; | ||
this.opts.serialize = compression.serialize.bind(compression); | ||
this.opts.deserialize = compression.deserialize.bind(compression); | ||
} | ||
if (typeof this.opts.store.on === 'function' && emitErrors) { | ||
this.opts.store.on('error', error => this.emit('error', error)); | ||
} | ||
this.opts.store.namespace = this.opts.namespace; | ||
const generateIterator = iterator => async function * () { | ||
for await (const [key, raw] of typeof iterator === 'function' | ||
? iterator(this.opts.store.namespace) | ||
: iterator) { | ||
const data = await this.opts.deserialize(raw); | ||
if (this.opts.store.namespace && !key.includes(this.opts.store.namespace)) { | ||
continue; | ||
} | ||
if (typeof data.expires === 'number' && Date.now() > data.expires) { | ||
this.delete(key); | ||
continue; | ||
} | ||
yield [this._getKeyUnprefix(key), data.value]; | ||
} | ||
}; | ||
// Attach iterators | ||
if (typeof this.opts.store[Symbol.iterator] === 'function' && this.opts.store instanceof Map) { | ||
this.iterator = generateIterator(this.opts.store); | ||
} else if (typeof this.opts.store.iterator === 'function' && this.opts.store.opts | ||
&& this._checkIterableAdaptar()) { | ||
this.iterator = generateIterator(this.opts.store.iterator.bind(this.opts.store)); | ||
} | ||
} | ||
_checkIterableAdaptar() { | ||
return iterableAdapters.includes(this.opts.store.opts.dialect) | ||
|| iterableAdapters.findIndex(element => this.opts.store.opts.url.includes(element)) >= 0; | ||
} | ||
_getKeyPrefix(key) { | ||
@@ -56,21 +104,80 @@ return `${this.opts.namespace}:${key}`; | ||
get(key, opts) { | ||
const keyPrefixed = this._getKeyPrefix(key); | ||
const { store } = this.opts; | ||
_getKeyPrefixArray(keys) { | ||
return keys.map(key => `${this.opts.namespace}:${key}`); | ||
} | ||
_getKeyUnprefix(key) { | ||
return key | ||
.split(':') | ||
.splice(1) | ||
.join(':'); | ||
} | ||
get(key, options) { | ||
const {store} = this.opts; | ||
const isArray = Array.isArray(key); | ||
const keyPrefixed = isArray ? this._getKeyPrefixArray(key) : this._getKeyPrefix(key); | ||
if (isArray && store.getMany === undefined) { | ||
const promises = []; | ||
for (const key of keyPrefixed) { | ||
promises.push(Promise.resolve() | ||
.then(() => store.get(key)) | ||
.then(data => (typeof data === 'string') ? this.opts.deserialize(data) : (this.opts.compression ? this.opts.deserialize(data) : data)) | ||
.then(data => { | ||
if (data === undefined || data === null) { | ||
return undefined; | ||
} | ||
if (typeof data.expires === 'number' && Date.now() > data.expires) { | ||
return this.delete(key).then(() => undefined); | ||
} | ||
return (options && options.raw) ? data : data.value; | ||
}), | ||
); | ||
} | ||
return Promise.allSettled(promises) | ||
.then(values => { | ||
const data = []; | ||
for (const value of values) { | ||
data.push(value.value); | ||
} | ||
return data; | ||
}); | ||
} | ||
return Promise.resolve() | ||
.then(() => store.get(keyPrefixed)) | ||
.then(() => isArray ? store.getMany(keyPrefixed) : store.get(keyPrefixed)) | ||
.then(data => (typeof data === 'string') ? this.opts.deserialize(data) : (this.opts.compression ? this.opts.deserialize(data) : data)) | ||
.then(data => { | ||
return (typeof data === 'string') ? this.opts.deserialize(data) : data; | ||
}) | ||
.then(data => { | ||
if (data === undefined) { | ||
if (data === undefined || data === null) { | ||
return undefined; | ||
} | ||
if (isArray) { | ||
return data.map((row, index) => { | ||
if ((typeof row === 'string')) { | ||
row = this.opts.deserialize(row); | ||
} | ||
if (row === undefined || row === null) { | ||
return undefined; | ||
} | ||
if (typeof row.expires === 'number' && Date.now() > row.expires) { | ||
this.delete(key[index]).then(() => undefined); | ||
return undefined; | ||
} | ||
return (options && options.raw) ? row : row.value; | ||
}); | ||
} | ||
if (typeof data.expires === 'number' && Date.now() > data.expires) { | ||
this.delete(key); | ||
return undefined; | ||
return this.delete(key).then(() => undefined); | ||
} | ||
return (opts && opts.raw) ? data : data.value; | ||
return (options && options.raw) ? data : data.value; | ||
}); | ||
@@ -89,3 +196,3 @@ } | ||
const { store } = this.opts; | ||
const {store} = this.opts; | ||
@@ -95,3 +202,7 @@ return Promise.resolve() | ||
const expires = (typeof ttl === 'number') ? (Date.now() + ttl) : null; | ||
value = { value, expires }; | ||
if (typeof value === 'symbol') { | ||
this.emit('error', 'symbol cannot be serialized'); | ||
} | ||
value = {value, expires}; | ||
return this.opts.serialize(value); | ||
@@ -104,4 +215,20 @@ }) | ||
delete(key) { | ||
const {store} = this.opts; | ||
if (Array.isArray(key)) { | ||
const keyPrefixed = this._getKeyPrefixArray(key); | ||
if (store.deleteMany === undefined) { | ||
const promises = []; | ||
for (const key of keyPrefixed) { | ||
promises.push(store.delete(key)); | ||
} | ||
return Promise.allSettled(promises) | ||
.then(values => values.every(x => x.value === true)); | ||
} | ||
return Promise.resolve() | ||
.then(() => store.deleteMany(keyPrefixed)); | ||
} | ||
const keyPrefixed = this._getKeyPrefix(key); | ||
const { store } = this.opts; | ||
return Promise.resolve() | ||
@@ -112,8 +239,29 @@ .then(() => store.delete(keyPrefixed)); | ||
clear() { | ||
const { store } = this.opts; | ||
const {store} = this.opts; | ||
return Promise.resolve() | ||
.then(() => store.clear()); | ||
} | ||
has(key) { | ||
const keyPrefixed = this._getKeyPrefix(key); | ||
const {store} = this.opts; | ||
return Promise.resolve() | ||
.then(async () => { | ||
if (typeof store.has === 'function') { | ||
return store.has(keyPrefixed); | ||
} | ||
const value = await store.get(keyPrefixed); | ||
return value !== undefined; | ||
}); | ||
} | ||
disconnect() { | ||
const {store} = this.opts; | ||
if (typeof store.disconnect === 'function') { | ||
return store.disconnect(); | ||
} | ||
} | ||
} | ||
module.exports = Keyv; |
@@ -0,1 +1,28 @@ | ||
1.52.0 / 2022-02-21 | ||
=================== | ||
* Add extensions from IANA for more `image/*` types | ||
* Add extension `.asc` to `application/pgp-keys` | ||
* Add extensions to various XML types | ||
* Add new upstream MIME types | ||
1.51.0 / 2021-11-08 | ||
=================== | ||
* Add new upstream MIME types | ||
* Mark `image/vnd.microsoft.icon` as compressible | ||
* Mark `image/vnd.ms-dds` as compressible | ||
1.50.0 / 2021-09-15 | ||
=================== | ||
* Add deprecated iWorks mime types and extensions | ||
* Add new upstream MIME types | ||
1.49.0 / 2021-07-26 | ||
=================== | ||
* Add extension `.trig` to `application/trig` | ||
* Add new upstream MIME types | ||
1.48.0 / 2021-05-30 | ||
@@ -2,0 +29,0 @@ =================== |
/*! | ||
* mime-db | ||
* Copyright(c) 2014 Jonathan Ong | ||
* Copyright(c) 2015-2022 Douglas Christopher Wilson | ||
* MIT Licensed | ||
@@ -5,0 +6,0 @@ */ |
{ | ||
"name": "mime-db", | ||
"description": "Media Type Database", | ||
"version": "1.48.0", | ||
"version": "1.52.0", | ||
"contributors": [ | ||
@@ -25,14 +25,15 @@ "Douglas Christopher Wilson <doug@somethingdoug.com>", | ||
"cogent": "1.0.1", | ||
"csv-parse": "4.15.4", | ||
"eslint": "7.27.0", | ||
"csv-parse": "4.16.3", | ||
"eslint": "7.32.0", | ||
"eslint-config-standard": "15.0.1", | ||
"eslint-plugin-import": "2.23.4", | ||
"eslint-plugin-markdown": "2.2.0", | ||
"eslint-plugin-import": "2.25.4", | ||
"eslint-plugin-markdown": "2.2.1", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-promise": "5.1.0", | ||
"eslint-plugin-promise": "5.1.1", | ||
"eslint-plugin-standard": "4.1.0", | ||
"gnode": "0.1.2", | ||
"mocha": "8.4.0", | ||
"media-typer": "1.1.0", | ||
"mocha": "9.2.1", | ||
"nyc": "15.1.0", | ||
"raw-body": "2.4.1", | ||
"raw-body": "2.5.0", | ||
"stream-to-array": "2.3.0" | ||
@@ -39,0 +40,0 @@ }, |
@@ -9,3 +9,3 @@ # mime-db | ||
This is a database of all mime types. | ||
This is a large database of mime types and information about them. | ||
It consists of a single, public JSON file and does not include any logic, | ||
@@ -12,0 +12,0 @@ allowing it to remain as un-opinionated as possible with an API. |
@@ -0,1 +1,30 @@ | ||
2.1.35 / 2022-03-12 | ||
=================== | ||
* deps: mime-db@1.52.0 | ||
- Add extensions from IANA for more `image/*` types | ||
- Add extension `.asc` to `application/pgp-keys` | ||
- Add extensions to various XML types | ||
- Add new upstream MIME types | ||
2.1.34 / 2021-11-08 | ||
=================== | ||
* deps: mime-db@1.51.0 | ||
- Add new upstream MIME types | ||
2.1.33 / 2021-10-01 | ||
=================== | ||
* deps: mime-db@1.50.0 | ||
- Add deprecated iWorks mime types and extensions | ||
- Add new upstream MIME types | ||
2.1.32 / 2021-07-27 | ||
=================== | ||
* deps: mime-db@1.49.0 | ||
- Add extension `.trig` to `application/trig` | ||
- Add new upstream MIME types | ||
2.1.31 / 2021-06-01 | ||
@@ -7,3 +36,2 @@ =================== | ||
- Add new upstream MIME types | ||
- Mark `text/yaml` as compressible | ||
@@ -86,3 +114,2 @@ 2.1.30 / 2021-04-02 | ||
- Add new upstream MIME types | ||
- Mark `text/less` as compressible | ||
@@ -340,3 +367,2 @@ 2.1.21 / 2018-10-19 | ||
- Add new mime types | ||
- Add additional compressible | ||
- Update charsets | ||
@@ -343,0 +369,0 @@ |
{ | ||
"name": "mime-types", | ||
"description": "The ultimate javascript content-type utility.", | ||
"version": "2.1.31", | ||
"version": "2.1.35", | ||
"contributors": [ | ||
@@ -17,13 +17,13 @@ "Douglas Christopher Wilson <doug@somethingdoug.com>", | ||
"dependencies": { | ||
"mime-db": "1.48.0" | ||
"mime-db": "1.52.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "7.27.0", | ||
"eslint": "7.32.0", | ||
"eslint-config-standard": "14.1.1", | ||
"eslint-plugin-import": "2.23.4", | ||
"eslint-plugin-markdown": "2.2.0", | ||
"eslint-plugin-import": "2.25.4", | ||
"eslint-plugin-markdown": "2.2.1", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-promise": "5.1.0", | ||
"eslint-plugin-promise": "5.2.0", | ||
"eslint-plugin-standard": "4.1.0", | ||
"mocha": "8.4.0", | ||
"mocha": "9.2.2", | ||
"nyc": "15.1.0" | ||
@@ -30,0 +30,0 @@ }, |
@@ -106,3 +106,3 @@ # mime-types | ||
[ci-image]: https://badgen.net/github/checks/jshttp/mime-types/master?label=ci | ||
[ci-url]: https://github.com/jshttp/mime-types/actions?query=workflow%3Aci | ||
[ci-url]: https://github.com/jshttp/mime-types/actions/workflows/ci.yml | ||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master | ||
@@ -109,0 +109,0 @@ [coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master |
{ | ||
"_from": "ms@2.1.2", | ||
"_id": "ms@2.1.2", | ||
"_inBundle": false, | ||
"_integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", | ||
"_location": "/ms", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "version", | ||
"registry": true, | ||
"raw": "ms@2.1.2", | ||
"name": "ms", | ||
"escapedName": "ms", | ||
"rawSpec": "2.1.2", | ||
"saveSpec": null, | ||
"fetchSpec": "2.1.2" | ||
}, | ||
"_requiredBy": [ | ||
"/debug" | ||
"name": "ms", | ||
"version": "2.1.2", | ||
"description": "Tiny millisecond conversion utility", | ||
"repository": "zeit/ms", | ||
"main": "./index", | ||
"files": [ | ||
"index.js" | ||
], | ||
"_resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", | ||
"_shasum": "d09d1f357b443f493382a8eb3ccd183872ae6009", | ||
"_spec": "ms@2.1.2", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/debug", | ||
"bugs": { | ||
"url": "https://github.com/zeit/ms/issues" | ||
"scripts": { | ||
"precommit": "lint-staged", | ||
"lint": "eslint lib/* bin/*", | ||
"test": "mocha tests.js" | ||
}, | ||
"bundleDependencies": false, | ||
"deprecated": false, | ||
"description": "Tiny millisecond conversion utility", | ||
"devDependencies": { | ||
"eslint": "4.12.1", | ||
"expect.js": "0.3.1", | ||
"husky": "0.14.3", | ||
"lint-staged": "5.0.0", | ||
"mocha": "4.0.1" | ||
}, | ||
"eslintConfig": { | ||
@@ -45,7 +22,2 @@ "extends": "eslint:recommended", | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"homepage": "https://github.com/zeit/ms#readme", | ||
"license": "MIT", | ||
"lint-staged": { | ||
@@ -58,14 +30,10 @@ "*.js": [ | ||
}, | ||
"main": "./index", | ||
"name": "ms", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/zeit/ms.git" | ||
}, | ||
"scripts": { | ||
"lint": "eslint lib/* bin/*", | ||
"precommit": "lint-staged", | ||
"test": "mocha tests.js" | ||
}, | ||
"version": "2.1.2" | ||
"license": "MIT", | ||
"devDependencies": { | ||
"eslint": "4.12.1", | ||
"expect.js": "0.3.1", | ||
"husky": "0.14.3", | ||
"lint-staged": "5.0.0", | ||
"mocha": "4.0.1" | ||
} | ||
} |
{ | ||
"_from": "proxy-from-env@^1.1.0", | ||
"_id": "proxy-from-env@1.1.0", | ||
"_inBundle": false, | ||
"_integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", | ||
"_location": "/proxy-from-env", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "range", | ||
"registry": true, | ||
"raw": "proxy-from-env@^1.1.0", | ||
"name": "proxy-from-env", | ||
"escapedName": "proxy-from-env", | ||
"rawSpec": "^1.1.0", | ||
"saveSpec": null, | ||
"fetchSpec": "^1.1.0" | ||
"name": "proxy-from-env", | ||
"version": "1.1.0", | ||
"description": "Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "eslint *.js", | ||
"test": "mocha ./test.js --reporter spec", | ||
"test-coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter spec" | ||
}, | ||
"_requiredBy": [ | ||
"/axios" | ||
], | ||
"_resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", | ||
"_shasum": "e102f16ca355424865755d2c9e8ea4f24d58c3e2", | ||
"_spec": "proxy-from-env@^1.1.0", | ||
"_where": "/Users/erowlands/git/ff-nodejs-server-sdk/node_modules/axios", | ||
"author": { | ||
"name": "Rob Wu", | ||
"email": "rob@robwu.nl", | ||
"url": "https://robwu.nl/" | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Rob--W/proxy-from-env.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Rob--W/proxy-from-env/issues" | ||
}, | ||
"bundleDependencies": false, | ||
"deprecated": false, | ||
"description": "Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.", | ||
"devDependencies": { | ||
"coveralls": "^3.0.9", | ||
"eslint": "^6.8.0", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^7.1.0" | ||
}, | ||
"homepage": "https://github.com/Rob--W/proxy-from-env#readme", | ||
"keywords": [ | ||
@@ -50,15 +22,14 @@ "proxy", | ||
], | ||
"author": "Rob Wu <rob@robwu.nl> (https://robwu.nl/)", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"name": "proxy-from-env", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Rob--W/proxy-from-env.git" | ||
"bugs": { | ||
"url": "https://github.com/Rob--W/proxy-from-env/issues" | ||
}, | ||
"scripts": { | ||
"lint": "eslint *.js", | ||
"test": "mocha ./test.js --reporter spec", | ||
"test-coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter spec" | ||
}, | ||
"version": "1.1.0" | ||
"homepage": "https://github.com/Rob--W/proxy-from-env#readme", | ||
"devDependencies": { | ||
"coveralls": "^3.0.9", | ||
"eslint": "^6.8.0", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^7.1.0" | ||
} | ||
} |
{ | ||
"name": "@harnessio/ff-nodejs-server-sdk", | ||
"version": "1.3.7", | ||
"version": "1.4.0", | ||
"description": "Feature flags SDK for NodeJS environments", | ||
@@ -21,4 +21,3 @@ "main": "dist/cjs/index.js", | ||
"devDependencies": { | ||
"@openapitools/openapi-generator-cli": "^2.4.12", | ||
"@types/jest": "~26.0.23", | ||
"@types/jest": "~29.5.8", | ||
"@types/keyv": "^3.1.3", | ||
@@ -32,9 +31,9 @@ "@types/node": "^14.17.11", | ||
"eslint-plugin-jest": "~24.3.6", | ||
"jest": "~27.0.6", | ||
"jest": "~29.7.0", | ||
"jest-junit": "^13.0.0", | ||
"prettier": "^3.0.0", | ||
"rimraf": "~3.0.2", | ||
"ts-jest": "~27.0.3", | ||
"ts-jest": "~29.1.1", | ||
"tsutils": "~3.21.0", | ||
"typescript": "~4.3.5" | ||
"typescript": "~4.9.5" | ||
}, | ||
@@ -41,0 +40,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3171792
16
34488