@apolitical/sdk 0.8.3 → 0.8.4-rc.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 +1 -1
- package/package.json +3 -3
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/auth"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/auth","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/auth"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/auth"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,r,a,n,i){return function(){var o={772:function(t,e,r){var a;t.exports=(a=r(785),function(){"use strict";var t={273:function(t){t.exports=a}},e={};function r(a){var n=e[a];if(void 0!==n)return n.exports;var i=e[a]={exports:{}};return t[a](i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var a in e)r.o(e,a)&&!r.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return function(){r.r(n),r.d(n,{setContext:function(){return u},setupGTM:function(){return d}});var t=r(273),e=r.n(t);const{APOLITICAL:{WEBSITES:{BETA:a,BETA_2:i,LIVE:o,RC:s}}}={APOLITICAL:{WEBSITES:{BETA:"https://beta.apolitical.co",BETA_2:"https://beta-2.apolitical.co",LIVE:"https://apolitical.co",RC:"https://rc.apolitical.co"},ENVIRONMENTS:{BETA:"beta",BETA_2:"beta",RC:"rc",LIVE:"master"}}};let c=null;const u=({configs:t,origin:e=null})=>{c=((t,e)=>{let r=null,n=null;switch(r="undefined"!=typeof window?window.origin||window.location.origin:e,r){case a:n=t.beta;break;case i:n=t["beta-2"];break;case o:n=t.live;break;case s:n=t.rc;break;default:n=t.local}return n})(t,e)},d=
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/auth"),require("axios"),require("http-status-codes"),require("buffer")):"function"==typeof define&&define.amd?define(["@apolitical/content","@apolitical/error-reporting","@apolitical/auth","axios","http-status-codes","buffer"],e):"object"==typeof exports?exports.ApoliticalSDK=e(require("@apolitical/content"),require("@apolitical/error-reporting"),require("@apolitical/auth"),require("axios"),require("http-status-codes"),require("buffer")):t.ApoliticalSDK=e(t["@apolitical/content"],t["@apolitical/error-reporting"],t["@apolitical/auth"],t.axios,t["http-status-codes"],t.buffer)}(this,(function(t,e,r,a,n,i){return function(){var o={772:function(t,e,r){var a;t.exports=(a=r(785),function(){"use strict";var t={273:function(t){t.exports=a}},e={};function r(a){var n=e[a];if(void 0!==n)return n.exports;var i=e[a]={exports:{}};return t[a](i,i.exports,r),i.exports}r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var a in e)r.o(e,a)&&!r.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return function(){r.r(n),r.d(n,{setContext:function(){return u},setupGTM:function(){return d}});var t=r(273),e=r.n(t);const{APOLITICAL:{WEBSITES:{BETA:a,BETA_2:i,LIVE:o,RC:s}}}={APOLITICAL:{WEBSITES:{BETA:"https://beta.apolitical.co",BETA_2:"https://beta-2.apolitical.co",LIVE:"https://apolitical.co",RC:"https://rc.apolitical.co"},ENVIRONMENTS:{BETA:"beta",BETA_2:"beta",RC:"rc",LIVE:"master"}}};let c=null;const u=({configs:t,origin:e=null})=>{c=((t,e)=>{let r=null,n=null;switch(r="undefined"!=typeof window?window.origin||window.location.origin:e,r){case a:n=t.beta;break;case i:n=t["beta-2"];break;case o:n=t.live;break;case s:n=t.rc;break;default:n=t.local}return n})(t,e)},d=t=>{const r=c;"true"===t["performance-cookie-consent"]&&e().initialize({gtmId:r.id})}}(),n}())},421:function(t,e,r){"use strict";var a,n=(a=r(425))&&a.__esModule?a:{default:a},i={tags:function(t){var e=t.id,r=t.events,a=t.dataLayer,i=t.dataLayerName,o=t.preview,s=">m_auth="+t.auth,c=">m_preview="+o;return e||(0,n.default)("GTM Id is required"),{iframe:'\n <iframe src="https://www.googletagmanager.com/ns.html?id='+e+s+c+'>m_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(r).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+">m_cookies_win=x';\n f.parentNode.insertBefore(j,f);\n })(window,document,'script','"+i+"','"+e+"');",dataLayerVar:this.dataLayer(a,i)}},dataLayer:function(t,e){return"\n window."+e+" = window."+e+" || [];\n window."+e+".push("+JSON.stringify(t)+")"}};t.exports=i},676:function(t,e,r){"use strict";var a,n=(a=r(421))&&a.__esModule?a:{default:a},i={dataScript:function(t){var e=document.createElement("script");return e.innerHTML=t,e},gtm:function(t){var e=n.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,r=t.events,a=void 0===r?{}:r,n=t.dataLayer,i=t.dataLayerName,o=void 0===i?"dataLayer":i,s=t.auth,c=void 0===s?"":s,u=t.preview,d=void 0===u?"":u,l=this.gtm({id:e,events:a,dataLayer:n||void 0,dataLayerName:o,auth:c,preview:d});n&&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,r=t.dataLayerName,a=void 0===r?"dataLayer":r;if(window[a])return window[a].push(e);var i=n.default.dataLayer(e,a),o=this.dataScript(i);document.head.insertBefore(o,document.head.childNodes[0])}};t.exports=i},785:function(t,e,r){"use strict";var a,n=(a=r(676))&&a.__esModule?a:{default:a};t.exports=n.default},425:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){console.warn("[react-gtm]",t)}},654:function(t){"use strict";t.exports=r},809:function(e){"use strict";e.exports=t},30:function(t){"use strict";t.exports=e},300:function(t){"use strict";t.exports=a},408:function(t){"use strict";t.exports=i},25:function(t){"use strict";t.exports=n}},s={};function c(t){var e=s[t];if(void 0!==e)return e.exports;var r=s[t]={exports:{}};return o[t].call(r.exports,r,r.exports,c),r.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 r in e)c.o(e,r)&&!c.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},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 f},decodeBase64:function(){return J},default:function(){return K},getEntries:function(){return t.getEntries},getEntry:function(){return t.getEntry},management:function(){return g},passwordlessLogin:function(){return r.passwordlessLogin},people:function(){return q},peopleEngagement:function(){return H},reportError:function(){return e.reportError},sendVerificationEmail:function(){return r.sendVerificationEmail},setupGTM:function(){return a.setupGTM}});var t=c(809),e=c(30),r=c(654),a=c(772),n=c(300),i=c.n(n),o={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 s=async t=>{try{const{message:r,response:a,request:n}=t;let i=r;a?i+=` - The request was made and the server responded with ${JSON.stringify({status:a.status,data:a.data})}`:n&&(i+=" - The request was made but no response was received"),console.warn(i),await(0,e.reportError)(new Error(i))}catch(t){console.warn(`Cannot handle error: ${t.message}`)}},{APIS:{ASSETS_API:{BASE_URL:d,ENDPOINTS:{USERS:l,CERTIFICATES:p}}}}=o;var f={certificates:{create:async(t,e)=>{let r=[];try{const{data:a}=await i().post(`${d}${l}/${t}${p}`,e);a&&a.length&&(r=a)}catch(t){await s(t)}return r}}};const{APIS:{MANAGEMENT_API:{BASE_URL:S,ENDPOINTS:{ACCOUNTS:E}}}}=o;var g={accounts:{create:async t=>{try{await i().post(`${S}${E}`,t)}catch(t){throw await s(t),t}},read:async t=>{let e=null;try{({data:e}=await i().get(`${S}${E}/${encodeURIComponent(t)}`))}catch(t){await s(t)}return e},update:async(t,e)=>{try{await i().put(`${S}${E}/${encodeURIComponent(t)}`,e)}catch(t){throw await s(t),t}}}};const{APIS:{PEOPLE_API:{BASE_URL:m,ENDPOINTS:{REGISTRATIONS:y}}}}=o;var w={list:async t=>{let e=[];try{const{data:r}=await i().get(`${m}${y}`,{params:t});r&&r.length&&(e=r)}catch(t){await s(t)}return e}},h=c(25);const{OK:P,MULTIPLE_CHOICES:_,NOT_FOUND:v,FORBIDDEN:L}=h.StatusCodes,I=t=>t>=P&&t<_||t===L||t===v,{APIS:{PEOPLE_API:{BASE_URL:T,ENDPOINTS:{USERS:A}}}}=o;var N={read:async t=>{let e=null;try{const{data:r}=await i().get(`${T}${A}/${encodeURIComponent(t)}`,{validateStatus:I});r&&r.slug&&(e=r)}catch(t){await s(t)}return e}};const{APIS:{PEOPLE_API:{BASE_URL:O,ENDPOINTS:{USERS:R,USER_COURSES:b}}},USERS:{MYSELF_SLUG:U}}=o,x=`${O}${R}/${U}${b}`;var $={create:async t=>{try{await i().post(x,t)}catch(t){await s(t)}},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await i().get(x,r);t&&t.length&&(e=t)}catch(t){await s(t)}return e},update:async(t,e)=>{try{await i().put(`${x}/${t}`,e)}catch(t){await s(t)}}};const{APIS:{PEOPLE_API:{BASE_URL:C,ENDPOINTS:{USERS:M,USER_LESSONS:B}}},USERS:{MYSELF_SLUG:j}}=o,D=`${C}${M}/${j}${B}`;var q={registrations:w,users:N,userCourses:$,userLessons:{create:async t=>{try{await i().post(D,t)}catch(t){await s(t)}},list:async t=>{let e=[],r=t?{params:t}:{params:{}};try{const{data:t}=await i().get(D,r);t&&t.length&&(e=t)}catch(t){await s(t)}return e}}};const{APIS:{PEOPLE_ENGAGEMENT_API:{BASE_URL:G,ENDPOINTS:{USERS:F,USER_PROPERTIES:V}}},USERS:{MYSELF_SLUG:k}}=o;var H={userProperties:{update:async(t,e)=>{try{await i().put(`${G}${F}/${k}${V}/${t}`,e)}catch(t){await s(t)}}}},Y=c(408);const J=t=>t&&Y.Buffer.from(t,"base64").toString("ascii");function K({authContext:n=null,contentContext:i=null,errorsContext:o=null,gtmContext:s=null,origin:c}){n&&(0,r.setContext)(Object.assign({},n,{origin:c})),i&&(0,t.setContext)(Object.assign({},i,{origin:c})),o&&(0,e.setContext)(Object.assign({},o,{origin:c})),s&&(0,a.setContext)(Object.assign({},s,{origin:c}))}}(),u}()}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apolitical/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-rc.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",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@apolitical/auth": "0.0.2",
|
|
29
29
|
"@apolitical/content": "0.3.0",
|
|
30
30
|
"@apolitical/error-reporting": "0.1.0",
|
|
31
|
-
"@apolitical/gtm": "1.0.
|
|
31
|
+
"@apolitical/gtm": "1.0.1-rc.2",
|
|
32
32
|
"axios": "0.26.0",
|
|
33
33
|
"buffer": "6.0.3",
|
|
34
34
|
"http-status-codes": "2.2.0"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@apolitical/auth": "0.0.2",
|
|
38
38
|
"@apolitical/content": "0.3.0",
|
|
39
39
|
"@apolitical/error-reporting": "0.1.0",
|
|
40
|
-
"@apolitical/gtm": "1.0.
|
|
40
|
+
"@apolitical/gtm": "1.0.1-rc.2",
|
|
41
41
|
"axios": "0.26.0",
|
|
42
42
|
"buffer": "6.0.3",
|
|
43
43
|
"http-status-codes": "2.2.0"
|