@qikdev/sdk 0.1.0 → 0.1.4

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/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("axios"),require("lodash"),require("axios-extensions")):"function"==typeof define&&define.amd?define(["axios","lodash","axios-extensions"],r):"object"==typeof exports?exports["@qikdev/sdk"]=r(require("axios"),require("lodash"),require("axios-extensions")):e["@qikdev/sdk"]=r(e.axios,e._,e["axios-extensions"])}("undefined"!=typeof self?self:this,(function(e,r,t){return(()=>{"use strict";var n={818:(e,r)=>{var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};"undefined"!=typeof window&&window.document,"object"===("undefined"==typeof self?"undefined":t(self))&&self.constructor&&self.constructor.name,"undefined"!=typeof process&&null!=process.versions&&process.versions.node},798:e=>{var r=String.prototype.replace,t=/%20/g;e.exports={default:"RFC3986",formatters:{RFC1738:function(e){return r.call(e,t,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},129:(e,r,t)=>{var n=t(261),o=t(235),i=t(798);e.exports={formats:i,parse:o,stringify:n}},235:(e,r,t)=>{var n=t(769),o=Object.prototype.hasOwnProperty,i={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:n.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},a=function(e,r,t){if(e){var n=t.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=/(\[[^[\]]*])/.exec(n),s=a?n.slice(0,a.index):n,u=[];if(s){if(!t.plainObjects&&o.call(Object.prototype,s)&&!t.allowPrototypes)return;u.push(s)}for(var c=0;null!==(a=i.exec(n))&&c<t.depth;){if(c+=1,!t.plainObjects&&o.call(Object.prototype,a[1].slice(1,-1))&&!t.allowPrototypes)return;u.push(a[1])}return a&&u.push("["+n.slice(a.index)+"]"),function(e,r,t){for(var n=r,o=e.length-1;o>=0;--o){var i,a=e[o];if("[]"===a&&t.parseArrays)i=[].concat(n);else{i=t.plainObjects?Object.create(null):{};var s="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,u=parseInt(s,10);t.parseArrays||""!==s?!isNaN(u)&&a!==s&&String(u)===s&&u>=0&&t.parseArrays&&u<=t.arrayLimit?(i=[])[u]=n:"__proto__"!==s&&(i[s]=n):i={0:n}}n=i}return n}(u,r,t)}};e.exports=function(e,r){var t=r?n.assign({},r):{};if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");if(t.ignoreQueryPrefix=!0===t.ignoreQueryPrefix,t.delimiter="string"==typeof t.delimiter||n.isRegExp(t.delimiter)?t.delimiter:i.delimiter,t.depth="number"==typeof t.depth?t.depth:i.depth,t.arrayLimit="number"==typeof t.arrayLimit?t.arrayLimit:i.arrayLimit,t.parseArrays=!1!==t.parseArrays,t.decoder="function"==typeof t.decoder?t.decoder:i.decoder,t.allowDots="boolean"==typeof t.allowDots?t.allowDots:i.allowDots,t.plainObjects="boolean"==typeof t.plainObjects?t.plainObjects:i.plainObjects,t.allowPrototypes="boolean"==typeof t.allowPrototypes?t.allowPrototypes:i.allowPrototypes,t.parameterLimit="number"==typeof t.parameterLimit?t.parameterLimit:i.parameterLimit,t.strictNullHandling="boolean"==typeof t.strictNullHandling?t.strictNullHandling:i.strictNullHandling,""===e||null==e)return t.plainObjects?Object.create(null):{};for(var s="string"==typeof e?function(e,r){for(var t={},n=r.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=r.parameterLimit===1/0?void 0:r.parameterLimit,s=n.split(r.delimiter,a),u=0;u<s.length;++u){var c,l,f=s[u],p=f.indexOf("]="),d=-1===p?f.indexOf("="):p+1;-1===d?(c=r.decoder(f,i.decoder),l=r.strictNullHandling?null:""):(c=r.decoder(f.slice(0,d),i.decoder),l=r.decoder(f.slice(d+1),i.decoder)),o.call(t,c)?t[c]=[].concat(t[c]).concat(l):t[c]=l}return t}(e,t):e,u=t.plainObjects?Object.create(null):{},c=Object.keys(s),l=0;l<c.length;++l){var f=c[l],p=a(f,s[f],t);u=n.merge(u,p,t)}return n.compact(u)}},261:(e,r,t)=>{var n=t(769),o=t(798),i={brackets:function(e){return e+"[]"},indices:function(e,r){return e+"["+r+"]"},repeat:function(e){return e}},a=Array.isArray,s=Array.prototype.push,u=function(e,r){s.apply(e,a(r)?r:[r])},c=Date.prototype.toISOString,l={delimiter:"&",encode:!0,encoder:n.encode,encodeValuesOnly:!1,serializeDate:function(e){return c.call(e)},skipNulls:!1,strictNullHandling:!1},f=function e(r,t,o,i,s,c,f,p,d,h,g,y){var m=r;if("function"==typeof f?m=f(t,m):m instanceof Date&&(m=h(m)),null===m){if(i)return c&&!y?c(t,l.encoder):t;m=""}if("string"==typeof m||"number"==typeof m||"boolean"==typeof m||n.isBuffer(m))return c?[g(y?t:c(t,l.encoder))+"="+g(c(m,l.encoder))]:[g(t)+"="+g(String(m))];var v,b=[];if(void 0===m)return b;if(a(f))v=f;else{var w=Object.keys(m);v=p?w.sort(p):w}for(var k=0;k<v.length;++k){var j=v[k];s&&null===m[j]||(a(m)?u(b,e(m[j],o(t,j),o,i,s,c,f,p,d,h,g,y)):u(b,e(m[j],t+(d?"."+j:"["+j+"]"),o,i,s,c,f,p,d,h,g,y)))}return b};e.exports=function(e,r){var t=e,s=r?n.assign({},r):{};if(null!==s.encoder&&void 0!==s.encoder&&"function"!=typeof s.encoder)throw new TypeError("Encoder has to be a function.");var c=void 0===s.delimiter?l.delimiter:s.delimiter,p="boolean"==typeof s.strictNullHandling?s.strictNullHandling:l.strictNullHandling,d="boolean"==typeof s.skipNulls?s.skipNulls:l.skipNulls,h="boolean"==typeof s.encode?s.encode:l.encode,g="function"==typeof s.encoder?s.encoder:l.encoder,y="function"==typeof s.sort?s.sort:null,m=void 0!==s.allowDots&&s.allowDots,v="function"==typeof s.serializeDate?s.serializeDate:l.serializeDate,b="boolean"==typeof s.encodeValuesOnly?s.encodeValuesOnly:l.encodeValuesOnly;if(void 0===s.format)s.format=o.default;else if(!Object.prototype.hasOwnProperty.call(o.formatters,s.format))throw new TypeError("Unknown format option provided.");var w,k,j=o.formatters[s.format];"function"==typeof s.filter?t=(k=s.filter)("",t):a(s.filter)&&(w=k=s.filter);var A,O=[];if("object"!=typeof t||null===t)return"";A=s.arrayFormat in i?s.arrayFormat:"indices"in s?s.indices?"indices":"repeat":"indices";var R=i[A];w||(w=Object.keys(t)),y&&w.sort(y);for(var q=0;q<w.length;++q){var x=w[q];d&&null===t[x]||u(O,f(t[x],x,R,p,d,h?g:null,k,y,m,v,j,b))}var S=O.join(c),P=!0===s.addQueryPrefix?"?":"";return S.length>0?P+S:""}},769:e=>{var r=Object.prototype.hasOwnProperty,t=function(){for(var e=[],r=0;r<256;++r)e.push("%"+((r<16?"0":"")+r.toString(16)).toUpperCase());return e}(),n=function(e,r){for(var t=r&&r.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(t[n]=e[n]);return t};e.exports={arrayToObject:n,assign:function(e,r){return Object.keys(r).reduce((function(e,t){return e[t]=r[t],e}),e)},compact:function(e){for(var r=[{obj:{o:e},prop:"o"}],t=[],n=0;n<r.length;++n)for(var o=r[n],i=o.obj[o.prop],a=Object.keys(i),s=0;s<a.length;++s){var u=a[s],c=i[u];"object"==typeof c&&null!==c&&-1===t.indexOf(c)&&(r.push({obj:i,prop:u}),t.push(c))}return function(e){for(var r;e.length;){var t=e.pop();if(r=t.obj[t.prop],Array.isArray(r)){for(var n=[],o=0;o<r.length;++o)void 0!==r[o]&&n.push(r[o]);t.obj[t.prop]=n}}return r}(r)},decode:function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(r){return e}},encode:function(e){if(0===e.length)return e;for(var r="string"==typeof e?e:String(e),n="",o=0;o<r.length;++o){var i=r.charCodeAt(o);45===i||46===i||95===i||126===i||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122?n+=r.charAt(o):i<128?n+=t[i]:i<2048?n+=t[192|i>>6]+t[128|63&i]:i<55296||i>=57344?n+=t[224|i>>12]+t[128|i>>6&63]+t[128|63&i]:(o+=1,i=65536+((1023&i)<<10|1023&r.charCodeAt(o)),n+=t[240|i>>18]+t[128|i>>12&63]+t[128|i>>6&63]+t[128|63&i])}return n},isBuffer:function(e){return null!=e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},merge:function e(t,o,i){if(!o)return t;if("object"!=typeof o){if(Array.isArray(t))t.push(o);else{if(!t||"object"!=typeof t)return[t,o];(i&&(i.plainObjects||i.allowPrototypes)||!r.call(Object.prototype,o))&&(t[o]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(o);var a=t;return Array.isArray(t)&&!Array.isArray(o)&&(a=n(t,i)),Array.isArray(t)&&Array.isArray(o)?(o.forEach((function(n,o){if(r.call(t,o)){var a=t[o];a&&"object"==typeof a&&n&&"object"==typeof n?t[o]=e(a,n,i):t.push(n)}else t[o]=n})),t):Object.keys(o).reduce((function(t,n){var a=o[n];return r.call(t,n)?t[n]=e(t[n],a,i):t[n]=a,t}),a)}}},103:r=>{r.exports=e},757:e=>{e.exports=t},607:e=>{e.exports=r}},o={};function i(e){var r=o[e];if(void 0!==r)return r.exports;var t=o[e]={exports:{}};return n[e](t,t.exports,i),t.exports}i.d=(e,r)=>{for(var t in r)i.o(r,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{i.r(a),i.d(a,{default:()=>g});var e=i(103),r=i(607),t=i(129);var n=i(757);const o=e.CancelToken,s=function(n){var i;process.browser&&(i=n.cache.get("api"));const a=e.defaults.adapter,s=(u=function(r){return new Promise((function(t,n){var o,s;switch(String(r.method).toLowerCase()){case"post":case"patch":case"put":case"delete":r.cache||(r.cache=!1)}if(!1===r.cache);else if(o=r.cache||i){var u=getCacheKeyFromConfig(r);s=o.get(u)}return s?t(s):(Object.assign(r,{adapter:a}),e.request(r).then((function(e){t(e)}),(function(e){n(e)})))}))},(c=e.create({paramsSerializer:e=>t.stringify(e,{arrayFormat:"repeat"}),adapter:u})).defaults.baseURL=n.apiURL,c.defaults.headers.common.Accept="application/json",c.interceptors.request.use((function(e){return e.headers["qik-request-date"]=(new Date).getTime(),Intl&&(e.headers["qik-request-timezone"]=Intl.DateTimeFormat().resolvedOptions().timeZone),e.headers["qik-api-version"]="0.1.0",e})),c.interceptors.response.use((function(e){return e.config,e}),(function(t){if(e.isCancel(t))return console.log("Request cancelled"),Promise.reject(t);var n=r.get(t,"response.status")||t.status;switch(n){case 401:case 404:break;case 502:case 504:return console.log(`qik.api > ${n} connection error retrying`),c.request(t.config);default:console.log("qik.api > connection error",n,t)}return Promise.reject(t)})),c);var u,c;return s.generateEndpointURL=function(e,r){if(e&&String(e).length){r||(r={});var t=`${n.apiURL}${e}`;t=function(e,r){if(!r.withoutToken){var t=n.auth.getCurrentToken();!r.access_token&&t&&(r.access_token=t)}return e}(t,r);var o=n.utils.mapParameters(r);return o.length&&(t+="?"+o),t}},s.CancelToken=o,s.axios=e,s};i(818);var u={mapParameters:function(e){return r.chain(e).reduce((function(e,t,n){return null==t||!1===t||(r.isArray(t)?r.each(t,(function(r){e.push(`${n}=${encodeURIComponent(r)}`)})):e.push(encodeURIComponent(n)+"="+encodeURIComponent(t))),e}),[]).compact().value().join("&")},formatCurrency:function(e,r){return e&&!isNaN(e)||(e=0),`${u.currencySymbol(r)}${parseFloat(parseInt(e)/100).toFixed(2)}`},currencySymbol:function(e){switch(e=String(e).toLowerCase(),String(e).toLowerCase()){case"gbp":return"£";case"eur":return"€";default:return"$"}},getAvailableCurrencies:function(e){var r=[];if(r.push({name:`USD (${u.currencySymbol("usd")})`,value:"usd",countryCode:{US:!0}}),r.push({name:`GBP (${u.currencySymbol("gbp")})`,value:"gbp",countryCode:{GB:!0,UK:!0}}),r.push({name:`CAD (${u.currencySymbol("cad")})`,value:"cad",countryCode:{CA:!0}}),r.push({name:`AUD (${u.currencySymbol("aud")})`,value:"aud",countryCode:{AU:!0}}),r.push({name:`NZD (${u.currencySymbol("nzd")})`,value:"nzd",countryCode:{NZ:!0}}),r.push({name:`SGD (${u.currencySymbol("sgd")})`,value:"sgd",countryCode:{SG:!0}}),e){var t=r.findIndex((function(r){return r.countryCode[e]}));const n=(e,r,t)=>{const n=[...e];return n.splice(t,0,...n.splice(r,1)),n};-1!=t&&(r=n(r,t,0))}return r},hash:function(e,t){return Array.isArray(e)||(e=[]),e.reduce((function(e,t){var n=r.get(t,n);return e[n]=t,e}),{})},guid:function(){var e=(new Date).getTime().toString(16)+Math.random().toString(16).substring(2)+"0".repeat(16);return e.substr(0,8)+"-"+e.substr(8,4)+"-4000-8"+e.substr(12,3)+"-"+e.substr(15,12)},extractFromArray:function(e,t,n,o,i,a,s){s||(s={}),n&&(s.sum=n),o&&(s.flatten=!0),i&&(s.unique=!0),a&&(s.excludeNull=!0);var u=r.reduce(e,(function(e,n){var o=r.get(n,t),i=!o&&!1!==o&&0!==o;return s.excludeNull&&i||e.push(o),e}),[]);return s.flatten&&(u=r.flatten(u)),s.unique&&(u=r.uniq(u)),s.sum&&(u=u.reduce((function(e,r){return e+r}),0)),u},matchInArray:function(e,t,n,o){return r.filter(e,(function(e){var i,a=r.get(e,t);switch(o){case">":i=a>n;break;case"<":i=a<n;break;case">=":i=a>=n;break;case"<=":i=a<=n;break;case"in":i=r.includes(a,n);break;default:i=void 0===n?a:a==n}return i}))},comma:function(e,t,n){return n&&(e=e.slice(0,n)),r.chain(e).compact().map((function(e){return t&&t.length?r.get(e,t):e})).value().join(", ")},id:function(e){var r;if(e&&(r=e._id?String(e._id):String(e),service.isValidID(r)))return r},ids:function(e){return r.chain(e).reduce((function(e,r){if(!r)return e;var t=service.id(r);return t&&(e[t]=1),e}),{}).keys().value()},isValidID:function(e){return new RegExp("^[0-9a-fA-F]{24}$").test(String(e))},errorMessage:function(e){r.isArray(e)&&(e=r.first(e));var t=r.chain(["response.data.message","response.data","message"]).map((function(t){return r.get(e,t)})).compact().first().value();return Array.isArray(t)&&(t=t[0]),t&&t.length?t:String(e)},machineName:function(e){if(e&&e.length)return e.replace(/[^a-zA-Z0-9-_]+/g,"")}};const c=u;function l(){var e={},r={removeAllListeners:function(){e={}},dispatch:function(r,t){e[r]&&e[r].forEach((function(e){return e(t)}))},addEventListener:function(r,t){e[r]||(e[r]=[]),-1==e[r].indexOf(t)&&e[r].push(t)},removeEventListener:function(r,t){e[r]||(e[r]=[]);var n=e[r].indexOf(t);-1!=n&&e[r].splice(n,1)},bootstrap:function(e){e&&(e.dispatch=r.dispatch,e.addEventListener=r.addEventListener,e.removeEventListener=r.removeEventListener,e.removeAllListeners=r.removeAllListeners)}};return r}const f=function(e){if(!e.api)throw new Error("Can't Instantiate QikAuth before QikAPI exists");var t={},n={debug:!1};Object.defineProperty(n,"store",{value:t,writable:!1});var o=new l;function i(e){var r=t.user;n.onChange&&n.onChange(r),o.dispatch("change",r,e)}function a(e){n.debug&&console.log(e)}o.bootstrap(n),n.set=function(e,r,n){return t.user=e,a("qik.auth > user set"),i(r)},n.logout=function(){return delete t.user,e.cache.reset(),a("qik.auth > user logout"),e.withCredentials&&(window.location.href="/qik/logout"),i()},n.changeOrganisation=function(r,t){r=e.utils.getStringID(r),t||(t={});var o=!0;t.disableAutoAuthentication&&(o=!1);var i=e.api.post(`/user/switch/${r}`);return i.then((function(r){o&&(e.cache.reset(),n.set(r.data))}),(function(e){})),i},n.impersonate=function(r,t){r=e.utils.getStringID(r),t||(t={});var o=!0;t.disableAutoAuthentication&&(o=!1);var i=e.api.post(`/user/impersonate/${r}`);return i.then((function(r){o&&(e.cache.reset(),n.set(r.data))}),(function(e){})),i},n.login=function(r,n){n||(n={});var o=!0;return n.disableAutoAuthentication&&(o=!1),new Promise((function(a,s){if(!r)return s({message:"Missing credentials!"});if(!r.email||!r.email.length)return s({message:"Username was not provided"});if(!r.password||!r.password.length)return s({message:"Password was not provided"});var u=`${e.apiURL}/user/login`;n.url&&(u=n.url),e.api.post(u,r,{bypassInterceptor:!0}).then((function(e){o&&(t.user=e.data,i()),a(e)}),s)}))},n.signup=function(r,n){n||(n={});var o=!0;return n.disableAutoAuthentication&&(o=!1),new Promise((function(a,s){if(!r)return s({message:"No details provided"});if(!r.firstName||!r.firstName.length)return s({message:"First Name was not provided"});if(!r.lastName||!r.lastName.length)return s({message:"Last Name was not provided"});if(!r.email||!r.email.length)return s({message:"Email/Username was not provided"});if(!r.password||!r.password.length)return s({message:"Password was not provided"});if(!r.confirmPassword||!r.confirmPassword.length)return s({message:"Confirm Password was not provided"});if(r.confirmPassword!=r.password)return s({message:"Your passwords do not match"});var u=`${e.apiURL}/user/signup`;n.application&&(u=`${e.domain||""}/qik/application/signup`),n.url&&(u=n.url),e.api.post(u,r,{bypassInterceptor:!0}).then((function(e){o&&(t.user=e.data,i()),a(e)}),s)}))},n.retrieveUserFromResetToken=function(r,t){return t||(t={}),new Promise((function(n,o){var i=`${e.apiURL}/user/reset/${r}`;t.url&&(i=t.url),e.api.get(i,{bypassInterceptor:!0}).then((function(e){return n(e.data)}),o)}))},n.updateUserWithToken=function(r,t,o){o||(o={});var i=!0;return o.disableAutoAuthentication&&(i=!1),new Promise((function(a,s){var u=`${e.apiURL}/user/reset/${r}`;o.url&&(u=o.url),e.api.post(u,t,{bypassInterceptor:!0}).then((function(r){return i&&(e.cache.reset(),n.set(r.data)),a(r.data)}),s)}))},n.sendResetPasswordRequest=function(r,t){return t||(t={}),new Promise((function(n,o){if(!r)return o({message:"No details provided"});if(!r.email||!r.email.length)return o({message:"Email was not provided"});r.email=r.email;var i=`${e.apiURL}/user/forgot`;t.url&&(i=t.url),e.api.post(i,r,{bypassInterceptor:!0}).then(n,o)}))};const s={};return n.refreshAccessToken=function(r){return s.inflightRefreshRequest?(a("qik.auth > use inflight request"),s.inflightRefreshRequest):(a("qik.auth > refresh token new request"),s.inflightRefreshRequest=new Promise((function(n,o){a(`qik.auth > refresh token ${r}`),e.api.post("/user/refresh",{refreshToken:r},{bypassInterceptor:!0}).then((function(e){if(!e)return a("qik.auth > no res"),s.inflightRefreshRequest=null,o();t.user?Object.assign(t.user,e.data):t.user=e.data,a(`qik.auth > token refreshed > ${e.data}`),i(),n(e.data.token),setTimeout((function(){s.inflightRefreshRequest=null}))})).catch((function(e){console.log("TOKEN REFRESH FAILED",e),setTimeout((function(){s.inflightRefreshRequest=null})),o(e)}))})),s.inflightRefreshRequest)},n.sync=function(){return e.api.get("/user").then((function(e){e.data?t.user&&Object.assign(t.user,e.data):t.user=null,a("qik.auth > server session refreshed"),i()})).catch((function(e){console.log("auth sync not logged in"),t.user=null,i()}))},n.getCurrentUser=function(){return t.user},n.getCurrentToken=function(){return n.getCurrentUser().accessToken},e.api.interceptors.request.use((function(e){if(e.bypassInterceptor)return console.log("auth interceptor was bypassed"),e;var o=e,i=r.get(t,"user.accessToken"),s=r.get(t,"user.refreshToken");if(!i)return a("qik.auth > no token"),o;if(o.headers.Authorization=`Bearer ${i}`,a("qik.auth > using user token"),!s)return a("qik.auth > no refresh token"),o;var u=new Date;u.setSeconds(u.getSeconds()+10);var c=r.get(t,"user.expires");return u<new Date(c)?o:(a("qik.auth > token expired"),new Promise((function(e,r){n.refreshAccessToken(s).then((function(r){return a("qik.auth > token refreshed",isManagedUser),o.headers.Authorization=`Bearer ${r}`,e(o)})).catch((function(e){return console.log("ERRRRRR",e),a("qik.auth > token refresh rejected"),r(e)}))})))}),(function(e){return Promise.reject(e)})),e.api.interceptors.response.use((function(e){return e}),(function(e){var t=r.get(e,"response.status")||e.status;return a("qik.auth > error"),401===t&&(console.log("logout from 401"),n.logout()),Promise.reject(e)})),n};var p={};const d={reset(){r.each(p,(function(e,r){e.reset()}))},get:(e,r)=>(p[e]||(p[e]=new n.Cache(r)),p[e])},h=function(e){if(!e.auth)throw new Error("Can't Instantiate QikAccess before QikAccess has been initialized");var t={};return(new l).bootstrap(t),t.has=function(e,n){var o=t.retrieveCurrentSession(n);if(!o)return!1;if(t.isQikAdmin()&&!n)return!0;var i=o.permissionSets,a=r.chain(i).reduce((function(e,r,t){return e.push(r.permissions),e}),[]).flattenDeep().compact().uniq().value();return r.includes(a,e)},t};console.log("qik 0.1.0");const g=function(e){switch(e||(e={}),e.apiURL&&e.apiURL.length||(e.apiURL="staging"),String(e.apiURL).toLowerCase()){case"production":e.apiURL="https://api.qik.dev";break;case"staging":e.apiURL="https://api.staging.qik.dev";break;case"local":e.apiURL="http://localhost:4001"}var r=Object.assign(e,{version:"0.1.0"}),t=d;Object.defineProperty(r,"cache",{value:t,writable:!1});var n=c;Object.defineProperty(r,"utils",{value:n,writable:!1}),(new l).bootstrap(r),r.error=function(e){return r.dispatch("error",n.errorMessage(e))},r.notify=function(e,t){return r.dispatch("notification",{message:e,options:t})};var o=new s(r);Object.defineProperty(r,"api",{value:o,writable:!1});var i=new f(r);Object.defineProperty(r,"auth",{value:i,writable:!1});var a=new h(r);return Object.defineProperty(r,"access",{value:a,writable:!1}),r}})(),a})()}));
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Lodash <https://lodash.com/>
4
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
5
+ * Released under MIT license <https://lodash.com/license>
6
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qikdev/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "description": "Promise based Javascript SDK",
6
6
  "scripts": {
@@ -13,11 +13,11 @@
13
13
  "main": "dist/index.js",
14
14
  "homepage": "https://qik.dev",
15
15
  "bugs": {
16
- "url":"https://support.qik.dev"
16
+ "url": "https://support.qik.dev"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "https://gitlab.com/qikdevelopers/sdk.git"
20
+ "url": "git+https://gitlab.com/qikdevelopers/sdk.git"
21
21
  },
22
22
  "keywords": [
23
23
  "qik",
@@ -34,13 +34,15 @@
34
34
  "jsdoc": "^3.6.3",
35
35
  "jsdom": "^14.1.0",
36
36
  "mocha": "^9.2.0",
37
- "webpack": "^4.41.5",
38
- "webpack-cli": "^3.3.11"
37
+ "webpack": "^5.68.0",
38
+ "webpack-cli": "^4.9.2"
39
39
  },
40
40
  "dependencies": {
41
41
  "axios": "^0.19.2",
42
42
  "axios-extensions": "^3.1.2",
43
- "browser-or-node": "^1.2.1",
44
43
  "lodash": "^4.17.15"
44
+ },
45
+ "directories": {
46
+ "test": "test"
45
47
  }
46
48
  }
@@ -1,6 +1,8 @@
1
1
  import axios from 'axios';
2
2
  import _ from 'lodash';
3
3
  import qs from 'qs';
4
+ import { version } from '../version.js';
5
+
4
6
 
5
7
 
6
8
 
@@ -164,11 +166,11 @@ var QikAPI = function(qik) {
164
166
  instance.interceptors.request.use(function(config) {
165
167
 
166
168
  config.headers['qik-request-date'] = new Date().getTime();
167
- if (qik.date.defaultTimezone) {
169
+ if (Intl) {
168
170
  config.headers['qik-request-timezone'] = Intl.DateTimeFormat().resolvedOptions().timeZone;
169
171
  }
170
172
 
171
- config.headers['qik-api-version'] = qik.version;
173
+ config.headers['qik-api-version'] = version;
172
174
 
173
175
  return config;
174
176
 
@@ -327,7 +329,7 @@ var QikAPI = function(qik) {
327
329
  var url = `${qik.apiURL}${path}`;
328
330
 
329
331
  ////////////////////////////////////////
330
-
332
+
331
333
  url = parameterDefaults(url, params);
332
334
 
333
335
  ////////////////////////////////////////
@@ -19,7 +19,7 @@ import { EventDispatcher } from './qik.utils.js';
19
19
  * @example
20
20
  *
21
21
  * //Import the Qik package
22
- * import Qik from 'qik';
22
+ * import Qik from '@qikdev/sdk';
23
23
  *
24
24
  * //Create a new Qik instance
25
25
  * var qik = new Qik();
@@ -70,6 +70,7 @@ var QikCore = function(options) {
70
70
  var core = Object.assign(options, {
71
71
  //Other options
72
72
  // domain:'',
73
+ version:'0.1.0',
73
74
  })
74
75
 
75
76
 
@@ -170,4 +171,4 @@ var QikCore = function(options) {
170
171
  ///////////////////////////////////////
171
172
  ///////////////////////////////////////
172
173
 
173
- export default QikCore;
174
+ QikCore;
package/src/index.js CHANGED
@@ -1,12 +1,15 @@
1
1
 
2
2
 
3
- var versionName = `qik 0.1.0`;
4
- console.log(versionName)
3
+
5
4
 
6
5
  ////////////////////////////////////////////
7
6
 
8
7
  //Import the pieces we need
9
8
  import QikCore from './api/qik.core.js';
9
+ import {version} from './version.js';
10
+
11
+ var versionName = `qik ${version}`;
12
+ console.log(versionName)
10
13
 
11
14
  ////////////////////////////////////////////
12
15
 
package/src/version.js ADDED
@@ -0,0 +1 @@
1
+ export const version = '0.1.0'
@@ -6,6 +6,8 @@ import Qik from '../src/index.js';
6
6
 
7
7
  var qik = new Qik();
8
8
 
9
+ var {data} = await qik.api.get(`/version`);
10
+
9
11
 
10
12
  // chai.expect();
11
13
 
package/webpack.config.js CHANGED
@@ -1,47 +1,24 @@
1
- const path = require('path');
2
- const webpack = require('webpack');
3
- // var JsDocPlugin = require('jsdoc-webpack-plugin-v2');
1
+ import * as path from 'path';
2
+ import {fileURLToPath} from 'url';
3
+ const __filename = fileURLToPath(import.meta.url);
4
+ const __dirname = path.dirname(__filename);
4
5
 
5
- module.exports = {
6
+ export default {
6
7
  entry: './src/index.js',
7
8
  output: {
8
9
  filename: 'index.js',
9
- library: 'qik',
10
- libraryTarget: 'umd',
11
- libraryExport: 'default',
10
+ library: {
11
+ name:'@qikdev/sdk',
12
+ type:'umd',
13
+ },
12
14
  path: path.resolve(__dirname, 'dist'),
13
15
  globalObject: 'typeof self !== \'undefined\' ? self : this',
14
16
  },
15
-
16
-
17
- // module.exports = () => {
18
- // return {
19
- // output: {
20
- // path: path.resolve(__dirname, 'build'),
21
- // filename: 'app.js',
22
- // },
23
- // entry: './src/index.js',
24
- plugins: [
25
- new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
26
- ],
27
- // };
28
- // };
29
-
30
-
31
-
32
- // plugins: [
33
- // new JsDocPlugin(
34
- // // {
35
- // // conf:path.join(__dirname, 'jsdoc.json'),
36
- // // }
37
- // )
38
- // ],
39
17
  optimization: {
40
18
  // splitChunks: {
41
19
  // chunks: 'all'
42
20
  // }
43
21
  },
44
-
45
22
  externals: {
46
23
  'axios': {
47
24
  commonjs: 'axios',
@@ -49,6 +26,12 @@ module.exports = {
49
26
  amd: 'axios',
50
27
  root: 'axios'
51
28
  },
29
+ 'lodash': {
30
+ commonjs: 'lodash',
31
+ commonjs2: 'lodash',
32
+ amd: 'lodash',
33
+ root: '_'
34
+ },
52
35
  'axios-extensions': {
53
36
  commonjs: 'axios-extensions',
54
37
  commonjs2: 'axios-extensions',