@apolitical/sdk 4.0.0-rc.1 → 4.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/gtm"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/gtm","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/gtm"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/gtm"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,a,n,r,o){return function(){"use strict";var s={809:function(e){e.exports=t},30:function(t){t.exports=e},36:function(t){t.exports=a},300:function(t){t.exports=n},408:function(t){t.exports=o},25:function(t){t.exports=r}},i={};function c(t){var e=i[t];if(void 0!==e)return e.exports;var a=i[t]={exports:{}};return s[t](a,a.exports,c),a.exports}c.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return c.d(e,{a:e}),e},c.d=function(t,e){for(var a in e)c.o(e,a)&&!c.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},c.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},c.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var S={};return function(){c.r(S),c.d(S,{assets:function(){return O},auth:function(){return _},buildQuestion:function(){return ce},buildQuestions:function(){return Se},contentInteraction:function(){return V},contentSuggestion:function(){return X},decodeBase64:function(){return ue},default:function(){return le},getEntries:function(){return t.getEntries},getEntry:function(){return t.getEntry},management:function(){return rt},payments:function(){return ct},people:function(){return Ht},peopleEngagement:function(){return ae},reportError:function(){return e.reportError}});var t=c(809),e=c(30),a=c(36),n={APOLITICAL:{WEBSITES:{LIVE:"https://apolitical.co",LOCALHOST:"localhost",STAGING:/https:\/\/([\w|\d|-]+)\.apolitical\.co/i,STAGING_SPLITTER:"-"},ENVIRONMENTS:{PRODUCTION:"live",LOCAL:"local"}},APIS:{ASSETS_API:{BASE_URL:"/api/assets-api",ENDPOINTS:{USERS:"/users",CERTIFICATES:"/certificates"}},AUTH_API:{BASE_URL:"/api/auth-api",ENDPOINTS:{USER_PASSWORD:"/password",USERS:"/users"}},CONTENT_INTERACTION_API:{BASE_URL:"/api/content-interaction-api",ENDPOINTS:{QUESTIONS:"/questions",ANSWERS:"/answers",LIKES:"/likes"}},CONTENT_SUGGESTIONS_API:{BASE_URL:"/api/content-suggestions-api",ENDPOINTS:{SUGGESTIONS:"/suggest"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts",LOGINS:"/logins",LOGIN_PASSWORDLESS:"/passwordless"}},PAYMENTS_API:{BASE_URL:"/api/payments-api",BASE_URL_V2:"/api/payments-api/v2",ENDPOINTS:{PRODUCTS:"/products"}},PEOPLE_API:{BASE_URL:"/api/people-api",BASE_URL_V2:"/api/people-api/v2",ENDPOINTS:{REGISTRATIONS:"/registrations",USERS:"/users",USER_ANSWERS:"/answers",USER_COURSES:"/courses",USER_EVENTS:"/events",USER_LESSONS:"/lessons",USER_PRODUCTS:"/products",USER_SUBSCRIPTIONS:"/subscriptions"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{ENQUIRY_EMAILS:"/enquiry-emails",USERS:"/users",USER_PROPERTIES:"/properties"}}},CONTENTFUL:{QUESTIONS:{TYPE:"qaQuestion",ORDER:"-sys.updatedAt",FIELDS:"sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.authorId,fields.answers,fields.isEdited"}},HUBSPOT:{ENVIRONMENTS_MAPPING:{local:"SANDBOX",beta:"SANDBOX",rc:"SANDBOX",live:"LIVE"},EMAIL_IDS:{SANDBOX:{internalEmailId:49099078634,externalEmailId:55196526554},LIVE:{internalEmailId:55233583049,externalEmailId:55231159239}}},USERS:{MYSELF:"me"}};const{APOLITICAL:{WEBSITES:{LIVE:r,LOCALHOST:o,STAGING:s,STAGING_SPLITTER:i},ENVIRONMENTS:{PRODUCTION:E,LOCAL:u}}}=n,{HUBSPOT:{ENVIRONMENTS_MAPPING:l,EMAIL_IDS:I}}=n;let p={emailIds:{}};var d=c(300),N=c.n(d);const w=async t=>{try{const{message:a,response:n,request:r}=t;let o=a;return n?o+=` - The request was made and the server responded with ${JSON.stringify({status:n.status,data:n.data})}`:r&&(o+=" - The request was made but no response was received"),console.warn(o),await(0,e.reportError)(new Error(o)),o}catch(t){return console.warn(`Cannot handle error: ${t.message}`),t.message}},{APIS:{ASSETS_API:{BASE_URL:A,ENDPOINTS:{USERS:P,CERTIFICATES:R}}}}=n;var O={certificates:{create:async(t,e)=>{let a=[];try{const{data:n}=await N().post(`${A}${P}/${t}${R}`,e);n&&(a=n)}catch(t){await w(t)}return a}}};const{APIS:{AUTH_API:{BASE_URL:T,ENDPOINTS:{USER_PASSWORD:U,USERS:y}}},USERS:{MYSELF:$}}=n;var _={userPassword:{update:async t=>{let e=null;try{e=await N().put(`${T}${y}/${$}${U}`,t)}catch(t){e={message:(((t||{}).response||{}).data||{}).message},await w(t)}return e}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:h,ENDPOINTS:{ANSWERS:m,QUESTIONS:f}}}}=n,L=`${h}${f}`;var g={create:async(t,e)=>{try{await N().post(`${L}/${encodeURIComponent(t)}${m}`,e)}catch(t){const e=await w(t);throw new Error(e)}},remove:async(t,e)=>{try{await N().delete(`${L}/${encodeURIComponent(t)}${m}/${encodeURIComponent(e)}`)}catch(t){const e=await w(t);throw new Error(e)}},update:async(t,e,a)=>{try{return await N().put(`${L}/${encodeURIComponent(t)}${m}/${encodeURIComponent(e)}`,{body:a})}catch(t){const e=await w(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:C,ENDPOINTS:{QUESTIONS:v}}}}=n,D=`${C}${v}`;var B={create:async t=>{try{return await N().post(D,t)}catch(t){const e=await w(t);throw new Error(e)}},remove:async t=>{try{await N().delete(`${D}/${encodeURIComponent(t)}`)}catch(t){const e=await w(t);throw new Error(e)}},update:async(t,e)=>{try{return await N().put(`${D}/${encodeURIComponent(t)}`,{title:e})}catch(t){const e=await w(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:G,ENDPOINTS:{QUESTIONS:M,ANSWERS:b,LIKES:x}}}}=n,q=`${G}${M}`;var V={answers:g,questions:B,likes:{create:async(t,e)=>{try{return await N().post(`${q}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}${x}`)}catch(t){const e=await w(t);throw new Error(e)}},remove:async(t,e)=>{try{return await N().delete(`${q}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}${x}`)}catch(t){const e=await w(t);throw new Error(e)}}}},F=c(25);const{OK:Y,MULTIPLE_CHOICES:Q,NOT_FOUND:j,FORBIDDEN:W}=F.StatusCodes,H=t=>t>=Y&&t<Q||t===W||t===j,{APIS:{CONTENT_SUGGESTIONS_API:{BASE_URL:K,ENDPOINTS:{SUGGESTIONS:k}}}}=n;var X={suggestions:{list:async(t={})=>{let e=[],a=Object.assign({validateStatus:H},t);try{const{data:t}=await N().get(`${K}${k}`,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e}}};const{APIS:{MANAGEMENT_API:{BASE_URL:J,ENDPOINTS:{ACCOUNTS:z}}}}=n;var Z={create:async t=>{try{await N().post(`${J}${z}`,t)}catch(t){throw await w(t),t}},read:async t=>{let e=null;try{({data:e}=await N().get(`${J}${z}/${encodeURIComponent(t)}`))}catch(t){await w(t)}return e},update:async(t,e)=>{try{await N().put(`${J}${z}/${encodeURIComponent(t)}`,e)}catch(t){throw await w(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:tt,ENDPOINTS:{LOGINS:et,LOGIN_PASSWORDLESS:at}}}}=n,nt=`${tt}${et}`;var rt={accounts:Z,passwordless:{update:async t=>{try{await N().put(`${nt}/${encodeURIComponent(t)}${at}`)}catch(t){throw await w(t),t}}}};const{APIS:{PAYMENTS_API:{BASE_URL_V2:ot,ENDPOINTS:{PRODUCTS:st}}}}=n,it=`${ot}${st}`;var ct={products:{list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(it,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:St,ENDPOINTS:{USERS:Et}}}}=n,ut=async t=>{let e=null;try{const{data:a}=await N().get(`${St}${Et}/${encodeURIComponent(t)}`,{validateStatus:H});a&&a.id&&(e=a)}catch(t){await w(t)}return e};var lt={read:ut,update:async(t,e)=>{let a=!1;try{const{data:n}=await N().put(`${St}${Et}/${encodeURIComponent(t)}`,e);a=!(!n||!n.id)}catch(t){await w(t)}return a}};const{APIS:{PEOPLE_API:{BASE_URL_V2:It,ENDPOINTS:{USERS:pt,USER_ANSWERS:dt}}},USERS:{MYSELF:Nt}}=n,wt=`${It}${pt}/${Nt}${dt}`,At=async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(wt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e};var Pt={list:At},Rt={authors:{readQuestionAuthors:async(t,e,a=!1)=>{try{if(t.author=await ut(t.authorId),t.answers&&t.answers.length&&!a){const a=[];if(e){const e=(await At("me",t.slug)).filter((t=>t.liked));for(const t of e)a.push(t.answerSlug)}for(let e of t.answers)e.author=e.authorId&&await ut(e.authorId)||{},e.userLiked=a.includes(e.slug);t.answers.sort(((t,e)=>new Date(e.updatedAt)-new Date(t.updatedAt)))}return t}catch(t){throw await w(t),new Error(`Cannot read question authors: ${t.message}`)}}}};const{APIS:{PEOPLE_API:{BASE_URL:Ot,ENDPOINTS:{REGISTRATIONS:Tt}}}}=n;var Ut={list:async t=>{let e=[];try{const{data:a}=await N().get(`${Ot}${Tt}`,{params:t});a&&a.length&&(e=a)}catch(t){await w(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:yt,ENDPOINTS:{USERS:$t,USER_COURSES:_t}}},USERS:{MYSELF:ht}}=n,mt=`${yt}${$t}/${ht}${_t}`;var ft={create:async t=>{try{await N().post(mt,t)}catch(t){await w(t)}},list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(mt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e},update:async(t,e)=>{try{await N().put(`${mt}/${t}`,e)}catch(t){await w(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Lt,ENDPOINTS:{USERS:gt,USER_EVENTS:Ct}}},USERS:{MYSELF:vt}}=n,Dt=`${Lt}${gt}/${vt}${Ct}`;var Bt={list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(Dt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Gt,ENDPOINTS:{USERS:Mt,USER_LESSONS:bt}}},USERS:{MYSELF:xt}}=n,qt=`${Gt}${Mt}/${xt}${bt}`;var Vt={create:async t=>{let e=null;try{e=await N().post(qt,t)}catch(t){await w(t)}return e},list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(qt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Ft,ENDPOINTS:{USERS:Yt,USER_PRODUCTS:Qt}}},USERS:{MYSELF:jt}}=n,Wt=`${Ft}${Yt}/${jt}${Qt}`;var Ht={handlers:Rt,registrations:Ut,users:lt,userAnswers:Pt,userCourses:ft,userEvents:Bt,userLessons:Vt,userProducts:{create:async t=>{let e=null;try{e=await N().post(Wt,t)}catch(t){await w(t)}return e},list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(Wt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e},update:async(t,e)=>{try{await N().put(`${Wt}/${t}`,e)}catch(t){await w(t)}}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:Kt,ENDPOINTS:{ENQUIRY_EMAILS:kt}}}}=n;var Xt={create:async t=>{let e=null;try{const{data:a}=await N().post(`${Kt}${kt}`,t);a&&(e=a)}catch(t){await w(t)}return e}},Jt={forms:{sendEnquiryEmails:async t=>{let e=null;try{const{emailIds:a}=p;e=await ae.emails.create({...a,...t})}catch(t){await w(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:zt,ENDPOINTS:{USERS:Zt,USER_PROPERTIES:te}}},USERS:{MYSELF:ee}}=n;var ae={emails:Xt,handlers:Jt,userProperties:{update:async(t,e)=>{try{await N().put(`${zt}${Zt}/${ee}${te}/${t}`,e)}catch(t){await w(t)}}}};const{CONTENTFUL:ne}=n,{TYPE:re,ORDER:oe,FIELDS:se}=ne.QUESTIONS;var ie={read:async e=>{try{return await(0,t.getEntry)({content_type:re,"fields.slug":e,include:2,select:se})}catch(t){throw await w(t),new Error(`Cannot read question: ${t.message}`)}},list:async(e=10,a=0,n={})=>{try{return await(0,t.getEntries)({content_type:re,include:1,limit:e,order:oe,select:se,"fields.private[ne]":!0,skip:a,...n})}catch(t){throw await w(t),new Error(`Cannot list questions: ${t.message}`)}}},ce=async(t,e,a=!1)=>{try{let n={};return n=await ie.read(t),n=await Ht.handlers.authors.readQuestionAuthors(n,e,a),n}catch(t){throw await w(t),new Error(`Cannot build question: ${t.message}`)}},Se=async(t,e=10,a={})=>{try{let n=[];const r=e*(t-1);n=await ie.list(e,r,a);for(let t of n)t.author=t.authorId&&await Ht.users.read(t.authorId)||{};return n}catch(t){throw await w(t),new Error(`Cannot build questions: ${t.message}`)}},Ee=c(408);const ue=t=>t&&Ee.Buffer.from(t,"base64").toString("ascii");function le({contentContext:n=null,errorsContext:c=null,gtmContext:S=null,origin:d}){try{const N=(t=>{let e=null;t?e=t:"undefined"!=typeof window&&(e=window.origin||window.location.origin),e||new Error("Cannot select environment: Website not defined");let a=null;const n=e.match(s);return n?a=n[1].split(i)[0]:e===r?a=E:e.includes(o)&&(a=u),a||new Error(`Cannot select environment: No rule for website ${e}`),a})(d);n&&(0,t.setContext)(Object.assign({},n,{environment:N})),c&&(0,e.setContext)(Object.assign({},c,{environment:N})),S&&((0,a.setContext)(Object.assign({},S,{environment:N})),(0,a.setupGTM)()),(({environment:t})=>{const e=(t=>{if(!t)throw new Error("Cannot map environment: Environment not defined");if(!l[t])throw new Error(`Cannot map environment: No mapping found for environment ${t}`);return l[t]})(t);p.emailIds=I[e]})(Object.assign({},{environment:N}))}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),S}()}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/gtm"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/gtm","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/gtm"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/gtm"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,a,n,r,o){return function(){"use strict";var s={809:function(e){e.exports=t},30:function(t){t.exports=e},36:function(t){t.exports=a},300:function(t){t.exports=n},408:function(t){t.exports=o},25:function(t){t.exports=r}},i={};function c(t){var e=i[t];if(void 0!==e)return e.exports;var a=i[t]={exports:{}};return s[t](a,a.exports,c),a.exports}c.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return c.d(e,{a:e}),e},c.d=function(t,e){for(var a in e)c.o(e,a)&&!c.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},c.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},c.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var S={};return function(){c.r(S),c.d(S,{assets:function(){return O},auth:function(){return _},buildQuestion:function(){return ce},buildQuestions:function(){return Se},contentInteraction:function(){return V},contentSuggestion:function(){return X},decodeBase64:function(){return ue},default:function(){return le},getEntries:function(){return t.getEntries},getEntry:function(){return t.getEntry},management:function(){return rt},payments:function(){return ct},people:function(){return Ht},peopleEngagement:function(){return ae},reportError:function(){return e.reportError}});var t=c(809),e=c(30),a=c(36),n={APOLITICAL:{WEBSITES:{LIVE:"https://apolitical.co",LOCALHOST:"localhost",STAGING:/https:\/\/([\w|\d|-]+)\.apolitical\.co/i,STAGING_SPLITTER:"-"},ENVIRONMENTS:{PRODUCTION:"live",LOCAL:"local"}},APIS:{ASSETS_API:{BASE_URL:"/api/assets-api",ENDPOINTS:{USERS:"/users",CERTIFICATES:"/certificates"}},AUTH_API:{BASE_URL:"/api/auth-api",ENDPOINTS:{USER_PASSWORD:"/password",USERS:"/users"}},CONTENT_INTERACTION_API:{BASE_URL:"/api/content-interaction-api",ENDPOINTS:{QUESTIONS:"/questions",ANSWERS:"/answers",LIKES:"/likes"}},CONTENT_SUGGESTIONS_API:{BASE_URL:"/api/content-suggestions-api",ENDPOINTS:{SUGGESTIONS:"/suggest"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts",LOGINS:"/logins",LOGIN_PASSWORDLESS:"/passwordless"}},PAYMENTS_API:{BASE_URL:"/api/payments-api",BASE_URL_V2:"/api/payments-api/v2",ENDPOINTS:{PRODUCTS:"/products"}},PEOPLE_API:{BASE_URL:"/api/people-api",BASE_URL_V2:"/api/people-api/v2",ENDPOINTS:{REGISTRATIONS:"/registrations",USERS:"/users",USER_ANSWERS:"/answers",USER_COURSES:"/courses",USER_EVENTS:"/events",USER_LESSONS:"/lessons",USER_PRODUCTS:"/products",USER_SUBSCRIPTIONS:"/subscriptions"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{ENQUIRY_EMAILS:"/enquiry-emails",USERS:"/users",USER_PROPERTIES:"/properties"}}},CONTENTFUL:{QUESTIONS:{TYPE:"qaQuestion",ORDER:"-sys.updatedAt",FIELDS:"sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.authorId,fields.answers,fields.isEdited"}},HUBSPOT:{ENVIRONMENTS_MAPPING:{local:"SANDBOX",beta:"SANDBOX",rc:"SANDBOX",live:"LIVE"},EMAIL_IDS:{SANDBOX:{internalEmailId:49099078634,externalEmailId:55196526554},LIVE:{internalEmailId:55233583049,externalEmailId:55231159239}}},USERS:{MYSELF:"me"}};const{APOLITICAL:{WEBSITES:{LIVE:r,LOCALHOST:o,STAGING:s,STAGING_SPLITTER:i},ENVIRONMENTS:{PRODUCTION:E,LOCAL:u}}}=n,{HUBSPOT:{ENVIRONMENTS_MAPPING:l,EMAIL_IDS:I}}=n;let p={emailIds:{}};var d=c(300),N=c.n(d);const w=async t=>{try{const{message:a,response:n,request:r}=t;let o=a;return n?o+=` - The request was made and the server responded with ${JSON.stringify({status:n.status,data:n.data})}`:r&&(o+=" - The request was made but no response was received"),console.warn(o),await(0,e.reportError)(new Error(o)),o}catch(t){return console.warn(`Cannot handle error: ${t.message}`),t.message}},{APIS:{ASSETS_API:{BASE_URL:A,ENDPOINTS:{USERS:P,CERTIFICATES:R}}}}=n;var O={certificates:{create:async(t,e)=>{let a=[];try{const{data:n}=await N().post(`${A}${P}/${t}${R}`,e);n&&(a=n)}catch(t){await w(t)}return a}}};const{APIS:{AUTH_API:{BASE_URL:T,ENDPOINTS:{USER_PASSWORD:U,USERS:y}}},USERS:{MYSELF:$}}=n;var _={userPassword:{update:async t=>{let e=null;try{e=await N().put(`${T}${y}/${$}${U}`,t)}catch(t){e={message:(((t||{}).response||{}).data||{}).message},await w(t)}return e}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:h,ENDPOINTS:{ANSWERS:m,QUESTIONS:f}}}}=n,L=`${h}${f}`;var g={create:async(t,e)=>{try{await N().post(`${L}/${encodeURIComponent(t)}${m}`,e)}catch(t){const e=await w(t);throw new Error(e)}},remove:async(t,e)=>{try{await N().delete(`${L}/${encodeURIComponent(t)}${m}/${encodeURIComponent(e)}`)}catch(t){const e=await w(t);throw new Error(e)}},update:async(t,e,a)=>{try{return await N().put(`${L}/${encodeURIComponent(t)}${m}/${encodeURIComponent(e)}`,{body:a})}catch(t){const e=await w(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:C,ENDPOINTS:{QUESTIONS:v}}}}=n,D=`${C}${v}`;var B={create:async t=>{try{return await N().post(D,t)}catch(t){const e=await w(t);throw new Error(e)}},remove:async t=>{try{await N().delete(`${D}/${encodeURIComponent(t)}`)}catch(t){const e=await w(t);throw new Error(e)}},update:async(t,e)=>{try{return await N().put(`${D}/${encodeURIComponent(t)}`,{title:e})}catch(t){const e=await w(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:G,ENDPOINTS:{QUESTIONS:M,ANSWERS:b,LIKES:x}}}}=n,q=`${G}${M}`;var V={answers:g,questions:B,likes:{create:async(t,e)=>{try{return await N().post(`${q}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}${x}`)}catch(t){const e=await w(t);throw new Error(e)}},remove:async(t,e)=>{try{return await N().delete(`${q}/${encodeURIComponent(t)}${b}/${encodeURIComponent(e)}${x}`)}catch(t){const e=await w(t);throw new Error(e)}}}},F=c(25);const{OK:Y,MULTIPLE_CHOICES:Q,NOT_FOUND:j,FORBIDDEN:W}=F.StatusCodes,H=t=>t>=Y&&t<Q||t===W||t===j,{APIS:{CONTENT_SUGGESTIONS_API:{BASE_URL:K,ENDPOINTS:{SUGGESTIONS:k}}}}=n;var X={suggestions:{list:async(t={})=>{let e=[],a=Object.assign({validateStatus:H},t);try{const{data:t}=await N().get(`${K}${k}`,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e}}};const{APIS:{MANAGEMENT_API:{BASE_URL:J,ENDPOINTS:{ACCOUNTS:z}}}}=n;var Z={create:async t=>{try{await N().post(`${J}${z}`,t)}catch(t){throw await w(t),t}},read:async t=>{let e=null;try{({data:e}=await N().get(`${J}${z}/${encodeURIComponent(t)}`))}catch(t){await w(t)}return e},update:async(t,e)=>{try{await N().put(`${J}${z}/${encodeURIComponent(t)}`,e)}catch(t){throw await w(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:tt,ENDPOINTS:{LOGINS:et,LOGIN_PASSWORDLESS:at}}}}=n,nt=`${tt}${et}`;var rt={accounts:Z,passwordless:{update:async t=>{try{await N().put(`${nt}/${encodeURIComponent(t)}${at}`)}catch(t){throw await w(t),t}}}};const{APIS:{PAYMENTS_API:{BASE_URL_V2:ot,ENDPOINTS:{PRODUCTS:st}}}}=n,it=`${ot}${st}`;var ct={products:{list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(it,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:St,ENDPOINTS:{USERS:Et}}}}=n,ut=async t=>{let e=null;try{const{data:a}=await N().get(`${St}${Et}/${encodeURIComponent(t)}`,{validateStatus:H});a&&a.id&&(e=a)}catch(t){await w(t)}return e};var lt={read:ut,update:async(t,e)=>{let a=!1;try{const{data:n}=await N().put(`${St}${Et}/${encodeURIComponent(t)}`,e);a=!(!n||!n.id)}catch(t){await w(t)}return a}};const{APIS:{PEOPLE_API:{BASE_URL_V2:It,ENDPOINTS:{USERS:pt,USER_ANSWERS:dt}}},USERS:{MYSELF:Nt}}=n,wt=`${It}${pt}/${Nt}${dt}`,At=async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(wt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e};var Pt={list:At},Rt={authors:{readQuestionAuthors:async(t,e,a=!1)=>{try{if(t.author=await ut(t.authorId),t.answers&&t.answers.length&&!a){const a=[];if(e){const e=(await At("me",t.slug)).filter((t=>t.liked));for(const t of e)a.push(t.answerSlug)}for(let e of t.answers)e.author=e.authorId&&await ut(e.authorId)||{},e.userLiked=a.includes(e.slug);t.answers.sort(((t,e)=>new Date(e.updatedAt)-new Date(t.updatedAt)))}return t}catch(t){throw await w(t),new Error(`Cannot read question authors: ${t.message}`)}}}};const{APIS:{PEOPLE_API:{BASE_URL:Ot,ENDPOINTS:{REGISTRATIONS:Tt}}}}=n;var Ut={list:async t=>{let e=[];try{const{data:a}=await N().get(`${Ot}${Tt}`,{params:t});a&&a.length&&(e=a)}catch(t){await w(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:yt,ENDPOINTS:{USERS:$t,USER_COURSES:_t}}},USERS:{MYSELF:ht}}=n,mt=`${yt}${$t}/${ht}${_t}`;var ft={create:async t=>{try{await N().post(mt,t)}catch(t){await w(t)}},list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(mt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e},update:async(t,e)=>{try{await N().put(`${mt}/${t}`,e)}catch(t){await w(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Lt,ENDPOINTS:{USERS:gt,USER_EVENTS:Ct}}},USERS:{MYSELF:vt}}=n,Dt=`${Lt}${gt}/${vt}${Ct}`;var Bt={list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(Dt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Gt,ENDPOINTS:{USERS:Mt,USER_LESSONS:bt}}},USERS:{MYSELF:xt}}=n,qt=`${Gt}${Mt}/${xt}${bt}`;var Vt={create:async t=>{let e=null;try{e=await N().post(qt,t)}catch(t){await w(t)}return e},list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(qt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Ft,ENDPOINTS:{USERS:Yt,USER_PRODUCTS:Qt}}},USERS:{MYSELF:jt}}=n,Wt=`${Ft}${Yt}/${jt}${Qt}`;var Ht={handlers:Rt,registrations:Ut,users:lt,userAnswers:Pt,userCourses:ft,userEvents:Bt,userLessons:Vt,userProducts:{create:async t=>{let e=null;try{e=await N().post(Wt,t)}catch(t){await w(t)}return e},list:async t=>{let e=[],a=t?{params:t}:{params:{}};try{const{data:t}=await N().get(Wt,a);t&&t.length&&(e=t)}catch(t){await w(t)}return e},update:async(t,e)=>{try{await N().put(`${Wt}/${t}`,e)}catch(t){await w(t)}}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:Kt,ENDPOINTS:{ENQUIRY_EMAILS:kt}}}}=n;var Xt={create:async t=>{let e=null;try{const{data:a}=await N().post(`${Kt}${kt}`,t);a&&(e=a)}catch(t){await w(t)}return e}},Jt={forms:{sendEnquiryEmails:async t=>{let e=null;try{const{emailIds:a}=p;e=await ae.emails.create({...a,...t})}catch(t){await w(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:zt,ENDPOINTS:{USERS:Zt,USER_PROPERTIES:te}}},USERS:{MYSELF:ee}}=n;var ae={emails:Xt,handlers:Jt,userProperties:{update:async(t,e)=>{try{await N().put(`${zt}${Zt}/${ee}${te}/${t}`,e)}catch(t){await w(t)}}}};const{CONTENTFUL:ne}=n,{TYPE:re,ORDER:oe,FIELDS:se}=ne.QUESTIONS;var ie={read:async e=>{try{return await(0,t.getEntry)({content_type:re,"fields.slug":e,include:2,select:se})}catch(t){throw await w(t),new Error(`Cannot read question: ${t.message}`)}},list:async(e=10,a=0,n={})=>{try{return await(0,t.getEntries)({content_type:re,include:1,limit:e,order:oe,select:se,"fields.private[ne]":!0,skip:a,...n})}catch(t){throw await w(t),new Error(`Cannot list questions: ${t.message}`)}}},ce=async(t,e,a=!1)=>{try{let n={};return n=await ie.read(t),n=await Ht.handlers.authors.readQuestionAuthors(n,e,a),n}catch(t){throw await w(t),new Error(`Cannot build question: ${t.message}`)}},Se=async(t,e=10,a={})=>{try{let n=[];const r=e*(t-1);n=await ie.list(e,r,a);for(let t of n)t.author=t.authorId&&await Ht.users.read(t.authorId)||{};return n}catch(t){throw await w(t),new Error(`Cannot build questions: ${t.message}`)}},Ee=c(408);const ue=t=>t&&Ee.Buffer.from(t,"base64").toString("ascii");function le({contentContext:n=null,errorsContext:c=null,gtmContext:S=null,origin:d}){try{const N=(t=>{let e=null;t?e=t:"undefined"!=typeof window&&(e=window.origin||window.location.origin),e||new Error("Cannot select environment: Website not defined");let a=null;const n=e.match(s);return n?a=n[1].split(i)[0]:e===r?a=E:e.includes(o)&&(a=u),a||new Error(`Cannot select environment: No rule for website ${e}`),a})(d);return n&&(0,t.setContext)(Object.assign({},n,{environment:N})),c&&(0,e.setContext)(Object.assign({},c,{environment:N})),S&&((0,a.setContext)(Object.assign({},S,{environment:N})),(0,a.setupGTM)()),(({environment:t})=>{const e=(t=>{if(!t)throw new Error("Cannot map environment: Environment not defined");if(!l[t])throw new Error(`Cannot map environment: No mapping found for environment ${t}`);return l[t]})(t);p.emailIds=I[e]})(Object.assign({},{environment:N})),N}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),S}()}));
|
package/package.json
CHANGED