ouisys-engine 5.1.14 → 5.1.16
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
|
-
import{__awaiter as r,__generator as t,__assign as i}from"tslib";import{l as o}from"./helpers-CBmogWIZ.js";import{searchToObject as e}from"./searchToObject.js";import{t as c}from"./tracker-DaaILhEr.js";import{u as n}from"./updateUrlWithParams-C6-BX4TY.js";import"pacman-client";import"uuid";function a(r){var t=s(r).replace(/^\/+/,"");if(!/^https?:\/\//i.test(t))throw new Error("Decoded string is not an absolute URL: ".concat(t))}function s(r){var t;do{t=r;try{r=decodeURIComponent(r)}catch(r){break}}while(r!==t);return r}function u(u){var d,l,h,v,m=u.window,p=u.flow,f=u.action,w=u.args,_=u.extraParams,k=void 0===_?{}:_,b=u.isRedirectToChainAndProduct,y=void 0!==b&&b,E=u.isShowThankYou,R=void 0!==E&&E;return r(this,void 0,void 0,(function(){var u,_,b,E,U,g,j,S,I,P,T,F;return t(this,(function(L){switch(L.label){case 0:return u=m.pac_analytics.visitor.rockmanId,p&&f&&c.advancedInFlow(p,f,i({},w)),_=e(m),b="check-subscription-success-state"===_["current-state"],E=_.product_url||"/product",b&&(console.log("isMock is true"),(U=_["show-chain-link"])&&"1"===U&&(m.pac_analytics.visitor.chainRedirectUrl="/chain-url")),g=function(){return b?Promise.resolve({success:!0,rockman_id:u,product_url:E,msisdn:"000"}):function(i){var o=i.window,e=i.rockmanId;return r(void 0,void 0,void 0,(function(){var r,i,c;return t(this,(function(t){switch(t.label){case 0:return r=o.DEV_BASE_URL||"",i=new URLSearchParams({action:"check-subscription",rockman_id:e}).toString(),c="".concat(r,"/tallyman/v1/?").concat(i),[4,fetch(c)];case 1:return[2,t.sent().json()]}}))}))}({window:m,rockmanId:u})},[4,o(g,60,(function(r){return r.success}),0)];case 1:if(!0===(j=L.sent()).success){if(S=s(j.product_url),R)return I=n(m.location.href,{rockman_id:u,ui_show_tq:"1","show-thank-you":1,product_url:S}),setTimeout((function(){c.customEvent(p,"show-thank-you","thank-you-page",{thankYou:I}),a(I)}),3e3),[2,I];if(null===(l=null===(d=null==m?void 0:m.pac_analytics)||void 0===d?void 0:d.visitor)||void 0===l?void 0:l.chainRedirectUrl){if(P=null===(v=null===(h=null==m?void 0:m.pac_analytics)||void 0===h?void 0:h.visitor)||void 0===v?void 0:v.chainRedirectUrl,T=n(P,k),y)return c.customEvent(p,"redirect","chain-redirect",{redirect_url:T}),m.open(T,"_blank"),S&&""!==S&&setTimeout((function(){c.customEvent(p,"redirect","product-redirect",{redirect_url:S}),a(S)}),3e3),[2];c.customEvent(p,"redirect","chain-redirect",{redirect_url:T}),a(T)}else S&&""!==S&&(c.customEvent(p,"redirect","product-redirect",{redirect_url:S}),a(S));return[2,S||null]}throw(F=new Error("".concat("SubscriptionFailed",":\n").concat(j.message))).type="SubscriptionFailed",F}}))}))}export{u as checkSubscriptionHander};
|
|
1
|
+
import{__awaiter as r,__generator as t,__assign as i}from"tslib";import{l as o}from"./helpers-CBmogWIZ.js";import{searchToObject as e}from"./searchToObject.js";import{t as c}from"./tracker-DaaILhEr.js";import{u as n}from"./updateUrlWithParams-C6-BX4TY.js";import"pacman-client";import"uuid";function a(r){var t=s(r).replace(/^\/+/,"");if(!/^https?:\/\//i.test(t))throw new Error("Decoded string is not an absolute URL: ".concat(t));window.location.replace(t)}function s(r){var t;do{t=r;try{r=decodeURIComponent(r)}catch(r){break}}while(r!==t);return r}function u(u){var d,l,h,v,m=u.window,p=u.flow,f=u.action,w=u.args,_=u.extraParams,k=void 0===_?{}:_,b=u.isRedirectToChainAndProduct,y=void 0!==b&&b,E=u.isShowThankYou,R=void 0!==E&&E;return r(this,void 0,void 0,(function(){var u,_,b,E,U,g,j,S,I,P,T,F;return t(this,(function(L){switch(L.label){case 0:return u=m.pac_analytics.visitor.rockmanId,p&&f&&c.advancedInFlow(p,f,i({},w)),_=e(m),b="check-subscription-success-state"===_["current-state"],E=_.product_url||"/product",b&&(console.log("isMock is true"),(U=_["show-chain-link"])&&"1"===U&&(m.pac_analytics.visitor.chainRedirectUrl="/chain-url")),g=function(){return b?Promise.resolve({success:!0,rockman_id:u,product_url:E,msisdn:"000"}):function(i){var o=i.window,e=i.rockmanId;return r(void 0,void 0,void 0,(function(){var r,i,c;return t(this,(function(t){switch(t.label){case 0:return r=o.DEV_BASE_URL||"",i=new URLSearchParams({action:"check-subscription",rockman_id:e}).toString(),c="".concat(r,"/tallyman/v1/?").concat(i),[4,fetch(c)];case 1:return[2,t.sent().json()]}}))}))}({window:m,rockmanId:u})},[4,o(g,60,(function(r){return r.success}),0)];case 1:if(!0===(j=L.sent()).success){if(S=s(j.product_url),R)return I=n(m.location.href,{rockman_id:u,ui_show_tq:"1","show-thank-you":1,product_url:S}),setTimeout((function(){c.customEvent(p,"show-thank-you","thank-you-page",{thankYou:I}),a(I)}),3e3),[2,I];if(null===(l=null===(d=null==m?void 0:m.pac_analytics)||void 0===d?void 0:d.visitor)||void 0===l?void 0:l.chainRedirectUrl){if(P=null===(v=null===(h=null==m?void 0:m.pac_analytics)||void 0===h?void 0:h.visitor)||void 0===v?void 0:v.chainRedirectUrl,T=n(P,k),y)return c.customEvent(p,"redirect","chain-redirect",{redirect_url:T}),m.open(T,"_blank"),S&&""!==S&&setTimeout((function(){c.customEvent(p,"redirect","product-redirect",{redirect_url:S}),a(S)}),3e3),[2];c.customEvent(p,"redirect","chain-redirect",{redirect_url:T}),a(T)}else S&&""!==S&&(c.customEvent(p,"redirect","product-redirect",{redirect_url:S}),a(S));return[2,S||null]}throw(F=new Error("".concat("SubscriptionFailed",":\n").concat(j.message))).type="SubscriptionFailed",F}}))}))}export{u as checkSubscriptionHander};
|
|
2
2
|
//# sourceMappingURL=checkSubscriptionHander.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkSubscriptionHander.js","sources":["../src/utilities/checkSubscriptionHander.ts","../src/sharedApi/checkSubscriptionByRockmanIdOnly.ts"],"sourcesContent":["import { ICheckSubscriptionResult } from '../common-types/ICheckSubscriptionResult';\nimport { IError } from '../common-types/IError';\nimport { checkSubscriptionByRockmanIdOnly } from '../sharedApi/checkSubscriptionByRockmanIdOnly';\nimport { loop } from './helpers';\nimport { searchToObject } from './searchToObject';\nimport { tracker } from './tracker';\nimport { updateUrlWithParams } from './updateUrlWithParams';\n\nfunction redirect(rawUrl: string) {\n const target = fullyDecode(rawUrl).replace(/^\\/+/, ''); // drop leading /\n if (!/^https?:\\/\\//i.test(target)) {\n throw new Error(`Decoded string is not an absolute URL: ${target}`);\n }\n
|
|
1
|
+
{"version":3,"file":"checkSubscriptionHander.js","sources":["../src/utilities/checkSubscriptionHander.ts","../src/sharedApi/checkSubscriptionByRockmanIdOnly.ts"],"sourcesContent":["import { ICheckSubscriptionResult } from '../common-types/ICheckSubscriptionResult';\nimport { IError } from '../common-types/IError';\nimport { checkSubscriptionByRockmanIdOnly } from '../sharedApi/checkSubscriptionByRockmanIdOnly';\nimport { loop } from './helpers';\nimport { searchToObject } from './searchToObject';\nimport { tracker } from './tracker';\nimport { updateUrlWithParams } from './updateUrlWithParams';\n\nfunction redirect(rawUrl: string) {\n const target = fullyDecode(rawUrl).replace(/^\\/+/, ''); // drop leading /\n if (!/^https?:\\/\\//i.test(target)) {\n throw new Error(`Decoded string is not an absolute URL: ${target}`);\n }\n window.location.replace(target); // or: window.location.href = target\n}\n\nfunction fullyDecode(s: string): string {\n let prev;\n do {\n prev = s;\n try {\n s = decodeURIComponent(s);\n } catch {\n break;\n } // stop if it’s no longer valid UTF-8\n } while (s !== prev);\n return s;\n}\nexport async function checkSubscriptionHander({\n window,\n flow,\n action,\n args,\n extraParams = {},\n isRedirectToChainAndProduct = false,\n isShowThankYou = false\n}: {\n window: Window;\n flow?: string;\n action?: string;\n args?: any;\n extraParams?: any;\n isRedirectToChainAndProduct?: boolean;\n isShowThankYou?: boolean;\n}): Promise<string> {\n const { rockmanId } = window.pac_analytics.visitor;\n if (flow && action) {\n tracker.advancedInFlow(flow, action, {\n ...args\n });\n }\n const search = searchToObject(window);\n const isMock = search['current-state'] === 'check-subscription-success-state';\n const mockProductUrl = search.product_url || '/product';\n if (isMock) {\n // eslint-disable-next-line no-console\n console.log('isMock is true');\n const mockChain = search['show-chain-link'];\n if (mockChain && mockChain === '1') {\n window.pac_analytics.visitor.chainRedirectUrl = '/chain-url';\n }\n }\n const check: () => Promise<ICheckSubscriptionResult> = () =>\n isMock\n ? Promise.resolve({\n success: true,\n rockman_id: rockmanId,\n product_url: mockProductUrl,\n msisdn: '000'\n })\n : checkSubscriptionByRockmanIdOnly({ window, rockmanId });\n const checkResult: ICheckSubscriptionResult = await loop(check, 60, (r) => r.success, 0);\n\n if (checkResult.success === true) {\n const productUrl = fullyDecode(checkResult.product_url);\n // if (flow && action) {\n // tracker.advancedInFlow(flow, action, {\n // ...args,\n // url: checkResult.product_url\n // });\n // }\n if (isShowThankYou) {\n const thankYou = updateUrlWithParams(window.location.href, {\n rockman_id: rockmanId,\n ui_show_tq: '1', // New param\n 'show-thank-you': 1, // backward compatibility\n product_url: productUrl\n });\n setTimeout(() => {\n tracker.customEvent(flow, 'show-thank-you', 'thank-you-page', { thankYou });\n\n redirect(thankYou);\n }, 3000);\n\n return thankYou;\n }\n if (window?.pac_analytics?.visitor?.chainRedirectUrl) {\n const chainLink = window?.pac_analytics?.visitor?.chainRedirectUrl;\n const updatedChainLink = updateUrlWithParams(chainLink, extraParams);\n if (isRedirectToChainAndProduct) {\n tracker.customEvent(flow, 'redirect', 'chain-redirect', { redirect_url: updatedChainLink });\n window.open(\n updatedChainLink,\n '_blank' // <- This is what makes it open in a new window.\n );\n if (productUrl && productUrl !== '') {\n setTimeout(() => {\n tracker.customEvent(flow, 'redirect', 'product-redirect', { redirect_url: productUrl });\n redirect(productUrl);\n }, 3000);\n }\n return;\n }\n\n tracker.customEvent(flow, 'redirect', 'chain-redirect', { redirect_url: updatedChainLink });\n redirect(updatedChainLink);\n } else if (productUrl && productUrl !== '') {\n tracker.customEvent(flow, 'redirect', 'product-redirect', { redirect_url: productUrl });\n redirect(productUrl);\n }\n\n return productUrl || null;\n }\n const error = new Error(`${'SubscriptionFailed'}:\\n${checkResult.message}`) as IError & { type: string };\n error.type = 'SubscriptionFailed';\n throw error;\n}\n","import { ICheckSubscriptionResult } from '../common-types/ICheckSubscriptionResult';\n\nconst checkSubscriptionByRockmanIdOnly = async ({\n window,\n rockmanId\n}: {\n window: Window;\n rockmanId: string;\n}): Promise<ICheckSubscriptionResult> => {\n const host = (window as Window).DEV_BASE_URL || '';\n\n const params = {\n action: 'check-subscription',\n rockman_id: rockmanId\n };\n\n const urlParams = new URLSearchParams(params).toString();\n const url = `${host}/tallyman/v1/?${urlParams}`;\n\n const response = await fetch(url);\n return response.json();\n};\n\nexport { checkSubscriptionByRockmanIdOnly };\n"],"names":["redirect","rawUrl","target","fullyDecode","replace","test","Error","window","location","s","prev","decodeURIComponent","_a","checkSubscriptionHander","flow","action","args","_f","extraParams","_g","isRedirectToChainAndProduct","_h","isShowThankYou","rockmanId","pac_analytics","visitor","tracker","advancedInFlow","__assign","search","searchToObject","isMock","mockProductUrl","product_url","console","log","mockChain","chainRedirectUrl","check","Promise","resolve","success","rockman_id","msisdn","host","DEV_BASE_URL","urlParams","URLSearchParams","toString","url","concat","fetch","_b","sent","json","checkSubscriptionByRockmanIdOnly","loop","r","checkResult","_j","productUrl_1","thankYou_1","updateUrlWithParams","href","ui_show_tq","setTimeout","customEvent","thankYou","_c","chainLink","_e","_d","updatedChainLink","redirect_url","open","error","message","type"],"mappings":"mSAQA,SAASA,EAASC,GAChB,IAAMC,EAASC,EAAYF,GAAQG,QAAQ,OAAQ,IACnD,IAAK,gBAAgBC,KAAKH,GACxB,MAAM,IAAII,MAAM,iDAA0CJ,IAE5DK,OAAOC,SAASJ,QAAQF,EAC1B,CAEA,SAASC,EAAYM,GACnB,IAAIC,EACJ,EAAG,CACDA,EAAOD,EACP,IACEA,E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/utilities/searchToObject.ts"],"sourcesContent":["import { IMockFlowParams, IStrategyIDentifyUserResult } from '../sharedFlowTypes/StrategyTypes';\n\
|
|
1
|
+
{"version":3,"file":"searchToObject.js","sources":["../src/utilities/searchToObject.ts"],"sourcesContent":["import { IMockFlowParams, IStrategyIDentifyUserResult } from '../sharedFlowTypes/StrategyTypes';\n\nexport function searchToObject(win: Window): IMockFlowParams<any> | IStrategyIDentifyUserResult | any {\n if (!win || !win.location || !win.location.search) return {};\n\n // URLSearchParams automatically decodes percent-encoding\n const params = new URL(win.location.href).searchParams;\n\n return Object.fromEntries(params.entries());\n}\n"],"names":["searchToObject","win","location","search","params","URL","href","searchParams","Object","fromEntries","entries"],"mappings":"AAEM,SAAUA,EAAeC,GAC7B,IAAKA,IAAQA,EAAIC,WAAaD,EAAIC,SAASC,OAAQ,MAAO,GAG1D,IAAMC,EAAS,IAAIC,IAAIJ,EAAIC,SAASI,MAAMC,aAE1C,OAAOC,OAAOC,YAAYL,EAAOM,UACnC"}
|