@apolitical/sdk 0.9.3 → 0.10.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/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.10.0] - 2022-08-04
9
+ ### Added
10
+ - List, Update and Create user products to people resources
11
+
8
12
  ## [0.9.3] - 2022-06-28
9
13
  ### Changed
10
14
  - Pipeline refs
package/build/index.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/auth"),require("@apolitical/content"),require("@apolitical/error-reporting"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/auth","@apolitical/content","@apolitical/error-reporting","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/auth"),require("@apolitical/content"),require("@apolitical/error-reporting"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/auth"],t["@apolitical/content"],t["@apolitical/error-reporting"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,n,r,a,o){return function(){var i={772:function(t,e,n){var r;t.exports=(r=n(785),function(){"use strict";var t={273:function(t){t.exports=r}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,n),o.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var a={};return function(){n.r(a),n.d(a,{setContext:function(){return o},setupGTM:function(){return i}});var t=n(273),e=n.n(t);let r=null;const o=({configs:t,environment:e})=>{if(!e)throw new Error("Cannot set context: Environment not defined");if(!t)throw new Error("Cannot set context: REACT_APP_GTM_ID not defined");if(!t[e])throw new Error(`Cannot set context: REACT_APP_GTM_ID not defined for environment - ${JSON.stringify({configs:t,environment:e})}`);r=t[e]},i=()=>{const t=r;e().initialize({gtmId:t.id})}}(),a}())},421:function(t,e,n){"use strict";var r,a=(r=n(425))&&r.__esModule?r:{default:r},o={tags:function(t){var e=t.id,n=t.events,r=t.dataLayer,o=t.dataLayerName,i=t.preview,s="&gtm_auth="+t.auth,c="&gtm_preview="+i;return e||(0,a.default)("GTM Id is required"),{iframe:'\n <iframe src="https://www.googletagmanager.com/ns.html?id='+e+s+c+'&gtm_cookies_win=x"\n height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>',script:"\n (function(w,d,s,l,i){w[l]=w[l]||[];\n w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js', "+JSON.stringify(n).slice(1,-1)+"});\n var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';\n j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl+'"+s+c+"&gtm_cookies_win=x';\n f.parentNode.insertBefore(j,f);\n })(window,document,'script','"+o+"','"+e+"');",dataLayerVar:this.dataLayer(r,o)}},dataLayer:function(t,e){return"\n window."+e+" = window."+e+" || [];\n window."+e+".push("+JSON.stringify(t)+")"}};t.exports=o},676:function(t,e,n){"use strict";var r,a=(r=n(421))&&r.__esModule?r:{default:r},o={dataScript:function(t){var e=document.createElement("script");return e.innerHTML=t,e},gtm:function(t){var e=a.default.tags(t);return{noScript:function(){var t=document.createElement("noscript");return t.innerHTML=e.iframe,t},script:function(){var t=document.createElement("script");return t.innerHTML=e.script,t},dataScript:this.dataScript(e.dataLayerVar)}},initialize:function(t){var e=t.gtmId,n=t.events,r=void 0===n?{}:n,a=t.dataLayer,o=t.dataLayerName,i=void 0===o?"dataLayer":o,s=t.auth,c=void 0===s?"":s,u=t.preview,d=void 0===u?"":u,l=this.gtm({id:e,events:r,dataLayer:a||void 0,dataLayerName:i,auth:c,preview:d});a&&document.head.appendChild(l.dataScript),document.head.insertBefore(l.script(),document.head.childNodes[0]),document.body.insertBefore(l.noScript(),document.body.childNodes[0])},dataLayer:function(t){var e=t.dataLayer,n=t.dataLayerName,r=void 0===n?"dataLayer":n;if(window[r])return window[r].push(e);var o=a.default.dataLayer(e,r),i=this.dataScript(o);document.head.insertBefore(i,document.head.childNodes[0])}};t.exports=o},785:function(t,e,n){"use strict";var r,a=(r=n(676))&&r.__esModule?r:{default:r};t.exports=a.default},425:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){console.warn("[react-gtm]",t)}},654:function(e){"use strict";e.exports=t},809:function(t){"use strict";t.exports=e},30:function(t){"use strict";t.exports=n},300:function(t){"use strict";t.exports=r},408:function(t){"use strict";t.exports=o},25:function(t){"use strict";t.exports=a}},s={};function c(t){var e=s[t];if(void 0!==e)return e.exports;var n=s[t]={exports:{}};return i[t].call(n.exports,n,n.exports,c),n.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 n in e)c.o(e,n)&&!c.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},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 u={};return function(){"use strict";c.r(u),c.d(u,{assets:function(){return y},decodeBase64:function(){return Z},default:function(){return tt},getAuthContext:function(){return t.getContext},getEntries:function(){return e.getEntries},getEntry:function(){return e.getEntry},management:function(){return I},passwordlessLogin:function(){return t.passwordlessLogin},people:function(){return K},peopleEngagement:function(){return Q},reportError:function(){return n.reportError},sendVerificationEmail:function(){return t.sendVerificationEmail},setupGTM:function(){return r.setupGTM}});var t=c(654),e=c(809),n=c(30),r=c(772),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"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts"}},PEOPLE_API:{BASE_URL:"/api/people-api",ENDPOINTS:{USERS:"/users",USER_COURSES:"/courses",USER_LESSONS:"/lessons",REGISTRATIONS:"/registrations"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{USERS:"/users",USER_PROPERTIES:"/properties"}}},USERS:{MYSELF_SLUG:"me"}};const{APOLITICAL:{WEBSITES:{LIVE:o,LOCALHOST:i,STAGING:s,STAGING_SPLITTER:d},ENVIRONMENTS:{PRODUCTION:l,LOCAL:p}}}=a;var f=c(300),S=c.n(f);const E=async t=>{try{const{message:e,response:r,request:a}=t;let o=e;r?o+=` - The request was made and the server responded with ${JSON.stringify({status:r.status,data:r.data})}`:a&&(o+=" - The request was made but no response was received"),console.warn(o),await(0,n.reportError)(new Error(o))}catch(t){console.warn(`Cannot handle error: ${t.message}`)}},{APIS:{ASSETS_API:{BASE_URL:m,ENDPOINTS:{USERS:g,CERTIFICATES:w}}}}=a;var y={certificates:{create:async(t,e)=>{let n=[];try{const{data:r}=await S().post(`${m}${g}/${t}${w}`,e);r&&(n=r)}catch(t){await E(t)}return n}}};const{APIS:{MANAGEMENT_API:{BASE_URL:h,ENDPOINTS:{ACCOUNTS:v}}}}=a;var I={accounts:{create:async t=>{try{await S().post(`${h}${v}`,t)}catch(t){throw await E(t),t}},read:async t=>{let e=null;try{({data:e}=await S().get(`${h}${v}/${encodeURIComponent(t)}`))}catch(t){await E(t)}return e},update:async(t,e)=>{try{await S().put(`${h}${v}/${encodeURIComponent(t)}`,e)}catch(t){throw await E(t),t}}}};const{APIS:{PEOPLE_API:{BASE_URL:L,ENDPOINTS:{REGISTRATIONS:P}}}}=a;var T={list:async t=>{let e=[];try{const{data:n}=await S().get(`${L}${P}`,{params:t});n&&n.length&&(e=n)}catch(t){await E(t)}return e}},O=c(25);const{OK:_,MULTIPLE_CHOICES:N,NOT_FOUND:A,FORBIDDEN:R}=O.StatusCodes,C=t=>t>=_&&t<N||t===R||t===A,{APIS:{PEOPLE_API:{BASE_URL:x,ENDPOINTS:{USERS:U}}}}=a;var $={read:async t=>{let e=null;try{const{data:n}=await S().get(`${x}${U}/${encodeURIComponent(t)}`,{validateStatus:C});n&&n.slug&&(e=n)}catch(t){await E(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL:b,ENDPOINTS:{USERS:M,USER_COURSES:G}}},USERS:{MYSELF_SLUG:j}}=a,D=`${b}${M}/${j}${G}`;var B={create:async t=>{try{await S().post(D,t)}catch(t){await E(t)}},list:async t=>{let e=[],n=t?{params:t}:{params:{}};try{const{data:t}=await S().get(D,n);t&&t.length&&(e=t)}catch(t){await E(t)}return e},update:async(t,e)=>{try{await S().put(`${D}/${t}`,e)}catch(t){await E(t)}}};const{APIS:{PEOPLE_API:{BASE_URL:q,ENDPOINTS:{USERS:F,USER_LESSONS:V}}},USERS:{MYSELF_SLUG:H}}=a,J=`${q}${F}/${H}${V}`;var K={registrations:T,users:$,userCourses:B,userLessons:{create:async t=>{let e=null;try{e=await S().post(J,t)}catch(t){await E(t)}return e},list:async t=>{let e=[],n=t?{params:t}:{params:{}};try{const{data:t}=await S().get(J,n);t&&t.length&&(e=t)}catch(t){await E(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:Y,ENDPOINTS:{USERS:W,USER_PROPERTIES:k}}},USERS:{MYSELF_SLUG:z}}=a;var Q={userProperties:{update:async(t,e)=>{try{await S().put(`${Y}${W}/${z}${k}/${t}`,e)}catch(t){await E(t)}}}},X=c(408);const Z=t=>t&&X.Buffer.from(t,"base64").toString("ascii");function tt({authContext:a=null,contentContext:c=null,errorsContext:u=null,gtmContext:f=null,origin:S}){try{const E=(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 n=null;const r=e.match(s);return r?n=r[1].split(d)[0]:e===o?n=l:e.includes(i)&&(n=p),n||new Error(`Cannot select environment: No rule for website ${e}`),n})(S);a&&(0,t.setContext)(Object.assign({},a,{environment:E,origin:S})),c&&(0,e.setContext)(Object.assign({},c,{environment:E})),u&&(0,n.setContext)(Object.assign({},u,{environment:E})),f&&(0,r.setContext)(Object.assign({},f,{environment:E}))}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),u}()}));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/auth"),require("@apolitical/content"),require("@apolitical/error-reporting"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/auth","@apolitical/content","@apolitical/error-reporting","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/auth"),require("@apolitical/content"),require("@apolitical/error-reporting"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/auth"],t["@apolitical/content"],t["@apolitical/error-reporting"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,n,r,a,o){return function(){var i={772:function(t,e,n){var r;t.exports=(r=n(785),function(){"use strict";var t={273:function(t){t.exports=r}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,n),o.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var a={};return function(){n.r(a),n.d(a,{setContext:function(){return o},setupGTM:function(){return i}});var t=n(273),e=n.n(t);let r=null;const o=({configs:t,environment:e})=>{if(!e)throw new Error("Cannot set context: Environment not defined");if(!t)throw new Error("Cannot set context: REACT_APP_GTM_ID not defined");if(!t[e])throw new Error(`Cannot set context: REACT_APP_GTM_ID not defined for environment - ${JSON.stringify({configs:t,environment:e})}`);r=t[e]},i=()=>{const t=r;e().initialize({gtmId:t.id})}}(),a}())},421:function(t,e,n){"use strict";var r,a=(r=n(425))&&r.__esModule?r:{default:r},o={tags:function(t){var e=t.id,n=t.events,r=t.dataLayer,o=t.dataLayerName,i=t.preview,s="&gtm_auth="+t.auth,c="&gtm_preview="+i;return e||(0,a.default)("GTM Id is required"),{iframe:'\n <iframe src="https://www.googletagmanager.com/ns.html?id='+e+s+c+'&gtm_cookies_win=x"\n height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>',script:"\n (function(w,d,s,l,i){w[l]=w[l]||[];\n w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js', "+JSON.stringify(n).slice(1,-1)+"});\n var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';\n j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl+'"+s+c+"&gtm_cookies_win=x';\n f.parentNode.insertBefore(j,f);\n })(window,document,'script','"+o+"','"+e+"');",dataLayerVar:this.dataLayer(r,o)}},dataLayer:function(t,e){return"\n window."+e+" = window."+e+" || [];\n window."+e+".push("+JSON.stringify(t)+")"}};t.exports=o},676:function(t,e,n){"use strict";var r,a=(r=n(421))&&r.__esModule?r:{default:r},o={dataScript:function(t){var e=document.createElement("script");return e.innerHTML=t,e},gtm:function(t){var e=a.default.tags(t);return{noScript:function(){var t=document.createElement("noscript");return t.innerHTML=e.iframe,t},script:function(){var t=document.createElement("script");return t.innerHTML=e.script,t},dataScript:this.dataScript(e.dataLayerVar)}},initialize:function(t){var e=t.gtmId,n=t.events,r=void 0===n?{}:n,a=t.dataLayer,o=t.dataLayerName,i=void 0===o?"dataLayer":o,s=t.auth,c=void 0===s?"":s,u=t.preview,d=void 0===u?"":u,l=this.gtm({id:e,events:r,dataLayer:a||void 0,dataLayerName:i,auth:c,preview:d});a&&document.head.appendChild(l.dataScript),document.head.insertBefore(l.script(),document.head.childNodes[0]),document.body.insertBefore(l.noScript(),document.body.childNodes[0])},dataLayer:function(t){var e=t.dataLayer,n=t.dataLayerName,r=void 0===n?"dataLayer":n;if(window[r])return window[r].push(e);var o=a.default.dataLayer(e,r),i=this.dataScript(o);document.head.insertBefore(i,document.head.childNodes[0])}};t.exports=o},785:function(t,e,n){"use strict";var r,a=(r=n(676))&&r.__esModule?r:{default:r};t.exports=a.default},425:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){console.warn("[react-gtm]",t)}},654:function(e){"use strict";e.exports=t},809:function(t){"use strict";t.exports=e},30:function(t){"use strict";t.exports=n},300:function(t){"use strict";t.exports=r},408:function(t){"use strict";t.exports=o},25:function(t){"use strict";t.exports=a}},s={};function c(t){var e=s[t];if(void 0!==e)return e.exports;var n=s[t]={exports:{}};return i[t].call(n.exports,n,n.exports,c),n.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 n in e)c.o(e,n)&&!c.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},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 u={};return function(){"use strict";c.r(u),c.d(u,{assets:function(){return y},decodeBase64:function(){return ot},default:function(){return it},getAuthContext:function(){return t.getContext},getEntries:function(){return e.getEntries},getEntry:function(){return e.getEntry},management:function(){return L},passwordlessLogin:function(){return t.passwordlessLogin},people:function(){return X},peopleEngagement:function(){return rt},reportError:function(){return n.reportError},sendVerificationEmail:function(){return t.sendVerificationEmail},setupGTM:function(){return r.setupGTM}});var t=c(654),e=c(809),n=c(30),r=c(772),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"}},MANAGEMENT_API:{BASE_URL:"/api/management-api",ENDPOINTS:{ACCOUNTS:"/accounts"}},PEOPLE_API:{BASE_URL:"/api/people-api",ENDPOINTS:{USERS:"/users",USER_PRODUCTS:"/products",USER_COURSES:"/courses",USER_LESSONS:"/lessons",REGISTRATIONS:"/registrations"}},PEOPLE_ENGAGEMENT_API:{BASE_URL:"/api/people-engagement-api",ENDPOINTS:{USERS:"/users",USER_PROPERTIES:"/properties"}}},USERS:{MYSELF_SLUG:"me"}};const{APOLITICAL:{WEBSITES:{LIVE:o,LOCALHOST:i,STAGING:s,STAGING_SPLITTER:d},ENVIRONMENTS:{PRODUCTION:l,LOCAL:p}}}=a;var S=c(300),f=c.n(S);const E=async t=>{try{const{message:e,response:r,request:a}=t;let o=e;r?o+=` - The request was made and the server responded with ${JSON.stringify({status:r.status,data:r.data})}`:a&&(o+=" - The request was made but no response was received"),console.warn(o),await(0,n.reportError)(new Error(o))}catch(t){console.warn(`Cannot handle error: ${t.message}`)}},{APIS:{ASSETS_API:{BASE_URL:m,ENDPOINTS:{USERS:w,CERTIFICATES:g}}}}=a;var y={certificates:{create:async(t,e)=>{let n=[];try{const{data:r}=await f().post(`${m}${w}/${t}${g}`,e);r&&(n=r)}catch(t){await E(t)}return n}}};const{APIS:{MANAGEMENT_API:{BASE_URL:P,ENDPOINTS:{ACCOUNTS:h}}}}=a;var L={accounts:{create:async t=>{try{await f().post(`${P}${h}`,t)}catch(t){throw await E(t),t}},read:async t=>{let e=null;try{({data:e}=await f().get(`${P}${h}/${encodeURIComponent(t)}`))}catch(t){await E(t)}return e},update:async(t,e)=>{try{await f().put(`${P}${h}/${encodeURIComponent(t)}`,e)}catch(t){throw await E(t),t}}}};const{APIS:{PEOPLE_API:{BASE_URL:v,ENDPOINTS:{REGISTRATIONS:I}}}}=a;var T={list:async t=>{let e=[];try{const{data:n}=await f().get(`${v}${I}`,{params:t});n&&n.length&&(e=n)}catch(t){await E(t)}return e}},_=c(25);const{OK:O,MULTIPLE_CHOICES:N,NOT_FOUND:A,FORBIDDEN:R}=_.StatusCodes,U=t=>t>=O&&t<N||t===R||t===A,{APIS:{PEOPLE_API:{BASE_URL:C,ENDPOINTS:{USERS:x}}}}=a;var $={read:async t=>{let e=null;try{const{data:n}=await f().get(`${C}${x}/${encodeURIComponent(t)}`,{validateStatus:U});n&&n.slug&&(e=n)}catch(t){await E(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL:b,ENDPOINTS:{USERS:M,USER_COURSES:G}}},USERS:{MYSELF_SLUG:D}}=a,j=`${b}${M}/${D}${G}`;var B={create:async t=>{try{await f().post(j,t)}catch(t){await E(t)}},list:async t=>{let e=[],n=t?{params:t}:{params:{}};try{const{data:t}=await f().get(j,n);t&&t.length&&(e=t)}catch(t){await E(t)}return e},update:async(t,e)=>{try{await f().put(`${j}/${t}`,e)}catch(t){await E(t)}}};const{APIS:{PEOPLE_API:{BASE_URL:q,ENDPOINTS:{USERS:F,USER_LESSONS:V}}},USERS:{MYSELF_SLUG:H}}=a,Y=`${q}${F}/${H}${V}`;var J={create:async t=>{let e=null;try{e=await f().post(Y,t)}catch(t){await E(t)}return e},list:async t=>{let e=[],n=t?{params:t}:{params:{}};try{const{data:t}=await f().get(Y,n);t&&t.length&&(e=t)}catch(t){await E(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL:K,ENDPOINTS:{USERS:W,USER_PRODUCTS:k}}},USERS:{MYSELF_SLUG:z}}=a,Q=`${K}${W}/${z}${k}`;var X={registrations:T,users:$,userCourses:B,userLessons:J,userProducts:{create:async t=>{let e=null;try{e=await f().post(Q,t)}catch(t){await E(t)}return e},list:async t=>{let e=[],n=t?{params:t}:{params:{}};try{const{data:t}=await f().get(Q,n);t&&t.length&&(e=t)}catch(t){await E(t)}return e},update:async(t,e)=>{try{await f().put(`${Q}/${t}`,e)}catch(t){await E(t)}}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:Z,ENDPOINTS:{USERS:tt,USER_PROPERTIES:et}}},USERS:{MYSELF_SLUG:nt}}=a;var rt={userProperties:{update:async(t,e)=>{try{await f().put(`${Z}${tt}/${nt}${et}/${t}`,e)}catch(t){await E(t)}}}},at=c(408);const ot=t=>t&&at.Buffer.from(t,"base64").toString("ascii");function it({authContext:a=null,contentContext:c=null,errorsContext:u=null,gtmContext:S=null,origin:f}){try{const E=(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 n=null;const r=e.match(s);return r?n=r[1].split(d)[0]:e===o?n=l:e.includes(i)&&(n=p),n||new Error(`Cannot select environment: No rule for website ${e}`),n})(f);a&&(0,t.setContext)(Object.assign({},a,{environment:E,origin:f})),c&&(0,e.setContext)(Object.assign({},c,{environment:E})),u&&(0,n.setContext)(Object.assign({},u,{environment:E})),S&&(0,r.setContext)(Object.assign({},S,{environment:E}))}catch(t){console.warn(`Cannot load SDK: ${t.message}`)}}}(),u}()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolitical/sdk",
3
- "version": "0.9.3",
3
+ "version": "0.10.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",