@apolitical/sdk 8.1.0-ld.0 → 8.1.0

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 CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !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("socket.io-client"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/gtm","axios","http-status-codes","socket.io-client","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("socket.io-client"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/gtm"],t.axios,t["http-status-codes"],t["socket.io-client"],t.buffer)}(this,(function(t,e,r,a,n,s,i){return function(){"use strict";var o={809:function(e){e.exports=t},30:function(t){t.exports=e},36:function(t){t.exports=r},300:function(t){t.exports=a},408:function(t){t.exports=i},25:function(t){t.exports=n},130:function(t){t.exports=s}},c={};function l(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return o[t](r,r.exports,l),r.exports}l.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return l.d(e,{a:e}),e},l.d=function(t,e){for(var r in e)l.o(e,r)&&!l.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},l.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},l.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return function(){l.r(u),l.d(u,{assets:function(){return N},auth:function(){return $},buildAnswer:function(){return aa},buildCarouselCard:function(){return ra},buildQuestion:function(){return Fr},carouselCards:function(){return Ur},contentInteraction:function(){return X},decodeBase64:function(){return Sa},default:function(){return da},editorialPages:function(){return br},features:function(){return et},getEntries:function(){return t.getEntries},getEntry:function(){return t.getEntry},management:function(){return wt},mgmt:function(){return Tt},payments:function(){return $t},people:function(){return Ve},peopleEngagement:function(){return ze},predictPlace:function(){return ua},qaQuestions:function(){return Yr},reportError:function(){return e.reportError},search:function(){return nr},socials:function(){return Pr}});var t=l(809),e=l(30),r=l(36),a={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",REPLIES:"/replies",LIKES:"/likes"}},FEATURES_API:{BASE_URL:"/api/features-api",ENDPOINTS:{FLAGS:"/features"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts",EVENT_REGISTRATIONS:"/event-registrations",LOGINS:"/logins",LOGIN_PASSWORDLESS:"/passwordless",BULK_ENROLMENTS:"/bulk-enrolments"}},MGMT_API:{BASE_URL:"/api/mgmt-api",ENDPOINTS:{REFERRALS:"/referrals",BULK_REFERRALS:"/bulk-referrals"}},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:{COMMUNITIES:"/user-communities",BULK_ENROLMENTS:"/bulk-enrolments",MY_COMMUNITIES:"/users/me/communities",REGISTRATIONS:"/registrations",USERS:"/users",USER_ANSWERS:"/answers",USER_COURSES:"/courses",USER_EVENTS:"/events",USER_LIKES:"/likes",USER_LESSONS:"/lessons",USER_PRODUCTS:"/products",USER_RATINGS:"/ratings",USER_REFERRALS:"/referrals",USER_SUBSCRIPTIONS:"/subscriptions"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{ENQUIRY_EMAILS:"/enquiry-emails",USERS:"/users",USER_PROPERTIES:"/properties"}},SEARCH_API:{BASE_URL:"/api/search-api",ENDPOINTS:{SEARCH:"/search"}},SOCIALS_API:{BASE_URL:"/api/socials-api",ENDPOINTS:{COMMUNITIES:"/communities"},PATHS:{ACTIVITIES:"activities",REACTIONS:"reactions"}}},CONTENTFUL:{ARTICLES:{TYPE:"solutionArticle"},CAROUSELS:{CARD_TYPES:{communityPage:{INCLUDE:1,SELECT:"fields.bannerSection,fields.slug,fields.title"},customCard:{INCLUDE:1,SELECT:"fields.icon,fields.label,fields.image,fields.primaryText,fields.secondaryText,fields.authorName,fields.authorImage,fields.link,fields.openInNewTab"},solutionArticle:{INCLUDE:1,SELECT:"fields.authorIds,fields.authorTag,fields.image,fields.publishedDate,fields.readingTime,fields.slug,fields.title"},microcourse:{INCLUDE:2,SELECT:"fields.banner,fields.freeCourse,fields.partnershipDetails,fields.slug,fields.title,fields.courseType"},event:{INCLUDE:1,SELECT:"fields.bannerImage,fields.defaultStartDate,fields.slug,fields.speakers,fields.title,fields.isEventOngoing"},listPage:{INCLUDE:1,SELECT:"fields.hero,fields.slug,fields.title"},qaQuestion:{INCLUDE:0,SELECT:"fields.answers,fields.authorId,fields.slug,fields.title,sys.createdAt,fields.projectNames"},learningHub:{INCLUDE:1,SELECT:"fields.bannerSection,fields.customLabel,fields.slug,fields.title"}}},COMMUNITY:{TYPE:"communityPage"},COURSES:{TYPE:"microcourse"},CUSTOM_CARD:{TYPE:"customCard"},EDITORIAL_PAGES:{INCLUDE:1,SELECT:"fields.carousels,fields.slug,fields.showCarouselCta,fields.header,fields.subHeader",TYPE:"editorialPage"},EVENTS:{TYPE:"event"},LISTS:{TYPE:"listPage"},QUESTIONS:{TYPE:"qaQuestion",INCLUDE:1,LIMIT:10,ORDER:"-sys.createdAt",SELECT:"sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.authorId,fields.answers,fields.isEdited,fields.projectNames",SKIP:0},ANSWERS:{TYPE:"qaAnswer"},REPLIES:{TYPE:"reply"},LEARNING_HUB:{TYPE:"learningHub"}},GOOGLE:{MAPS:{LIBRARIES:{PLACES:"places"},VERSION:"weekly"}},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:n,LOCALHOST:s,STAGING:i,STAGING_SPLITTER:o},ENVIRONMENTS:{PRODUCTION:c,LOCAL:E}}}=a,{HUBSPOT:{ENVIRONMENTS_MAPPING:S,EMAIL_IDS:d}}=a;let p={emailIds:{}};const h=()=>p;var I=l(300),w=l.n(I);const g=async t=>{try{const{message:r,response:a,request:n}=t;let s=r;return a?s+=` - The request was made and the server responded with ${JSON.stringify({status:a.status,data:a.data})}`:n&&(s+=" - The request was made but no response was received"),console.warn(s),await(0,e.reportError)(new Error(s)),s}catch(t){return console.warn(`Cannot handle error: ${t.message}`),t.message}},{APIS:{ASSETS_API:{BASE_URL:y,ENDPOINTS:{USERS:m,CERTIFICATES:A}}}}=a;var N={certificates:{create:async(t,e)=>{let r=[];try{const{data:a}=await w().post(`${y}${m}/${t}${A}`,e);a&&(r=a)}catch(t){await g(t)}return r}}};const{APIS:{AUTH_API:{BASE_URL:T,ENDPOINTS:{USER_PASSWORD:f,USERS:P}}},USERS:{MYSELF:R}}=a;var $={userPassword:{update:async t=>{let e=null;try{e=await w().put(`${T}${P}/${R}${f}`,t)}catch(t){e={message:(((t||{}).response||{}).data||{}).message},await g(t)}return e}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:L,ENDPOINTS:{ANSWERS:U,QUESTIONS:O,LIKES:C}}}}=a,_=`${L}${O}`;var v={create:async({questionSlug:t},e)=>{try{await w().post(`${_}/${encodeURIComponent(t)}${U}`,e)}catch(t){const e=await g(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e})=>{try{await w().delete(`${_}/${encodeURIComponent(t)}${U}/${encodeURIComponent(e)}`)}catch(t){const e=await g(t);throw new Error(e)}},update:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().put(`${_}/${encodeURIComponent(t)}${U}/${encodeURIComponent(e)}`,r)}catch(t){const e=await g(t);throw new Error(e)}},like:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().post(`${_}/${encodeURIComponent(t)}${U}/${encodeURIComponent(e)}${C}`,r)}catch(t){const e=await g(t);throw new Error(e)}},unlike:async({questionSlug:t,answerSlug:e})=>{try{return await w().delete(`${_}/${encodeURIComponent(t)}${U}/${encodeURIComponent(e)}${C}`)}catch(t){const e=await g(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:b,ENDPOINTS:{QUESTIONS:D}}}}=a,M=`${b}${D}`;var B={create:async t=>{try{return await w().post(M,t)}catch(t){const e=await g(t);throw new Error(e)}},remove:async({questionSlug:t})=>{try{await w().delete(`${M}/${encodeURIComponent(t)}`)}catch(t){const e=await g(t);throw new Error(e)}},update:async({questionSlug:t},e)=>{try{return await w().put(`${M}/${encodeURIComponent(t)}`,e)}catch(t){const e=await g(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:k,ENDPOINTS:{REPLIES:q,ANSWERS:G,QUESTIONS:x,LIKES:Y}}}}=a,F=`${k}${x}`,V=({questionSlug:t,answerSlug:e,replySlug:r},a=!1)=>{let n=`${F}/${encodeURIComponent(t)}${G}/${encodeURIComponent(e)}${q}`;return r&&(n=`${n}/${encodeURIComponent(r)}`,a&&(n=`${n}${Y}`)),n};var j={create:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().post(V({questionSlug:t,answerSlug:e}),r)}catch(t){const e=await g(t);throw new Error(e)}},update:async({questionSlug:t,answerSlug:e,replySlug:r},a)=>{try{return await w().put(V({questionSlug:t,answerSlug:e,replySlug:r}),a)}catch(t){const e=await g(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e,replySlug:r})=>{try{await w().delete(V({questionSlug:t,answerSlug:e,replySlug:r}))}catch(t){const e=await g(t);throw new Error(e)}},like:async({questionSlug:t,answerSlug:e,replySlug:r,payload:a})=>{try{await w().post(V({questionSlug:t,answerSlug:e,replySlug:r},!0),a)}catch(t){const e=await g(t);throw new Error(e)}},unlike:async({questionSlug:t,answerSlug:e,replySlug:r})=>{try{await w().delete(V({questionSlug:t,answerSlug:e,replySlug:r},!0))}catch(t){const e=await g(t);throw new Error(e)}},getReplyUrl:V};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:K,ENDPOINTS:{QUESTIONS:H,ANSWERS:Q,LIKES:W}}}}=a,J=`${K}${H}`;var X={answers:v,questions:B,replies:j,likes:{create:async({questionSlug:t,answerSlug:e})=>{try{return await w().post(`${J}/${encodeURIComponent(t)}${Q}/${encodeURIComponent(e)}${W}`)}catch(t){const e=await g(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e})=>{try{return await w().delete(`${J}/${encodeURIComponent(t)}${Q}/${encodeURIComponent(e)}${W}`)}catch(t){const e=await g(t);throw new Error(e)}}}};const{APIS:{FEATURES_API:{BASE_URL:Z,ENDPOINTS:{FLAGS:z}}}}=a,tt=`${Z}${z}`;var et={flags:{read:async t=>{let e=null;try{const{data:r}=await w().get(`${tt}/${encodeURIComponent(t)}`);r?.name&&r?.featureState&&(e=r)}catch(t){await g(t)}return e}}};const{APIS:{MANAGEMENT_API:{BASE_URL:rt,ENDPOINTS:{ACCOUNTS:at}}}}=a;var nt={create:async t=>{try{await w().post(`${rt}${at}`,t)}catch(t){throw await g(t),t}},read:async t=>{let e=null;try{({data:e}=await w().get(`${rt}${at}/${encodeURIComponent(t)}`))}catch(t){await g(t)}return e},update:async(t,e)=>{try{await w().put(`${rt}${at}/${encodeURIComponent(t)}`,e)}catch(t){throw await g(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:st,ENDPOINTS:{BULK_ENROLMENTS:it}}}}=a;var ot={create:async t=>{try{await w().post(`${st}${it}`,t)}catch(t){throw await g(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:ct,ENDPOINTS:{EVENT_REGISTRATIONS:lt}}}}=a;var ut={create:async t=>{try{await w().post(`${ct}${lt}`,t)}catch(t){const e=await g(t);throw new Error(e)}}};const{APIS:{MANAGEMENT_API:{BASE_URL:Et,ENDPOINTS:{LOGINS:St,LOGIN_PASSWORDLESS:dt}}}}=a,pt=`${Et}${St}`;var ht={update:async t=>{try{await w().put(`${pt}/${encodeURIComponent(t)}${dt}`)}catch(t){throw await g(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:It}}}=a;var wt={accounts:nt,bulkEnrolments:ot,eventRegistrations:ut,passwordless:ht,userProducts:{create:async t=>{try{await w().post(`${It}/users/${t.id}/products`,t)}catch(t){const e=await g(t);throw new Error(e)}}}};const{APIS:{MGMT_API:{BASE_URL:gt,ENDPOINTS:{REFERRALS:yt}}}}=a;var mt={create:async t=>{try{await w().post(`${gt}${yt}`,t)}catch(t){throw await g(t),t}}};const{APIS:{MGMT_API:{BASE_URL:At,ENDPOINTS:{BULK_REFERRALS:Nt}}}}=a;var Tt={referrals:mt,bulkReferrals:{create:async t=>{try{await w().post(`${At}${Nt}`,t)}catch(t){throw await g(t),t}}}};const{APIS:{PAYMENTS_API:{BASE_URL_V2:ft,ENDPOINTS:{PRODUCTS:Pt}}}}=a,Rt=`${ft}${Pt}`;var $t={products:{list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Rt,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Lt,ENDPOINTS:{BULK_ENROLMENTS:Ut}}}}=a;var Ot={list:async t=>{let e=[];try{const{data:r}=await w().get(`${Lt}${Ut}`,{params:t});r&&r.length&&(e=r)}catch(t){await g(t)}return e}},Ct=l(25);const{OK:_t,MULTIPLE_CHOICES:vt,NOT_FOUND:bt,FORBIDDEN:Dt}=Ct.StatusCodes,Mt=t=>t>=_t&&t<vt||t===Dt||t===bt,{APIS:{PEOPLE_API:{BASE_URL_V2:Bt,ENDPOINTS:{USERS:kt}}}}=a,qt=async t=>{let e=null;try{const{data:r}=await w().get(`${Bt}${kt}/${encodeURIComponent(t)}`,{validateStatus:Mt});r&&r.id&&(e=r)}catch(t){await g(t)}return e},Gt=async t=>{let e=[];try{if(t&&t.length<2)throw new Error("users list method requires at least two ids");const r=t.map((t=>`ids=${encodeURIComponent(t)}`)).join("&"),a=await w().get(`${Bt}${kt}?${r}`,{validateStatus:Mt});a&&a.length&&(e=a)}catch(t){await g(t)}return e};var xt={read:qt,update:async(t,e)=>{let r=!1;try{const{data:a}=await w().put(`${Bt}${kt}/${encodeURIComponent(t)}`,e);r=!(!a||!a.id)}catch(t){await g(t)}return r},list:Gt};const{APIS:{PEOPLE_API:{BASE_URL_V2:Yt,ENDPOINTS:{USERS:Ft,USER_LIKES:Vt}}},USERS:{MYSELF:jt}}=a,Kt=`${Yt}${Ft}/${jt}${Vt}`,Ht=async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Kt,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e};var Qt={list:Ht};var Wt={authors:{readQuestionAuthors:async(t,e,r)=>{try{if(t.author=await qt(t.authorId),t.answers&&t.answers.length&&!r.ignoreAnswersAuthors){t.answers.sort(((t,e)=>new Date(e.updatedAt)-new Date(t.updatedAt))),t.totalAnswers=t.answers.length;let n=t.answers;if(r.limit&&r.pageNumber){const e=r.limit*(r.pageNumber-1);n=t.answers.slice(e,e+r.limit)}for(let t of n){t.author=t.authorId&&await qt(t.authorId)||{};const[r]=e?await Ht({contentType:a.CONTENTFUL.ANSWERS.TYPE,contentSlug:t.slug}):[null];t.userLiked=!!r}t.answers=n}else t.answers||(t.answers=[]);return t}catch(t){throw await g(t),new Error(`Cannot read authors for question: ${t.message}`)}},readAuthors:async(t=[])=>{let e=[];try{if(!1===Array.isArray(t))throw new Error("authorIds is not an array!");if(t&&1===t.length){const r=await qt(t[0]);r&&e.push(r)}else if(t&&t.length>1){const r=await Gt(t);r&&r.length>0&&(e=r)}}catch(t){throw await g(t),new Error(`Cannot read authors: ${t.message}`)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Jt,ENDPOINTS:{MY_COMMUNITIES:Xt}}}}=a,Zt=`${Jt}${Xt}`;function zt(t){const e=t["content-range"].split(" ")[1].split("/"),[r,a,n]=[...e[0].split("-"),e[1]].map((t=>parseInt(t,10)||0));return{start:r,end:a,total:n}}var te={list:async t=>{let e={items:[],start:0,end:0,total:0},r=t?{params:t}:{params:{}};try{const{data:t,headers:a}=await w().get(Zt,{...r,headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}});return t?.length>0&&(e={items:t,...zt(a)}),e}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL:ee,ENDPOINTS:{REGISTRATIONS:re}}}}=a;var ae={list:async t=>{let e=[];try{const{data:r}=await w().get(`${ee}${re}`,{params:t});r&&r.length&&(e=r)}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:ne,ENDPOINTS:{COMMUNITIES:se}}}}=a,ie=`${ne}${se}`;function oe(t){const e=t["content-range"].split(" ")[1].split("/"),[r,a,n]=[...e[0].split("-"),e[1]].map((t=>parseInt(t,10)||0));return{start:r,end:a,total:n}}var ce={list:async t=>{let e={items:[],start:0,end:0,total:0},r=t?{params:t}:{params:{}};try{const{data:t,headers:a}=await w().get(ie,{...r,headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}});return t?.length>0&&(e={items:t,...oe(a)}),e}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:le,ENDPOINTS:{USERS:ue,USER_COURSES:Ee}}},USERS:{MYSELF:Se}}=a,de=`${le}${ue}/${Se}${Ee}`;var pe={create:async t=>{try{await w().post(de,t)}catch(t){await g(t)}},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(de,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e},update:async(t,e)=>{try{await w().put(`${de}/${t}`,e)}catch(t){await g(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:he,ENDPOINTS:{USERS:Ie,USER_EVENTS:we}}},USERS:{MYSELF:ge}}=a,ye=`${he}${Ie}/${ge}${we}`;var me={list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(ye,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Ae,ENDPOINTS:{USERS:Ne,USER_LESSONS:Te}}},USERS:{MYSELF:fe}}=a,Pe=`${Ae}${Ne}/${fe}${Te}`;var Re={create:async t=>{let e=null;try{e=await w().post(Pe,t)}catch(t){await g(t)}return e},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Pe,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:$e,ENDPOINTS:{USERS:Le,USER_PRODUCTS:Ue}}},USERS:{MYSELF:Oe}}=a,Ce=`${$e}${Le}/${Oe}${Ue}`;var _e={create:async t=>{let e=null;try{e=await w().post(Ce,t)}catch(t){await g(t)}return e},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Ce,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e},update:async(t,e)=>{try{await w().put(`${Ce}/${t}`,e)}catch(t){await g(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:ve,ENDPOINTS:{USERS:be,USER_RATINGS:De}}},USERS:{MYSELF:Me}}=a,Be=`${ve}${be}/${Me}${De}`;var ke={create:async t=>{let e=null;try{const{data:r}=await w().post(Be,t);r?.id&&(e=r)}catch(t){await g(t)}return e},update:async(t,e)=>{try{await w().put(`${Be}/${t}`,e)}catch(t){await g(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:qe,ENDPOINTS:{USERS:Ge,USER_REFERRALS:xe}}},USERS:{MYSELF:Ye}}=a,Fe=`${qe}${Ge}/${Ye}${xe}`;var Ve={bulkEnrolments:Ot,handlers:Wt,myCommunities:te,registrations:ae,users:xt,userCommunities:ce,userCourses:pe,userEvents:me,userLessons:Re,userLikes:Qt,userProducts:_e,userRatings:ke,userReferrals:{list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Fe,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:je,ENDPOINTS:{ENQUIRY_EMAILS:Ke}}}}=a;var He={create:async t=>{let e=null;try{const{data:r}=await w().post(`${je}${Ke}`,t);r&&(e=r)}catch(t){await g(t)}return e}},Qe={forms:{sendEnquiryEmails:async t=>{let e=null;try{const{emailIds:r}=h();e=await ze.emails.create({...r,...t})}catch(t){await g(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:We,ENDPOINTS:{USERS:Je,USER_PROPERTIES:Xe}}},USERS:{MYSELF:Ze}}=a;var ze={emails:He,handlers:Qe,userProperties:{update:async(t,e)=>{try{await w().put(`${We}${Je}/${Ze}${Xe}/${t}`,e)}catch(t){await g(t)}}}},tr=l(130);const{APIS:{SEARCH_API:{BASE_URL:er,ENDPOINTS:{SEARCH:rr}}}}=a,ar=`${er}${rr}`;var nr={ask:async t=>{try{let e=null;const{data:r}=await w().get(ar,{params:{question:t}});return r?.answer&&r?.references&&r?.version&&(e=r),e}catch(t){const e=await g(t);throw new Error(e)}},stream:(t,e,r)=>{const a=(0,tr.io)(void 0,{path:"/api/search-api/web-sockets"});function n(){a.emit("search",{question:t})}function s(t){r(t),i(),a.disconnect()}function i(){a.off("connect",n),a.off("update",e),a.off("result",s)}return a.on("connect",n),a.on("update",e),a.on("result",s),i}};const{APIS:{SOCIALS_API:{BASE_URL:sr,ENDPOINTS:{COMMUNITIES:ir}}}}=a,or=`${sr}${ir}`;var cr={read:async t=>{let e=null;try{const{data:r}=await w().get(`${or}/${encodeURIComponent(t)}`);r?.title&&(e=r)}catch(t){await g(t)}return e},join:async(t,e)=>{let r=null;try{const{data:a}=await w().post(`${or}/${encodeURIComponent(t)}/members`,e);r=a}catch(t){await g(t)}return r},leave:async t=>{let e=null;try{const{data:r}=await w().delete(`${or}/${encodeURIComponent(t)}/members/me`);e=r}catch(t){await g(t)}return e}};const{APIS:{SOCIALS_API:{BASE_URL:lr,ENDPOINTS:{COMMUNITIES:ur},PATHS:{ACTIVITIES:Er}}}}=a,Sr=`${lr}${ur}`;var dr={read:async(t,e)=>{let r=null;try{const{data:a}=await w().get(`${Sr}/${encodeURIComponent(t)}/${Er}/${e}`);a&&(r=a)}catch(t){await g(t)}return r},list:async(t,e={})=>{let r=null;try{const{data:a}=await w().get(`${Sr}/${encodeURIComponent(t)}/${Er}`,{params:e});a&&(r=a)}catch(t){await g(t)}return r},create:async(t,e)=>{let r=null;try{const{data:a}=await w().post(`${Sr}/${encodeURIComponent(t)}/${Er}`,e);a?.content&&(r=a)}catch(t){await g(t)}return r},update:async(t,e,r)=>{let a=null;try{const{data:n}=await w().put(`${Sr}/${encodeURIComponent(t)}/${Er}/${e}`,r);n?.content&&(a=n)}catch(t){await g(t)}return a},remove:async(t,e)=>{let r=null;try{const{data:a}=await w().delete(`${Sr}/${encodeURIComponent(t)}/${Er}/${e}`);r=a}catch(t){await g(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:pr,ENDPOINTS:{COMMUNITIES:hr},PATHS:{ACTIVITIES:Ir,REACTIONS:wr}}}}=a,gr=`${pr}${hr}`;var yr={create:async(t,e,r,a)=>{let n=null,s=`${gr}/${encodeURIComponent(t)}`;s=e?`${s}/${Ir}/${e}/${wr}`:`${s}/${wr}/${r}/${wr}`;try{const{data:t}=await w().post(s,a);n=t}catch(t){await g(t)}return n},list:async(t,{activityId:e,reactionId:r},a={})=>{let n=null,s=`${gr}/${encodeURIComponent(t)}`;s=e?`${s}/${Ir}/${e}/${wr}`:`${s}/${wr}/${r}/${wr}`;try{const{data:t}=await w().get(s,{params:a});t&&(n=t)}catch(t){await g(t)}return n},remove:async(t,e)=>{let r=null;try{const{data:a}=await w().delete(`${gr}/${encodeURIComponent(t)}/${wr}/${e}`);r=a}catch(t){await g(t)}return r},update:async(t,e,r,a)=>{let n=null,s=`${gr}/${encodeURIComponent(t)}`;s=e?`${s}/${Ir}/${e}`:`${s}/${wr}/${r}`;try{const{data:t}=await w().put(s,a);n=t}catch(t){await g(t)}return n}};const{APIS:{SOCIALS_API:{BASE_URL:mr,ENDPOINTS:{COMMUNITIES:Ar},PATHS:{ACTIVITIES:Nr,REACTIONS:Tr}}}}=a,fr=`${mr}${Ar}`;var Pr={activities:dr,communities:cr,likes:{create:async({slug:t,activityId:e,reactionId:r})=>{let a=null;const n={kind:"like"};let s=`${fr}/${encodeURIComponent(t)}`;s=e?`${s}/${Nr}/${e}/${Tr}`:`${s}/${Tr}/${r}/${Tr}`;try{const{data:t}=await w().post(s,n);a=t}catch(t){await g(t)}return a},remove:async({slug:t,reactionId:e})=>{let r=null;try{const{data:a}=await w().delete(`${fr}/${encodeURIComponent(t)}/${Tr}/${e}`);r=a}catch(t){await g(t)}return r}},reactions:yr};const{CONTENTFUL:Rr}=a,{CARD_TYPES:$r}=Rr.CAROUSELS,Lr={read:async(e,r)=>{try{if(!r||!r.sys||!r.sys.id)throw new Error("Invalid link to card");if(!e||!$r[e])throw new Error("Unsupported card content type");const{INCLUDE:a,SELECT:n}=$r[e];return await(0,t.getEntry)({content_type:e,"sys.id":r.sys.id,include:a,select:n},{assetDetails:!0})}catch(t){throw await g(t),new Error(`Cannot read carousel card: ${t.message}`)}}};var Ur=Lr;const{CONTENTFUL:Or}=a,{INCLUDE:Cr,SELECT:_r,TYPE:vr}=Or.EDITORIAL_PAGES;var br={read:async e=>{try{return await(0,t.getEntry)({content_type:vr,"fields.slug":e,include:Cr,select:_r})}catch(t){throw await g(t),new Error(`Cannot read editorial page: ${t.message}`)}}};const{CONTENTFUL:Dr}=a,{TYPE:Mr,ORDER:Br,SELECT:kr,SKIP:qr,LIMIT:Gr,INCLUDE:xr}=Dr.QUESTIONS;var Yr={read:async e=>{try{return await(0,t.getEntry)({content_type:Mr,"fields.slug":e,include:2,select:kr})}catch(t){throw await g(t),new Error(`Cannot read question: ${t.message}`)}},list:async(e={})=>{try{return await(0,t.getEntries)({content_type:Mr,include:xr,limit:Gr,order:Br,select:kr,skip:qr,...e})}catch(t){throw await g(t),new Error(`Cannot list questions: ${t.message}`)}}},Fr=async(t,e,r={ignoreAnswersAuthors:!1})=>{try{let a={};return a=await Yr.read(t),a=await Ve.handlers.authors.readQuestionAuthors(a,e,r),a}catch(t){throw await g(t),new Error(`Cannot build question: ${t.message}`)}};const{ARTICLES:{TYPE:Vr},COURSES:{TYPE:jr},CUSTOM_CARD:{TYPE:Kr},COMMUNITY:{TYPE:Hr},EVENTS:{TYPE:Qr},LISTS:{TYPE:Wr},QUESTIONS:{TYPE:Jr},LEARNING_HUB:{TYPE:Xr}}=a.CONTENTFUL,Zr=t=>t&&t.url?(Object.assign(t,{aspect:"responsiveCard",query:"q=90&fit=fill"}),t):null,zr=t=>t&&t.url?`${t.url}?w=100&h=100&fit=thumb&f=center`:null,ta=t=>t.toLowerCase().split(" ")[0],ea={[Vr]:async t=>{const{authorIds:e,authorTag:r,image:a,publishedDate:n,readingTime:s,slug:i,title:o}=t,c=await Ve.handlers.authors.readAuthors(e),l=c&&c.length?c:r?[ta(r)]:null;return{banner:Zr(a),contributors:l,publishedDate:n,readingTime:s,slug:i,title:o}},[Hr]:async t=>{const{title:e,slug:r,bannerSection:a}=t,n=await Pr.communities.read(r),s=await Ve.userCommunities.list({communitySlug:r,count:1});return{banner:a?.image?Zr(a.image):null,slug:r,title:e,members:{isMember:!!n?.member,memberType:n?.member?.role||null,count:s?.total||0}}},[jr]:async(t,e)=>{const{banner:r,freeCourse:a,partnershipDetails:n,slug:s,title:i,registered:o,courseType:c}=t,l={banner:Zr(r),slug:s,title:i,pill:a?"free":"premium",registered:!!o,courseType:c};if(n){const{partners:t}=n;if(t)if(t.length>1){let e=[];for(let r=0;r<t.length;r++)e.push(t[r].title);l.partner=e}else l.partner=[t[0].title]}if(void 0===o&&e){const[t]=await Ve.userProducts.list({courseSlug:s,isEnrolled:!0,scope:"active"});l.registered=!!t}return l},[Kr]:t=>{const{authorName:e,authorImage:r,icon:a,image:n,label:s,link:i,primaryText:o}=t;return{...t,banner:n?Zr(n):null,customIcon:a?a.toLowerCase():null,customLabel:s,contributors:e?[{name:e,image:r?{thumbnail:zr(r)}:null}]:null,slug:i,text:o}},[Qr]:async(t,e)=>{const{bannerImage:r,defaultStartDate:a,isEventOngoing:n,slug:s,speakers:i,title:o,registered:c}=t,l=new Date(a),u=!!l&&l<new Date;if(i&&i.length)for(const t of i)t.image=zr(t.image);const E={banner:Zr(r),dateHasPassed:u,title:o,slug:s,isOngoingEvent:n,contributors:i,startDate:l,registered:!!c};if(void 0===c&&e){const[t]=await Ve.userEvents.list({eventSlug:s});E.registered=!!t}return E},[Wr]:async t=>{const{hero:e,slug:r,title:a}=t;return{banner:Zr(e),slug:r,title:a}},[Jr]:async t=>{const{answers:e,authorId:r,createdAt:a,slug:n,title:s}=t;let i=null;if(r){const t=await Ve.users.read(r);t&&(i=t)}return{answers:e&&e.length?e.length:0,contributors:i?[i]:[],createdAt:a,slug:n,title:s}},[Xr]:t=>{const{bannerSection:e,customLabel:r,slug:a,title:n}=t;return{banner:Zr(e.image),slug:a,title:n,customLabel:r}},people:t=>{const{id:e,name:r,jobTitle:a,location:n,image:s,customLink:i}=t;return{profile:s,slug:i?.link||e,title:r,text:a,secondaryText:n,customLinkText:i?.text}}};var ra=async({contentType:t,...e}={},r)=>{try{if(!ea[t])throw new Error("Content type not supported");if("function"!=typeof ea[t])throw new Error("No builder function for content type");return"people"!==t&&e.sys&&e.sys.type&&"Link"===e.sys.type&&(e=await Ur.read(t,e)),{contentType:t,...await ea[t](e,r)}}catch(t){throw await g(t),new Error(`Cannot build carousel card: ${t.message}`)}},aa=async(t,e,r={})=>{try{if(!t.replies||0===t.replies.length)return t.replies=[],t;t.replies.sort(((t,e)=>new Date(t.createdAt)-new Date(e.createdAt))),t.totalReplies=t.totalReplies||t.replies.length;let n=t.replies;if(r.limit&&r.pageNumber){const e=r.limit*(r.pageNumber-1);n=t.replies.slice(e,e+r.limit)}for(const r of n){if(r.authorId===t.authorId){r.author=t.author,r.userLiked=!1;continue}r.author=r.authorId&&await qt(r.authorId)||{};const[n]=e?await Ht({contentType:a.CONTENTFUL.REPLIES.TYPE,contentSlug:r.slug}):[null];r.userLiked=!!n}return t.replies=n,t}catch(t){throw await g(t),new Error(`Cannot build replies for answer: ${t.message}`)}};var na=function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;var a,n,s;if(Array.isArray(e)){if((a=e.length)!=r.length)return!1;for(n=a;0!=n--;)if(!t(e[n],r[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if((a=(s=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(n=a;0!=n--;)if(!Object.prototype.hasOwnProperty.call(r,s[n]))return!1;for(n=a;0!=n--;){var i=s[n];if(!t(e[i],r[i]))return!1}return!0}return e!=e&&r!=r};const sa="__googleMapsScriptId";var ia;!function(t){t[t.INITIALIZED=0]="INITIALIZED",t[t.LOADING=1]="LOADING",t[t.SUCCESS=2]="SUCCESS",t[t.FAILURE=3]="FAILURE"}(ia||(ia={}));class oa{constructor({apiKey:t,authReferrerPolicy:e,channel:r,client:a,id:n=sa,language:s,libraries:i=[],mapIds:o,nonce:c,region:l,retries:u=3,url:E="https://maps.googleapis.com/maps/api/js",version:S}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=t,this.authReferrerPolicy=e,this.channel=r,this.client=a,this.id=n||sa,this.language=s,this.libraries=i,this.mapIds=o,this.nonce=c,this.region=l,this.retries=u,this.url=E,this.version=S,oa.instance){if(!na(this.options,oa.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(oa.instance.options)}`);return oa.instance}oa.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?ia.FAILURE:this.done?ia.SUCCESS:this.loading?ia.LOADING:ia.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let t=this.url;return t+="?callback=__googleMapsCallback",this.apiKey&&(t+=`&key=${this.apiKey}`),this.channel&&(t+=`&channel=${this.channel}`),this.client&&(t+=`&client=${this.client}`),this.libraries.length>0&&(t+=`&libraries=${this.libraries.join(",")}`),this.language&&(t+=`&language=${this.language}`),this.region&&(t+=`&region=${this.region}`),this.version&&(t+=`&v=${this.version}`),this.mapIds&&(t+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(t+=`&auth_referrer_policy=${this.authReferrerPolicy}`),t}deleteScript(){const t=document.getElementById(this.id);t&&t.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise(((t,e)=>{this.loadCallback((r=>{r?e(r.error):t(window.google)}))}))}importLibrary(t){return this.execute(),google.maps.importLibrary(t)}loadCallback(t){this.callbacks.push(t),this.execute()}setScript(){var t,e;if(document.getElementById(this.id))return void this.callback();const r={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(r).forEach((t=>!r[t]&&delete r[t])),(null===(e=null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.maps)||void 0===e?void 0:e.importLibrary)||(t=>{let e,r,a,n="The Google Maps JavaScript API",s="google",i="importLibrary",o="__ib__",c=document,l=window;l=l[s]||(l[s]={});const u=l.maps||(l.maps={}),E=new Set,S=new URLSearchParams,d=()=>e||(e=new Promise(((i,l)=>{return d=this,p=void 0,I=function*(){var d;for(a in yield r=c.createElement("script"),r.id=this.id,S.set("libraries",[...E]+""),t)S.set(a.replace(/[A-Z]/g,(t=>"_"+t[0].toLowerCase())),t[a]);S.set("callback",s+".maps."+o),r.src=this.url+"?"+S,u[o]=i,r.onerror=()=>e=l(Error(n+" could not load.")),r.nonce=this.nonce||(null===(d=c.querySelector("script[nonce]"))||void 0===d?void 0:d.nonce)||"",c.head.append(r)},new((h=void 0)||(h=Promise))((function(t,e){function r(t){try{n(I.next(t))}catch(t){e(t)}}function a(t){try{n(I.throw(t))}catch(t){e(t)}}function n(e){var n;e.done?t(e.value):(n=e.value,n instanceof h?n:new h((function(t){t(n)}))).then(r,a)}n((I=I.apply(d,p||[])).next())}));var d,p,h,I})));u[i]?console.warn(n+" only loads once. Ignoring:",t):u[i]=(t,...e)=>E.add(t)&&d().then((()=>u[i](t,...e)))})(r);const a=this.libraries.map((t=>this.importLibrary(t)));a.length||a.push(this.importLibrary("core")),Promise.all(a).then((()=>this.callback()),(t=>{const e=new ErrorEvent("error",{error:t});this.loadErrorCallback(e)}))}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(t){if(this.errors.push(t),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout((()=>{this.deleteScript(),this.setScript()}),t)}else this.onerrorEvent=t,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach((t=>{t(this.onerrorEvent)})),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading||(this.loading=!0,this.setScript())}}}const{GOOGLE:{MAPS:{LIBRARIES:ca,VERSION:la}}}=a;var ua=function(t){return{city:async function(e){try{const r=await async function(){try{const{AutocompleteService:t}=await async function(t=ca.PLACES){const e=h(),r=new oa({apiKey:e?.googleMaps?.apiKey,version:la});return await r.importLibrary(t)}();return new t}catch(t){throw new Error("Unable to load google library:",t)}}();return new Promise((a=>{r.getPlacePredictions({...t,input:e,types:["(cities)"]},((t=[],e)=>{a("OK"===e?t:[])}))}))}catch(t){return console.error("Error with Autocomplete Service:",t),[]}}}},Ea=l(408);const Sa=t=>t&&Ea.Buffer.from(t,"base64").toString("ascii");function da({contentContext:a=null,errorsContext:l=null,googleMapsContext:u=null,gtmContext:h=null,origin:I}){try{const w=(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 r=null;const a=e.match(i);return a?r=a[1].split(o)[0]:e===n?r=c:e.includes(s)&&(r=E),r||new Error(`Cannot select environment: No rule for website ${e}`),r})(I);return a&&(0,t.setContext)(Object.assign({},a,{environment:w})),l&&(0,e.setContext)(Object.assign({},l,{environment:w})),u&&(({apiKey:t})=>{p.googleMaps={apiKey:t}})(Object.assign({},u,{environment:w})),h&&((0,r.setContext)(Object.assign({},h,{environment:w})),(0,r.setupGTM)()),(({environment:t})=>{const e=(t=>{if(!t)throw new Error("Cannot map environment: Environment not defined");if(!S[t])throw new Error(`Cannot map environment: No mapping found for environment ${t}`);return S[t]})(t);p.emailIds=d[e]})(Object.assign({},{environment:w})),w}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),u}()}));
2
+ !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("socket.io-client"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/gtm","axios","http-status-codes","socket.io-client","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("socket.io-client"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/gtm"],t.axios,t["http-status-codes"],t["socket.io-client"],t.buffer)}(this,(function(t,e,r,a,n,s,i){return function(){"use strict";var o={809:function(e){e.exports=t},30:function(t){t.exports=e},36:function(t){t.exports=r},300:function(t){t.exports=a},408:function(t){t.exports=i},25:function(t){t.exports=n},130:function(t){t.exports=s}},c={};function l(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return o[t](r,r.exports,l),r.exports}l.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return l.d(e,{a:e}),e},l.d=function(t,e){for(var r in e)l.o(e,r)&&!l.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},l.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},l.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return function(){l.r(u),l.d(u,{assets:function(){return f},auth:function(){return $},buildAnswer:function(){return aa},buildCardCtaClickHandler:function(){return ia},buildCarouselCard:function(){return ra},buildQuestion:function(){return Fr},carouselCards:function(){return Ur},contentInteraction:function(){return X},decodeBase64:function(){return ha},default:function(){return Ia},editorialPages:function(){return br},features:function(){return et},getEntries:function(){return t.getEntries},getEntry:function(){return t.getEntry},management:function(){return wt},mgmt:function(){return Nt},payments:function(){return $t},people:function(){return Ve},peopleEngagement:function(){return ze},predictPlace:function(){return da},qaQuestions:function(){return Yr},reportError:function(){return e.reportError},search:function(){return nr},socials:function(){return Pr}});var t=l(809),e=l(30),r=l(36),a={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",REPLIES:"/replies",LIKES:"/likes"}},FEATURES_API:{BASE_URL:"/api/features-api",ENDPOINTS:{FLAGS:"/features"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts",EVENT_REGISTRATIONS:"/event-registrations",LOGINS:"/logins",LOGIN_PASSWORDLESS:"/passwordless",BULK_ENROLMENTS:"/bulk-enrolments"}},MGMT_API:{BASE_URL:"/api/mgmt-api",ENDPOINTS:{REFERRALS:"/referrals",BULK_REFERRALS:"/bulk-referrals"}},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:{COMMUNITIES:"/user-communities",BULK_ENROLMENTS:"/bulk-enrolments",MY_COMMUNITIES:"/users/me/communities",REGISTRATIONS:"/registrations",USERS:"/users",USER_ANSWERS:"/answers",USER_COURSES:"/courses",USER_EVENTS:"/events",USER_LIKES:"/likes",USER_LESSONS:"/lessons",USER_PRODUCTS:"/products",USER_RATINGS:"/ratings",USER_REFERRALS:"/referrals",USER_SUBSCRIPTIONS:"/subscriptions"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{ENQUIRY_EMAILS:"/enquiry-emails",USERS:"/users",USER_PROPERTIES:"/properties"}},SEARCH_API:{BASE_URL:"/api/search-api",ENDPOINTS:{SEARCH:"/search"}},SOCIALS_API:{BASE_URL:"/api/socials-api",ENDPOINTS:{COMMUNITIES:"/communities"},PATHS:{ACTIVITIES:"activities",REACTIONS:"reactions"}}},CONTENTFUL:{ARTICLES:{TYPE:"solutionArticle"},CAROUSELS:{CARD_TYPES:{communityPage:{INCLUDE:1,SELECT:"fields.bannerSection,fields.slug,fields.title"},customCard:{INCLUDE:1,SELECT:"fields.icon,fields.label,fields.image,fields.primaryText,fields.secondaryText,fields.authorName,fields.authorImage,fields.link,fields.openInNewTab"},solutionArticle:{INCLUDE:1,SELECT:"fields.authorIds,fields.authorTag,fields.image,fields.publishedDate,fields.readingTime,fields.slug,fields.title"},microcourse:{INCLUDE:2,SELECT:"fields.banner,fields.freeCourse,fields.partnershipDetails,fields.slug,fields.title,fields.courseType"},event:{INCLUDE:1,SELECT:"fields.bannerImage,fields.defaultStartDate,fields.slug,fields.speakers,fields.title,fields.isEventOngoing"},listPage:{INCLUDE:1,SELECT:"fields.hero,fields.slug,fields.title"},qaQuestion:{INCLUDE:0,SELECT:"fields.answers,fields.authorId,fields.slug,fields.title,sys.createdAt,fields.projectNames"},learningHub:{INCLUDE:1,SELECT:"fields.bannerSection,fields.customLabel,fields.slug,fields.title"}}},COMMUNITY:{TYPE:"communityPage"},COURSES:{TYPE:"microcourse"},CUSTOM_CARD:{TYPE:"customCard"},EDITORIAL_PAGES:{INCLUDE:1,SELECT:"fields.carousels,fields.slug,fields.showCarouselCta,fields.header,fields.subHeader",TYPE:"editorialPage"},EVENTS:{TYPE:"event"},LISTS:{TYPE:"listPage"},QUESTIONS:{TYPE:"qaQuestion",INCLUDE:1,LIMIT:10,ORDER:"-sys.createdAt",SELECT:"sys.createdAt,sys.updatedAt,fields.title,fields.slug,fields.authorId,fields.answers,fields.isEdited,fields.projectNames",SKIP:0},ANSWERS:{TYPE:"qaAnswer"},REPLIES:{TYPE:"reply"},LEARNING_HUB:{TYPE:"learningHub"}},GOOGLE:{MAPS:{LIBRARIES:{PLACES:"places"},VERSION:"weekly"}},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:n,LOCALHOST:s,STAGING:i,STAGING_SPLITTER:o},ENVIRONMENTS:{PRODUCTION:c,LOCAL:E}}}=a,{HUBSPOT:{ENVIRONMENTS_MAPPING:S,EMAIL_IDS:d}}=a;let p={emailIds:{}};const h=()=>p;var I=l(300),w=l.n(I);const g=async t=>{try{const{message:r,response:a,request:n}=t;let s=r;return a?s+=` - The request was made and the server responded with ${JSON.stringify({status:a.status,data:a.data})}`:n&&(s+=" - The request was made but no response was received"),console.warn(s),await(0,e.reportError)(new Error(s)),s}catch(t){return console.warn(`Cannot handle error: ${t.message}`),t.message}},{APIS:{ASSETS_API:{BASE_URL:y,ENDPOINTS:{USERS:m,CERTIFICATES:A}}}}=a;var f={certificates:{create:async(t,e)=>{let r=[];try{const{data:a}=await w().post(`${y}${m}/${t}${A}`,e);a&&(r=a)}catch(t){await g(t)}return r}}};const{APIS:{AUTH_API:{BASE_URL:N,ENDPOINTS:{USER_PASSWORD:T,USERS:P}}},USERS:{MYSELF:R}}=a;var $={userPassword:{update:async t=>{let e=null;try{e=await w().put(`${N}${P}/${R}${T}`,t)}catch(t){e={message:(((t||{}).response||{}).data||{}).message},await g(t)}return e}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:L,ENDPOINTS:{ANSWERS:U,QUESTIONS:O,LIKES:C}}}}=a,_=`${L}${O}`;var v={create:async({questionSlug:t},e)=>{try{await w().post(`${_}/${encodeURIComponent(t)}${U}`,e)}catch(t){const e=await g(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e})=>{try{await w().delete(`${_}/${encodeURIComponent(t)}${U}/${encodeURIComponent(e)}`)}catch(t){const e=await g(t);throw new Error(e)}},update:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().put(`${_}/${encodeURIComponent(t)}${U}/${encodeURIComponent(e)}`,r)}catch(t){const e=await g(t);throw new Error(e)}},like:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().post(`${_}/${encodeURIComponent(t)}${U}/${encodeURIComponent(e)}${C}`,r)}catch(t){const e=await g(t);throw new Error(e)}},unlike:async({questionSlug:t,answerSlug:e})=>{try{return await w().delete(`${_}/${encodeURIComponent(t)}${U}/${encodeURIComponent(e)}${C}`)}catch(t){const e=await g(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:b,ENDPOINTS:{QUESTIONS:D}}}}=a,M=`${b}${D}`;var B={create:async t=>{try{return await w().post(M,t)}catch(t){const e=await g(t);throw new Error(e)}},remove:async({questionSlug:t})=>{try{await w().delete(`${M}/${encodeURIComponent(t)}`)}catch(t){const e=await g(t);throw new Error(e)}},update:async({questionSlug:t},e)=>{try{return await w().put(`${M}/${encodeURIComponent(t)}`,e)}catch(t){const e=await g(t);throw new Error(e)}}};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:k,ENDPOINTS:{REPLIES:q,ANSWERS:G,QUESTIONS:x,LIKES:Y}}}}=a,F=`${k}${x}`,V=({questionSlug:t,answerSlug:e,replySlug:r},a=!1)=>{let n=`${F}/${encodeURIComponent(t)}${G}/${encodeURIComponent(e)}${q}`;return r&&(n=`${n}/${encodeURIComponent(r)}`,a&&(n=`${n}${Y}`)),n};var j={create:async({questionSlug:t,answerSlug:e},r)=>{try{return await w().post(V({questionSlug:t,answerSlug:e}),r)}catch(t){const e=await g(t);throw new Error(e)}},update:async({questionSlug:t,answerSlug:e,replySlug:r},a)=>{try{return await w().put(V({questionSlug:t,answerSlug:e,replySlug:r}),a)}catch(t){const e=await g(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e,replySlug:r})=>{try{await w().delete(V({questionSlug:t,answerSlug:e,replySlug:r}))}catch(t){const e=await g(t);throw new Error(e)}},like:async({questionSlug:t,answerSlug:e,replySlug:r,payload:a})=>{try{await w().post(V({questionSlug:t,answerSlug:e,replySlug:r},!0),a)}catch(t){const e=await g(t);throw new Error(e)}},unlike:async({questionSlug:t,answerSlug:e,replySlug:r})=>{try{await w().delete(V({questionSlug:t,answerSlug:e,replySlug:r},!0))}catch(t){const e=await g(t);throw new Error(e)}},getReplyUrl:V};const{APIS:{CONTENT_INTERACTION_API:{BASE_URL:K,ENDPOINTS:{QUESTIONS:H,ANSWERS:Q,LIKES:W}}}}=a,J=`${K}${H}`;var X={answers:v,questions:B,replies:j,likes:{create:async({questionSlug:t,answerSlug:e})=>{try{return await w().post(`${J}/${encodeURIComponent(t)}${Q}/${encodeURIComponent(e)}${W}`)}catch(t){const e=await g(t);throw new Error(e)}},remove:async({questionSlug:t,answerSlug:e})=>{try{return await w().delete(`${J}/${encodeURIComponent(t)}${Q}/${encodeURIComponent(e)}${W}`)}catch(t){const e=await g(t);throw new Error(e)}}}};const{APIS:{FEATURES_API:{BASE_URL:Z,ENDPOINTS:{FLAGS:z}}}}=a,tt=`${Z}${z}`;var et={flags:{read:async t=>{let e=null;try{const{data:r}=await w().get(`${tt}/${encodeURIComponent(t)}`);r?.name&&r?.featureState&&(e=r)}catch(t){await g(t)}return e}}};const{APIS:{MANAGEMENT_API:{BASE_URL:rt,ENDPOINTS:{ACCOUNTS:at}}}}=a;var nt={create:async t=>{try{await w().post(`${rt}${at}`,t)}catch(t){throw await g(t),t}},read:async t=>{let e=null;try{({data:e}=await w().get(`${rt}${at}/${encodeURIComponent(t)}`))}catch(t){await g(t)}return e},update:async(t,e)=>{try{await w().put(`${rt}${at}/${encodeURIComponent(t)}`,e)}catch(t){throw await g(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:st,ENDPOINTS:{BULK_ENROLMENTS:it}}}}=a;var ot={create:async t=>{try{await w().post(`${st}${it}`,t)}catch(t){throw await g(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:ct,ENDPOINTS:{EVENT_REGISTRATIONS:lt}}}}=a;var ut={create:async t=>{try{await w().post(`${ct}${lt}`,t)}catch(t){const e=await g(t);throw new Error(e)}}};const{APIS:{MANAGEMENT_API:{BASE_URL:Et,ENDPOINTS:{LOGINS:St,LOGIN_PASSWORDLESS:dt}}}}=a,pt=`${Et}${St}`;var ht={update:async t=>{try{await w().put(`${pt}/${encodeURIComponent(t)}${dt}`)}catch(t){throw await g(t),t}}};const{APIS:{MANAGEMENT_API:{BASE_URL:It}}}=a;var wt={accounts:nt,bulkEnrolments:ot,eventRegistrations:ut,passwordless:ht,userProducts:{create:async t=>{try{await w().post(`${It}/users/${t.id}/products`,t)}catch(t){const e=await g(t);throw new Error(e)}}}};const{APIS:{MGMT_API:{BASE_URL:gt,ENDPOINTS:{REFERRALS:yt}}}}=a;var mt={create:async t=>{try{await w().post(`${gt}${yt}`,t)}catch(t){throw await g(t),t}}};const{APIS:{MGMT_API:{BASE_URL:At,ENDPOINTS:{BULK_REFERRALS:ft}}}}=a;var Nt={referrals:mt,bulkReferrals:{create:async t=>{try{await w().post(`${At}${ft}`,t)}catch(t){throw await g(t),t}}}};const{APIS:{PAYMENTS_API:{BASE_URL_V2:Tt,ENDPOINTS:{PRODUCTS:Pt}}}}=a,Rt=`${Tt}${Pt}`;var $t={products:{list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Rt,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Lt,ENDPOINTS:{BULK_ENROLMENTS:Ut}}}}=a;var Ot={list:async t=>{let e=[];try{const{data:r}=await w().get(`${Lt}${Ut}`,{params:t});r&&r.length&&(e=r)}catch(t){await g(t)}return e}},Ct=l(25);const{OK:_t,MULTIPLE_CHOICES:vt,NOT_FOUND:bt,FORBIDDEN:Dt}=Ct.StatusCodes,Mt=t=>t>=_t&&t<vt||t===Dt||t===bt,{APIS:{PEOPLE_API:{BASE_URL_V2:Bt,ENDPOINTS:{USERS:kt}}}}=a,qt=async t=>{let e=null;try{const{data:r}=await w().get(`${Bt}${kt}/${encodeURIComponent(t)}`,{validateStatus:Mt});r&&r.id&&(e=r)}catch(t){await g(t)}return e},Gt=async t=>{let e=[];try{if(t&&t.length<2)throw new Error("users list method requires at least two ids");const r=t.map((t=>`ids=${encodeURIComponent(t)}`)).join("&"),a=await w().get(`${Bt}${kt}?${r}`,{validateStatus:Mt});a&&a.length&&(e=a)}catch(t){await g(t)}return e};var xt={read:qt,update:async(t,e)=>{let r=!1;try{const{data:a}=await w().put(`${Bt}${kt}/${encodeURIComponent(t)}`,e);r=!(!a||!a.id)}catch(t){await g(t)}return r},list:Gt};const{APIS:{PEOPLE_API:{BASE_URL_V2:Yt,ENDPOINTS:{USERS:Ft,USER_LIKES:Vt}}},USERS:{MYSELF:jt}}=a,Kt=`${Yt}${Ft}/${jt}${Vt}`,Ht=async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Kt,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e};var Qt={list:Ht};var Wt={authors:{readQuestionAuthors:async(t,e,r)=>{try{if(t.author=await qt(t.authorId),t.answers&&t.answers.length&&!r.ignoreAnswersAuthors){t.answers.sort(((t,e)=>new Date(e.updatedAt)-new Date(t.updatedAt))),t.totalAnswers=t.answers.length;let n=t.answers;if(r.limit&&r.pageNumber){const e=r.limit*(r.pageNumber-1);n=t.answers.slice(e,e+r.limit)}for(let t of n){t.author=t.authorId&&await qt(t.authorId)||{};const[r]=e?await Ht({contentType:a.CONTENTFUL.ANSWERS.TYPE,contentSlug:t.slug}):[null];t.userLiked=!!r}t.answers=n}else t.answers||(t.answers=[]);return t}catch(t){throw await g(t),new Error(`Cannot read authors for question: ${t.message}`)}},readAuthors:async(t=[])=>{let e=[];try{if(!1===Array.isArray(t))throw new Error("authorIds is not an array!");if(t&&1===t.length){const r=await qt(t[0]);r&&e.push(r)}else if(t&&t.length>1){const r=await Gt(t);r&&r.length>0&&(e=r)}}catch(t){throw await g(t),new Error(`Cannot read authors: ${t.message}`)}return e}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Jt,ENDPOINTS:{MY_COMMUNITIES:Xt}}}}=a,Zt=`${Jt}${Xt}`;function zt(t){const e=t["content-range"].split(" ")[1].split("/"),[r,a,n]=[...e[0].split("-"),e[1]].map((t=>parseInt(t,10)||0));return{start:r,end:a,total:n}}var te={list:async t=>{let e={items:[],start:0,end:0,total:0},r=t?{params:t}:{params:{}};try{const{data:t,headers:a}=await w().get(Zt,{...r,headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}});return t?.length>0&&(e={items:t,...zt(a)}),e}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL:ee,ENDPOINTS:{REGISTRATIONS:re}}}}=a;var ae={list:async t=>{let e=[];try{const{data:r}=await w().get(`${ee}${re}`,{params:t});r&&r.length&&(e=r)}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:ne,ENDPOINTS:{COMMUNITIES:se}}}}=a,ie=`${ne}${se}`;function oe(t){const e=t["content-range"].split(" ")[1].split("/"),[r,a,n]=[...e[0].split("-"),e[1]].map((t=>parseInt(t,10)||0));return{start:r,end:a,total:n}}var ce={list:async t=>{let e={items:[],start:0,end:0,total:0},r=t?{params:t}:{params:{}};try{const{data:t,headers:a}=await w().get(ie,{...r,headers:{"Cache-Control":"no-cache",Pragma:"no-cache",Expires:0}});return t?.length>0&&(e={items:t,...oe(a)}),e}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:le,ENDPOINTS:{USERS:ue,USER_COURSES:Ee}}},USERS:{MYSELF:Se}}=a,de=`${le}${ue}/${Se}${Ee}`;var pe={create:async t=>{try{await w().post(de,t)}catch(t){await g(t)}},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(de,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e},update:async(t,e)=>{try{await w().put(`${de}/${t}`,e)}catch(t){await g(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:he,ENDPOINTS:{USERS:Ie,USER_EVENTS:we}}},USERS:{MYSELF:ge}}=a,ye=`${he}${Ie}/${ge}${we}`;var me={list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(ye,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:Ae,ENDPOINTS:{USERS:fe,USER_LESSONS:Ne}}},USERS:{MYSELF:Te}}=a,Pe=`${Ae}${fe}/${Te}${Ne}`;var Re={create:async t=>{let e=null;try{e=await w().post(Pe,t)}catch(t){await g(t)}return e},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Pe,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL_V2:$e,ENDPOINTS:{USERS:Le,USER_PRODUCTS:Ue}}},USERS:{MYSELF:Oe}}=a,Ce=`${$e}${Le}/${Oe}${Ue}`;var _e={create:async t=>{let e=null;try{e=await w().post(Ce,t)}catch(t){await g(t)}return e},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Ce,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e},update:async(t,e)=>{try{await w().put(`${Ce}/${t}`,e)}catch(t){await g(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:ve,ENDPOINTS:{USERS:be,USER_RATINGS:De}}},USERS:{MYSELF:Me}}=a,Be=`${ve}${be}/${Me}${De}`;var ke={create:async t=>{let e=null;try{const{data:r}=await w().post(Be,t);r?.id&&(e=r)}catch(t){await g(t)}return e},update:async(t,e)=>{try{await w().put(`${Be}/${t}`,e)}catch(t){await g(t)}}};const{APIS:{PEOPLE_API:{BASE_URL_V2:qe,ENDPOINTS:{USERS:Ge,USER_REFERRALS:xe}}},USERS:{MYSELF:Ye}}=a,Fe=`${qe}${Ge}/${Ye}${xe}`;var Ve={bulkEnrolments:Ot,handlers:Wt,myCommunities:te,registrations:ae,users:xt,userCommunities:ce,userCourses:pe,userEvents:me,userLessons:Re,userLikes:Qt,userProducts:_e,userRatings:ke,userReferrals:{list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await w().get(Fe,r);t&&t.length&&(e=t)}catch(t){await g(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:je,ENDPOINTS:{ENQUIRY_EMAILS:Ke}}}}=a;var He={create:async t=>{let e=null;try{const{data:r}=await w().post(`${je}${Ke}`,t);r&&(e=r)}catch(t){await g(t)}return e}},Qe={forms:{sendEnquiryEmails:async t=>{let e=null;try{const{emailIds:r}=h();e=await ze.emails.create({...r,...t})}catch(t){await g(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:We,ENDPOINTS:{USERS:Je,USER_PROPERTIES:Xe}}},USERS:{MYSELF:Ze}}=a;var ze={emails:He,handlers:Qe,userProperties:{update:async(t,e)=>{try{await w().put(`${We}${Je}/${Ze}${Xe}/${t}`,e)}catch(t){await g(t)}}}},tr=l(130);const{APIS:{SEARCH_API:{BASE_URL:er,ENDPOINTS:{SEARCH:rr}}}}=a,ar=`${er}${rr}`;var nr={ask:async t=>{try{let e=null;const{data:r}=await w().get(ar,{params:{question:t}});return r?.answer&&r?.references&&r?.version&&(e=r),e}catch(t){const e=await g(t);throw new Error(e)}},stream:(t,e,r)=>{const a=(0,tr.io)(void 0,{path:"/api/search-api/web-sockets"});function n(){a.emit("search",{question:t})}function s(t){r(t),i(),a.disconnect()}function i(){a.off("connect",n),a.off("update",e),a.off("result",s)}return a.on("connect",n),a.on("update",e),a.on("result",s),i}};const{APIS:{SOCIALS_API:{BASE_URL:sr,ENDPOINTS:{COMMUNITIES:ir}}}}=a,or=`${sr}${ir}`;var cr={read:async t=>{let e=null;try{const{data:r}=await w().get(`${or}/${encodeURIComponent(t)}`);r?.title&&(e=r)}catch(t){await g(t)}return e},join:async(t,e)=>{let r=null;try{const{data:a}=await w().post(`${or}/${encodeURIComponent(t)}/members`,e);r=a}catch(t){await g(t)}return r},leave:async t=>{let e=null;try{const{data:r}=await w().delete(`${or}/${encodeURIComponent(t)}/members/me`);e=r}catch(t){await g(t)}return e}};const{APIS:{SOCIALS_API:{BASE_URL:lr,ENDPOINTS:{COMMUNITIES:ur},PATHS:{ACTIVITIES:Er}}}}=a,Sr=`${lr}${ur}`;var dr={read:async(t,e)=>{let r=null;try{const{data:a}=await w().get(`${Sr}/${encodeURIComponent(t)}/${Er}/${e}`);a&&(r=a)}catch(t){await g(t)}return r},list:async(t,e={})=>{let r=null;try{const{data:a}=await w().get(`${Sr}/${encodeURIComponent(t)}/${Er}`,{params:e});a&&(r=a)}catch(t){await g(t)}return r},create:async(t,e)=>{let r=null;try{const{data:a}=await w().post(`${Sr}/${encodeURIComponent(t)}/${Er}`,e);a?.content&&(r=a)}catch(t){await g(t)}return r},update:async(t,e,r)=>{let a=null;try{const{data:n}=await w().put(`${Sr}/${encodeURIComponent(t)}/${Er}/${e}`,r);n?.content&&(a=n)}catch(t){await g(t)}return a},remove:async(t,e)=>{let r=null;try{const{data:a}=await w().delete(`${Sr}/${encodeURIComponent(t)}/${Er}/${e}`);r=a}catch(t){await g(t)}return r}};const{APIS:{SOCIALS_API:{BASE_URL:pr,ENDPOINTS:{COMMUNITIES:hr},PATHS:{ACTIVITIES:Ir,REACTIONS:wr}}}}=a,gr=`${pr}${hr}`;var yr={create:async(t,e,r,a)=>{let n=null,s=`${gr}/${encodeURIComponent(t)}`;s=e?`${s}/${Ir}/${e}/${wr}`:`${s}/${wr}/${r}/${wr}`;try{const{data:t}=await w().post(s,a);n=t}catch(t){await g(t)}return n},list:async(t,{activityId:e,reactionId:r},a={})=>{let n=null,s=`${gr}/${encodeURIComponent(t)}`;s=e?`${s}/${Ir}/${e}/${wr}`:`${s}/${wr}/${r}/${wr}`;try{const{data:t}=await w().get(s,{params:a});t&&(n=t)}catch(t){await g(t)}return n},remove:async(t,e)=>{let r=null;try{const{data:a}=await w().delete(`${gr}/${encodeURIComponent(t)}/${wr}/${e}`);r=a}catch(t){await g(t)}return r},update:async(t,e,r,a)=>{let n=null,s=`${gr}/${encodeURIComponent(t)}`;s=e?`${s}/${Ir}/${e}`:`${s}/${wr}/${r}`;try{const{data:t}=await w().put(s,a);n=t}catch(t){await g(t)}return n}};const{APIS:{SOCIALS_API:{BASE_URL:mr,ENDPOINTS:{COMMUNITIES:Ar},PATHS:{ACTIVITIES:fr,REACTIONS:Nr}}}}=a,Tr=`${mr}${Ar}`;var Pr={activities:dr,communities:cr,likes:{create:async({slug:t,activityId:e,reactionId:r})=>{let a=null;const n={kind:"like"};let s=`${Tr}/${encodeURIComponent(t)}`;s=e?`${s}/${fr}/${e}/${Nr}`:`${s}/${Nr}/${r}/${Nr}`;try{const{data:t}=await w().post(s,n);a=t}catch(t){await g(t)}return a},remove:async({slug:t,reactionId:e})=>{let r=null;try{const{data:a}=await w().delete(`${Tr}/${encodeURIComponent(t)}/${Nr}/${e}`);r=a}catch(t){await g(t)}return r}},reactions:yr};const{CONTENTFUL:Rr}=a,{CARD_TYPES:$r}=Rr.CAROUSELS,Lr={read:async(e,r)=>{try{if(!r||!r.sys||!r.sys.id)throw new Error("Invalid link to card");if(!e||!$r[e])throw new Error("Unsupported card content type");const{INCLUDE:a,SELECT:n}=$r[e];return await(0,t.getEntry)({content_type:e,"sys.id":r.sys.id,include:a,select:n},{assetDetails:!0})}catch(t){throw await g(t),new Error(`Cannot read carousel card: ${t.message}`)}}};var Ur=Lr;const{CONTENTFUL:Or}=a,{INCLUDE:Cr,SELECT:_r,TYPE:vr}=Or.EDITORIAL_PAGES;var br={read:async e=>{try{return await(0,t.getEntry)({content_type:vr,"fields.slug":e,include:Cr,select:_r})}catch(t){throw await g(t),new Error(`Cannot read editorial page: ${t.message}`)}}};const{CONTENTFUL:Dr}=a,{TYPE:Mr,ORDER:Br,SELECT:kr,SKIP:qr,LIMIT:Gr,INCLUDE:xr}=Dr.QUESTIONS;var Yr={read:async e=>{try{return await(0,t.getEntry)({content_type:Mr,"fields.slug":e,include:2,select:kr})}catch(t){throw await g(t),new Error(`Cannot read question: ${t.message}`)}},list:async(e={})=>{try{return await(0,t.getEntries)({content_type:Mr,include:xr,limit:Gr,order:Br,select:kr,skip:qr,...e})}catch(t){throw await g(t),new Error(`Cannot list questions: ${t.message}`)}}},Fr=async(t,e,r={ignoreAnswersAuthors:!1})=>{try{let a={};return a=await Yr.read(t),a=await Ve.handlers.authors.readQuestionAuthors(a,e,r),a}catch(t){throw await g(t),new Error(`Cannot build question: ${t.message}`)}};const{ARTICLES:{TYPE:Vr},COURSES:{TYPE:jr},CUSTOM_CARD:{TYPE:Kr},COMMUNITY:{TYPE:Hr},EVENTS:{TYPE:Qr},LISTS:{TYPE:Wr},QUESTIONS:{TYPE:Jr},LEARNING_HUB:{TYPE:Xr}}=a.CONTENTFUL,Zr=t=>t&&t.url?(Object.assign(t,{aspect:"responsiveCard",query:"q=90&fit=fill"}),t):null,zr=t=>t&&t.url?`${t.url}?w=100&h=100&fit=thumb&f=center`:null,ta=t=>t.toLowerCase().split(" ")[0],ea={[Vr]:async t=>{const{authorIds:e,authorTag:r,image:a,publishedDate:n,readingTime:s,slug:i,title:o}=t,c=await Ve.handlers.authors.readAuthors(e),l=c&&c.length?c:r?[ta(r)]:null;return{banner:Zr(a),contributors:l,publishedDate:n,readingTime:s,slug:i,title:o}},[Hr]:async t=>{const{title:e,slug:r,bannerSection:a}=t,n=await Pr.communities.read(r),s=await Ve.userCommunities.list({communitySlug:r,count:1});return{banner:a?.image?Zr(a.image):null,slug:r,title:e,members:{isMember:!!n?.member,memberType:n?.member?.role||null,count:s?.total||0}}},[jr]:async(t,e)=>{const{banner:r,freeCourse:a,partnershipDetails:n,slug:s,title:i,registered:o,courseType:c}=t,l={banner:Zr(r),slug:s,title:i,pill:a?"free":"premium",registered:!!o,courseType:c};if(n){const{partners:t}=n;if(t)if(t.length>1){let e=[];for(let r=0;r<t.length;r++)e.push(t[r].title);l.partner=e}else l.partner=[t[0].title]}if(void 0===o&&e){const[t]=await Ve.userProducts.list({courseSlug:s,isEnrolled:!0,scope:"active"});l.registered=!!t}return l},[Kr]:t=>{const{authorName:e,authorImage:r,icon:a,image:n,label:s,link:i,primaryText:o}=t;return{...t,banner:n?Zr(n):null,customIcon:a?a.toLowerCase():null,customLabel:s,contributors:e?[{name:e,image:r?{thumbnail:zr(r)}:null}]:null,slug:i,text:o}},[Qr]:async(t,e)=>{const{bannerImage:r,defaultStartDate:a,isEventOngoing:n,slug:s,speakers:i,title:o,registered:c}=t,l=new Date(a),u=!!l&&l<new Date;if(i&&i.length)for(const t of i)t.image=zr(t.image);const E={banner:Zr(r),dateHasPassed:u,title:o,slug:s,isOngoingEvent:n,contributors:i,startDate:l,registered:!!c};if(void 0===c&&e){const[t]=await Ve.userEvents.list({eventSlug:s});E.registered=!!t}return E},[Wr]:async t=>{const{hero:e,slug:r,title:a}=t;return{banner:Zr(e),slug:r,title:a}},[Jr]:async t=>{const{answers:e,authorId:r,createdAt:a,slug:n,title:s}=t;let i=null;if(r){const t=await Ve.users.read(r);t&&(i=t)}return{answers:e&&e.length?e.length:0,contributors:i?[i]:[],createdAt:a,slug:n,title:s}},[Xr]:t=>{const{bannerSection:e,customLabel:r,slug:a,title:n}=t;return{banner:Zr(e.image),slug:a,title:n,customLabel:r}},people:t=>{const{id:e,name:r,jobTitle:a,location:n,image:s,customLink:i}=t;return{profile:s,slug:i?.link||e,title:r,text:a,secondaryText:n,customLinkText:i?.text}}};var ra=async({contentType:t,...e}={},r)=>{try{if(!ea[t])throw new Error("Content type not supported");if("function"!=typeof ea[t])throw new Error("No builder function for content type");return"people"!==t&&e.sys&&e.sys.type&&"Link"===e.sys.type&&(e=await Ur.read(t,e)),{contentType:t,...await ea[t](e,r)}}catch(t){throw await g(t),new Error(`Cannot build carousel card: ${t.message}`)}},aa=async(t,e,r={})=>{try{if(!t.replies||0===t.replies.length)return t.replies=[],t;t.replies.sort(((t,e)=>new Date(t.createdAt)-new Date(e.createdAt))),t.totalReplies=t.totalReplies||t.replies.length;let n=t.replies;if(r.limit&&r.pageNumber){const e=r.limit*(r.pageNumber-1);n=t.replies.slice(e,e+r.limit)}for(const r of n){if(r.authorId===t.authorId){r.author=t.author,r.userLiked=!1;continue}r.author=r.authorId&&await qt(r.authorId)||{};const[n]=e?await Ht({contentType:a.CONTENTFUL.REPLIES.TYPE,contentSlug:r.slug}):[null];r.userLiked=!!n}return t.replies=n,t}catch(t){throw await g(t),new Error(`Cannot build replies for answer: ${t.message}`)}};const na="success",sa="error";var ia=t=>async e=>{const{contentType:r}=e;switch(r){case"event":try{return await wt.eventRegistrations.create({eventSlug:e.slug,expectation:null,userEmail:t.email,startsAt:new Date(e.startDate).toISOString()}),na}catch(t){return reportError(new Error(`Error registering for event: ${JSON.stringify(t)}`)),sa}case"microcourse":try{return await wt.userProducts.create({id:t.id,courseSlug:e.slug,email:t.email,courseType:e.courseType}),na}catch(t){return reportError(new Error(`Error registering for microcourse: ${JSON.stringify(t)}`)),sa}default:return sa}};var oa=function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;var a,n,s;if(Array.isArray(e)){if((a=e.length)!=r.length)return!1;for(n=a;0!=n--;)if(!t(e[n],r[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if((a=(s=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(n=a;0!=n--;)if(!Object.prototype.hasOwnProperty.call(r,s[n]))return!1;for(n=a;0!=n--;){var i=s[n];if(!t(e[i],r[i]))return!1}return!0}return e!=e&&r!=r};const ca="__googleMapsScriptId";var la;!function(t){t[t.INITIALIZED=0]="INITIALIZED",t[t.LOADING=1]="LOADING",t[t.SUCCESS=2]="SUCCESS",t[t.FAILURE=3]="FAILURE"}(la||(la={}));class ua{constructor({apiKey:t,authReferrerPolicy:e,channel:r,client:a,id:n=ca,language:s,libraries:i=[],mapIds:o,nonce:c,region:l,retries:u=3,url:E="https://maps.googleapis.com/maps/api/js",version:S}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=t,this.authReferrerPolicy=e,this.channel=r,this.client=a,this.id=n||ca,this.language=s,this.libraries=i,this.mapIds=o,this.nonce=c,this.region=l,this.retries=u,this.url=E,this.version=S,ua.instance){if(!oa(this.options,ua.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ua.instance.options)}`);return ua.instance}ua.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?la.FAILURE:this.done?la.SUCCESS:this.loading?la.LOADING:la.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let t=this.url;return t+="?callback=__googleMapsCallback",this.apiKey&&(t+=`&key=${this.apiKey}`),this.channel&&(t+=`&channel=${this.channel}`),this.client&&(t+=`&client=${this.client}`),this.libraries.length>0&&(t+=`&libraries=${this.libraries.join(",")}`),this.language&&(t+=`&language=${this.language}`),this.region&&(t+=`&region=${this.region}`),this.version&&(t+=`&v=${this.version}`),this.mapIds&&(t+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(t+=`&auth_referrer_policy=${this.authReferrerPolicy}`),t}deleteScript(){const t=document.getElementById(this.id);t&&t.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise(((t,e)=>{this.loadCallback((r=>{r?e(r.error):t(window.google)}))}))}importLibrary(t){return this.execute(),google.maps.importLibrary(t)}loadCallback(t){this.callbacks.push(t),this.execute()}setScript(){var t,e;if(document.getElementById(this.id))return void this.callback();const r={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(r).forEach((t=>!r[t]&&delete r[t])),(null===(e=null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.maps)||void 0===e?void 0:e.importLibrary)||(t=>{let e,r,a,n="The Google Maps JavaScript API",s="google",i="importLibrary",o="__ib__",c=document,l=window;l=l[s]||(l[s]={});const u=l.maps||(l.maps={}),E=new Set,S=new URLSearchParams,d=()=>e||(e=new Promise(((i,l)=>{return d=this,p=void 0,I=function*(){var d;for(a in yield r=c.createElement("script"),r.id=this.id,S.set("libraries",[...E]+""),t)S.set(a.replace(/[A-Z]/g,(t=>"_"+t[0].toLowerCase())),t[a]);S.set("callback",s+".maps."+o),r.src=this.url+"?"+S,u[o]=i,r.onerror=()=>e=l(Error(n+" could not load.")),r.nonce=this.nonce||(null===(d=c.querySelector("script[nonce]"))||void 0===d?void 0:d.nonce)||"",c.head.append(r)},new((h=void 0)||(h=Promise))((function(t,e){function r(t){try{n(I.next(t))}catch(t){e(t)}}function a(t){try{n(I.throw(t))}catch(t){e(t)}}function n(e){var n;e.done?t(e.value):(n=e.value,n instanceof h?n:new h((function(t){t(n)}))).then(r,a)}n((I=I.apply(d,p||[])).next())}));var d,p,h,I})));u[i]?console.warn(n+" only loads once. Ignoring:",t):u[i]=(t,...e)=>E.add(t)&&d().then((()=>u[i](t,...e)))})(r);const a=this.libraries.map((t=>this.importLibrary(t)));a.length||a.push(this.importLibrary("core")),Promise.all(a).then((()=>this.callback()),(t=>{const e=new ErrorEvent("error",{error:t});this.loadErrorCallback(e)}))}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(t){if(this.errors.push(t),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout((()=>{this.deleteScript(),this.setScript()}),t)}else this.onerrorEvent=t,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach((t=>{t(this.onerrorEvent)})),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading||(this.loading=!0,this.setScript())}}}const{GOOGLE:{MAPS:{LIBRARIES:Ea,VERSION:Sa}}}=a;var da=function(t){return{city:async function(e){try{const r=await async function(){try{const{AutocompleteService:t}=await async function(t=Ea.PLACES){const e=h(),r=new ua({apiKey:e?.googleMaps?.apiKey,version:Sa});return await r.importLibrary(t)}();return new t}catch(t){throw new Error("Unable to load google library:",t)}}();return new Promise((a=>{r.getPlacePredictions({...t,input:e,types:["(cities)"]},((t=[],e)=>{a("OK"===e?t:[])}))}))}catch(t){return console.error("Error with Autocomplete Service:",t),[]}}}},pa=l(408);const ha=t=>t&&pa.Buffer.from(t,"base64").toString("ascii");function Ia({contentContext:a=null,errorsContext:l=null,googleMapsContext:u=null,gtmContext:h=null,origin:I}){try{const w=(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 r=null;const a=e.match(i);return a?r=a[1].split(o)[0]:e===n?r=c:e.includes(s)&&(r=E),r||new Error(`Cannot select environment: No rule for website ${e}`),r})(I);return a&&(0,t.setContext)(Object.assign({},a,{environment:w})),l&&(0,e.setContext)(Object.assign({},l,{environment:w})),u&&(({apiKey:t})=>{p.googleMaps={apiKey:t}})(Object.assign({},u,{environment:w})),h&&((0,r.setContext)(Object.assign({},h,{environment:w})),(0,r.setupGTM)()),(({environment:t})=>{const e=(t=>{if(!t)throw new Error("Cannot map environment: Environment not defined");if(!S[t])throw new Error(`Cannot map environment: No mapping found for environment ${t}`);return S[t]})(t);p.emailIds=d[e]})(Object.assign({},{environment:w})),w}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),u}()}));
package/package.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "name": "@apolitical/sdk",
3
- "version": "8.1.0-ld.0",
3
+ "version": "8.1.0",
4
4
  "description": "Browser library to interact with Apolitical's APIs",
5
5
  "author": "Apolitical Group Limited <engineering@apolitical.co>",
6
6
  "license": "MIT",
7
7
  "main": "build/index.js",
8
8
  "files": [
9
- "build/**",
10
- "lib/index.d.ts"
9
+ "build/**"
11
10
  ],
12
- "types": "lib/index.d.ts",
13
11
  "scripts": {
14
12
  "test": "jest --runInBand",
15
13
  "unit-test": "jest test/unit/* --bail --runInBand --passWithNoTests",
package/lib/index.d.ts DELETED
@@ -1,349 +0,0 @@
1
- interface LoadSdkOptions {
2
- contentContext: { apiKey: string; previewKey: string; location: string };
3
- errorsContext: { apiKey: string; serviceName: string };
4
- gtmContext: { configs: { [key: string]: any } };
5
- origin: string;
6
- }
7
-
8
- interface PeopleAPIUser {
9
- [key: string]: any;
10
- }
11
-
12
- interface PeopleAPIUserCourse {
13
- [key: string]: any;
14
- }
15
-
16
- interface PeopleAPIUserEvents {
17
- [key: string]: any;
18
- }
19
-
20
- interface PeopleAPIUserLikes {
21
- [key: string]: any;
22
- }
23
-
24
- interface PeopleAPIUserLesson {
25
- [key: string]: any;
26
- }
27
-
28
- interface PeopleAPIUserProduct {
29
- [key: string]: any;
30
- }
31
-
32
- interface PeopleAPIUserRating {
33
- [key: string]: any;
34
- }
35
-
36
- interface PeopleAPIUserReferral {
37
- [key: string]: any;
38
- }
39
-
40
- interface SocialsAPIActivity {
41
- [key: string]: any;
42
- }
43
-
44
- interface SocialsAPICommunity {
45
- [key: string]: any;
46
- }
47
-
48
- interface SocialsAPIReaction {
49
- [key: string]: any;
50
- }
51
-
52
- interface SocialsAPILike {
53
- slug: string;
54
- activityId: string;
55
- reactionId: string;
56
- }
57
-
58
- interface PostResponse {
59
- created: true;
60
- }
61
-
62
- interface DeleteResponse {
63
- removed?: true;
64
- deleted?: true;
65
- }
66
-
67
- interface QueryParams {
68
- [key: string]: string | number | boolean;
69
- }
70
-
71
- declare module '@apolitical/sdk' {
72
- /**
73
- * Loads the SDK using the provided options
74
- *
75
- * @param contentContext for setting up Contentful
76
- * @param errorsContext for setting up GCP error logging
77
- * @param gtmContext for setting up Google Tag Manager
78
- * @param origin the origin of the page
79
- */
80
- export default function loadSdk(options: LoadSdkOptions): string;
81
-
82
- /**
83
- * Decodes a base64 string to plain string
84
- * @param {String} value - The base64 string
85
- * @return {String} value - The plain string
86
- */
87
- export function decodeBase64(value: string): string;
88
-
89
- /**
90
- * Logs the error message and reports the error to GCP
91
- * @param {Error} error - The error object
92
- */
93
- export function reportError(error: Error): void;
94
-
95
- //
96
- // People API resources
97
- // ----------------------------------------------------------------------
98
- export const people: {
99
- bulkEnrolments: {
100
- /**
101
- * Lists bulk enrolments from the People API
102
- * @param {Object} params - Params to be passed to the request
103
- * @return {Array} data - JSON array returned by the API
104
- */
105
- list: (params: QueryParams) => Promise<any[]>;
106
- };
107
- // TODO: add types for the rest of the handlers
108
- handlers: {};
109
- registrations: {
110
- /**
111
- * Lists registrations from the People API
112
- * @param {Object} params - Params to be passed to the request
113
- * @return {Object} data - JSON object returned by the API
114
- */
115
- list: (params: QueryParams) => Promise<any>;
116
- };
117
- users: {
118
- /**
119
- * Fetches a user by id
120
- * @param {String} id - The id of the user
121
- * @return {Promise} user - The user object
122
- */
123
- read: (id: string) => Promise<PeopleAPIUser>;
124
- /**
125
- * Lists users from the People API based on an array of ids
126
- * @param {String} ids - The ids of the users (needs at least two)
127
- * @return {Array} data - array with JSON objects returned by the API
128
- */
129
- list: (ids: string[]) => Promise<PeopleAPIUser[]>;
130
- /**
131
- * Updates a user in the People API
132
- * @param {String} id - The id of the user
133
- * @param {Object} payload - The data to update the user with
134
- * @return {Promise} updated - Whether the user was updated or not
135
- */
136
- update: (id: string, payload: Partial<PeopleAPIUser>) => Promise<boolean>;
137
- };
138
- userCourses: {
139
- /**
140
- * Creates a user course in People API
141
- * @param {Object} payload - The data to create the user course with
142
- */
143
- create: (payload: PeopleAPIUserCourse) => Promise<void>;
144
- /**
145
- * Lists user's courses from the People API based on the supplied params
146
- * @param {String} params - The params to use to filter the courses
147
- * @return {Array} data - array with JSON objects returned by the API
148
- */
149
- list: (params: QueryParams) => Promise<PeopleAPIUserCourse[]>;
150
- /**
151
- * Updates a user course in the People API
152
- * @param {String} courseId - The id of the user course
153
- * @param {Object} payload - The data to update the user course with
154
- */
155
- update: (courseId: string, payload: Partial<PeopleAPIUserCourse>) => Promise<void>;
156
- };
157
- userEvents: {
158
- /**
159
- * Lists user's events from the People API based on the supplied params
160
- * * @param {String} params - The params to use to filter the events
161
- * @return {Array} data - array with JSON objects returned by the API
162
- */
163
- list: (params: QueryParams) => Promise<PeopleAPIUserEvents[]>;
164
- };
165
- userLikes: {
166
- /**
167
- * Lists user's likes from the People API based on the supplied params
168
- * @param {String} params - The params to use to filter the likes
169
- * @return {Array} data - array with JSON objects returned by the API
170
- */
171
- list: (params: QueryParams) => Promise<PeopleAPIUserLikes[]>;
172
- };
173
- userLessons: {
174
- /**
175
- * Creates a user lesson in People API
176
- * @param {Object} payload - The data to create the user lesson with
177
- */
178
- create: (payload: PeopleAPIUserLesson) => Promise<PeopleAPIUserLesson>;
179
- /**
180
- * Lists user's lessons from the People API based on the supplied params
181
- * @param {String} params - The params to use to filter the lessons
182
- * @return {Array} data - array with JSON objects returned by the API
183
- */
184
- list: (params: QueryParams) => Promise<PeopleAPIUserLesson[]>;
185
- };
186
- userProducts: {
187
- /**
188
- * Creates a user product in People API
189
- * @param {Object} payload - The data to create the user product with
190
- */
191
- create: (payload: PeopleAPIUserProduct) => Promise<PeopleAPIUserProduct>;
192
- /**
193
- * Lists user's products from the People API based on the supplied params
194
- * @param {String} params - The params to use to filter the products
195
- * @return {Array} data - array with JSON objects returned by the API
196
- */
197
- list: (params: QueryParams) => Promise<PeopleAPIUserProduct[]>;
198
- /**
199
- * Updates a user product in the People API
200
- * @param {String} productId - The id of the user product
201
- * @param {Object} payload - The data to update the user product with
202
- */
203
- update: (productId: string, payload: Partial<PeopleAPIUserProduct>) => Promise<void>;
204
- };
205
- userRatings: {
206
- /**
207
- * Creates a user rating in People API
208
- * @param {Object} payload - The data to create the user rating with
209
- */
210
- create: (payload: PeopleAPIUserRating) => Promise<PeopleAPIUserRating>;
211
- /**
212
- * Updates a user rating in the People API
213
- * @param {String} ratingId - The id of the user rating
214
- * @param {Object} payload - The data to update the user rating with
215
- */
216
- update: (ratingId: string, payload: Partial<PeopleAPIUserRating>) => Promise<void>;
217
- };
218
- userReferrals: {
219
- /**
220
- * Lists user's referrals from the People API based on the supplied params
221
- * @param {String} params - The params to use to filter the referrals
222
- * @return {Array} data - array with JSON objects returned by the API
223
- */
224
- list: (params: QueryParams) => Promise<PeopleAPIUserReferral[]>;
225
- };
226
- };
227
-
228
- //
229
- // Social API resources
230
- // ----------------------------------------------------------------------
231
- export const socials: {
232
- activities: {
233
- /**
234
- * Creates an activity in Socials API
235
- * @param {String} slug - The slug of the community
236
- * @param {Object} payload - The data to create the activity with
237
- * @return {Promise} activity - The activity object
238
- */
239
- create: (slug: string, payload: SocialsAPIActivity) => Promise<SocialsAPIActivity>;
240
- /**
241
- * Fetches an activity by slug in Socials API
242
- * @param {String} slug - The slug of the community
243
- * @param {String} activityId - The ID of the activity
244
- * @return {Promise} activity - The activity object
245
- */
246
- read: (slug: string, activityId: string) => Promise<SocialsAPIActivity>;
247
- /**
248
- * Lists activities from the Socials API based on params
249
- * @param {String} slug - The slug of the community
250
- * @param {Object} params - Params to be passed to the request
251
- * @return {Array} data - array with JSON objects returned by the API
252
- */
253
- list: (slug: string, params: QueryParams) => Promise<SocialsAPIActivity[]>;
254
- /**
255
- * Updates an activity in the Socials API
256
- * @param {String} slug - The slug of the community
257
- * @param {String} activityId - The ID of the activity
258
- * @param {Object} payload - The data to update the activity with
259
- * @return {Promise} activity - The activity object
260
- */
261
- update: (slug: string, activityId: string, payload: Partial<SocialsAPIActivity>) => Promise<SocialsAPIActivity>;
262
- /**
263
- * Removes an activity in the Socials API
264
- * @param {String} slug - The slug of the community
265
- * @param {String} activityId - The ID of the activity
266
- * @return {Promise} activity - The activity object
267
- */
268
- remove: (slug: string, activityId: string) => Promise<DeleteResponse>;
269
- };
270
- communities: {
271
- /**
272
- * Fetches a community by slug in Socials API
273
- * @param {String} slug - The slug of the community
274
- * @return {Promise} community - The community object
275
- */
276
- read: (slug: string) => Promise<SocialsAPICommunity>;
277
- /**
278
- * Allows a user to join a community in Socials API
279
- * @param {String} slug - The slug of the community
280
- * @param {Object} payload - The data to join the community with
281
- * @return {Promise} data - The join object
282
- */
283
- join: (slug: string, payload: SocialsAPICommunity) => Promise<PostResponse>;
284
- /**
285
- * Allows a user to leave a community in the Socials API
286
- * @param {String} slug - The slug of the community
287
- * @return {Promise} data - The deletion object
288
- */
289
- remove: (slug: string) => Promise<DeleteResponse>;
290
- };
291
- likes: {
292
- /**
293
- * Creates a like on a reaction in Socials API
294
- * @param {String} slug - The slug of the community
295
- * @param {String} activityId - The ID of the activity
296
- * @param {String} reactionId - The ID of the reaction
297
- * @return {Promise} reaction - The reaction object
298
- */
299
- create: (payload: SocialsAPILike) => Promise<SocialsAPIReaction>;
300
- /**
301
- * Allows a user to remove like on a reaction in the Socials API
302
- * @param {String} slug - The slug of the community
303
- * @param {String} reactionId - The ID of the reaction
304
- * @return {Promise} data - The deletion object
305
- */
306
- remove: (payload: Exclude<SocialsAPILike, 'activityId'>) => Promise<DeleteResponse>;
307
- };
308
- reactions: {
309
- /**
310
- * Creates a reaction on a reaction in Socials API
311
- * @param {String} slug - The slug of the community
312
- * @param {String} activityId - The ID of the activity
313
- * @param {String} reactionId - The ID of the reaction
314
- * @return {Promise} reaction - The reaction object
315
- */
316
- create: (slug: string, activityId: string, reactionId: string) => Promise<SocialsAPIReaction>;
317
- /**
318
- * Removes a reaction on a reaction in the Socials API
319
- * @param {String} slug - The slug of the community
320
- * @param {String} reactionId - The ID of the reaction
321
- * @return {Promise} data - The deletion object
322
- */
323
- remove: (slug: string, reactionId: string) => Promise<DeleteResponse>;
324
-
325
- /**
326
- * Updates a reaction on a reaction in the Socials API
327
- * @param {String} slug - The slug of the community
328
- * @param {String} activityId - The ID of the activity
329
- * @param {String} reactionId - The ID of the reaction
330
- * @param {Object} payload - The data to update the reaction with
331
- */
332
- update: (
333
- slug: string,
334
- activityId: string,
335
- reactionId: string,
336
- payload: Partial<SocialsAPIReaction>,
337
- ) => Promise<SocialsAPIReaction>;
338
-
339
- /**
340
- * Lists reactions from the Socials API based on params
341
- * @param {String} slug - The slug of the community
342
- * @param {Object} payload - The data to create the reaction with
343
- * @param {Object} params - Params to be passed to the request
344
- * @return {Array}
345
- */
346
- list: (slug: string, payload: Exclude<SocialsAPILike, 'slug'>, params: any) => Promise<SocialsAPIReaction[]>;
347
- };
348
- };
349
- }