@sunrise-upc/sales-static-components 3.8.7-beta.10 → 3.8.7-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../node_modules/tslib/tslib.es6.js"),t=require("../components/Constants.js"),o=require("cookies-next"),r=require("./CustomerService.js");const n=e=>{if("undefined"==typeof window)return()=>{};const o=t=>{e(t)};return window.addEventListener(t.CUSTOMER_SEGMENT_REFRESH_EVENT,o),w({fetchCustomerGroup:E,isLoggedIn:f,onError:()=>{}}),()=>{window.removeEventListener(t.CUSTOMER_SEGMENT_REFRESH_EVENT,o)}},i=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(t.CUSTOMER_SEGMENT_REFRESH_EVENT,{detail:{customerGroup:e,refreshedAt:Date.now()}}))},s=e=>{if("string"!=typeof e)return null;const t=e.trim();return t.length>0?t:null},u=e=>{var t,o;const r=s(null==e?void 0:e.customerGroup);if(r)return r;const n=s(null===(o=null===(t=null==e?void 0:e.relatedParty)||void 0===t?void 0:t[0])||void 0===o?void 0:o.segment);return n||null},d=t=>()=>e.__awaiter(void 0,void 0,void 0,function*(){const e=yield t.fetchCustomerProfile();return u(e||{})}),E=d({fetchCustomerProfile:r.customerGroup}),l=new Map,c=new Set([
|
|
1
|
+
"use strict";var e=require("../node_modules/tslib/tslib.es6.js"),t=require("../components/Constants.js"),o=require("cookies-next"),r=require("./CustomerService.js");const n=e=>{if("undefined"==typeof window)return()=>{};const o=t=>{e(t)};return window.addEventListener(t.CUSTOMER_SEGMENT_REFRESH_EVENT,o),w({fetchCustomerGroup:E,isLoggedIn:f,onError:()=>{}}),()=>{window.removeEventListener(t.CUSTOMER_SEGMENT_REFRESH_EVENT,o)}},i=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(t.CUSTOMER_SEGMENT_REFRESH_EVENT,{detail:{customerGroup:e,refreshedAt:Date.now()}}))},s=e=>{if("string"!=typeof e)return null;const t=e.trim();return t.length>0?t:null},u=e=>{var t,o;const r=s(null==e?void 0:e.customerGroup);if(r)return r;const n=s(null===(o=null===(t=null==e?void 0:e.relatedParty)||void 0===t?void 0:t[0])||void 0===o?void 0:o.segment);return n||null},d=t=>()=>e.__awaiter(void 0,void 0,void 0,function*(){const e=yield t.fetchCustomerProfile();return u(e||{})}),E=d({fetchCustomerProfile:r.customerGroup}),l=new Map,c=new Set(["MOBILE","FIXNET","FIXNET_MOBILE","DEFAULT"]),f=()=>Boolean(o.getCookie(t.AUTHCOOKIE)),_=e=>"undefined"==typeof window?null:s(window.localStorage.getItem(e)),a=(e,t)=>{"undefined"!=typeof window&&(t?window.localStorage.setItem(e,t):window.localStorage.removeItem(e))},m=o=>e.__awaiter(void 0,void 0,void 0,function*(){const r=t.CUSTOMER_GROUP_STORAGE_KEY,n=t.CUSTOMER_GROUP_NEW_CUSTOMER_VALUE;if("undefined"==typeof window)return null;if(!o.isLoggedIn())return a(r,n),n;if(!o.forceRefresh){const e=_(r);if((e=>{const t=(o=e)?o.trim().toUpperCase():null;var o;return Boolean(t&&c.has(t))})(e))return e}const i=l.get(r);if(i)return i;const u=e.__awaiter(void 0,void 0,void 0,function*(){try{const e=s(yield o.fetchCustomerGroup());return a(r,e),e}catch(e){return o.onError&&o.onError(e),_(r)}finally{l.delete(r)}});return l.set(r,u),u}),w=t=>e.__awaiter(void 0,void 0,void 0,function*(){const e=yield m(t);return i(e),e});exports.createCustomerGroupFetcher=d,exports.createCustomerSegmentSync=o=>{const r=t.CUSTOMER_GROUP_STORAGE_KEY;let s=null,u=0;return{refreshCustomerSegmentAfterLogin:()=>e.__awaiter(void 0,void 0,void 0,function*(){if("undefined"==typeof window)return null;var t;if(yield(t=o.isLoggedIn,e.__awaiter(void 0,void 0,void 0,function*(){if("undefined"==typeof window||t())return;const e=Date.now()+2e3;for(;!t()&&Date.now()<e;)yield new Promise(e=>window.setTimeout(e,100))})),s)return s;if(Date.now()-u<8e3){const e=_(r);return i(e),e}return s=e.__awaiter(void 0,void 0,void 0,function*(){try{const e=yield w({fetchCustomerGroup:o.fetchCustomerGroup,isLoggedIn:o.isLoggedIn,forceRefresh:!0,onError:o.onError});return u=Date.now(),e}finally{s=null}}),s}),subscribeToCustomerSegmentRefresh:n,dispatchCustomerSegmentRefreshEvent:i}},exports.dispatchCustomerSegmentRefreshEvent=i,exports.extractCustomerGroupFromProfile=u,exports.getCurrentCustomerSegment=()=>{const e=_(t.CUSTOMER_GROUP_STORAGE_KEY);return null!=e?e:t.CUSTOMER_GROUP_NEW_CUSTOMER_VALUE},exports.resolveCustomerGroup=m,exports.setCustomerSegment=e=>{const o=e===t.CUSTOMER_GROUP_NEW_CUSTOMER_VALUE?t.CUSTOMER_GROUP_NEW_CUSTOMER_VALUE:s(e);return a(t.CUSTOMER_GROUP_STORAGE_KEY,o),i(o),o},exports.subscribeToCustomerSegmentRefresh=n,exports.syncCustomerSegment=w;
|
|
2
2
|
//# sourceMappingURL=customerSegmentSync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customerSegmentSync.js","sources":["../../../../src/services/customerSegmentSync.ts"],"sourcesContent":[null],"names":["subscribeToCustomerSegmentRefresh","handler","window","eventListener","event","addEventListener","CUSTOMER_SEGMENT_REFRESH_EVENT","syncCustomerSegment","fetchCustomerGroup","defaultFetchCustomerGroup","isLoggedIn","defaultIsLoggedIn","onError","removeEventListener","dispatchCustomerSegmentRefreshEvent","customerGroup","dispatchEvent","CustomEvent","detail","refreshedAt","Date","now","normalizeCustomerGroup","value","normalized","trim","length","extractCustomerGroupFromProfile","profile","directCustomerGroup","relatedPartySegment","_b","_a","relatedParty","segment","createCustomerGroupFetcher","options","__awaiter","customerProfile","fetchCustomerProfile","inFlightCustomerGroupByStorageKey","Map","ALLOWED_CUSTOMER_GROUP_VALUES","Set","
|
|
1
|
+
{"version":3,"file":"customerSegmentSync.js","sources":["../../../../src/services/customerSegmentSync.ts"],"sourcesContent":[null],"names":["subscribeToCustomerSegmentRefresh","handler","window","eventListener","event","addEventListener","CUSTOMER_SEGMENT_REFRESH_EVENT","syncCustomerSegment","fetchCustomerGroup","defaultFetchCustomerGroup","isLoggedIn","defaultIsLoggedIn","onError","removeEventListener","dispatchCustomerSegmentRefreshEvent","customerGroup","dispatchEvent","CustomEvent","detail","refreshedAt","Date","now","normalizeCustomerGroup","value","normalized","trim","length","extractCustomerGroupFromProfile","profile","directCustomerGroup","relatedPartySegment","_b","_a","relatedParty","segment","createCustomerGroupFetcher","options","__awaiter","customerProfile","fetchCustomerProfile","inFlightCustomerGroupByStorageKey","Map","ALLOWED_CUSTOMER_GROUP_VALUES","Set","Boolean","getCookie","AUTHCOOKIE","getCachedCustomerGroup","storageKey","localStorage","getItem","setCachedCustomerGroup","setItem","removeItem","resolveCustomerGroup","CUSTOMER_GROUP_STORAGE_KEY","newCustomerValue","CUSTOMER_GROUP_NEW_CUSTOMER_VALUE","forceRefresh","cachedCustomerGroup","customerGroupValue","normalizedCustomerGroup","toUpperCase","has","isAllowedCachedCustomerGroup","inFlightCustomerGroup","get","customerGroupPromise","resolvedCustomerGroup","error","delete","set","inFlightSync","lastSyncedAtMs","refreshCustomerSegmentAfterLogin","deadline","Promise","resolve","setTimeout"],"mappings":"qKA4CO,MAMMA,EACXC,IAEA,GAAsB,oBAAXC,OACT,MAAO,OAGT,MAAMC,EAAgCC,IACpCH,EAAQG,IAYV,OATAF,OAAOG,iBAAiBC,EAAAA,+BAAgCH,GAGnDI,EAAoB,CACvBC,mBAAoBC,EACpBC,WAAYC,EACZC,QAAS,SAGJ,KACLV,OAAOW,oBAAoBP,EAAAA,+BAAgCH,KAIlDW,EAAuCC,IAC5B,oBAAXb,QAIXA,OAAOc,cACL,IAAIC,YAA0CX,iCAAgC,CAC5EY,OAAQ,CACNH,gBACAI,YAAaC,KAAKC,WAMpBC,EAA0BC,IAC9B,GAAqB,iBAAVA,EACT,OAAO,KAGT,MAAMC,EAAaD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B4B,EAAQ5B,mBAC5BE,WAAY0B,EAAQ1B,WACpBgD,cAAc,EACd9C,QAASwB,EAAQxB,UAGnB,OADA6D,EAAiBrD,KAAKC,MACf+C,CACT,SACEI,EAAe,IACjB,CACF,GAEOA,CACT,GAIExE,oCACAc,kKA/PqC,KACvC,MAAM6C,EAAsBZ,EAAuBQ,8BAEnD,OAAOI,QAAAA,EAAuBF,EAAAA,6FAwIG1C,IACjC,MAAM8C,EACJ9C,IAAkB0C,EAAAA,kCACdA,EAAAA,kCACAnC,EAAuBP,GAK7B,OAHAoC,EAAuBI,EAAAA,2BAA4BM,GACnD/C,EAAoC+C,GAE7BA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{CUSTOMER_SEGMENT_REFRESH_EVENT as o,CUSTOMER_GROUP_NEW_CUSTOMER_VALUE as n,CUSTOMER_GROUP_STORAGE_KEY as t,AUTHCOOKIE as r}from"../components/Constants.js";import{getCookie as i}from"cookies-next";import{customerGroup as d}from"./CustomerService.js";const u=()=>{const e=g(t);return null!=e?e:n},s=e=>{if("undefined"==typeof window)return()=>{};const n=o=>{e(o)};return window.addEventListener(o,n),C({fetchCustomerGroup:w,isLoggedIn:p,onError:()=>{}}),()=>{window.removeEventListener(o,n)}},f=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(o,{detail:{customerGroup:e,refreshedAt:Date.now()}}))},l=e=>{if("string"!=typeof e)return null;const o=e.trim();return o.length>0?o:null},c=e=>{var o,n;const t=l(null==e?void 0:e.customerGroup);if(t)return t;const r=l(null===(n=null===(o=null==e?void 0:e.relatedParty)||void 0===o?void 0:o[0])||void 0===n?void 0:n.segment);return r||null},v=o=>()=>e(void 0,void 0,void 0,function*(){const e=yield o.fetchCustomerProfile();return c(e||{})}),w=v({fetchCustomerProfile:d}),m=new Map,a=new Set([
|
|
1
|
+
import{__awaiter as e}from"../node_modules/tslib/tslib.es6.js";import{CUSTOMER_SEGMENT_REFRESH_EVENT as o,CUSTOMER_GROUP_NEW_CUSTOMER_VALUE as n,CUSTOMER_GROUP_STORAGE_KEY as t,AUTHCOOKIE as r}from"../components/Constants.js";import{getCookie as i}from"cookies-next";import{customerGroup as d}from"./CustomerService.js";const u=()=>{const e=g(t);return null!=e?e:n},s=e=>{if("undefined"==typeof window)return()=>{};const n=o=>{e(o)};return window.addEventListener(o,n),C({fetchCustomerGroup:w,isLoggedIn:p,onError:()=>{}}),()=>{window.removeEventListener(o,n)}},f=e=>{"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(o,{detail:{customerGroup:e,refreshedAt:Date.now()}}))},l=e=>{if("string"!=typeof e)return null;const o=e.trim();return o.length>0?o:null},c=e=>{var o,n;const t=l(null==e?void 0:e.customerGroup);if(t)return t;const r=l(null===(n=null===(o=null==e?void 0:e.relatedParty)||void 0===o?void 0:o[0])||void 0===n?void 0:n.segment);return r||null},v=o=>()=>e(void 0,void 0,void 0,function*(){const e=yield o.fetchCustomerProfile();return c(e||{})}),w=v({fetchCustomerProfile:d}),m=new Map,a=new Set(["MOBILE","FIXNET","FIXNET_MOBILE","DEFAULT"]),p=()=>Boolean(i(r)),g=e=>"undefined"==typeof window?null:l(window.localStorage.getItem(e)),y=(e,o)=>{"undefined"!=typeof window&&(o?window.localStorage.setItem(e,o):window.localStorage.removeItem(e))},h=e=>{const o=e===n?n:l(e);return y(t,o),f(o),o},E=o=>e(void 0,void 0,void 0,function*(){const r=t,i=n;if("undefined"==typeof window)return null;if(!o.isLoggedIn())return y(r,i),i;if(!o.forceRefresh){const e=g(r);if((e=>{const o=(n=e)?n.trim().toUpperCase():null;var n;return Boolean(o&&a.has(o))})(e))return e}const d=m.get(r);if(d)return d;const u=e(void 0,void 0,void 0,function*(){try{const e=l(yield o.fetchCustomerGroup());return y(r,e),e}catch(e){return o.onError&&o.onError(e),g(r)}finally{m.delete(r)}});return m.set(r,u),u}),C=o=>e(void 0,void 0,void 0,function*(){const e=yield E(o);return f(e),e}),I=o=>{const n=t;let r=null,i=0;return{refreshCustomerSegmentAfterLogin:()=>e(void 0,void 0,void 0,function*(){if("undefined"==typeof window)return null;var t;if(yield(t=o.isLoggedIn,e(void 0,void 0,void 0,function*(){if("undefined"==typeof window||t())return;const e=Date.now()+2e3;for(;!t()&&Date.now()<e;)yield new Promise(e=>window.setTimeout(e,100))})),r)return r;if(Date.now()-i<8e3){const e=g(n);return f(e),e}return r=e(void 0,void 0,void 0,function*(){try{const e=yield C({fetchCustomerGroup:o.fetchCustomerGroup,isLoggedIn:o.isLoggedIn,forceRefresh:!0,onError:o.onError});return i=Date.now(),e}finally{r=null}}),r}),subscribeToCustomerSegmentRefresh:s,dispatchCustomerSegmentRefreshEvent:f}};export{v as createCustomerGroupFetcher,I as createCustomerSegmentSync,f as dispatchCustomerSegmentRefreshEvent,c as extractCustomerGroupFromProfile,u as getCurrentCustomerSegment,E as resolveCustomerGroup,h as setCustomerSegment,s as subscribeToCustomerSegmentRefresh,C as syncCustomerSegment};
|
|
2
2
|
//# sourceMappingURL=customerSegmentSync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customerSegmentSync.js","sources":["../../../../src/services/customerSegmentSync.ts"],"sourcesContent":[null],"names":["getCurrentCustomerSegment","cachedCustomerGroup","getCachedCustomerGroup","CUSTOMER_GROUP_STORAGE_KEY","CUSTOMER_GROUP_NEW_CUSTOMER_VALUE","subscribeToCustomerSegmentRefresh","handler","window","eventListener","event","addEventListener","CUSTOMER_SEGMENT_REFRESH_EVENT","syncCustomerSegment","fetchCustomerGroup","defaultFetchCustomerGroup","isLoggedIn","defaultIsLoggedIn","onError","removeEventListener","dispatchCustomerSegmentRefreshEvent","customerGroup","dispatchEvent","CustomEvent","detail","refreshedAt","Date","now","normalizeCustomerGroup","value","normalized","trim","length","extractCustomerGroupFromProfile","profile","directCustomerGroup","relatedPartySegment","_b","_a","relatedParty","segment","createCustomerGroupFetcher","options","__awaiter","customerProfile","fetchCustomerProfile","inFlightCustomerGroupByStorageKey","Map","ALLOWED_CUSTOMER_GROUP_VALUES","Set","Boolean","getCookie","AUTHCOOKIE","storageKey","localStorage","getItem","setCachedCustomerGroup","setItem","removeItem","setCustomerSegment","normalizedCustomerGroup","resolveCustomerGroup","newCustomerValue","forceRefresh","customerGroupValue","toUpperCase","has","isAllowedCachedCustomerGroup","inFlightCustomerGroup","get","customerGroupPromise","resolvedCustomerGroup","error","delete","set","createCustomerSegmentSync","inFlightSync","lastSyncedAtMs","refreshCustomerSegmentAfterLogin","deadline","Promise","resolve","setTimeout"],"mappings":"gUA4CO,MAAMA,EAA4B,KACvC,MAAMC,EAAsBC,EAAuBC,GAEnD,OAAOF,QAAAA,EAAuBG,GAGnBC,EACXC,IAEA,GAAsB,oBAAXC,OACT,MAAO,OAGT,MAAMC,EAAgCC,IACpCH,EAAQG,IAYV,OATAF,OAAOG,iBAAiBC,EAAgCH,GAGnDI,EAAoB,CACvBC,mBAAoBC,EACpBC,WAAYC,EACZC,QAAS,SAGJ,KACLV,OAAOW,oBAAoBP,EAAgCH,KAIlDW,EAAuCC,IAC5B,oBAAXb,QAIXA,OAAOc,cACL,IAAIC,YAA0CX,EAAgC,CAC5EY,OAAQ,CACNH,gBACAI,YAAaC,KAAKC,WAMpBC,EAA0BC,IAC9B,GAAqB,iBAAVA,EACT,OAAO,KAGT,MAAMC,EAAaD,EAAME,OACzB,OAAOD,EAAWE,OAAS,EAAIF,EAAa,MAGjCG,EAAmCC,YAC9C,MAAMC,EAAsBP,EAAuBM,aAAO,EAAPA,EAASb,eAC5D,GAAIc,EACF,OAAOA,EAGT,MAAMC,EAAsBR,EAAiD,QAA1BS,EAAqB,QAArBC,EAAAJ,eAAAA,EAASK,oBAAY,IAAAD,OAAA,EAAAA,EAAG,UAAE,IAAAD,OAAA,EAAAA,EAAEG,SAC/E,OAAIJ,GAIG,MAGIK,EACXC,GAEO,IAAWC,OAAA,OAAA,OAAA,EAAA,YAChB,MAAMC,QAAwBF,EAAQG,uBACtC,OAAOZ,EAAiCW,GAAmB,GAC7D,GAGI7B,EAA4B0B,EAA2B,CAC3DI,qBAAsBxB,IAGlByB,EAAoC,IAAIC,IAIxCC,EAAgC,IAAIC,IAAI,
|
|
1
|
+
{"version":3,"file":"customerSegmentSync.js","sources":["../../../../src/services/customerSegmentSync.ts"],"sourcesContent":[null],"names":["getCurrentCustomerSegment","cachedCustomerGroup","getCachedCustomerGroup","CUSTOMER_GROUP_STORAGE_KEY","CUSTOMER_GROUP_NEW_CUSTOMER_VALUE","subscribeToCustomerSegmentRefresh","handler","window","eventListener","event","addEventListener","CUSTOMER_SEGMENT_REFRESH_EVENT","syncCustomerSegment","fetchCustomerGroup","defaultFetchCustomerGroup","isLoggedIn","defaultIsLoggedIn","onError","removeEventListener","dispatchCustomerSegmentRefreshEvent","customerGroup","dispatchEvent","CustomEvent","detail","refreshedAt","Date","now","normalizeCustomerGroup","value","normalized","trim","length","extractCustomerGroupFromProfile","profile","directCustomerGroup","relatedPartySegment","_b","_a","relatedParty","segment","createCustomerGroupFetcher","options","__awaiter","customerProfile","fetchCustomerProfile","inFlightCustomerGroupByStorageKey","Map","ALLOWED_CUSTOMER_GROUP_VALUES","Set","Boolean","getCookie","AUTHCOOKIE","storageKey","localStorage","getItem","setCachedCustomerGroup","setItem","removeItem","setCustomerSegment","normalizedCustomerGroup","resolveCustomerGroup","newCustomerValue","forceRefresh","customerGroupValue","toUpperCase","has","isAllowedCachedCustomerGroup","inFlightCustomerGroup","get","customerGroupPromise","resolvedCustomerGroup","error","delete","set","createCustomerSegmentSync","inFlightSync","lastSyncedAtMs","refreshCustomerSegmentAfterLogin","deadline","Promise","resolve","setTimeout"],"mappings":"gUA4CO,MAAMA,EAA4B,KACvC,MAAMC,EAAsBC,EAAuBC,GAEnD,OAAOF,QAAAA,EAAuBG,GAGnBC,EACXC,IAEA,GAAsB,oBAAXC,OACT,MAAO,OAGT,MAAMC,EAAgCC,IACpCH,EAAQG,IAYV,OATAF,OAA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