From 75ea4d33fae3f90736e8dc7e182a07386466b36a Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Mon, 21 Feb 2022 18:21:49 +0800 Subject: [PATCH] v1.2.2 --- dist/@fleetbase/sdk.min.js | 2 +- dist/@fleetbase/sdk.min.js.map | 2 +- dist/cjs/fleetbase.js | 2 +- dist/cjs/fleetbase.js.map | 2 +- dist/esm/fleetbase.js | 2 +- dist/esm/fleetbase.js.map | 2 +- package.json | 2 +- src/fleetbase.js | 3 +- src/resolver.js | 30 +++++---- src/resource.js | 13 +++- src/resources/driver.js | 43 +++++++++++++ src/resources/order.js | 107 +++++++++++++++++++++++++++++++-- src/utils/index.js | 4 ++ src/utils/is-email.js | 5 ++ src/utils/is-phone.js | 5 ++ 15 files changed, 198 insertions(+), 26 deletions(-) create mode 100644 src/utils/is-email.js create mode 100644 src/utils/is-phone.js diff --git a/dist/@fleetbase/sdk.min.js b/dist/@fleetbase/sdk.min.js index b54574c..d18882f 100644 --- a/dist/@fleetbase/sdk.min.js +++ b/dist/@fleetbase/sdk.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@fleetbase/sdk"]={},t.axios)}(this,(function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=n(e);function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function o(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n3&&void 0!==arguments[3]?arguments[3]:[];if(L(t))if(r.length<=C)t.splice.apply(t,[e,n].concat(R(r)));else{t.splice(e,n);for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:T,n=[],r=new Set,i="function"==typeof e?e:function(t){return get(t,e)};return t.forEach((function(t){var e=i(t);r.has(e)||(r.add(e),n.push(t))})),n},q=function(t){return t instanceof V},B=function(t,e){return L(t)?t[e]:q(t)?t.objectAt(e):null},U=function(t,e){return 2===F.length?function(n){return e===n[t]}:function(e){return Boolean(e[t])}},I=function(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=t.length,i=n;i2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0,i=t.length;n<0&&(n+=i);var o=r&&e!=e?function(t){return t!=t}:function(t){return t===e};return I(t,o,n)},G=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return D(t,e,n,[]),t},H=function(t,e,n){return D(t,e,0,[n]),n},V=function(t){f(n,t);var e=A(n);function n(){for(var t=arguments.length,r=new Array(t),i=0;i0}},{key:"empty",get:function(){return 0===this.length}},{key:"first",get:function(){return B(this,0)}},{key:"last",get:function(){return B(this,this.length-1)}},{key:"replace",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return D(this,t,e,n),this}},{key:"objectsAt",value:function(t){var e=this;return t.map((function(t){return B(e,t)}))}},{key:"objectAt",value:function(t){return B(this,t)}},{key:"indexOf",value:function(t,e){return M(this,t,e,!1)}},{key:"lastIndexOf",value:function(t,e){var n=this.length;(void 0===e||e>=n)&&(e=n-1),e<0&&(e+=n);for(var r=e;r>=0;r--)if(B(this,r)===t)return r;return-1}},{key:"includes",value:function(t,e){return-1!==M(this,t,e,!0)}},{key:"findBy",value:function(){return J(this,U.apply(void 0,arguments))}},{key:"findIndexBy",value:function(){return I(this,U.apply(void 0,arguments))}},{key:"isEvery",value:function(){return K(this,U.apply(void 0,arguments))}},{key:"isAny",value:function(){return W(this,U.apply(void 0,arguments))}},{key:"invoke",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r=0;){B(this,e)===t&&this.removeAt(e)}return this}},{key:"removeObjects",value:function(t){for(var e=t.length-1;e>=0;e--)this.removeObject(t[e]);return this}},{key:"addObject",value:function(t){return this.includes(t)||this.pushObject(t),this}},{key:"addObjects",value:function(t){var e=this;return t.forEach((function(t){return e.addObject(t)})),this}}]),n}(m(Array)),Z=function(t){var e=null==t;if(e)return e;if("number"==typeof t.size)return!t.size;var n=s(t);if("object"===n){var r=t.size;if("number"==typeof r)return!r}if("number"==typeof t.length&&"function"!==n)return!t.length;if("object"===n){var i=t.length;if("number"==typeof i)return!i}return!1},Q=function(t){return Z(t)||"string"==typeof t&&!1===/\S/.test(t)};function Y(t){return isFinite(t)&&Math.abs(t)<=90}function X(t){return isFinite(t)&&Math.abs(t)<=180&&Math.abs(t)>=90}function tt(t){return t instanceof ht}var et=function(){var t,e,n,r,i;return!("undefined"==typeof process||"object"!==s(null===(t=process)||void 0===t?void 0:t.env)&&-1===(null===(e=process.release)||void 0===e||null===(n=e.name)||void 0===n?void 0:n.search(/node|io.js/))||"undefined"!=typeof window&&"ReactNative"!==(null===(r=window)||void 0===r||null===(i=r.navigator)||void 0===i?void 0:i.product))},nt=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return et()?Bt("adapter","NodeAdapter",t):Bt("adapter","BrowserAdapter",t)},rt=Array.isArray,it=function(){function t(e){c(this,t),this.place=e,this.geometry=null==e?void 0:e.geometry,this.components=this.parseComponents(),this.attributes=this.parseProperties()}return h(t,[{key:"parse",value:function(){this.parseComponents(),this.parseProperties()}},{key:"parseComponents",value:function(){var t;return((null===(t=this.place)||void 0===t?void 0:t.address_components)||[]).reduce((function(t,e){return e.types.forEach((function(n){t[n]=e})),t}),{})}},{key:"parseProperties",value:function(){var t,e={streetNumber:this.get("street_number"),streetName:this.get("route"),coordinates:null!==(t=this.geometry)&&void 0!==t&&t.location?Object.values(this.geometry.location):[0,0],city:this.or(["locality","sublocality","sublocality_level_1","neighborhood","administrative_area_level_3","administrative_area_level_2"]),county:this.get("administrative_area_level_2"),stateShort:this.get("administrative_area_level_1",!0),stateLong:this.get("administrative_area_level_1"),countryShort:this.get("country",!0),country:this.get("country",!0),countryLong:this.get("country"),postalCode:this.get("postal_code")};return e.address=[e.streetNumber,e.streetName].filter(Boolean).join(" "),e}},{key:"all",value:function(){return this.attributes}},{key:"or",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e1&&void 0!==arguments[1]&&arguments[1];return t in this.components?e?this.components[t].short_name:this.components[t].long_name:null}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.attributes=o(o({},this.attributes),t),this}},{key:"setAttribute",value:function(t,e){return this.attributes[t]=e,this}},{key:"getAttribute",value:function(t){return this.attributes[t]||null}}]),t}(),ot=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;c(this,t),this.type="Point",this.coordinates=[n,e]}return h(t,[{key:"latitude",get:function(){return this.coordinates[1]}},{key:"longitude",get:function(){return this.coordinates[0]}},{key:"lat",value:function(){return this.latitude}},{key:"lng",value:function(){return this.longitude}},{key:"serialize",value:function(){return{type:"Point",coorindates:[this.lat(),this.lng()]}}},{key:"toJson",value:function(){return this.serialize()}},{key:"toString",value:function(){return"(".concat(this.latitude,", ").concat(this.longitude,")")}}],[{key:"fromGeoJson",value:function(e){var n=x(e.coordinates,2);return longitude=n[0],latitude=n[1],new t(latitude,longitude)}}]),t}(),st=function(t){return"object"===s(t)&&!Z(null==t?void 0:t.attributes)&&"object"===s(null==t?void 0:t.attributes)},ut=function(t,e){var n=t();return Array.isArray(n)||"object"===s(n)?at(n,e):null},at=function t(e,n){var r=e,i=s(e),o="object"===i,u="function"===i,a=Array.isArray(e),c="string"===s(n)&&n.includes(".")?n.split("."):[n];if(a||o){for(var l=0;l0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;c(this,t),this.actions=e,this.bind=n}return h(t,[{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=t||this.bind;if(!e)return this;if(null!=this&&this.actions&&"object"===s(this.actions))for(var n in this.actions){var r=this.actions[n];"function"==typeof r?ct(e,n,r.bind(e)):ct(e,n,r)}return this}}]),t}(),ht=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};c(this,t),this.attributes=e,this.dirtyAttributes={},this.changes={},this.isLoading=!1,this.isSaving=!1,this.isDestroying=!1,this.isReloading=!1,this.resource=r,this.options=i,this.version=i.version||"v1",this.setAdapter(n)}return h(t,[{key:"setAdapter",value:function(t){var e;return this.adapter=t,this.store=new Jt(this.resource,t,{onAfterFetch:this.syncAttributes.bind(this),actions:null===(e=this.options)||void 0===e?void 0:e.actions}),this}},{key:"id",get:function(){return this.getAttribute("id")}},{key:"create",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.mergeAttributes(e);return this.setFlags(["isLoading","isSaving"]),this.store.create(n).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.setFlags(["isLoading","isSaving"]),this.store.update(this.attributes.id,e).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"destroy",value:function(){var t=this;return this.setFlags(["isLoading","isDestroying"]),this.store.destroy(this.attributes.id).then((function(e){return t.setFlags(["isLoading","isDestroying"],!1),e}))}},{key:"reload",value:function(){var t=this;return this.setFlags(["isLoading","isReloading"]),this.store.findRecord(this.attributes.id).then((function(e){return t.reset(),e}))}},{key:"setFlags",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=["isLoading","isSaving","isReloading","isDestroying"],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},e=this.getAttributes();return Z(this.id)?this.create(e):!0===t.onlyDirty?this.savedirty():this.update(e)}},{key:"saveDirty",value:function(){for(var t=Object.keys(this.dirtyAttributes),e={},n=0;n0}},{key:"mutate",value:function(t,e){this.attributes[t]=e}},{key:"setAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===n&&"object"===s(t))return this.setAttributes(t);var r=null!==(e=null==this?void 0:this.attributes[t])&&void 0!==e?e:null;return ct(this.attributes,t,n),ct(this.dirtyAttributes,t,r),L(null==this?void 0:this.changes[t])||(this.changes[t]=[]),this.changes[t].push({property:t,previousValue:r,value:n,changedAt:new Date}),this}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)this.setAttribute(e,t[e]);return this}},{key:"getAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=at(null!==(e=null==this?void 0:this.attributes)&&void 0!==e?e:{},t);return void 0===r?n:r}},{key:"hasAttribute",value:function(t){if(L(t)){var e,n=t,r=Object.keys(null!==(e=this.attributes)&&void 0!==e?e:{});return n.every((function(t){return r.includes(t)}))}return!(null==this||!this.attributes)&&t in this.attributes}},{key:"hasAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.hasAttribute(t)}},{key:"isAttributeFilled",value:function(t){var e=this;return L(t)?this.hasAttribute(t)&&t.every((function(t){return!Z(e.getAttribute(t))})):this.hasAttribute(t)&&!Z(this.getAttribute(t))}},{key:"getAttributes",value:function(t){var e={};if(null==t)return this.getAttributes(Object.keys(this.attributes));if("string"==typeof t)return this.getAttribute(Array.prototype.slice.call(arguments));if(!L(t))throw new Error("No attribute properties provided!");for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=null!==(t=null==this?void 0:this.attributes)&&void 0!==t?t:{};return this.attributes=o(o({},n),e),this.attributes}},{key:"syncAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attributes=t}}]),t}(),vt=new lt({getDistanceAndTime:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.adapter.get("".concat(this.namespace,"/").concat(t,"/distance-and-time"),{},e)}}),ft=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"order",o({actions:vt},i))}return h(n,[{key:"getDistanceAndTime",value:function(){return this.store.getDistanceAndTime(this.id)}}]),n}(ht),dt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"payload",i)}return h(n,[{key:"attach",value:function(t){}},{key:"entities",get:function(){}},{key:"dropoff",get:function(){}},{key:"pickup",get:function(){}},{key:"waypoints",get:function(){return new V(this.waypoints)}}]),n}(ht),gt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"entity",i)}return n}(ht),pt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"place",i)}return h(n,[{key:"latitude",get:function(){var t;return null===(t=this.getAttribute("location",new ot))||void 0===t?void 0:t.coordinates[1]}},{key:"longitude",get:function(){var t;return null===(t=this.getAttribute("location",new ot))||void 0===t?void 0:t.coordinates[0]}},{key:"coordinates",get:function(){return[this.latitude,this.longitude]}},{key:"setOwner",value:function(t){return tt(t)&&this.setAttribute("owner",t.id),"string"==typeof t&&this.setAttribute("owner",t),this}}],[{key:"fromGoogleAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.getAttribute("coordinates"),o=x(i,2),s=o[0],u=o[1],a={name:null,address:t.getAttribute("address"),location:new ot(s,u),street1:t.getAttribute("streetName"),street2:null,city:t.getAttribute("city"),province:t.getAttribute("stateLong"),postal_code:t.getAttribute("postalCode"),neighborhood:t.get("neighborhood"),district:t.getAttribute("county"),building:t.get("building"),country:t.getAttribute("countryShort"),phone:null,security_access_code:null};return new n(a,e,r)}}]),n}(ht),yt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"waypoint",i)}return n}(pt),bt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"tracking-status",i)}return n}(ht),mt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"vehicle",i)}return n}(ht),kt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"driver",i)}return n}(ht),wt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"vendor",i)}return n}(ht),At=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"contact",i)}return n}(ht),xt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"zone",i)}return n}(ht),Rt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"service-area",i)}return n}(ht),$t=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"service-rate",i)}return n}(ht),Et=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"service-quote",i)}return h(n,[{key:"fromPreliminary",value:function(){}},{key:"fromPayload",value:function(){}}]),n}(ht),jt=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,t),this.version=e.version||"v1",this.host=e.host||null,this.namespace=e.namespace||null,this.headers=e.headers||{}},Ot=function(t){f(n,t);var e=A(n);function n(t){var r;return c(this,n),(r=e.call(this,t)).setHeaders({Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;browser"}),r}return h(n,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.headers=o(o({},this.headers),t),this}},{key:"parseJSON",value:function(t){return new Promise((function(e,n){return t.json().then((function(n){return e({statusText:t.statusText,status:t.status,ok:t.ok,json:n})})).catch((function(){n(new Error("Oops! Something went wrong when handling your request."))}))}))}},{key:"request",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise((function(s,u){return fetch(i.url||"".concat(e.host,"/").concat(e.namespace,"/").concat(t),o({method:n,mode:i.mode||"cors",headers:new Headers(o(o({},e.headers||{}),i.headers||{}))},r)).then(e.parseJSON).then((function(t){return t.ok?s(t.json):u(new Error(t.json.errors?t.json.errors[0]:t.statusText))})).catch((function(t){u(t)}))}))}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Q(e)?"":new URLSearchParams(e).toString();return this.request("".concat(t).concat(r?"?".concat(r):""),"GET",{},n)}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"POST",{body:JSON.stringify(e)},n)}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PUT",{body:JSON.stringify(e)},n)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.request(t,"DELETE",{},e)}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PATCH",{body:JSON.stringify(e)},n)}}]),n}(jt),St=function(t){f(n,t);var e=A(n);function n(t){var i;return c(this,n),(i=e.call(this,t)).axios=r.default.create({baseURL:"".concat(i.host,"/").concat(i.namespace),headers:{Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;node"}}),i}return h(n,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.axios.defaults.headers.common;return this.axios.defaults.headers.common=o(o({},e),t),this}},{key:"transform",value:function(t){return t.data}},{key:"handleError",value:function(t){if(t.response){var e=t.response.data;if(L(e.errors))throw new Error(e.errors[0]);if(e.error)throw new Error(e.error)}throw t}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Q(e)?"":new URLSearchParams(e).toString();return this.axios.get("".concat(t).concat(r?"?".concat(r):""),n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.post(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.put(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.axios.delete(t,e).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.patch(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}}]),n}(jt),_t=function(t){f(n,t);var e=A(n);function n(){return c(this,n),e.apply(this,arguments)}return n}(jt),Pt=function(){function t(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];c(this,t),v(this,"uncountableWords",["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"]),v(this,"pluralRules",[[new RegExp("(m)an$","gi"),"$1en"],[new RegExp("(pe)rson$","gi"),"$1ople"],[new RegExp("(child)$","gi"),"$1ren"],[new RegExp("^(ox)$","gi"),"$1en"],[new RegExp("(ax|test)is$","gi"),"$1es"],[new RegExp("(octop|vir)us$","gi"),"$1i"],[new RegExp("(alias|status)$","gi"),"$1es"],[new RegExp("(bu)s$","gi"),"$1ses"],[new RegExp("(buffal|tomat|potat)o$","gi"),"$1oes"],[new RegExp("([ti])um$","gi"),"$1a"],[new RegExp("sis$","gi"),"ses"],[new RegExp("(?:([^f])fe|([lr])f)$","gi"),"$1$2ves"],[new RegExp("(hive)$","gi"),"$1s"],[new RegExp("([^aeiouy]|qu)y$","gi"),"$1ies"],[new RegExp("(x|ch|ss|sh)$","gi"),"$1es"],[new RegExp("(matr|vert|ind)ix|ex$","gi"),"$1ices"],[new RegExp("([m|l])ouse$","gi"),"$1ice"],[new RegExp("(quiz)$","gi"),"$1zes"],[new RegExp("s$","gi"),"s"],[new RegExp("$","gi"),"s"]]),v(this,"singularRules",[[new RegExp("(m)en$","gi"),"$1an"],[new RegExp("(pe)ople$","gi"),"$1rson"],[new RegExp("(child)ren$","gi"),"$1"],[new RegExp("([ti])a$","gi"),"$1um"],[new RegExp("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$","gi"),"$1$2sis"],[new RegExp("(hive)s$","gi"),"$1"],[new RegExp("(tive)s$","gi"),"$1"],[new RegExp("(curve)s$","gi"),"$1"],[new RegExp("([lr])ves$","gi"),"$1f"],[new RegExp("([^fo])ves$","gi"),"$1fe"],[new RegExp("([^aeiouy]|qu)ies$","gi"),"$1y"],[new RegExp("(s)eries$","gi"),"$1eries"],[new RegExp("(m)ovies$","gi"),"$1ovie"],[new RegExp("(x|ch|ss|sh)es$","gi"),"$1"],[new RegExp("([m|l])ice$","gi"),"$1ouse"],[new RegExp("(bus)es$","gi"),"$1"],[new RegExp("(o)es$","gi"),"$1"],[new RegExp("(shoe)s$","gi"),"$1"],[new RegExp("(cris|ax|test)es$","gi"),"$1is"],[new RegExp("(octop|vir)i$","gi"),"$1us"],[new RegExp("(alias|status)es$","gi"),"$1"],[new RegExp("^(ox)en","gi"),"$1"],[new RegExp("(vert|ind)ices$","gi"),"$1ex"],[new RegExp("(matr)ices$","gi"),"$1ix"],[new RegExp("(quiz)zes$","gi"),"$1"],[new RegExp("s$","gi"),""]]),v(this,"nonTitlecasedWords",["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"]),v(this,"idSuffix",new RegExp("(_ids|_id)$","g")),v(this,"underbar",new RegExp("_","g")),v(this,"spaceOrUnderbar",new RegExp("[ _]","g")),v(this,"uppercase",new RegExp("([A-Z])","g")),v(this,"underbarPrefix",new RegExp("^_")),this.str=e,this.chain=n}return h(t,[{key:"get",value:function(){return this.str}},{key:"applyRules",value:function(t,e,n,r){if(r)t=r;else if(!(n.indexOf(t.toLowerCase())>-1))for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:null;return t=t||this.str,this.applyRules(t,this.pluralRules,this.uncountableWords,e)}},{key:"singularize",value:function(t,e){return t=t||this.str,this.applyRules(t,this.singularRules,this.uncountableWords,e)}},{key:"camelize",value:function(t,e){for(var n=(t=t||this.str).split("/"),r=0;r1&&void 0!==arguments[1]&&arguments[1];return t=t||this.str,t=this.underscore(this.demodulize(t))+(e?"":"_")+"id",this.str=t,!0===this.chain?this:t}},{key:"ordinalize",value:function(t){for(var e=(t=t||this.str).split(" "),n=0;n1&&void 0!==arguments[1]?arguments[1]:[];if(t.actions=L(e)?e:[e],!L(e))return e instanceof lt&&e.extend(t),t;for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};c(this,t),this.resource=e,this.adapter=n||nt(),this.namespace=zt(e),this.storage=new V,this.options=r,this.extendActions(r.actions)}return h(t,[{key:"extendActions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return Ut(this,t)}},{key:"deposit",value:function(t){return t}},{key:"serialize",value:function(t){return Bt("resource",Dt(this.resource),t,this.adapter)}},{key:"afterFetch",value:function(t){return It(this,t)}},{key:"create",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=a(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.post("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"update",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(function(){var i=a(regeneratorRuntime.mark((function i(o,s){var u;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,e.adapter.put("".concat(e.namespace,"/").concat(t),n,r).then(e.afterFetch.bind(e)).catch(s);case 2:u=i.sent,o(u);case 4:case"end":return i.stop()}}),i)})));return function(t,e){return i.apply(this,arguments)}}())}},{key:"findRecord",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=a(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e.adapter.get("".concat(e.namespace,"/").concat(t),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"findAll",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var n=a(regeneratorRuntime.mark((function n(r,i){var o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.adapter.get("".concat(t.namespace),{},e).then(t.afterFetch.bind(t)).catch(i);case 2:o=n.sent,r(o);case 4:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"query",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=a(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"queryRecord",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.single=!0,new Promise(function(){var r=a(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"destroy",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=tt(t)?t.getAttribute("id"):t;return new Promise(function(){var t=a(regeneratorRuntime.mark((function t(i,o){var s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.adapter.delete("".concat(e.namespace,"/").concat(r),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=t.sent,i(s);case 4:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}}]),t}(),Wt=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(c(this,t),this.version=n.version||"v1",this.options={version:this.version,host:n.host||"https://api.fleetbase.io",namespace:this.version||n.namespace,debug:r,publicKey:e},"string"!=typeof e||0===e.length)throw new Error("⚠️ Invalid public key given to Fleetbase SDK");if(!et()&&e.toLowerCase().startsWith("$"))throw new Error("Secret key provided. You must use a public key with Fleetbase Javascript SDK!");this.adapter=n.adapter||nt(this.options),this.orders=new Jt("order",this.adapter).extendActions(vt),this.entities=new Jt("entity",this.adapter),this.places=new Jt("place",this.adapter),this.drivers=new Jt("driver",this.adapter),this.vehicles=new Jt("vehicle",this.adapter),this.vendors=new Jt("vendor",this.adapter),this.contacts=new Jt("contact",this.adapter)}return h(t,[{key:"setAdapter",value:function(t){this.adapter=t}},{key:"getAdapter",value:function(){return this.adapter}}],[{key:"newInstance",value:function(){return y(t,Array.prototype.slice.call(arguments))}}]),t}();t.Adapter=jt,t.BrowserAdapter=Ot,t.Collection=V,t.Contact=At,t.Driver=kt,t.EmberJsAdapter=_t,t.Entity=gt,t.GoogleAddress=it,t.NodeAdapter=St,t.Order=ft,t.Payload=dt,t.Place=pt,t.Point=ot,t.Resource=ht,t.ServiceArea=Rt,t.ServiceQuote=Et,t.ServiceRate=$t,t.Store=Jt,t.StoreActions=lt,t.TrackingStatus=bt,t.Vehicle=mt,t.Vendor=wt,t.Waypoint=yt,t.Zone=xt,t.camelize=Ft,t.classify=Dt,t.dasherize=Ct,t.default=Wt,t.extendStoreActions=Ut,t.isLatitude=Y,t.isLongitude=X,t.isNodeEnvironment=et,t.isResource=tt,t.pluralize=zt,t.singularize=Lt})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios"),require("date-fns")):"function"==typeof define&&define.amd?define(["exports","axios","date-fns"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@fleetbase/sdk"]={},t.axios)}(this,(function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=n(e);function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function o(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n3&&void 0!==arguments[3]?arguments[3]:[];if(F(t))if(r.length<=L)t.splice.apply(t,[e,n].concat(E(r)));else{t.splice(e,n);for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:N,n=[],r=new Set,i="function"==typeof e?e:function(t){return get(t,e)};return t.forEach((function(t){var e=i(t);r.has(e)||(r.add(e),n.push(t))})),n},q=function(t){return t instanceof V},B=function(t,e){return F(t)?t[e]:q(t)?t.objectAt(e):null},U=function(t,e){return 2===D.length?function(n){return e===n[t]}:function(e){return Boolean(e[t])}},I=function(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=t.length,i=n;i2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0,i=t.length;n<0&&(n+=i);var o=r&&e!=e?function(t){return t!=t}:function(t){return t===e};return I(t,o,n)},M=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return C(t,e,n,[]),t},G=function(t,e,n){return C(t,e,0,[n]),n},V=function(t){f(n,t);var e=A(n);function n(){for(var t=arguments.length,r=new Array(t),i=0;i0}},{key:"empty",get:function(){return 0===this.length}},{key:"first",get:function(){return B(this,0)}},{key:"last",get:function(){return B(this,this.length-1)}},{key:"replace",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return C(this,t,e,n),this}},{key:"objectsAt",value:function(t){var e=this;return t.map((function(t){return B(e,t)}))}},{key:"objectAt",value:function(t){return B(this,t)}},{key:"indexOf",value:function(t,e){return K(this,t,e,!1)}},{key:"lastIndexOf",value:function(t,e){var n=this.length;(void 0===e||e>=n)&&(e=n-1),e<0&&(e+=n);for(var r=e;r>=0;r--)if(B(this,r)===t)return r;return-1}},{key:"includes",value:function(t,e){return-1!==K(this,t,e,!0)}},{key:"findBy",value:function(){return J(this,U.apply(void 0,arguments))}},{key:"findIndexBy",value:function(){return I(this,U.apply(void 0,arguments))}},{key:"isEvery",value:function(){return H(this,U.apply(void 0,arguments))}},{key:"isAny",value:function(){return W(this,U.apply(void 0,arguments))}},{key:"invoke",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r=0;){B(this,e)===t&&this.removeAt(e)}return this}},{key:"removeObjects",value:function(t){for(var e=t.length-1;e>=0;e--)this.removeObject(t[e]);return this}},{key:"addObject",value:function(t){return this.includes(t)||this.pushObject(t),this}},{key:"addObjects",value:function(t){var e=this;return t.forEach((function(t){return e.addObject(t)})),this}}]),n}(k(Array)),Z=function(t){var e=null==t;if(e)return e;if("number"==typeof t.size)return!t.size;var n=s(t);if("object"===n){var r=t.size;if("number"==typeof r)return!r}if("number"==typeof t.length&&"function"!==n)return!t.length;if("object"===n){var i=t.length;if("number"==typeof i)return!i}return!1},Q=function(t){return Z(t)||"string"==typeof t&&!1===/\S/.test(t)};function Y(t){return isFinite(t)&&Math.abs(t)<=90}function X(t){return isFinite(t)&&Math.abs(t)<=180&&Math.abs(t)>=90}function tt(t){return t instanceof vt}var et=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^[+]?[\s./0-9]*[(]?[0-9]{1,4}[)]?[-\s./0-9]*$/g.test(t)},nt=function(){var t,e,n,r,i;return!("undefined"==typeof process||"object"!==s(null===(t=process)||void 0===t?void 0:t.env)&&-1===(null===(e=process.release)||void 0===e||null===(n=e.name)||void 0===n?void 0:n.search(/node|io.js/))||"undefined"!=typeof window&&"ReactNative"!==(null===(r=window)||void 0===r||null===(i=r.navigator)||void 0===i?void 0:i.product))},rt=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return nt()?It("adapter","NodeAdapter",t):It("adapter","BrowserAdapter",t)},it=Array.isArray,ot=function(){function t(e){c(this,t),this.place=e,this.geometry=null==e?void 0:e.geometry,this.components=this.parseComponents(),this.attributes=this.parseProperties()}return l(t,[{key:"parse",value:function(){this.parseComponents(),this.parseProperties()}},{key:"parseComponents",value:function(){var t;return((null===(t=this.place)||void 0===t?void 0:t.address_components)||[]).reduce((function(t,e){return e.types.forEach((function(n){t[n]=e})),t}),{})}},{key:"parseProperties",value:function(){var t,e={streetNumber:this.get("street_number"),streetName:this.get("route"),coordinates:null!==(t=this.geometry)&&void 0!==t&&t.location?Object.values(this.geometry.location):[0,0],city:this.or(["locality","sublocality","sublocality_level_1","neighborhood","administrative_area_level_3","administrative_area_level_2"]),county:this.get("administrative_area_level_2"),stateShort:this.get("administrative_area_level_1",!0),stateLong:this.get("administrative_area_level_1"),countryShort:this.get("country",!0),country:this.get("country",!0),countryLong:this.get("country"),postalCode:this.get("postal_code")};return e.address=[e.streetNumber,e.streetName].filter(Boolean).join(" "),e}},{key:"all",value:function(){return this.attributes}},{key:"or",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e1&&void 0!==arguments[1]&&arguments[1];return t in this.components?e?this.components[t].short_name:this.components[t].long_name:null}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.attributes=o(o({},this.attributes),t),this}},{key:"setAttribute",value:function(t,e){return this.attributes[t]=e,this}},{key:"getAttribute",value:function(t){return this.attributes[t]||null}}]),t}(),st=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;c(this,t),this.type="Point",this.coordinates=[n,e]}return l(t,[{key:"latitude",get:function(){return this.coordinates[1]}},{key:"longitude",get:function(){return this.coordinates[0]}},{key:"lat",value:function(){return this.latitude}},{key:"lng",value:function(){return this.longitude}},{key:"serialize",value:function(){return{type:"Point",coorindates:[this.lat(),this.lng()]}}},{key:"toJson",value:function(){return this.serialize()}},{key:"toString",value:function(){return"(".concat(this.latitude,", ").concat(this.longitude,")")}}],[{key:"fromGeoJson",value:function(e){var n=x(e.coordinates,2);return longitude=n[0],latitude=n[1],new t(latitude,longitude)}}]),t}(),ut=function(t){return"object"===s(t)&&!Z(null==t?void 0:t.attributes)&&"object"===s(null==t?void 0:t.attributes)},at=function(t,e){var n=t();return Array.isArray(n)||"object"===s(n)?ct(n,e):null},ct=function t(e,n){var r=e,i=s(e),o="object"===i,u="function"===i,a=Array.isArray(e),c="string"===s(n)&&n.includes(".")?n.split("."):[n];if(a||o){for(var h=0;h0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;c(this,t),this.actions=e,this.bind=n}return l(t,[{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=t||this.bind;if(!e)return this;if(null!=this&&this.actions&&"object"===s(this.actions))for(var n in this.actions){var r=this.actions[n];"function"==typeof r?ht(e,n,r.bind(e)):ht(e,n,r)}return this}}]),t}(),vt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};c(this,t),this.attributes=e,this.dirtyAttributes={},this.changes={},this.isLoading=!1,this.isSaving=!1,this.isDestroying=!1,this.isReloading=!1,this.resource=r,this.options=i,this.version=i.version||"v1",this.setAdapter(n)}return l(t,[{key:"setAdapter",value:function(t){var e;return this.adapter=t,this.store=new Ht(this.resource,t,{onAfterFetch:this.syncAttributes.bind(this),actions:null===(e=this.options)||void 0===e?void 0:e.actions}),this}},{key:"id",get:function(){return this.getAttribute("id")}},{key:"create",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.mergeAttributes(e);return this.setFlags(["isLoading","isSaving"]),this.store.create(n).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.setFlags(["isLoading","isSaving"]),this.store.update(this.attributes.id,e).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"destroy",value:function(){var t=this;return this.setFlags(["isLoading","isDestroying"]),this.store.destroy(this.attributes.id).then((function(e){return t.setFlags(["isLoading","isDestroying"],!1),e}))}},{key:"reload",value:function(){var t=this;return this.setFlags(["isLoading","isReloading"]),this.store.findRecord(this.attributes.id).then((function(e){return t.reset(),e}))}},{key:"setFlags",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=["isLoading","isSaving","isReloading","isDestroying"],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},e=this.getAttributes();return Z(this.id)?this.create(e):!0===t.onlyDirty?this.savedirty():this.update(e)}},{key:"saveDirty",value:function(){for(var t=Object.keys(this.dirtyAttributes),e={},n=0;n0}},{key:"mutate",value:function(t,e){this.attributes[t]=e}},{key:"setAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===n&&"object"===s(t))return this.setAttributes(t);var r=null!==(e=null==this?void 0:this.attributes[t])&&void 0!==e?e:null;return ht(this.attributes,t,n),ht(this.dirtyAttributes,t,r),F(null==this?void 0:this.changes[t])||(this.changes[t]=[]),this.changes[t].push({property:t,previousValue:r,value:n,changedAt:new Date}),this}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)this.setAttribute(e,t[e]);return this}},{key:"getAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=ct(null!==(e=null==this?void 0:this.attributes)&&void 0!==e?e:{},t);return void 0===r?n:r}},{key:"hasAttribute",value:function(t){if(F(t)){var e,n=t,r=Object.keys(null!==(e=this.attributes)&&void 0!==e?e:{});return n.every((function(t){return r.includes(t)}))}return!(null==this||!this.attributes)&&t in this.attributes}},{key:"hasAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.hasAttribute(t)}},{key:"isAttributeFilled",value:function(t){var e=this;return F(t)?this.hasAttribute(t)&&t.every((function(t){return!Z(e.getAttribute(t))})):this.hasAttribute(t)&&!Z(this.getAttribute(t))}},{key:"getAttributes",value:function(t){var e={};if(null==t)return this.getAttributes(Object.keys(this.attributes));if("string"==typeof t)return this.getAttribute(Array.prototype.slice.call(arguments));if(!F(t))throw new Error("No attribute properties provided!");for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=null!==(t=null==this?void 0:this.attributes)&&void 0!==t?t:{};return this.attributes=o(o({},n),e),this.attributes}},{key:"syncAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attributes=t}}]),t}(),ft=new lt({getDistanceAndTime:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.get("".concat(this.namespace,"/").concat(t,"/distance-and-time"),e,n)},getNextActivity:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.get("".concat(this.namespace,"/").concat(t,"/next-activity"),e,n)},dispatch:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/dispatch"),e,n).then(this.afterFetch.bind(this))},start:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/start"),e,n).then(this.afterFetch.bind(this))},updateActivity:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/update-activity"),e,n).then(this.afterFetch.bind(this))},complete:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/complete"),e,n).then(this.afterFetch.bind(this))},cancel:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.delete("".concat(this.namespace,"/").concat(t,"/cancel"),e,n).then(this.afterFetch.bind(this))}}),dt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"order",o({actions:ft},i))}return l(n,[{key:"getDistanceAndTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.getDistanceAndTime(this.id,t,e)}},{key:"dispatch",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.dispatch(this.id,t,e)}},{key:"start",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.start(this.id,t,e)}},{key:"getNextActivity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.getNextActivity(this.id,t,e)}},{key:"updateActivity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.updateActivity(this.id,t,e)}},{key:"cancel",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.cancel(this.id,t,e)}},{key:"complete",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.complete(this.id,t,e)}},{key:"isDispatched",get:function(){return null!==this.getAttribute("dispatched_at")}},{key:"isNotDispatched",get:function(){return null==this.getAttribute("dispatched_at")}},{key:"isStarted",get:function(){return null!==this.getAttribute("started_at")}},{key:"isNotStarted",get:function(){return null==this.getAttribute("started_at")}},{key:"isCompleted",get:function(){return"completed"==this.getAttribute("status")}},{key:"isCanceled",get:function(){return"canceled"==this.getAttribute("status")}},{key:"isEnroute",get:function(){return"driver_enroute"==this.getAttribute("status")||"enroute"===this.getAttribute("status")}},{key:"isInProgress",get:function(){return this.isStarted&&!this.isCanceled&&!this.isCompleted}},{key:"scheduledAt",get:function(){return this.isAttributeFilled("scheduled_at")?new Date(this.getAttribute("scheduled_at")):null}},{key:"startedAt",get:function(){return this.isAttributeFilled("started_at")?new Date(this.getAttribute("started_at")):null}},{key:"dispatchedAt",get:function(){return this.isAttributeFilled("dispatched_at")?new Date(this.getAttribute("dispatched_at")):null}},{key:"status",get:function(){return this.getAttribute("status")}}]),n}(vt),gt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"payload",i)}return l(n,[{key:"attach",value:function(t){}},{key:"entities",get:function(){}},{key:"dropoff",get:function(){}},{key:"pickup",get:function(){}},{key:"waypoints",get:function(){return new V(this.waypoints)}}]),n}(vt),pt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"entity",i)}return n}(vt),yt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"place",i)}return l(n,[{key:"latitude",get:function(){var t;return null===(t=this.getAttribute("location",new st))||void 0===t?void 0:t.coordinates[1]}},{key:"longitude",get:function(){var t;return null===(t=this.getAttribute("location",new st))||void 0===t?void 0:t.coordinates[0]}},{key:"coordinates",get:function(){return[this.latitude,this.longitude]}},{key:"setOwner",value:function(t){return tt(t)&&this.setAttribute("owner",t.id),"string"==typeof t&&this.setAttribute("owner",t),this}}],[{key:"fromGoogleAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.getAttribute("coordinates"),o=x(i,2),s=o[0],u=o[1],a={name:null,address:t.getAttribute("address"),location:new st(s,u),street1:t.getAttribute("streetName"),street2:null,city:t.getAttribute("city"),province:t.getAttribute("stateLong"),postal_code:t.getAttribute("postalCode"),neighborhood:t.get("neighborhood"),district:t.getAttribute("county"),building:t.get("building"),country:t.getAttribute("countryShort"),phone:null,security_access_code:null};return new n(a,e,r)}}]),n}(vt),bt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"waypoint",i)}return n}(yt),kt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"tracking-status",i)}return n}(vt),mt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"vehicle",i)}return n}(vt),wt=new lt({login:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(et(t))return this.adapter.post("drivers/login-with-sms",{phone:t});if(!e)throw new Error("Login requires password!");return this.adapter.post("drivers/login",o({identity:t,password:e},n)).then(this.afterFetch.bind(this))},verifyCode:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("drivers/verify-code",o({identity:t,code:e},n)).then(this.afterFetch.bind(this))},retrieve:function(t){return this.findRecord(t)}}),At=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"driver",i)}return l(n,[{key:"token",get:function(){return this.getAttribute("token")}},{key:"isOnline",get:function(){return!0===this.getAttribute("online")}},{key:"syncDevice",value:function(t){var e=this;return this.adapter.setHeaders({"Driver-Token":this.token}).post("drivers/register-device",t).then((function(){return e}))}}]),n}(vt),xt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"vendor",i)}return n}(vt),Et=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"contact",i)}return n}(vt),Rt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"zone",i)}return n}(vt),$t=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"service-area",i)}return n}(vt),jt=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"service-rate",i)}return n}(vt),Ot=function(t){f(n,t);var e=A(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c(this,n),e.call(this,t,r,"service-quote",i)}return l(n,[{key:"fromPreliminary",value:function(){}},{key:"fromPayload",value:function(){}}]),n}(vt),St=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c(this,t),this.version=e.version||"v1",this.host=e.host||null,this.namespace=e.namespace||null,this.headers=e.headers||{}},_t=function(t){f(n,t);var e=A(n);function n(t){var r;return c(this,n),(r=e.call(this,t)).setHeaders({Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;browser"}),r}return l(n,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.headers=o(o({},this.headers),t),this}},{key:"parseJSON",value:function(t){return new Promise((function(e,n){return t.json().then((function(n){return e({statusText:t.statusText,status:t.status,ok:t.ok,json:n})})).catch((function(){n(new Error("Oops! Something went wrong when handling your request."))}))}))}},{key:"request",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise((function(s,u){return fetch(i.url||"".concat(e.host,"/").concat(e.namespace,"/").concat(t),o({method:n,mode:i.mode||"cors",headers:new Headers(o(o({},e.headers||{}),i.headers||{}))},r)).then(e.parseJSON).then((function(t){return t.ok?s(t.json):u(new Error(t.json.errors?t.json.errors[0]:t.statusText))})).catch((function(t){u(t)}))}))}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Q(e)?"":new URLSearchParams(e).toString();return this.request("".concat(t).concat(r?"?".concat(r):""),"GET",{},n)}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"POST",{body:JSON.stringify(e)},n)}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PUT",{body:JSON.stringify(e)},n)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.request(t,"DELETE",{},e)}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PATCH",{body:JSON.stringify(e)},n)}}]),n}(St),Pt=function(t){f(n,t);var e=A(n);function n(t){var i;return c(this,n),(i=e.call(this,t)).axios=r.default.create({baseURL:"".concat(i.host,"/").concat(i.namespace),headers:{Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;node"}}),i}return l(n,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.axios.defaults.headers.common;return this.axios.defaults.headers.common=o(o({},e),t),this}},{key:"transform",value:function(t){return t.data}},{key:"handleError",value:function(t){if(t.response){var e=t.response.data;if(F(e.errors))throw new Error(e.errors[0]);if(e.error)throw new Error(e.error)}throw t}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Q(e)?"":new URLSearchParams(e).toString();return this.axios.get("".concat(t).concat(r?"?".concat(r):""),n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.post(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.put(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.axios.delete(t,e).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.patch(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}}]),n}(St),zt=function(t){f(n,t);var e=A(n);function n(){return c(this,n),e.apply(this,arguments)}return n}(St),Ft=function(){function t(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];c(this,t),v(this,"uncountableWords",["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"]),v(this,"pluralRules",[[new RegExp("(m)an$","gi"),"$1en"],[new RegExp("(pe)rson$","gi"),"$1ople"],[new RegExp("(child)$","gi"),"$1ren"],[new RegExp("^(ox)$","gi"),"$1en"],[new RegExp("(ax|test)is$","gi"),"$1es"],[new RegExp("(octop|vir)us$","gi"),"$1i"],[new RegExp("(alias|status)$","gi"),"$1es"],[new RegExp("(bu)s$","gi"),"$1ses"],[new RegExp("(buffal|tomat|potat)o$","gi"),"$1oes"],[new RegExp("([ti])um$","gi"),"$1a"],[new RegExp("sis$","gi"),"ses"],[new RegExp("(?:([^f])fe|([lr])f)$","gi"),"$1$2ves"],[new RegExp("(hive)$","gi"),"$1s"],[new RegExp("([^aeiouy]|qu)y$","gi"),"$1ies"],[new RegExp("(x|ch|ss|sh)$","gi"),"$1es"],[new RegExp("(matr|vert|ind)ix|ex$","gi"),"$1ices"],[new RegExp("([m|l])ouse$","gi"),"$1ice"],[new RegExp("(quiz)$","gi"),"$1zes"],[new RegExp("s$","gi"),"s"],[new RegExp("$","gi"),"s"]]),v(this,"singularRules",[[new RegExp("(m)en$","gi"),"$1an"],[new RegExp("(pe)ople$","gi"),"$1rson"],[new RegExp("(child)ren$","gi"),"$1"],[new RegExp("([ti])a$","gi"),"$1um"],[new RegExp("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$","gi"),"$1$2sis"],[new RegExp("(hive)s$","gi"),"$1"],[new RegExp("(tive)s$","gi"),"$1"],[new RegExp("(curve)s$","gi"),"$1"],[new RegExp("([lr])ves$","gi"),"$1f"],[new RegExp("([^fo])ves$","gi"),"$1fe"],[new RegExp("([^aeiouy]|qu)ies$","gi"),"$1y"],[new RegExp("(s)eries$","gi"),"$1eries"],[new RegExp("(m)ovies$","gi"),"$1ovie"],[new RegExp("(x|ch|ss|sh)es$","gi"),"$1"],[new RegExp("([m|l])ice$","gi"),"$1ouse"],[new RegExp("(bus)es$","gi"),"$1"],[new RegExp("(o)es$","gi"),"$1"],[new RegExp("(shoe)s$","gi"),"$1"],[new RegExp("(cris|ax|test)es$","gi"),"$1is"],[new RegExp("(octop|vir)i$","gi"),"$1us"],[new RegExp("(alias|status)es$","gi"),"$1"],[new RegExp("^(ox)en","gi"),"$1"],[new RegExp("(vert|ind)ices$","gi"),"$1ex"],[new RegExp("(matr)ices$","gi"),"$1ix"],[new RegExp("(quiz)zes$","gi"),"$1"],[new RegExp("s$","gi"),""]]),v(this,"nonTitlecasedWords",["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"]),v(this,"idSuffix",new RegExp("(_ids|_id)$","g")),v(this,"underbar",new RegExp("_","g")),v(this,"spaceOrUnderbar",new RegExp("[ _]","g")),v(this,"uppercase",new RegExp("([A-Z])","g")),v(this,"underbarPrefix",new RegExp("^_")),this.str=e,this.chain=n}return l(t,[{key:"get",value:function(){return this.str}},{key:"applyRules",value:function(t,e,n,r){if(r)t=r;else if(!(n.indexOf(t.toLowerCase())>-1))for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:null;return t=t||this.str,this.applyRules(t,this.pluralRules,this.uncountableWords,e)}},{key:"singularize",value:function(t,e){return t=t||this.str,this.applyRules(t,this.singularRules,this.uncountableWords,e)}},{key:"camelize",value:function(t,e){for(var n=(t=t||this.str).split("/"),r=0;r1&&void 0!==arguments[1]&&arguments[1];return t=t||this.str,t=this.underscore(this.demodulize(t))+(e?"":"_")+"id",this.str=t,!0===this.chain?this:t}},{key:"ordinalize",value:function(t){for(var e=(t=t||this.str).split(" "),n=0;n1&&void 0!==arguments[1]?arguments[1]:[];if(t.actions=F(e)?e:[e],!F(e))return e instanceof lt&&e.extend(t),t;for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};c(this,t),this.resource=e,this.adapter=n||rt(),this.namespace=Dt(e),this.storage=new V,this.options=r,this.extendActions(r.actions)}return l(t,[{key:"extendActions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return Jt(this,t)}},{key:"deposit",value:function(t){return t}},{key:"serialize",value:function(t){return It("resource",Tt(this.resource),t,this.adapter)}},{key:"afterFetch",value:function(t){return Wt(this,t)}},{key:"create",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=a(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.post("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"update",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(function(){var i=a(regeneratorRuntime.mark((function i(o,s){var u;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,e.adapter.put("".concat(e.namespace,"/").concat(t),n,r).then(e.afterFetch.bind(e)).catch(s);case 2:u=i.sent,o(u);case 4:case"end":return i.stop()}}),i)})));return function(t,e){return i.apply(this,arguments)}}())}},{key:"findRecord",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=a(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e.adapter.get("".concat(e.namespace,"/").concat(t),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"findAll",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var n=a(regeneratorRuntime.mark((function n(r,i){var o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.adapter.get("".concat(t.namespace),{},e).then(t.afterFetch.bind(t)).catch(i);case 2:o=n.sent,r(o);case 4:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"query",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=a(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"queryRecord",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.single=!0,new Promise(function(){var r=a(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"destroy",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=tt(t)?t.getAttribute("id"):t;return new Promise(function(){var t=a(regeneratorRuntime.mark((function t(i,o){var s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.adapter.delete("".concat(e.namespace,"/").concat(r),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=t.sent,i(s);case 4:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}}]),t}(),Kt=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(c(this,t),this.version=n.version||"v1",this.options={version:this.version,host:n.host||"https://api.fleetbase.io",namespace:this.version||n.namespace,debug:r,publicKey:e},"string"!=typeof e||0===e.length)throw new Error("⚠️ Invalid public key given to Fleetbase SDK");if(!nt()&&e.toLowerCase().startsWith("$"))throw new Error("Secret key provided. You must use a public key with Fleetbase Javascript SDK!");this.adapter=n.adapter||rt(this.options),this.orders=new Ht("order",this.adapter).extendActions(ft),this.entities=new Ht("entity",this.adapter),this.places=new Ht("place",this.adapter),this.drivers=new Ht("driver",this.adapter).extendActions(wt),this.vehicles=new Ht("vehicle",this.adapter),this.vendors=new Ht("vendor",this.adapter),this.contacts=new Ht("contact",this.adapter)}return l(t,[{key:"setAdapter",value:function(t){this.adapter=t}},{key:"getAdapter",value:function(){return this.adapter}}],[{key:"newInstance",value:function(){return y(t,Array.prototype.slice.call(arguments))}}]),t}();t.Adapter=St,t.BrowserAdapter=_t,t.Collection=V,t.Contact=Et,t.Driver=At,t.EmberJsAdapter=zt,t.Entity=pt,t.GoogleAddress=ot,t.NodeAdapter=Pt,t.Order=dt,t.Payload=gt,t.Place=yt,t.Point=st,t.Resource=vt,t.ServiceArea=$t,t.ServiceQuote=Ot,t.ServiceRate=jt,t.Store=Ht,t.StoreActions=lt,t.TrackingStatus=kt,t.Vehicle=mt,t.Vendor=xt,t.Waypoint=bt,t.Zone=Rt,t.camelize=Ct,t.classify=Tt,t.dasherize=Nt,t.default=Kt,t.extendStoreActions=Jt,t.isLatitude=Y,t.isLongitude=X,t.isNodeEnvironment=nt,t.isResource=tt,t.pluralize=Dt,t.singularize=Lt})); //# sourceMappingURL=sdk.min.js.map diff --git a/dist/@fleetbase/sdk.min.js.map b/dist/@fleetbase/sdk.min.js.map index 88c0abf..0256aff 100644 --- a/dist/@fleetbase/sdk.min.js.map +++ b/dist/@fleetbase/sdk.min.js.map @@ -1 +1 @@ -{"version":3,"file":"sdk.min.js","sources":["../../src/utils/array.js","../../src/utils/collection.js","../../src/utils/is-empty.js","../../src/utils/is-blank.js","../../src/utils/is-latitude.js","../../src/utils/is-longitude.js","../../src/utils/is-resource.js","../../src/utils/is-node-environment.js","../../src/utils/detect-adapter.js","../../src/utils/google-address.js","../../src/utils/point.js","../../src/utils/object.js","../../src/utils/store-actions.js","../../src/resource.js","../../src/resources/order.js","../../src/resources/payload.js","../../src/resources/entity.js","../../src/resources/place.js","../../src/resources/waypoint.js","../../src/resources/tracking-status.js","../../src/resources/vehicle.js","../../src/resources/driver.js","../../src/resources/vendor.js","../../src/resources/contact.js","../../src/resources/zone.js","../../src/resources/service-area.js","../../src/resources/service-rate.js","../../src/resources/service-quote.js","../../src/adapter.js","../../src/adapters/browser.js","../../src/adapters/node.js","../../src/adapters/ember.js","../../src/utils/string.js","../../src/resolver.js","../../src/store.js","../../src/fleetbase.js"],"sourcesContent":["const { isArray } = Array;\n\nexport {\n isArray\n};\n","import { isArray } from './array';\n\n/**\n * Collection\n * Extended array inspired by Ember's NativeArray\n **/\n\nconst CHUNK_SIZE = 60000;\n\n// To avoid overflowing the stack, we splice up to CHUNK_SIZE items at a time.\n// See https://code.google.com/p/chromium/issues/detail?id=56588 for more details.\nconst replace = (array, start, deleteCount, items = []) => {\n if (isArray(array)) {\n if (items.length <= CHUNK_SIZE) {\n array.splice(start, deleteCount, ...items);\n } else {\n array.splice(start, deleteCount);\n\n for (let i = 0; i < items.length; i += CHUNK_SIZE) {\n let chunk = items.slice(i, i + CHUNK_SIZE);\n array.splice(start + i, 0, ...chunk);\n }\n }\n } else if (isCollection(arr)) {\n array.replace(start, deleteCount, items);\n }\n};\n\nconst identityFunction = (item) => item;\n\nconst uniqBy = (array, key = identityFunction) => {\n let ret = [];\n let seen = new Set();\n let getter = typeof key === 'function' ? key : (item) => get(item, key);\n\n array.forEach((item) => {\n let val = getter(item);\n if (!seen.has(val)) {\n seen.add(val);\n ret.push(item);\n }\n });\n\n return ret;\n};\n\nconst isCollection = (mixed) => mixed instanceof Collection;\n\nconst objectAt = (array, index) => {\n if (isArray(array)) {\n return array[index];\n } else if (isCollection(array)) {\n return array.objectAt(index);\n }\n\n return null;\n};\n\nconst iter = (key, value) => {\n let valueProvided = arguments.length === 2;\n return valueProvided ? (item) => value === item[key] : (item) => Boolean(item[key]);\n};\n\nconst findIndex = (array, predicate, startAt = 0) => {\n let len = array.length;\n for (let index = startAt; index < len; index++) {\n let item = objectAt(array, index);\n if (predicate(item, index, array)) {\n return index;\n }\n }\n return -1;\n};\n\nconst find = (array, callback, target) => {\n let predicate = callback.bind(target);\n let index = findIndex(array, predicate, 0);\n return index === -1 ? undefined : objectAt(array, index);\n};\n\nconst any = (array, callback, target) => {\n let predicate = callback.bind(target);\n return findIndex(array, predicate, 0) !== -1;\n};\n\nconst every = (array, callback, target) => {\n let cb = callback.bind(target);\n let predicate = (item, index, array) => !cb(item, index, array);\n return findIndex(array, predicate, 0) === -1;\n};\n\nconst indexOf = (array, val, startAt = 0, withNaNCheck) => {\n let len = array.length;\n\n if (startAt < 0) {\n startAt += len;\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = withNaNCheck && val !== val ? (item) => item !== item : (item) => item === val;\n return findIndex(array, predicate, startAt);\n};\n\nconst removeAt = (array, index, len = 1) => {\n replace(array, index, len, []);\n return array;\n};\n\nconst insertAt = (array, index, item) => {\n replace(array, index, 0, [item]);\n return item;\n};\n\nclass Collection extends Array {\n constructor(...items) {\n if (isArray(arguments[0])) {\n super(...arguments[0]);\n } else {\n super(...arguments);\n }\n }\n\n get notEmpty() {\n return this.length > 0;\n }\n\n get empty() {\n return this.length === 0;\n }\n\n get first() {\n return objectAt(this, 0);\n }\n\n get last() {\n return objectAt(this, this.length - 1);\n }\n\n replace(start, deleteCount, items = []) {\n replace(this, start, deleteCount, items);\n\n return this;\n }\n\n objectsAt(indexes) {\n return indexes.map((idx) => objectAt(this, idx));\n }\n\n objectAt(index) {\n return objectAt(this, index);\n }\n\n indexOf(object, startAt) {\n return indexOf(this, object, startAt, false);\n }\n\n lastIndexOf(object, startAt) {\n let len = this.length;\n\n if (startAt === undefined || startAt >= len) {\n startAt = len - 1;\n }\n\n if (startAt < 0) {\n startAt += len;\n }\n\n for (let idx = startAt; idx >= 0; idx--) {\n if (objectAt(this, idx) === object) {\n return idx;\n }\n }\n\n return -1;\n }\n\n includes(object, startAt) {\n return indexOf(this, object, startAt, true) !== -1;\n }\n\n findBy() {\n return find(this, iter(...arguments));\n }\n\n findIndexBy() {\n return findIndex(this, iter(...arguments));\n }\n\n isEvery() {\n return every(this, iter(...arguments));\n }\n\n isAny() {\n return any(this, iter(...arguments));\n }\n\n invoke(methodName, ...args) {\n let ret = [];\n\n this.forEach((item) => ret.push(item[methodName]?.(...args)));\n\n return ret;\n }\n\n toArray() {\n return this.map((item) => item);\n }\n\n compact() {\n return this.filter((value) => value != null);\n }\n\n sortBy() {\n let sortKeys = arguments;\n\n return this.sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n let key = sortKeys[i];\n let propA = a[key];\n let propB = b[key];\n // return 1 or -1 else continue to the next sortKey\n let compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n }\n\n uniqBy(key) {\n return uniqBy(this, key);\n }\n\n without(value) {\n if (!this.includes(value)) {\n return this; // nothing to do\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = value === value ? (item) => item !== value : (item) => item === item;\n return this.filter(predicate);\n }\n\n clear() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n this.replace(0, len, []);\n return this;\n }\n\n insertAt(idx, object) {\n insertAt(this, idx, object);\n return this;\n }\n\n replaceAt(idx, object) {\n return this.replace(idx, 1, [object]);\n }\n\n removeAt(start, len) {\n return removeAt(this, start, len);\n }\n\n pushObject(obj) {\n return this.insertAt(this.length, obj);\n }\n\n pushObjects(objects) {\n this.replace(this.length, 0, objects);\n return this;\n }\n\n popObject() {\n let len = this.length;\n if (len === 0) {\n return null;\n }\n\n let ret = objectAt(this, len - 1);\n this.removeAt(len - 1, 1);\n return ret;\n }\n\n shiftObject() {\n if (this.length === 0) {\n return null;\n }\n\n let ret = objectAt(this, 0);\n this.removeAt(0);\n return ret;\n }\n\n unshiftObject(obj) {\n return insertAt(this, 0, obj);\n }\n\n unshiftObjects(objects) {\n this.replace(0, 0, objects);\n return this;\n }\n\n reverseObjects() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n let objects = this.toArray().reverse();\n this.replace(0, len, objects);\n return this;\n }\n\n setObjects(objects) {\n if (objects.length === 0) {\n return this.clear();\n }\n\n let len = this.length;\n this.replace(0, len, objects);\n return this;\n }\n\n removeObject(obj) {\n let loc = this.length || 0;\n while (--loc >= 0) {\n let curObject = objectAt(this, loc);\n\n if (curObject === obj) {\n this.removeAt(loc);\n }\n }\n return this;\n }\n\n removeObjects(objects) {\n for (let i = objects.length - 1; i >= 0; i--) {\n this.removeObject(objects[i]);\n }\n\n return this;\n }\n\n addObject(obj) {\n let included = this.includes(obj);\n\n if (!included) {\n this.pushObject(obj);\n }\n\n return this;\n }\n\n addObjects(objects) {\n objects.forEach((obj) => this.addObject(obj));\n return this;\n }\n}\n\nexport default Collection;\n\nexport { replace, uniqBy, isCollection, objectAt, iter, findIndex, find, any, every, indexOf, removeAt, insertAt };\n","const isEmpty = (obj) => {\n const none = obj === null || obj === undefined;\n if (none) {\n return none;\n }\n\n if (typeof obj.size === 'number') {\n return !obj.size;\n }\n\n const objectType = typeof obj;\n\n if (objectType === 'object') {\n const { size } = obj;\n if (typeof size === 'number') {\n return !size;\n }\n }\n\n if (typeof obj.length === 'number' && objectType !== 'function') {\n return !obj.length;\n }\n\n if (objectType === 'object') {\n const { length } = obj;\n if (typeof length === 'number') {\n return !length;\n }\n }\n\n return false;\n};\n\nexport default isEmpty;\n","import isEmpty from './is-empty';\n\nconst isBlank = (obj) => isEmpty(obj) || (typeof obj === 'string' && /\\S/.test(obj) === false);\n\nexport default isBlank;\n","export default function isLatitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 90;\n}\n","export default function isLongitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 180 && Math.abs(coordinate) >= 90;\n}\n","import Resource from '../resource';\n\nexport default function isResource(record) {\n return record instanceof Resource;\n}\n","/**\n * Determines if environment SDK is initialized in is Node, additionally checks pass if environment is ReactNative.\n * \n * @returns boolean\n */\nconst isNodeEnvironment = () => {\n return (typeof process !== 'undefined') && (typeof process?.env === 'object' || process.release?.name?.search(/node|io.js/) !== -1) && (typeof window === 'undefined' || window?.navigator?.product === 'ReactNative');\n};\n\nexport default isNodeEnvironment;","import { lookup } from '../resolver';\nimport isNodeEnvironment from './is-node-environment';\n\nconst detectAdapter = (options = {}) => {\n if (isNodeEnvironment()) {\n return lookup('adapter', 'NodeAdapter', options);\n }\n\n return lookup('adapter', 'BrowserAdapter', options);\n}\n\nexport default detectAdapter;","const { isArray } = Array;\n\nclass GoogleAddress {\n constructor(place) {\n this.place = place;\n this.geometry = place?.geometry;\n this.components = this.parseComponents();\n this.attributes = this.parseProperties();\n }\n\n parse() {\n this.parseComponents();\n this.parseProperties();\n }\n\n parseComponents() {\n const components = (this.place?.address_components || []).reduce(function (acc, data) {\n data.types.forEach(function (type) {\n acc[type] = data;\n });\n return acc;\n }, {});\n\n return components;\n }\n\n parseProperties() {\n const attributes = {\n streetNumber: this.get('street_number'),\n streetName: this.get('route'),\n coordinates: this.geometry?.location ? Object.values(this.geometry.location) : [0, 0],\n city: this.or(['locality', 'sublocality', 'sublocality_level_1', 'neighborhood', 'administrative_area_level_3', 'administrative_area_level_2']),\n county: this.get('administrative_area_level_2'),\n stateShort: this.get('administrative_area_level_1', true),\n stateLong: this.get('administrative_area_level_1'),\n countryShort: this.get('country', true),\n country: this.get('country', true),\n countryLong: this.get('country'),\n postalCode: this.get('postal_code'),\n };\n\n attributes.address = [attributes.streetNumber, attributes.streetName].filter(Boolean).join(' ');\n\n return attributes;\n }\n\n all() {\n return this.attributes;\n }\n\n or(keys = []) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (isArray(key)) {\n const pkey = key[0];\n const short = key[1];\n\n if (this.has(pkey)) {\n return this.get(pkey, short);\n }\n\n continue;\n }\n\n if (this.has(key)) {\n return this.get(key);\n }\n }\n\n return null;\n }\n\n has(key) {\n return (key in this.components);\n }\n\n get(key, short = false) {\n if (!(key in this.components)) {\n return null;\n }\n\n return short ? this.components[key].short_name : this.components[key].long_name;\n }\n\n setAttributes(attributes = {}) {\n this.attributes = {...this.attributes, ...attributes};\n\n return this;\n }\n\n setAttribute(key, value) {\n this.attributes[key] = value;\n\n return this;\n }\n\n getAttribute(key) {\n return this.attributes[key] || null;\n }\n}\n\nexport default GoogleAddress;\n","export default class Point {\n constructor(latitude = 0, longitude = 0) {\n this.type = 'Point';\n this.coordinates = [longitude, latitude];\n }\n\n get latitude() {\n return this.coordinates[1];\n }\n\n get longitude() {\n return this.coordinates[0];\n }\n\n lat() {\n return this.latitude;\n }\n\n lng() {\n return this.longitude;\n }\n\n static fromGeoJson(json) {\n [ longitude, latitude ] = json.coordinates;\n\n return new Point(latitude, longitude);\n }\n\n serialize() {\n return {\n type: 'Point',\n coorindates: [this.lat(), this.lng()]\n };\n }\n\n toJson() {\n return this.serialize();\n }\n\n toString() {\n return `(${this.latitude}, ${this.longitude})`;\n }\n}","import isEmpty from './is-empty';\n\nconst isResource = (mixed) => typeof mixed === 'object' && !isEmpty(mixed?.attributes) && typeof mixed?.attributes === 'object';\n\nconst isCallable = (object, property) => typeof object[property] === 'function';\n\nconst getResolved = (func, path) => {\n const resolved = func();\n return Array.isArray(resolved) || typeof resolved === 'object' ? get(resolved, path) : null;\n};\n\nconst invoke = (object, method) => {\n if (typeof object[method] === 'function') {\n return object[method].bind(object);\n }\n};\n\nconst get = (object, path) => {\n let current = object;\n\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n\n if (isArray || isObject) {\n for (let i = 0; i < pathArray.length; i++) {\n if (current && current[pathArray[i]] === undefined) {\n return null;\n } else if (current) {\n current = current[pathArray[i]];\n\n // if is resource then return get on it's attributes\n if (isResource(current) && pathArray[i + 1] !== undefined) {\n const newPath = pathArray.slice(i + 1).join('.');\n\n return get(current.attributes, newPath);\n }\n\n // resolve functions and continue\n if (typeof current === 'function') {\n const newPath = pathArray.slice(i + 1).join('.');\n return getResolved(current, newPath);\n }\n }\n }\n return current;\n }\n\n if (isFunction) {\n return getResolved(object, path);\n }\n};\n\nconst getProperties = (object, properties = []) => {\n const selected = {};\n let propertyNames = arguments;\n let i = 1;\n\n if (arguments.length === 2 && Array.isArray(properties)) {\n i = 0;\n propertyNames = arguments[1];\n }\n\n for (; i < propertyNames.length; i++) {\n selected[propertyNames[i]] = get(object, propertyNames[i]);\n }\n\n return selected;\n};\n\nconst set = (object, path, value) => {\n let current = object;\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n // if is function\n if (isFunction) {\n // throw error should be object or array or object like\n }\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n const iterations = pathArray.length;\n\n if (isArray || isObject) {\n for (let i = 0; i < iterations - 1; i++) {\n if (!current[pathArray[i]]) {\n current[pathArray[i]] = {};\n }\n current = current[pathArray[i]];\n }\n\n current[pathArray[iterations - 1]] = value;\n }\n\n return value;\n};\n\nconst setProperties = (object, properties = {}) => {\n for (const property in properties) {\n set(object, property, properties[property]);\n }\n\n return object;\n};\n\nconst extend = (target, classes = []) => {\n if (arguments.length > 1) {\n classes = arguments;\n }\n for (let index = 0; index < classes.length; index++) {\n for (const property in classes[index]) {\n if (Object.prototype.hasOwnProperty.call(classes[index], property)) {\n target[property] = classes[index][property];\n }\n }\n }\n return target;\n};\n\nexport { set, get, getProperties, setProperties, extend, isCallable, invoke };\n","import { set } from './object';\n\nexport default class StoreActions {\n constructor(actions = {}, bind = null) {\n this.actions = actions;\n this.bind = bind;\n }\n\n extend(bindTo = null) {\n const binding = bindTo || this.bind;\n\n if (!binding) {\n return this;\n }\n\n if (this?.actions && typeof this.actions === 'object') {\n for (let action in this.actions) {\n const fn = this.actions[action];\n\n if (typeof fn !== 'function') {\n set(binding, action, fn);\n continue;\n }\n\n set(binding, action, fn.bind(binding));\n }\n }\n\n return this;\n }\n}\n","import Store from './store';\nimport { isEmpty } from './utils';\nimport { isArray } from './utils/array';\nimport { set, get } from './utils/object';\n\nclass Resource {\n /**\n\t * The base resource for all resources\n\n\t * @return {[type]} [description]\n\t */\n constructor(attributes = {}, adapter, resource, options = {}) {\n this.attributes = attributes;\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isDestroying = false;\n this.isReloading = false;\n this.resource = resource;\n this.options = options;\n this.version = options.version || 'v1';\n this.setAdapter(adapter);\n }\n\n /**\n * Set a new adapter to the resource instance, this will update the Store instance\n *\n * @param {Adapter} adapter\n * @return {Resource} this\n */\n setAdapter(adapter) {\n this.adapter = adapter;\n this.store = new Store(this.resource, adapter, {\n onAfterFetch: this.syncAttributes.bind(this),\n actions: this.options?.actions\n });\n\n return this;\n }\n\n /**\n * Getter for id attribute\n *\n * @var {String}\n */\n get id() {\n return this.getAttribute('id');\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n create(attributes = {}) {\n const data = this.mergeAttributes(attributes);\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.create(data).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n update(attributes = {}) {\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.update(this.attributes.id, attributes).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Deletes the resource instance on the server\n *\n * @return {[type]} [description]\n */\n destroy() {\n this.setFlags(['isLoading', 'isDestroying']);\n\n return this.store.destroy(this.attributes.id).then((response) => {\n this.setFlags(['isLoading', 'isDestroying'], false);\n\n return response;\n });\n }\n\n /**\n * Reloads the resource from the server.\n *\n * @return {[type]} [description]\n */\n reload() {\n this.setFlags(['isLoading', 'isReloading']);\n\n return this.store.findRecord(this.attributes.id).then((response) => {\n this.reset();\n\n return response;\n });\n }\n\n /**\n * Sets flag properties.\n *\n * @return this\n */\n setFlags(flags = [], state = true) {\n const validFlags = ['isLoading', 'isSaving', 'isReloading', 'isDestroying'];\n\n for(let i = 0; i < flags.length; i++) {\n const flag = flags[i];\n\n if (typeof flag !== 'string' || !validFlags.includes(flag)) {\n throw new Error(`${flag} is not a valid flag!`);\n }\n\n this[flag] = state;\n }\n\n return this;\n }\n\n /**\n * Resets tracked properties\n *\n * @return this\n */\n reset() {\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isReloading = false;\n\n return this;\n }\n\n /**\n * Emptys resource.\n *\n * @return this\n */\n empty() {\n this.reset();\n this.attribues = {};\n\n return this;\n }\n\n /**\n * Saves the resource instance on the server\n *\n * @return {[type]} [description]\n */\n save(options = {}) {\n const attributes = this.getAttributes();\n\n if (isEmpty(this.id)) {\n return this.create(attributes);\n }\n\n if (options.onlyDirty === true) {\n return this.savedirty();\n }\n\n return this.update(attributes);\n }\n\n /**\n * Saves only dirtied attributes.\n *\n * @return {[type]} [description]\n */\n saveDirty() {\n const dirtyAttributeKeys = Object.keys(this.dirtyAttributes);\n const dirtyAttributes = {};\n\n for (let i = 0; i < dirtyAttributeKeys.length; i++) {\n const key = dirtyAttributeKeys[i];\n dirtyAttributes[key] = this.getAttribute(key);\n }\n\n return this.update(dirtyAttributes);\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get createdAt() {\n return this.hasAttribute('created_at') ? new Date(this.getAttribute('created_at')) : null;\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get updatedAt() {\n return this.hasAttribute('updated_at') ? new Date(this.getAttribute('updated_at')) : null;\n }\n\n /**\n * Checks if resource is loaded from the server.\n *\n * @return {Boolean}\n */\n get isLoaded() {\n return this.hasAttributes(['created_at', 'id']);\n }\n\n /**\n * Checks if resource ihas no attributes\n *\n * @return {Boolean}\n */\n get isEmpty() {\n return Object.values(this?.attributes).length === 0;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isNew() {\n return !this.id;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isSaved() {\n return !this.isNew && this.isLoaded;\n }\n\n /**\n * Checks if resource is deleted on server.\n *\n * @return {Boolean}\n */\n get isDeleted() {\n return this.hasAttributes(['deleted', 'time']);\n }\n\n /**\n * Iterates over each attribute value and property executing a user supplied callback.\n *\n * @return {Object}\n */\n eachAttribute(callback) {\n if (typeof callback !== 'function') {\n return this;\n }\n\n Object.keys(this?.attributes ?? {}).forEach((property) => {\n const value = this.getAttribute(property);\n callback.call(this, value, property);\n });\n\n return this;\n }\n\n /**\n * Gets all changes\n *\n * @return {Object}\n */\n changes() {\n return this.changes;\n }\n\n /**\n * Gets all dirty attributes.\n *\n * @return {Object}\n */\n getDirtyAttributes() {\n return this.dirtyAttributes;\n }\n\n /**\n * Checks if property is dirty.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n isDirty(property) {\n return property in this.dirtyAttributes;\n }\n\n /**\n * Checks if any properties is dirty.\n *\n * @return {Boolean}\n */\n hasDirtyAttributes() {\n return Object.keys(this?.dirtyAttributes ?? {}).length > 0;\n }\n\n /**\n * Updates a instance property without tracking changes or dirtying attribute.\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n mutate(property, value) {\n this.attributes[property] = value;\n }\n\n /**\n * Set an instance property locally\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n setAttribute(property, value = null) {\n if (value === null && typeof property === 'object') {\n return this.setAttributes(property);\n }\n\n const previousValue = this?.attributes[property] ?? null;\n\n // use object setter\n set(this.attributes, property, value);\n set(this.dirtyAttributes, property, previousValue);\n \n // this.attributes[property] = value;\n // this.dirtyAttributes[property] = previousValue;\n\n // track changes\n if (!isArray(this?.changes[property])) {\n this.changes[property] = [];\n }\n\n this.changes[property].push({\n property,\n previousValue,\n value,\n changedAt: new Date(),\n });\n\n return this;\n }\n\n /**\n * Set multiple instance properties locally\n *\n * @param {Object} properties [description]\n */\n setAttributes(attributes = {}) {\n for (let property in attributes) {\n this.setAttribute(property, attributes[property]);\n }\n\n return this;\n }\n\n /**\n * Get an attribute\n *\n * @param {String} attribute The attribute key to get\n * @param {mixed} defaultValue The default value if no attribute value\n */\n getAttribute(attribute, defaultValue = null) {\n const value = get(this?.attributes ?? {}, attribute);\n\n if (value === undefined) {\n return defaultValue;\n }\n\n return value;\n }\n\n /**\n * Checks if attribute exists.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n hasAttribute(property) {\n if (isArray(property)) {\n const properties = property;\n const attributeKeys = Object.keys(this.attributes ?? {});\n \n return properties.every((prop) => attributeKeys.includes(prop));\n }\n\n if (!this?.attributes) {\n return false;\n }\n\n return property in this.attributes;\n }\n\n /**\n * Alias for checking if has multiple attributes.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n hasAttributes(properties = []) {\n return this.hasAttribute(properties);\n }\n\n /**\n * Returns true if attribute has value.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n isAttributeFilled(property) {\n if (isArray(property)) {\n return this.hasAttribute(property) && property.every((prop) => !isEmpty(this.getAttribute(prop)));\n }\n\n return this.hasAttribute(property) && !isEmpty(this.getAttribute(property));\n }\n\n /**\n * Get multiple attributes.\n *\n * @param {Array} properties [description]\n * @param {[type]} value [description]\n */\n getAttributes(properties) {\n const attributes = {};\n\n if (properties === null || properties === undefined) {\n return this.getAttributes(Object.keys(this.attributes));\n }\n\n if (typeof properties === 'string') {\n return this.getAttribute([...arguments]);\n }\n\n if (!isArray(properties)) {\n throw new Error('No attribute properties provided!');\n }\n\n for (let i = 0; i < properties.length; i++) {\n const property = properties[i];\n\n if (typeof property !== 'string') {\n continue;\n }\n\n let value = this.getAttribute(property);\n\n if (typeof value?.attributes === 'object' && !isArray(value?.attributes)) {\n value = value.attributes;\n }\n\n attributes[property] = value;\n }\n\n return attributes;\n }\n\n /**\n * Serialize resource to a POJO\n *\n * @returns {Object}\n */\n serialize() {\n return this.getAttributes();\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n mergeAttributes(attributes = {}) {\n const modelAttributes = this?.attributes ?? {};\n this.attributes = { ...modelAttributes, ...attributes };\n\n return this.attributes;\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n syncAttributes(json = {}) {\n this.attributes = json;\n }\n}\n\nexport default Resource;\n","import Resource from '../resource';\nimport { StoreActions } from '../utils';\n\nconst orderActions = new StoreActions({\n getDistanceAndTime: function (id, options = {}) {\n return this.adapter.get(`${this.namespace}/${id}/distance-and-time`, {}, options);\n },\n});\n\nclass Order extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'order', { actions: orderActions, ...options });\n }\n\n getDistanceAndTime() {\n return this.store.getDistanceAndTime(this.id);\n }\n}\n\nexport default Order;\n\nexport { orderActions };","import Resource from '../resource';\nimport Collection from '../utils/collection';\n\nclass Payload extends Resource {\n\tconstructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'payload', options);\n }\n\t\n /**\n\t * Attaches an entity to an existing payload and returns\n\t * the payload with the entity attached\n\t *\n\t * @param {[type]} Entity entity [description]\n\t * @return {[type]} [description]\n\t */\n attach(entity) {\n // perform op return payload\n }\n\n /**\n\t * Returns all of the entities attached to this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get entities() {\n\n }\n\n /**\n\t * Returns the dropoff for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get dropoff() {\n\n }\n\n /**\n\t * Returns the pickup for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get pickup() {\n\n }\n\n /**\n\t * Returns all the waypoints for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get waypoints() {\n return new Collection(this.waypoints);\n }\n}\n\nexport default Payload;\n","import Resource from '../resource';\n\nclass Entity extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'entity', options);\n }\n}\n\nexport default Entity;\n","import Resource from '../resource';\nimport { isResource, Point } from '../utils';\n\nclass Place extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'place', options);\n }\n\n static fromGoogleAddress(googleAddress, adapter, options = {}) {\n const [ latitude, longitude ] = googleAddress.getAttribute('coordinates');\n const attributes = {\n name: null,\n address: googleAddress.getAttribute('address'),\n location: new Point(latitude, longitude),\n street1: googleAddress.getAttribute('streetName'),\n street2: null,\n city: googleAddress.getAttribute('city'),\n province: googleAddress.getAttribute('stateLong'),\n postal_code: googleAddress.getAttribute('postalCode'),\n neighborhood: googleAddress.get('neighborhood'),\n district: googleAddress.getAttribute('county'),\n building: googleAddress.get('building'),\n country: googleAddress.getAttribute('countryShort'),\n phone: null,\n security_access_code: null\n };\n\n return new Place(attributes, adapter, options);\n }\n\n /**\n * The latitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get latitude() {\n return this.getAttribute('location', new Point())?.coordinates[1];\n }\n\n /**\n * The longitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get longitude() {\n return this.getAttribute('location', new Point())?.coordinates[0];\n }\n\n /**\n * Array coordinate pair for Place location.\n * \n * @var {Array}\n */\n get coordinates() {\n const { latitude, longitude } = this;\n\n return [ latitude, longitude ];\n }\n\n /**\n * Set the owner of the place.\n * \n * @param {Object|String} owner\n * @return {Place}\n */\n setOwner(owner) {\n if (isResource(owner)) {\n this.setAttribute('owner', owner.id);\n }\n\n if (typeof owner === 'string') {\n this.setAttribute('owner', owner);\n }\n\n return this;\n }\n}\n\nexport default Place;\n","import Place from './place';\n\nclass Waypoint extends Place {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'waypoint', options);\n }\n}\n\nexport default Waypoint;\n","import Resource from '../resource';\n\nclass TrackingStatus extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'tracking-status', options);\n }\n}\n\nexport default TrackingStatus;\n","import Resource from '../resource';\n\nclass Vehicle extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vehicle', options);\n }\n}\n\nexport default Vehicle;\n","import Resource from '../resource';\n\nclass Driver extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'driver', options);\n }\n}\n\nexport default Driver;\n","import Resource from '../resource';\n\nclass Vendor extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vendor', options);\n }\n}\n\nexport default Vendor;\n","import Resource from '../resource';\n\nclass Contact extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'contact', options);\n }\n}\n\nexport default Contact;\n","import Resource from '../resource';\n\nclass Zone extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'zone', options);\n }\n}\n\nexport default Zone;\n","import Resource from '../resource';\n\nclass ServiceArea extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-area', options);\n }\n}\n\nexport default ServiceArea;\n","import Resource from '../resource';\n\nclass ServiceRate extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-rate', options);\n }\n}\n\nexport default ServiceRate;\n","import Resource from '../resource';\n\nclass ServiceQuote extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-quote', options);\n }\n\n fromPreliminary() {\n\n }\n\n fromPayload() {\n \n }\n}\n\nexport default ServiceQuote;\n","class Adapter {\n /**\n\t * Creates a configured base adapter for Fleetbase.\n\t *\n\t * @param {Object} config Configuration options for adapter\n\t */\n constructor(config = {}) {\n this.version = config.version || 'v1';\n this.host = config.host || null;\n this.namespace = config.namespace || null;\n this.headers = config.headers || {};\n }\n}\n\nexport default Adapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\n\nclass BrowserAdapter extends Adapter {\n /**\n * Setup browser adapter.\n * @param {Object} config\n */\n constructor(config) {\n super(config);\n\n this.setHeaders({\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;browser'\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n this.headers = { ...this.headers, ...headers };\n\n return this;\n }\n\n /**\n * Parses the JSON returned by a network request\n *\n * @param {Object} response A response from a network request\n * @return {Object} The parsed JSON, status from the response\n *\n * @return {Promise}\n */\n parseJSON(response) {\n return new Promise((resolve, reject) => response\n .json()\n .then((json) => resolve({\n statusText: response.statusText,\n status: response.status,\n ok: response.ok,\n json,\n }))\n .catch(() => {\n reject(new Error('Oops! Something went wrong when handling your request.'));\n }));\n }\n\n /**\n * The base request method\n *\n * @param {String} path\n * @param {String} method\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n request(path, method = 'GET', data = {}, options = {}) {\n return new Promise((resolve, reject) => fetch(options.url || `${this.host}/${this.namespace}/${path}`, {\n method,\n mode: options.mode || 'cors',\n headers: new Headers({\n ...(this.headers || {}),\n ...(options.headers || {}),\n }),\n ...data,\n })\n .then(this.parseJSON)\n .then((response) => {\n if (response.ok) {\n return resolve(response.json);\n }\n\n return reject(new Error(response.json.errors ? response.json.errors[0] : response.statusText));\n })\n .catch((error) => {\n reject(error);\n }));\n }\n\n /**\n * Makes a GET request with fetch\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.request(`${path}${urlParams ? `?${urlParams}` : ''}`, 'GET', {}, options);\n }\n\n /**\n * Makes a POST request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.request(path, 'POST', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a PUT request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.request(path, 'PUT', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a DELETE request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.request(path, 'DELETE', {}, options);\n }\n\n /**\n * Makes a PATCH request with fetch\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.request(path, 'PATCH', { body: JSON.stringify(data) }, options);\n }\n}\n\nexport default BrowserAdapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\nimport { isArray } from '../utils/array';\nimport axios from 'axios';\n\nclass NodeAdapter extends Adapter {\n constructor(config) {\n super(config);\n\n this.axios = axios.create({\n baseURL: `${this.host}/${this.namespace}`,\n headers: {\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;node',\n },\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n const commonHeaders = this.axios.defaults.headers.common;\n this.axios.defaults.headers.common = { ...commonHeaders, ...headers };\n\n return this;\n }\n\n /**\n * Tranform the response, and return the response data from axios.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n transform(response) {\n return response.data;\n }\n\n /**\n * Handles an erroneous request.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n handleError(error) {\n if (error.response) {\n const { data } = error.response;\n\n if (isArray(data.errors)) {\n throw new Error(data.errors[0]);\n }\n\n if (data.error) {\n throw new Error(data.error);\n }\n }\n\n throw error;\n }\n\n /**\n * Makes a GET request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.axios\n .get(`${path}${urlParams ? `?${urlParams}` : ''}`, options)\n .then(this.transform.bind(this))\n .catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a POST request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.axios.post(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PUT request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.axios.put(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a DELETE request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.axios.delete(path, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PATCH request with axios\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.axios.patch(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n}\n\nexport default NodeAdapter;\n","import Adapter from '../adapter';\n\nclass EmberJsAdapter extends Adapter {}\n\nexport default EmberJsAdapter;\n","'use strict';\n\n/**\n * Javascript String\n *\n * instance\n * new String('hello_world').humanize().get() => \"Hello world\"\n *\n * instance\n * const string = new String();\n * string.humanize('hello_world').get() => \"Hello world\"\n * \n * no chain\n * new String('hello_world', false).humanize() => \"Hello world\"\n *\n * static\n * String.invoke('humanize', 'hello_world') => \"Hello world\"\n *\n * exports {}\n * humanize('hello_world') => \"Hello world\"\n */\n\nexport default class String {\n constructor(string, chain = true) {\n this.str = string;\n this.chain = chain;\n }\n\n uncountableWords = ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'moose', 'deer', 'news'];\n\n pluralRules = [\n [new RegExp('(m)an$', 'gi'), '$1en'],\n [new RegExp('(pe)rson$', 'gi'), '$1ople'],\n [new RegExp('(child)$', 'gi'), '$1ren'],\n [new RegExp('^(ox)$', 'gi'), '$1en'],\n [new RegExp('(ax|test)is$', 'gi'), '$1es'],\n [new RegExp('(octop|vir)us$', 'gi'), '$1i'],\n [new RegExp('(alias|status)$', 'gi'), '$1es'],\n [new RegExp('(bu)s$', 'gi'), '$1ses'],\n [new RegExp('(buffal|tomat|potat)o$', 'gi'), '$1oes'],\n [new RegExp('([ti])um$', 'gi'), '$1a'],\n [new RegExp('sis$', 'gi'), 'ses'],\n [new RegExp('(?:([^f])fe|([lr])f)$', 'gi'), '$1$2ves'],\n [new RegExp('(hive)$', 'gi'), '$1s'],\n [new RegExp('([^aeiouy]|qu)y$', 'gi'), '$1ies'],\n [new RegExp('(x|ch|ss|sh)$', 'gi'), '$1es'],\n [new RegExp('(matr|vert|ind)ix|ex$', 'gi'), '$1ices'],\n [new RegExp('([m|l])ouse$', 'gi'), '$1ice'],\n [new RegExp('(quiz)$', 'gi'), '$1zes'],\n [new RegExp('s$', 'gi'), 's'],\n [new RegExp('$', 'gi'), 's'],\n ];\n\n singularRules = [\n [new RegExp('(m)en$', 'gi'), '$1an'],\n [new RegExp('(pe)ople$', 'gi'), '$1rson'],\n [new RegExp('(child)ren$', 'gi'), '$1'],\n [new RegExp('([ti])a$', 'gi'), '$1um'],\n [new RegExp('((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$', 'gi'), '$1$2sis'],\n [new RegExp('(hive)s$', 'gi'), '$1'],\n [new RegExp('(tive)s$', 'gi'), '$1'],\n [new RegExp('(curve)s$', 'gi'), '$1'],\n [new RegExp('([lr])ves$', 'gi'), '$1f'],\n [new RegExp('([^fo])ves$', 'gi'), '$1fe'],\n [new RegExp('([^aeiouy]|qu)ies$', 'gi'), '$1y'],\n [new RegExp('(s)eries$', 'gi'), '$1eries'],\n [new RegExp('(m)ovies$', 'gi'), '$1ovie'],\n [new RegExp('(x|ch|ss|sh)es$', 'gi'), '$1'],\n [new RegExp('([m|l])ice$', 'gi'), '$1ouse'],\n [new RegExp('(bus)es$', 'gi'), '$1'],\n [new RegExp('(o)es$', 'gi'), '$1'],\n [new RegExp('(shoe)s$', 'gi'), '$1'],\n [new RegExp('(cris|ax|test)es$', 'gi'), '$1is'],\n [new RegExp('(octop|vir)i$', 'gi'), '$1us'],\n [new RegExp('(alias|status)es$', 'gi'), '$1'],\n [new RegExp('^(ox)en', 'gi'), '$1'],\n [new RegExp('(vert|ind)ices$', 'gi'), '$1ex'],\n [new RegExp('(matr)ices$', 'gi'), '$1ix'],\n [new RegExp('(quiz)zes$', 'gi'), '$1'],\n [new RegExp('s$', 'gi'), ''],\n ];\n\n nonTitlecasedWords = ['and', 'or', 'nor', 'a', 'an', 'the', 'so', 'but', 'to', 'of', 'at', 'by', 'from', 'into', 'on', 'onto', 'off', 'out', 'in', 'over', 'with', 'for'];\n\n idSuffix = new RegExp('(_ids|_id)$', 'g');\n underbar = new RegExp('_', 'g');\n spaceOrUnderbar = new RegExp('[ _]', 'g');\n uppercase = new RegExp('([A-Z])', 'g');\n underbarPrefix = new RegExp('^_');\n\n get() {\n return this.str;\n }\n\n applyRules(str, rules, skip, override) {\n if (override) {\n str = override;\n } else {\n var ignore = skip.indexOf(str.toLowerCase()) > -1;\n if (!ignore) {\n for (var x = 0; x < rules.length; x++) {\n if (str.match(rules[x][0])) {\n str = str.replace(rules[x][0], rules[x][1]);\n break;\n }\n }\n }\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.pluralize('person') -> 'people'\n String.pluralize('octopus') -> 'octopi'\n String.pluralize('Hat') -> 'Hats'\n String.pluralize('person', 'guys') -> 'guys' \n */\n pluralize(str, plural = null) {\n str = str || this.str;\n\n return this.applyRules(str, this.pluralRules, this.uncountableWords, plural);\n }\n\n /*\n String.singularize('person') -> 'person'\n String.singularize('octopi') -> 'octopus'\n String.singularize('hats') -> 'hat'\n String.singularize('guys', 'person') -> 'person'\n */\n singularize(str, singular) {\n str = str || this.str;\n\n return this.applyRules(str, this.singularRules, this.uncountableWords, singular);\n }\n\n /*\n String.camelize('message_properties') -> 'MessageProperties'\n String.camelize('message_properties', true) -> 'messageProperties'\n */\n camelize(str, lowFirstLetter) {\n str = str || this.str;\n\n let str_path = str.split('/');\n for (var i = 0; i < str_path.length; i++) {\n let str_arr = str_path[i].split('_');\n let initX = lowFirstLetter && i + 1 === str_path.length ? 1 : 0;\n\n for (let x = initX; x < str_arr.length; x++) {\n str_arr[x] = str_arr[x].charAt(0).toUpperCase() + str_arr[x].substring(1);\n }\n str_path[i] = str_arr.join('');\n }\n str = str_path.join('::');\n\n // fix\n if (lowFirstLetter === true) {\n let first = str.charAt(0).toLowerCase();\n let last = str.slice(1);\n str = first + last;\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.underscore('MessageProperties') -> 'message_properties'\n String.underscore('messageProperties') -> 'message_properties'\n */\n underscore(str) {\n str = str || this.str;\n\n var str_path = str.split('::');\n for (var i = 0; i < str_path.length; i++) {\n str_path[i] = str_path[i].replace(this.uppercase, '_$1');\n str_path[i] = str_path[i].replace(this.underbarPrefix, '');\n }\n str = str_path.join('/').toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.humanize('message_properties') -> 'Message properties'\n String.humanize('message_properties') -> 'message properties'\n */\n humanize(str, lowFirstLetter) {\n str = str || this.str;\n\n var str = str.toLowerCase();\n str = str.replace(this.idSuffix, '');\n str = str.replace(this.underbar, ' ');\n if (!lowFirstLetter) {\n str = this.capitalize(str);\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.capitalize('message_properties') -> 'Message_properties'\n String.capitalize('message properties') -> 'Message properties'\n */\n capitalize(str) {\n str = str || this.str;\n\n str = str.toLowerCase();\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.dasherize('message_properties') -> 'message-properties'\n String.dasherize('message properties') -> 'message-properties'\n */\n dasherize(str) {\n str = str || this.str;\n\n str = str.replace(this.spaceOrUnderbar, '-');\n str = str.toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.normify('message_properties') -> 'Message Properties'\n String.normify('message properties') -> 'Message Properties'\n Inflactor.normify('Message_propertyId', true) -> 'Message Properties Id'\n */\n normify(str, allFirstUpper) {\n str = str || this.str;\n\n //var str = str.toLowerCase();\n if (allFirstUpper === true) {\n str = this.camelize(str);\n str = this.underscore(str);\n } else {\n str = str.toLowerCase();\n }\n\n str = str.replace(this.underbar, ' ');\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var d = str_arr[x].split('-');\n for (var i = 0; i < d.length; i++) {\n if (this.nonTitlecasedWords.indexOf(d[i].toLowerCase()) < 0) {\n d[i] = this.capitalize(d[i]);\n }\n }\n str_arr[x] = d.join('-');\n }\n str = str_arr.join(' ');\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.demodulize('Message::Bus::Properties') -> 'Properties'\n */\n demodulize(str) {\n str = str || this.str;\n\n var str_arr = str.split('::');\n str = str_arr[str_arr.length - 1];\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.tableize('MessageBusProperty') -> 'message_bus_properties'\n */\n tableize(str) {\n str = str || this.str;\n\n str = this.pluralize(this.underscore(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.classify('message_bus_properties') -> 'MessageBusProperty'\n */\n classify(str) {\n str = str || this.str;\n\n str = this.singularize(this.camelize(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.foreignKey('MessageBusProperty') -> 'message_bus_property_id'\n String.foreignKey('MessageBusProperty', true) -> 'message_bus_propertyid'\n */\n foreignKey(str, dropIdUbar = false) {\n str = str || this.str;\n\n str = this.underscore(this.demodulize(str)) + (dropIdUbar ? '' : '_') + 'id';\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.ordinalize('the 1 pitch') -> 'the 1st pitch'\n */\n ordinalize(str) {\n str = str || this.str;\n\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var i = parseInt(str_arr[x]);\n if (i === NaN) {\n var ltd = str_arr[x].substring(str_arr[x].length - 2);\n var ld = str_arr[x].substring(str_arr[x].length - 1);\n var suf = 'th';\n if (ltd != '11' && ltd != '12' && ltd != '13') {\n if (ld === '1') {\n suf = 'st';\n } else if (ld === '2') {\n suf = 'nd';\n } else if (ld === '3') {\n suf = 'rd';\n }\n }\n str_arr[x] += suf;\n }\n }\n str = str_arr.join(' ');\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /**\n * @method invoke\n **/\n static invoke() {\n const argz = Object.values(arguments);\n const instance = new String(null, false);\n const method = arguments[0];\n argz.shift();\n\n if (typeof instance[method] === 'function') {\n return instance[method](...argz);\n }\n\n return null;\n }\n}\n\nconst pluralize = function() {\n const argz = ['pluralize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst singularize = function() {\n const argz = ['singularize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst humanize = function() {\n const argz = ['humanize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst underscore = function() {\n const argz = ['underscore', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst camelize = function() {\n const argz = ['camelize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst capitalize = function() {\n const argz = ['capitalize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst dasherize = function() {\n const argz = ['dasherize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst normify = function() {\n const argz = ['normify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst demodulize = function() {\n const argz = ['demodulize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst tableize = function() {\n const argz = ['tableize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst classify = function() {\n const argz = ['classify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst foreignKey = function() {\n const argz = ['foreignKey', ...arguments];\n\n return String.invoke(...argz);\n};\n\nexport {\n pluralize,\n singularize,\n humanize,\n underscore,\n camelize,\n capitalize,\n dasherize,\n normify,\n demodulize,\n tableize,\n classify,\n foreignKey\n}","import { Place, Payload, Order } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter } from './adapters';\nimport { pluralize, singularize } from './utils/string';\n\nconst resources = {\n Place,\n Payload,\n Order\n};\n\nconst adapters = {\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter\n};\n\nclass Resolver {\n constructor () {\n this.resources = resources;\n this.adapters = adapters;\n\n return this.lookup(...arguments);\n }\n\n lookup(type, className) {\n const key = pluralize(type);\n const params = [ ...arguments ].slice(2);\n\n if (!this[key]) {\n throw new Error('Attempted to resolve invalid type');\n }\n\n if (!this[key][className]) {\n throw new Error(`No ${singularize(type)} named ${className} to resolve`);\n }\n\n return new this[key][className](...params);\n }\n}\n\nconst lookup = function() {\n return new Resolver(...arguments);\n};\n\nexport {\n Resolver,\n lookup\n};\n","import { lookup } from './resolver';\nimport { pluralize, classify } from './utils/string';\nimport { isArray } from './utils/array';\nimport { Collection, detectAdapter, isResource, StoreActions } from './utils';\nimport { set, isCallable, invoke } from './utils/object';\n\nconst extendStoreActions = (store, actions = []) => {\n store.actions = isArray(actions) ? actions : [actions];\n\n if (isArray(actions)) {\n for (let i = 0; i < actions.length; i++) {\n const action = actions[i];\n\n store.extendActions(action);\n }\n return;\n }\n\n if (actions instanceof StoreActions) {\n actions.extend(store);\n }\n\n return store;\n};\n\nconst afterFetch = (store, json) => {\n if (typeof store.options.onAfterFetch === 'function') {\n store.options.onAfterFetch(json);\n }\n\n if (isArray(json)) {\n const serialized = [];\n\n for (let i = 0; i < json.length; i++) {\n serialized.push(store.afterFetch(json[i]));\n }\n\n return new Collection(...serialized);\n }\n\n const resourceInstance = store.serialize(json);\n return store.deposit(resourceInstance);\n};\n\nclass Store {\n constructor(resource, adapter, options = {}) {\n this.resource = resource;\n this.adapter = adapter || detectAdapter();\n this.namespace = pluralize(resource);\n this.storage = new Collection();\n this.options = options;\n this.extendActions(options.actions);\n }\n\n extendActions(actions = []) {\n return extendStoreActions(this, actions);\n }\n\n deposit(resourceInstance) {\n // this.storage[this.namespace].pushObject(resourceInstance);\n\n return resourceInstance;\n }\n\n serialize(json) {\n return lookup('resource', classify(this.resource), json, this.adapter);\n }\n\n afterFetch(json) {\n return afterFetch(this, json);\n }\n\n create(attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.post(`${this.namespace}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n update(id, attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.put(`${this.namespace}/${id}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findRecord(id, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findAll(options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n query(query = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n queryRecord(query = {}, options = {}) {\n query.single = true;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n destroy(record, options = {}) {\n const id = isResource(record) ? record.getAttribute('id') : record;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.delete(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n}\n\nexport default Store;\n\nexport { extendStoreActions, afterFetch };\n","import Store from './store';\nimport Resource from './resource';\nimport { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter, Adapter } from './adapters';\nimport { isNodeEnvironment, detectAdapter, isLatitude, isLongitude, Point, isResource, GoogleAddress, Collection, StoreActions } from './utils';\nimport { pluralize, singularize, classify, dasherize, camelize } from './utils/string';\nimport { extendStoreActions } from './store';\nimport { orderActions } from './resources/order';\n\n/**\n * // instance\n * const fleetbase = new Fleetbase();\n *\n * const contact = fleetbase.contacts.create({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * constact.update({ name: 'Hollywood Ron' });\n *\n * // export\n * import { Contact } from '@fleetbase/sdk';\n *\n * const contact = new Contact({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * contact.save();\n */\n\nexport default class Fleetbase {\n /**\n * Builds an instance of the Fleetbase SDK\n *\n * @param {String} publicKey The public key issued\n * @param {Object} config The version of resource to access\n * @param {Boolean} debug Debug mode for SDK\n * @return {Fleetbase} Instance\n */\n constructor(publicKey, config = {}, debug = false) {\n this.version = config.version || 'v1';\n this.options = {\n version: this.version,\n host: config.host || 'https://api.fleetbase.io',\n namespace: this.version || config.namespace,\n debug,\n publicKey,\n };\n\n if (typeof publicKey !== 'string' || publicKey.length === 0) {\n throw new Error('⚠️ Invalid public key given to Fleetbase SDK');\n }\n\n if (!isNodeEnvironment() && publicKey.toLowerCase().startsWith('$')) {\n throw new Error('Secret key provided. You must use a public key with Fleetbase Javascript SDK!');\n }\n\n this.adapter = config.adapter || detectAdapter(this.options);\n\n this.orders = new Store('order', this.adapter).extendActions(orderActions);\n this.entities = new Store('entity', this.adapter);\n this.places = new Store('place', this.adapter);\n this.drivers = new Store('driver', this.adapter);\n this.vehicles = new Store('vehicle', this.adapter);\n this.vendors = new Store('vendor', this.adapter);\n this.contacts = new Store('contact', this.adapter);\n }\n\n static newInstance() {\n return new Fleetbase(...arguments);\n }\n\n setAdapter(adapter) {\n this.adapter = adapter;\n }\n\n getAdapter() {\n return this.adapter;\n }\n}\n\nexport {\n Store,\n Resource,\n Contact,\n Driver,\n Entity,\n Order,\n Payload,\n Place,\n TrackingStatus,\n Vehicle,\n Vendor,\n Waypoint,\n Zone,\n ServiceArea,\n ServiceRate,\n ServiceQuote,\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter,\n Adapter,\n isNodeEnvironment,\n isLatitude,\n isLongitude,\n Point,\n isResource,\n GoogleAddress,\n Collection,\n StoreActions,\n extendStoreActions,\n pluralize,\n singularize,\n classify,\n dasherize,\n camelize,\n};\n"],"names":["isArray","Array","CHUNK_SIZE","replace","array","start","deleteCount","items","length","splice","i","chunk","slice","isCollection","arr","identityFunction","item","uniqBy","key","ret","seen","Set","getter","get","forEach","val","has","add","push","mixed","Collection","objectAt","index","iter","value","arguments","Boolean","findIndex","predicate","startAt","len","find","callback","target","bind","undefined","any","every","cb","indexOf","withNaNCheck","removeAt","insertAt","this","indexes","map","idx","_this2","object","methodName","args","_item$methodName","filter","sortKeys","sort","a","b","propA","propB","compareValue","compare","includes","obj","objects","toArray","reverse","clear","loc","removeObject","pushObject","_this3","addObject","isEmpty","none","size","objectType","isBlank","test","isLatitude","coordinate","isFinite","Math","abs","isLongitude","isResource","record","Resource","isNodeEnvironment","process","_typeof","_process","env","release","name","search","window","navigator","product","detectAdapter","options","lookup","GoogleAddress","place","geometry","components","parseComponents","attributes","parseProperties","address_components","reduce","acc","data","types","type","streetNumber","streetName","coordinates","location","Object","values","city","or","county","stateShort","stateLong","countryShort","country","countryLong","postalCode","address","join","keys","pkey","short","short_name","long_name","Point","latitude","longitude","coorindates","lat","lng","serialize","json","getResolved","func","path","resolved","current","isObject","isFunction","pathArray","split","newPath","set","iterations","StoreActions","actions","bindTo","binding","action","fn","adapter","resource","dirtyAttributes","changes","isLoading","isSaving","isDestroying","isReloading","version","setAdapter","store","Store","onAfterFetch","syncAttributes","_this$options","getAttribute","mergeAttributes","setFlags","create","then","response","_this","update","id","destroy","findRecord","_this4","reset","flags","state","validFlags","flag","Error","attribues","getAttributes","onlyDirty","savedirty","dirtyAttributeKeys","hasAttribute","Date","hasAttributes","isNew","isLoaded","property","_this5","call","setAttributes","previousValue","changedAt","setAttribute","attribute","defaultValue","properties","attributeKeys","prop","_this6","_value","_value2","modelAttributes","orderActions","getDistanceAndTime","namespace","Order","Payload","entity","waypoints","Entity","Place","_this$getAttribute","_this$getAttribute2","owner","googleAddress","street1","street2","province","postal_code","neighborhood","district","building","phone","security_access_code","Waypoint","TrackingStatus","Vehicle","Driver","Vendor","Contact","Zone","ServiceArea","ServiceRate","ServiceQuote","Adapter","config","host","headers","BrowserAdapter","setHeaders","Authorization","publicKey","Promise","resolve","reject","statusText","status","ok","method","fetch","url","mode","Headers","parseJSON","errors","error","query","urlParams","URLSearchParams","toString","request","body","JSON","stringify","NodeAdapter","axios","baseURL","commonHeaders","defaults","common","transform","handleError","post","put","patch","EmberJsAdapter","String","string","chain","RegExp","str","rules","skip","override","toLowerCase","x","match","plural","applyRules","pluralRules","uncountableWords","singular","singularRules","lowFirstLetter","str_path","str_arr","charAt","toUpperCase","substring","first","last","uppercase","underbarPrefix","idSuffix","underbar","capitalize","spaceOrUnderbar","allFirstUpper","camelize","underscore","d","nonTitlecasedWords","pluralize","singularize","dropIdUbar","demodulize","NaN","parseInt","ltd","ld","suf","argz","instance","shift","invoke","dasherize","classify","resources","adapters","Resolver","className","params","extendStoreActions","extend","extendActions","afterFetch","serialized","resourceInstance","deposit","storage","single","_this7","Fleetbase","debug","startsWith","orders","entities","places","drivers","vehicles","vendors","contacts"],"mappings":"66JAAA,IAAQA,EAAYC,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G,cAAQc,yDAAU,GAChBsF,EAAKrG,GAAWC,GAAUA,EAAO4F,aAAa,MAAQ5F,SAErD,IAAIgL,oDAAQ,WAAOC,EAASC,yGACRiG,EAAKtM,yBAAkBsM,EAAKzI,sBAAatC,GAAM,GAAItF,GAASkF,KAAKmL,EAAKN,WAAWhU,KAAKsU,UAAajG,UAApHjF,SAENgF,EAAQhF,gHCjGCmL,yBASLrG,OAAWN,yDAAS,GAAI4G,4EAC3BhM,QAAUoF,EAAOpF,SAAW,UAC5BvE,QAAU,CACXuE,QAAS/H,KAAK+H,QACdqF,KAAMD,EAAOC,MAAQ,2BACrBhC,UAAWpL,KAAK+H,SAAWoF,EAAO/B,UAClC2I,MAAAA,EACAtG,UAAAA,GAGqB,iBAAdA,GAA+C,IAArBA,EAAUtQ,aACrC,IAAIoM,MAAM,oDAGf3G,MAAuB6K,EAAU2C,cAAc4D,WAAW,WACrD,IAAIzK,MAAM,sFAGfhC,QAAU4F,EAAO5F,SAAWhE,GAAcvD,KAAKwD,cAE/CyQ,OAAS,IAAI/L,GAAM,QAASlI,KAAKuH,SAAS+L,cAAcpI,SACxDgJ,SAAW,IAAIhM,GAAM,SAAUlI,KAAKuH,cACpC4M,OAAS,IAAIjM,GAAM,QAASlI,KAAKuH,cACjC6M,QAAU,IAAIlM,GAAM,SAAUlI,KAAKuH,cACnC8M,SAAW,IAAInM,GAAM,UAAWlI,KAAKuH,cACrC+M,QAAU,IAAIpM,GAAM,SAAUlI,KAAKuH,cACnCgN,SAAW,IAAIrM,GAAM,UAAWlI,KAAKuH,6CAO9C,SAAWA,QACFA,QAAUA,4BAGnB,kBACWvH,KAAKuH,qCAThB,oBACeuM,6BAAahV"} \ No newline at end of file +{"version":3,"file":"sdk.min.js","sources":["../../src/utils/array.js","../../src/utils/collection.js","../../src/utils/is-empty.js","../../src/utils/is-blank.js","../../src/utils/is-latitude.js","../../src/utils/is-longitude.js","../../src/utils/is-resource.js","../../src/utils/is-phone.js","../../src/utils/is-node-environment.js","../../src/utils/detect-adapter.js","../../src/utils/google-address.js","../../src/utils/point.js","../../src/utils/object.js","../../src/utils/store-actions.js","../../src/resource.js","../../src/resources/order.js","../../src/resources/payload.js","../../src/resources/entity.js","../../src/resources/place.js","../../src/resources/waypoint.js","../../src/resources/tracking-status.js","../../src/resources/vehicle.js","../../src/resources/driver.js","../../src/resources/vendor.js","../../src/resources/contact.js","../../src/resources/zone.js","../../src/resources/service-area.js","../../src/resources/service-rate.js","../../src/resources/service-quote.js","../../src/adapter.js","../../src/adapters/browser.js","../../src/adapters/node.js","../../src/adapters/ember.js","../../src/utils/string.js","../../src/resolver.js","../../src/store.js","../../src/fleetbase.js"],"sourcesContent":["const { isArray } = Array;\n\nexport {\n isArray\n};\n","import { isArray } from './array';\n\n/**\n * Collection\n * Extended array inspired by Ember's NativeArray\n **/\n\nconst CHUNK_SIZE = 60000;\n\n// To avoid overflowing the stack, we splice up to CHUNK_SIZE items at a time.\n// See https://code.google.com/p/chromium/issues/detail?id=56588 for more details.\nconst replace = (array, start, deleteCount, items = []) => {\n if (isArray(array)) {\n if (items.length <= CHUNK_SIZE) {\n array.splice(start, deleteCount, ...items);\n } else {\n array.splice(start, deleteCount);\n\n for (let i = 0; i < items.length; i += CHUNK_SIZE) {\n let chunk = items.slice(i, i + CHUNK_SIZE);\n array.splice(start + i, 0, ...chunk);\n }\n }\n } else if (isCollection(arr)) {\n array.replace(start, deleteCount, items);\n }\n};\n\nconst identityFunction = (item) => item;\n\nconst uniqBy = (array, key = identityFunction) => {\n let ret = [];\n let seen = new Set();\n let getter = typeof key === 'function' ? key : (item) => get(item, key);\n\n array.forEach((item) => {\n let val = getter(item);\n if (!seen.has(val)) {\n seen.add(val);\n ret.push(item);\n }\n });\n\n return ret;\n};\n\nconst isCollection = (mixed) => mixed instanceof Collection;\n\nconst objectAt = (array, index) => {\n if (isArray(array)) {\n return array[index];\n } else if (isCollection(array)) {\n return array.objectAt(index);\n }\n\n return null;\n};\n\nconst iter = (key, value) => {\n let valueProvided = arguments.length === 2;\n return valueProvided ? (item) => value === item[key] : (item) => Boolean(item[key]);\n};\n\nconst findIndex = (array, predicate, startAt = 0) => {\n let len = array.length;\n for (let index = startAt; index < len; index++) {\n let item = objectAt(array, index);\n if (predicate(item, index, array)) {\n return index;\n }\n }\n return -1;\n};\n\nconst find = (array, callback, target) => {\n let predicate = callback.bind(target);\n let index = findIndex(array, predicate, 0);\n return index === -1 ? undefined : objectAt(array, index);\n};\n\nconst any = (array, callback, target) => {\n let predicate = callback.bind(target);\n return findIndex(array, predicate, 0) !== -1;\n};\n\nconst every = (array, callback, target) => {\n let cb = callback.bind(target);\n let predicate = (item, index, array) => !cb(item, index, array);\n return findIndex(array, predicate, 0) === -1;\n};\n\nconst indexOf = (array, val, startAt = 0, withNaNCheck) => {\n let len = array.length;\n\n if (startAt < 0) {\n startAt += len;\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = withNaNCheck && val !== val ? (item) => item !== item : (item) => item === val;\n return findIndex(array, predicate, startAt);\n};\n\nconst removeAt = (array, index, len = 1) => {\n replace(array, index, len, []);\n return array;\n};\n\nconst insertAt = (array, index, item) => {\n replace(array, index, 0, [item]);\n return item;\n};\n\nclass Collection extends Array {\n constructor(...items) {\n if (isArray(arguments[0])) {\n super(...arguments[0]);\n } else {\n super(...arguments);\n }\n }\n\n get notEmpty() {\n return this.length > 0;\n }\n\n get empty() {\n return this.length === 0;\n }\n\n get first() {\n return objectAt(this, 0);\n }\n\n get last() {\n return objectAt(this, this.length - 1);\n }\n\n replace(start, deleteCount, items = []) {\n replace(this, start, deleteCount, items);\n\n return this;\n }\n\n objectsAt(indexes) {\n return indexes.map((idx) => objectAt(this, idx));\n }\n\n objectAt(index) {\n return objectAt(this, index);\n }\n\n indexOf(object, startAt) {\n return indexOf(this, object, startAt, false);\n }\n\n lastIndexOf(object, startAt) {\n let len = this.length;\n\n if (startAt === undefined || startAt >= len) {\n startAt = len - 1;\n }\n\n if (startAt < 0) {\n startAt += len;\n }\n\n for (let idx = startAt; idx >= 0; idx--) {\n if (objectAt(this, idx) === object) {\n return idx;\n }\n }\n\n return -1;\n }\n\n includes(object, startAt) {\n return indexOf(this, object, startAt, true) !== -1;\n }\n\n findBy() {\n return find(this, iter(...arguments));\n }\n\n findIndexBy() {\n return findIndex(this, iter(...arguments));\n }\n\n isEvery() {\n return every(this, iter(...arguments));\n }\n\n isAny() {\n return any(this, iter(...arguments));\n }\n\n invoke(methodName, ...args) {\n let ret = [];\n\n this.forEach((item) => ret.push(item[methodName]?.(...args)));\n\n return ret;\n }\n\n toArray() {\n return this.map((item) => item);\n }\n\n compact() {\n return this.filter((value) => value != null);\n }\n\n sortBy() {\n let sortKeys = arguments;\n\n return this.sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n let key = sortKeys[i];\n let propA = a[key];\n let propB = b[key];\n // return 1 or -1 else continue to the next sortKey\n let compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n }\n\n uniqBy(key) {\n return uniqBy(this, key);\n }\n\n without(value) {\n if (!this.includes(value)) {\n return this; // nothing to do\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = value === value ? (item) => item !== value : (item) => item === item;\n return this.filter(predicate);\n }\n\n clear() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n this.replace(0, len, []);\n return this;\n }\n\n insertAt(idx, object) {\n insertAt(this, idx, object);\n return this;\n }\n\n replaceAt(idx, object) {\n return this.replace(idx, 1, [object]);\n }\n\n removeAt(start, len) {\n return removeAt(this, start, len);\n }\n\n pushObject(obj) {\n return this.insertAt(this.length, obj);\n }\n\n pushObjects(objects) {\n this.replace(this.length, 0, objects);\n return this;\n }\n\n popObject() {\n let len = this.length;\n if (len === 0) {\n return null;\n }\n\n let ret = objectAt(this, len - 1);\n this.removeAt(len - 1, 1);\n return ret;\n }\n\n shiftObject() {\n if (this.length === 0) {\n return null;\n }\n\n let ret = objectAt(this, 0);\n this.removeAt(0);\n return ret;\n }\n\n unshiftObject(obj) {\n return insertAt(this, 0, obj);\n }\n\n unshiftObjects(objects) {\n this.replace(0, 0, objects);\n return this;\n }\n\n reverseObjects() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n let objects = this.toArray().reverse();\n this.replace(0, len, objects);\n return this;\n }\n\n setObjects(objects) {\n if (objects.length === 0) {\n return this.clear();\n }\n\n let len = this.length;\n this.replace(0, len, objects);\n return this;\n }\n\n removeObject(obj) {\n let loc = this.length || 0;\n while (--loc >= 0) {\n let curObject = objectAt(this, loc);\n\n if (curObject === obj) {\n this.removeAt(loc);\n }\n }\n return this;\n }\n\n removeObjects(objects) {\n for (let i = objects.length - 1; i >= 0; i--) {\n this.removeObject(objects[i]);\n }\n\n return this;\n }\n\n addObject(obj) {\n let included = this.includes(obj);\n\n if (!included) {\n this.pushObject(obj);\n }\n\n return this;\n }\n\n addObjects(objects) {\n objects.forEach((obj) => this.addObject(obj));\n return this;\n }\n}\n\nexport default Collection;\n\nexport { replace, uniqBy, isCollection, objectAt, iter, findIndex, find, any, every, indexOf, removeAt, insertAt };\n","const isEmpty = (obj) => {\n const none = obj === null || obj === undefined;\n if (none) {\n return none;\n }\n\n if (typeof obj.size === 'number') {\n return !obj.size;\n }\n\n const objectType = typeof obj;\n\n if (objectType === 'object') {\n const { size } = obj;\n if (typeof size === 'number') {\n return !size;\n }\n }\n\n if (typeof obj.length === 'number' && objectType !== 'function') {\n return !obj.length;\n }\n\n if (objectType === 'object') {\n const { length } = obj;\n if (typeof length === 'number') {\n return !length;\n }\n }\n\n return false;\n};\n\nexport default isEmpty;\n","import isEmpty from './is-empty';\n\nconst isBlank = (obj) => isEmpty(obj) || (typeof obj === 'string' && /\\S/.test(obj) === false);\n\nexport default isBlank;\n","export default function isLatitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 90;\n}\n","export default function isLongitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 180 && Math.abs(coordinate) >= 90;\n}\n","import Resource from '../resource';\n\nexport default function isResource(record) {\n return record instanceof Resource;\n}\n","const isPhone = (phone = '') => {\n return /^[+]?[\\s./0-9]*[(]?[0-9]{1,4}[)]?[-\\s./0-9]*$/g.test(phone);\n}\n\nexport default isPhone;","/**\n * Determines if environment SDK is initialized in is Node, additionally checks pass if environment is ReactNative.\n * \n * @returns boolean\n */\nconst isNodeEnvironment = () => {\n return (typeof process !== 'undefined') && (typeof process?.env === 'object' || process.release?.name?.search(/node|io.js/) !== -1) && (typeof window === 'undefined' || window?.navigator?.product === 'ReactNative');\n};\n\nexport default isNodeEnvironment;","import { lookup } from '../resolver';\nimport isNodeEnvironment from './is-node-environment';\n\nconst detectAdapter = (options = {}) => {\n if (isNodeEnvironment()) {\n return lookup('adapter', 'NodeAdapter', options);\n }\n\n return lookup('adapter', 'BrowserAdapter', options);\n}\n\nexport default detectAdapter;","const { isArray } = Array;\n\nclass GoogleAddress {\n constructor(place) {\n this.place = place;\n this.geometry = place?.geometry;\n this.components = this.parseComponents();\n this.attributes = this.parseProperties();\n }\n\n parse() {\n this.parseComponents();\n this.parseProperties();\n }\n\n parseComponents() {\n const components = (this.place?.address_components || []).reduce(function (acc, data) {\n data.types.forEach(function (type) {\n acc[type] = data;\n });\n return acc;\n }, {});\n\n return components;\n }\n\n parseProperties() {\n const attributes = {\n streetNumber: this.get('street_number'),\n streetName: this.get('route'),\n coordinates: this.geometry?.location ? Object.values(this.geometry.location) : [0, 0],\n city: this.or(['locality', 'sublocality', 'sublocality_level_1', 'neighborhood', 'administrative_area_level_3', 'administrative_area_level_2']),\n county: this.get('administrative_area_level_2'),\n stateShort: this.get('administrative_area_level_1', true),\n stateLong: this.get('administrative_area_level_1'),\n countryShort: this.get('country', true),\n country: this.get('country', true),\n countryLong: this.get('country'),\n postalCode: this.get('postal_code'),\n };\n\n attributes.address = [attributes.streetNumber, attributes.streetName].filter(Boolean).join(' ');\n\n return attributes;\n }\n\n all() {\n return this.attributes;\n }\n\n or(keys = []) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (isArray(key)) {\n const pkey = key[0];\n const short = key[1];\n\n if (this.has(pkey)) {\n return this.get(pkey, short);\n }\n\n continue;\n }\n\n if (this.has(key)) {\n return this.get(key);\n }\n }\n\n return null;\n }\n\n has(key) {\n return (key in this.components);\n }\n\n get(key, short = false) {\n if (!(key in this.components)) {\n return null;\n }\n\n return short ? this.components[key].short_name : this.components[key].long_name;\n }\n\n setAttributes(attributes = {}) {\n this.attributes = {...this.attributes, ...attributes};\n\n return this;\n }\n\n setAttribute(key, value) {\n this.attributes[key] = value;\n\n return this;\n }\n\n getAttribute(key) {\n return this.attributes[key] || null;\n }\n}\n\nexport default GoogleAddress;\n","export default class Point {\n constructor(latitude = 0, longitude = 0) {\n this.type = 'Point';\n this.coordinates = [longitude, latitude];\n }\n\n get latitude() {\n return this.coordinates[1];\n }\n\n get longitude() {\n return this.coordinates[0];\n }\n\n lat() {\n return this.latitude;\n }\n\n lng() {\n return this.longitude;\n }\n\n static fromGeoJson(json) {\n [ longitude, latitude ] = json.coordinates;\n\n return new Point(latitude, longitude);\n }\n\n serialize() {\n return {\n type: 'Point',\n coorindates: [this.lat(), this.lng()]\n };\n }\n\n toJson() {\n return this.serialize();\n }\n\n toString() {\n return `(${this.latitude}, ${this.longitude})`;\n }\n}","import isEmpty from './is-empty';\n\nconst isResource = (mixed) => typeof mixed === 'object' && !isEmpty(mixed?.attributes) && typeof mixed?.attributes === 'object';\n\nconst isCallable = (object, property) => typeof object[property] === 'function';\n\nconst getResolved = (func, path) => {\n const resolved = func();\n return Array.isArray(resolved) || typeof resolved === 'object' ? get(resolved, path) : null;\n};\n\nconst invoke = (object, method) => {\n if (typeof object[method] === 'function') {\n return object[method].bind(object);\n }\n};\n\nconst get = (object, path) => {\n let current = object;\n\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n\n if (isArray || isObject) {\n for (let i = 0; i < pathArray.length; i++) {\n if (current && current[pathArray[i]] === undefined) {\n return null;\n } else if (current) {\n current = current[pathArray[i]];\n\n // if is resource then return get on it's attributes\n if (isResource(current) && pathArray[i + 1] !== undefined) {\n const newPath = pathArray.slice(i + 1).join('.');\n\n return get(current.attributes, newPath);\n }\n\n // resolve functions and continue\n if (typeof current === 'function') {\n const newPath = pathArray.slice(i + 1).join('.');\n return getResolved(current, newPath);\n }\n }\n }\n return current;\n }\n\n if (isFunction) {\n return getResolved(object, path);\n }\n};\n\nconst getProperties = (object, properties = []) => {\n const selected = {};\n let propertyNames = arguments;\n let i = 1;\n\n if (arguments.length === 2 && Array.isArray(properties)) {\n i = 0;\n propertyNames = arguments[1];\n }\n\n for (; i < propertyNames.length; i++) {\n selected[propertyNames[i]] = get(object, propertyNames[i]);\n }\n\n return selected;\n};\n\nconst set = (object, path, value) => {\n let current = object;\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n // if is function\n if (isFunction) {\n // throw error should be object or array or object like\n }\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n const iterations = pathArray.length;\n\n if (isArray || isObject) {\n for (let i = 0; i < iterations - 1; i++) {\n if (!current[pathArray[i]]) {\n current[pathArray[i]] = {};\n }\n current = current[pathArray[i]];\n }\n\n current[pathArray[iterations - 1]] = value;\n }\n\n return value;\n};\n\nconst setProperties = (object, properties = {}) => {\n for (const property in properties) {\n set(object, property, properties[property]);\n }\n\n return object;\n};\n\nconst extend = (target, classes = []) => {\n if (arguments.length > 1) {\n classes = arguments;\n }\n for (let index = 0; index < classes.length; index++) {\n for (const property in classes[index]) {\n if (Object.prototype.hasOwnProperty.call(classes[index], property)) {\n target[property] = classes[index][property];\n }\n }\n }\n return target;\n};\n\nexport { set, get, getProperties, setProperties, extend, isCallable, invoke };\n","import { set } from './object';\n\nexport default class StoreActions {\n constructor(actions = {}, bind = null) {\n this.actions = actions;\n this.bind = bind;\n }\n\n extend(bindTo = null) {\n const binding = bindTo || this.bind;\n\n if (!binding) {\n return this;\n }\n\n if (this?.actions && typeof this.actions === 'object') {\n for (let action in this.actions) {\n const fn = this.actions[action];\n\n if (typeof fn !== 'function') {\n set(binding, action, fn);\n continue;\n }\n\n set(binding, action, fn.bind(binding));\n }\n }\n\n return this;\n }\n}\n","import Store from './store';\nimport { isEmpty } from './utils';\nimport { isArray } from './utils/array';\nimport { set, get } from './utils/object';\n\nclass Resource {\n /**\n\t * The base resource for all resources\n\n\t * @return {[type]} [description]\n\t */\n constructor(attributes = {}, adapter, resource, options = {}) {\n this.attributes = attributes;\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isDestroying = false;\n this.isReloading = false;\n this.resource = resource;\n this.options = options;\n this.version = options.version || 'v1';\n this.setAdapter(adapter);\n }\n\n /**\n * Set a new adapter to the resource instance, this will update the Store instance\n *\n * @param {Adapter} adapter\n * @return {Resource} this\n */\n setAdapter(adapter) {\n this.adapter = adapter;\n this.store = new Store(this.resource, adapter, {\n onAfterFetch: this.syncAttributes.bind(this),\n actions: this.options?.actions\n });\n\n return this;\n }\n\n /**\n * Getter for id attribute\n *\n * @var {String}\n */\n get id() {\n return this.getAttribute('id');\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n create(attributes = {}) {\n const data = this.mergeAttributes(attributes);\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.create(data).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n update(attributes = {}) {\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.update(this.attributes.id, attributes).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Deletes the resource instance on the server\n *\n * @return {[type]} [description]\n */\n destroy() {\n this.setFlags(['isLoading', 'isDestroying']);\n\n return this.store.destroy(this.attributes.id).then((response) => {\n this.setFlags(['isLoading', 'isDestroying'], false);\n\n return response;\n });\n }\n\n /**\n * Reloads the resource from the server.\n *\n * @return {[type]} [description]\n */\n reload() {\n this.setFlags(['isLoading', 'isReloading']);\n\n return this.store.findRecord(this.attributes.id).then((response) => {\n this.reset();\n\n return response;\n });\n }\n\n /**\n * Sets flag properties.\n *\n * @return this\n */\n setFlags(flags = [], state = true) {\n const validFlags = ['isLoading', 'isSaving', 'isReloading', 'isDestroying'];\n\n for(let i = 0; i < flags.length; i++) {\n const flag = flags[i];\n\n if (typeof flag !== 'string' || !validFlags.includes(flag)) {\n throw new Error(`${flag} is not a valid flag!`);\n }\n\n this[flag] = state;\n }\n\n return this;\n }\n\n /**\n * Resets tracked properties\n *\n * @return this\n */\n reset() {\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isReloading = false;\n\n return this;\n }\n\n /**\n * Emptys resource.\n *\n * @return this\n */\n empty() {\n this.reset();\n this.attribues = {};\n\n return this;\n }\n\n /**\n * Saves the resource instance on the server\n *\n * @return {[type]} [description]\n */\n save(options = {}) {\n const attributes = this.getAttributes();\n\n if (isEmpty(this.id)) {\n return this.create(attributes);\n }\n\n if (options.onlyDirty === true) {\n return this.savedirty();\n }\n\n return this.update(attributes);\n }\n\n /**\n * Saves only dirtied attributes.\n *\n * @return {[type]} [description]\n */\n saveDirty() {\n const dirtyAttributeKeys = Object.keys(this.dirtyAttributes);\n const dirtyAttributes = {};\n\n for (let i = 0; i < dirtyAttributeKeys.length; i++) {\n const key = dirtyAttributeKeys[i];\n dirtyAttributes[key] = this.getAttribute(key);\n }\n\n return this.update(dirtyAttributes);\n }\n\n /**\n * Returns the resource meta if exists.\n *\n * @return {Object}\n */\n get meta() {\n return this.getAttribute('meta', {});\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get createdAt() {\n return this.isAttributeFilled('created_at') ? new Date(this.getAttribute('created_at')) : null;\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get updatedAt() {\n return this.isAttributeFilled('updated_at') ? new Date(this.getAttribute('updated_at')) : null;\n }\n\n /**\n * Checks if resource is loaded from the server.\n *\n * @return {Boolean}\n */\n get isLoaded() {\n return this.hasAttributes(['created_at', 'id']);\n }\n\n /**\n * Checks if resource ihas no attributes\n *\n * @return {Boolean}\n */\n get isEmpty() {\n return Object.values(this?.attributes).length === 0;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isNew() {\n return !this.id;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isSaved() {\n return !this.isNew && this.isLoaded;\n }\n\n /**\n * Checks if resource is deleted on server.\n *\n * @return {Boolean}\n */\n get isDeleted() {\n return this.hasAttributes(['deleted', 'time']);\n }\n\n /**\n * Iterates over each attribute value and property executing a user supplied callback.\n *\n * @return {Object}\n */\n eachAttribute(callback) {\n if (typeof callback !== 'function') {\n return this;\n }\n\n Object.keys(this?.attributes ?? {}).forEach((property) => {\n const value = this.getAttribute(property);\n callback.call(this, value, property);\n });\n\n return this;\n }\n\n /**\n * Gets all changes\n *\n * @return {Object}\n */\n changes() {\n return this.changes;\n }\n\n /**\n * Gets all dirty attributes.\n *\n * @return {Object}\n */\n getDirtyAttributes() {\n return this.dirtyAttributes;\n }\n\n /**\n * Checks if property is dirty.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n isDirty(property) {\n return property in this.dirtyAttributes;\n }\n\n /**\n * Checks if any properties is dirty.\n *\n * @return {Boolean}\n */\n hasDirtyAttributes() {\n return Object.keys(this?.dirtyAttributes ?? {}).length > 0;\n }\n\n /**\n * Updates a instance property without tracking changes or dirtying attribute.\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n mutate(property, value) {\n this.attributes[property] = value;\n }\n\n /**\n * Set an instance property locally\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n setAttribute(property, value = null) {\n if (value === null && typeof property === 'object') {\n return this.setAttributes(property);\n }\n\n const previousValue = this?.attributes[property] ?? null;\n\n // use object setter\n set(this.attributes, property, value);\n set(this.dirtyAttributes, property, previousValue);\n \n // this.attributes[property] = value;\n // this.dirtyAttributes[property] = previousValue;\n\n // track changes\n if (!isArray(this?.changes[property])) {\n this.changes[property] = [];\n }\n\n this.changes[property].push({\n property,\n previousValue,\n value,\n changedAt: new Date(),\n });\n\n return this;\n }\n\n /**\n * Set multiple instance properties locally\n *\n * @param {Object} properties [description]\n */\n setAttributes(attributes = {}) {\n for (let property in attributes) {\n this.setAttribute(property, attributes[property]);\n }\n\n return this;\n }\n\n /**\n * Get an attribute\n *\n * @param {String} attribute The attribute key to get\n * @param {mixed} defaultValue The default value if no attribute value\n */\n getAttribute(attribute, defaultValue = null) {\n const value = get(this?.attributes ?? {}, attribute);\n\n if (value === undefined) {\n return defaultValue;\n }\n\n return value;\n }\n\n /**\n * Checks if attribute exists.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n hasAttribute(property) {\n if (isArray(property)) {\n const properties = property;\n const attributeKeys = Object.keys(this.attributes ?? {});\n \n return properties.every((prop) => attributeKeys.includes(prop));\n }\n\n if (!this?.attributes) {\n return false;\n }\n\n return property in this.attributes;\n }\n\n /**\n * Alias for checking if has multiple attributes.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n hasAttributes(properties = []) {\n return this.hasAttribute(properties);\n }\n\n /**\n * Returns true if attribute has value.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n isAttributeFilled(property) {\n if (isArray(property)) {\n return this.hasAttribute(property) && property.every((prop) => !isEmpty(this.getAttribute(prop)));\n }\n\n return this.hasAttribute(property) && !isEmpty(this.getAttribute(property));\n }\n\n /**\n * Get multiple attributes.\n *\n * @param {Array} properties [description]\n * @param {[type]} value [description]\n */\n getAttributes(properties) {\n const attributes = {};\n\n if (properties === null || properties === undefined) {\n return this.getAttributes(Object.keys(this.attributes));\n }\n\n if (typeof properties === 'string') {\n return this.getAttribute([...arguments]);\n }\n\n if (!isArray(properties)) {\n throw new Error('No attribute properties provided!');\n }\n\n for (let i = 0; i < properties.length; i++) {\n const property = properties[i];\n\n if (typeof property !== 'string') {\n continue;\n }\n\n let value = this.getAttribute(property);\n\n if (typeof value?.attributes === 'object' && !isArray(value?.attributes)) {\n value = value.attributes;\n }\n\n attributes[property] = value;\n }\n\n return attributes;\n }\n\n /**\n * Serialize resource to a POJO\n *\n * @returns {Object}\n */\n serialize() {\n return this.getAttributes();\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n mergeAttributes(attributes = {}) {\n const modelAttributes = this?.attributes ?? {};\n this.attributes = { ...modelAttributes, ...attributes };\n\n return this.attributes;\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n syncAttributes(json = {}) {\n this.attributes = json;\n }\n}\n\nexport default Resource;\n","import Resource from '../resource';\nimport { StoreActions } from '../utils';\nimport { isValid as isValidDate } from 'date-fns';\n\nconst orderActions = new StoreActions({\n getDistanceAndTime: function (id, params = {}, options = {}) {\n return this.adapter.get(`${this.namespace}/${id}/distance-and-time`, params, options);\n },\n\n getNextActivity: function (id, params = {}, options = {}) {\n return this.adapter.get(`${this.namespace}/${id}/next-activity`, params, options);\n },\n\n dispatch: function (id, params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/dispatch`, params, options).then(this.afterFetch.bind(this));\n },\n\n start: function (id,params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/start`, params, options).then(this.afterFetch.bind(this));\n },\n\n updateActivity: function (id, params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/update-activity`, params, options).then(this.afterFetch.bind(this));\n },\n\n complete: function (id, params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/complete`, params, options).then(this.afterFetch.bind(this));\n },\n\n cancel: function (id, params = {}, options = {}) {\n return this.adapter.delete(`${this.namespace}/${id}/cancel`, params, options).then(this.afterFetch.bind(this));\n }\n});\n\nclass Order extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'order', { actions: orderActions, ...options });\n }\n\n getDistanceAndTime(params = {}, options = {}) {\n return this.store.getDistanceAndTime(this.id, params, options);\n }\n\n dispatch(params = {}, options = {}) {\n return this.store.dispatch(this.id, params, options);\n }\n\n start(params = {}, options = {}) {\n return this.store.start(this.id, params, options);\n }\n\n getNextActivity(params = {}, options = {}) {\n return this.store.getNextActivity(this.id, params, options);\n }\n\n updateActivity(params = {}, options = {}) {\n return this.store.updateActivity(this.id, params, options);\n }\n\n cancel(params = {}, options = {}) {\n return this.store.cancel(this.id, params, options);\n }\n\n complete(params = {}, options = {}) {\n return this.store.complete(this.id, params, options);\n }\n\n get isDispatched() {\n return this.getAttribute('dispatched_at') !== null;\n }\n\n get isNotDispatched() {\n return this.getAttribute('dispatched_at') == null;\n }\n\n get isStarted() {\n return this.getAttribute('started_at') !== null;\n }\n\n get isNotStarted() {\n return this.getAttribute('started_at') == null;\n }\n\n get isCompleted() {\n return this.getAttribute('status') == 'completed';\n }\n\n get isCanceled() {\n return this.getAttribute('status') == 'canceled';\n }\n\n get isEnroute() {\n return this.getAttribute('status') == 'driver_enroute' || this.getAttribute('status') === 'enroute';\n }\n\n get isInProgress() {\n return this.isStarted && !this.isCanceled && !this.isCompleted;\n }\n\n get scheduledAt() {\n return this.isAttributeFilled('scheduled_at') ? new Date(this.getAttribute('scheduled_at')) : null;\n }\n\n get startedAt() {\n return this.isAttributeFilled('started_at') ? new Date(this.getAttribute('started_at')) : null;\n }\n\n get dispatchedAt() {\n return this.isAttributeFilled('dispatched_at') ? new Date(this.getAttribute('dispatched_at')) : null;\n }\n\n get status() {\n return this.getAttribute('status');\n }\n}\n\nexport default Order;\n\nexport { orderActions };\n","import Resource from '../resource';\nimport Collection from '../utils/collection';\n\nclass Payload extends Resource {\n\tconstructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'payload', options);\n }\n\t\n /**\n\t * Attaches an entity to an existing payload and returns\n\t * the payload with the entity attached\n\t *\n\t * @param {[type]} Entity entity [description]\n\t * @return {[type]} [description]\n\t */\n attach(entity) {\n // perform op return payload\n }\n\n /**\n\t * Returns all of the entities attached to this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get entities() {\n\n }\n\n /**\n\t * Returns the dropoff for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get dropoff() {\n\n }\n\n /**\n\t * Returns the pickup for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get pickup() {\n\n }\n\n /**\n\t * Returns all the waypoints for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get waypoints() {\n return new Collection(this.waypoints);\n }\n}\n\nexport default Payload;\n","import Resource from '../resource';\n\nclass Entity extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'entity', options);\n }\n}\n\nexport default Entity;\n","import Resource from '../resource';\nimport { isResource, Point } from '../utils';\n\nclass Place extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'place', options);\n }\n\n static fromGoogleAddress(googleAddress, adapter, options = {}) {\n const [ latitude, longitude ] = googleAddress.getAttribute('coordinates');\n const attributes = {\n name: null,\n address: googleAddress.getAttribute('address'),\n location: new Point(latitude, longitude),\n street1: googleAddress.getAttribute('streetName'),\n street2: null,\n city: googleAddress.getAttribute('city'),\n province: googleAddress.getAttribute('stateLong'),\n postal_code: googleAddress.getAttribute('postalCode'),\n neighborhood: googleAddress.get('neighborhood'),\n district: googleAddress.getAttribute('county'),\n building: googleAddress.get('building'),\n country: googleAddress.getAttribute('countryShort'),\n phone: null,\n security_access_code: null\n };\n\n return new Place(attributes, adapter, options);\n }\n\n /**\n * The latitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get latitude() {\n return this.getAttribute('location', new Point())?.coordinates[1];\n }\n\n /**\n * The longitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get longitude() {\n return this.getAttribute('location', new Point())?.coordinates[0];\n }\n\n /**\n * Array coordinate pair for Place location.\n * \n * @var {Array}\n */\n get coordinates() {\n const { latitude, longitude } = this;\n\n return [ latitude, longitude ];\n }\n\n /**\n * Set the owner of the place.\n * \n * @param {Object|String} owner\n * @return {Place}\n */\n setOwner(owner) {\n if (isResource(owner)) {\n this.setAttribute('owner', owner.id);\n }\n\n if (typeof owner === 'string') {\n this.setAttribute('owner', owner);\n }\n\n return this;\n }\n}\n\nexport default Place;\n","import Place from './place';\n\nclass Waypoint extends Place {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'waypoint', options);\n }\n}\n\nexport default Waypoint;\n","import Resource from '../resource';\n\nclass TrackingStatus extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'tracking-status', options);\n }\n}\n\nexport default TrackingStatus;\n","import Resource from '../resource';\n\nclass Vehicle extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vehicle', options);\n }\n}\n\nexport default Vehicle;\n","import Resource from '../resource';\nimport { StoreActions, isPhone, isEmail } from '../utils';\n\nconst driverActions = new StoreActions({\n // const { error } = await fleetbase.drivers.login('+1 111-1111');\n login: function (identity, password = null, attributes = {}) {\n // handle phone number authentication\n if (isPhone(identity)) {\n return this.adapter.post('drivers/login-with-sms', { phone: identity });\n }\n\n if (!password) {\n throw new Error('Login requires password!');\n }\n\n return this.adapter.post('drivers/login', { identity, password, ...attributes }).then(this.afterFetch.bind(this));\n },\n\n verifyCode: function (identity, code, attributes = {}) {\n return this.adapter.post('drivers/verify-code', { identity, code, ...attributes }).then(this.afterFetch.bind(this));\n },\n\n retrieve: function (id) {\n return this.findRecord(id);\n },\n});\n\nclass Driver extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'driver', options);\n }\n\n get token() {\n return this.getAttribute('token');\n }\n\n get isOnline() {\n return this.getAttribute('online') === true;\n }\n\n syncDevice(token) {\n return this.adapter\n .setHeaders({ 'Driver-Token': this.token })\n .post('drivers/register-device', token)\n .then(() => {\n return this;\n });\n }\n}\n\nexport default Driver;\nexport { driverActions };\n","import Resource from '../resource';\n\nclass Vendor extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vendor', options);\n }\n}\n\nexport default Vendor;\n","import Resource from '../resource';\n\nclass Contact extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'contact', options);\n }\n}\n\nexport default Contact;\n","import Resource from '../resource';\n\nclass Zone extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'zone', options);\n }\n}\n\nexport default Zone;\n","import Resource from '../resource';\n\nclass ServiceArea extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-area', options);\n }\n}\n\nexport default ServiceArea;\n","import Resource from '../resource';\n\nclass ServiceRate extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-rate', options);\n }\n}\n\nexport default ServiceRate;\n","import Resource from '../resource';\n\nclass ServiceQuote extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-quote', options);\n }\n\n fromPreliminary() {\n\n }\n\n fromPayload() {\n \n }\n}\n\nexport default ServiceQuote;\n","class Adapter {\n /**\n\t * Creates a configured base adapter for Fleetbase.\n\t *\n\t * @param {Object} config Configuration options for adapter\n\t */\n constructor(config = {}) {\n this.version = config.version || 'v1';\n this.host = config.host || null;\n this.namespace = config.namespace || null;\n this.headers = config.headers || {};\n }\n}\n\nexport default Adapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\n\nclass BrowserAdapter extends Adapter {\n /**\n * Setup browser adapter.\n * @param {Object} config\n */\n constructor(config) {\n super(config);\n\n this.setHeaders({\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;browser'\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n this.headers = { ...this.headers, ...headers };\n\n return this;\n }\n\n /**\n * Parses the JSON returned by a network request\n *\n * @param {Object} response A response from a network request\n * @return {Object} The parsed JSON, status from the response\n *\n * @return {Promise}\n */\n parseJSON(response) {\n return new Promise((resolve, reject) => response\n .json()\n .then((json) => resolve({\n statusText: response.statusText,\n status: response.status,\n ok: response.ok,\n json,\n }))\n .catch(() => {\n reject(new Error('Oops! Something went wrong when handling your request.'));\n }));\n }\n\n /**\n * The base request method\n *\n * @param {String} path\n * @param {String} method\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n request(path, method = 'GET', data = {}, options = {}) {\n return new Promise((resolve, reject) => fetch(options.url || `${this.host}/${this.namespace}/${path}`, {\n method,\n mode: options.mode || 'cors',\n headers: new Headers({\n ...(this.headers || {}),\n ...(options.headers || {}),\n }),\n ...data,\n })\n .then(this.parseJSON)\n .then((response) => {\n if (response.ok) {\n return resolve(response.json);\n }\n\n return reject(new Error(response.json.errors ? response.json.errors[0] : response.statusText));\n })\n .catch((error) => {\n reject(error);\n }));\n }\n\n /**\n * Makes a GET request with fetch\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.request(`${path}${urlParams ? `?${urlParams}` : ''}`, 'GET', {}, options);\n }\n\n /**\n * Makes a POST request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.request(path, 'POST', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a PUT request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.request(path, 'PUT', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a DELETE request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.request(path, 'DELETE', {}, options);\n }\n\n /**\n * Makes a PATCH request with fetch\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.request(path, 'PATCH', { body: JSON.stringify(data) }, options);\n }\n}\n\nexport default BrowserAdapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\nimport { isArray } from '../utils/array';\nimport axios from 'axios';\n\nclass NodeAdapter extends Adapter {\n constructor(config) {\n super(config);\n\n this.axios = axios.create({\n baseURL: `${this.host}/${this.namespace}`,\n headers: {\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;node',\n },\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n const commonHeaders = this.axios.defaults.headers.common;\n this.axios.defaults.headers.common = { ...commonHeaders, ...headers };\n\n return this;\n }\n\n /**\n * Tranform the response, and return the response data from axios.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n transform(response) {\n return response.data;\n }\n\n /**\n * Handles an erroneous request.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n handleError(error) {\n if (error.response) {\n const { data } = error.response;\n\n if (isArray(data.errors)) {\n throw new Error(data.errors[0]);\n }\n\n if (data.error) {\n throw new Error(data.error);\n }\n }\n\n throw error;\n }\n\n /**\n * Makes a GET request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.axios\n .get(`${path}${urlParams ? `?${urlParams}` : ''}`, options)\n .then(this.transform.bind(this))\n .catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a POST request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.axios.post(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PUT request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.axios.put(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a DELETE request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.axios.delete(path, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PATCH request with axios\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.axios.patch(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n}\n\nexport default NodeAdapter;\n","import Adapter from '../adapter';\n\nclass EmberJsAdapter extends Adapter {}\n\nexport default EmberJsAdapter;\n","'use strict';\n\n/**\n * Javascript String\n *\n * instance\n * new String('hello_world').humanize().get() => \"Hello world\"\n *\n * instance\n * const string = new String();\n * string.humanize('hello_world').get() => \"Hello world\"\n * \n * no chain\n * new String('hello_world', false).humanize() => \"Hello world\"\n *\n * static\n * String.invoke('humanize', 'hello_world') => \"Hello world\"\n *\n * exports {}\n * humanize('hello_world') => \"Hello world\"\n */\n\nexport default class String {\n constructor(string, chain = true) {\n this.str = string;\n this.chain = chain;\n }\n\n uncountableWords = ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'moose', 'deer', 'news'];\n\n pluralRules = [\n [new RegExp('(m)an$', 'gi'), '$1en'],\n [new RegExp('(pe)rson$', 'gi'), '$1ople'],\n [new RegExp('(child)$', 'gi'), '$1ren'],\n [new RegExp('^(ox)$', 'gi'), '$1en'],\n [new RegExp('(ax|test)is$', 'gi'), '$1es'],\n [new RegExp('(octop|vir)us$', 'gi'), '$1i'],\n [new RegExp('(alias|status)$', 'gi'), '$1es'],\n [new RegExp('(bu)s$', 'gi'), '$1ses'],\n [new RegExp('(buffal|tomat|potat)o$', 'gi'), '$1oes'],\n [new RegExp('([ti])um$', 'gi'), '$1a'],\n [new RegExp('sis$', 'gi'), 'ses'],\n [new RegExp('(?:([^f])fe|([lr])f)$', 'gi'), '$1$2ves'],\n [new RegExp('(hive)$', 'gi'), '$1s'],\n [new RegExp('([^aeiouy]|qu)y$', 'gi'), '$1ies'],\n [new RegExp('(x|ch|ss|sh)$', 'gi'), '$1es'],\n [new RegExp('(matr|vert|ind)ix|ex$', 'gi'), '$1ices'],\n [new RegExp('([m|l])ouse$', 'gi'), '$1ice'],\n [new RegExp('(quiz)$', 'gi'), '$1zes'],\n [new RegExp('s$', 'gi'), 's'],\n [new RegExp('$', 'gi'), 's'],\n ];\n\n singularRules = [\n [new RegExp('(m)en$', 'gi'), '$1an'],\n [new RegExp('(pe)ople$', 'gi'), '$1rson'],\n [new RegExp('(child)ren$', 'gi'), '$1'],\n [new RegExp('([ti])a$', 'gi'), '$1um'],\n [new RegExp('((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$', 'gi'), '$1$2sis'],\n [new RegExp('(hive)s$', 'gi'), '$1'],\n [new RegExp('(tive)s$', 'gi'), '$1'],\n [new RegExp('(curve)s$', 'gi'), '$1'],\n [new RegExp('([lr])ves$', 'gi'), '$1f'],\n [new RegExp('([^fo])ves$', 'gi'), '$1fe'],\n [new RegExp('([^aeiouy]|qu)ies$', 'gi'), '$1y'],\n [new RegExp('(s)eries$', 'gi'), '$1eries'],\n [new RegExp('(m)ovies$', 'gi'), '$1ovie'],\n [new RegExp('(x|ch|ss|sh)es$', 'gi'), '$1'],\n [new RegExp('([m|l])ice$', 'gi'), '$1ouse'],\n [new RegExp('(bus)es$', 'gi'), '$1'],\n [new RegExp('(o)es$', 'gi'), '$1'],\n [new RegExp('(shoe)s$', 'gi'), '$1'],\n [new RegExp('(cris|ax|test)es$', 'gi'), '$1is'],\n [new RegExp('(octop|vir)i$', 'gi'), '$1us'],\n [new RegExp('(alias|status)es$', 'gi'), '$1'],\n [new RegExp('^(ox)en', 'gi'), '$1'],\n [new RegExp('(vert|ind)ices$', 'gi'), '$1ex'],\n [new RegExp('(matr)ices$', 'gi'), '$1ix'],\n [new RegExp('(quiz)zes$', 'gi'), '$1'],\n [new RegExp('s$', 'gi'), ''],\n ];\n\n nonTitlecasedWords = ['and', 'or', 'nor', 'a', 'an', 'the', 'so', 'but', 'to', 'of', 'at', 'by', 'from', 'into', 'on', 'onto', 'off', 'out', 'in', 'over', 'with', 'for'];\n\n idSuffix = new RegExp('(_ids|_id)$', 'g');\n underbar = new RegExp('_', 'g');\n spaceOrUnderbar = new RegExp('[ _]', 'g');\n uppercase = new RegExp('([A-Z])', 'g');\n underbarPrefix = new RegExp('^_');\n\n get() {\n return this.str;\n }\n\n applyRules(str, rules, skip, override) {\n if (override) {\n str = override;\n } else {\n var ignore = skip.indexOf(str.toLowerCase()) > -1;\n if (!ignore) {\n for (var x = 0; x < rules.length; x++) {\n if (str.match(rules[x][0])) {\n str = str.replace(rules[x][0], rules[x][1]);\n break;\n }\n }\n }\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.pluralize('person') -> 'people'\n String.pluralize('octopus') -> 'octopi'\n String.pluralize('Hat') -> 'Hats'\n String.pluralize('person', 'guys') -> 'guys' \n */\n pluralize(str, plural = null) {\n str = str || this.str;\n\n return this.applyRules(str, this.pluralRules, this.uncountableWords, plural);\n }\n\n /*\n String.singularize('person') -> 'person'\n String.singularize('octopi') -> 'octopus'\n String.singularize('hats') -> 'hat'\n String.singularize('guys', 'person') -> 'person'\n */\n singularize(str, singular) {\n str = str || this.str;\n\n return this.applyRules(str, this.singularRules, this.uncountableWords, singular);\n }\n\n /*\n String.camelize('message_properties') -> 'MessageProperties'\n String.camelize('message_properties', true) -> 'messageProperties'\n */\n camelize(str, lowFirstLetter) {\n str = str || this.str;\n\n let str_path = str.split('/');\n for (var i = 0; i < str_path.length; i++) {\n let str_arr = str_path[i].split('_');\n let initX = lowFirstLetter && i + 1 === str_path.length ? 1 : 0;\n\n for (let x = initX; x < str_arr.length; x++) {\n str_arr[x] = str_arr[x].charAt(0).toUpperCase() + str_arr[x].substring(1);\n }\n str_path[i] = str_arr.join('');\n }\n str = str_path.join('::');\n\n // fix\n if (lowFirstLetter === true) {\n let first = str.charAt(0).toLowerCase();\n let last = str.slice(1);\n str = first + last;\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.underscore('MessageProperties') -> 'message_properties'\n String.underscore('messageProperties') -> 'message_properties'\n */\n underscore(str) {\n str = str || this.str;\n\n var str_path = str.split('::');\n for (var i = 0; i < str_path.length; i++) {\n str_path[i] = str_path[i].replace(this.uppercase, '_$1');\n str_path[i] = str_path[i].replace(this.underbarPrefix, '');\n }\n str = str_path.join('/').toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.humanize('message_properties') -> 'Message properties'\n String.humanize('message_properties') -> 'message properties'\n */\n humanize(str, lowFirstLetter) {\n str = str || this.str;\n\n var str = str.toLowerCase();\n str = str.replace(this.idSuffix, '');\n str = str.replace(this.underbar, ' ');\n if (!lowFirstLetter) {\n str = this.capitalize(str);\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.capitalize('message_properties') -> 'Message_properties'\n String.capitalize('message properties') -> 'Message properties'\n */\n capitalize(str) {\n str = str || this.str;\n\n str = str.toLowerCase();\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.dasherize('message_properties') -> 'message-properties'\n String.dasherize('message properties') -> 'message-properties'\n */\n dasherize(str) {\n str = str || this.str;\n\n str = str.replace(this.spaceOrUnderbar, '-');\n str = str.toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.normify('message_properties') -> 'Message Properties'\n String.normify('message properties') -> 'Message Properties'\n Inflactor.normify('Message_propertyId', true) -> 'Message Properties Id'\n */\n normify(str, allFirstUpper) {\n str = str || this.str;\n\n //var str = str.toLowerCase();\n if (allFirstUpper === true) {\n str = this.camelize(str);\n str = this.underscore(str);\n } else {\n str = str.toLowerCase();\n }\n\n str = str.replace(this.underbar, ' ');\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var d = str_arr[x].split('-');\n for (var i = 0; i < d.length; i++) {\n if (this.nonTitlecasedWords.indexOf(d[i].toLowerCase()) < 0) {\n d[i] = this.capitalize(d[i]);\n }\n }\n str_arr[x] = d.join('-');\n }\n str = str_arr.join(' ');\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.demodulize('Message::Bus::Properties') -> 'Properties'\n */\n demodulize(str) {\n str = str || this.str;\n\n var str_arr = str.split('::');\n str = str_arr[str_arr.length - 1];\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.tableize('MessageBusProperty') -> 'message_bus_properties'\n */\n tableize(str) {\n str = str || this.str;\n\n str = this.pluralize(this.underscore(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.classify('message_bus_properties') -> 'MessageBusProperty'\n */\n classify(str) {\n str = str || this.str;\n\n str = this.singularize(this.camelize(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.foreignKey('MessageBusProperty') -> 'message_bus_property_id'\n String.foreignKey('MessageBusProperty', true) -> 'message_bus_propertyid'\n */\n foreignKey(str, dropIdUbar = false) {\n str = str || this.str;\n\n str = this.underscore(this.demodulize(str)) + (dropIdUbar ? '' : '_') + 'id';\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.ordinalize('the 1 pitch') -> 'the 1st pitch'\n */\n ordinalize(str) {\n str = str || this.str;\n\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var i = parseInt(str_arr[x]);\n if (i === NaN) {\n var ltd = str_arr[x].substring(str_arr[x].length - 2);\n var ld = str_arr[x].substring(str_arr[x].length - 1);\n var suf = 'th';\n if (ltd != '11' && ltd != '12' && ltd != '13') {\n if (ld === '1') {\n suf = 'st';\n } else if (ld === '2') {\n suf = 'nd';\n } else if (ld === '3') {\n suf = 'rd';\n }\n }\n str_arr[x] += suf;\n }\n }\n str = str_arr.join(' ');\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /**\n * @method invoke\n **/\n static invoke() {\n const argz = Object.values(arguments);\n const instance = new String(null, false);\n const method = arguments[0];\n argz.shift();\n\n if (typeof instance[method] === 'function') {\n return instance[method](...argz);\n }\n\n return null;\n }\n}\n\nconst pluralize = function() {\n const argz = ['pluralize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst singularize = function() {\n const argz = ['singularize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst humanize = function() {\n const argz = ['humanize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst underscore = function() {\n const argz = ['underscore', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst camelize = function() {\n const argz = ['camelize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst capitalize = function() {\n const argz = ['capitalize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst dasherize = function() {\n const argz = ['dasherize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst normify = function() {\n const argz = ['normify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst demodulize = function() {\n const argz = ['demodulize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst tableize = function() {\n const argz = ['tableize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst classify = function() {\n const argz = ['classify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst foreignKey = function() {\n const argz = ['foreignKey', ...arguments];\n\n return String.invoke(...argz);\n};\n\nexport {\n pluralize,\n singularize,\n humanize,\n underscore,\n camelize,\n capitalize,\n dasherize,\n normify,\n demodulize,\n tableize,\n classify,\n foreignKey\n}","import { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter } from './adapters';\nimport { pluralize, singularize } from './utils/string';\n\nconst resources = {\n Contact,\n Driver,\n Entity,\n Order,\n Payload,\n Place,\n TrackingStatus,\n Vehicle,\n Vendor,\n Waypoint,\n Zone,\n ServiceArea,\n ServiceRate,\n ServiceQuote,\n};\n\nconst adapters = {\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter,\n};\n\nclass Resolver {\n constructor() {\n this.resources = resources;\n this.adapters = adapters;\n\n return this.lookup(...arguments);\n }\n\n lookup(type, className) {\n const key = pluralize(type);\n const params = [...arguments].slice(2);\n\n if (!this[key]) {\n throw new Error('Attempted to resolve invalid type');\n }\n\n if (!this[key][className]) {\n throw new Error(`No ${singularize(type)} named ${className} to resolve`);\n }\n\n return new this[key][className](...params);\n }\n}\n\nconst lookup = function () {\n return new Resolver(...arguments);\n};\n\nexport { Resolver, lookup };\n","import { lookup } from './resolver';\nimport { pluralize, classify } from './utils/string';\nimport { isArray } from './utils/array';\nimport { Collection, detectAdapter, isResource, StoreActions } from './utils';\nimport { set, isCallable, invoke } from './utils/object';\n\nconst extendStoreActions = (store, actions = []) => {\n store.actions = isArray(actions) ? actions : [actions];\n\n if (isArray(actions)) {\n for (let i = 0; i < actions.length; i++) {\n const action = actions[i];\n\n store.extendActions(action);\n }\n return;\n }\n\n if (actions instanceof StoreActions) {\n actions.extend(store);\n }\n\n return store;\n};\n\nconst afterFetch = (store, json) => {\n if (typeof store.options.onAfterFetch === 'function') {\n store.options.onAfterFetch(json);\n }\n\n if (isArray(json)) {\n const serialized = [];\n\n for (let i = 0; i < json.length; i++) {\n serialized.push(store.afterFetch(json[i]));\n }\n\n return new Collection(...serialized);\n }\n\n const resourceInstance = store.serialize(json);\n return store.deposit(resourceInstance);\n};\n\nclass Store {\n constructor(resource, adapter, options = {}) {\n this.resource = resource;\n this.adapter = adapter || detectAdapter();\n this.namespace = pluralize(resource);\n this.storage = new Collection();\n this.options = options;\n this.extendActions(options.actions);\n }\n\n extendActions(actions = []) {\n return extendStoreActions(this, actions);\n }\n\n deposit(resourceInstance) {\n // this.storage[this.namespace].pushObject(resourceInstance);\n\n return resourceInstance;\n }\n\n serialize(json) {\n return lookup('resource', classify(this.resource), json, this.adapter);\n }\n\n afterFetch(json) {\n return afterFetch(this, json);\n }\n\n create(attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.post(`${this.namespace}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n update(id, attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.put(`${this.namespace}/${id}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findRecord(id, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findAll(options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n query(query = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n queryRecord(query = {}, options = {}) {\n query.single = true;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n destroy(record, options = {}) {\n const id = isResource(record) ? record.getAttribute('id') : record;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.delete(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n}\n\nexport default Store;\n\nexport { extendStoreActions, afterFetch };\n","import Store from './store';\nimport Resource from './resource';\nimport { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter, Adapter } from './adapters';\nimport { isNodeEnvironment, detectAdapter, isLatitude, isLongitude, Point, isResource, GoogleAddress, Collection, StoreActions } from './utils';\nimport { pluralize, singularize, classify, dasherize, camelize } from './utils/string';\nimport { extendStoreActions } from './store';\nimport { orderActions } from './resources/order';\nimport { driverActions } from './resources/driver';\n\n/**\n * // instance\n * const fleetbase = new Fleetbase();\n *\n * const contact = fleetbase.contacts.create({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * constact.update({ name: 'Hollywood Ron' });\n *\n * // export\n * import { Contact } from '@fleetbase/sdk';\n *\n * const contact = new Contact({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * contact.save();\n */\n\nexport default class Fleetbase {\n /**\n * Builds an instance of the Fleetbase SDK\n *\n * @param {String} publicKey The public key issued\n * @param {Object} config The version of resource to access\n * @param {Boolean} debug Debug mode for SDK\n * @return {Fleetbase} Instance\n */\n constructor(publicKey, config = {}, debug = false) {\n this.version = config.version || 'v1';\n this.options = {\n version: this.version,\n host: config.host || 'https://api.fleetbase.io',\n namespace: this.version || config.namespace,\n debug,\n publicKey,\n };\n\n if (typeof publicKey !== 'string' || publicKey.length === 0) {\n throw new Error('⚠️ Invalid public key given to Fleetbase SDK');\n }\n\n if (!isNodeEnvironment() && publicKey.toLowerCase().startsWith('$')) {\n throw new Error('Secret key provided. You must use a public key with Fleetbase Javascript SDK!');\n }\n\n this.adapter = config.adapter || detectAdapter(this.options);\n\n this.orders = new Store('order', this.adapter).extendActions(orderActions);\n this.entities = new Store('entity', this.adapter);\n this.places = new Store('place', this.adapter);\n this.drivers = new Store('driver', this.adapter).extendActions(driverActions);\n this.vehicles = new Store('vehicle', this.adapter);\n this.vendors = new Store('vendor', this.adapter);\n this.contacts = new Store('contact', this.adapter);\n }\n\n static newInstance() {\n return new Fleetbase(...arguments);\n }\n\n setAdapter(adapter) {\n this.adapter = adapter;\n }\n\n getAdapter() {\n return this.adapter;\n }\n}\n\nexport {\n Store,\n Resource,\n Contact,\n Driver,\n Entity,\n Order,\n Payload,\n Place,\n TrackingStatus,\n Vehicle,\n Vendor,\n Waypoint,\n Zone,\n ServiceArea,\n ServiceRate,\n ServiceQuote,\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter,\n Adapter,\n isNodeEnvironment,\n isLatitude,\n isLongitude,\n Point,\n isResource,\n GoogleAddress,\n Collection,\n StoreActions,\n extendStoreActions,\n pluralize,\n singularize,\n classify,\n dasherize,\n camelize,\n};\n"],"names":["isArray","Array","CHUNK_SIZE","replace","array","start","deleteCount","items","length","splice","i","chunk","slice","isCollection","arr","identityFunction","item","uniqBy","key","ret","seen","Set","getter","get","forEach","val","has","add","push","mixed","Collection","objectAt","index","iter","value","arguments","Boolean","findIndex","predicate","startAt","len","find","callback","target","bind","undefined","any","every","cb","indexOf","withNaNCheck","removeAt","insertAt","this","indexes","map","idx","_this2","object","methodName","args","_item$methodName","filter","sortKeys","sort","a","b","propA","propB","compareValue","compare","includes","obj","objects","toArray","reverse","clear","loc","removeObject","pushObject","_this3","addObject","isEmpty","none","size","objectType","isBlank","test","isLatitude","coordinate","isFinite","Math","abs","isLongitude","isResource","record","Resource","isPhone","phone","isNodeEnvironment","process","_typeof","_process","env","release","name","search","window","navigator","product","detectAdapter","options","lookup","GoogleAddress","place","geometry","components","parseComponents","attributes","parseProperties","address_components","reduce","acc","data","types","type","streetNumber","streetName","coordinates","location","Object","values","city","or","county","stateShort","stateLong","countryShort","country","countryLong","postalCode","address","join","keys","pkey","short","short_name","long_name","Point","latitude","longitude","coorindates","lat","lng","serialize","json","getResolved","func","path","resolved","current","isObject","isFunction","pathArray","split","newPath","set","iterations","StoreActions","actions","bindTo","binding","action","fn","adapter","resource","dirtyAttributes","changes","isLoading","isSaving","isDestroying","isReloading","version","setAdapter","store","Store","onAfterFetch","syncAttributes","_this$options","getAttribute","mergeAttributes","setFlags","create","then","response","_this","update","id","destroy","findRecord","_this4","reset","flags","state","validFlags","flag","Error","attribues","getAttributes","onlyDirty","savedirty","dirtyAttributeKeys","isAttributeFilled","Date","hasAttributes","isNew","isLoaded","property","_this5","call","setAttributes","previousValue","changedAt","setAttribute","attribute","defaultValue","properties","attributeKeys","prop","hasAttribute","_this6","_value","_value2","modelAttributes","orderActions","getDistanceAndTime","params","namespace","getNextActivity","dispatch","post","afterFetch","updateActivity","complete","cancel","Order","isStarted","isCanceled","isCompleted","Payload","entity","waypoints","Entity","Place","_this$getAttribute","_this$getAttribute2","owner","googleAddress","street1","street2","province","postal_code","neighborhood","district","building","security_access_code","Waypoint","TrackingStatus","Vehicle","driverActions","login","identity","password","verifyCode","code","retrieve","Driver","token","setHeaders","Vendor","Contact","Zone","ServiceArea","ServiceRate","ServiceQuote","Adapter","config","host","headers","BrowserAdapter","Authorization","publicKey","Promise","resolve","reject","statusText","status","ok","method","fetch","url","mode","Headers","parseJSON","errors","error","query","urlParams","URLSearchParams","toString","request","body","JSON","stringify","NodeAdapter","axios","baseURL","commonHeaders","defaults","common","transform","handleError","put","patch","EmberJsAdapter","String","string","chain","RegExp","str","rules","skip","override","toLowerCase","x","match","plural","applyRules","pluralRules","uncountableWords","singular","singularRules","lowFirstLetter","str_path","str_arr","charAt","toUpperCase","substring","first","last","uppercase","underbarPrefix","idSuffix","underbar","capitalize","spaceOrUnderbar","allFirstUpper","camelize","underscore","d","nonTitlecasedWords","pluralize","singularize","dropIdUbar","demodulize","NaN","parseInt","ltd","ld","suf","argz","instance","shift","invoke","dasherize","classify","resources","adapters","Resolver","className","extendStoreActions","extend","extendActions","serialized","resourceInstance","deposit","storage","single","_this7","Fleetbase","debug","startsWith","orders","entities","places","drivers","vehicles","vendors","contacts"],"mappings":"48JAAA,IAAQA,EAAYC,MAAZD,8CCOFE,EAAa,IAIbC,EAAU,SAACC,EAAOC,EAAOC,OAAaC,yDAAQ,MAC5CP,EAAQI,MACJG,EAAMC,QAAUN,EAChBE,EAAMK,aAANL,GAAaC,EAAOC,YAAgBC,SACjC,CACHH,EAAMK,OAAOJ,EAAOC,OAEf,IAAII,EAAI,EAAGA,EAAIH,EAAMC,OAAQE,GAAKR,EAAY,KAC3CS,EAAQJ,EAAMK,MAAMF,EAAGA,EAAIR,GAC/BE,EAAMK,aAANL,GAAaC,EAAQK,EAAG,YAAMC,WAG/BE,EAAaC,MACpBV,EAAMD,QAAQE,EAAOC,EAAaC,IAIpCQ,EAAmB,SAACC,UAASA,GAE7BC,EAAS,SAACb,OAAOc,yDAAMH,EACrBI,EAAM,GACNC,EAAO,IAAIC,IACXC,EAAwB,mBAARJ,EAAqBA,EAAM,SAACF,UAASO,IAAIP,EAAME,WAEnEd,EAAMoB,SAAQ,SAACR,OACPS,EAAMH,EAAON,GACZ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cjs/fleetbase.js +++ b/dist/cjs/fleetbase.js @@ -1,2 +1,2 @@ -"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("axios"));function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function r(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n3&&void 0!==arguments[3]?arguments[3]:[];if(A(t))if(r.length<=6e4)t.splice.apply(t,[e,n].concat(k(r)));else{t.splice(e,n);for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:0,r=t.length,i=n;i2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0,i=t.length;n<0&&(n+=i);var o=r&&e!=e?function(t){return t!=t}:function(t){return t===e};return _(t,o,n)},C=function(t,e,n){return $(t,e,0,[n]),n},D=function(t){h(n,g(Array));var e=b(n);function n(){for(var t=arguments.length,r=new Array(t),i=0;i0}},{key:"empty",get:function(){return 0===this.length}},{key:"first",get:function(){return O(this,0)}},{key:"last",get:function(){return O(this,this.length-1)}},{key:"replace",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return $(this,t,e,n),this}},{key:"objectsAt",value:function(t){var e=this;return t.map((function(t){return O(e,t)}))}},{key:"objectAt",value:function(t){return O(this,t)}},{key:"indexOf",value:function(t,e){return F(this,t,e,!1)}},{key:"lastIndexOf",value:function(t,e){var n=this.length;(void 0===e||e>=n)&&(e=n-1),e<0&&(e+=n);for(var r=e;r>=0;r--)if(O(this,r)===t)return r;return-1}},{key:"includes",value:function(t,e){return-1!==F(this,t,e,!0)}},{key:"findBy",value:function(){return P(this,S.apply(void 0,arguments))}},{key:"findIndexBy",value:function(){return _(this,S.apply(void 0,arguments))}},{key:"isEvery",value:function(){return L(this,S.apply(void 0,arguments))}},{key:"isAny",value:function(){return z(this,S.apply(void 0,arguments))}},{key:"invoke",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:E,n=[],r=new Set,i="function"==typeof e?e:function(t){return get(t,e)};return t.forEach((function(t){var e=i(t);r.has(e)||(r.add(e),n.push(t))})),n}(this,t)}},{key:"without",value:function(t){if(!this.includes(t))return this;var e=t==t?function(e){return e!==t}:function(t){return t==t};return this.filter(e)}},{key:"clear",value:function(){var t=this.length;return 0===t||this.replace(0,t,[]),this}},{key:"insertAt",value:function(t,e){return C(this,t,e),this}},{key:"replaceAt",value:function(t,e){return this.replace(t,1,[e])}},{key:"removeAt",value:function(t,e){return function(t,e){return $(t,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,[]),t}(this,t,e)}},{key:"pushObject",value:function(t){return this.insertAt(this.length,t)}},{key:"pushObjects",value:function(t){return this.replace(this.length,0,t),this}},{key:"popObject",value:function(){var t=this.length;if(0===t)return null;var e=O(this,t-1);return this.removeAt(t-1,1),e}},{key:"shiftObject",value:function(){if(0===this.length)return null;var t=O(this,0);return this.removeAt(0),t}},{key:"unshiftObject",value:function(t){return C(this,0,t)}},{key:"unshiftObjects",value:function(t){return this.replace(0,0,t),this}},{key:"reverseObjects",value:function(){var t=this.length;if(0===t)return this;var e=this.toArray().reverse();return this.replace(0,t,e),this}},{key:"setObjects",value:function(t){if(0===t.length)return this.clear();var e=this.length;return this.replace(0,e,t),this}},{key:"removeObject",value:function(t){for(var e=this.length||0;--e>=0;){O(this,e)===t&&this.removeAt(e)}return this}},{key:"removeObjects",value:function(t){for(var e=t.length-1;e>=0;e--)this.removeObject(t[e]);return this}},{key:"addObject",value:function(t){return this.includes(t)||this.pushObject(t),this}},{key:"addObjects",value:function(t){var e=this;return t.forEach((function(t){return e.addObject(t)})),this}}]),n}(),T=function(t){var e=null==t;if(e)return e;if("number"==typeof t.size)return!t.size;var n=i(t);if("object"===n){var r=t.size;if("number"==typeof r)return!r}if("number"==typeof t.length&&"function"!==n)return!t.length;if("object"===n){var o=t.length;if("number"==typeof o)return!o}return!1},N=function(t){return T(t)||"string"==typeof t&&!1===/\S/.test(t)};function q(t){return t instanceof V}var B=function(){var t,e,n,r,o;return!("undefined"==typeof process||"object"!==i(null===(t=process)||void 0===t?void 0:t.env)&&-1===(null===(e=process.release)||void 0===e||null===(n=e.name)||void 0===n?void 0:n.search(/node|io.js/))||"undefined"!=typeof window&&"ReactNative"!==(null===(r=window)||void 0===r||null===(o=r.navigator)||void 0===o?void 0:o.product))},U=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return B()?xt("adapter","NodeAdapter",t):xt("adapter","BrowserAdapter",t)},I=Array.isArray,J=function(){function t(e){u(this,t),this.place=e,this.geometry=null==e?void 0:e.geometry,this.components=this.parseComponents(),this.attributes=this.parseProperties()}return c(t,[{key:"parse",value:function(){this.parseComponents(),this.parseProperties()}},{key:"parseComponents",value:function(){var t;return((null===(t=this.place)||void 0===t?void 0:t.address_components)||[]).reduce((function(t,e){return e.types.forEach((function(n){t[n]=e})),t}),{})}},{key:"parseProperties",value:function(){var t,e={streetNumber:this.get("street_number"),streetName:this.get("route"),coordinates:null!==(t=this.geometry)&&void 0!==t&&t.location?Object.values(this.geometry.location):[0,0],city:this.or(["locality","sublocality","sublocality_level_1","neighborhood","administrative_area_level_3","administrative_area_level_2"]),county:this.get("administrative_area_level_2"),stateShort:this.get("administrative_area_level_1",!0),stateLong:this.get("administrative_area_level_1"),countryShort:this.get("country",!0),country:this.get("country",!0),countryLong:this.get("country"),postalCode:this.get("postal_code")};return e.address=[e.streetNumber,e.streetName].filter(Boolean).join(" "),e}},{key:"all",value:function(){return this.attributes}},{key:"or",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e1&&void 0!==arguments[1]&&arguments[1];return t in this.components?e?this.components[t].short_name:this.components[t].long_name:null}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.attributes=r(r({},this.attributes),t),this}},{key:"setAttribute",value:function(t,e){return this.attributes[t]=e,this}},{key:"getAttribute",value:function(t){return this.attributes[t]||null}}]),t}(),M=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;u(this,t),this.type="Point",this.coordinates=[n,e]}return c(t,[{key:"latitude",get:function(){return this.coordinates[1]}},{key:"longitude",get:function(){return this.coordinates[0]}},{key:"lat",value:function(){return this.latitude}},{key:"lng",value:function(){return this.longitude}},{key:"serialize",value:function(){return{type:"Point",coorindates:[this.lat(),this.lng()]}}},{key:"toJson",value:function(){return this.serialize()}},{key:"toString",value:function(){return"(".concat(this.latitude,", ").concat(this.longitude,")")}}],[{key:"fromGeoJson",value:function(e){var n=m(e.coordinates,2);return longitude=n[0],latitude=n[1],new t(latitude,longitude)}}]),t}();"undefined"==typeof arguments||arguments;var W=function(t,e){var n=t();return Array.isArray(n)||"object"===i(n)?K(n,e):null},K=function t(e,n){var r,o=e,s=i(e),u="object"===s,a="function"===s,c=Array.isArray(e),l="string"===i(n)&&n.includes(".")?n.split("."):[n];if(c||u){for(var h=0;h0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;u(this,t),this.actions=e,this.bind=n}return c(t,[{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=t||this.bind;if(!e)return this;if(null!=this&&this.actions&&"object"===i(this.actions))for(var n in this.actions){var r=this.actions[n];"function"==typeof r?G(e,n,r.bind(e)):G(e,n,r)}return this}}]),t}(),V=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};u(this,t),this.attributes=e,this.dirtyAttributes={},this.changes={},this.isLoading=!1,this.isSaving=!1,this.isDestroying=!1,this.isReloading=!1,this.resource=r,this.options=i,this.version=i.version||"v1",this.setAdapter(n)}return c(t,[{key:"setAdapter",value:function(t){var e;return this.adapter=t,this.store=new Rt(this.resource,t,{onAfterFetch:this.syncAttributes.bind(this),actions:null===(e=this.options)||void 0===e?void 0:e.actions}),this}},{key:"id",get:function(){return this.getAttribute("id")}},{key:"create",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.mergeAttributes(e);return this.setFlags(["isLoading","isSaving"]),this.store.create(n).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.setFlags(["isLoading","isSaving"]),this.store.update(this.attributes.id,e).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"destroy",value:function(){var t=this;return this.setFlags(["isLoading","isDestroying"]),this.store.destroy(this.attributes.id).then((function(e){return t.setFlags(["isLoading","isDestroying"],!1),e}))}},{key:"reload",value:function(){var t=this;return this.setFlags(["isLoading","isReloading"]),this.store.findRecord(this.attributes.id).then((function(e){return t.reset(),e}))}},{key:"setFlags",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=["isLoading","isSaving","isReloading","isDestroying"],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},e=this.getAttributes();return T(this.id)?this.create(e):!0===t.onlyDirty?this.savedirty():this.update(e)}},{key:"saveDirty",value:function(){for(var t=Object.keys(this.dirtyAttributes),e={},n=0;n0}},{key:"mutate",value:function(t,e){this.attributes[t]=e}},{key:"setAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===n&&"object"===i(t))return this.setAttributes(t);var r=null!==(e=null==this?void 0:this.attributes[t])&&void 0!==e?e:null;return G(this.attributes,t,n),G(this.dirtyAttributes,t,r),A(null==this?void 0:this.changes[t])||(this.changes[t]=[]),this.changes[t].push({property:t,previousValue:r,value:n,changedAt:new Date}),this}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)this.setAttribute(e,t[e]);return this}},{key:"getAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=K(null!==(e=null==this?void 0:this.attributes)&&void 0!==e?e:{},t);return void 0===r?n:r}},{key:"hasAttribute",value:function(t){if(A(t)){var e,n=t,r=Object.keys(null!==(e=this.attributes)&&void 0!==e?e:{});return n.every((function(t){return r.includes(t)}))}return!(null==this||!this.attributes)&&t in this.attributes}},{key:"hasAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.hasAttribute(t)}},{key:"isAttributeFilled",value:function(t){var e=this;return A(t)?this.hasAttribute(t)&&t.every((function(t){return!T(e.getAttribute(t))})):this.hasAttribute(t)&&!T(this.getAttribute(t))}},{key:"getAttributes",value:function(t){var e={};if(null==t)return this.getAttributes(Object.keys(this.attributes));if("string"==typeof t)return this.getAttribute(Array.prototype.slice.call(arguments));if(!A(t))throw new Error("No attribute properties provided!");for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=null!==(t=null==this?void 0:this.attributes)&&void 0!==t?t:{};return this.attributes=r(r({},n),e),this.attributes}},{key:"syncAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attributes=t}}]),t}(),Z=new H({getDistanceAndTime:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.adapter.get("".concat(this.namespace,"/").concat(t,"/distance-and-time"),{},e)}}),Q=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,i,"order",r({actions:Z},o))}return c(n,[{key:"getDistanceAndTime",value:function(){return this.store.getDistanceAndTime(this.id)}}]),n}(),Y=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"payload",i)}return c(n,[{key:"attach",value:function(t){}},{key:"entities",get:function(){}},{key:"dropoff",get:function(){}},{key:"pickup",get:function(){}},{key:"waypoints",get:function(){return new D(this.waypoints)}}]),n}(),X=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"entity",i)}return n}(),tt=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"place",i)}return c(n,[{key:"latitude",get:function(){var t;return null===(t=this.getAttribute("location",new M))||void 0===t?void 0:t.coordinates[1]}},{key:"longitude",get:function(){var t;return null===(t=this.getAttribute("location",new M))||void 0===t?void 0:t.coordinates[0]}},{key:"coordinates",get:function(){return[this.latitude,this.longitude]}},{key:"setOwner",value:function(t){return q(t)&&this.setAttribute("owner",t.id),"string"==typeof t&&this.setAttribute("owner",t),this}}],[{key:"fromGoogleAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.getAttribute("coordinates"),o=m(i,2),s=o[0],u=o[1],a={name:null,address:t.getAttribute("address"),location:new M(s,u),street1:t.getAttribute("streetName"),street2:null,city:t.getAttribute("city"),province:t.getAttribute("stateLong"),postal_code:t.getAttribute("postalCode"),neighborhood:t.get("neighborhood"),district:t.getAttribute("county"),building:t.get("building"),country:t.getAttribute("countryShort"),phone:null,security_access_code:null};return new n(a,e,r)}}]),n}(),et=function(t){h(n,tt);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"waypoint",i)}return n}(),nt=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"tracking-status",i)}return n}(),rt=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"vehicle",i)}return n}(),it=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"driver",i)}return n}(),ot=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"vendor",i)}return n}(),st=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"contact",i)}return n}(),ut=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"zone",i)}return n}(),at=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"service-area",i)}return n}(),ct=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"service-rate",i)}return n}(),lt=function(t){h(n,V);var e=b(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(this,n),e.call(this,t,r,"service-quote",i)}return c(n,[{key:"fromPreliminary",value:function(){}},{key:"fromPayload",value:function(){}}]),n}(),ht=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};u(this,t),this.version=e.version||"v1",this.host=e.host||null,this.namespace=e.namespace||null,this.headers=e.headers||{}},vt=function(t){h(n,ht);var e=b(n);function n(t){var r;return u(this,n),(r=e.call(this,t)).setHeaders({Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;browser"}),r}return c(n,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.headers=r(r({},this.headers),t),this}},{key:"parseJSON",value:function(t){return new Promise((function(e,n){return t.json().then((function(n){return e({statusText:t.statusText,status:t.status,ok:t.ok,json:n})})).catch((function(){n(new Error("Oops! Something went wrong when handling your request."))}))}))}},{key:"request",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise((function(s,u){return fetch(o.url||"".concat(e.host,"/").concat(e.namespace,"/").concat(t),r({method:n,mode:o.mode||"cors",headers:new Headers(r(r({},e.headers||{}),o.headers||{}))},i)).then(e.parseJSON).then((function(t){return t.ok?s(t.json):u(new Error(t.json.errors?t.json.errors[0]:t.statusText))})).catch((function(t){u(t)}))}))}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=N(e)?"":new URLSearchParams(e).toString();return this.request("".concat(t).concat(r?"?".concat(r):""),"GET",{},n)}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"POST",{body:JSON.stringify(e)},n)}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PUT",{body:JSON.stringify(e)},n)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.request(t,"DELETE",{},e)}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PATCH",{body:JSON.stringify(e)},n)}}]),n}(),ft=function(t){h(i,ht);var n=b(i);function i(t){var r;return u(this,i),(r=n.call(this,t)).axios=e.default.create({baseURL:"".concat(r.host,"/").concat(r.namespace),headers:{Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;node"}}),r}return c(i,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.axios.defaults.headers.common;return this.axios.defaults.headers.common=r(r({},e),t),this}},{key:"transform",value:function(t){return t.data}},{key:"handleError",value:function(t){if(t.response){var e=t.response.data;if(A(e.errors))throw new Error(e.errors[0]);if(e.error)throw new Error(e.error)}throw t}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=N(e)?"":new URLSearchParams(e).toString();return this.axios.get("".concat(t).concat(r?"?".concat(r):""),n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.post(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.put(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.axios.delete(t,e).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.patch(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}}]),i}(),dt=function(t){h(n,ht);var e=b(n);function n(){return u(this,n),e.apply(this,arguments)}return n}(),pt=function(){function t(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];u(this,t),l(this,"uncountableWords",["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"]),l(this,"pluralRules",[[new RegExp("(m)an$","gi"),"$1en"],[new RegExp("(pe)rson$","gi"),"$1ople"],[new RegExp("(child)$","gi"),"$1ren"],[new RegExp("^(ox)$","gi"),"$1en"],[new RegExp("(ax|test)is$","gi"),"$1es"],[new RegExp("(octop|vir)us$","gi"),"$1i"],[new RegExp("(alias|status)$","gi"),"$1es"],[new RegExp("(bu)s$","gi"),"$1ses"],[new RegExp("(buffal|tomat|potat)o$","gi"),"$1oes"],[new RegExp("([ti])um$","gi"),"$1a"],[new RegExp("sis$","gi"),"ses"],[new RegExp("(?:([^f])fe|([lr])f)$","gi"),"$1$2ves"],[new RegExp("(hive)$","gi"),"$1s"],[new RegExp("([^aeiouy]|qu)y$","gi"),"$1ies"],[new RegExp("(x|ch|ss|sh)$","gi"),"$1es"],[new RegExp("(matr|vert|ind)ix|ex$","gi"),"$1ices"],[new RegExp("([m|l])ouse$","gi"),"$1ice"],[new RegExp("(quiz)$","gi"),"$1zes"],[new RegExp("s$","gi"),"s"],[new RegExp("$","gi"),"s"]]),l(this,"singularRules",[[new RegExp("(m)en$","gi"),"$1an"],[new RegExp("(pe)ople$","gi"),"$1rson"],[new RegExp("(child)ren$","gi"),"$1"],[new RegExp("([ti])a$","gi"),"$1um"],[new RegExp("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$","gi"),"$1$2sis"],[new RegExp("(hive)s$","gi"),"$1"],[new RegExp("(tive)s$","gi"),"$1"],[new RegExp("(curve)s$","gi"),"$1"],[new RegExp("([lr])ves$","gi"),"$1f"],[new RegExp("([^fo])ves$","gi"),"$1fe"],[new RegExp("([^aeiouy]|qu)ies$","gi"),"$1y"],[new RegExp("(s)eries$","gi"),"$1eries"],[new RegExp("(m)ovies$","gi"),"$1ovie"],[new RegExp("(x|ch|ss|sh)es$","gi"),"$1"],[new RegExp("([m|l])ice$","gi"),"$1ouse"],[new RegExp("(bus)es$","gi"),"$1"],[new RegExp("(o)es$","gi"),"$1"],[new RegExp("(shoe)s$","gi"),"$1"],[new RegExp("(cris|ax|test)es$","gi"),"$1is"],[new RegExp("(octop|vir)i$","gi"),"$1us"],[new RegExp("(alias|status)es$","gi"),"$1"],[new RegExp("^(ox)en","gi"),"$1"],[new RegExp("(vert|ind)ices$","gi"),"$1ex"],[new RegExp("(matr)ices$","gi"),"$1ix"],[new RegExp("(quiz)zes$","gi"),"$1"],[new RegExp("s$","gi"),""]]),l(this,"nonTitlecasedWords",["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"]),l(this,"idSuffix",new RegExp("(_ids|_id)$","g")),l(this,"underbar",new RegExp("_","g")),l(this,"spaceOrUnderbar",new RegExp("[ _]","g")),l(this,"uppercase",new RegExp("([A-Z])","g")),l(this,"underbarPrefix",new RegExp("^_")),this.str=e,this.chain=n}return c(t,[{key:"get",value:function(){return this.str}},{key:"applyRules",value:function(t,e,n,r){if(r)t=r;else if(!(n.indexOf(t.toLowerCase())>-1))for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:null;return t=t||this.str,this.applyRules(t,this.pluralRules,this.uncountableWords,e)}},{key:"singularize",value:function(t,e){return t=t||this.str,this.applyRules(t,this.singularRules,this.uncountableWords,e)}},{key:"camelize",value:function(t,e){for(var n=(t=t||this.str).split("/"),r=0;r1&&void 0!==arguments[1]&&arguments[1];return t=t||this.str,t=this.underscore(this.demodulize(t))+(e?"":"_")+"id",this.str=t,!0===this.chain?this:t}},{key:"ordinalize",value:function(t){for(var e=(t=t||this.str).split(" "),n=0;n1&&void 0!==arguments[1]?arguments[1]:[];if(t.actions=A(e)?e:[e],!A(e))return e instanceof H&&e.extend(t),t;for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};u(this,t),this.resource=e,this.adapter=n||U(),this.namespace=gt(e),this.storage=new D,this.options=r,this.extendActions(r.actions)}return c(t,[{key:"extendActions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return At(this,t)}},{key:"deposit",value:function(t){return t}},{key:"serialize",value:function(t){return xt("resource",bt(this.resource),t,this.adapter)}},{key:"afterFetch",value:function(t){return function(t,e){if("function"==typeof t.options.onAfterFetch&&t.options.onAfterFetch(e),A(e)){for(var n=[],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=s(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.post("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"update",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(function(){var i=s(regeneratorRuntime.mark((function i(o,s){var u;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,e.adapter.put("".concat(e.namespace,"/").concat(t),n,r).then(e.afterFetch.bind(e)).catch(s);case 2:u=i.sent,o(u);case 4:case"end":return i.stop()}}),i)})));return function(t,e){return i.apply(this,arguments)}}())}},{key:"findRecord",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=s(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e.adapter.get("".concat(e.namespace,"/").concat(t),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"findAll",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var n=s(regeneratorRuntime.mark((function n(r,i){var o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.adapter.get("".concat(t.namespace),{},e).then(t.afterFetch.bind(t)).catch(i);case 2:o=n.sent,r(o);case 4:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"query",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=s(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"queryRecord",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.single=!0,new Promise(function(){var r=s(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"destroy",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=q(t)?t.getAttribute("id"):t;return new Promise(function(){var t=s(regeneratorRuntime.mark((function t(i,o){var s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.adapter.delete("".concat(e.namespace,"/").concat(r),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=t.sent,i(s);case 4:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}}]),t}(),$t=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(u(this,t),this.version=n.version||"v1",this.options={version:this.version,host:n.host||"https://api.fleetbase.io",namespace:this.version||n.namespace,debug:r,publicKey:e},"string"!=typeof e||0===e.length)throw new Error("⚠️ Invalid public key given to Fleetbase SDK");if(!B()&&e.toLowerCase().startsWith("$"))throw new Error("Secret key provided. You must use a public key with Fleetbase Javascript SDK!");this.adapter=n.adapter||U(this.options),this.orders=new Rt("order",this.adapter).extendActions(Z),this.entities=new Rt("entity",this.adapter),this.places=new Rt("place",this.adapter),this.drivers=new Rt("driver",this.adapter),this.vehicles=new Rt("vehicle",this.adapter),this.vendors=new Rt("vendor",this.adapter),this.contacts=new Rt("contact",this.adapter)}return c(t,[{key:"setAdapter",value:function(t){this.adapter=t}},{key:"getAdapter",value:function(){return this.adapter}}],[{key:"newInstance",value:function(){return p(t,Array.prototype.slice.call(arguments))}}]),t}();exports.Adapter=ht,exports.BrowserAdapter=vt,exports.Collection=D,exports.Contact=st,exports.Driver=it,exports.EmberJsAdapter=dt,exports.Entity=X,exports.GoogleAddress=J,exports.NodeAdapter=ft,exports.Order=Q,exports.Payload=Y,exports.Place=tt,exports.Point=M,exports.Resource=V,exports.ServiceArea=at,exports.ServiceQuote=lt,exports.ServiceRate=ct,exports.Store=Rt,exports.StoreActions=H,exports.TrackingStatus=nt,exports.Vehicle=rt,exports.Vendor=ot,exports.Waypoint=et,exports.Zone=ut,exports.camelize=function(){var t=["camelize"].concat(Array.prototype.slice.call(arguments));return pt.invoke.apply(pt,k(t))},exports.classify=bt,exports.dasherize=function(){var t=["dasherize"].concat(Array.prototype.slice.call(arguments));return pt.invoke.apply(pt,k(t))},exports.default=$t,exports.extendStoreActions=At,exports.isLatitude=function(t){return isFinite(t)&&Math.abs(t)<=90},exports.isLongitude=function(t){return isFinite(t)&&Math.abs(t)<=180&&Math.abs(t)>=90},exports.isNodeEnvironment=B,exports.isResource=q,exports.pluralize=gt,exports.singularize=yt; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("axios");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}require("date-fns");var n=e(t);function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function i(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=new Array(e);n3&&void 0!==arguments[3]?arguments[3]:[];if(E(t))if(r.length<=6e4)t.splice.apply(t,[e,n].concat(w(r)));else{t.splice(e,n);for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:0,r=t.length,i=n;i2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0,i=t.length;n<0&&(n+=i);var o=r&&e!=e?function(t){return t!=t}:function(t){return t===e};return P(t,o,n)},C=function(t,e,n){return $(t,e,0,[n]),n},N=function(t){v(n,y(Array));var e=k(n);function n(){for(var t=arguments.length,r=new Array(t),i=0;i0}},{key:"empty",get:function(){return 0===this.length}},{key:"first",get:function(){return S(this,0)}},{key:"last",get:function(){return S(this,this.length-1)}},{key:"replace",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return $(this,t,e,n),this}},{key:"objectsAt",value:function(t){var e=this;return t.map((function(t){return S(e,t)}))}},{key:"objectAt",value:function(t){return S(this,t)}},{key:"indexOf",value:function(t,e){return L(this,t,e,!1)}},{key:"lastIndexOf",value:function(t,e){var n=this.length;(void 0===e||e>=n)&&(e=n-1),e<0&&(e+=n);for(var r=e;r>=0;r--)if(S(this,r)===t)return r;return-1}},{key:"includes",value:function(t,e){return-1!==L(this,t,e,!0)}},{key:"findBy",value:function(){return z(this,_.apply(void 0,arguments))}},{key:"findIndexBy",value:function(){return P(this,_.apply(void 0,arguments))}},{key:"isEvery",value:function(){return D(this,_.apply(void 0,arguments))}},{key:"isAny",value:function(){return F(this,_.apply(void 0,arguments))}},{key:"invoke",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:j,n=[],r=new Set,i="function"==typeof e?e:function(t){return get(t,e)};return t.forEach((function(t){var e=i(t);r.has(e)||(r.add(e),n.push(t))})),n}(this,t)}},{key:"without",value:function(t){if(!this.includes(t))return this;var e=t==t?function(e){return e!==t}:function(t){return t==t};return this.filter(e)}},{key:"clear",value:function(){var t=this.length;return 0===t||this.replace(0,t,[]),this}},{key:"insertAt",value:function(t,e){return C(this,t,e),this}},{key:"replaceAt",value:function(t,e){return this.replace(t,1,[e])}},{key:"removeAt",value:function(t,e){return function(t,e){return $(t,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,[]),t}(this,t,e)}},{key:"pushObject",value:function(t){return this.insertAt(this.length,t)}},{key:"pushObjects",value:function(t){return this.replace(this.length,0,t),this}},{key:"popObject",value:function(){var t=this.length;if(0===t)return null;var e=S(this,t-1);return this.removeAt(t-1,1),e}},{key:"shiftObject",value:function(){if(0===this.length)return null;var t=S(this,0);return this.removeAt(0),t}},{key:"unshiftObject",value:function(t){return C(this,0,t)}},{key:"unshiftObjects",value:function(t){return this.replace(0,0,t),this}},{key:"reverseObjects",value:function(){var t=this.length;if(0===t)return this;var e=this.toArray().reverse();return this.replace(0,t,e),this}},{key:"setObjects",value:function(t){if(0===t.length)return this.clear();var e=this.length;return this.replace(0,e,t),this}},{key:"removeObject",value:function(t){for(var e=this.length||0;--e>=0;){S(this,e)===t&&this.removeAt(e)}return this}},{key:"removeObjects",value:function(t){for(var e=t.length-1;e>=0;e--)this.removeObject(t[e]);return this}},{key:"addObject",value:function(t){return this.includes(t)||this.pushObject(t),this}},{key:"addObjects",value:function(t){var e=this;return t.forEach((function(t){return e.addObject(t)})),this}}]),n}(),T=function(t){var e=null==t;if(e)return e;if("number"==typeof t.size)return!t.size;var n=o(t);if("object"===n){var r=t.size;if("number"==typeof r)return!r}if("number"==typeof t.length&&"function"!==n)return!t.length;if("object"===n){var i=t.length;if("number"==typeof i)return!i}return!1},q=function(t){return T(t)||"string"==typeof t&&!1===/\S/.test(t)};function B(t){return t instanceof Q}var U=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^[+]?[\s./0-9]*[(]?[0-9]{1,4}[)]?[-\s./0-9]*$/g.test(t)},I=function(){var t,e,n,r,i;return!("undefined"==typeof process||"object"!==o(null===(t=process)||void 0===t?void 0:t.env)&&-1===(null===(e=process.release)||void 0===e||null===(n=e.name)||void 0===n?void 0:n.search(/node|io.js/))||"undefined"!=typeof window&&"ReactNative"!==(null===(r=window)||void 0===r||null===(i=r.navigator)||void 0===i?void 0:i.product))},J=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return I()?Rt("adapter","NodeAdapter",t):Rt("adapter","BrowserAdapter",t)},W=Array.isArray,M=function(){function t(e){a(this,t),this.place=e,this.geometry=null==e?void 0:e.geometry,this.components=this.parseComponents(),this.attributes=this.parseProperties()}return h(t,[{key:"parse",value:function(){this.parseComponents(),this.parseProperties()}},{key:"parseComponents",value:function(){var t;return((null===(t=this.place)||void 0===t?void 0:t.address_components)||[]).reduce((function(t,e){return e.types.forEach((function(n){t[n]=e})),t}),{})}},{key:"parseProperties",value:function(){var t,e={streetNumber:this.get("street_number"),streetName:this.get("route"),coordinates:null!==(t=this.geometry)&&void 0!==t&&t.location?Object.values(this.geometry.location):[0,0],city:this.or(["locality","sublocality","sublocality_level_1","neighborhood","administrative_area_level_3","administrative_area_level_2"]),county:this.get("administrative_area_level_2"),stateShort:this.get("administrative_area_level_1",!0),stateLong:this.get("administrative_area_level_1"),countryShort:this.get("country",!0),country:this.get("country",!0),countryLong:this.get("country"),postalCode:this.get("postal_code")};return e.address=[e.streetNumber,e.streetName].filter(Boolean).join(" "),e}},{key:"all",value:function(){return this.attributes}},{key:"or",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e1&&void 0!==arguments[1]&&arguments[1];return t in this.components?e?this.components[t].short_name:this.components[t].long_name:null}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.attributes=i(i({},this.attributes),t),this}},{key:"setAttribute",value:function(t,e){return this.attributes[t]=e,this}},{key:"getAttribute",value:function(t){return this.attributes[t]||null}}]),t}(),H=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;a(this,t),this.type="Point",this.coordinates=[n,e]}return h(t,[{key:"latitude",get:function(){return this.coordinates[1]}},{key:"longitude",get:function(){return this.coordinates[0]}},{key:"lat",value:function(){return this.latitude}},{key:"lng",value:function(){return this.longitude}},{key:"serialize",value:function(){return{type:"Point",coorindates:[this.lat(),this.lng()]}}},{key:"toJson",value:function(){return this.serialize()}},{key:"toString",value:function(){return"(".concat(this.latitude,", ").concat(this.longitude,")")}}],[{key:"fromGeoJson",value:function(e){var n=m(e.coordinates,2);return longitude=n[0],latitude=n[1],new t(latitude,longitude)}}]),t}();"undefined"==typeof arguments||arguments;var K=function(t,e){var n=t();return Array.isArray(n)||"object"===o(n)?G(n,e):null},G=function t(e,n){var r,i=e,s=o(e),u="object"===s,a="function"===s,c=Array.isArray(e),h="string"===o(n)&&n.includes(".")?n.split("."):[n];if(c||u){for(var l=0;l0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;a(this,t),this.actions=e,this.bind=n}return h(t,[{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=t||this.bind;if(!e)return this;if(null!=this&&this.actions&&"object"===o(this.actions))for(var n in this.actions){var r=this.actions[n];"function"==typeof r?V(e,n,r.bind(e)):V(e,n,r)}return this}}]),t}(),Q=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};a(this,t),this.attributes=e,this.dirtyAttributes={},this.changes={},this.isLoading=!1,this.isSaving=!1,this.isDestroying=!1,this.isReloading=!1,this.resource=r,this.options=i,this.version=i.version||"v1",this.setAdapter(n)}return h(t,[{key:"setAdapter",value:function(t){var e;return this.adapter=t,this.store=new jt(this.resource,t,{onAfterFetch:this.syncAttributes.bind(this),actions:null===(e=this.options)||void 0===e?void 0:e.actions}),this}},{key:"id",get:function(){return this.getAttribute("id")}},{key:"create",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.mergeAttributes(e);return this.setFlags(["isLoading","isSaving"]),this.store.create(n).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.setFlags(["isLoading","isSaving"]),this.store.update(this.attributes.id,e).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"destroy",value:function(){var t=this;return this.setFlags(["isLoading","isDestroying"]),this.store.destroy(this.attributes.id).then((function(e){return t.setFlags(["isLoading","isDestroying"],!1),e}))}},{key:"reload",value:function(){var t=this;return this.setFlags(["isLoading","isReloading"]),this.store.findRecord(this.attributes.id).then((function(e){return t.reset(),e}))}},{key:"setFlags",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=["isLoading","isSaving","isReloading","isDestroying"],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},e=this.getAttributes();return T(this.id)?this.create(e):!0===t.onlyDirty?this.savedirty():this.update(e)}},{key:"saveDirty",value:function(){for(var t=Object.keys(this.dirtyAttributes),e={},n=0;n0}},{key:"mutate",value:function(t,e){this.attributes[t]=e}},{key:"setAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===n&&"object"===o(t))return this.setAttributes(t);var r=null!==(e=null==this?void 0:this.attributes[t])&&void 0!==e?e:null;return V(this.attributes,t,n),V(this.dirtyAttributes,t,r),E(null==this?void 0:this.changes[t])||(this.changes[t]=[]),this.changes[t].push({property:t,previousValue:r,value:n,changedAt:new Date}),this}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)this.setAttribute(e,t[e]);return this}},{key:"getAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=G(null!==(e=null==this?void 0:this.attributes)&&void 0!==e?e:{},t);return void 0===r?n:r}},{key:"hasAttribute",value:function(t){if(E(t)){var e,n=t,r=Object.keys(null!==(e=this.attributes)&&void 0!==e?e:{});return n.every((function(t){return r.includes(t)}))}return!(null==this||!this.attributes)&&t in this.attributes}},{key:"hasAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.hasAttribute(t)}},{key:"isAttributeFilled",value:function(t){var e=this;return E(t)?this.hasAttribute(t)&&t.every((function(t){return!T(e.getAttribute(t))})):this.hasAttribute(t)&&!T(this.getAttribute(t))}},{key:"getAttributes",value:function(t){var e={};if(null==t)return this.getAttributes(Object.keys(this.attributes));if("string"==typeof t)return this.getAttribute(Array.prototype.slice.call(arguments));if(!E(t))throw new Error("No attribute properties provided!");for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=null!==(t=null==this?void 0:this.attributes)&&void 0!==t?t:{};return this.attributes=i(i({},n),e),this.attributes}},{key:"syncAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attributes=t}}]),t}(),Y=new Z({getDistanceAndTime:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.get("".concat(this.namespace,"/").concat(t,"/distance-and-time"),e,n)},getNextActivity:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.get("".concat(this.namespace,"/").concat(t,"/next-activity"),e,n)},dispatch:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/dispatch"),e,n).then(this.afterFetch.bind(this))},start:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/start"),e,n).then(this.afterFetch.bind(this))},updateActivity:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/update-activity"),e,n).then(this.afterFetch.bind(this))},complete:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/complete"),e,n).then(this.afterFetch.bind(this))},cancel:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.delete("".concat(this.namespace,"/").concat(t,"/cancel"),e,n).then(this.afterFetch.bind(this))}}),X=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"order",i({actions:Y},o))}return h(n,[{key:"getDistanceAndTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.getDistanceAndTime(this.id,t,e)}},{key:"dispatch",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.dispatch(this.id,t,e)}},{key:"start",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.start(this.id,t,e)}},{key:"getNextActivity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.getNextActivity(this.id,t,e)}},{key:"updateActivity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.updateActivity(this.id,t,e)}},{key:"cancel",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.cancel(this.id,t,e)}},{key:"complete",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.complete(this.id,t,e)}},{key:"isDispatched",get:function(){return null!==this.getAttribute("dispatched_at")}},{key:"isNotDispatched",get:function(){return null==this.getAttribute("dispatched_at")}},{key:"isStarted",get:function(){return null!==this.getAttribute("started_at")}},{key:"isNotStarted",get:function(){return null==this.getAttribute("started_at")}},{key:"isCompleted",get:function(){return"completed"==this.getAttribute("status")}},{key:"isCanceled",get:function(){return"canceled"==this.getAttribute("status")}},{key:"isEnroute",get:function(){return"driver_enroute"==this.getAttribute("status")||"enroute"===this.getAttribute("status")}},{key:"isInProgress",get:function(){return this.isStarted&&!this.isCanceled&&!this.isCompleted}},{key:"scheduledAt",get:function(){return this.isAttributeFilled("scheduled_at")?new Date(this.getAttribute("scheduled_at")):null}},{key:"startedAt",get:function(){return this.isAttributeFilled("started_at")?new Date(this.getAttribute("started_at")):null}},{key:"dispatchedAt",get:function(){return this.isAttributeFilled("dispatched_at")?new Date(this.getAttribute("dispatched_at")):null}},{key:"status",get:function(){return this.getAttribute("status")}}]),n}(),tt=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"payload",i)}return h(n,[{key:"attach",value:function(t){}},{key:"entities",get:function(){}},{key:"dropoff",get:function(){}},{key:"pickup",get:function(){}},{key:"waypoints",get:function(){return new N(this.waypoints)}}]),n}(),et=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"entity",i)}return n}(),nt=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"place",i)}return h(n,[{key:"latitude",get:function(){var t;return null===(t=this.getAttribute("location",new H))||void 0===t?void 0:t.coordinates[1]}},{key:"longitude",get:function(){var t;return null===(t=this.getAttribute("location",new H))||void 0===t?void 0:t.coordinates[0]}},{key:"coordinates",get:function(){return[this.latitude,this.longitude]}},{key:"setOwner",value:function(t){return B(t)&&this.setAttribute("owner",t.id),"string"==typeof t&&this.setAttribute("owner",t),this}}],[{key:"fromGoogleAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.getAttribute("coordinates"),o=m(i,2),s=o[0],u=o[1],a={name:null,address:t.getAttribute("address"),location:new H(s,u),street1:t.getAttribute("streetName"),street2:null,city:t.getAttribute("city"),province:t.getAttribute("stateLong"),postal_code:t.getAttribute("postalCode"),neighborhood:t.get("neighborhood"),district:t.getAttribute("county"),building:t.get("building"),country:t.getAttribute("countryShort"),phone:null,security_access_code:null};return new n(a,e,r)}}]),n}(),rt=function(t){v(n,nt);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"waypoint",i)}return n}(),it=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"tracking-status",i)}return n}(),ot=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"vehicle",i)}return n}(),st=new Z({login:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(U(t))return this.adapter.post("drivers/login-with-sms",{phone:t});if(!e)throw new Error("Login requires password!");return this.adapter.post("drivers/login",i({identity:t,password:e},n)).then(this.afterFetch.bind(this))},verifyCode:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("drivers/verify-code",i({identity:t,code:e},n)).then(this.afterFetch.bind(this))},retrieve:function(t){return this.findRecord(t)}}),ut=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"driver",i)}return h(n,[{key:"token",get:function(){return this.getAttribute("token")}},{key:"isOnline",get:function(){return!0===this.getAttribute("online")}},{key:"syncDevice",value:function(t){var e=this;return this.adapter.setHeaders({"Driver-Token":this.token}).post("drivers/register-device",t).then((function(){return e}))}}]),n}(),at=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"vendor",i)}return n}(),ct=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"contact",i)}return n}(),ht=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"zone",i)}return n}(),lt=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"service-area",i)}return n}(),vt=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"service-rate",i)}return n}(),dt=function(t){v(n,Q);var e=k(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(this,n),e.call(this,t,r,"service-quote",i)}return h(n,[{key:"fromPreliminary",value:function(){}},{key:"fromPayload",value:function(){}}]),n}(),ft=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t),this.version=e.version||"v1",this.host=e.host||null,this.namespace=e.namespace||null,this.headers=e.headers||{}},pt=function(t){v(n,ft);var e=k(n);function n(t){var r;return a(this,n),(r=e.call(this,t)).setHeaders({Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;browser"}),r}return h(n,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.headers=i(i({},this.headers),t),this}},{key:"parseJSON",value:function(t){return new Promise((function(e,n){return t.json().then((function(n){return e({statusText:t.statusText,status:t.status,ok:t.ok,json:n})})).catch((function(){n(new Error("Oops! Something went wrong when handling your request."))}))}))}},{key:"request",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise((function(s,u){return fetch(o.url||"".concat(e.host,"/").concat(e.namespace,"/").concat(t),i({method:n,mode:o.mode||"cors",headers:new Headers(i(i({},e.headers||{}),o.headers||{}))},r)).then(e.parseJSON).then((function(t){return t.ok?s(t.json):u(new Error(t.json.errors?t.json.errors[0]:t.statusText))})).catch((function(t){u(t)}))}))}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=q(e)?"":new URLSearchParams(e).toString();return this.request("".concat(t).concat(r?"?".concat(r):""),"GET",{},n)}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"POST",{body:JSON.stringify(e)},n)}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PUT",{body:JSON.stringify(e)},n)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.request(t,"DELETE",{},e)}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PATCH",{body:JSON.stringify(e)},n)}}]),n}(),gt=function(t){v(r,ft);var e=k(r);function r(t){var i;return a(this,r),(i=e.call(this,t)).axios=n.default.create({baseURL:"".concat(i.host,"/").concat(i.namespace),headers:{Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;node"}}),i}return h(r,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.axios.defaults.headers.common;return this.axios.defaults.headers.common=i(i({},e),t),this}},{key:"transform",value:function(t){return t.data}},{key:"handleError",value:function(t){if(t.response){var e=t.response.data;if(E(e.errors))throw new Error(e.errors[0]);if(e.error)throw new Error(e.error)}throw t}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=q(e)?"":new URLSearchParams(e).toString();return this.axios.get("".concat(t).concat(r?"?".concat(r):""),n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.post(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.put(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.axios.delete(t,e).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.patch(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}}]),r}(),yt=function(t){v(n,ft);var e=k(n);function n(){return a(this,n),e.apply(this,arguments)}return n}(),bt=function(){function t(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];a(this,t),l(this,"uncountableWords",["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"]),l(this,"pluralRules",[[new RegExp("(m)an$","gi"),"$1en"],[new RegExp("(pe)rson$","gi"),"$1ople"],[new RegExp("(child)$","gi"),"$1ren"],[new RegExp("^(ox)$","gi"),"$1en"],[new RegExp("(ax|test)is$","gi"),"$1es"],[new RegExp("(octop|vir)us$","gi"),"$1i"],[new RegExp("(alias|status)$","gi"),"$1es"],[new RegExp("(bu)s$","gi"),"$1ses"],[new RegExp("(buffal|tomat|potat)o$","gi"),"$1oes"],[new RegExp("([ti])um$","gi"),"$1a"],[new RegExp("sis$","gi"),"ses"],[new RegExp("(?:([^f])fe|([lr])f)$","gi"),"$1$2ves"],[new RegExp("(hive)$","gi"),"$1s"],[new RegExp("([^aeiouy]|qu)y$","gi"),"$1ies"],[new RegExp("(x|ch|ss|sh)$","gi"),"$1es"],[new RegExp("(matr|vert|ind)ix|ex$","gi"),"$1ices"],[new RegExp("([m|l])ouse$","gi"),"$1ice"],[new RegExp("(quiz)$","gi"),"$1zes"],[new RegExp("s$","gi"),"s"],[new RegExp("$","gi"),"s"]]),l(this,"singularRules",[[new RegExp("(m)en$","gi"),"$1an"],[new RegExp("(pe)ople$","gi"),"$1rson"],[new RegExp("(child)ren$","gi"),"$1"],[new RegExp("([ti])a$","gi"),"$1um"],[new RegExp("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$","gi"),"$1$2sis"],[new RegExp("(hive)s$","gi"),"$1"],[new RegExp("(tive)s$","gi"),"$1"],[new RegExp("(curve)s$","gi"),"$1"],[new RegExp("([lr])ves$","gi"),"$1f"],[new RegExp("([^fo])ves$","gi"),"$1fe"],[new RegExp("([^aeiouy]|qu)ies$","gi"),"$1y"],[new RegExp("(s)eries$","gi"),"$1eries"],[new RegExp("(m)ovies$","gi"),"$1ovie"],[new RegExp("(x|ch|ss|sh)es$","gi"),"$1"],[new RegExp("([m|l])ice$","gi"),"$1ouse"],[new RegExp("(bus)es$","gi"),"$1"],[new RegExp("(o)es$","gi"),"$1"],[new RegExp("(shoe)s$","gi"),"$1"],[new RegExp("(cris|ax|test)es$","gi"),"$1is"],[new RegExp("(octop|vir)i$","gi"),"$1us"],[new RegExp("(alias|status)es$","gi"),"$1"],[new RegExp("^(ox)en","gi"),"$1"],[new RegExp("(vert|ind)ices$","gi"),"$1ex"],[new RegExp("(matr)ices$","gi"),"$1ix"],[new RegExp("(quiz)zes$","gi"),"$1"],[new RegExp("s$","gi"),""]]),l(this,"nonTitlecasedWords",["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"]),l(this,"idSuffix",new RegExp("(_ids|_id)$","g")),l(this,"underbar",new RegExp("_","g")),l(this,"spaceOrUnderbar",new RegExp("[ _]","g")),l(this,"uppercase",new RegExp("([A-Z])","g")),l(this,"underbarPrefix",new RegExp("^_")),this.str=e,this.chain=n}return h(t,[{key:"get",value:function(){return this.str}},{key:"applyRules",value:function(t,e,n,r){if(r)t=r;else if(!(n.indexOf(t.toLowerCase())>-1))for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:null;return t=t||this.str,this.applyRules(t,this.pluralRules,this.uncountableWords,e)}},{key:"singularize",value:function(t,e){return t=t||this.str,this.applyRules(t,this.singularRules,this.uncountableWords,e)}},{key:"camelize",value:function(t,e){for(var n=(t=t||this.str).split("/"),r=0;r1&&void 0!==arguments[1]&&arguments[1];return t=t||this.str,t=this.underscore(this.demodulize(t))+(e?"":"_")+"id",this.str=t,!0===this.chain?this:t}},{key:"ordinalize",value:function(t){for(var e=(t=t||this.str).split(" "),n=0;n1&&void 0!==arguments[1]?arguments[1]:[];if(t.actions=E(e)?e:[e],!E(e))return e instanceof Z&&e.extend(t),t;for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};a(this,t),this.resource=e,this.adapter=n||J(),this.namespace=kt(e),this.storage=new N,this.options=r,this.extendActions(r.actions)}return h(t,[{key:"extendActions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return $t(this,t)}},{key:"deposit",value:function(t){return t}},{key:"serialize",value:function(t){return Rt("resource",wt(this.resource),t,this.adapter)}},{key:"afterFetch",value:function(t){return function(t,e){if("function"==typeof t.options.onAfterFetch&&t.options.onAfterFetch(e),E(e)){for(var n=[],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=u(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.post("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"update",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(function(){var i=u(regeneratorRuntime.mark((function i(o,s){var u;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,e.adapter.put("".concat(e.namespace,"/").concat(t),n,r).then(e.afterFetch.bind(e)).catch(s);case 2:u=i.sent,o(u);case 4:case"end":return i.stop()}}),i)})));return function(t,e){return i.apply(this,arguments)}}())}},{key:"findRecord",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=u(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e.adapter.get("".concat(e.namespace,"/").concat(t),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"findAll",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var n=u(regeneratorRuntime.mark((function n(r,i){var o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.adapter.get("".concat(t.namespace),{},e).then(t.afterFetch.bind(t)).catch(i);case 2:o=n.sent,r(o);case 4:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"query",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=u(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"queryRecord",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.single=!0,new Promise(function(){var r=u(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"destroy",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=B(t)?t.getAttribute("id"):t;return new Promise(function(){var t=u(regeneratorRuntime.mark((function t(i,o){var s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.adapter.delete("".concat(e.namespace,"/").concat(r),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=t.sent,i(s);case 4:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}}]),t}(),Ot=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(a(this,t),this.version=n.version||"v1",this.options={version:this.version,host:n.host||"https://api.fleetbase.io",namespace:this.version||n.namespace,debug:r,publicKey:e},"string"!=typeof e||0===e.length)throw new Error("⚠️ Invalid public key given to Fleetbase SDK");if(!I()&&e.toLowerCase().startsWith("$"))throw new Error("Secret key provided. You must use a public key with Fleetbase Javascript SDK!");this.adapter=n.adapter||J(this.options),this.orders=new jt("order",this.adapter).extendActions(Y),this.entities=new jt("entity",this.adapter),this.places=new jt("place",this.adapter),this.drivers=new jt("driver",this.adapter).extendActions(st),this.vehicles=new jt("vehicle",this.adapter),this.vendors=new jt("vendor",this.adapter),this.contacts=new jt("contact",this.adapter)}return h(t,[{key:"setAdapter",value:function(t){this.adapter=t}},{key:"getAdapter",value:function(){return this.adapter}}],[{key:"newInstance",value:function(){return g(t,Array.prototype.slice.call(arguments))}}]),t}();exports.Adapter=ft,exports.BrowserAdapter=pt,exports.Collection=N,exports.Contact=ct,exports.Driver=ut,exports.EmberJsAdapter=yt,exports.Entity=et,exports.GoogleAddress=M,exports.NodeAdapter=gt,exports.Order=X,exports.Payload=tt,exports.Place=nt,exports.Point=H,exports.Resource=Q,exports.ServiceArea=lt,exports.ServiceQuote=dt,exports.ServiceRate=vt,exports.Store=jt,exports.StoreActions=Z,exports.TrackingStatus=it,exports.Vehicle=ot,exports.Vendor=at,exports.Waypoint=rt,exports.Zone=ht,exports.camelize=function(){var t=["camelize"].concat(Array.prototype.slice.call(arguments));return bt.invoke.apply(bt,w(t))},exports.classify=wt,exports.dasherize=function(){var t=["dasherize"].concat(Array.prototype.slice.call(arguments));return bt.invoke.apply(bt,w(t))},exports.default=Ot,exports.extendStoreActions=$t,exports.isLatitude=function(t){return isFinite(t)&&Math.abs(t)<=90},exports.isLongitude=function(t){return isFinite(t)&&Math.abs(t)<=180&&Math.abs(t)>=90},exports.isNodeEnvironment=I,exports.isResource=B,exports.pluralize=kt,exports.singularize=mt; //# sourceMappingURL=fleetbase.js.map diff --git a/dist/cjs/fleetbase.js.map b/dist/cjs/fleetbase.js.map index 444b387..7d31b14 100644 --- a/dist/cjs/fleetbase.js.map +++ b/dist/cjs/fleetbase.js.map @@ -1 +1 @@ -{"version":3,"file":"fleetbase.js","sources":["../../src/utils/array.js","../../src/utils/collection.js","../../src/utils/is-empty.js","../../src/utils/is-blank.js","../../src/utils/is-resource.js","../../src/utils/is-node-environment.js","../../src/utils/detect-adapter.js","../../src/utils/google-address.js","../../src/utils/point.js","../../src/utils/object.js","../../src/utils/store-actions.js","../../src/resource.js","../../src/resources/order.js","../../src/resources/payload.js","../../src/resources/entity.js","../../src/resources/place.js","../../src/resources/waypoint.js","../../src/resources/tracking-status.js","../../src/resources/vehicle.js","../../src/resources/driver.js","../../src/resources/vendor.js","../../src/resources/contact.js","../../src/resources/zone.js","../../src/resources/service-area.js","../../src/resources/service-rate.js","../../src/resources/service-quote.js","../../src/adapter.js","../../src/adapters/browser.js","../../src/adapters/node.js","../../src/adapters/ember.js","../../src/utils/string.js","../../src/resolver.js","../../src/store.js","../../src/fleetbase.js","../../src/utils/is-latitude.js","../../src/utils/is-longitude.js"],"sourcesContent":["const { isArray } = Array;\n\nexport {\n isArray\n};\n","import { isArray } from './array';\n\n/**\n * Collection\n * Extended array inspired by Ember's NativeArray\n **/\n\nconst CHUNK_SIZE = 60000;\n\n// To avoid overflowing the stack, we splice up to CHUNK_SIZE items at a time.\n// See https://code.google.com/p/chromium/issues/detail?id=56588 for more details.\nconst replace = (array, start, deleteCount, items = []) => {\n if (isArray(array)) {\n if (items.length <= CHUNK_SIZE) {\n array.splice(start, deleteCount, ...items);\n } else {\n array.splice(start, deleteCount);\n\n for (let i = 0; i < items.length; i += CHUNK_SIZE) {\n let chunk = items.slice(i, i + CHUNK_SIZE);\n array.splice(start + i, 0, ...chunk);\n }\n }\n } else if (isCollection(arr)) {\n array.replace(start, deleteCount, items);\n }\n};\n\nconst identityFunction = (item) => item;\n\nconst uniqBy = (array, key = identityFunction) => {\n let ret = [];\n let seen = new Set();\n let getter = typeof key === 'function' ? key : (item) => get(item, key);\n\n array.forEach((item) => {\n let val = getter(item);\n if (!seen.has(val)) {\n seen.add(val);\n ret.push(item);\n }\n });\n\n return ret;\n};\n\nconst isCollection = (mixed) => mixed instanceof Collection;\n\nconst objectAt = (array, index) => {\n if (isArray(array)) {\n return array[index];\n } else if (isCollection(array)) {\n return array.objectAt(index);\n }\n\n return null;\n};\n\nconst iter = (key, value) => {\n let valueProvided = arguments.length === 2;\n return valueProvided ? (item) => value === item[key] : (item) => Boolean(item[key]);\n};\n\nconst findIndex = (array, predicate, startAt = 0) => {\n let len = array.length;\n for (let index = startAt; index < len; index++) {\n let item = objectAt(array, index);\n if (predicate(item, index, array)) {\n return index;\n }\n }\n return -1;\n};\n\nconst find = (array, callback, target) => {\n let predicate = callback.bind(target);\n let index = findIndex(array, predicate, 0);\n return index === -1 ? undefined : objectAt(array, index);\n};\n\nconst any = (array, callback, target) => {\n let predicate = callback.bind(target);\n return findIndex(array, predicate, 0) !== -1;\n};\n\nconst every = (array, callback, target) => {\n let cb = callback.bind(target);\n let predicate = (item, index, array) => !cb(item, index, array);\n return findIndex(array, predicate, 0) === -1;\n};\n\nconst indexOf = (array, val, startAt = 0, withNaNCheck) => {\n let len = array.length;\n\n if (startAt < 0) {\n startAt += len;\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = withNaNCheck && val !== val ? (item) => item !== item : (item) => item === val;\n return findIndex(array, predicate, startAt);\n};\n\nconst removeAt = (array, index, len = 1) => {\n replace(array, index, len, []);\n return array;\n};\n\nconst insertAt = (array, index, item) => {\n replace(array, index, 0, [item]);\n return item;\n};\n\nclass Collection extends Array {\n constructor(...items) {\n if (isArray(arguments[0])) {\n super(...arguments[0]);\n } else {\n super(...arguments);\n }\n }\n\n get notEmpty() {\n return this.length > 0;\n }\n\n get empty() {\n return this.length === 0;\n }\n\n get first() {\n return objectAt(this, 0);\n }\n\n get last() {\n return objectAt(this, this.length - 1);\n }\n\n replace(start, deleteCount, items = []) {\n replace(this, start, deleteCount, items);\n\n return this;\n }\n\n objectsAt(indexes) {\n return indexes.map((idx) => objectAt(this, idx));\n }\n\n objectAt(index) {\n return objectAt(this, index);\n }\n\n indexOf(object, startAt) {\n return indexOf(this, object, startAt, false);\n }\n\n lastIndexOf(object, startAt) {\n let len = this.length;\n\n if (startAt === undefined || startAt >= len) {\n startAt = len - 1;\n }\n\n if (startAt < 0) {\n startAt += len;\n }\n\n for (let idx = startAt; idx >= 0; idx--) {\n if (objectAt(this, idx) === object) {\n return idx;\n }\n }\n\n return -1;\n }\n\n includes(object, startAt) {\n return indexOf(this, object, startAt, true) !== -1;\n }\n\n findBy() {\n return find(this, iter(...arguments));\n }\n\n findIndexBy() {\n return findIndex(this, iter(...arguments));\n }\n\n isEvery() {\n return every(this, iter(...arguments));\n }\n\n isAny() {\n return any(this, iter(...arguments));\n }\n\n invoke(methodName, ...args) {\n let ret = [];\n\n this.forEach((item) => ret.push(item[methodName]?.(...args)));\n\n return ret;\n }\n\n toArray() {\n return this.map((item) => item);\n }\n\n compact() {\n return this.filter((value) => value != null);\n }\n\n sortBy() {\n let sortKeys = arguments;\n\n return this.sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n let key = sortKeys[i];\n let propA = a[key];\n let propB = b[key];\n // return 1 or -1 else continue to the next sortKey\n let compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n }\n\n uniqBy(key) {\n return uniqBy(this, key);\n }\n\n without(value) {\n if (!this.includes(value)) {\n return this; // nothing to do\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = value === value ? (item) => item !== value : (item) => item === item;\n return this.filter(predicate);\n }\n\n clear() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n this.replace(0, len, []);\n return this;\n }\n\n insertAt(idx, object) {\n insertAt(this, idx, object);\n return this;\n }\n\n replaceAt(idx, object) {\n return this.replace(idx, 1, [object]);\n }\n\n removeAt(start, len) {\n return removeAt(this, start, len);\n }\n\n pushObject(obj) {\n return this.insertAt(this.length, obj);\n }\n\n pushObjects(objects) {\n this.replace(this.length, 0, objects);\n return this;\n }\n\n popObject() {\n let len = this.length;\n if (len === 0) {\n return null;\n }\n\n let ret = objectAt(this, len - 1);\n this.removeAt(len - 1, 1);\n return ret;\n }\n\n shiftObject() {\n if (this.length === 0) {\n return null;\n }\n\n let ret = objectAt(this, 0);\n this.removeAt(0);\n return ret;\n }\n\n unshiftObject(obj) {\n return insertAt(this, 0, obj);\n }\n\n unshiftObjects(objects) {\n this.replace(0, 0, objects);\n return this;\n }\n\n reverseObjects() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n let objects = this.toArray().reverse();\n this.replace(0, len, objects);\n return this;\n }\n\n setObjects(objects) {\n if (objects.length === 0) {\n return this.clear();\n }\n\n let len = this.length;\n this.replace(0, len, objects);\n return this;\n }\n\n removeObject(obj) {\n let loc = this.length || 0;\n while (--loc >= 0) {\n let curObject = objectAt(this, loc);\n\n if (curObject === obj) {\n this.removeAt(loc);\n }\n }\n return this;\n }\n\n removeObjects(objects) {\n for (let i = objects.length - 1; i >= 0; i--) {\n this.removeObject(objects[i]);\n }\n\n return this;\n }\n\n addObject(obj) {\n let included = this.includes(obj);\n\n if (!included) {\n this.pushObject(obj);\n }\n\n return this;\n }\n\n addObjects(objects) {\n objects.forEach((obj) => this.addObject(obj));\n return this;\n }\n}\n\nexport default Collection;\n\nexport { replace, uniqBy, isCollection, objectAt, iter, findIndex, find, any, every, indexOf, removeAt, insertAt };\n","const isEmpty = (obj) => {\n const none = obj === null || obj === undefined;\n if (none) {\n return none;\n }\n\n if (typeof obj.size === 'number') {\n return !obj.size;\n }\n\n const objectType = typeof obj;\n\n if (objectType === 'object') {\n const { size } = obj;\n if (typeof size === 'number') {\n return !size;\n }\n }\n\n if (typeof obj.length === 'number' && objectType !== 'function') {\n return !obj.length;\n }\n\n if (objectType === 'object') {\n const { length } = obj;\n if (typeof length === 'number') {\n return !length;\n }\n }\n\n return false;\n};\n\nexport default isEmpty;\n","import isEmpty from './is-empty';\n\nconst isBlank = (obj) => isEmpty(obj) || (typeof obj === 'string' && /\\S/.test(obj) === false);\n\nexport default isBlank;\n","import Resource from '../resource';\n\nexport default function isResource(record) {\n return record instanceof Resource;\n}\n","/**\n * Determines if environment SDK is initialized in is Node, additionally checks pass if environment is ReactNative.\n * \n * @returns boolean\n */\nconst isNodeEnvironment = () => {\n return (typeof process !== 'undefined') && (typeof process?.env === 'object' || process.release?.name?.search(/node|io.js/) !== -1) && (typeof window === 'undefined' || window?.navigator?.product === 'ReactNative');\n};\n\nexport default isNodeEnvironment;","import { lookup } from '../resolver';\nimport isNodeEnvironment from './is-node-environment';\n\nconst detectAdapter = (options = {}) => {\n if (isNodeEnvironment()) {\n return lookup('adapter', 'NodeAdapter', options);\n }\n\n return lookup('adapter', 'BrowserAdapter', options);\n}\n\nexport default detectAdapter;","const { isArray } = Array;\n\nclass GoogleAddress {\n constructor(place) {\n this.place = place;\n this.geometry = place?.geometry;\n this.components = this.parseComponents();\n this.attributes = this.parseProperties();\n }\n\n parse() {\n this.parseComponents();\n this.parseProperties();\n }\n\n parseComponents() {\n const components = (this.place?.address_components || []).reduce(function (acc, data) {\n data.types.forEach(function (type) {\n acc[type] = data;\n });\n return acc;\n }, {});\n\n return components;\n }\n\n parseProperties() {\n const attributes = {\n streetNumber: this.get('street_number'),\n streetName: this.get('route'),\n coordinates: this.geometry?.location ? Object.values(this.geometry.location) : [0, 0],\n city: this.or(['locality', 'sublocality', 'sublocality_level_1', 'neighborhood', 'administrative_area_level_3', 'administrative_area_level_2']),\n county: this.get('administrative_area_level_2'),\n stateShort: this.get('administrative_area_level_1', true),\n stateLong: this.get('administrative_area_level_1'),\n countryShort: this.get('country', true),\n country: this.get('country', true),\n countryLong: this.get('country'),\n postalCode: this.get('postal_code'),\n };\n\n attributes.address = [attributes.streetNumber, attributes.streetName].filter(Boolean).join(' ');\n\n return attributes;\n }\n\n all() {\n return this.attributes;\n }\n\n or(keys = []) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (isArray(key)) {\n const pkey = key[0];\n const short = key[1];\n\n if (this.has(pkey)) {\n return this.get(pkey, short);\n }\n\n continue;\n }\n\n if (this.has(key)) {\n return this.get(key);\n }\n }\n\n return null;\n }\n\n has(key) {\n return (key in this.components);\n }\n\n get(key, short = false) {\n if (!(key in this.components)) {\n return null;\n }\n\n return short ? this.components[key].short_name : this.components[key].long_name;\n }\n\n setAttributes(attributes = {}) {\n this.attributes = {...this.attributes, ...attributes};\n\n return this;\n }\n\n setAttribute(key, value) {\n this.attributes[key] = value;\n\n return this;\n }\n\n getAttribute(key) {\n return this.attributes[key] || null;\n }\n}\n\nexport default GoogleAddress;\n","export default class Point {\n constructor(latitude = 0, longitude = 0) {\n this.type = 'Point';\n this.coordinates = [longitude, latitude];\n }\n\n get latitude() {\n return this.coordinates[1];\n }\n\n get longitude() {\n return this.coordinates[0];\n }\n\n lat() {\n return this.latitude;\n }\n\n lng() {\n return this.longitude;\n }\n\n static fromGeoJson(json) {\n [ longitude, latitude ] = json.coordinates;\n\n return new Point(latitude, longitude);\n }\n\n serialize() {\n return {\n type: 'Point',\n coorindates: [this.lat(), this.lng()]\n };\n }\n\n toJson() {\n return this.serialize();\n }\n\n toString() {\n return `(${this.latitude}, ${this.longitude})`;\n }\n}","import isEmpty from './is-empty';\n\nconst isResource = (mixed) => typeof mixed === 'object' && !isEmpty(mixed?.attributes) && typeof mixed?.attributes === 'object';\n\nconst isCallable = (object, property) => typeof object[property] === 'function';\n\nconst getResolved = (func, path) => {\n const resolved = func();\n return Array.isArray(resolved) || typeof resolved === 'object' ? get(resolved, path) : null;\n};\n\nconst invoke = (object, method) => {\n if (typeof object[method] === 'function') {\n return object[method].bind(object);\n }\n};\n\nconst get = (object, path) => {\n let current = object;\n\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n\n if (isArray || isObject) {\n for (let i = 0; i < pathArray.length; i++) {\n if (current && current[pathArray[i]] === undefined) {\n return null;\n } else if (current) {\n current = current[pathArray[i]];\n\n // if is resource then return get on it's attributes\n if (isResource(current) && pathArray[i + 1] !== undefined) {\n const newPath = pathArray.slice(i + 1).join('.');\n\n return get(current.attributes, newPath);\n }\n\n // resolve functions and continue\n if (typeof current === 'function') {\n const newPath = pathArray.slice(i + 1).join('.');\n return getResolved(current, newPath);\n }\n }\n }\n return current;\n }\n\n if (isFunction) {\n return getResolved(object, path);\n }\n};\n\nconst getProperties = (object, properties = []) => {\n const selected = {};\n let propertyNames = arguments;\n let i = 1;\n\n if (arguments.length === 2 && Array.isArray(properties)) {\n i = 0;\n propertyNames = arguments[1];\n }\n\n for (; i < propertyNames.length; i++) {\n selected[propertyNames[i]] = get(object, propertyNames[i]);\n }\n\n return selected;\n};\n\nconst set = (object, path, value) => {\n let current = object;\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n // if is function\n if (isFunction) {\n // throw error should be object or array or object like\n }\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n const iterations = pathArray.length;\n\n if (isArray || isObject) {\n for (let i = 0; i < iterations - 1; i++) {\n if (!current[pathArray[i]]) {\n current[pathArray[i]] = {};\n }\n current = current[pathArray[i]];\n }\n\n current[pathArray[iterations - 1]] = value;\n }\n\n return value;\n};\n\nconst setProperties = (object, properties = {}) => {\n for (const property in properties) {\n set(object, property, properties[property]);\n }\n\n return object;\n};\n\nconst extend = (target, classes = []) => {\n if (arguments.length > 1) {\n classes = arguments;\n }\n for (let index = 0; index < classes.length; index++) {\n for (const property in classes[index]) {\n if (Object.prototype.hasOwnProperty.call(classes[index], property)) {\n target[property] = classes[index][property];\n }\n }\n }\n return target;\n};\n\nexport { set, get, getProperties, setProperties, extend, isCallable, invoke };\n","import { set } from './object';\n\nexport default class StoreActions {\n constructor(actions = {}, bind = null) {\n this.actions = actions;\n this.bind = bind;\n }\n\n extend(bindTo = null) {\n const binding = bindTo || this.bind;\n\n if (!binding) {\n return this;\n }\n\n if (this?.actions && typeof this.actions === 'object') {\n for (let action in this.actions) {\n const fn = this.actions[action];\n\n if (typeof fn !== 'function') {\n set(binding, action, fn);\n continue;\n }\n\n set(binding, action, fn.bind(binding));\n }\n }\n\n return this;\n }\n}\n","import Store from './store';\nimport { isEmpty } from './utils';\nimport { isArray } from './utils/array';\nimport { set, get } from './utils/object';\n\nclass Resource {\n /**\n\t * The base resource for all resources\n\n\t * @return {[type]} [description]\n\t */\n constructor(attributes = {}, adapter, resource, options = {}) {\n this.attributes = attributes;\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isDestroying = false;\n this.isReloading = false;\n this.resource = resource;\n this.options = options;\n this.version = options.version || 'v1';\n this.setAdapter(adapter);\n }\n\n /**\n * Set a new adapter to the resource instance, this will update the Store instance\n *\n * @param {Adapter} adapter\n * @return {Resource} this\n */\n setAdapter(adapter) {\n this.adapter = adapter;\n this.store = new Store(this.resource, adapter, {\n onAfterFetch: this.syncAttributes.bind(this),\n actions: this.options?.actions\n });\n\n return this;\n }\n\n /**\n * Getter for id attribute\n *\n * @var {String}\n */\n get id() {\n return this.getAttribute('id');\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n create(attributes = {}) {\n const data = this.mergeAttributes(attributes);\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.create(data).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n update(attributes = {}) {\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.update(this.attributes.id, attributes).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Deletes the resource instance on the server\n *\n * @return {[type]} [description]\n */\n destroy() {\n this.setFlags(['isLoading', 'isDestroying']);\n\n return this.store.destroy(this.attributes.id).then((response) => {\n this.setFlags(['isLoading', 'isDestroying'], false);\n\n return response;\n });\n }\n\n /**\n * Reloads the resource from the server.\n *\n * @return {[type]} [description]\n */\n reload() {\n this.setFlags(['isLoading', 'isReloading']);\n\n return this.store.findRecord(this.attributes.id).then((response) => {\n this.reset();\n\n return response;\n });\n }\n\n /**\n * Sets flag properties.\n *\n * @return this\n */\n setFlags(flags = [], state = true) {\n const validFlags = ['isLoading', 'isSaving', 'isReloading', 'isDestroying'];\n\n for(let i = 0; i < flags.length; i++) {\n const flag = flags[i];\n\n if (typeof flag !== 'string' || !validFlags.includes(flag)) {\n throw new Error(`${flag} is not a valid flag!`);\n }\n\n this[flag] = state;\n }\n\n return this;\n }\n\n /**\n * Resets tracked properties\n *\n * @return this\n */\n reset() {\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isReloading = false;\n\n return this;\n }\n\n /**\n * Emptys resource.\n *\n * @return this\n */\n empty() {\n this.reset();\n this.attribues = {};\n\n return this;\n }\n\n /**\n * Saves the resource instance on the server\n *\n * @return {[type]} [description]\n */\n save(options = {}) {\n const attributes = this.getAttributes();\n\n if (isEmpty(this.id)) {\n return this.create(attributes);\n }\n\n if (options.onlyDirty === true) {\n return this.savedirty();\n }\n\n return this.update(attributes);\n }\n\n /**\n * Saves only dirtied attributes.\n *\n * @return {[type]} [description]\n */\n saveDirty() {\n const dirtyAttributeKeys = Object.keys(this.dirtyAttributes);\n const dirtyAttributes = {};\n\n for (let i = 0; i < dirtyAttributeKeys.length; i++) {\n const key = dirtyAttributeKeys[i];\n dirtyAttributes[key] = this.getAttribute(key);\n }\n\n return this.update(dirtyAttributes);\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get createdAt() {\n return this.hasAttribute('created_at') ? new Date(this.getAttribute('created_at')) : null;\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get updatedAt() {\n return this.hasAttribute('updated_at') ? new Date(this.getAttribute('updated_at')) : null;\n }\n\n /**\n * Checks if resource is loaded from the server.\n *\n * @return {Boolean}\n */\n get isLoaded() {\n return this.hasAttributes(['created_at', 'id']);\n }\n\n /**\n * Checks if resource ihas no attributes\n *\n * @return {Boolean}\n */\n get isEmpty() {\n return Object.values(this?.attributes).length === 0;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isNew() {\n return !this.id;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isSaved() {\n return !this.isNew && this.isLoaded;\n }\n\n /**\n * Checks if resource is deleted on server.\n *\n * @return {Boolean}\n */\n get isDeleted() {\n return this.hasAttributes(['deleted', 'time']);\n }\n\n /**\n * Iterates over each attribute value and property executing a user supplied callback.\n *\n * @return {Object}\n */\n eachAttribute(callback) {\n if (typeof callback !== 'function') {\n return this;\n }\n\n Object.keys(this?.attributes ?? {}).forEach((property) => {\n const value = this.getAttribute(property);\n callback.call(this, value, property);\n });\n\n return this;\n }\n\n /**\n * Gets all changes\n *\n * @return {Object}\n */\n changes() {\n return this.changes;\n }\n\n /**\n * Gets all dirty attributes.\n *\n * @return {Object}\n */\n getDirtyAttributes() {\n return this.dirtyAttributes;\n }\n\n /**\n * Checks if property is dirty.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n isDirty(property) {\n return property in this.dirtyAttributes;\n }\n\n /**\n * Checks if any properties is dirty.\n *\n * @return {Boolean}\n */\n hasDirtyAttributes() {\n return Object.keys(this?.dirtyAttributes ?? {}).length > 0;\n }\n\n /**\n * Updates a instance property without tracking changes or dirtying attribute.\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n mutate(property, value) {\n this.attributes[property] = value;\n }\n\n /**\n * Set an instance property locally\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n setAttribute(property, value = null) {\n if (value === null && typeof property === 'object') {\n return this.setAttributes(property);\n }\n\n const previousValue = this?.attributes[property] ?? null;\n\n // use object setter\n set(this.attributes, property, value);\n set(this.dirtyAttributes, property, previousValue);\n \n // this.attributes[property] = value;\n // this.dirtyAttributes[property] = previousValue;\n\n // track changes\n if (!isArray(this?.changes[property])) {\n this.changes[property] = [];\n }\n\n this.changes[property].push({\n property,\n previousValue,\n value,\n changedAt: new Date(),\n });\n\n return this;\n }\n\n /**\n * Set multiple instance properties locally\n *\n * @param {Object} properties [description]\n */\n setAttributes(attributes = {}) {\n for (let property in attributes) {\n this.setAttribute(property, attributes[property]);\n }\n\n return this;\n }\n\n /**\n * Get an attribute\n *\n * @param {String} attribute The attribute key to get\n * @param {mixed} defaultValue The default value if no attribute value\n */\n getAttribute(attribute, defaultValue = null) {\n const value = get(this?.attributes ?? {}, attribute);\n\n if (value === undefined) {\n return defaultValue;\n }\n\n return value;\n }\n\n /**\n * Checks if attribute exists.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n hasAttribute(property) {\n if (isArray(property)) {\n const properties = property;\n const attributeKeys = Object.keys(this.attributes ?? {});\n \n return properties.every((prop) => attributeKeys.includes(prop));\n }\n\n if (!this?.attributes) {\n return false;\n }\n\n return property in this.attributes;\n }\n\n /**\n * Alias for checking if has multiple attributes.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n hasAttributes(properties = []) {\n return this.hasAttribute(properties);\n }\n\n /**\n * Returns true if attribute has value.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n isAttributeFilled(property) {\n if (isArray(property)) {\n return this.hasAttribute(property) && property.every((prop) => !isEmpty(this.getAttribute(prop)));\n }\n\n return this.hasAttribute(property) && !isEmpty(this.getAttribute(property));\n }\n\n /**\n * Get multiple attributes.\n *\n * @param {Array} properties [description]\n * @param {[type]} value [description]\n */\n getAttributes(properties) {\n const attributes = {};\n\n if (properties === null || properties === undefined) {\n return this.getAttributes(Object.keys(this.attributes));\n }\n\n if (typeof properties === 'string') {\n return this.getAttribute([...arguments]);\n }\n\n if (!isArray(properties)) {\n throw new Error('No attribute properties provided!');\n }\n\n for (let i = 0; i < properties.length; i++) {\n const property = properties[i];\n\n if (typeof property !== 'string') {\n continue;\n }\n\n let value = this.getAttribute(property);\n\n if (typeof value?.attributes === 'object' && !isArray(value?.attributes)) {\n value = value.attributes;\n }\n\n attributes[property] = value;\n }\n\n return attributes;\n }\n\n /**\n * Serialize resource to a POJO\n *\n * @returns {Object}\n */\n serialize() {\n return this.getAttributes();\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n mergeAttributes(attributes = {}) {\n const modelAttributes = this?.attributes ?? {};\n this.attributes = { ...modelAttributes, ...attributes };\n\n return this.attributes;\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n syncAttributes(json = {}) {\n this.attributes = json;\n }\n}\n\nexport default Resource;\n","import Resource from '../resource';\nimport { StoreActions } from '../utils';\n\nconst orderActions = new StoreActions({\n getDistanceAndTime: function (id, options = {}) {\n return this.adapter.get(`${this.namespace}/${id}/distance-and-time`, {}, options);\n },\n});\n\nclass Order extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'order', { actions: orderActions, ...options });\n }\n\n getDistanceAndTime() {\n return this.store.getDistanceAndTime(this.id);\n }\n}\n\nexport default Order;\n\nexport { orderActions };","import Resource from '../resource';\nimport Collection from '../utils/collection';\n\nclass Payload extends Resource {\n\tconstructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'payload', options);\n }\n\t\n /**\n\t * Attaches an entity to an existing payload and returns\n\t * the payload with the entity attached\n\t *\n\t * @param {[type]} Entity entity [description]\n\t * @return {[type]} [description]\n\t */\n attach(entity) {\n // perform op return payload\n }\n\n /**\n\t * Returns all of the entities attached to this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get entities() {\n\n }\n\n /**\n\t * Returns the dropoff for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get dropoff() {\n\n }\n\n /**\n\t * Returns the pickup for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get pickup() {\n\n }\n\n /**\n\t * Returns all the waypoints for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get waypoints() {\n return new Collection(this.waypoints);\n }\n}\n\nexport default Payload;\n","import Resource from '../resource';\n\nclass Entity extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'entity', options);\n }\n}\n\nexport default Entity;\n","import Resource from '../resource';\nimport { isResource, Point } from '../utils';\n\nclass Place extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'place', options);\n }\n\n static fromGoogleAddress(googleAddress, adapter, options = {}) {\n const [ latitude, longitude ] = googleAddress.getAttribute('coordinates');\n const attributes = {\n name: null,\n address: googleAddress.getAttribute('address'),\n location: new Point(latitude, longitude),\n street1: googleAddress.getAttribute('streetName'),\n street2: null,\n city: googleAddress.getAttribute('city'),\n province: googleAddress.getAttribute('stateLong'),\n postal_code: googleAddress.getAttribute('postalCode'),\n neighborhood: googleAddress.get('neighborhood'),\n district: googleAddress.getAttribute('county'),\n building: googleAddress.get('building'),\n country: googleAddress.getAttribute('countryShort'),\n phone: null,\n security_access_code: null\n };\n\n return new Place(attributes, adapter, options);\n }\n\n /**\n * The latitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get latitude() {\n return this.getAttribute('location', new Point())?.coordinates[1];\n }\n\n /**\n * The longitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get longitude() {\n return this.getAttribute('location', new Point())?.coordinates[0];\n }\n\n /**\n * Array coordinate pair for Place location.\n * \n * @var {Array}\n */\n get coordinates() {\n const { latitude, longitude } = this;\n\n return [ latitude, longitude ];\n }\n\n /**\n * Set the owner of the place.\n * \n * @param {Object|String} owner\n * @return {Place}\n */\n setOwner(owner) {\n if (isResource(owner)) {\n this.setAttribute('owner', owner.id);\n }\n\n if (typeof owner === 'string') {\n this.setAttribute('owner', owner);\n }\n\n return this;\n }\n}\n\nexport default Place;\n","import Place from './place';\n\nclass Waypoint extends Place {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'waypoint', options);\n }\n}\n\nexport default Waypoint;\n","import Resource from '../resource';\n\nclass TrackingStatus extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'tracking-status', options);\n }\n}\n\nexport default TrackingStatus;\n","import Resource from '../resource';\n\nclass Vehicle extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vehicle', options);\n }\n}\n\nexport default Vehicle;\n","import Resource from '../resource';\n\nclass Driver extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'driver', options);\n }\n}\n\nexport default Driver;\n","import Resource from '../resource';\n\nclass Vendor extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vendor', options);\n }\n}\n\nexport default Vendor;\n","import Resource from '../resource';\n\nclass Contact extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'contact', options);\n }\n}\n\nexport default Contact;\n","import Resource from '../resource';\n\nclass Zone extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'zone', options);\n }\n}\n\nexport default Zone;\n","import Resource from '../resource';\n\nclass ServiceArea extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-area', options);\n }\n}\n\nexport default ServiceArea;\n","import Resource from '../resource';\n\nclass ServiceRate extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-rate', options);\n }\n}\n\nexport default ServiceRate;\n","import Resource from '../resource';\n\nclass ServiceQuote extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-quote', options);\n }\n\n fromPreliminary() {\n\n }\n\n fromPayload() {\n \n }\n}\n\nexport default ServiceQuote;\n","class Adapter {\n /**\n\t * Creates a configured base adapter for Fleetbase.\n\t *\n\t * @param {Object} config Configuration options for adapter\n\t */\n constructor(config = {}) {\n this.version = config.version || 'v1';\n this.host = config.host || null;\n this.namespace = config.namespace || null;\n this.headers = config.headers || {};\n }\n}\n\nexport default Adapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\n\nclass BrowserAdapter extends Adapter {\n /**\n * Setup browser adapter.\n * @param {Object} config\n */\n constructor(config) {\n super(config);\n\n this.setHeaders({\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;browser'\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n this.headers = { ...this.headers, ...headers };\n\n return this;\n }\n\n /**\n * Parses the JSON returned by a network request\n *\n * @param {Object} response A response from a network request\n * @return {Object} The parsed JSON, status from the response\n *\n * @return {Promise}\n */\n parseJSON(response) {\n return new Promise((resolve, reject) => response\n .json()\n .then((json) => resolve({\n statusText: response.statusText,\n status: response.status,\n ok: response.ok,\n json,\n }))\n .catch(() => {\n reject(new Error('Oops! Something went wrong when handling your request.'));\n }));\n }\n\n /**\n * The base request method\n *\n * @param {String} path\n * @param {String} method\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n request(path, method = 'GET', data = {}, options = {}) {\n return new Promise((resolve, reject) => fetch(options.url || `${this.host}/${this.namespace}/${path}`, {\n method,\n mode: options.mode || 'cors',\n headers: new Headers({\n ...(this.headers || {}),\n ...(options.headers || {}),\n }),\n ...data,\n })\n .then(this.parseJSON)\n .then((response) => {\n if (response.ok) {\n return resolve(response.json);\n }\n\n return reject(new Error(response.json.errors ? response.json.errors[0] : response.statusText));\n })\n .catch((error) => {\n reject(error);\n }));\n }\n\n /**\n * Makes a GET request with fetch\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.request(`${path}${urlParams ? `?${urlParams}` : ''}`, 'GET', {}, options);\n }\n\n /**\n * Makes a POST request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.request(path, 'POST', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a PUT request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.request(path, 'PUT', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a DELETE request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.request(path, 'DELETE', {}, options);\n }\n\n /**\n * Makes a PATCH request with fetch\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.request(path, 'PATCH', { body: JSON.stringify(data) }, options);\n }\n}\n\nexport default BrowserAdapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\nimport { isArray } from '../utils/array';\nimport axios from 'axios';\n\nclass NodeAdapter extends Adapter {\n constructor(config) {\n super(config);\n\n this.axios = axios.create({\n baseURL: `${this.host}/${this.namespace}`,\n headers: {\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;node',\n },\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n const commonHeaders = this.axios.defaults.headers.common;\n this.axios.defaults.headers.common = { ...commonHeaders, ...headers };\n\n return this;\n }\n\n /**\n * Tranform the response, and return the response data from axios.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n transform(response) {\n return response.data;\n }\n\n /**\n * Handles an erroneous request.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n handleError(error) {\n if (error.response) {\n const { data } = error.response;\n\n if (isArray(data.errors)) {\n throw new Error(data.errors[0]);\n }\n\n if (data.error) {\n throw new Error(data.error);\n }\n }\n\n throw error;\n }\n\n /**\n * Makes a GET request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.axios\n .get(`${path}${urlParams ? `?${urlParams}` : ''}`, options)\n .then(this.transform.bind(this))\n .catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a POST request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.axios.post(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PUT request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.axios.put(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a DELETE request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.axios.delete(path, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PATCH request with axios\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.axios.patch(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n}\n\nexport default NodeAdapter;\n","import Adapter from '../adapter';\n\nclass EmberJsAdapter extends Adapter {}\n\nexport default EmberJsAdapter;\n","'use strict';\n\n/**\n * Javascript String\n *\n * instance\n * new String('hello_world').humanize().get() => \"Hello world\"\n *\n * instance\n * const string = new String();\n * string.humanize('hello_world').get() => \"Hello world\"\n * \n * no chain\n * new String('hello_world', false).humanize() => \"Hello world\"\n *\n * static\n * String.invoke('humanize', 'hello_world') => \"Hello world\"\n *\n * exports {}\n * humanize('hello_world') => \"Hello world\"\n */\n\nexport default class String {\n constructor(string, chain = true) {\n this.str = string;\n this.chain = chain;\n }\n\n uncountableWords = ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'moose', 'deer', 'news'];\n\n pluralRules = [\n [new RegExp('(m)an$', 'gi'), '$1en'],\n [new RegExp('(pe)rson$', 'gi'), '$1ople'],\n [new RegExp('(child)$', 'gi'), '$1ren'],\n [new RegExp('^(ox)$', 'gi'), '$1en'],\n [new RegExp('(ax|test)is$', 'gi'), '$1es'],\n [new RegExp('(octop|vir)us$', 'gi'), '$1i'],\n [new RegExp('(alias|status)$', 'gi'), '$1es'],\n [new RegExp('(bu)s$', 'gi'), '$1ses'],\n [new RegExp('(buffal|tomat|potat)o$', 'gi'), '$1oes'],\n [new RegExp('([ti])um$', 'gi'), '$1a'],\n [new RegExp('sis$', 'gi'), 'ses'],\n [new RegExp('(?:([^f])fe|([lr])f)$', 'gi'), '$1$2ves'],\n [new RegExp('(hive)$', 'gi'), '$1s'],\n [new RegExp('([^aeiouy]|qu)y$', 'gi'), '$1ies'],\n [new RegExp('(x|ch|ss|sh)$', 'gi'), '$1es'],\n [new RegExp('(matr|vert|ind)ix|ex$', 'gi'), '$1ices'],\n [new RegExp('([m|l])ouse$', 'gi'), '$1ice'],\n [new RegExp('(quiz)$', 'gi'), '$1zes'],\n [new RegExp('s$', 'gi'), 's'],\n [new RegExp('$', 'gi'), 's'],\n ];\n\n singularRules = [\n [new RegExp('(m)en$', 'gi'), '$1an'],\n [new RegExp('(pe)ople$', 'gi'), '$1rson'],\n [new RegExp('(child)ren$', 'gi'), '$1'],\n [new RegExp('([ti])a$', 'gi'), '$1um'],\n [new RegExp('((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$', 'gi'), '$1$2sis'],\n [new RegExp('(hive)s$', 'gi'), '$1'],\n [new RegExp('(tive)s$', 'gi'), '$1'],\n [new RegExp('(curve)s$', 'gi'), '$1'],\n [new RegExp('([lr])ves$', 'gi'), '$1f'],\n [new RegExp('([^fo])ves$', 'gi'), '$1fe'],\n [new RegExp('([^aeiouy]|qu)ies$', 'gi'), '$1y'],\n [new RegExp('(s)eries$', 'gi'), '$1eries'],\n [new RegExp('(m)ovies$', 'gi'), '$1ovie'],\n [new RegExp('(x|ch|ss|sh)es$', 'gi'), '$1'],\n [new RegExp('([m|l])ice$', 'gi'), '$1ouse'],\n [new RegExp('(bus)es$', 'gi'), '$1'],\n [new RegExp('(o)es$', 'gi'), '$1'],\n [new RegExp('(shoe)s$', 'gi'), '$1'],\n [new RegExp('(cris|ax|test)es$', 'gi'), '$1is'],\n [new RegExp('(octop|vir)i$', 'gi'), '$1us'],\n [new RegExp('(alias|status)es$', 'gi'), '$1'],\n [new RegExp('^(ox)en', 'gi'), '$1'],\n [new RegExp('(vert|ind)ices$', 'gi'), '$1ex'],\n [new RegExp('(matr)ices$', 'gi'), '$1ix'],\n [new RegExp('(quiz)zes$', 'gi'), '$1'],\n [new RegExp('s$', 'gi'), ''],\n ];\n\n nonTitlecasedWords = ['and', 'or', 'nor', 'a', 'an', 'the', 'so', 'but', 'to', 'of', 'at', 'by', 'from', 'into', 'on', 'onto', 'off', 'out', 'in', 'over', 'with', 'for'];\n\n idSuffix = new RegExp('(_ids|_id)$', 'g');\n underbar = new RegExp('_', 'g');\n spaceOrUnderbar = new RegExp('[ _]', 'g');\n uppercase = new RegExp('([A-Z])', 'g');\n underbarPrefix = new RegExp('^_');\n\n get() {\n return this.str;\n }\n\n applyRules(str, rules, skip, override) {\n if (override) {\n str = override;\n } else {\n var ignore = skip.indexOf(str.toLowerCase()) > -1;\n if (!ignore) {\n for (var x = 0; x < rules.length; x++) {\n if (str.match(rules[x][0])) {\n str = str.replace(rules[x][0], rules[x][1]);\n break;\n }\n }\n }\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.pluralize('person') -> 'people'\n String.pluralize('octopus') -> 'octopi'\n String.pluralize('Hat') -> 'Hats'\n String.pluralize('person', 'guys') -> 'guys' \n */\n pluralize(str, plural = null) {\n str = str || this.str;\n\n return this.applyRules(str, this.pluralRules, this.uncountableWords, plural);\n }\n\n /*\n String.singularize('person') -> 'person'\n String.singularize('octopi') -> 'octopus'\n String.singularize('hats') -> 'hat'\n String.singularize('guys', 'person') -> 'person'\n */\n singularize(str, singular) {\n str = str || this.str;\n\n return this.applyRules(str, this.singularRules, this.uncountableWords, singular);\n }\n\n /*\n String.camelize('message_properties') -> 'MessageProperties'\n String.camelize('message_properties', true) -> 'messageProperties'\n */\n camelize(str, lowFirstLetter) {\n str = str || this.str;\n\n let str_path = str.split('/');\n for (var i = 0; i < str_path.length; i++) {\n let str_arr = str_path[i].split('_');\n let initX = lowFirstLetter && i + 1 === str_path.length ? 1 : 0;\n\n for (let x = initX; x < str_arr.length; x++) {\n str_arr[x] = str_arr[x].charAt(0).toUpperCase() + str_arr[x].substring(1);\n }\n str_path[i] = str_arr.join('');\n }\n str = str_path.join('::');\n\n // fix\n if (lowFirstLetter === true) {\n let first = str.charAt(0).toLowerCase();\n let last = str.slice(1);\n str = first + last;\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.underscore('MessageProperties') -> 'message_properties'\n String.underscore('messageProperties') -> 'message_properties'\n */\n underscore(str) {\n str = str || this.str;\n\n var str_path = str.split('::');\n for (var i = 0; i < str_path.length; i++) {\n str_path[i] = str_path[i].replace(this.uppercase, '_$1');\n str_path[i] = str_path[i].replace(this.underbarPrefix, '');\n }\n str = str_path.join('/').toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.humanize('message_properties') -> 'Message properties'\n String.humanize('message_properties') -> 'message properties'\n */\n humanize(str, lowFirstLetter) {\n str = str || this.str;\n\n var str = str.toLowerCase();\n str = str.replace(this.idSuffix, '');\n str = str.replace(this.underbar, ' ');\n if (!lowFirstLetter) {\n str = this.capitalize(str);\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.capitalize('message_properties') -> 'Message_properties'\n String.capitalize('message properties') -> 'Message properties'\n */\n capitalize(str) {\n str = str || this.str;\n\n str = str.toLowerCase();\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.dasherize('message_properties') -> 'message-properties'\n String.dasherize('message properties') -> 'message-properties'\n */\n dasherize(str) {\n str = str || this.str;\n\n str = str.replace(this.spaceOrUnderbar, '-');\n str = str.toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.normify('message_properties') -> 'Message Properties'\n String.normify('message properties') -> 'Message Properties'\n Inflactor.normify('Message_propertyId', true) -> 'Message Properties Id'\n */\n normify(str, allFirstUpper) {\n str = str || this.str;\n\n //var str = str.toLowerCase();\n if (allFirstUpper === true) {\n str = this.camelize(str);\n str = this.underscore(str);\n } else {\n str = str.toLowerCase();\n }\n\n str = str.replace(this.underbar, ' ');\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var d = str_arr[x].split('-');\n for (var i = 0; i < d.length; i++) {\n if (this.nonTitlecasedWords.indexOf(d[i].toLowerCase()) < 0) {\n d[i] = this.capitalize(d[i]);\n }\n }\n str_arr[x] = d.join('-');\n }\n str = str_arr.join(' ');\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.demodulize('Message::Bus::Properties') -> 'Properties'\n */\n demodulize(str) {\n str = str || this.str;\n\n var str_arr = str.split('::');\n str = str_arr[str_arr.length - 1];\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.tableize('MessageBusProperty') -> 'message_bus_properties'\n */\n tableize(str) {\n str = str || this.str;\n\n str = this.pluralize(this.underscore(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.classify('message_bus_properties') -> 'MessageBusProperty'\n */\n classify(str) {\n str = str || this.str;\n\n str = this.singularize(this.camelize(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.foreignKey('MessageBusProperty') -> 'message_bus_property_id'\n String.foreignKey('MessageBusProperty', true) -> 'message_bus_propertyid'\n */\n foreignKey(str, dropIdUbar = false) {\n str = str || this.str;\n\n str = this.underscore(this.demodulize(str)) + (dropIdUbar ? '' : '_') + 'id';\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.ordinalize('the 1 pitch') -> 'the 1st pitch'\n */\n ordinalize(str) {\n str = str || this.str;\n\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var i = parseInt(str_arr[x]);\n if (i === NaN) {\n var ltd = str_arr[x].substring(str_arr[x].length - 2);\n var ld = str_arr[x].substring(str_arr[x].length - 1);\n var suf = 'th';\n if (ltd != '11' && ltd != '12' && ltd != '13') {\n if (ld === '1') {\n suf = 'st';\n } else if (ld === '2') {\n suf = 'nd';\n } else if (ld === '3') {\n suf = 'rd';\n }\n }\n str_arr[x] += suf;\n }\n }\n str = str_arr.join(' ');\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /**\n * @method invoke\n **/\n static invoke() {\n const argz = Object.values(arguments);\n const instance = new String(null, false);\n const method = arguments[0];\n argz.shift();\n\n if (typeof instance[method] === 'function') {\n return instance[method](...argz);\n }\n\n return null;\n }\n}\n\nconst pluralize = function() {\n const argz = ['pluralize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst singularize = function() {\n const argz = ['singularize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst humanize = function() {\n const argz = ['humanize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst underscore = function() {\n const argz = ['underscore', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst camelize = function() {\n const argz = ['camelize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst capitalize = function() {\n const argz = ['capitalize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst dasherize = function() {\n const argz = ['dasherize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst normify = function() {\n const argz = ['normify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst demodulize = function() {\n const argz = ['demodulize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst tableize = function() {\n const argz = ['tableize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst classify = function() {\n const argz = ['classify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst foreignKey = function() {\n const argz = ['foreignKey', ...arguments];\n\n return String.invoke(...argz);\n};\n\nexport {\n pluralize,\n singularize,\n humanize,\n underscore,\n camelize,\n capitalize,\n dasherize,\n normify,\n demodulize,\n tableize,\n classify,\n foreignKey\n}","import { Place, Payload, Order } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter } from './adapters';\nimport { pluralize, singularize } from './utils/string';\n\nconst resources = {\n Place,\n Payload,\n Order\n};\n\nconst adapters = {\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter\n};\n\nclass Resolver {\n constructor () {\n this.resources = resources;\n this.adapters = adapters;\n\n return this.lookup(...arguments);\n }\n\n lookup(type, className) {\n const key = pluralize(type);\n const params = [ ...arguments ].slice(2);\n\n if (!this[key]) {\n throw new Error('Attempted to resolve invalid type');\n }\n\n if (!this[key][className]) {\n throw new Error(`No ${singularize(type)} named ${className} to resolve`);\n }\n\n return new this[key][className](...params);\n }\n}\n\nconst lookup = function() {\n return new Resolver(...arguments);\n};\n\nexport {\n Resolver,\n lookup\n};\n","import { lookup } from './resolver';\nimport { pluralize, classify } from './utils/string';\nimport { isArray } from './utils/array';\nimport { Collection, detectAdapter, isResource, StoreActions } from './utils';\nimport { set, isCallable, invoke } from './utils/object';\n\nconst extendStoreActions = (store, actions = []) => {\n store.actions = isArray(actions) ? actions : [actions];\n\n if (isArray(actions)) {\n for (let i = 0; i < actions.length; i++) {\n const action = actions[i];\n\n store.extendActions(action);\n }\n return;\n }\n\n if (actions instanceof StoreActions) {\n actions.extend(store);\n }\n\n return store;\n};\n\nconst afterFetch = (store, json) => {\n if (typeof store.options.onAfterFetch === 'function') {\n store.options.onAfterFetch(json);\n }\n\n if (isArray(json)) {\n const serialized = [];\n\n for (let i = 0; i < json.length; i++) {\n serialized.push(store.afterFetch(json[i]));\n }\n\n return new Collection(...serialized);\n }\n\n const resourceInstance = store.serialize(json);\n return store.deposit(resourceInstance);\n};\n\nclass Store {\n constructor(resource, adapter, options = {}) {\n this.resource = resource;\n this.adapter = adapter || detectAdapter();\n this.namespace = pluralize(resource);\n this.storage = new Collection();\n this.options = options;\n this.extendActions(options.actions);\n }\n\n extendActions(actions = []) {\n return extendStoreActions(this, actions);\n }\n\n deposit(resourceInstance) {\n // this.storage[this.namespace].pushObject(resourceInstance);\n\n return resourceInstance;\n }\n\n serialize(json) {\n return lookup('resource', classify(this.resource), json, this.adapter);\n }\n\n afterFetch(json) {\n return afterFetch(this, json);\n }\n\n create(attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.post(`${this.namespace}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n update(id, attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.put(`${this.namespace}/${id}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findRecord(id, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findAll(options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n query(query = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n queryRecord(query = {}, options = {}) {\n query.single = true;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n destroy(record, options = {}) {\n const id = isResource(record) ? record.getAttribute('id') : record;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.delete(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n}\n\nexport default Store;\n\nexport { extendStoreActions, afterFetch };\n","import Store from './store';\nimport Resource from './resource';\nimport { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter, Adapter } from './adapters';\nimport { isNodeEnvironment, detectAdapter, isLatitude, isLongitude, Point, isResource, GoogleAddress, Collection, StoreActions } from './utils';\nimport { pluralize, singularize, classify, dasherize, camelize } from './utils/string';\nimport { extendStoreActions } from './store';\nimport { orderActions } from './resources/order';\n\n/**\n * // instance\n * const fleetbase = new Fleetbase();\n *\n * const contact = fleetbase.contacts.create({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * constact.update({ name: 'Hollywood Ron' });\n *\n * // export\n * import { Contact } from '@fleetbase/sdk';\n *\n * const contact = new Contact({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * contact.save();\n */\n\nexport default class Fleetbase {\n /**\n * Builds an instance of the Fleetbase SDK\n *\n * @param {String} publicKey The public key issued\n * @param {Object} config The version of resource to access\n * @param {Boolean} debug Debug mode for SDK\n * @return {Fleetbase} Instance\n */\n constructor(publicKey, config = {}, debug = false) {\n this.version = config.version || 'v1';\n this.options = {\n version: this.version,\n host: config.host || 'https://api.fleetbase.io',\n namespace: this.version || config.namespace,\n debug,\n publicKey,\n };\n\n if (typeof publicKey !== 'string' || publicKey.length === 0) {\n throw new Error('⚠️ Invalid public key given to Fleetbase SDK');\n }\n\n if (!isNodeEnvironment() && publicKey.toLowerCase().startsWith('$')) {\n throw new Error('Secret key provided. You must use a public key with Fleetbase Javascript SDK!');\n }\n\n this.adapter = config.adapter || detectAdapter(this.options);\n\n this.orders = new Store('order', this.adapter).extendActions(orderActions);\n this.entities = new Store('entity', this.adapter);\n this.places = new Store('place', this.adapter);\n this.drivers = new Store('driver', this.adapter);\n this.vehicles = new Store('vehicle', this.adapter);\n this.vendors = new Store('vendor', this.adapter);\n this.contacts = new Store('contact', this.adapter);\n }\n\n static newInstance() {\n return new Fleetbase(...arguments);\n }\n\n setAdapter(adapter) {\n this.adapter = adapter;\n }\n\n getAdapter() {\n return this.adapter;\n }\n}\n\nexport {\n Store,\n Resource,\n Contact,\n Driver,\n Entity,\n Order,\n Payload,\n Place,\n TrackingStatus,\n Vehicle,\n Vendor,\n Waypoint,\n Zone,\n ServiceArea,\n ServiceRate,\n ServiceQuote,\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter,\n Adapter,\n isNodeEnvironment,\n isLatitude,\n isLongitude,\n Point,\n isResource,\n GoogleAddress,\n Collection,\n StoreActions,\n extendStoreActions,\n pluralize,\n singularize,\n classify,\n dasherize,\n camelize,\n};\n","export default function isLatitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 90;\n}\n","export default function isLongitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 180 && Math.abs(coordinate) >= 90;\n}\n"],"names":["isArray","Array","replace","array","start","deleteCount","items","length","splice","i","chunk","slice","isCollection","arr","identityFunction","item","mixed","Collection","objectAt","index","iter","key","value","arguments","Boolean","findIndex","predicate","startAt","len","find","callback","target","bind","undefined","any","every","cb","indexOf","val","withNaNCheck","insertAt","this","indexes","map","idx","_this2","object","methodName","args","ret","forEach","push","_item$methodName","filter","sortKeys","sort","a","b","propA","propB","compareValue","compare","seen","Set","getter","get","has","add","uniqBy","includes","removeAt","obj","objects","toArray","reverse","clear","loc","removeObject","pushObject","_this3","addObject","isEmpty","none","size","objectType","isBlank","test","isResource","record","Resource","isNodeEnvironment","process","_typeof","_process","env","release","name","search","window","navigator","product","detectAdapter","options","lookup","GoogleAddress","place","geometry","components","parseComponents","attributes","parseProperties","address_components","reduce","acc","data","types","type","streetNumber","streetName","coordinates","location","Object","values","city","or","county","stateShort","stateLong","countryShort","country","countryLong","postalCode","address","join","keys","pkey","short","short_name","long_name","Point","latitude","longitude","coorindates","lat","lng","serialize","json","getResolved","func","path","resolved","current","isObject","isFunction","pathArray","split","newPath","set","iterations","StoreActions","actions","bindTo","binding","action","fn","adapter","resource","dirtyAttributes","changes","isLoading","isSaving","isDestroying","isReloading","version","setAdapter","store","Store","onAfterFetch","syncAttributes","_this$options","getAttribute","mergeAttributes","setFlags","create","then","response","_this","update","id","destroy","findRecord","_this4","reset","flags","state","validFlags","flag","Error","attribues","getAttributes","onlyDirty","savedirty","dirtyAttributeKeys","hasAttribute","Date","hasAttributes","isNew","isLoaded","property","_this5","call","setAttributes","previousValue","changedAt","setAttribute","attribute","defaultValue","properties","attributeKeys","prop","_this6","_value","_value2","modelAttributes","orderActions","getDistanceAndTime","namespace","Order","Payload","entity","waypoints","Entity","Place","_this$getAttribute","_this$getAttribute2","owner","googleAddress","street1","street2","province","postal_code","neighborhood","district","building","phone","security_access_code","Waypoint","TrackingStatus","Vehicle","Driver","Vendor","Contact","Zone","ServiceArea","ServiceRate","ServiceQuote","Adapter","config","host","headers","BrowserAdapter","setHeaders","Authorization","publicKey","Promise","resolve","reject","statusText","status","ok","method","fetch","url","mode","Headers","parseJSON","errors","error","query","urlParams","URLSearchParams","toString","request","body","JSON","stringify","NodeAdapter","axios","baseURL","commonHeaders","defaults","common","transform","handleError","post","put","patch","EmberJsAdapter","String","string","chain","RegExp","str","rules","skip","override","toLowerCase","x","match","plural","applyRules","pluralRules","uncountableWords","singular","singularRules","lowFirstLetter","str_path","str_arr","charAt","toUpperCase","substring","first","last","uppercase","underbarPrefix","idSuffix","underbar","capitalize","spaceOrUnderbar","allFirstUpper","camelize","underscore","d","nonTitlecasedWords","pluralize","singularize","dropIdUbar","demodulize","NaN","parseInt","ltd","ld","suf","argz","instance","shift","invoke","classify","resources","adapters","Resolver","className","params","extendStoreActions","extend","extendActions","storage","resourceInstance","serialized","afterFetch","deposit","single","_this7","Fleetbase","debug","startsWith","orders","entities","places","drivers","vehicles","vendors","contacts","coordinate","isFinite","Math","abs"],"mappings":"ssJAAA,IAAQA,EAAYC,MAAZD,yDCWFE,EAAU,SAACC,EAAOC,EAAOC,OAAaC,yDAAQ,MAC5CN,EAAQG,MACJG,EAAMC,QANC,IAOPJ,EAAMK,aAANL,GAAaC,EAAOC,YAAgBC,SACjC,CACHH,EAAMK,OAAOJ,EAAOC,OAEf,IAAII,EAAI,EAAGA,EAAIH,EAAMC,OAAQE,GAX3B,IAW4C,KAC3CC,EAAQJ,EAAMK,MAAMF,EAAGA,EAZxB,KAaHN,EAAMK,aAANL,GAAaC,EAAQK,EAAG,YAAMC,WAG/BE,EAAaC,MACpBV,EAAMD,QAAQE,EAAOC,EAAaC,IAIpCQ,EAAmB,SAACC,UAASA,GAkB7BH,EAAe,SAACI,UAAUA,aAAiBC,GAE3CC,EAAW,SAACf,EAAOgB,UACjBnB,EAAQG,GACDA,EAAMgB,GACNP,EAAaT,GACbA,EAAMe,SAASC,GAGnB,MAGLC,EAAO,SAACC,EAAKC,UAC0B,IAArBC,EAAUhB,OACP,SAACQ,UAASO,IAAUP,EAAKM,IAAO,SAACN,UAASS,QAAQT,EAAKM,MAG5EI,EAAY,SAACtB,EAAOuB,WAAWC,yDAAU,EACvCC,EAAMzB,EAAMI,OACPY,EAAQQ,EAASR,EAAQS,EAAKT,IAAS,KACxCJ,EAAOG,EAASf,EAAOgB,MACvBO,EAAUX,EAAMI,EAAOhB,UAChBgB,SAGP,GAGNU,EAAO,SAAC1B,EAAO2B,EAAUC,OACvBL,EAAYI,EAASE,KAAKD,GAC1BZ,EAAQM,EAAUtB,EAAOuB,EAAW,UACtB,IAAXP,OAAec,EAAYf,EAASf,EAAOgB,IAGhDe,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KAAKC,IAAIH,IAAe"} \ No newline at end of file +{"version":3,"file":"fleetbase.js","sources":["../../src/utils/array.js","../../src/utils/collection.js","../../src/utils/is-empty.js","../../src/utils/is-blank.js","../../src/utils/is-resource.js","../../src/utils/is-phone.js","../../src/utils/is-node-environment.js","../../src/utils/detect-adapter.js","../../src/utils/google-address.js","../../src/utils/point.js","../../src/utils/object.js","../../src/utils/store-actions.js","../../src/resource.js","../../src/resources/order.js","../../src/resources/payload.js","../../src/resources/entity.js","../../src/resources/place.js","../../src/resources/waypoint.js","../../src/resources/tracking-status.js","../../src/resources/vehicle.js","../../src/resources/driver.js","../../src/resources/vendor.js","../../src/resources/contact.js","../../src/resources/zone.js","../../src/resources/service-area.js","../../src/resources/service-rate.js","../../src/resources/service-quote.js","../../src/adapter.js","../../src/adapters/browser.js","../../src/adapters/node.js","../../src/adapters/ember.js","../../src/utils/string.js","../../src/resolver.js","../../src/store.js","../../src/fleetbase.js","../../src/utils/is-latitude.js","../../src/utils/is-longitude.js"],"sourcesContent":["const { isArray } = Array;\n\nexport {\n isArray\n};\n","import { isArray } from './array';\n\n/**\n * Collection\n * Extended array inspired by Ember's NativeArray\n **/\n\nconst CHUNK_SIZE = 60000;\n\n// To avoid overflowing the stack, we splice up to CHUNK_SIZE items at a time.\n// See https://code.google.com/p/chromium/issues/detail?id=56588 for more details.\nconst replace = (array, start, deleteCount, items = []) => {\n if (isArray(array)) {\n if (items.length <= CHUNK_SIZE) {\n array.splice(start, deleteCount, ...items);\n } else {\n array.splice(start, deleteCount);\n\n for (let i = 0; i < items.length; i += CHUNK_SIZE) {\n let chunk = items.slice(i, i + CHUNK_SIZE);\n array.splice(start + i, 0, ...chunk);\n }\n }\n } else if (isCollection(arr)) {\n array.replace(start, deleteCount, items);\n }\n};\n\nconst identityFunction = (item) => item;\n\nconst uniqBy = (array, key = identityFunction) => {\n let ret = [];\n let seen = new Set();\n let getter = typeof key === 'function' ? key : (item) => get(item, key);\n\n array.forEach((item) => {\n let val = getter(item);\n if (!seen.has(val)) {\n seen.add(val);\n ret.push(item);\n }\n });\n\n return ret;\n};\n\nconst isCollection = (mixed) => mixed instanceof Collection;\n\nconst objectAt = (array, index) => {\n if (isArray(array)) {\n return array[index];\n } else if (isCollection(array)) {\n return array.objectAt(index);\n }\n\n return null;\n};\n\nconst iter = (key, value) => {\n let valueProvided = arguments.length === 2;\n return valueProvided ? (item) => value === item[key] : (item) => Boolean(item[key]);\n};\n\nconst findIndex = (array, predicate, startAt = 0) => {\n let len = array.length;\n for (let index = startAt; index < len; index++) {\n let item = objectAt(array, index);\n if (predicate(item, index, array)) {\n return index;\n }\n }\n return -1;\n};\n\nconst find = (array, callback, target) => {\n let predicate = callback.bind(target);\n let index = findIndex(array, predicate, 0);\n return index === -1 ? undefined : objectAt(array, index);\n};\n\nconst any = (array, callback, target) => {\n let predicate = callback.bind(target);\n return findIndex(array, predicate, 0) !== -1;\n};\n\nconst every = (array, callback, target) => {\n let cb = callback.bind(target);\n let predicate = (item, index, array) => !cb(item, index, array);\n return findIndex(array, predicate, 0) === -1;\n};\n\nconst indexOf = (array, val, startAt = 0, withNaNCheck) => {\n let len = array.length;\n\n if (startAt < 0) {\n startAt += len;\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = withNaNCheck && val !== val ? (item) => item !== item : (item) => item === val;\n return findIndex(array, predicate, startAt);\n};\n\nconst removeAt = (array, index, len = 1) => {\n replace(array, index, len, []);\n return array;\n};\n\nconst insertAt = (array, index, item) => {\n replace(array, index, 0, [item]);\n return item;\n};\n\nclass Collection extends Array {\n constructor(...items) {\n if (isArray(arguments[0])) {\n super(...arguments[0]);\n } else {\n super(...arguments);\n }\n }\n\n get notEmpty() {\n return this.length > 0;\n }\n\n get empty() {\n return this.length === 0;\n }\n\n get first() {\n return objectAt(this, 0);\n }\n\n get last() {\n return objectAt(this, this.length - 1);\n }\n\n replace(start, deleteCount, items = []) {\n replace(this, start, deleteCount, items);\n\n return this;\n }\n\n objectsAt(indexes) {\n return indexes.map((idx) => objectAt(this, idx));\n }\n\n objectAt(index) {\n return objectAt(this, index);\n }\n\n indexOf(object, startAt) {\n return indexOf(this, object, startAt, false);\n }\n\n lastIndexOf(object, startAt) {\n let len = this.length;\n\n if (startAt === undefined || startAt >= len) {\n startAt = len - 1;\n }\n\n if (startAt < 0) {\n startAt += len;\n }\n\n for (let idx = startAt; idx >= 0; idx--) {\n if (objectAt(this, idx) === object) {\n return idx;\n }\n }\n\n return -1;\n }\n\n includes(object, startAt) {\n return indexOf(this, object, startAt, true) !== -1;\n }\n\n findBy() {\n return find(this, iter(...arguments));\n }\n\n findIndexBy() {\n return findIndex(this, iter(...arguments));\n }\n\n isEvery() {\n return every(this, iter(...arguments));\n }\n\n isAny() {\n return any(this, iter(...arguments));\n }\n\n invoke(methodName, ...args) {\n let ret = [];\n\n this.forEach((item) => ret.push(item[methodName]?.(...args)));\n\n return ret;\n }\n\n toArray() {\n return this.map((item) => item);\n }\n\n compact() {\n return this.filter((value) => value != null);\n }\n\n sortBy() {\n let sortKeys = arguments;\n\n return this.sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n let key = sortKeys[i];\n let propA = a[key];\n let propB = b[key];\n // return 1 or -1 else continue to the next sortKey\n let compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n }\n\n uniqBy(key) {\n return uniqBy(this, key);\n }\n\n without(value) {\n if (!this.includes(value)) {\n return this; // nothing to do\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = value === value ? (item) => item !== value : (item) => item === item;\n return this.filter(predicate);\n }\n\n clear() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n this.replace(0, len, []);\n return this;\n }\n\n insertAt(idx, object) {\n insertAt(this, idx, object);\n return this;\n }\n\n replaceAt(idx, object) {\n return this.replace(idx, 1, [object]);\n }\n\n removeAt(start, len) {\n return removeAt(this, start, len);\n }\n\n pushObject(obj) {\n return this.insertAt(this.length, obj);\n }\n\n pushObjects(objects) {\n this.replace(this.length, 0, objects);\n return this;\n }\n\n popObject() {\n let len = this.length;\n if (len === 0) {\n return null;\n }\n\n let ret = objectAt(this, len - 1);\n this.removeAt(len - 1, 1);\n return ret;\n }\n\n shiftObject() {\n if (this.length === 0) {\n return null;\n }\n\n let ret = objectAt(this, 0);\n this.removeAt(0);\n return ret;\n }\n\n unshiftObject(obj) {\n return insertAt(this, 0, obj);\n }\n\n unshiftObjects(objects) {\n this.replace(0, 0, objects);\n return this;\n }\n\n reverseObjects() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n let objects = this.toArray().reverse();\n this.replace(0, len, objects);\n return this;\n }\n\n setObjects(objects) {\n if (objects.length === 0) {\n return this.clear();\n }\n\n let len = this.length;\n this.replace(0, len, objects);\n return this;\n }\n\n removeObject(obj) {\n let loc = this.length || 0;\n while (--loc >= 0) {\n let curObject = objectAt(this, loc);\n\n if (curObject === obj) {\n this.removeAt(loc);\n }\n }\n return this;\n }\n\n removeObjects(objects) {\n for (let i = objects.length - 1; i >= 0; i--) {\n this.removeObject(objects[i]);\n }\n\n return this;\n }\n\n addObject(obj) {\n let included = this.includes(obj);\n\n if (!included) {\n this.pushObject(obj);\n }\n\n return this;\n }\n\n addObjects(objects) {\n objects.forEach((obj) => this.addObject(obj));\n return this;\n }\n}\n\nexport default Collection;\n\nexport { replace, uniqBy, isCollection, objectAt, iter, findIndex, find, any, every, indexOf, removeAt, insertAt };\n","const isEmpty = (obj) => {\n const none = obj === null || obj === undefined;\n if (none) {\n return none;\n }\n\n if (typeof obj.size === 'number') {\n return !obj.size;\n }\n\n const objectType = typeof obj;\n\n if (objectType === 'object') {\n const { size } = obj;\n if (typeof size === 'number') {\n return !size;\n }\n }\n\n if (typeof obj.length === 'number' && objectType !== 'function') {\n return !obj.length;\n }\n\n if (objectType === 'object') {\n const { length } = obj;\n if (typeof length === 'number') {\n return !length;\n }\n }\n\n return false;\n};\n\nexport default isEmpty;\n","import isEmpty from './is-empty';\n\nconst isBlank = (obj) => isEmpty(obj) || (typeof obj === 'string' && /\\S/.test(obj) === false);\n\nexport default isBlank;\n","import Resource from '../resource';\n\nexport default function isResource(record) {\n return record instanceof Resource;\n}\n","const isPhone = (phone = '') => {\n return /^[+]?[\\s./0-9]*[(]?[0-9]{1,4}[)]?[-\\s./0-9]*$/g.test(phone);\n}\n\nexport default isPhone;","/**\n * Determines if environment SDK is initialized in is Node, additionally checks pass if environment is ReactNative.\n * \n * @returns boolean\n */\nconst isNodeEnvironment = () => {\n return (typeof process !== 'undefined') && (typeof process?.env === 'object' || process.release?.name?.search(/node|io.js/) !== -1) && (typeof window === 'undefined' || window?.navigator?.product === 'ReactNative');\n};\n\nexport default isNodeEnvironment;","import { lookup } from '../resolver';\nimport isNodeEnvironment from './is-node-environment';\n\nconst detectAdapter = (options = {}) => {\n if (isNodeEnvironment()) {\n return lookup('adapter', 'NodeAdapter', options);\n }\n\n return lookup('adapter', 'BrowserAdapter', options);\n}\n\nexport default detectAdapter;","const { isArray } = Array;\n\nclass GoogleAddress {\n constructor(place) {\n this.place = place;\n this.geometry = place?.geometry;\n this.components = this.parseComponents();\n this.attributes = this.parseProperties();\n }\n\n parse() {\n this.parseComponents();\n this.parseProperties();\n }\n\n parseComponents() {\n const components = (this.place?.address_components || []).reduce(function (acc, data) {\n data.types.forEach(function (type) {\n acc[type] = data;\n });\n return acc;\n }, {});\n\n return components;\n }\n\n parseProperties() {\n const attributes = {\n streetNumber: this.get('street_number'),\n streetName: this.get('route'),\n coordinates: this.geometry?.location ? Object.values(this.geometry.location) : [0, 0],\n city: this.or(['locality', 'sublocality', 'sublocality_level_1', 'neighborhood', 'administrative_area_level_3', 'administrative_area_level_2']),\n county: this.get('administrative_area_level_2'),\n stateShort: this.get('administrative_area_level_1', true),\n stateLong: this.get('administrative_area_level_1'),\n countryShort: this.get('country', true),\n country: this.get('country', true),\n countryLong: this.get('country'),\n postalCode: this.get('postal_code'),\n };\n\n attributes.address = [attributes.streetNumber, attributes.streetName].filter(Boolean).join(' ');\n\n return attributes;\n }\n\n all() {\n return this.attributes;\n }\n\n or(keys = []) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (isArray(key)) {\n const pkey = key[0];\n const short = key[1];\n\n if (this.has(pkey)) {\n return this.get(pkey, short);\n }\n\n continue;\n }\n\n if (this.has(key)) {\n return this.get(key);\n }\n }\n\n return null;\n }\n\n has(key) {\n return (key in this.components);\n }\n\n get(key, short = false) {\n if (!(key in this.components)) {\n return null;\n }\n\n return short ? this.components[key].short_name : this.components[key].long_name;\n }\n\n setAttributes(attributes = {}) {\n this.attributes = {...this.attributes, ...attributes};\n\n return this;\n }\n\n setAttribute(key, value) {\n this.attributes[key] = value;\n\n return this;\n }\n\n getAttribute(key) {\n return this.attributes[key] || null;\n }\n}\n\nexport default GoogleAddress;\n","export default class Point {\n constructor(latitude = 0, longitude = 0) {\n this.type = 'Point';\n this.coordinates = [longitude, latitude];\n }\n\n get latitude() {\n return this.coordinates[1];\n }\n\n get longitude() {\n return this.coordinates[0];\n }\n\n lat() {\n return this.latitude;\n }\n\n lng() {\n return this.longitude;\n }\n\n static fromGeoJson(json) {\n [ longitude, latitude ] = json.coordinates;\n\n return new Point(latitude, longitude);\n }\n\n serialize() {\n return {\n type: 'Point',\n coorindates: [this.lat(), this.lng()]\n };\n }\n\n toJson() {\n return this.serialize();\n }\n\n toString() {\n return `(${this.latitude}, ${this.longitude})`;\n }\n}","import isEmpty from './is-empty';\n\nconst isResource = (mixed) => typeof mixed === 'object' && !isEmpty(mixed?.attributes) && typeof mixed?.attributes === 'object';\n\nconst isCallable = (object, property) => typeof object[property] === 'function';\n\nconst getResolved = (func, path) => {\n const resolved = func();\n return Array.isArray(resolved) || typeof resolved === 'object' ? get(resolved, path) : null;\n};\n\nconst invoke = (object, method) => {\n if (typeof object[method] === 'function') {\n return object[method].bind(object);\n }\n};\n\nconst get = (object, path) => {\n let current = object;\n\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n\n if (isArray || isObject) {\n for (let i = 0; i < pathArray.length; i++) {\n if (current && current[pathArray[i]] === undefined) {\n return null;\n } else if (current) {\n current = current[pathArray[i]];\n\n // if is resource then return get on it's attributes\n if (isResource(current) && pathArray[i + 1] !== undefined) {\n const newPath = pathArray.slice(i + 1).join('.');\n\n return get(current.attributes, newPath);\n }\n\n // resolve functions and continue\n if (typeof current === 'function') {\n const newPath = pathArray.slice(i + 1).join('.');\n return getResolved(current, newPath);\n }\n }\n }\n return current;\n }\n\n if (isFunction) {\n return getResolved(object, path);\n }\n};\n\nconst getProperties = (object, properties = []) => {\n const selected = {};\n let propertyNames = arguments;\n let i = 1;\n\n if (arguments.length === 2 && Array.isArray(properties)) {\n i = 0;\n propertyNames = arguments[1];\n }\n\n for (; i < propertyNames.length; i++) {\n selected[propertyNames[i]] = get(object, propertyNames[i]);\n }\n\n return selected;\n};\n\nconst set = (object, path, value) => {\n let current = object;\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n // if is function\n if (isFunction) {\n // throw error should be object or array or object like\n }\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n const iterations = pathArray.length;\n\n if (isArray || isObject) {\n for (let i = 0; i < iterations - 1; i++) {\n if (!current[pathArray[i]]) {\n current[pathArray[i]] = {};\n }\n current = current[pathArray[i]];\n }\n\n current[pathArray[iterations - 1]] = value;\n }\n\n return value;\n};\n\nconst setProperties = (object, properties = {}) => {\n for (const property in properties) {\n set(object, property, properties[property]);\n }\n\n return object;\n};\n\nconst extend = (target, classes = []) => {\n if (arguments.length > 1) {\n classes = arguments;\n }\n for (let index = 0; index < classes.length; index++) {\n for (const property in classes[index]) {\n if (Object.prototype.hasOwnProperty.call(classes[index], property)) {\n target[property] = classes[index][property];\n }\n }\n }\n return target;\n};\n\nexport { set, get, getProperties, setProperties, extend, isCallable, invoke };\n","import { set } from './object';\n\nexport default class StoreActions {\n constructor(actions = {}, bind = null) {\n this.actions = actions;\n this.bind = bind;\n }\n\n extend(bindTo = null) {\n const binding = bindTo || this.bind;\n\n if (!binding) {\n return this;\n }\n\n if (this?.actions && typeof this.actions === 'object') {\n for (let action in this.actions) {\n const fn = this.actions[action];\n\n if (typeof fn !== 'function') {\n set(binding, action, fn);\n continue;\n }\n\n set(binding, action, fn.bind(binding));\n }\n }\n\n return this;\n }\n}\n","import Store from './store';\nimport { isEmpty } from './utils';\nimport { isArray } from './utils/array';\nimport { set, get } from './utils/object';\n\nclass Resource {\n /**\n\t * The base resource for all resources\n\n\t * @return {[type]} [description]\n\t */\n constructor(attributes = {}, adapter, resource, options = {}) {\n this.attributes = attributes;\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isDestroying = false;\n this.isReloading = false;\n this.resource = resource;\n this.options = options;\n this.version = options.version || 'v1';\n this.setAdapter(adapter);\n }\n\n /**\n * Set a new adapter to the resource instance, this will update the Store instance\n *\n * @param {Adapter} adapter\n * @return {Resource} this\n */\n setAdapter(adapter) {\n this.adapter = adapter;\n this.store = new Store(this.resource, adapter, {\n onAfterFetch: this.syncAttributes.bind(this),\n actions: this.options?.actions\n });\n\n return this;\n }\n\n /**\n * Getter for id attribute\n *\n * @var {String}\n */\n get id() {\n return this.getAttribute('id');\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n create(attributes = {}) {\n const data = this.mergeAttributes(attributes);\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.create(data).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n update(attributes = {}) {\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.update(this.attributes.id, attributes).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Deletes the resource instance on the server\n *\n * @return {[type]} [description]\n */\n destroy() {\n this.setFlags(['isLoading', 'isDestroying']);\n\n return this.store.destroy(this.attributes.id).then((response) => {\n this.setFlags(['isLoading', 'isDestroying'], false);\n\n return response;\n });\n }\n\n /**\n * Reloads the resource from the server.\n *\n * @return {[type]} [description]\n */\n reload() {\n this.setFlags(['isLoading', 'isReloading']);\n\n return this.store.findRecord(this.attributes.id).then((response) => {\n this.reset();\n\n return response;\n });\n }\n\n /**\n * Sets flag properties.\n *\n * @return this\n */\n setFlags(flags = [], state = true) {\n const validFlags = ['isLoading', 'isSaving', 'isReloading', 'isDestroying'];\n\n for(let i = 0; i < flags.length; i++) {\n const flag = flags[i];\n\n if (typeof flag !== 'string' || !validFlags.includes(flag)) {\n throw new Error(`${flag} is not a valid flag!`);\n }\n\n this[flag] = state;\n }\n\n return this;\n }\n\n /**\n * Resets tracked properties\n *\n * @return this\n */\n reset() {\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isReloading = false;\n\n return this;\n }\n\n /**\n * Emptys resource.\n *\n * @return this\n */\n empty() {\n this.reset();\n this.attribues = {};\n\n return this;\n }\n\n /**\n * Saves the resource instance on the server\n *\n * @return {[type]} [description]\n */\n save(options = {}) {\n const attributes = this.getAttributes();\n\n if (isEmpty(this.id)) {\n return this.create(attributes);\n }\n\n if (options.onlyDirty === true) {\n return this.savedirty();\n }\n\n return this.update(attributes);\n }\n\n /**\n * Saves only dirtied attributes.\n *\n * @return {[type]} [description]\n */\n saveDirty() {\n const dirtyAttributeKeys = Object.keys(this.dirtyAttributes);\n const dirtyAttributes = {};\n\n for (let i = 0; i < dirtyAttributeKeys.length; i++) {\n const key = dirtyAttributeKeys[i];\n dirtyAttributes[key] = this.getAttribute(key);\n }\n\n return this.update(dirtyAttributes);\n }\n\n /**\n * Returns the resource meta if exists.\n *\n * @return {Object}\n */\n get meta() {\n return this.getAttribute('meta', {});\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get createdAt() {\n return this.isAttributeFilled('created_at') ? new Date(this.getAttribute('created_at')) : null;\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get updatedAt() {\n return this.isAttributeFilled('updated_at') ? new Date(this.getAttribute('updated_at')) : null;\n }\n\n /**\n * Checks if resource is loaded from the server.\n *\n * @return {Boolean}\n */\n get isLoaded() {\n return this.hasAttributes(['created_at', 'id']);\n }\n\n /**\n * Checks if resource ihas no attributes\n *\n * @return {Boolean}\n */\n get isEmpty() {\n return Object.values(this?.attributes).length === 0;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isNew() {\n return !this.id;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isSaved() {\n return !this.isNew && this.isLoaded;\n }\n\n /**\n * Checks if resource is deleted on server.\n *\n * @return {Boolean}\n */\n get isDeleted() {\n return this.hasAttributes(['deleted', 'time']);\n }\n\n /**\n * Iterates over each attribute value and property executing a user supplied callback.\n *\n * @return {Object}\n */\n eachAttribute(callback) {\n if (typeof callback !== 'function') {\n return this;\n }\n\n Object.keys(this?.attributes ?? {}).forEach((property) => {\n const value = this.getAttribute(property);\n callback.call(this, value, property);\n });\n\n return this;\n }\n\n /**\n * Gets all changes\n *\n * @return {Object}\n */\n changes() {\n return this.changes;\n }\n\n /**\n * Gets all dirty attributes.\n *\n * @return {Object}\n */\n getDirtyAttributes() {\n return this.dirtyAttributes;\n }\n\n /**\n * Checks if property is dirty.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n isDirty(property) {\n return property in this.dirtyAttributes;\n }\n\n /**\n * Checks if any properties is dirty.\n *\n * @return {Boolean}\n */\n hasDirtyAttributes() {\n return Object.keys(this?.dirtyAttributes ?? {}).length > 0;\n }\n\n /**\n * Updates a instance property without tracking changes or dirtying attribute.\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n mutate(property, value) {\n this.attributes[property] = value;\n }\n\n /**\n * Set an instance property locally\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n setAttribute(property, value = null) {\n if (value === null && typeof property === 'object') {\n return this.setAttributes(property);\n }\n\n const previousValue = this?.attributes[property] ?? null;\n\n // use object setter\n set(this.attributes, property, value);\n set(this.dirtyAttributes, property, previousValue);\n \n // this.attributes[property] = value;\n // this.dirtyAttributes[property] = previousValue;\n\n // track changes\n if (!isArray(this?.changes[property])) {\n this.changes[property] = [];\n }\n\n this.changes[property].push({\n property,\n previousValue,\n value,\n changedAt: new Date(),\n });\n\n return this;\n }\n\n /**\n * Set multiple instance properties locally\n *\n * @param {Object} properties [description]\n */\n setAttributes(attributes = {}) {\n for (let property in attributes) {\n this.setAttribute(property, attributes[property]);\n }\n\n return this;\n }\n\n /**\n * Get an attribute\n *\n * @param {String} attribute The attribute key to get\n * @param {mixed} defaultValue The default value if no attribute value\n */\n getAttribute(attribute, defaultValue = null) {\n const value = get(this?.attributes ?? {}, attribute);\n\n if (value === undefined) {\n return defaultValue;\n }\n\n return value;\n }\n\n /**\n * Checks if attribute exists.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n hasAttribute(property) {\n if (isArray(property)) {\n const properties = property;\n const attributeKeys = Object.keys(this.attributes ?? {});\n \n return properties.every((prop) => attributeKeys.includes(prop));\n }\n\n if (!this?.attributes) {\n return false;\n }\n\n return property in this.attributes;\n }\n\n /**\n * Alias for checking if has multiple attributes.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n hasAttributes(properties = []) {\n return this.hasAttribute(properties);\n }\n\n /**\n * Returns true if attribute has value.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n isAttributeFilled(property) {\n if (isArray(property)) {\n return this.hasAttribute(property) && property.every((prop) => !isEmpty(this.getAttribute(prop)));\n }\n\n return this.hasAttribute(property) && !isEmpty(this.getAttribute(property));\n }\n\n /**\n * Get multiple attributes.\n *\n * @param {Array} properties [description]\n * @param {[type]} value [description]\n */\n getAttributes(properties) {\n const attributes = {};\n\n if (properties === null || properties === undefined) {\n return this.getAttributes(Object.keys(this.attributes));\n }\n\n if (typeof properties === 'string') {\n return this.getAttribute([...arguments]);\n }\n\n if (!isArray(properties)) {\n throw new Error('No attribute properties provided!');\n }\n\n for (let i = 0; i < properties.length; i++) {\n const property = properties[i];\n\n if (typeof property !== 'string') {\n continue;\n }\n\n let value = this.getAttribute(property);\n\n if (typeof value?.attributes === 'object' && !isArray(value?.attributes)) {\n value = value.attributes;\n }\n\n attributes[property] = value;\n }\n\n return attributes;\n }\n\n /**\n * Serialize resource to a POJO\n *\n * @returns {Object}\n */\n serialize() {\n return this.getAttributes();\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n mergeAttributes(attributes = {}) {\n const modelAttributes = this?.attributes ?? {};\n this.attributes = { ...modelAttributes, ...attributes };\n\n return this.attributes;\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n syncAttributes(json = {}) {\n this.attributes = json;\n }\n}\n\nexport default Resource;\n","import Resource from '../resource';\nimport { StoreActions } from '../utils';\nimport { isValid as isValidDate } from 'date-fns';\n\nconst orderActions = new StoreActions({\n getDistanceAndTime: function (id, params = {}, options = {}) {\n return this.adapter.get(`${this.namespace}/${id}/distance-and-time`, params, options);\n },\n\n getNextActivity: function (id, params = {}, options = {}) {\n return this.adapter.get(`${this.namespace}/${id}/next-activity`, params, options);\n },\n\n dispatch: function (id, params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/dispatch`, params, options).then(this.afterFetch.bind(this));\n },\n\n start: function (id,params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/start`, params, options).then(this.afterFetch.bind(this));\n },\n\n updateActivity: function (id, params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/update-activity`, params, options).then(this.afterFetch.bind(this));\n },\n\n complete: function (id, params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/complete`, params, options).then(this.afterFetch.bind(this));\n },\n\n cancel: function (id, params = {}, options = {}) {\n return this.adapter.delete(`${this.namespace}/${id}/cancel`, params, options).then(this.afterFetch.bind(this));\n }\n});\n\nclass Order extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'order', { actions: orderActions, ...options });\n }\n\n getDistanceAndTime(params = {}, options = {}) {\n return this.store.getDistanceAndTime(this.id, params, options);\n }\n\n dispatch(params = {}, options = {}) {\n return this.store.dispatch(this.id, params, options);\n }\n\n start(params = {}, options = {}) {\n return this.store.start(this.id, params, options);\n }\n\n getNextActivity(params = {}, options = {}) {\n return this.store.getNextActivity(this.id, params, options);\n }\n\n updateActivity(params = {}, options = {}) {\n return this.store.updateActivity(this.id, params, options);\n }\n\n cancel(params = {}, options = {}) {\n return this.store.cancel(this.id, params, options);\n }\n\n complete(params = {}, options = {}) {\n return this.store.complete(this.id, params, options);\n }\n\n get isDispatched() {\n return this.getAttribute('dispatched_at') !== null;\n }\n\n get isNotDispatched() {\n return this.getAttribute('dispatched_at') == null;\n }\n\n get isStarted() {\n return this.getAttribute('started_at') !== null;\n }\n\n get isNotStarted() {\n return this.getAttribute('started_at') == null;\n }\n\n get isCompleted() {\n return this.getAttribute('status') == 'completed';\n }\n\n get isCanceled() {\n return this.getAttribute('status') == 'canceled';\n }\n\n get isEnroute() {\n return this.getAttribute('status') == 'driver_enroute' || this.getAttribute('status') === 'enroute';\n }\n\n get isInProgress() {\n return this.isStarted && !this.isCanceled && !this.isCompleted;\n }\n\n get scheduledAt() {\n return this.isAttributeFilled('scheduled_at') ? new Date(this.getAttribute('scheduled_at')) : null;\n }\n\n get startedAt() {\n return this.isAttributeFilled('started_at') ? new Date(this.getAttribute('started_at')) : null;\n }\n\n get dispatchedAt() {\n return this.isAttributeFilled('dispatched_at') ? new Date(this.getAttribute('dispatched_at')) : null;\n }\n\n get status() {\n return this.getAttribute('status');\n }\n}\n\nexport default Order;\n\nexport { orderActions };\n","import Resource from '../resource';\nimport Collection from '../utils/collection';\n\nclass Payload extends Resource {\n\tconstructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'payload', options);\n }\n\t\n /**\n\t * Attaches an entity to an existing payload and returns\n\t * the payload with the entity attached\n\t *\n\t * @param {[type]} Entity entity [description]\n\t * @return {[type]} [description]\n\t */\n attach(entity) {\n // perform op return payload\n }\n\n /**\n\t * Returns all of the entities attached to this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get entities() {\n\n }\n\n /**\n\t * Returns the dropoff for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get dropoff() {\n\n }\n\n /**\n\t * Returns the pickup for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get pickup() {\n\n }\n\n /**\n\t * Returns all the waypoints for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get waypoints() {\n return new Collection(this.waypoints);\n }\n}\n\nexport default Payload;\n","import Resource from '../resource';\n\nclass Entity extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'entity', options);\n }\n}\n\nexport default Entity;\n","import Resource from '../resource';\nimport { isResource, Point } from '../utils';\n\nclass Place extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'place', options);\n }\n\n static fromGoogleAddress(googleAddress, adapter, options = {}) {\n const [ latitude, longitude ] = googleAddress.getAttribute('coordinates');\n const attributes = {\n name: null,\n address: googleAddress.getAttribute('address'),\n location: new Point(latitude, longitude),\n street1: googleAddress.getAttribute('streetName'),\n street2: null,\n city: googleAddress.getAttribute('city'),\n province: googleAddress.getAttribute('stateLong'),\n postal_code: googleAddress.getAttribute('postalCode'),\n neighborhood: googleAddress.get('neighborhood'),\n district: googleAddress.getAttribute('county'),\n building: googleAddress.get('building'),\n country: googleAddress.getAttribute('countryShort'),\n phone: null,\n security_access_code: null\n };\n\n return new Place(attributes, adapter, options);\n }\n\n /**\n * The latitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get latitude() {\n return this.getAttribute('location', new Point())?.coordinates[1];\n }\n\n /**\n * The longitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get longitude() {\n return this.getAttribute('location', new Point())?.coordinates[0];\n }\n\n /**\n * Array coordinate pair for Place location.\n * \n * @var {Array}\n */\n get coordinates() {\n const { latitude, longitude } = this;\n\n return [ latitude, longitude ];\n }\n\n /**\n * Set the owner of the place.\n * \n * @param {Object|String} owner\n * @return {Place}\n */\n setOwner(owner) {\n if (isResource(owner)) {\n this.setAttribute('owner', owner.id);\n }\n\n if (typeof owner === 'string') {\n this.setAttribute('owner', owner);\n }\n\n return this;\n }\n}\n\nexport default Place;\n","import Place from './place';\n\nclass Waypoint extends Place {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'waypoint', options);\n }\n}\n\nexport default Waypoint;\n","import Resource from '../resource';\n\nclass TrackingStatus extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'tracking-status', options);\n }\n}\n\nexport default TrackingStatus;\n","import Resource from '../resource';\n\nclass Vehicle extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vehicle', options);\n }\n}\n\nexport default Vehicle;\n","import Resource from '../resource';\nimport { StoreActions, isPhone, isEmail } from '../utils';\n\nconst driverActions = new StoreActions({\n // const { error } = await fleetbase.drivers.login('+1 111-1111');\n login: function (identity, password = null, attributes = {}) {\n // handle phone number authentication\n if (isPhone(identity)) {\n return this.adapter.post('drivers/login-with-sms', { phone: identity });\n }\n\n if (!password) {\n throw new Error('Login requires password!');\n }\n\n return this.adapter.post('drivers/login', { identity, password, ...attributes }).then(this.afterFetch.bind(this));\n },\n\n verifyCode: function (identity, code, attributes = {}) {\n return this.adapter.post('drivers/verify-code', { identity, code, ...attributes }).then(this.afterFetch.bind(this));\n },\n\n retrieve: function (id) {\n return this.findRecord(id);\n },\n});\n\nclass Driver extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'driver', options);\n }\n\n get token() {\n return this.getAttribute('token');\n }\n\n get isOnline() {\n return this.getAttribute('online') === true;\n }\n\n syncDevice(token) {\n return this.adapter\n .setHeaders({ 'Driver-Token': this.token })\n .post('drivers/register-device', token)\n .then(() => {\n return this;\n });\n }\n}\n\nexport default Driver;\nexport { driverActions };\n","import Resource from '../resource';\n\nclass Vendor extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vendor', options);\n }\n}\n\nexport default Vendor;\n","import Resource from '../resource';\n\nclass Contact extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'contact', options);\n }\n}\n\nexport default Contact;\n","import Resource from '../resource';\n\nclass Zone extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'zone', options);\n }\n}\n\nexport default Zone;\n","import Resource from '../resource';\n\nclass ServiceArea extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-area', options);\n }\n}\n\nexport default ServiceArea;\n","import Resource from '../resource';\n\nclass ServiceRate extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-rate', options);\n }\n}\n\nexport default ServiceRate;\n","import Resource from '../resource';\n\nclass ServiceQuote extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-quote', options);\n }\n\n fromPreliminary() {\n\n }\n\n fromPayload() {\n \n }\n}\n\nexport default ServiceQuote;\n","class Adapter {\n /**\n\t * Creates a configured base adapter for Fleetbase.\n\t *\n\t * @param {Object} config Configuration options for adapter\n\t */\n constructor(config = {}) {\n this.version = config.version || 'v1';\n this.host = config.host || null;\n this.namespace = config.namespace || null;\n this.headers = config.headers || {};\n }\n}\n\nexport default Adapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\n\nclass BrowserAdapter extends Adapter {\n /**\n * Setup browser adapter.\n * @param {Object} config\n */\n constructor(config) {\n super(config);\n\n this.setHeaders({\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;browser'\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n this.headers = { ...this.headers, ...headers };\n\n return this;\n }\n\n /**\n * Parses the JSON returned by a network request\n *\n * @param {Object} response A response from a network request\n * @return {Object} The parsed JSON, status from the response\n *\n * @return {Promise}\n */\n parseJSON(response) {\n return new Promise((resolve, reject) => response\n .json()\n .then((json) => resolve({\n statusText: response.statusText,\n status: response.status,\n ok: response.ok,\n json,\n }))\n .catch(() => {\n reject(new Error('Oops! Something went wrong when handling your request.'));\n }));\n }\n\n /**\n * The base request method\n *\n * @param {String} path\n * @param {String} method\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n request(path, method = 'GET', data = {}, options = {}) {\n return new Promise((resolve, reject) => fetch(options.url || `${this.host}/${this.namespace}/${path}`, {\n method,\n mode: options.mode || 'cors',\n headers: new Headers({\n ...(this.headers || {}),\n ...(options.headers || {}),\n }),\n ...data,\n })\n .then(this.parseJSON)\n .then((response) => {\n if (response.ok) {\n return resolve(response.json);\n }\n\n return reject(new Error(response.json.errors ? response.json.errors[0] : response.statusText));\n })\n .catch((error) => {\n reject(error);\n }));\n }\n\n /**\n * Makes a GET request with fetch\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.request(`${path}${urlParams ? `?${urlParams}` : ''}`, 'GET', {}, options);\n }\n\n /**\n * Makes a POST request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.request(path, 'POST', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a PUT request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.request(path, 'PUT', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a DELETE request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.request(path, 'DELETE', {}, options);\n }\n\n /**\n * Makes a PATCH request with fetch\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.request(path, 'PATCH', { body: JSON.stringify(data) }, options);\n }\n}\n\nexport default BrowserAdapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\nimport { isArray } from '../utils/array';\nimport axios from 'axios';\n\nclass NodeAdapter extends Adapter {\n constructor(config) {\n super(config);\n\n this.axios = axios.create({\n baseURL: `${this.host}/${this.namespace}`,\n headers: {\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;node',\n },\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n const commonHeaders = this.axios.defaults.headers.common;\n this.axios.defaults.headers.common = { ...commonHeaders, ...headers };\n\n return this;\n }\n\n /**\n * Tranform the response, and return the response data from axios.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n transform(response) {\n return response.data;\n }\n\n /**\n * Handles an erroneous request.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n handleError(error) {\n if (error.response) {\n const { data } = error.response;\n\n if (isArray(data.errors)) {\n throw new Error(data.errors[0]);\n }\n\n if (data.error) {\n throw new Error(data.error);\n }\n }\n\n throw error;\n }\n\n /**\n * Makes a GET request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.axios\n .get(`${path}${urlParams ? `?${urlParams}` : ''}`, options)\n .then(this.transform.bind(this))\n .catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a POST request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.axios.post(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PUT request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.axios.put(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a DELETE request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.axios.delete(path, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PATCH request with axios\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.axios.patch(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n}\n\nexport default NodeAdapter;\n","import Adapter from '../adapter';\n\nclass EmberJsAdapter extends Adapter {}\n\nexport default EmberJsAdapter;\n","'use strict';\n\n/**\n * Javascript String\n *\n * instance\n * new String('hello_world').humanize().get() => \"Hello world\"\n *\n * instance\n * const string = new String();\n * string.humanize('hello_world').get() => \"Hello world\"\n * \n * no chain\n * new String('hello_world', false).humanize() => \"Hello world\"\n *\n * static\n * String.invoke('humanize', 'hello_world') => \"Hello world\"\n *\n * exports {}\n * humanize('hello_world') => \"Hello world\"\n */\n\nexport default class String {\n constructor(string, chain = true) {\n this.str = string;\n this.chain = chain;\n }\n\n uncountableWords = ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'moose', 'deer', 'news'];\n\n pluralRules = [\n [new RegExp('(m)an$', 'gi'), '$1en'],\n [new RegExp('(pe)rson$', 'gi'), '$1ople'],\n [new RegExp('(child)$', 'gi'), '$1ren'],\n [new RegExp('^(ox)$', 'gi'), '$1en'],\n [new RegExp('(ax|test)is$', 'gi'), '$1es'],\n [new RegExp('(octop|vir)us$', 'gi'), '$1i'],\n [new RegExp('(alias|status)$', 'gi'), '$1es'],\n [new RegExp('(bu)s$', 'gi'), '$1ses'],\n [new RegExp('(buffal|tomat|potat)o$', 'gi'), '$1oes'],\n [new RegExp('([ti])um$', 'gi'), '$1a'],\n [new RegExp('sis$', 'gi'), 'ses'],\n [new RegExp('(?:([^f])fe|([lr])f)$', 'gi'), '$1$2ves'],\n [new RegExp('(hive)$', 'gi'), '$1s'],\n [new RegExp('([^aeiouy]|qu)y$', 'gi'), '$1ies'],\n [new RegExp('(x|ch|ss|sh)$', 'gi'), '$1es'],\n [new RegExp('(matr|vert|ind)ix|ex$', 'gi'), '$1ices'],\n [new RegExp('([m|l])ouse$', 'gi'), '$1ice'],\n [new RegExp('(quiz)$', 'gi'), '$1zes'],\n [new RegExp('s$', 'gi'), 's'],\n [new RegExp('$', 'gi'), 's'],\n ];\n\n singularRules = [\n [new RegExp('(m)en$', 'gi'), '$1an'],\n [new RegExp('(pe)ople$', 'gi'), '$1rson'],\n [new RegExp('(child)ren$', 'gi'), '$1'],\n [new RegExp('([ti])a$', 'gi'), '$1um'],\n [new RegExp('((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$', 'gi'), '$1$2sis'],\n [new RegExp('(hive)s$', 'gi'), '$1'],\n [new RegExp('(tive)s$', 'gi'), '$1'],\n [new RegExp('(curve)s$', 'gi'), '$1'],\n [new RegExp('([lr])ves$', 'gi'), '$1f'],\n [new RegExp('([^fo])ves$', 'gi'), '$1fe'],\n [new RegExp('([^aeiouy]|qu)ies$', 'gi'), '$1y'],\n [new RegExp('(s)eries$', 'gi'), '$1eries'],\n [new RegExp('(m)ovies$', 'gi'), '$1ovie'],\n [new RegExp('(x|ch|ss|sh)es$', 'gi'), '$1'],\n [new RegExp('([m|l])ice$', 'gi'), '$1ouse'],\n [new RegExp('(bus)es$', 'gi'), '$1'],\n [new RegExp('(o)es$', 'gi'), '$1'],\n [new RegExp('(shoe)s$', 'gi'), '$1'],\n [new RegExp('(cris|ax|test)es$', 'gi'), '$1is'],\n [new RegExp('(octop|vir)i$', 'gi'), '$1us'],\n [new RegExp('(alias|status)es$', 'gi'), '$1'],\n [new RegExp('^(ox)en', 'gi'), '$1'],\n [new RegExp('(vert|ind)ices$', 'gi'), '$1ex'],\n [new RegExp('(matr)ices$', 'gi'), '$1ix'],\n [new RegExp('(quiz)zes$', 'gi'), '$1'],\n [new RegExp('s$', 'gi'), ''],\n ];\n\n nonTitlecasedWords = ['and', 'or', 'nor', 'a', 'an', 'the', 'so', 'but', 'to', 'of', 'at', 'by', 'from', 'into', 'on', 'onto', 'off', 'out', 'in', 'over', 'with', 'for'];\n\n idSuffix = new RegExp('(_ids|_id)$', 'g');\n underbar = new RegExp('_', 'g');\n spaceOrUnderbar = new RegExp('[ _]', 'g');\n uppercase = new RegExp('([A-Z])', 'g');\n underbarPrefix = new RegExp('^_');\n\n get() {\n return this.str;\n }\n\n applyRules(str, rules, skip, override) {\n if (override) {\n str = override;\n } else {\n var ignore = skip.indexOf(str.toLowerCase()) > -1;\n if (!ignore) {\n for (var x = 0; x < rules.length; x++) {\n if (str.match(rules[x][0])) {\n str = str.replace(rules[x][0], rules[x][1]);\n break;\n }\n }\n }\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.pluralize('person') -> 'people'\n String.pluralize('octopus') -> 'octopi'\n String.pluralize('Hat') -> 'Hats'\n String.pluralize('person', 'guys') -> 'guys' \n */\n pluralize(str, plural = null) {\n str = str || this.str;\n\n return this.applyRules(str, this.pluralRules, this.uncountableWords, plural);\n }\n\n /*\n String.singularize('person') -> 'person'\n String.singularize('octopi') -> 'octopus'\n String.singularize('hats') -> 'hat'\n String.singularize('guys', 'person') -> 'person'\n */\n singularize(str, singular) {\n str = str || this.str;\n\n return this.applyRules(str, this.singularRules, this.uncountableWords, singular);\n }\n\n /*\n String.camelize('message_properties') -> 'MessageProperties'\n String.camelize('message_properties', true) -> 'messageProperties'\n */\n camelize(str, lowFirstLetter) {\n str = str || this.str;\n\n let str_path = str.split('/');\n for (var i = 0; i < str_path.length; i++) {\n let str_arr = str_path[i].split('_');\n let initX = lowFirstLetter && i + 1 === str_path.length ? 1 : 0;\n\n for (let x = initX; x < str_arr.length; x++) {\n str_arr[x] = str_arr[x].charAt(0).toUpperCase() + str_arr[x].substring(1);\n }\n str_path[i] = str_arr.join('');\n }\n str = str_path.join('::');\n\n // fix\n if (lowFirstLetter === true) {\n let first = str.charAt(0).toLowerCase();\n let last = str.slice(1);\n str = first + last;\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.underscore('MessageProperties') -> 'message_properties'\n String.underscore('messageProperties') -> 'message_properties'\n */\n underscore(str) {\n str = str || this.str;\n\n var str_path = str.split('::');\n for (var i = 0; i < str_path.length; i++) {\n str_path[i] = str_path[i].replace(this.uppercase, '_$1');\n str_path[i] = str_path[i].replace(this.underbarPrefix, '');\n }\n str = str_path.join('/').toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.humanize('message_properties') -> 'Message properties'\n String.humanize('message_properties') -> 'message properties'\n */\n humanize(str, lowFirstLetter) {\n str = str || this.str;\n\n var str = str.toLowerCase();\n str = str.replace(this.idSuffix, '');\n str = str.replace(this.underbar, ' ');\n if (!lowFirstLetter) {\n str = this.capitalize(str);\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.capitalize('message_properties') -> 'Message_properties'\n String.capitalize('message properties') -> 'Message properties'\n */\n capitalize(str) {\n str = str || this.str;\n\n str = str.toLowerCase();\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.dasherize('message_properties') -> 'message-properties'\n String.dasherize('message properties') -> 'message-properties'\n */\n dasherize(str) {\n str = str || this.str;\n\n str = str.replace(this.spaceOrUnderbar, '-');\n str = str.toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.normify('message_properties') -> 'Message Properties'\n String.normify('message properties') -> 'Message Properties'\n Inflactor.normify('Message_propertyId', true) -> 'Message Properties Id'\n */\n normify(str, allFirstUpper) {\n str = str || this.str;\n\n //var str = str.toLowerCase();\n if (allFirstUpper === true) {\n str = this.camelize(str);\n str = this.underscore(str);\n } else {\n str = str.toLowerCase();\n }\n\n str = str.replace(this.underbar, ' ');\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var d = str_arr[x].split('-');\n for (var i = 0; i < d.length; i++) {\n if (this.nonTitlecasedWords.indexOf(d[i].toLowerCase()) < 0) {\n d[i] = this.capitalize(d[i]);\n }\n }\n str_arr[x] = d.join('-');\n }\n str = str_arr.join(' ');\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.demodulize('Message::Bus::Properties') -> 'Properties'\n */\n demodulize(str) {\n str = str || this.str;\n\n var str_arr = str.split('::');\n str = str_arr[str_arr.length - 1];\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.tableize('MessageBusProperty') -> 'message_bus_properties'\n */\n tableize(str) {\n str = str || this.str;\n\n str = this.pluralize(this.underscore(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.classify('message_bus_properties') -> 'MessageBusProperty'\n */\n classify(str) {\n str = str || this.str;\n\n str = this.singularize(this.camelize(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.foreignKey('MessageBusProperty') -> 'message_bus_property_id'\n String.foreignKey('MessageBusProperty', true) -> 'message_bus_propertyid'\n */\n foreignKey(str, dropIdUbar = false) {\n str = str || this.str;\n\n str = this.underscore(this.demodulize(str)) + (dropIdUbar ? '' : '_') + 'id';\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.ordinalize('the 1 pitch') -> 'the 1st pitch'\n */\n ordinalize(str) {\n str = str || this.str;\n\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var i = parseInt(str_arr[x]);\n if (i === NaN) {\n var ltd = str_arr[x].substring(str_arr[x].length - 2);\n var ld = str_arr[x].substring(str_arr[x].length - 1);\n var suf = 'th';\n if (ltd != '11' && ltd != '12' && ltd != '13') {\n if (ld === '1') {\n suf = 'st';\n } else if (ld === '2') {\n suf = 'nd';\n } else if (ld === '3') {\n suf = 'rd';\n }\n }\n str_arr[x] += suf;\n }\n }\n str = str_arr.join(' ');\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /**\n * @method invoke\n **/\n static invoke() {\n const argz = Object.values(arguments);\n const instance = new String(null, false);\n const method = arguments[0];\n argz.shift();\n\n if (typeof instance[method] === 'function') {\n return instance[method](...argz);\n }\n\n return null;\n }\n}\n\nconst pluralize = function() {\n const argz = ['pluralize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst singularize = function() {\n const argz = ['singularize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst humanize = function() {\n const argz = ['humanize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst underscore = function() {\n const argz = ['underscore', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst camelize = function() {\n const argz = ['camelize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst capitalize = function() {\n const argz = ['capitalize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst dasherize = function() {\n const argz = ['dasherize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst normify = function() {\n const argz = ['normify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst demodulize = function() {\n const argz = ['demodulize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst tableize = function() {\n const argz = ['tableize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst classify = function() {\n const argz = ['classify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst foreignKey = function() {\n const argz = ['foreignKey', ...arguments];\n\n return String.invoke(...argz);\n};\n\nexport {\n pluralize,\n singularize,\n humanize,\n underscore,\n camelize,\n capitalize,\n dasherize,\n normify,\n demodulize,\n tableize,\n classify,\n foreignKey\n}","import { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter } from './adapters';\nimport { pluralize, singularize } from './utils/string';\n\nconst resources = {\n Contact,\n Driver,\n Entity,\n Order,\n Payload,\n Place,\n TrackingStatus,\n Vehicle,\n Vendor,\n Waypoint,\n Zone,\n ServiceArea,\n ServiceRate,\n ServiceQuote,\n};\n\nconst adapters = {\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter,\n};\n\nclass Resolver {\n constructor() {\n this.resources = resources;\n this.adapters = adapters;\n\n return this.lookup(...arguments);\n }\n\n lookup(type, className) {\n const key = pluralize(type);\n const params = [...arguments].slice(2);\n\n if (!this[key]) {\n throw new Error('Attempted to resolve invalid type');\n }\n\n if (!this[key][className]) {\n throw new Error(`No ${singularize(type)} named ${className} to resolve`);\n }\n\n return new this[key][className](...params);\n }\n}\n\nconst lookup = function () {\n return new Resolver(...arguments);\n};\n\nexport { Resolver, lookup };\n","import { lookup } from './resolver';\nimport { pluralize, classify } from './utils/string';\nimport { isArray } from './utils/array';\nimport { Collection, detectAdapter, isResource, StoreActions } from './utils';\nimport { set, isCallable, invoke } from './utils/object';\n\nconst extendStoreActions = (store, actions = []) => {\n store.actions = isArray(actions) ? actions : [actions];\n\n if (isArray(actions)) {\n for (let i = 0; i < actions.length; i++) {\n const action = actions[i];\n\n store.extendActions(action);\n }\n return;\n }\n\n if (actions instanceof StoreActions) {\n actions.extend(store);\n }\n\n return store;\n};\n\nconst afterFetch = (store, json) => {\n if (typeof store.options.onAfterFetch === 'function') {\n store.options.onAfterFetch(json);\n }\n\n if (isArray(json)) {\n const serialized = [];\n\n for (let i = 0; i < json.length; i++) {\n serialized.push(store.afterFetch(json[i]));\n }\n\n return new Collection(...serialized);\n }\n\n const resourceInstance = store.serialize(json);\n return store.deposit(resourceInstance);\n};\n\nclass Store {\n constructor(resource, adapter, options = {}) {\n this.resource = resource;\n this.adapter = adapter || detectAdapter();\n this.namespace = pluralize(resource);\n this.storage = new Collection();\n this.options = options;\n this.extendActions(options.actions);\n }\n\n extendActions(actions = []) {\n return extendStoreActions(this, actions);\n }\n\n deposit(resourceInstance) {\n // this.storage[this.namespace].pushObject(resourceInstance);\n\n return resourceInstance;\n }\n\n serialize(json) {\n return lookup('resource', classify(this.resource), json, this.adapter);\n }\n\n afterFetch(json) {\n return afterFetch(this, json);\n }\n\n create(attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.post(`${this.namespace}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n update(id, attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.put(`${this.namespace}/${id}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findRecord(id, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findAll(options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n query(query = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n queryRecord(query = {}, options = {}) {\n query.single = true;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n destroy(record, options = {}) {\n const id = isResource(record) ? record.getAttribute('id') : record;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.delete(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n}\n\nexport default Store;\n\nexport { extendStoreActions, afterFetch };\n","import Store from './store';\nimport Resource from './resource';\nimport { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter, Adapter } from './adapters';\nimport { isNodeEnvironment, detectAdapter, isLatitude, isLongitude, Point, isResource, GoogleAddress, Collection, StoreActions } from './utils';\nimport { pluralize, singularize, classify, dasherize, camelize } from './utils/string';\nimport { extendStoreActions } from './store';\nimport { orderActions } from './resources/order';\nimport { driverActions } from './resources/driver';\n\n/**\n * // instance\n * const fleetbase = new Fleetbase();\n *\n * const contact = fleetbase.contacts.create({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * constact.update({ name: 'Hollywood Ron' });\n *\n * // export\n * import { Contact } from '@fleetbase/sdk';\n *\n * const contact = new Contact({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * contact.save();\n */\n\nexport default class Fleetbase {\n /**\n * Builds an instance of the Fleetbase SDK\n *\n * @param {String} publicKey The public key issued\n * @param {Object} config The version of resource to access\n * @param {Boolean} debug Debug mode for SDK\n * @return {Fleetbase} Instance\n */\n constructor(publicKey, config = {}, debug = false) {\n this.version = config.version || 'v1';\n this.options = {\n version: this.version,\n host: config.host || 'https://api.fleetbase.io',\n namespace: this.version || config.namespace,\n debug,\n publicKey,\n };\n\n if (typeof publicKey !== 'string' || publicKey.length === 0) {\n throw new Error('⚠️ Invalid public key given to Fleetbase SDK');\n }\n\n if (!isNodeEnvironment() && publicKey.toLowerCase().startsWith('$')) {\n throw new Error('Secret key provided. You must use a public key with Fleetbase Javascript SDK!');\n }\n\n this.adapter = config.adapter || detectAdapter(this.options);\n\n this.orders = new Store('order', this.adapter).extendActions(orderActions);\n this.entities = new Store('entity', this.adapter);\n this.places = new Store('place', this.adapter);\n this.drivers = new Store('driver', this.adapter).extendActions(driverActions);\n this.vehicles = new Store('vehicle', this.adapter);\n this.vendors = new Store('vendor', this.adapter);\n this.contacts = new Store('contact', this.adapter);\n }\n\n static newInstance() {\n return new Fleetbase(...arguments);\n }\n\n setAdapter(adapter) {\n this.adapter = adapter;\n }\n\n getAdapter() {\n return this.adapter;\n }\n}\n\nexport {\n Store,\n Resource,\n Contact,\n Driver,\n Entity,\n Order,\n Payload,\n Place,\n TrackingStatus,\n Vehicle,\n Vendor,\n Waypoint,\n Zone,\n ServiceArea,\n ServiceRate,\n ServiceQuote,\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter,\n Adapter,\n isNodeEnvironment,\n isLatitude,\n isLongitude,\n Point,\n isResource,\n GoogleAddress,\n Collection,\n StoreActions,\n extendStoreActions,\n pluralize,\n singularize,\n classify,\n dasherize,\n camelize,\n};\n","export default function isLatitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 90;\n}\n","export default function isLongitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 180 && Math.abs(coordinate) >= 90;\n}\n"],"names":["isArray","Array","replace","array","start","deleteCount","items","length","splice","i","chunk","slice","isCollection","arr","identityFunction","item","mixed","Collection","objectAt","index","iter","key","value","arguments","Boolean","findIndex","predicate","startAt","len","find","callback","target","bind","undefined","any","every","cb","indexOf","val","withNaNCheck","insertAt","this","indexes","map","idx","_this2","object","methodName","args","ret","forEach","push","_item$methodName","filter","sortKeys","sort","a","b","propA","propB","compareValue","compare","seen","Set","getter","get","has","add","uniqBy","includes","removeAt","obj","objects","toArray","reverse","clear","loc","removeObject","pushObject","_this3","addObject","isEmpty","none","size","objectType","isBlank","test","isResource","record","Resource","isPhone","phone","isNodeEnvironment","process","_typeof","_process","env","release","name","search","window","navigator","product","detectAdapter","options","lookup","GoogleAddress","place","geometry","components","parseComponents","attributes","parseProperties","address_components","reduce","acc","data","types","type","streetNumber","streetName","coordinates","location","Object","values","city","or","county","stateShort","stateLong","countryShort","country","countryLong","postalCode","address","join","keys","pkey","short","short_name","long_name","Point","latitude","longitude","coorindates","lat","lng","serialize","json","getResolved","func","path","resolved","current","isObject","isFunction","pathArray","split","newPath","set","iterations","StoreActions","actions","bindTo","binding","action","fn","adapter","resource","dirtyAttributes","changes","isLoading","isSaving","isDestroying","isReloading","version","setAdapter","store","Store","onAfterFetch","syncAttributes","_this$options","getAttribute","mergeAttributes","setFlags","create","then","response","_this","update","id","destroy","findRecord","_this4","reset","flags","state","validFlags","flag","Error","attribues","getAttributes","onlyDirty","savedirty","dirtyAttributeKeys","isAttributeFilled","Date","hasAttributes","isNew","isLoaded","property","_this5","call","setAttributes","previousValue","changedAt","setAttribute","attribute","defaultValue","properties","attributeKeys","prop","hasAttribute","_this6","_value","_value2","modelAttributes","orderActions","getDistanceAndTime","params","namespace","getNextActivity","dispatch","post","afterFetch","updateActivity","complete","cancel","Order","isStarted","isCanceled","isCompleted","Payload","entity","waypoints","Entity","Place","_this$getAttribute","_this$getAttribute2","owner","googleAddress","street1","street2","province","postal_code","neighborhood","district","building","security_access_code","Waypoint","TrackingStatus","Vehicle","driverActions","login","identity","password","verifyCode","code","retrieve","Driver","token","setHeaders","Vendor","Contact","Zone","ServiceArea","ServiceRate","ServiceQuote","Adapter","config","host","headers","BrowserAdapter","Authorization","publicKey","Promise","resolve","reject","statusText","status","ok","method","fetch","url","mode","Headers","parseJSON","errors","error","query","urlParams","URLSearchParams","toString","request","body","JSON","stringify","NodeAdapter","axios","baseURL","commonHeaders","defaults","common","transform","handleError","put","patch","EmberJsAdapter","String","string","chain","RegExp","str","rules","skip","override","toLowerCase","x","match","plural","applyRules","pluralRules","uncountableWords","singular","singularRules","lowFirstLetter","str_path","str_arr","charAt","toUpperCase","substring","first","last","uppercase","underbarPrefix","idSuffix","underbar","capitalize","spaceOrUnderbar","allFirstUpper","camelize","underscore","d","nonTitlecasedWords","pluralize","singularize","dropIdUbar","demodulize","NaN","parseInt","ltd","ld","suf","argz","instance","shift","invoke","classify","resources","adapters","Resolver","className","extendStoreActions","extend","extendActions","storage","resourceInstance","serialized","deposit","single","_this7","Fleetbase","debug","startsWith","orders","entities","places","drivers","vehicles","vendors","contacts","coordinate","isFinite","Math","abs"],"mappings":"kuJAAA,IAAQA,EAAYC,MAAZD,yDCWFE,EAAU,SAACC,EAAOC,EAAOC,OAAaC,yDAAQ,MAC5CN,EAAQG,MACJG,EAAMC,QANC,IAOPJ,EAAMK,aAANL,GAAaC,EAAOC,YAAgBC,SACjC,CACHH,EAAMK,OAAOJ,EAAOC,OAEf,IAAII,EAAI,EAAGA,EAAIH,EAAMC,OAAQE,GAX3B,IAW4C,KAC3CC,EAAQJ,EAAMK,MAAMF,EAAGA,EAZxB,KAaHN,EAAMK,aAANL,GAAaC,EAAQK,EAAG,YAAMC,WAG/BE,EAAaC,MACpBV,EAAMD,QAAQE,EAAOC,EAAaC,IAIpCQ,EAAmB,SAACC,UAASA,GAkB7BH,EAAe,SAACI,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BC,SAASD,IAAeE,KAAKC,IAAIH,IAAe,KAAOE,KAAKC,IAAIH,IAAe"} \ No newline at end of file diff --git a/dist/esm/fleetbase.js b/dist/esm/fleetbase.js index fb03801..3d9249b 100644 --- a/dist/esm/fleetbase.js +++ b/dist/esm/fleetbase.js @@ -1,2 +1,2 @@ -import t from"axios";function e(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n3&&void 0!==arguments[3]?arguments[3]:[];if(A(t))if(r.length<=6e4)t.splice.apply(t,[e,n].concat(m(r)));else{t.splice(e,n);for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:0,r=t.length,i=n;i2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0,i=t.length;n<0&&(n+=i);var o=r&&e!=e?function(t){return t!=t}:function(t){return t===e};return S(t,o,n)},F=function(t,e,n){return $(t,e,0,[n]),n},D=function(t){h(n,g(Array));var e=y(n);function n(){for(var t=arguments.length,r=new Array(t),i=0;i0}},{key:"empty",get:function(){return 0===this.length}},{key:"first",get:function(){return j(this,0)}},{key:"last",get:function(){return j(this,this.length-1)}},{key:"replace",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return $(this,t,e,n),this}},{key:"objectsAt",value:function(t){var e=this;return t.map((function(t){return j(e,t)}))}},{key:"objectAt",value:function(t){return j(this,t)}},{key:"indexOf",value:function(t,e){return L(this,t,e,!1)}},{key:"lastIndexOf",value:function(t,e){var n=this.length;(void 0===e||e>=n)&&(e=n-1),e<0&&(e+=n);for(var r=e;r>=0;r--)if(j(this,r)===t)return r;return-1}},{key:"includes",value:function(t,e){return-1!==L(this,t,e,!0)}},{key:"findBy",value:function(){return _(this,O.apply(void 0,arguments))}},{key:"findIndexBy",value:function(){return S(this,O.apply(void 0,arguments))}},{key:"isEvery",value:function(){return z(this,O.apply(void 0,arguments))}},{key:"isAny",value:function(){return P(this,O.apply(void 0,arguments))}},{key:"invoke",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:R,n=[],r=new Set,i="function"==typeof e?e:function(t){return get(t,e)};return t.forEach((function(t){var e=i(t);r.has(e)||(r.add(e),n.push(t))})),n}(this,t)}},{key:"without",value:function(t){if(!this.includes(t))return this;var e=t==t?function(e){return e!==t}:function(t){return t==t};return this.filter(e)}},{key:"clear",value:function(){var t=this.length;return 0===t||this.replace(0,t,[]),this}},{key:"insertAt",value:function(t,e){return F(this,t,e),this}},{key:"replaceAt",value:function(t,e){return this.replace(t,1,[e])}},{key:"removeAt",value:function(t,e){return function(t,e){return $(t,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,[]),t}(this,t,e)}},{key:"pushObject",value:function(t){return this.insertAt(this.length,t)}},{key:"pushObjects",value:function(t){return this.replace(this.length,0,t),this}},{key:"popObject",value:function(){var t=this.length;if(0===t)return null;var e=j(this,t-1);return this.removeAt(t-1,1),e}},{key:"shiftObject",value:function(){if(0===this.length)return null;var t=j(this,0);return this.removeAt(0),t}},{key:"unshiftObject",value:function(t){return F(this,0,t)}},{key:"unshiftObjects",value:function(t){return this.replace(0,0,t),this}},{key:"reverseObjects",value:function(){var t=this.length;if(0===t)return this;var e=this.toArray().reverse();return this.replace(0,t,e),this}},{key:"setObjects",value:function(t){if(0===t.length)return this.clear();var e=this.length;return this.replace(0,e,t),this}},{key:"removeObject",value:function(t){for(var e=this.length||0;--e>=0;){j(this,e)===t&&this.removeAt(e)}return this}},{key:"removeObjects",value:function(t){for(var e=t.length-1;e>=0;e--)this.removeObject(t[e]);return this}},{key:"addObject",value:function(t){return this.includes(t)||this.pushObject(t),this}},{key:"addObjects",value:function(t){var e=this;return t.forEach((function(t){return e.addObject(t)})),this}}]),n}(),C=function(t){var e=null==t;if(e)return e;if("number"==typeof t.size)return!t.size;var n=r(t);if("object"===n){var i=t.size;if("number"==typeof i)return!i}if("number"==typeof t.length&&"function"!==n)return!t.length;if("object"===n){var o=t.length;if("number"==typeof o)return!o}return!1},T=function(t){return C(t)||"string"==typeof t&&!1===/\S/.test(t)};function N(t){return isFinite(t)&&Math.abs(t)<=90}function q(t){return isFinite(t)&&Math.abs(t)<=180&&Math.abs(t)>=90}function B(t){return t instanceof Y}var U=function(){var t,e,n,i,o;return!("undefined"==typeof process||"object"!==r(null===(t=process)||void 0===t?void 0:t.env)&&-1===(null===(e=process.release)||void 0===e||null===(n=e.name)||void 0===n?void 0:n.search(/node|io.js/))||"undefined"!=typeof window&&"ReactNative"!==(null===(i=window)||void 0===i||null===(o=i.navigator)||void 0===o?void 0:o.product))},I=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return U()?Rt("adapter","NodeAdapter",t):Rt("adapter","BrowserAdapter",t)},J=Array.isArray,K=function(){function t(e){s(this,t),this.place=e,this.geometry=null==e?void 0:e.geometry,this.components=this.parseComponents(),this.attributes=this.parseProperties()}return a(t,[{key:"parse",value:function(){this.parseComponents(),this.parseProperties()}},{key:"parseComponents",value:function(){var t;return((null===(t=this.place)||void 0===t?void 0:t.address_components)||[]).reduce((function(t,e){return e.types.forEach((function(n){t[n]=e})),t}),{})}},{key:"parseProperties",value:function(){var t,e={streetNumber:this.get("street_number"),streetName:this.get("route"),coordinates:null!==(t=this.geometry)&&void 0!==t&&t.location?Object.values(this.geometry.location):[0,0],city:this.or(["locality","sublocality","sublocality_level_1","neighborhood","administrative_area_level_3","administrative_area_level_2"]),county:this.get("administrative_area_level_2"),stateShort:this.get("administrative_area_level_1",!0),stateLong:this.get("administrative_area_level_1"),countryShort:this.get("country",!0),country:this.get("country",!0),countryLong:this.get("country"),postalCode:this.get("postal_code")};return e.address=[e.streetNumber,e.streetName].filter(Boolean).join(" "),e}},{key:"all",value:function(){return this.attributes}},{key:"or",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e1&&void 0!==arguments[1]&&arguments[1];return t in this.components?e?this.components[t].short_name:this.components[t].long_name:null}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.attributes=n(n({},this.attributes),t),this}},{key:"setAttribute",value:function(t,e){return this.attributes[t]=e,this}},{key:"getAttribute",value:function(t){return this.attributes[t]||null}}]),t}(),M=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;s(this,t),this.type="Point",this.coordinates=[n,e]}return a(t,[{key:"latitude",get:function(){return this.coordinates[1]}},{key:"longitude",get:function(){return this.coordinates[0]}},{key:"lat",value:function(){return this.latitude}},{key:"lng",value:function(){return this.longitude}},{key:"serialize",value:function(){return{type:"Point",coorindates:[this.lat(),this.lng()]}}},{key:"toJson",value:function(){return this.serialize()}},{key:"toString",value:function(){return"(".concat(this.latitude,", ").concat(this.longitude,")")}}],[{key:"fromGeoJson",value:function(e){var n=b(e.coordinates,2);return longitude=n[0],latitude=n[1],new t(latitude,longitude)}}]),t}();"undefined"==typeof arguments||arguments;var W=function(t,e){var n=t();return Array.isArray(n)||"object"===r(n)?H(n,e):null},H=function t(e,n){var i,o=e,s=r(e),u="object"===s,a="function"===s,c=Array.isArray(e),h="string"===r(n)&&n.includes(".")?n.split("."):[n];if(c||u){for(var l=0;l0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;s(this,t),this.actions=e,this.bind=n}return a(t,[{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=t||this.bind;if(!e)return this;if(null!=this&&this.actions&&"object"===r(this.actions))for(var n in this.actions){var i=this.actions[n];"function"==typeof i?G(e,n,i.bind(e)):G(e,n,i)}return this}}]),t}(),Y=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};s(this,t),this.attributes=e,this.dirtyAttributes={},this.changes={},this.isLoading=!1,this.isSaving=!1,this.isDestroying=!1,this.isReloading=!1,this.resource=r,this.options=i,this.version=i.version||"v1",this.setAdapter(n)}return a(t,[{key:"setAdapter",value:function(t){var e;return this.adapter=t,this.store=new jt(this.resource,t,{onAfterFetch:this.syncAttributes.bind(this),actions:null===(e=this.options)||void 0===e?void 0:e.actions}),this}},{key:"id",get:function(){return this.getAttribute("id")}},{key:"create",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.mergeAttributes(e);return this.setFlags(["isLoading","isSaving"]),this.store.create(n).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.setFlags(["isLoading","isSaving"]),this.store.update(this.attributes.id,e).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"destroy",value:function(){var t=this;return this.setFlags(["isLoading","isDestroying"]),this.store.destroy(this.attributes.id).then((function(e){return t.setFlags(["isLoading","isDestroying"],!1),e}))}},{key:"reload",value:function(){var t=this;return this.setFlags(["isLoading","isReloading"]),this.store.findRecord(this.attributes.id).then((function(e){return t.reset(),e}))}},{key:"setFlags",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=["isLoading","isSaving","isReloading","isDestroying"],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},e=this.getAttributes();return C(this.id)?this.create(e):!0===t.onlyDirty?this.savedirty():this.update(e)}},{key:"saveDirty",value:function(){for(var t=Object.keys(this.dirtyAttributes),e={},n=0;n0}},{key:"mutate",value:function(t,e){this.attributes[t]=e}},{key:"setAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===n&&"object"===r(t))return this.setAttributes(t);var i=null!==(e=null==this?void 0:this.attributes[t])&&void 0!==e?e:null;return G(this.attributes,t,n),G(this.dirtyAttributes,t,i),A(null==this?void 0:this.changes[t])||(this.changes[t]=[]),this.changes[t].push({property:t,previousValue:i,value:n,changedAt:new Date}),this}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)this.setAttribute(e,t[e]);return this}},{key:"getAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=H(null!==(e=null==this?void 0:this.attributes)&&void 0!==e?e:{},t);return void 0===r?n:r}},{key:"hasAttribute",value:function(t){if(A(t)){var e,n=t,r=Object.keys(null!==(e=this.attributes)&&void 0!==e?e:{});return n.every((function(t){return r.includes(t)}))}return!(null==this||!this.attributes)&&t in this.attributes}},{key:"hasAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.hasAttribute(t)}},{key:"isAttributeFilled",value:function(t){var e=this;return A(t)?this.hasAttribute(t)&&t.every((function(t){return!C(e.getAttribute(t))})):this.hasAttribute(t)&&!C(this.getAttribute(t))}},{key:"getAttributes",value:function(t){var e={};if(null==t)return this.getAttributes(Object.keys(this.attributes));if("string"==typeof t)return this.getAttribute(Array.prototype.slice.call(arguments));if(!A(t))throw new Error("No attribute properties provided!");for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},r=null!==(t=null==this?void 0:this.attributes)&&void 0!==t?t:{};return this.attributes=n(n({},r),e),this.attributes}},{key:"syncAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attributes=t}}]),t}(),Z=new V({getDistanceAndTime:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.adapter.get("".concat(this.namespace,"/").concat(t,"/distance-and-time"),{},e)}}),Q=function(t){h(r,Y);var e=y(r);function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,r),e.call(this,t,i,"order",n({actions:Z},o))}return a(r,[{key:"getDistanceAndTime",value:function(){return this.store.getDistanceAndTime(this.id)}}]),r}(),X=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"payload",i)}return a(n,[{key:"attach",value:function(t){}},{key:"entities",get:function(){}},{key:"dropoff",get:function(){}},{key:"pickup",get:function(){}},{key:"waypoints",get:function(){return new D(this.waypoints)}}]),n}(),tt=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"entity",i)}return n}(),et=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"place",i)}return a(n,[{key:"latitude",get:function(){var t;return null===(t=this.getAttribute("location",new M))||void 0===t?void 0:t.coordinates[1]}},{key:"longitude",get:function(){var t;return null===(t=this.getAttribute("location",new M))||void 0===t?void 0:t.coordinates[0]}},{key:"coordinates",get:function(){return[this.latitude,this.longitude]}},{key:"setOwner",value:function(t){return B(t)&&this.setAttribute("owner",t.id),"string"==typeof t&&this.setAttribute("owner",t),this}}],[{key:"fromGoogleAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.getAttribute("coordinates"),o=b(i,2),s=o[0],u=o[1],a={name:null,address:t.getAttribute("address"),location:new M(s,u),street1:t.getAttribute("streetName"),street2:null,city:t.getAttribute("city"),province:t.getAttribute("stateLong"),postal_code:t.getAttribute("postalCode"),neighborhood:t.get("neighborhood"),district:t.getAttribute("county"),building:t.get("building"),country:t.getAttribute("countryShort"),phone:null,security_access_code:null};return new n(a,e,r)}}]),n}(),nt=function(t){h(n,et);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"waypoint",i)}return n}(),rt=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"tracking-status",i)}return n}(),it=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"vehicle",i)}return n}(),ot=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"driver",i)}return n}(),st=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"vendor",i)}return n}(),ut=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"contact",i)}return n}(),at=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"zone",i)}return n}(),ct=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"service-area",i)}return n}(),ht=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"service-rate",i)}return n}(),lt=function(t){h(n,Y);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s(this,n),e.call(this,t,r,"service-quote",i)}return a(n,[{key:"fromPreliminary",value:function(){}},{key:"fromPayload",value:function(){}}]),n}(),vt=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s(this,t),this.version=e.version||"v1",this.host=e.host||null,this.namespace=e.namespace||null,this.headers=e.headers||{}},ft=function(t){h(r,vt);var e=y(r);function r(t){var n;return s(this,r),(n=e.call(this,t)).setHeaders({Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;browser"}),n}return a(r,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.headers=n(n({},this.headers),t),this}},{key:"parseJSON",value:function(t){return new Promise((function(e,n){return t.json().then((function(n){return e({statusText:t.statusText,status:t.status,ok:t.ok,json:n})})).catch((function(){n(new Error("Oops! Something went wrong when handling your request."))}))}))}},{key:"request",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise((function(s,u){return fetch(o.url||"".concat(e.host,"/").concat(e.namespace,"/").concat(t),n({method:r,mode:o.mode||"cors",headers:new Headers(n(n({},e.headers||{}),o.headers||{}))},i)).then(e.parseJSON).then((function(t){return t.ok?s(t.json):u(new Error(t.json.errors?t.json.errors[0]:t.statusText))})).catch((function(t){u(t)}))}))}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=T(e)?"":new URLSearchParams(e).toString();return this.request("".concat(t).concat(r?"?".concat(r):""),"GET",{},n)}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"POST",{body:JSON.stringify(e)},n)}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PUT",{body:JSON.stringify(e)},n)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.request(t,"DELETE",{},e)}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PATCH",{body:JSON.stringify(e)},n)}}]),r}(),dt=function(e){h(i,vt);var r=y(i);function i(e){var n;return s(this,i),(n=r.call(this,e)).axios=t.create({baseURL:"".concat(n.host,"/").concat(n.namespace),headers:{Authorization:"Bearer ".concat(e.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;node"}}),n}return a(i,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.axios.defaults.headers.common;return this.axios.defaults.headers.common=n(n({},e),t),this}},{key:"transform",value:function(t){return t.data}},{key:"handleError",value:function(t){if(t.response){var e=t.response.data;if(A(e.errors))throw new Error(e.errors[0]);if(e.error)throw new Error(e.error)}throw t}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=T(e)?"":new URLSearchParams(e).toString();return this.axios.get("".concat(t).concat(r?"?".concat(r):""),n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.post(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.put(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.axios.delete(t,e).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.patch(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}}]),i}(),gt=function(t){h(n,vt);var e=y(n);function n(){return s(this,n),e.apply(this,arguments)}return n}(),pt=function(){function t(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];s(this,t),c(this,"uncountableWords",["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"]),c(this,"pluralRules",[[new RegExp("(m)an$","gi"),"$1en"],[new RegExp("(pe)rson$","gi"),"$1ople"],[new RegExp("(child)$","gi"),"$1ren"],[new RegExp("^(ox)$","gi"),"$1en"],[new RegExp("(ax|test)is$","gi"),"$1es"],[new RegExp("(octop|vir)us$","gi"),"$1i"],[new RegExp("(alias|status)$","gi"),"$1es"],[new RegExp("(bu)s$","gi"),"$1ses"],[new RegExp("(buffal|tomat|potat)o$","gi"),"$1oes"],[new RegExp("([ti])um$","gi"),"$1a"],[new RegExp("sis$","gi"),"ses"],[new RegExp("(?:([^f])fe|([lr])f)$","gi"),"$1$2ves"],[new RegExp("(hive)$","gi"),"$1s"],[new RegExp("([^aeiouy]|qu)y$","gi"),"$1ies"],[new RegExp("(x|ch|ss|sh)$","gi"),"$1es"],[new RegExp("(matr|vert|ind)ix|ex$","gi"),"$1ices"],[new RegExp("([m|l])ouse$","gi"),"$1ice"],[new RegExp("(quiz)$","gi"),"$1zes"],[new RegExp("s$","gi"),"s"],[new RegExp("$","gi"),"s"]]),c(this,"singularRules",[[new RegExp("(m)en$","gi"),"$1an"],[new RegExp("(pe)ople$","gi"),"$1rson"],[new RegExp("(child)ren$","gi"),"$1"],[new RegExp("([ti])a$","gi"),"$1um"],[new RegExp("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$","gi"),"$1$2sis"],[new RegExp("(hive)s$","gi"),"$1"],[new RegExp("(tive)s$","gi"),"$1"],[new RegExp("(curve)s$","gi"),"$1"],[new RegExp("([lr])ves$","gi"),"$1f"],[new RegExp("([^fo])ves$","gi"),"$1fe"],[new RegExp("([^aeiouy]|qu)ies$","gi"),"$1y"],[new RegExp("(s)eries$","gi"),"$1eries"],[new RegExp("(m)ovies$","gi"),"$1ovie"],[new RegExp("(x|ch|ss|sh)es$","gi"),"$1"],[new RegExp("([m|l])ice$","gi"),"$1ouse"],[new RegExp("(bus)es$","gi"),"$1"],[new RegExp("(o)es$","gi"),"$1"],[new RegExp("(shoe)s$","gi"),"$1"],[new RegExp("(cris|ax|test)es$","gi"),"$1is"],[new RegExp("(octop|vir)i$","gi"),"$1us"],[new RegExp("(alias|status)es$","gi"),"$1"],[new RegExp("^(ox)en","gi"),"$1"],[new RegExp("(vert|ind)ices$","gi"),"$1ex"],[new RegExp("(matr)ices$","gi"),"$1ix"],[new RegExp("(quiz)zes$","gi"),"$1"],[new RegExp("s$","gi"),""]]),c(this,"nonTitlecasedWords",["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"]),c(this,"idSuffix",new RegExp("(_ids|_id)$","g")),c(this,"underbar",new RegExp("_","g")),c(this,"spaceOrUnderbar",new RegExp("[ _]","g")),c(this,"uppercase",new RegExp("([A-Z])","g")),c(this,"underbarPrefix",new RegExp("^_")),this.str=e,this.chain=n}return a(t,[{key:"get",value:function(){return this.str}},{key:"applyRules",value:function(t,e,n,r){if(r)t=r;else if(!(n.indexOf(t.toLowerCase())>-1))for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:null;return t=t||this.str,this.applyRules(t,this.pluralRules,this.uncountableWords,e)}},{key:"singularize",value:function(t,e){return t=t||this.str,this.applyRules(t,this.singularRules,this.uncountableWords,e)}},{key:"camelize",value:function(t,e){for(var n=(t=t||this.str).split("/"),r=0;r1&&void 0!==arguments[1]&&arguments[1];return t=t||this.str,t=this.underscore(this.demodulize(t))+(e?"":"_")+"id",this.str=t,!0===this.chain?this:t}},{key:"ordinalize",value:function(t){for(var e=(t=t||this.str).split(" "),n=0;n1&&void 0!==arguments[1]?arguments[1]:[];if(t.actions=A(e)?e:[e],!A(e))return e instanceof V&&e.extend(t),t;for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};s(this,t),this.resource=e,this.adapter=n||I(),this.namespace=yt(e),this.storage=new D,this.options=r,this.extendActions(r.actions)}return a(t,[{key:"extendActions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return Et(this,t)}},{key:"deposit",value:function(t){return t}},{key:"serialize",value:function(t){return Rt("resource",wt(this.resource),t,this.adapter)}},{key:"afterFetch",value:function(t){return function(t,e){if("function"==typeof t.options.onAfterFetch&&t.options.onAfterFetch(e),A(e)){for(var n=[],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=o(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.post("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"update",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(function(){var i=o(regeneratorRuntime.mark((function i(o,s){var u;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,e.adapter.put("".concat(e.namespace,"/").concat(t),n,r).then(e.afterFetch.bind(e)).catch(s);case 2:u=i.sent,o(u);case 4:case"end":return i.stop()}}),i)})));return function(t,e){return i.apply(this,arguments)}}())}},{key:"findRecord",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=o(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e.adapter.get("".concat(e.namespace,"/").concat(t),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"findAll",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var n=o(regeneratorRuntime.mark((function n(r,i){var o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.adapter.get("".concat(t.namespace),{},e).then(t.afterFetch.bind(t)).catch(i);case 2:o=n.sent,r(o);case 4:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"query",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=o(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"queryRecord",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.single=!0,new Promise(function(){var r=o(regeneratorRuntime.mark((function r(i,o){var s;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(o);case 2:s=r.sent,i(s);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"destroy",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=B(t)?t.getAttribute("id"):t;return new Promise(function(){var t=o(regeneratorRuntime.mark((function t(i,o){var s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.adapter.delete("".concat(e.namespace,"/").concat(r),{},n).then(e.afterFetch.bind(e)).catch(o);case 2:s=t.sent,i(s);case 4:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}}]),t}(),Ot=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(s(this,t),this.version=n.version||"v1",this.options={version:this.version,host:n.host||"https://api.fleetbase.io",namespace:this.version||n.namespace,debug:r,publicKey:e},"string"!=typeof e||0===e.length)throw new Error("⚠️ Invalid public key given to Fleetbase SDK");if(!U()&&e.toLowerCase().startsWith("$"))throw new Error("Secret key provided. You must use a public key with Fleetbase Javascript SDK!");this.adapter=n.adapter||I(this.options),this.orders=new jt("order",this.adapter).extendActions(Z),this.entities=new jt("entity",this.adapter),this.places=new jt("place",this.adapter),this.drivers=new jt("driver",this.adapter),this.vehicles=new jt("vehicle",this.adapter),this.vendors=new jt("vendor",this.adapter),this.contacts=new jt("contact",this.adapter)}return a(t,[{key:"setAdapter",value:function(t){this.adapter=t}},{key:"getAdapter",value:function(){return this.adapter}}],[{key:"newInstance",value:function(){return d(t,Array.prototype.slice.call(arguments))}}]),t}();export default Ot;export{vt as Adapter,ft as BrowserAdapter,D as Collection,ut as Contact,ot as Driver,gt as EmberJsAdapter,tt as Entity,K as GoogleAddress,dt as NodeAdapter,Q as Order,X as Payload,et as Place,M as Point,Y as Resource,ct as ServiceArea,lt as ServiceQuote,ht as ServiceRate,jt as Store,V as StoreActions,rt as TrackingStatus,it as Vehicle,st as Vendor,nt as Waypoint,at as Zone,mt as camelize,wt as classify,kt as dasherize,Et as extendStoreActions,N as isLatitude,q as isLongitude,U as isNodeEnvironment,B as isResource,yt as pluralize,bt as singularize}; +import t from"axios";import"date-fns";function e(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n3&&void 0!==arguments[3]?arguments[3]:[];if(A(t))if(r.length<=6e4)t.splice.apply(t,[e,n].concat(k(r)));else{t.splice(e,n);for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:0,r=t.length,i=n;i2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0,i=t.length;n<0&&(n+=i);var s=r&&e!=e?function(t){return t!=t}:function(t){return t===e};return _(t,s,n)},D=function(t,e,n){return $(t,e,0,[n]),n},L=function(t){h(n,g(Array));var e=y(n);function n(){for(var t=arguments.length,r=new Array(t),i=0;i0}},{key:"empty",get:function(){return 0===this.length}},{key:"first",get:function(){return j(this,0)}},{key:"last",get:function(){return j(this,this.length-1)}},{key:"replace",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return $(this,t,e,n),this}},{key:"objectsAt",value:function(t){var e=this;return t.map((function(t){return j(e,t)}))}},{key:"objectAt",value:function(t){return j(this,t)}},{key:"indexOf",value:function(t,e){return z(this,t,e,!1)}},{key:"lastIndexOf",value:function(t,e){var n=this.length;(void 0===e||e>=n)&&(e=n-1),e<0&&(e+=n);for(var r=e;r>=0;r--)if(j(this,r)===t)return r;return-1}},{key:"includes",value:function(t,e){return-1!==z(this,t,e,!0)}},{key:"findBy",value:function(){return S(this,O.apply(void 0,arguments))}},{key:"findIndexBy",value:function(){return _(this,O.apply(void 0,arguments))}},{key:"isEvery",value:function(){return F(this,O.apply(void 0,arguments))}},{key:"isAny",value:function(){return P(this,O.apply(void 0,arguments))}},{key:"invoke",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:R,n=[],r=new Set,i="function"==typeof e?e:function(t){return get(t,e)};return t.forEach((function(t){var e=i(t);r.has(e)||(r.add(e),n.push(t))})),n}(this,t)}},{key:"without",value:function(t){if(!this.includes(t))return this;var e=t==t?function(e){return e!==t}:function(t){return t==t};return this.filter(e)}},{key:"clear",value:function(){var t=this.length;return 0===t||this.replace(0,t,[]),this}},{key:"insertAt",value:function(t,e){return D(this,t,e),this}},{key:"replaceAt",value:function(t,e){return this.replace(t,1,[e])}},{key:"removeAt",value:function(t,e){return function(t,e){return $(t,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,[]),t}(this,t,e)}},{key:"pushObject",value:function(t){return this.insertAt(this.length,t)}},{key:"pushObjects",value:function(t){return this.replace(this.length,0,t),this}},{key:"popObject",value:function(){var t=this.length;if(0===t)return null;var e=j(this,t-1);return this.removeAt(t-1,1),e}},{key:"shiftObject",value:function(){if(0===this.length)return null;var t=j(this,0);return this.removeAt(0),t}},{key:"unshiftObject",value:function(t){return D(this,0,t)}},{key:"unshiftObjects",value:function(t){return this.replace(0,0,t),this}},{key:"reverseObjects",value:function(){var t=this.length;if(0===t)return this;var e=this.toArray().reverse();return this.replace(0,t,e),this}},{key:"setObjects",value:function(t){if(0===t.length)return this.clear();var e=this.length;return this.replace(0,e,t),this}},{key:"removeObject",value:function(t){for(var e=this.length||0;--e>=0;){j(this,e)===t&&this.removeAt(e)}return this}},{key:"removeObjects",value:function(t){for(var e=t.length-1;e>=0;e--)this.removeObject(t[e]);return this}},{key:"addObject",value:function(t){return this.includes(t)||this.pushObject(t),this}},{key:"addObjects",value:function(t){var e=this;return t.forEach((function(t){return e.addObject(t)})),this}}]),n}(),C=function(t){var e=null==t;if(e)return e;if("number"==typeof t.size)return!t.size;var n=r(t);if("object"===n){var i=t.size;if("number"==typeof i)return!i}if("number"==typeof t.length&&"function"!==n)return!t.length;if("object"===n){var s=t.length;if("number"==typeof s)return!s}return!1},N=function(t){return C(t)||"string"==typeof t&&!1===/\S/.test(t)};function T(t){return isFinite(t)&&Math.abs(t)<=90}function q(t){return isFinite(t)&&Math.abs(t)<=180&&Math.abs(t)>=90}function B(t){return t instanceof Q}var U=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^[+]?[\s./0-9]*[(]?[0-9]{1,4}[)]?[-\s./0-9]*$/g.test(t)},I=function(){var t,e,n,i,s;return!("undefined"==typeof process||"object"!==r(null===(t=process)||void 0===t?void 0:t.env)&&-1===(null===(e=process.release)||void 0===e||null===(n=e.name)||void 0===n?void 0:n.search(/node|io.js/))||"undefined"!=typeof window&&"ReactNative"!==(null===(i=window)||void 0===i||null===(s=i.navigator)||void 0===s?void 0:s.product))},J=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return I()?jt("adapter","NodeAdapter",t):jt("adapter","BrowserAdapter",t)},W=Array.isArray,H=function(){function t(e){o(this,t),this.place=e,this.geometry=null==e?void 0:e.geometry,this.components=this.parseComponents(),this.attributes=this.parseProperties()}return a(t,[{key:"parse",value:function(){this.parseComponents(),this.parseProperties()}},{key:"parseComponents",value:function(){var t;return((null===(t=this.place)||void 0===t?void 0:t.address_components)||[]).reduce((function(t,e){return e.types.forEach((function(n){t[n]=e})),t}),{})}},{key:"parseProperties",value:function(){var t,e={streetNumber:this.get("street_number"),streetName:this.get("route"),coordinates:null!==(t=this.geometry)&&void 0!==t&&t.location?Object.values(this.geometry.location):[0,0],city:this.or(["locality","sublocality","sublocality_level_1","neighborhood","administrative_area_level_3","administrative_area_level_2"]),county:this.get("administrative_area_level_2"),stateShort:this.get("administrative_area_level_1",!0),stateLong:this.get("administrative_area_level_1"),countryShort:this.get("country",!0),country:this.get("country",!0),countryLong:this.get("country"),postalCode:this.get("postal_code")};return e.address=[e.streetNumber,e.streetName].filter(Boolean).join(" "),e}},{key:"all",value:function(){return this.attributes}},{key:"or",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e1&&void 0!==arguments[1]&&arguments[1];return t in this.components?e?this.components[t].short_name:this.components[t].long_name:null}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.attributes=n(n({},this.attributes),t),this}},{key:"setAttribute",value:function(t,e){return this.attributes[t]=e,this}},{key:"getAttribute",value:function(t){return this.attributes[t]||null}}]),t}(),K=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;o(this,t),this.type="Point",this.coordinates=[n,e]}return a(t,[{key:"latitude",get:function(){return this.coordinates[1]}},{key:"longitude",get:function(){return this.coordinates[0]}},{key:"lat",value:function(){return this.latitude}},{key:"lng",value:function(){return this.longitude}},{key:"serialize",value:function(){return{type:"Point",coorindates:[this.lat(),this.lng()]}}},{key:"toJson",value:function(){return this.serialize()}},{key:"toString",value:function(){return"(".concat(this.latitude,", ").concat(this.longitude,")")}}],[{key:"fromGeoJson",value:function(e){var n=b(e.coordinates,2);return longitude=n[0],latitude=n[1],new t(latitude,longitude)}}]),t}();"undefined"==typeof arguments||arguments;var M=function(t,e){var n=t();return Array.isArray(n)||"object"===r(n)?G(n,e):null},G=function t(e,n){var i,s=e,o=r(e),u="object"===o,a="function"===o,c=Array.isArray(e),h="string"===r(n)&&n.includes(".")?n.split("."):[n];if(c||u){for(var l=0;l0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;o(this,t),this.actions=e,this.bind=n}return a(t,[{key:"extend",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=t||this.bind;if(!e)return this;if(null!=this&&this.actions&&"object"===r(this.actions))for(var n in this.actions){var i=this.actions[n];"function"==typeof i?V(e,n,i.bind(e)):V(e,n,i)}return this}}]),t}(),Q=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};o(this,t),this.attributes=e,this.dirtyAttributes={},this.changes={},this.isLoading=!1,this.isSaving=!1,this.isDestroying=!1,this.isReloading=!1,this.resource=r,this.options=i,this.version=i.version||"v1",this.setAdapter(n)}return a(t,[{key:"setAdapter",value:function(t){var e;return this.adapter=t,this.store=new _t(this.resource,t,{onAfterFetch:this.syncAttributes.bind(this),actions:null===(e=this.options)||void 0===e?void 0:e.actions}),this}},{key:"id",get:function(){return this.getAttribute("id")}},{key:"create",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=this.mergeAttributes(e);return this.setFlags(["isLoading","isSaving"]),this.store.create(n).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.setFlags(["isLoading","isSaving"]),this.store.update(this.attributes.id,e).then((function(e){return t.setFlags(["isLoading","isSaving"],!1),e}))}},{key:"destroy",value:function(){var t=this;return this.setFlags(["isLoading","isDestroying"]),this.store.destroy(this.attributes.id).then((function(e){return t.setFlags(["isLoading","isDestroying"],!1),e}))}},{key:"reload",value:function(){var t=this;return this.setFlags(["isLoading","isReloading"]),this.store.findRecord(this.attributes.id).then((function(e){return t.reset(),e}))}},{key:"setFlags",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=["isLoading","isSaving","isReloading","isDestroying"],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},e=this.getAttributes();return C(this.id)?this.create(e):!0===t.onlyDirty?this.savedirty():this.update(e)}},{key:"saveDirty",value:function(){for(var t=Object.keys(this.dirtyAttributes),e={},n=0;n0}},{key:"mutate",value:function(t,e){this.attributes[t]=e}},{key:"setAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===n&&"object"===r(t))return this.setAttributes(t);var i=null!==(e=null==this?void 0:this.attributes[t])&&void 0!==e?e:null;return V(this.attributes,t,n),V(this.dirtyAttributes,t,i),A(null==this?void 0:this.changes[t])||(this.changes[t]=[]),this.changes[t].push({property:t,previousValue:i,value:n,changedAt:new Date}),this}},{key:"setAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)this.setAttribute(e,t[e]);return this}},{key:"getAttribute",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=G(null!==(e=null==this?void 0:this.attributes)&&void 0!==e?e:{},t);return void 0===r?n:r}},{key:"hasAttribute",value:function(t){if(A(t)){var e,n=t,r=Object.keys(null!==(e=this.attributes)&&void 0!==e?e:{});return n.every((function(t){return r.includes(t)}))}return!(null==this||!this.attributes)&&t in this.attributes}},{key:"hasAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.hasAttribute(t)}},{key:"isAttributeFilled",value:function(t){var e=this;return A(t)?this.hasAttribute(t)&&t.every((function(t){return!C(e.getAttribute(t))})):this.hasAttribute(t)&&!C(this.getAttribute(t))}},{key:"getAttributes",value:function(t){var e={};if(null==t)return this.getAttributes(Object.keys(this.attributes));if("string"==typeof t)return this.getAttribute(Array.prototype.slice.call(arguments));if(!A(t))throw new Error("No attribute properties provided!");for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},r=null!==(t=null==this?void 0:this.attributes)&&void 0!==t?t:{};return this.attributes=n(n({},r),e),this.attributes}},{key:"syncAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.attributes=t}}]),t}(),Y=new Z({getDistanceAndTime:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.get("".concat(this.namespace,"/").concat(t,"/distance-and-time"),e,n)},getNextActivity:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.get("".concat(this.namespace,"/").concat(t,"/next-activity"),e,n)},dispatch:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/dispatch"),e,n).then(this.afterFetch.bind(this))},start:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/start"),e,n).then(this.afterFetch.bind(this))},updateActivity:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/update-activity"),e,n).then(this.afterFetch.bind(this))},complete:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("".concat(this.namespace,"/").concat(t,"/complete"),e,n).then(this.afterFetch.bind(this))},cancel:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.delete("".concat(this.namespace,"/").concat(t,"/cancel"),e,n).then(this.afterFetch.bind(this))}}),X=function(t){h(r,Q);var e=y(r);function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,r),e.call(this,t,i,"order",n({actions:Y},s))}return a(r,[{key:"getDistanceAndTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.getDistanceAndTime(this.id,t,e)}},{key:"dispatch",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.dispatch(this.id,t,e)}},{key:"start",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.start(this.id,t,e)}},{key:"getNextActivity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.getNextActivity(this.id,t,e)}},{key:"updateActivity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.updateActivity(this.id,t,e)}},{key:"cancel",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.cancel(this.id,t,e)}},{key:"complete",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.store.complete(this.id,t,e)}},{key:"isDispatched",get:function(){return null!==this.getAttribute("dispatched_at")}},{key:"isNotDispatched",get:function(){return null==this.getAttribute("dispatched_at")}},{key:"isStarted",get:function(){return null!==this.getAttribute("started_at")}},{key:"isNotStarted",get:function(){return null==this.getAttribute("started_at")}},{key:"isCompleted",get:function(){return"completed"==this.getAttribute("status")}},{key:"isCanceled",get:function(){return"canceled"==this.getAttribute("status")}},{key:"isEnroute",get:function(){return"driver_enroute"==this.getAttribute("status")||"enroute"===this.getAttribute("status")}},{key:"isInProgress",get:function(){return this.isStarted&&!this.isCanceled&&!this.isCompleted}},{key:"scheduledAt",get:function(){return this.isAttributeFilled("scheduled_at")?new Date(this.getAttribute("scheduled_at")):null}},{key:"startedAt",get:function(){return this.isAttributeFilled("started_at")?new Date(this.getAttribute("started_at")):null}},{key:"dispatchedAt",get:function(){return this.isAttributeFilled("dispatched_at")?new Date(this.getAttribute("dispatched_at")):null}},{key:"status",get:function(){return this.getAttribute("status")}}]),r}(),tt=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"payload",i)}return a(n,[{key:"attach",value:function(t){}},{key:"entities",get:function(){}},{key:"dropoff",get:function(){}},{key:"pickup",get:function(){}},{key:"waypoints",get:function(){return new L(this.waypoints)}}]),n}(),et=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"entity",i)}return n}(),nt=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"place",i)}return a(n,[{key:"latitude",get:function(){var t;return null===(t=this.getAttribute("location",new K))||void 0===t?void 0:t.coordinates[1]}},{key:"longitude",get:function(){var t;return null===(t=this.getAttribute("location",new K))||void 0===t?void 0:t.coordinates[0]}},{key:"coordinates",get:function(){return[this.latitude,this.longitude]}},{key:"setOwner",value:function(t){return B(t)&&this.setAttribute("owner",t.id),"string"==typeof t&&this.setAttribute("owner",t),this}}],[{key:"fromGoogleAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.getAttribute("coordinates"),s=b(i,2),o=s[0],u=s[1],a={name:null,address:t.getAttribute("address"),location:new K(o,u),street1:t.getAttribute("streetName"),street2:null,city:t.getAttribute("city"),province:t.getAttribute("stateLong"),postal_code:t.getAttribute("postalCode"),neighborhood:t.get("neighborhood"),district:t.getAttribute("county"),building:t.get("building"),country:t.getAttribute("countryShort"),phone:null,security_access_code:null};return new n(a,e,r)}}]),n}(),rt=function(t){h(n,nt);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"waypoint",i)}return n}(),it=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"tracking-status",i)}return n}(),st=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"vehicle",i)}return n}(),ot=new Z({login:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(U(t))return this.adapter.post("drivers/login-with-sms",{phone:t});if(!e)throw new Error("Login requires password!");return this.adapter.post("drivers/login",n({identity:t,password:e},r)).then(this.afterFetch.bind(this))},verifyCode:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.adapter.post("drivers/verify-code",n({identity:t,code:e},r)).then(this.afterFetch.bind(this))},retrieve:function(t){return this.findRecord(t)}}),ut=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"driver",i)}return a(n,[{key:"token",get:function(){return this.getAttribute("token")}},{key:"isOnline",get:function(){return!0===this.getAttribute("online")}},{key:"syncDevice",value:function(t){var e=this;return this.adapter.setHeaders({"Driver-Token":this.token}).post("drivers/register-device",t).then((function(){return e}))}}]),n}(),at=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"vendor",i)}return n}(),ct=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"contact",i)}return n}(),ht=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"zone",i)}return n}(),lt=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"service-area",i)}return n}(),vt=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"service-rate",i)}return n}(),ft=function(t){h(n,Q);var e=y(n);function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o(this,n),e.call(this,t,r,"service-quote",i)}return a(n,[{key:"fromPreliminary",value:function(){}},{key:"fromPayload",value:function(){}}]),n}(),dt=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.version=e.version||"v1",this.host=e.host||null,this.namespace=e.namespace||null,this.headers=e.headers||{}},gt=function(t){h(r,dt);var e=y(r);function r(t){var n;return o(this,r),(n=e.call(this,t)).setHeaders({Authorization:"Bearer ".concat(t.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;browser"}),n}return a(r,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.headers=n(n({},this.headers),t),this}},{key:"parseJSON",value:function(t){return new Promise((function(e,n){return t.json().then((function(n){return e({statusText:t.statusText,status:t.status,ok:t.ok,json:n})})).catch((function(){n(new Error("Oops! Something went wrong when handling your request."))}))}))}},{key:"request",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise((function(o,u){return fetch(s.url||"".concat(e.host,"/").concat(e.namespace,"/").concat(t),n({method:r,mode:s.mode||"cors",headers:new Headers(n(n({},e.headers||{}),s.headers||{}))},i)).then(e.parseJSON).then((function(t){return t.ok?o(t.json):u(new Error(t.json.errors?t.json.errors[0]:t.statusText))})).catch((function(t){u(t)}))}))}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=N(e)?"":new URLSearchParams(e).toString();return this.request("".concat(t).concat(r?"?".concat(r):""),"GET",{},n)}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"POST",{body:JSON.stringify(e)},n)}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PUT",{body:JSON.stringify(e)},n)}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.request(t,"DELETE",{},e)}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.request(t,"PATCH",{body:JSON.stringify(e)},n)}}]),r}(),pt=function(e){h(i,dt);var r=y(i);function i(e){var n;return o(this,i),(n=r.call(this,e)).axios=t.create({baseURL:"".concat(n.host,"/").concat(n.namespace),headers:{Authorization:"Bearer ".concat(e.publicKey),"Content-Type":"application/json","User-Agent":"@fleetbase/sdk;node"}}),n}return a(i,[{key:"setHeaders",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.axios.defaults.headers.common;return this.axios.defaults.headers.common=n(n({},e),t),this}},{key:"transform",value:function(t){return t.data}},{key:"handleError",value:function(t){if(t.response){var e=t.response.data;if(A(e.errors))throw new Error(e.errors[0]);if(e.error)throw new Error(e.error)}throw t}},{key:"get",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=N(e)?"":new URLSearchParams(e).toString();return this.axios.get("".concat(t).concat(r?"?".concat(r):""),n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"post",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.post(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"put",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.put(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"delete",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.axios.delete(t,e).then(this.transform.bind(this)).catch(this.handleError.bind(this))}},{key:"patch",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.axios.patch(t,e,n).then(this.transform.bind(this)).catch(this.handleError.bind(this))}}]),i}(),yt=function(t){h(n,dt);var e=y(n);function n(){return o(this,n),e.apply(this,arguments)}return n}(),bt=function(){function t(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];o(this,t),c(this,"uncountableWords",["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"]),c(this,"pluralRules",[[new RegExp("(m)an$","gi"),"$1en"],[new RegExp("(pe)rson$","gi"),"$1ople"],[new RegExp("(child)$","gi"),"$1ren"],[new RegExp("^(ox)$","gi"),"$1en"],[new RegExp("(ax|test)is$","gi"),"$1es"],[new RegExp("(octop|vir)us$","gi"),"$1i"],[new RegExp("(alias|status)$","gi"),"$1es"],[new RegExp("(bu)s$","gi"),"$1ses"],[new RegExp("(buffal|tomat|potat)o$","gi"),"$1oes"],[new RegExp("([ti])um$","gi"),"$1a"],[new RegExp("sis$","gi"),"ses"],[new RegExp("(?:([^f])fe|([lr])f)$","gi"),"$1$2ves"],[new RegExp("(hive)$","gi"),"$1s"],[new RegExp("([^aeiouy]|qu)y$","gi"),"$1ies"],[new RegExp("(x|ch|ss|sh)$","gi"),"$1es"],[new RegExp("(matr|vert|ind)ix|ex$","gi"),"$1ices"],[new RegExp("([m|l])ouse$","gi"),"$1ice"],[new RegExp("(quiz)$","gi"),"$1zes"],[new RegExp("s$","gi"),"s"],[new RegExp("$","gi"),"s"]]),c(this,"singularRules",[[new RegExp("(m)en$","gi"),"$1an"],[new RegExp("(pe)ople$","gi"),"$1rson"],[new RegExp("(child)ren$","gi"),"$1"],[new RegExp("([ti])a$","gi"),"$1um"],[new RegExp("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$","gi"),"$1$2sis"],[new RegExp("(hive)s$","gi"),"$1"],[new RegExp("(tive)s$","gi"),"$1"],[new RegExp("(curve)s$","gi"),"$1"],[new RegExp("([lr])ves$","gi"),"$1f"],[new RegExp("([^fo])ves$","gi"),"$1fe"],[new RegExp("([^aeiouy]|qu)ies$","gi"),"$1y"],[new RegExp("(s)eries$","gi"),"$1eries"],[new RegExp("(m)ovies$","gi"),"$1ovie"],[new RegExp("(x|ch|ss|sh)es$","gi"),"$1"],[new RegExp("([m|l])ice$","gi"),"$1ouse"],[new RegExp("(bus)es$","gi"),"$1"],[new RegExp("(o)es$","gi"),"$1"],[new RegExp("(shoe)s$","gi"),"$1"],[new RegExp("(cris|ax|test)es$","gi"),"$1is"],[new RegExp("(octop|vir)i$","gi"),"$1us"],[new RegExp("(alias|status)es$","gi"),"$1"],[new RegExp("^(ox)en","gi"),"$1"],[new RegExp("(vert|ind)ices$","gi"),"$1ex"],[new RegExp("(matr)ices$","gi"),"$1ix"],[new RegExp("(quiz)zes$","gi"),"$1"],[new RegExp("s$","gi"),""]]),c(this,"nonTitlecasedWords",["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"]),c(this,"idSuffix",new RegExp("(_ids|_id)$","g")),c(this,"underbar",new RegExp("_","g")),c(this,"spaceOrUnderbar",new RegExp("[ _]","g")),c(this,"uppercase",new RegExp("([A-Z])","g")),c(this,"underbarPrefix",new RegExp("^_")),this.str=e,this.chain=n}return a(t,[{key:"get",value:function(){return this.str}},{key:"applyRules",value:function(t,e,n,r){if(r)t=r;else if(!(n.indexOf(t.toLowerCase())>-1))for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:null;return t=t||this.str,this.applyRules(t,this.pluralRules,this.uncountableWords,e)}},{key:"singularize",value:function(t,e){return t=t||this.str,this.applyRules(t,this.singularRules,this.uncountableWords,e)}},{key:"camelize",value:function(t,e){for(var n=(t=t||this.str).split("/"),r=0;r1&&void 0!==arguments[1]&&arguments[1];return t=t||this.str,t=this.underscore(this.demodulize(t))+(e?"":"_")+"id",this.str=t,!0===this.chain?this:t}},{key:"ordinalize",value:function(t){for(var e=(t=t||this.str).split(" "),n=0;n1&&void 0!==arguments[1]?arguments[1]:[];if(t.actions=A(e)?e:[e],!A(e))return e instanceof Z&&e.extend(t),t;for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{};o(this,t),this.resource=e,this.adapter=n||J(),this.namespace=kt(e),this.storage=new L,this.options=r,this.extendActions(r.actions)}return a(t,[{key:"extendActions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return Ot(this,t)}},{key:"deposit",value:function(t){return t}},{key:"serialize",value:function(t){return jt("resource",xt(this.resource),t,this.adapter)}},{key:"afterFetch",value:function(t){return function(t,e){if("function"==typeof t.options.onAfterFetch&&t.options.onAfterFetch(e),A(e)){for(var n=[],r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=s(regeneratorRuntime.mark((function r(i,s){var o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.post("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(s);case 2:o=r.sent,i(o);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"update",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(function(){var i=s(regeneratorRuntime.mark((function i(s,o){var u;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,e.adapter.put("".concat(e.namespace,"/").concat(t),n,r).then(e.afterFetch.bind(e)).catch(o);case 2:u=i.sent,s(u);case 4:case"end":return i.stop()}}),i)})));return function(t,e){return i.apply(this,arguments)}}())}},{key:"findRecord",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=s(regeneratorRuntime.mark((function r(i,s){var o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e.adapter.get("".concat(e.namespace,"/").concat(t),{},n).then(e.afterFetch.bind(e)).catch(s);case 2:o=r.sent,i(o);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"findAll",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise(function(){var n=s(regeneratorRuntime.mark((function n(r,i){var s;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.adapter.get("".concat(t.namespace),{},e).then(t.afterFetch.bind(t)).catch(i);case 2:s=n.sent,r(s);case 4:case"end":return n.stop()}}),n)})));return function(t,e){return n.apply(this,arguments)}}())}},{key:"query",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(){var r=s(regeneratorRuntime.mark((function r(i,s){var o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(s);case 2:o=r.sent,i(o);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"queryRecord",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.single=!0,new Promise(function(){var r=s(regeneratorRuntime.mark((function r(i,s){var o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.adapter.get("".concat(t.namespace),e,n).then(t.afterFetch.bind(t)).catch(s);case 2:o=r.sent,i(o);case 4:case"end":return r.stop()}}),r)})));return function(t,e){return r.apply(this,arguments)}}())}},{key:"destroy",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=B(t)?t.getAttribute("id"):t;return new Promise(function(){var t=s(regeneratorRuntime.mark((function t(i,s){var o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.adapter.delete("".concat(e.namespace,"/").concat(r),{},n).then(e.afterFetch.bind(e)).catch(s);case 2:o=t.sent,i(o);case 4:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}}]),t}(),St=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(o(this,t),this.version=n.version||"v1",this.options={version:this.version,host:n.host||"https://api.fleetbase.io",namespace:this.version||n.namespace,debug:r,publicKey:e},"string"!=typeof e||0===e.length)throw new Error("⚠️ Invalid public key given to Fleetbase SDK");if(!I()&&e.toLowerCase().startsWith("$"))throw new Error("Secret key provided. You must use a public key with Fleetbase Javascript SDK!");this.adapter=n.adapter||J(this.options),this.orders=new _t("order",this.adapter).extendActions(Y),this.entities=new _t("entity",this.adapter),this.places=new _t("place",this.adapter),this.drivers=new _t("driver",this.adapter).extendActions(ot),this.vehicles=new _t("vehicle",this.adapter),this.vendors=new _t("vendor",this.adapter),this.contacts=new _t("contact",this.adapter)}return a(t,[{key:"setAdapter",value:function(t){this.adapter=t}},{key:"getAdapter",value:function(){return this.adapter}}],[{key:"newInstance",value:function(){return d(t,Array.prototype.slice.call(arguments))}}]),t}();export{dt as Adapter,gt as BrowserAdapter,L as Collection,ct as Contact,ut as Driver,yt as EmberJsAdapter,et as Entity,H as GoogleAddress,pt as NodeAdapter,X as Order,tt as Payload,nt as Place,K as Point,Q as Resource,lt as ServiceArea,ft as ServiceQuote,vt as ServiceRate,_t as Store,Z as StoreActions,it as TrackingStatus,st as Vehicle,at as Vendor,rt as Waypoint,ht as Zone,wt as camelize,xt as classify,At as dasherize,St as default,Ot as extendStoreActions,T as isLatitude,q as isLongitude,I as isNodeEnvironment,B as isResource,kt as pluralize,mt as singularize}; //# sourceMappingURL=fleetbase.js.map diff --git a/dist/esm/fleetbase.js.map b/dist/esm/fleetbase.js.map index 2557951..23116ec 100644 --- a/dist/esm/fleetbase.js.map +++ b/dist/esm/fleetbase.js.map @@ -1 +1 @@ -{"version":3,"file":"fleetbase.js","sources":["../../src/utils/array.js","../../src/utils/collection.js","../../src/utils/is-empty.js","../../src/utils/is-blank.js","../../src/utils/is-latitude.js","../../src/utils/is-longitude.js","../../src/utils/is-resource.js","../../src/utils/is-node-environment.js","../../src/utils/detect-adapter.js","../../src/utils/google-address.js","../../src/utils/point.js","../../src/utils/object.js","../../src/utils/store-actions.js","../../src/resource.js","../../src/resources/order.js","../../src/resources/payload.js","../../src/resources/entity.js","../../src/resources/place.js","../../src/resources/waypoint.js","../../src/resources/tracking-status.js","../../src/resources/vehicle.js","../../src/resources/driver.js","../../src/resources/vendor.js","../../src/resources/contact.js","../../src/resources/zone.js","../../src/resources/service-area.js","../../src/resources/service-rate.js","../../src/resources/service-quote.js","../../src/adapter.js","../../src/adapters/browser.js","../../src/adapters/node.js","../../src/adapters/ember.js","../../src/utils/string.js","../../src/resolver.js","../../src/store.js","../../src/fleetbase.js"],"sourcesContent":["const { isArray } = Array;\n\nexport {\n isArray\n};\n","import { isArray } from './array';\n\n/**\n * Collection\n * Extended array inspired by Ember's NativeArray\n **/\n\nconst CHUNK_SIZE = 60000;\n\n// To avoid overflowing the stack, we splice up to CHUNK_SIZE items at a time.\n// See https://code.google.com/p/chromium/issues/detail?id=56588 for more details.\nconst replace = (array, start, deleteCount, items = []) => {\n if (isArray(array)) {\n if (items.length <= CHUNK_SIZE) {\n array.splice(start, deleteCount, ...items);\n } else {\n array.splice(start, deleteCount);\n\n for (let i = 0; i < items.length; i += CHUNK_SIZE) {\n let chunk = items.slice(i, i + CHUNK_SIZE);\n array.splice(start + i, 0, ...chunk);\n }\n }\n } else if (isCollection(arr)) {\n array.replace(start, deleteCount, items);\n }\n};\n\nconst identityFunction = (item) => item;\n\nconst uniqBy = (array, key = identityFunction) => {\n let ret = [];\n let seen = new Set();\n let getter = typeof key === 'function' ? key : (item) => get(item, key);\n\n array.forEach((item) => {\n let val = getter(item);\n if (!seen.has(val)) {\n seen.add(val);\n ret.push(item);\n }\n });\n\n return ret;\n};\n\nconst isCollection = (mixed) => mixed instanceof Collection;\n\nconst objectAt = (array, index) => {\n if (isArray(array)) {\n return array[index];\n } else if (isCollection(array)) {\n return array.objectAt(index);\n }\n\n return null;\n};\n\nconst iter = (key, value) => {\n let valueProvided = arguments.length === 2;\n return valueProvided ? (item) => value === item[key] : (item) => Boolean(item[key]);\n};\n\nconst findIndex = (array, predicate, startAt = 0) => {\n let len = array.length;\n for (let index = startAt; index < len; index++) {\n let item = objectAt(array, index);\n if (predicate(item, index, array)) {\n return index;\n }\n }\n return -1;\n};\n\nconst find = (array, callback, target) => {\n let predicate = callback.bind(target);\n let index = findIndex(array, predicate, 0);\n return index === -1 ? undefined : objectAt(array, index);\n};\n\nconst any = (array, callback, target) => {\n let predicate = callback.bind(target);\n return findIndex(array, predicate, 0) !== -1;\n};\n\nconst every = (array, callback, target) => {\n let cb = callback.bind(target);\n let predicate = (item, index, array) => !cb(item, index, array);\n return findIndex(array, predicate, 0) === -1;\n};\n\nconst indexOf = (array, val, startAt = 0, withNaNCheck) => {\n let len = array.length;\n\n if (startAt < 0) {\n startAt += len;\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = withNaNCheck && val !== val ? (item) => item !== item : (item) => item === val;\n return findIndex(array, predicate, startAt);\n};\n\nconst removeAt = (array, index, len = 1) => {\n replace(array, index, len, []);\n return array;\n};\n\nconst insertAt = (array, index, item) => {\n replace(array, index, 0, [item]);\n return item;\n};\n\nclass Collection extends Array {\n constructor(...items) {\n if (isArray(arguments[0])) {\n super(...arguments[0]);\n } else {\n super(...arguments);\n }\n }\n\n get notEmpty() {\n return this.length > 0;\n }\n\n get empty() {\n return this.length === 0;\n }\n\n get first() {\n return objectAt(this, 0);\n }\n\n get last() {\n return objectAt(this, this.length - 1);\n }\n\n replace(start, deleteCount, items = []) {\n replace(this, start, deleteCount, items);\n\n return this;\n }\n\n objectsAt(indexes) {\n return indexes.map((idx) => objectAt(this, idx));\n }\n\n objectAt(index) {\n return objectAt(this, index);\n }\n\n indexOf(object, startAt) {\n return indexOf(this, object, startAt, false);\n }\n\n lastIndexOf(object, startAt) {\n let len = this.length;\n\n if (startAt === undefined || startAt >= len) {\n startAt = len - 1;\n }\n\n if (startAt < 0) {\n startAt += len;\n }\n\n for (let idx = startAt; idx >= 0; idx--) {\n if (objectAt(this, idx) === object) {\n return idx;\n }\n }\n\n return -1;\n }\n\n includes(object, startAt) {\n return indexOf(this, object, startAt, true) !== -1;\n }\n\n findBy() {\n return find(this, iter(...arguments));\n }\n\n findIndexBy() {\n return findIndex(this, iter(...arguments));\n }\n\n isEvery() {\n return every(this, iter(...arguments));\n }\n\n isAny() {\n return any(this, iter(...arguments));\n }\n\n invoke(methodName, ...args) {\n let ret = [];\n\n this.forEach((item) => ret.push(item[methodName]?.(...args)));\n\n return ret;\n }\n\n toArray() {\n return this.map((item) => item);\n }\n\n compact() {\n return this.filter((value) => value != null);\n }\n\n sortBy() {\n let sortKeys = arguments;\n\n return this.sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n let key = sortKeys[i];\n let propA = a[key];\n let propB = b[key];\n // return 1 or -1 else continue to the next sortKey\n let compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n }\n\n uniqBy(key) {\n return uniqBy(this, key);\n }\n\n without(value) {\n if (!this.includes(value)) {\n return this; // nothing to do\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = value === value ? (item) => item !== value : (item) => item === item;\n return this.filter(predicate);\n }\n\n clear() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n this.replace(0, len, []);\n return this;\n }\n\n insertAt(idx, object) {\n insertAt(this, idx, object);\n return this;\n }\n\n replaceAt(idx, object) {\n return this.replace(idx, 1, [object]);\n }\n\n removeAt(start, len) {\n return removeAt(this, start, len);\n }\n\n pushObject(obj) {\n return this.insertAt(this.length, obj);\n }\n\n pushObjects(objects) {\n this.replace(this.length, 0, objects);\n return this;\n }\n\n popObject() {\n let len = this.length;\n if (len === 0) {\n return null;\n }\n\n let ret = objectAt(this, len - 1);\n this.removeAt(len - 1, 1);\n return ret;\n }\n\n shiftObject() {\n if (this.length === 0) {\n return null;\n }\n\n let ret = objectAt(this, 0);\n this.removeAt(0);\n return ret;\n }\n\n unshiftObject(obj) {\n return insertAt(this, 0, obj);\n }\n\n unshiftObjects(objects) {\n this.replace(0, 0, objects);\n return this;\n }\n\n reverseObjects() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n let objects = this.toArray().reverse();\n this.replace(0, len, objects);\n return this;\n }\n\n setObjects(objects) {\n if (objects.length === 0) {\n return this.clear();\n }\n\n let len = this.length;\n this.replace(0, len, objects);\n return this;\n }\n\n removeObject(obj) {\n let loc = this.length || 0;\n while (--loc >= 0) {\n let curObject = objectAt(this, loc);\n\n if (curObject === obj) {\n this.removeAt(loc);\n }\n }\n return this;\n }\n\n removeObjects(objects) {\n for (let i = objects.length - 1; i >= 0; i--) {\n this.removeObject(objects[i]);\n }\n\n return this;\n }\n\n addObject(obj) {\n let included = this.includes(obj);\n\n if (!included) {\n this.pushObject(obj);\n }\n\n return this;\n }\n\n addObjects(objects) {\n objects.forEach((obj) => this.addObject(obj));\n return this;\n }\n}\n\nexport default Collection;\n\nexport { replace, uniqBy, isCollection, objectAt, iter, findIndex, find, any, every, indexOf, removeAt, insertAt };\n","const isEmpty = (obj) => {\n const none = obj === null || obj === undefined;\n if (none) {\n return none;\n }\n\n if (typeof obj.size === 'number') {\n return !obj.size;\n }\n\n const objectType = typeof obj;\n\n if (objectType === 'object') {\n const { size } = obj;\n if (typeof size === 'number') {\n return !size;\n }\n }\n\n if (typeof obj.length === 'number' && objectType !== 'function') {\n return !obj.length;\n }\n\n if (objectType === 'object') {\n const { length } = obj;\n if (typeof length === 'number') {\n return !length;\n }\n }\n\n return false;\n};\n\nexport default isEmpty;\n","import isEmpty from './is-empty';\n\nconst isBlank = (obj) => isEmpty(obj) || (typeof obj === 'string' && /\\S/.test(obj) === false);\n\nexport default isBlank;\n","export default function isLatitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 90;\n}\n","export default function isLongitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 180 && Math.abs(coordinate) >= 90;\n}\n","import Resource from '../resource';\n\nexport default function isResource(record) {\n return record instanceof Resource;\n}\n","/**\n * Determines if environment SDK is initialized in is Node, additionally checks pass if environment is ReactNative.\n * \n * @returns boolean\n */\nconst isNodeEnvironment = () => {\n return (typeof process !== 'undefined') && (typeof process?.env === 'object' || process.release?.name?.search(/node|io.js/) !== -1) && (typeof window === 'undefined' || window?.navigator?.product === 'ReactNative');\n};\n\nexport default isNodeEnvironment;","import { lookup } from '../resolver';\nimport isNodeEnvironment from './is-node-environment';\n\nconst detectAdapter = (options = {}) => {\n if (isNodeEnvironment()) {\n return lookup('adapter', 'NodeAdapter', options);\n }\n\n return lookup('adapter', 'BrowserAdapter', options);\n}\n\nexport default detectAdapter;","const { isArray } = Array;\n\nclass GoogleAddress {\n constructor(place) {\n this.place = place;\n this.geometry = place?.geometry;\n this.components = this.parseComponents();\n this.attributes = this.parseProperties();\n }\n\n parse() {\n this.parseComponents();\n this.parseProperties();\n }\n\n parseComponents() {\n const components = (this.place?.address_components || []).reduce(function (acc, data) {\n data.types.forEach(function (type) {\n acc[type] = data;\n });\n return acc;\n }, {});\n\n return components;\n }\n\n parseProperties() {\n const attributes = {\n streetNumber: this.get('street_number'),\n streetName: this.get('route'),\n coordinates: this.geometry?.location ? Object.values(this.geometry.location) : [0, 0],\n city: this.or(['locality', 'sublocality', 'sublocality_level_1', 'neighborhood', 'administrative_area_level_3', 'administrative_area_level_2']),\n county: this.get('administrative_area_level_2'),\n stateShort: this.get('administrative_area_level_1', true),\n stateLong: this.get('administrative_area_level_1'),\n countryShort: this.get('country', true),\n country: this.get('country', true),\n countryLong: this.get('country'),\n postalCode: this.get('postal_code'),\n };\n\n attributes.address = [attributes.streetNumber, attributes.streetName].filter(Boolean).join(' ');\n\n return attributes;\n }\n\n all() {\n return this.attributes;\n }\n\n or(keys = []) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (isArray(key)) {\n const pkey = key[0];\n const short = key[1];\n\n if (this.has(pkey)) {\n return this.get(pkey, short);\n }\n\n continue;\n }\n\n if (this.has(key)) {\n return this.get(key);\n }\n }\n\n return null;\n }\n\n has(key) {\n return (key in this.components);\n }\n\n get(key, short = false) {\n if (!(key in this.components)) {\n return null;\n }\n\n return short ? this.components[key].short_name : this.components[key].long_name;\n }\n\n setAttributes(attributes = {}) {\n this.attributes = {...this.attributes, ...attributes};\n\n return this;\n }\n\n setAttribute(key, value) {\n this.attributes[key] = value;\n\n return this;\n }\n\n getAttribute(key) {\n return this.attributes[key] || null;\n }\n}\n\nexport default GoogleAddress;\n","export default class Point {\n constructor(latitude = 0, longitude = 0) {\n this.type = 'Point';\n this.coordinates = [longitude, latitude];\n }\n\n get latitude() {\n return this.coordinates[1];\n }\n\n get longitude() {\n return this.coordinates[0];\n }\n\n lat() {\n return this.latitude;\n }\n\n lng() {\n return this.longitude;\n }\n\n static fromGeoJson(json) {\n [ longitude, latitude ] = json.coordinates;\n\n return new Point(latitude, longitude);\n }\n\n serialize() {\n return {\n type: 'Point',\n coorindates: [this.lat(), this.lng()]\n };\n }\n\n toJson() {\n return this.serialize();\n }\n\n toString() {\n return `(${this.latitude}, ${this.longitude})`;\n }\n}","import isEmpty from './is-empty';\n\nconst isResource = (mixed) => typeof mixed === 'object' && !isEmpty(mixed?.attributes) && typeof mixed?.attributes === 'object';\n\nconst isCallable = (object, property) => typeof object[property] === 'function';\n\nconst getResolved = (func, path) => {\n const resolved = func();\n return Array.isArray(resolved) || typeof resolved === 'object' ? get(resolved, path) : null;\n};\n\nconst invoke = (object, method) => {\n if (typeof object[method] === 'function') {\n return object[method].bind(object);\n }\n};\n\nconst get = (object, path) => {\n let current = object;\n\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n\n if (isArray || isObject) {\n for (let i = 0; i < pathArray.length; i++) {\n if (current && current[pathArray[i]] === undefined) {\n return null;\n } else if (current) {\n current = current[pathArray[i]];\n\n // if is resource then return get on it's attributes\n if (isResource(current) && pathArray[i + 1] !== undefined) {\n const newPath = pathArray.slice(i + 1).join('.');\n\n return get(current.attributes, newPath);\n }\n\n // resolve functions and continue\n if (typeof current === 'function') {\n const newPath = pathArray.slice(i + 1).join('.');\n return getResolved(current, newPath);\n }\n }\n }\n return current;\n }\n\n if (isFunction) {\n return getResolved(object, path);\n }\n};\n\nconst getProperties = (object, properties = []) => {\n const selected = {};\n let propertyNames = arguments;\n let i = 1;\n\n if (arguments.length === 2 && Array.isArray(properties)) {\n i = 0;\n propertyNames = arguments[1];\n }\n\n for (; i < propertyNames.length; i++) {\n selected[propertyNames[i]] = get(object, propertyNames[i]);\n }\n\n return selected;\n};\n\nconst set = (object, path, value) => {\n let current = object;\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n // if is function\n if (isFunction) {\n // throw error should be object or array or object like\n }\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n const iterations = pathArray.length;\n\n if (isArray || isObject) {\n for (let i = 0; i < iterations - 1; i++) {\n if (!current[pathArray[i]]) {\n current[pathArray[i]] = {};\n }\n current = current[pathArray[i]];\n }\n\n current[pathArray[iterations - 1]] = value;\n }\n\n return value;\n};\n\nconst setProperties = (object, properties = {}) => {\n for (const property in properties) {\n set(object, property, properties[property]);\n }\n\n return object;\n};\n\nconst extend = (target, classes = []) => {\n if (arguments.length > 1) {\n classes = arguments;\n }\n for (let index = 0; index < classes.length; index++) {\n for (const property in classes[index]) {\n if (Object.prototype.hasOwnProperty.call(classes[index], property)) {\n target[property] = classes[index][property];\n }\n }\n }\n return target;\n};\n\nexport { set, get, getProperties, setProperties, extend, isCallable, invoke };\n","import { set } from './object';\n\nexport default class StoreActions {\n constructor(actions = {}, bind = null) {\n this.actions = actions;\n this.bind = bind;\n }\n\n extend(bindTo = null) {\n const binding = bindTo || this.bind;\n\n if (!binding) {\n return this;\n }\n\n if (this?.actions && typeof this.actions === 'object') {\n for (let action in this.actions) {\n const fn = this.actions[action];\n\n if (typeof fn !== 'function') {\n set(binding, action, fn);\n continue;\n }\n\n set(binding, action, fn.bind(binding));\n }\n }\n\n return this;\n }\n}\n","import Store from './store';\nimport { isEmpty } from './utils';\nimport { isArray } from './utils/array';\nimport { set, get } from './utils/object';\n\nclass Resource {\n /**\n\t * The base resource for all resources\n\n\t * @return {[type]} [description]\n\t */\n constructor(attributes = {}, adapter, resource, options = {}) {\n this.attributes = attributes;\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isDestroying = false;\n this.isReloading = false;\n this.resource = resource;\n this.options = options;\n this.version = options.version || 'v1';\n this.setAdapter(adapter);\n }\n\n /**\n * Set a new adapter to the resource instance, this will update the Store instance\n *\n * @param {Adapter} adapter\n * @return {Resource} this\n */\n setAdapter(adapter) {\n this.adapter = adapter;\n this.store = new Store(this.resource, adapter, {\n onAfterFetch: this.syncAttributes.bind(this),\n actions: this.options?.actions\n });\n\n return this;\n }\n\n /**\n * Getter for id attribute\n *\n * @var {String}\n */\n get id() {\n return this.getAttribute('id');\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n create(attributes = {}) {\n const data = this.mergeAttributes(attributes);\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.create(data).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n update(attributes = {}) {\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.update(this.attributes.id, attributes).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Deletes the resource instance on the server\n *\n * @return {[type]} [description]\n */\n destroy() {\n this.setFlags(['isLoading', 'isDestroying']);\n\n return this.store.destroy(this.attributes.id).then((response) => {\n this.setFlags(['isLoading', 'isDestroying'], false);\n\n return response;\n });\n }\n\n /**\n * Reloads the resource from the server.\n *\n * @return {[type]} [description]\n */\n reload() {\n this.setFlags(['isLoading', 'isReloading']);\n\n return this.store.findRecord(this.attributes.id).then((response) => {\n this.reset();\n\n return response;\n });\n }\n\n /**\n * Sets flag properties.\n *\n * @return this\n */\n setFlags(flags = [], state = true) {\n const validFlags = ['isLoading', 'isSaving', 'isReloading', 'isDestroying'];\n\n for(let i = 0; i < flags.length; i++) {\n const flag = flags[i];\n\n if (typeof flag !== 'string' || !validFlags.includes(flag)) {\n throw new Error(`${flag} is not a valid flag!`);\n }\n\n this[flag] = state;\n }\n\n return this;\n }\n\n /**\n * Resets tracked properties\n *\n * @return this\n */\n reset() {\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isReloading = false;\n\n return this;\n }\n\n /**\n * Emptys resource.\n *\n * @return this\n */\n empty() {\n this.reset();\n this.attribues = {};\n\n return this;\n }\n\n /**\n * Saves the resource instance on the server\n *\n * @return {[type]} [description]\n */\n save(options = {}) {\n const attributes = this.getAttributes();\n\n if (isEmpty(this.id)) {\n return this.create(attributes);\n }\n\n if (options.onlyDirty === true) {\n return this.savedirty();\n }\n\n return this.update(attributes);\n }\n\n /**\n * Saves only dirtied attributes.\n *\n * @return {[type]} [description]\n */\n saveDirty() {\n const dirtyAttributeKeys = Object.keys(this.dirtyAttributes);\n const dirtyAttributes = {};\n\n for (let i = 0; i < dirtyAttributeKeys.length; i++) {\n const key = dirtyAttributeKeys[i];\n dirtyAttributes[key] = this.getAttribute(key);\n }\n\n return this.update(dirtyAttributes);\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get createdAt() {\n return this.hasAttribute('created_at') ? new Date(this.getAttribute('created_at')) : null;\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get updatedAt() {\n return this.hasAttribute('updated_at') ? new Date(this.getAttribute('updated_at')) : null;\n }\n\n /**\n * Checks if resource is loaded from the server.\n *\n * @return {Boolean}\n */\n get isLoaded() {\n return this.hasAttributes(['created_at', 'id']);\n }\n\n /**\n * Checks if resource ihas no attributes\n *\n * @return {Boolean}\n */\n get isEmpty() {\n return Object.values(this?.attributes).length === 0;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isNew() {\n return !this.id;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isSaved() {\n return !this.isNew && this.isLoaded;\n }\n\n /**\n * Checks if resource is deleted on server.\n *\n * @return {Boolean}\n */\n get isDeleted() {\n return this.hasAttributes(['deleted', 'time']);\n }\n\n /**\n * Iterates over each attribute value and property executing a user supplied callback.\n *\n * @return {Object}\n */\n eachAttribute(callback) {\n if (typeof callback !== 'function') {\n return this;\n }\n\n Object.keys(this?.attributes ?? {}).forEach((property) => {\n const value = this.getAttribute(property);\n callback.call(this, value, property);\n });\n\n return this;\n }\n\n /**\n * Gets all changes\n *\n * @return {Object}\n */\n changes() {\n return this.changes;\n }\n\n /**\n * Gets all dirty attributes.\n *\n * @return {Object}\n */\n getDirtyAttributes() {\n return this.dirtyAttributes;\n }\n\n /**\n * Checks if property is dirty.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n isDirty(property) {\n return property in this.dirtyAttributes;\n }\n\n /**\n * Checks if any properties is dirty.\n *\n * @return {Boolean}\n */\n hasDirtyAttributes() {\n return Object.keys(this?.dirtyAttributes ?? {}).length > 0;\n }\n\n /**\n * Updates a instance property without tracking changes or dirtying attribute.\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n mutate(property, value) {\n this.attributes[property] = value;\n }\n\n /**\n * Set an instance property locally\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n setAttribute(property, value = null) {\n if (value === null && typeof property === 'object') {\n return this.setAttributes(property);\n }\n\n const previousValue = this?.attributes[property] ?? null;\n\n // use object setter\n set(this.attributes, property, value);\n set(this.dirtyAttributes, property, previousValue);\n \n // this.attributes[property] = value;\n // this.dirtyAttributes[property] = previousValue;\n\n // track changes\n if (!isArray(this?.changes[property])) {\n this.changes[property] = [];\n }\n\n this.changes[property].push({\n property,\n previousValue,\n value,\n changedAt: new Date(),\n });\n\n return this;\n }\n\n /**\n * Set multiple instance properties locally\n *\n * @param {Object} properties [description]\n */\n setAttributes(attributes = {}) {\n for (let property in attributes) {\n this.setAttribute(property, attributes[property]);\n }\n\n return this;\n }\n\n /**\n * Get an attribute\n *\n * @param {String} attribute The attribute key to get\n * @param {mixed} defaultValue The default value if no attribute value\n */\n getAttribute(attribute, defaultValue = null) {\n const value = get(this?.attributes ?? {}, attribute);\n\n if (value === undefined) {\n return defaultValue;\n }\n\n return value;\n }\n\n /**\n * Checks if attribute exists.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n hasAttribute(property) {\n if (isArray(property)) {\n const properties = property;\n const attributeKeys = Object.keys(this.attributes ?? {});\n \n return properties.every((prop) => attributeKeys.includes(prop));\n }\n\n if (!this?.attributes) {\n return false;\n }\n\n return property in this.attributes;\n }\n\n /**\n * Alias for checking if has multiple attributes.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n hasAttributes(properties = []) {\n return this.hasAttribute(properties);\n }\n\n /**\n * Returns true if attribute has value.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n isAttributeFilled(property) {\n if (isArray(property)) {\n return this.hasAttribute(property) && property.every((prop) => !isEmpty(this.getAttribute(prop)));\n }\n\n return this.hasAttribute(property) && !isEmpty(this.getAttribute(property));\n }\n\n /**\n * Get multiple attributes.\n *\n * @param {Array} properties [description]\n * @param {[type]} value [description]\n */\n getAttributes(properties) {\n const attributes = {};\n\n if (properties === null || properties === undefined) {\n return this.getAttributes(Object.keys(this.attributes));\n }\n\n if (typeof properties === 'string') {\n return this.getAttribute([...arguments]);\n }\n\n if (!isArray(properties)) {\n throw new Error('No attribute properties provided!');\n }\n\n for (let i = 0; i < properties.length; i++) {\n const property = properties[i];\n\n if (typeof property !== 'string') {\n continue;\n }\n\n let value = this.getAttribute(property);\n\n if (typeof value?.attributes === 'object' && !isArray(value?.attributes)) {\n value = value.attributes;\n }\n\n attributes[property] = value;\n }\n\n return attributes;\n }\n\n /**\n * Serialize resource to a POJO\n *\n * @returns {Object}\n */\n serialize() {\n return this.getAttributes();\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n mergeAttributes(attributes = {}) {\n const modelAttributes = this?.attributes ?? {};\n this.attributes = { ...modelAttributes, ...attributes };\n\n return this.attributes;\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n syncAttributes(json = {}) {\n this.attributes = json;\n }\n}\n\nexport default Resource;\n","import Resource from '../resource';\nimport { StoreActions } from '../utils';\n\nconst orderActions = new StoreActions({\n getDistanceAndTime: function (id, options = {}) {\n return this.adapter.get(`${this.namespace}/${id}/distance-and-time`, {}, options);\n },\n});\n\nclass Order extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'order', { actions: orderActions, ...options });\n }\n\n getDistanceAndTime() {\n return this.store.getDistanceAndTime(this.id);\n }\n}\n\nexport default Order;\n\nexport { orderActions };","import Resource from '../resource';\nimport Collection from '../utils/collection';\n\nclass Payload extends Resource {\n\tconstructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'payload', options);\n }\n\t\n /**\n\t * Attaches an entity to an existing payload and returns\n\t * the payload with the entity attached\n\t *\n\t * @param {[type]} Entity entity [description]\n\t * @return {[type]} [description]\n\t */\n attach(entity) {\n // perform op return payload\n }\n\n /**\n\t * Returns all of the entities attached to this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get entities() {\n\n }\n\n /**\n\t * Returns the dropoff for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get dropoff() {\n\n }\n\n /**\n\t * Returns the pickup for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get pickup() {\n\n }\n\n /**\n\t * Returns all the waypoints for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get waypoints() {\n return new Collection(this.waypoints);\n }\n}\n\nexport default Payload;\n","import Resource from '../resource';\n\nclass Entity extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'entity', options);\n }\n}\n\nexport default Entity;\n","import Resource from '../resource';\nimport { isResource, Point } from '../utils';\n\nclass Place extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'place', options);\n }\n\n static fromGoogleAddress(googleAddress, adapter, options = {}) {\n const [ latitude, longitude ] = googleAddress.getAttribute('coordinates');\n const attributes = {\n name: null,\n address: googleAddress.getAttribute('address'),\n location: new Point(latitude, longitude),\n street1: googleAddress.getAttribute('streetName'),\n street2: null,\n city: googleAddress.getAttribute('city'),\n province: googleAddress.getAttribute('stateLong'),\n postal_code: googleAddress.getAttribute('postalCode'),\n neighborhood: googleAddress.get('neighborhood'),\n district: googleAddress.getAttribute('county'),\n building: googleAddress.get('building'),\n country: googleAddress.getAttribute('countryShort'),\n phone: null,\n security_access_code: null\n };\n\n return new Place(attributes, adapter, options);\n }\n\n /**\n * The latitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get latitude() {\n return this.getAttribute('location', new Point())?.coordinates[1];\n }\n\n /**\n * The longitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get longitude() {\n return this.getAttribute('location', new Point())?.coordinates[0];\n }\n\n /**\n * Array coordinate pair for Place location.\n * \n * @var {Array}\n */\n get coordinates() {\n const { latitude, longitude } = this;\n\n return [ latitude, longitude ];\n }\n\n /**\n * Set the owner of the place.\n * \n * @param {Object|String} owner\n * @return {Place}\n */\n setOwner(owner) {\n if (isResource(owner)) {\n this.setAttribute('owner', owner.id);\n }\n\n if (typeof owner === 'string') {\n this.setAttribute('owner', owner);\n }\n\n return this;\n }\n}\n\nexport default Place;\n","import Place from './place';\n\nclass Waypoint extends Place {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'waypoint', options);\n }\n}\n\nexport default Waypoint;\n","import Resource from '../resource';\n\nclass TrackingStatus extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'tracking-status', options);\n }\n}\n\nexport default TrackingStatus;\n","import Resource from '../resource';\n\nclass Vehicle extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vehicle', options);\n }\n}\n\nexport default Vehicle;\n","import Resource from '../resource';\n\nclass Driver extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'driver', options);\n }\n}\n\nexport default Driver;\n","import Resource from '../resource';\n\nclass Vendor extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vendor', options);\n }\n}\n\nexport default Vendor;\n","import Resource from '../resource';\n\nclass Contact extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'contact', options);\n }\n}\n\nexport default Contact;\n","import Resource from '../resource';\n\nclass Zone extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'zone', options);\n }\n}\n\nexport default Zone;\n","import Resource from '../resource';\n\nclass ServiceArea extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-area', options);\n }\n}\n\nexport default ServiceArea;\n","import Resource from '../resource';\n\nclass ServiceRate extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-rate', options);\n }\n}\n\nexport default ServiceRate;\n","import Resource from '../resource';\n\nclass ServiceQuote extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-quote', options);\n }\n\n fromPreliminary() {\n\n }\n\n fromPayload() {\n \n }\n}\n\nexport default ServiceQuote;\n","class Adapter {\n /**\n\t * Creates a configured base adapter for Fleetbase.\n\t *\n\t * @param {Object} config Configuration options for adapter\n\t */\n constructor(config = {}) {\n this.version = config.version || 'v1';\n this.host = config.host || null;\n this.namespace = config.namespace || null;\n this.headers = config.headers || {};\n }\n}\n\nexport default Adapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\n\nclass BrowserAdapter extends Adapter {\n /**\n * Setup browser adapter.\n * @param {Object} config\n */\n constructor(config) {\n super(config);\n\n this.setHeaders({\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;browser'\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n this.headers = { ...this.headers, ...headers };\n\n return this;\n }\n\n /**\n * Parses the JSON returned by a network request\n *\n * @param {Object} response A response from a network request\n * @return {Object} The parsed JSON, status from the response\n *\n * @return {Promise}\n */\n parseJSON(response) {\n return new Promise((resolve, reject) => response\n .json()\n .then((json) => resolve({\n statusText: response.statusText,\n status: response.status,\n ok: response.ok,\n json,\n }))\n .catch(() => {\n reject(new Error('Oops! Something went wrong when handling your request.'));\n }));\n }\n\n /**\n * The base request method\n *\n * @param {String} path\n * @param {String} method\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n request(path, method = 'GET', data = {}, options = {}) {\n return new Promise((resolve, reject) => fetch(options.url || `${this.host}/${this.namespace}/${path}`, {\n method,\n mode: options.mode || 'cors',\n headers: new Headers({\n ...(this.headers || {}),\n ...(options.headers || {}),\n }),\n ...data,\n })\n .then(this.parseJSON)\n .then((response) => {\n if (response.ok) {\n return resolve(response.json);\n }\n\n return reject(new Error(response.json.errors ? response.json.errors[0] : response.statusText));\n })\n .catch((error) => {\n reject(error);\n }));\n }\n\n /**\n * Makes a GET request with fetch\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.request(`${path}${urlParams ? `?${urlParams}` : ''}`, 'GET', {}, options);\n }\n\n /**\n * Makes a POST request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.request(path, 'POST', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a PUT request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.request(path, 'PUT', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a DELETE request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.request(path, 'DELETE', {}, options);\n }\n\n /**\n * Makes a PATCH request with fetch\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.request(path, 'PATCH', { body: JSON.stringify(data) }, options);\n }\n}\n\nexport default BrowserAdapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\nimport { isArray } from '../utils/array';\nimport axios from 'axios';\n\nclass NodeAdapter extends Adapter {\n constructor(config) {\n super(config);\n\n this.axios = axios.create({\n baseURL: `${this.host}/${this.namespace}`,\n headers: {\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;node',\n },\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n const commonHeaders = this.axios.defaults.headers.common;\n this.axios.defaults.headers.common = { ...commonHeaders, ...headers };\n\n return this;\n }\n\n /**\n * Tranform the response, and return the response data from axios.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n transform(response) {\n return response.data;\n }\n\n /**\n * Handles an erroneous request.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n handleError(error) {\n if (error.response) {\n const { data } = error.response;\n\n if (isArray(data.errors)) {\n throw new Error(data.errors[0]);\n }\n\n if (data.error) {\n throw new Error(data.error);\n }\n }\n\n throw error;\n }\n\n /**\n * Makes a GET request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.axios\n .get(`${path}${urlParams ? `?${urlParams}` : ''}`, options)\n .then(this.transform.bind(this))\n .catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a POST request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.axios.post(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PUT request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.axios.put(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a DELETE request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.axios.delete(path, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PATCH request with axios\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.axios.patch(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n}\n\nexport default NodeAdapter;\n","import Adapter from '../adapter';\n\nclass EmberJsAdapter extends Adapter {}\n\nexport default EmberJsAdapter;\n","'use strict';\n\n/**\n * Javascript String\n *\n * instance\n * new String('hello_world').humanize().get() => \"Hello world\"\n *\n * instance\n * const string = new String();\n * string.humanize('hello_world').get() => \"Hello world\"\n * \n * no chain\n * new String('hello_world', false).humanize() => \"Hello world\"\n *\n * static\n * String.invoke('humanize', 'hello_world') => \"Hello world\"\n *\n * exports {}\n * humanize('hello_world') => \"Hello world\"\n */\n\nexport default class String {\n constructor(string, chain = true) {\n this.str = string;\n this.chain = chain;\n }\n\n uncountableWords = ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'moose', 'deer', 'news'];\n\n pluralRules = [\n [new RegExp('(m)an$', 'gi'), '$1en'],\n [new RegExp('(pe)rson$', 'gi'), '$1ople'],\n [new RegExp('(child)$', 'gi'), '$1ren'],\n [new RegExp('^(ox)$', 'gi'), '$1en'],\n [new RegExp('(ax|test)is$', 'gi'), '$1es'],\n [new RegExp('(octop|vir)us$', 'gi'), '$1i'],\n [new RegExp('(alias|status)$', 'gi'), '$1es'],\n [new RegExp('(bu)s$', 'gi'), '$1ses'],\n [new RegExp('(buffal|tomat|potat)o$', 'gi'), '$1oes'],\n [new RegExp('([ti])um$', 'gi'), '$1a'],\n [new RegExp('sis$', 'gi'), 'ses'],\n [new RegExp('(?:([^f])fe|([lr])f)$', 'gi'), '$1$2ves'],\n [new RegExp('(hive)$', 'gi'), '$1s'],\n [new RegExp('([^aeiouy]|qu)y$', 'gi'), '$1ies'],\n [new RegExp('(x|ch|ss|sh)$', 'gi'), '$1es'],\n [new RegExp('(matr|vert|ind)ix|ex$', 'gi'), '$1ices'],\n [new RegExp('([m|l])ouse$', 'gi'), '$1ice'],\n [new RegExp('(quiz)$', 'gi'), '$1zes'],\n [new RegExp('s$', 'gi'), 's'],\n [new RegExp('$', 'gi'), 's'],\n ];\n\n singularRules = [\n [new RegExp('(m)en$', 'gi'), '$1an'],\n [new RegExp('(pe)ople$', 'gi'), '$1rson'],\n [new RegExp('(child)ren$', 'gi'), '$1'],\n [new RegExp('([ti])a$', 'gi'), '$1um'],\n [new RegExp('((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$', 'gi'), '$1$2sis'],\n [new RegExp('(hive)s$', 'gi'), '$1'],\n [new RegExp('(tive)s$', 'gi'), '$1'],\n [new RegExp('(curve)s$', 'gi'), '$1'],\n [new RegExp('([lr])ves$', 'gi'), '$1f'],\n [new RegExp('([^fo])ves$', 'gi'), '$1fe'],\n [new RegExp('([^aeiouy]|qu)ies$', 'gi'), '$1y'],\n [new RegExp('(s)eries$', 'gi'), '$1eries'],\n [new RegExp('(m)ovies$', 'gi'), '$1ovie'],\n [new RegExp('(x|ch|ss|sh)es$', 'gi'), '$1'],\n [new RegExp('([m|l])ice$', 'gi'), '$1ouse'],\n [new RegExp('(bus)es$', 'gi'), '$1'],\n [new RegExp('(o)es$', 'gi'), '$1'],\n [new RegExp('(shoe)s$', 'gi'), '$1'],\n [new RegExp('(cris|ax|test)es$', 'gi'), '$1is'],\n [new RegExp('(octop|vir)i$', 'gi'), '$1us'],\n [new RegExp('(alias|status)es$', 'gi'), '$1'],\n [new RegExp('^(ox)en', 'gi'), '$1'],\n [new RegExp('(vert|ind)ices$', 'gi'), '$1ex'],\n [new RegExp('(matr)ices$', 'gi'), '$1ix'],\n [new RegExp('(quiz)zes$', 'gi'), '$1'],\n [new RegExp('s$', 'gi'), ''],\n ];\n\n nonTitlecasedWords = ['and', 'or', 'nor', 'a', 'an', 'the', 'so', 'but', 'to', 'of', 'at', 'by', 'from', 'into', 'on', 'onto', 'off', 'out', 'in', 'over', 'with', 'for'];\n\n idSuffix = new RegExp('(_ids|_id)$', 'g');\n underbar = new RegExp('_', 'g');\n spaceOrUnderbar = new RegExp('[ _]', 'g');\n uppercase = new RegExp('([A-Z])', 'g');\n underbarPrefix = new RegExp('^_');\n\n get() {\n return this.str;\n }\n\n applyRules(str, rules, skip, override) {\n if (override) {\n str = override;\n } else {\n var ignore = skip.indexOf(str.toLowerCase()) > -1;\n if (!ignore) {\n for (var x = 0; x < rules.length; x++) {\n if (str.match(rules[x][0])) {\n str = str.replace(rules[x][0], rules[x][1]);\n break;\n }\n }\n }\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.pluralize('person') -> 'people'\n String.pluralize('octopus') -> 'octopi'\n String.pluralize('Hat') -> 'Hats'\n String.pluralize('person', 'guys') -> 'guys' \n */\n pluralize(str, plural = null) {\n str = str || this.str;\n\n return this.applyRules(str, this.pluralRules, this.uncountableWords, plural);\n }\n\n /*\n String.singularize('person') -> 'person'\n String.singularize('octopi') -> 'octopus'\n String.singularize('hats') -> 'hat'\n String.singularize('guys', 'person') -> 'person'\n */\n singularize(str, singular) {\n str = str || this.str;\n\n return this.applyRules(str, this.singularRules, this.uncountableWords, singular);\n }\n\n /*\n String.camelize('message_properties') -> 'MessageProperties'\n String.camelize('message_properties', true) -> 'messageProperties'\n */\n camelize(str, lowFirstLetter) {\n str = str || this.str;\n\n let str_path = str.split('/');\n for (var i = 0; i < str_path.length; i++) {\n let str_arr = str_path[i].split('_');\n let initX = lowFirstLetter && i + 1 === str_path.length ? 1 : 0;\n\n for (let x = initX; x < str_arr.length; x++) {\n str_arr[x] = str_arr[x].charAt(0).toUpperCase() + str_arr[x].substring(1);\n }\n str_path[i] = str_arr.join('');\n }\n str = str_path.join('::');\n\n // fix\n if (lowFirstLetter === true) {\n let first = str.charAt(0).toLowerCase();\n let last = str.slice(1);\n str = first + last;\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.underscore('MessageProperties') -> 'message_properties'\n String.underscore('messageProperties') -> 'message_properties'\n */\n underscore(str) {\n str = str || this.str;\n\n var str_path = str.split('::');\n for (var i = 0; i < str_path.length; i++) {\n str_path[i] = str_path[i].replace(this.uppercase, '_$1');\n str_path[i] = str_path[i].replace(this.underbarPrefix, '');\n }\n str = str_path.join('/').toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.humanize('message_properties') -> 'Message properties'\n String.humanize('message_properties') -> 'message properties'\n */\n humanize(str, lowFirstLetter) {\n str = str || this.str;\n\n var str = str.toLowerCase();\n str = str.replace(this.idSuffix, '');\n str = str.replace(this.underbar, ' ');\n if (!lowFirstLetter) {\n str = this.capitalize(str);\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.capitalize('message_properties') -> 'Message_properties'\n String.capitalize('message properties') -> 'Message properties'\n */\n capitalize(str) {\n str = str || this.str;\n\n str = str.toLowerCase();\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.dasherize('message_properties') -> 'message-properties'\n String.dasherize('message properties') -> 'message-properties'\n */\n dasherize(str) {\n str = str || this.str;\n\n str = str.replace(this.spaceOrUnderbar, '-');\n str = str.toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.normify('message_properties') -> 'Message Properties'\n String.normify('message properties') -> 'Message Properties'\n Inflactor.normify('Message_propertyId', true) -> 'Message Properties Id'\n */\n normify(str, allFirstUpper) {\n str = str || this.str;\n\n //var str = str.toLowerCase();\n if (allFirstUpper === true) {\n str = this.camelize(str);\n str = this.underscore(str);\n } else {\n str = str.toLowerCase();\n }\n\n str = str.replace(this.underbar, ' ');\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var d = str_arr[x].split('-');\n for (var i = 0; i < d.length; i++) {\n if (this.nonTitlecasedWords.indexOf(d[i].toLowerCase()) < 0) {\n d[i] = this.capitalize(d[i]);\n }\n }\n str_arr[x] = d.join('-');\n }\n str = str_arr.join(' ');\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.demodulize('Message::Bus::Properties') -> 'Properties'\n */\n demodulize(str) {\n str = str || this.str;\n\n var str_arr = str.split('::');\n str = str_arr[str_arr.length - 1];\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.tableize('MessageBusProperty') -> 'message_bus_properties'\n */\n tableize(str) {\n str = str || this.str;\n\n str = this.pluralize(this.underscore(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.classify('message_bus_properties') -> 'MessageBusProperty'\n */\n classify(str) {\n str = str || this.str;\n\n str = this.singularize(this.camelize(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.foreignKey('MessageBusProperty') -> 'message_bus_property_id'\n String.foreignKey('MessageBusProperty', true) -> 'message_bus_propertyid'\n */\n foreignKey(str, dropIdUbar = false) {\n str = str || this.str;\n\n str = this.underscore(this.demodulize(str)) + (dropIdUbar ? '' : '_') + 'id';\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.ordinalize('the 1 pitch') -> 'the 1st pitch'\n */\n ordinalize(str) {\n str = str || this.str;\n\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var i = parseInt(str_arr[x]);\n if (i === NaN) {\n var ltd = str_arr[x].substring(str_arr[x].length - 2);\n var ld = str_arr[x].substring(str_arr[x].length - 1);\n var suf = 'th';\n if (ltd != '11' && ltd != '12' && ltd != '13') {\n if (ld === '1') {\n suf = 'st';\n } else if (ld === '2') {\n suf = 'nd';\n } else if (ld === '3') {\n suf = 'rd';\n }\n }\n str_arr[x] += suf;\n }\n }\n str = str_arr.join(' ');\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /**\n * @method invoke\n **/\n static invoke() {\n const argz = Object.values(arguments);\n const instance = new String(null, false);\n const method = arguments[0];\n argz.shift();\n\n if (typeof instance[method] === 'function') {\n return instance[method](...argz);\n }\n\n return null;\n }\n}\n\nconst pluralize = function() {\n const argz = ['pluralize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst singularize = function() {\n const argz = ['singularize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst humanize = function() {\n const argz = ['humanize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst underscore = function() {\n const argz = ['underscore', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst camelize = function() {\n const argz = ['camelize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst capitalize = function() {\n const argz = ['capitalize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst dasherize = function() {\n const argz = ['dasherize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst normify = function() {\n const argz = ['normify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst demodulize = function() {\n const argz = ['demodulize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst tableize = function() {\n const argz = ['tableize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst classify = function() {\n const argz = ['classify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst foreignKey = function() {\n const argz = ['foreignKey', ...arguments];\n\n return String.invoke(...argz);\n};\n\nexport {\n pluralize,\n singularize,\n humanize,\n underscore,\n camelize,\n capitalize,\n dasherize,\n normify,\n demodulize,\n tableize,\n classify,\n foreignKey\n}","import { Place, Payload, Order } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter } from './adapters';\nimport { pluralize, singularize } from './utils/string';\n\nconst resources = {\n Place,\n Payload,\n Order\n};\n\nconst adapters = {\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter\n};\n\nclass Resolver {\n constructor () {\n this.resources = resources;\n this.adapters = adapters;\n\n return this.lookup(...arguments);\n }\n\n lookup(type, className) {\n const key = pluralize(type);\n const params = [ ...arguments ].slice(2);\n\n if (!this[key]) {\n throw new Error('Attempted to resolve invalid type');\n }\n\n if (!this[key][className]) {\n throw new Error(`No ${singularize(type)} named ${className} to resolve`);\n }\n\n return new this[key][className](...params);\n }\n}\n\nconst lookup = function() {\n return new Resolver(...arguments);\n};\n\nexport {\n Resolver,\n lookup\n};\n","import { lookup } from './resolver';\nimport { pluralize, classify } from './utils/string';\nimport { isArray } from './utils/array';\nimport { Collection, detectAdapter, isResource, StoreActions } from './utils';\nimport { set, isCallable, invoke } from './utils/object';\n\nconst extendStoreActions = (store, actions = []) => {\n store.actions = isArray(actions) ? actions : [actions];\n\n if (isArray(actions)) {\n for (let i = 0; i < actions.length; i++) {\n const action = actions[i];\n\n store.extendActions(action);\n }\n return;\n }\n\n if (actions instanceof StoreActions) {\n actions.extend(store);\n }\n\n return store;\n};\n\nconst afterFetch = (store, json) => {\n if (typeof store.options.onAfterFetch === 'function') {\n store.options.onAfterFetch(json);\n }\n\n if (isArray(json)) {\n const serialized = [];\n\n for (let i = 0; i < json.length; i++) {\n serialized.push(store.afterFetch(json[i]));\n }\n\n return new Collection(...serialized);\n }\n\n const resourceInstance = store.serialize(json);\n return store.deposit(resourceInstance);\n};\n\nclass Store {\n constructor(resource, adapter, options = {}) {\n this.resource = resource;\n this.adapter = adapter || detectAdapter();\n this.namespace = pluralize(resource);\n this.storage = new Collection();\n this.options = options;\n this.extendActions(options.actions);\n }\n\n extendActions(actions = []) {\n return extendStoreActions(this, actions);\n }\n\n deposit(resourceInstance) {\n // this.storage[this.namespace].pushObject(resourceInstance);\n\n return resourceInstance;\n }\n\n serialize(json) {\n return lookup('resource', classify(this.resource), json, this.adapter);\n }\n\n afterFetch(json) {\n return afterFetch(this, json);\n }\n\n create(attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.post(`${this.namespace}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n update(id, attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.put(`${this.namespace}/${id}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findRecord(id, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findAll(options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n query(query = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n queryRecord(query = {}, options = {}) {\n query.single = true;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n destroy(record, options = {}) {\n const id = isResource(record) ? record.getAttribute('id') : record;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.delete(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n}\n\nexport default Store;\n\nexport { extendStoreActions, afterFetch };\n","import Store from './store';\nimport Resource from './resource';\nimport { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter, Adapter } from './adapters';\nimport { isNodeEnvironment, detectAdapter, isLatitude, isLongitude, Point, isResource, GoogleAddress, Collection, StoreActions } from './utils';\nimport { pluralize, singularize, classify, dasherize, camelize } from './utils/string';\nimport { extendStoreActions } from './store';\nimport { orderActions } from './resources/order';\n\n/**\n * // instance\n * const fleetbase = new Fleetbase();\n *\n * const contact = fleetbase.contacts.create({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * constact.update({ name: 'Hollywood Ron' });\n *\n * // export\n * import { Contact } from '@fleetbase/sdk';\n *\n * const contact = new Contact({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * contact.save();\n */\n\nexport default class Fleetbase {\n /**\n * Builds an instance of the Fleetbase SDK\n *\n * @param {String} publicKey The public key issued\n * @param {Object} config The version of resource to access\n * @param {Boolean} debug Debug mode for SDK\n * @return {Fleetbase} Instance\n */\n constructor(publicKey, config = {}, debug = false) {\n this.version = config.version || 'v1';\n this.options = {\n version: this.version,\n host: config.host || 'https://api.fleetbase.io',\n namespace: this.version || config.namespace,\n debug,\n publicKey,\n };\n\n if (typeof publicKey !== 'string' || publicKey.length === 0) {\n throw new Error('⚠️ Invalid public key given to Fleetbase SDK');\n }\n\n if (!isNodeEnvironment() && publicKey.toLowerCase().startsWith('$')) {\n throw new Error('Secret key provided. You must use a public key with Fleetbase Javascript SDK!');\n }\n\n this.adapter = config.adapter || detectAdapter(this.options);\n\n this.orders = new Store('order', this.adapter).extendActions(orderActions);\n this.entities = new Store('entity', this.adapter);\n this.places = new Store('place', this.adapter);\n this.drivers = new Store('driver', this.adapter);\n this.vehicles = new Store('vehicle', this.adapter);\n this.vendors = new Store('vendor', this.adapter);\n this.contacts = new Store('contact', this.adapter);\n }\n\n static newInstance() {\n return new Fleetbase(...arguments);\n }\n\n setAdapter(adapter) {\n this.adapter = adapter;\n }\n\n getAdapter() {\n return this.adapter;\n }\n}\n\nexport {\n Store,\n Resource,\n Contact,\n Driver,\n Entity,\n Order,\n Payload,\n Place,\n TrackingStatus,\n Vehicle,\n Vendor,\n Waypoint,\n Zone,\n ServiceArea,\n ServiceRate,\n ServiceQuote,\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter,\n Adapter,\n isNodeEnvironment,\n isLatitude,\n isLongitude,\n Point,\n isResource,\n GoogleAddress,\n Collection,\n StoreActions,\n extendStoreActions,\n pluralize,\n singularize,\n classify,\n dasherize,\n camelize,\n};\n"],"names":["isArray","Array","replace","array","start","deleteCount","items","length","splice","i","chunk","slice","isCollection","arr","identityFunction","item","mixed","Collection","objectAt","index","iter","key","value","arguments","Boolean","findIndex","predicate","startAt","len","find","callback","target","bind","undefined","any","every","cb","indexOf","val","withNaNCheck","insertAt","this","indexes","map","idx","_this2","object","methodName","args","ret","forEach","push","_item$methodName","filter","sortKeys","sort","a","b","propA","propB","compareValue","compare","seen","Set","getter","get","has","add","uniqBy","includes","removeAt","obj","objects","toArray","reverse","clear","loc","removeObject","pushObject","_this3","addObject","isEmpty","none","size","objectType","isBlank","test","isLatitude","coordinate","isFinite","Math","abs","isLongitude","isResource","record","Resource","isNodeEnvironment","process","_typeof","_process","env","release","name","search","window","navigator","product","detectAdapter","options","lookup","GoogleAddress","place","geometry","components","parseComponents","attributes","parseProperties","address_components","reduce","acc","data","types","type","streetNumber","streetName","coordinates","location","Object","values","city","or","county","stateShort","stateLong","countryShort","country","countryLong","postalCode","address","join","keys","pkey","short","short_name","long_name","Point","latitude","longitude","coorindates","lat","lng","serialize","json","getResolved","func","path","resolved","current","isObject","isFunction","pathArray","split","newPath","set","iterations","StoreActions","actions","bindTo","binding","action","fn","adapter","resource","dirtyAttributes","changes","isLoading","isSaving","isDestroying","isReloading","version","setAdapter","store","Store","onAfterFetch","syncAttributes","_this$options","getAttribute","mergeAttributes","setFlags","create","then","response","_this","update","id","destroy","findRecord","_this4","reset","flags","state","validFlags","flag","Error","attribues","getAttributes","onlyDirty","savedirty","dirtyAttributeKeys","hasAttribute","Date","hasAttributes","isNew","isLoaded","property","_this5","call","setAttributes","previousValue","changedAt","setAttribute","attribute","defaultValue","properties","attributeKeys","prop","_this6","_value","_value2","modelAttributes","orderActions","getDistanceAndTime","namespace","Order","Payload","entity","waypoints","Entity","Place","_this$getAttribute","_this$getAttribute2","owner","googleAddress","street1","street2","province","postal_code","neighborhood","district","building","phone","security_access_code","Waypoint","TrackingStatus","Vehicle","Driver","Vendor","Contact","Zone","ServiceArea","ServiceRate","ServiceQuote","Adapter","config","host","headers","BrowserAdapter","setHeaders","Authorization","publicKey","Promise","resolve","reject","statusText","status","ok","method","fetch","url","mode","Headers","parseJSON","errors","error","query","urlParams","URLSearchParams","toString","request","body","JSON","stringify","NodeAdapter","axios","baseURL","commonHeaders","defaults","common","transform","handleError","post","put","patch","EmberJsAdapter","String","string","chain","RegExp","str","rules","skip","override","toLowerCase","x","match","plural","applyRules","pluralRules","uncountableWords","singular","singularRules","lowFirstLetter","str_path","str_arr","charAt","toUpperCase","substring","first","last","uppercase","underbarPrefix","idSuffix","underbar","capitalize","spaceOrUnderbar","allFirstUpper","camelize","underscore","d","nonTitlecasedWords","pluralize","singularize","dropIdUbar","demodulize","NaN","parseInt","ltd","ld","suf","argz","instance","shift","invoke","dasherize","classify","resources","adapters","Resolver","className","params","extendStoreActions","extend","extendActions","storage","resourceInstance","serialized","afterFetch","deposit","single","_this7","Fleetbase","debug","startsWith","orders","entities","places","drivers","vehicles","vendors","contacts"],"mappings":"qjJAAA,IAAQA,EAAYC,MAAZD,yDCWFE,EAAU,SAACC,EAAOC,EAAOC,OAAaC,yDAAQ,MAC5CN,EAAQG,MACJG,EAAMC,QANC,IAOPJ,EAAMK,aAANL,GAAaC,EAAOC,YAAgBC,SACjC,CACHH,EAAMK,OAAOJ,EAAOC,OAEf,IAAII,EAAI,EAAGA,EAAIH,EAAMC,OAAQE,GAX3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F,GAASkF,KAAKmL,EAAKH,WAAW9U,KAAKiV,UAAajG,UAApHjF,SAENgF,EAAQhF,gHCjGCmL,yBASLrG,OAAWN,yDAAS,GAAI4G,4EAC3BhM,QAAUoF,EAAOpF,SAAW,UAC5BvE,QAAU,CACXuE,QAAS1I,KAAK0I,QACdqF,KAAMD,EAAOC,MAAQ,2BACrBhC,UAAW/L,KAAK0I,SAAWoF,EAAO/B,UAClC2I,MAAAA,EACAtG,UAAAA,GAGqB,iBAAdA,GAA+C,IAArBA,EAAUtQ,aACrC,IAAIoM,MAAM,oDAGf3G,KAAuB6K,EAAU2C,cAAc4D,WAAW,WACrD,IAAIzK,MAAM,sFAGfhC,QAAU4F,EAAO5F,SAAWhE,EAAclE,KAAKmE,cAE/CyQ,OAAS,IAAI/L,GAAM,QAAS7I,KAAKkI,SAAS+L,cAAcpI,QACxDgJ,SAAW,IAAIhM,GAAM,SAAU7I,KAAKkI,cACpC4M,OAAS,IAAIjM,GAAM,QAAS7I,KAAKkI,cACjC6M,QAAU,IAAIlM,GAAM,SAAU7I,KAAKkI,cACnC8M,SAAW,IAAInM,GAAM,UAAW7I,KAAKkI,cACrC+M,QAAU,IAAIpM,GAAM,SAAU7I,KAAKkI,cACnCgN,SAAW,IAAIrM,GAAM,UAAW7I,KAAKkI,6CAO9C,SAAWA,QACFA,QAAUA,4BAGnB,kBACWlI,KAAKkI,qCAThB,oBACeuM,6BAAa3V"} \ No newline at end of file +{"version":3,"file":"fleetbase.js","sources":["../../src/utils/array.js","../../src/utils/collection.js","../../src/utils/is-empty.js","../../src/utils/is-blank.js","../../src/utils/is-latitude.js","../../src/utils/is-longitude.js","../../src/utils/is-resource.js","../../src/utils/is-phone.js","../../src/utils/is-node-environment.js","../../src/utils/detect-adapter.js","../../src/utils/google-address.js","../../src/utils/point.js","../../src/utils/object.js","../../src/utils/store-actions.js","../../src/resource.js","../../src/resources/order.js","../../src/resources/payload.js","../../src/resources/entity.js","../../src/resources/place.js","../../src/resources/waypoint.js","../../src/resources/tracking-status.js","../../src/resources/vehicle.js","../../src/resources/driver.js","../../src/resources/vendor.js","../../src/resources/contact.js","../../src/resources/zone.js","../../src/resources/service-area.js","../../src/resources/service-rate.js","../../src/resources/service-quote.js","../../src/adapter.js","../../src/adapters/browser.js","../../src/adapters/node.js","../../src/adapters/ember.js","../../src/utils/string.js","../../src/resolver.js","../../src/store.js","../../src/fleetbase.js"],"sourcesContent":["const { isArray } = Array;\n\nexport {\n isArray\n};\n","import { isArray } from './array';\n\n/**\n * Collection\n * Extended array inspired by Ember's NativeArray\n **/\n\nconst CHUNK_SIZE = 60000;\n\n// To avoid overflowing the stack, we splice up to CHUNK_SIZE items at a time.\n// See https://code.google.com/p/chromium/issues/detail?id=56588 for more details.\nconst replace = (array, start, deleteCount, items = []) => {\n if (isArray(array)) {\n if (items.length <= CHUNK_SIZE) {\n array.splice(start, deleteCount, ...items);\n } else {\n array.splice(start, deleteCount);\n\n for (let i = 0; i < items.length; i += CHUNK_SIZE) {\n let chunk = items.slice(i, i + CHUNK_SIZE);\n array.splice(start + i, 0, ...chunk);\n }\n }\n } else if (isCollection(arr)) {\n array.replace(start, deleteCount, items);\n }\n};\n\nconst identityFunction = (item) => item;\n\nconst uniqBy = (array, key = identityFunction) => {\n let ret = [];\n let seen = new Set();\n let getter = typeof key === 'function' ? key : (item) => get(item, key);\n\n array.forEach((item) => {\n let val = getter(item);\n if (!seen.has(val)) {\n seen.add(val);\n ret.push(item);\n }\n });\n\n return ret;\n};\n\nconst isCollection = (mixed) => mixed instanceof Collection;\n\nconst objectAt = (array, index) => {\n if (isArray(array)) {\n return array[index];\n } else if (isCollection(array)) {\n return array.objectAt(index);\n }\n\n return null;\n};\n\nconst iter = (key, value) => {\n let valueProvided = arguments.length === 2;\n return valueProvided ? (item) => value === item[key] : (item) => Boolean(item[key]);\n};\n\nconst findIndex = (array, predicate, startAt = 0) => {\n let len = array.length;\n for (let index = startAt; index < len; index++) {\n let item = objectAt(array, index);\n if (predicate(item, index, array)) {\n return index;\n }\n }\n return -1;\n};\n\nconst find = (array, callback, target) => {\n let predicate = callback.bind(target);\n let index = findIndex(array, predicate, 0);\n return index === -1 ? undefined : objectAt(array, index);\n};\n\nconst any = (array, callback, target) => {\n let predicate = callback.bind(target);\n return findIndex(array, predicate, 0) !== -1;\n};\n\nconst every = (array, callback, target) => {\n let cb = callback.bind(target);\n let predicate = (item, index, array) => !cb(item, index, array);\n return findIndex(array, predicate, 0) === -1;\n};\n\nconst indexOf = (array, val, startAt = 0, withNaNCheck) => {\n let len = array.length;\n\n if (startAt < 0) {\n startAt += len;\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = withNaNCheck && val !== val ? (item) => item !== item : (item) => item === val;\n return findIndex(array, predicate, startAt);\n};\n\nconst removeAt = (array, index, len = 1) => {\n replace(array, index, len, []);\n return array;\n};\n\nconst insertAt = (array, index, item) => {\n replace(array, index, 0, [item]);\n return item;\n};\n\nclass Collection extends Array {\n constructor(...items) {\n if (isArray(arguments[0])) {\n super(...arguments[0]);\n } else {\n super(...arguments);\n }\n }\n\n get notEmpty() {\n return this.length > 0;\n }\n\n get empty() {\n return this.length === 0;\n }\n\n get first() {\n return objectAt(this, 0);\n }\n\n get last() {\n return objectAt(this, this.length - 1);\n }\n\n replace(start, deleteCount, items = []) {\n replace(this, start, deleteCount, items);\n\n return this;\n }\n\n objectsAt(indexes) {\n return indexes.map((idx) => objectAt(this, idx));\n }\n\n objectAt(index) {\n return objectAt(this, index);\n }\n\n indexOf(object, startAt) {\n return indexOf(this, object, startAt, false);\n }\n\n lastIndexOf(object, startAt) {\n let len = this.length;\n\n if (startAt === undefined || startAt >= len) {\n startAt = len - 1;\n }\n\n if (startAt < 0) {\n startAt += len;\n }\n\n for (let idx = startAt; idx >= 0; idx--) {\n if (objectAt(this, idx) === object) {\n return idx;\n }\n }\n\n return -1;\n }\n\n includes(object, startAt) {\n return indexOf(this, object, startAt, true) !== -1;\n }\n\n findBy() {\n return find(this, iter(...arguments));\n }\n\n findIndexBy() {\n return findIndex(this, iter(...arguments));\n }\n\n isEvery() {\n return every(this, iter(...arguments));\n }\n\n isAny() {\n return any(this, iter(...arguments));\n }\n\n invoke(methodName, ...args) {\n let ret = [];\n\n this.forEach((item) => ret.push(item[methodName]?.(...args)));\n\n return ret;\n }\n\n toArray() {\n return this.map((item) => item);\n }\n\n compact() {\n return this.filter((value) => value != null);\n }\n\n sortBy() {\n let sortKeys = arguments;\n\n return this.sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n let key = sortKeys[i];\n let propA = a[key];\n let propB = b[key];\n // return 1 or -1 else continue to the next sortKey\n let compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n }\n\n uniqBy(key) {\n return uniqBy(this, key);\n }\n\n without(value) {\n if (!this.includes(value)) {\n return this; // nothing to do\n }\n\n // SameValueZero comparison (NaN !== NaN)\n let predicate = value === value ? (item) => item !== value : (item) => item === item;\n return this.filter(predicate);\n }\n\n clear() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n this.replace(0, len, []);\n return this;\n }\n\n insertAt(idx, object) {\n insertAt(this, idx, object);\n return this;\n }\n\n replaceAt(idx, object) {\n return this.replace(idx, 1, [object]);\n }\n\n removeAt(start, len) {\n return removeAt(this, start, len);\n }\n\n pushObject(obj) {\n return this.insertAt(this.length, obj);\n }\n\n pushObjects(objects) {\n this.replace(this.length, 0, objects);\n return this;\n }\n\n popObject() {\n let len = this.length;\n if (len === 0) {\n return null;\n }\n\n let ret = objectAt(this, len - 1);\n this.removeAt(len - 1, 1);\n return ret;\n }\n\n shiftObject() {\n if (this.length === 0) {\n return null;\n }\n\n let ret = objectAt(this, 0);\n this.removeAt(0);\n return ret;\n }\n\n unshiftObject(obj) {\n return insertAt(this, 0, obj);\n }\n\n unshiftObjects(objects) {\n this.replace(0, 0, objects);\n return this;\n }\n\n reverseObjects() {\n let len = this.length;\n if (len === 0) {\n return this;\n }\n\n let objects = this.toArray().reverse();\n this.replace(0, len, objects);\n return this;\n }\n\n setObjects(objects) {\n if (objects.length === 0) {\n return this.clear();\n }\n\n let len = this.length;\n this.replace(0, len, objects);\n return this;\n }\n\n removeObject(obj) {\n let loc = this.length || 0;\n while (--loc >= 0) {\n let curObject = objectAt(this, loc);\n\n if (curObject === obj) {\n this.removeAt(loc);\n }\n }\n return this;\n }\n\n removeObjects(objects) {\n for (let i = objects.length - 1; i >= 0; i--) {\n this.removeObject(objects[i]);\n }\n\n return this;\n }\n\n addObject(obj) {\n let included = this.includes(obj);\n\n if (!included) {\n this.pushObject(obj);\n }\n\n return this;\n }\n\n addObjects(objects) {\n objects.forEach((obj) => this.addObject(obj));\n return this;\n }\n}\n\nexport default Collection;\n\nexport { replace, uniqBy, isCollection, objectAt, iter, findIndex, find, any, every, indexOf, removeAt, insertAt };\n","const isEmpty = (obj) => {\n const none = obj === null || obj === undefined;\n if (none) {\n return none;\n }\n\n if (typeof obj.size === 'number') {\n return !obj.size;\n }\n\n const objectType = typeof obj;\n\n if (objectType === 'object') {\n const { size } = obj;\n if (typeof size === 'number') {\n return !size;\n }\n }\n\n if (typeof obj.length === 'number' && objectType !== 'function') {\n return !obj.length;\n }\n\n if (objectType === 'object') {\n const { length } = obj;\n if (typeof length === 'number') {\n return !length;\n }\n }\n\n return false;\n};\n\nexport default isEmpty;\n","import isEmpty from './is-empty';\n\nconst isBlank = (obj) => isEmpty(obj) || (typeof obj === 'string' && /\\S/.test(obj) === false);\n\nexport default isBlank;\n","export default function isLatitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 90;\n}\n","export default function isLongitude(coordinate) {\n return isFinite(coordinate) && Math.abs(coordinate) <= 180 && Math.abs(coordinate) >= 90;\n}\n","import Resource from '../resource';\n\nexport default function isResource(record) {\n return record instanceof Resource;\n}\n","const isPhone = (phone = '') => {\n return /^[+]?[\\s./0-9]*[(]?[0-9]{1,4}[)]?[-\\s./0-9]*$/g.test(phone);\n}\n\nexport default isPhone;","/**\n * Determines if environment SDK is initialized in is Node, additionally checks pass if environment is ReactNative.\n * \n * @returns boolean\n */\nconst isNodeEnvironment = () => {\n return (typeof process !== 'undefined') && (typeof process?.env === 'object' || process.release?.name?.search(/node|io.js/) !== -1) && (typeof window === 'undefined' || window?.navigator?.product === 'ReactNative');\n};\n\nexport default isNodeEnvironment;","import { lookup } from '../resolver';\nimport isNodeEnvironment from './is-node-environment';\n\nconst detectAdapter = (options = {}) => {\n if (isNodeEnvironment()) {\n return lookup('adapter', 'NodeAdapter', options);\n }\n\n return lookup('adapter', 'BrowserAdapter', options);\n}\n\nexport default detectAdapter;","const { isArray } = Array;\n\nclass GoogleAddress {\n constructor(place) {\n this.place = place;\n this.geometry = place?.geometry;\n this.components = this.parseComponents();\n this.attributes = this.parseProperties();\n }\n\n parse() {\n this.parseComponents();\n this.parseProperties();\n }\n\n parseComponents() {\n const components = (this.place?.address_components || []).reduce(function (acc, data) {\n data.types.forEach(function (type) {\n acc[type] = data;\n });\n return acc;\n }, {});\n\n return components;\n }\n\n parseProperties() {\n const attributes = {\n streetNumber: this.get('street_number'),\n streetName: this.get('route'),\n coordinates: this.geometry?.location ? Object.values(this.geometry.location) : [0, 0],\n city: this.or(['locality', 'sublocality', 'sublocality_level_1', 'neighborhood', 'administrative_area_level_3', 'administrative_area_level_2']),\n county: this.get('administrative_area_level_2'),\n stateShort: this.get('administrative_area_level_1', true),\n stateLong: this.get('administrative_area_level_1'),\n countryShort: this.get('country', true),\n country: this.get('country', true),\n countryLong: this.get('country'),\n postalCode: this.get('postal_code'),\n };\n\n attributes.address = [attributes.streetNumber, attributes.streetName].filter(Boolean).join(' ');\n\n return attributes;\n }\n\n all() {\n return this.attributes;\n }\n\n or(keys = []) {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (isArray(key)) {\n const pkey = key[0];\n const short = key[1];\n\n if (this.has(pkey)) {\n return this.get(pkey, short);\n }\n\n continue;\n }\n\n if (this.has(key)) {\n return this.get(key);\n }\n }\n\n return null;\n }\n\n has(key) {\n return (key in this.components);\n }\n\n get(key, short = false) {\n if (!(key in this.components)) {\n return null;\n }\n\n return short ? this.components[key].short_name : this.components[key].long_name;\n }\n\n setAttributes(attributes = {}) {\n this.attributes = {...this.attributes, ...attributes};\n\n return this;\n }\n\n setAttribute(key, value) {\n this.attributes[key] = value;\n\n return this;\n }\n\n getAttribute(key) {\n return this.attributes[key] || null;\n }\n}\n\nexport default GoogleAddress;\n","export default class Point {\n constructor(latitude = 0, longitude = 0) {\n this.type = 'Point';\n this.coordinates = [longitude, latitude];\n }\n\n get latitude() {\n return this.coordinates[1];\n }\n\n get longitude() {\n return this.coordinates[0];\n }\n\n lat() {\n return this.latitude;\n }\n\n lng() {\n return this.longitude;\n }\n\n static fromGeoJson(json) {\n [ longitude, latitude ] = json.coordinates;\n\n return new Point(latitude, longitude);\n }\n\n serialize() {\n return {\n type: 'Point',\n coorindates: [this.lat(), this.lng()]\n };\n }\n\n toJson() {\n return this.serialize();\n }\n\n toString() {\n return `(${this.latitude}, ${this.longitude})`;\n }\n}","import isEmpty from './is-empty';\n\nconst isResource = (mixed) => typeof mixed === 'object' && !isEmpty(mixed?.attributes) && typeof mixed?.attributes === 'object';\n\nconst isCallable = (object, property) => typeof object[property] === 'function';\n\nconst getResolved = (func, path) => {\n const resolved = func();\n return Array.isArray(resolved) || typeof resolved === 'object' ? get(resolved, path) : null;\n};\n\nconst invoke = (object, method) => {\n if (typeof object[method] === 'function') {\n return object[method].bind(object);\n }\n};\n\nconst get = (object, path) => {\n let current = object;\n\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n\n if (isArray || isObject) {\n for (let i = 0; i < pathArray.length; i++) {\n if (current && current[pathArray[i]] === undefined) {\n return null;\n } else if (current) {\n current = current[pathArray[i]];\n\n // if is resource then return get on it's attributes\n if (isResource(current) && pathArray[i + 1] !== undefined) {\n const newPath = pathArray.slice(i + 1).join('.');\n\n return get(current.attributes, newPath);\n }\n\n // resolve functions and continue\n if (typeof current === 'function') {\n const newPath = pathArray.slice(i + 1).join('.');\n return getResolved(current, newPath);\n }\n }\n }\n return current;\n }\n\n if (isFunction) {\n return getResolved(object, path);\n }\n};\n\nconst getProperties = (object, properties = []) => {\n const selected = {};\n let propertyNames = arguments;\n let i = 1;\n\n if (arguments.length === 2 && Array.isArray(properties)) {\n i = 0;\n propertyNames = arguments[1];\n }\n\n for (; i < propertyNames.length; i++) {\n selected[propertyNames[i]] = get(object, propertyNames[i]);\n }\n\n return selected;\n};\n\nconst set = (object, path, value) => {\n let current = object;\n const type = typeof object;\n const isObject = type === 'object';\n const isFunction = type === 'function';\n const isArray = Array.isArray(object);\n\n // if is function\n if (isFunction) {\n // throw error should be object or array or object like\n }\n\n const pathType = typeof path;\n const pathIsString = pathType === 'string';\n const pathIsDotted = pathIsString && path.includes('.');\n const pathArray = pathIsDotted ? path.split('.') : [path];\n const iterations = pathArray.length;\n\n if (isArray || isObject) {\n for (let i = 0; i < iterations - 1; i++) {\n if (!current[pathArray[i]]) {\n current[pathArray[i]] = {};\n }\n current = current[pathArray[i]];\n }\n\n current[pathArray[iterations - 1]] = value;\n }\n\n return value;\n};\n\nconst setProperties = (object, properties = {}) => {\n for (const property in properties) {\n set(object, property, properties[property]);\n }\n\n return object;\n};\n\nconst extend = (target, classes = []) => {\n if (arguments.length > 1) {\n classes = arguments;\n }\n for (let index = 0; index < classes.length; index++) {\n for (const property in classes[index]) {\n if (Object.prototype.hasOwnProperty.call(classes[index], property)) {\n target[property] = classes[index][property];\n }\n }\n }\n return target;\n};\n\nexport { set, get, getProperties, setProperties, extend, isCallable, invoke };\n","import { set } from './object';\n\nexport default class StoreActions {\n constructor(actions = {}, bind = null) {\n this.actions = actions;\n this.bind = bind;\n }\n\n extend(bindTo = null) {\n const binding = bindTo || this.bind;\n\n if (!binding) {\n return this;\n }\n\n if (this?.actions && typeof this.actions === 'object') {\n for (let action in this.actions) {\n const fn = this.actions[action];\n\n if (typeof fn !== 'function') {\n set(binding, action, fn);\n continue;\n }\n\n set(binding, action, fn.bind(binding));\n }\n }\n\n return this;\n }\n}\n","import Store from './store';\nimport { isEmpty } from './utils';\nimport { isArray } from './utils/array';\nimport { set, get } from './utils/object';\n\nclass Resource {\n /**\n\t * The base resource for all resources\n\n\t * @return {[type]} [description]\n\t */\n constructor(attributes = {}, adapter, resource, options = {}) {\n this.attributes = attributes;\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isDestroying = false;\n this.isReloading = false;\n this.resource = resource;\n this.options = options;\n this.version = options.version || 'v1';\n this.setAdapter(adapter);\n }\n\n /**\n * Set a new adapter to the resource instance, this will update the Store instance\n *\n * @param {Adapter} adapter\n * @return {Resource} this\n */\n setAdapter(adapter) {\n this.adapter = adapter;\n this.store = new Store(this.resource, adapter, {\n onAfterFetch: this.syncAttributes.bind(this),\n actions: this.options?.actions\n });\n\n return this;\n }\n\n /**\n * Getter for id attribute\n *\n * @var {String}\n */\n get id() {\n return this.getAttribute('id');\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n create(attributes = {}) {\n const data = this.mergeAttributes(attributes);\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.create(data).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Creates a new resource on the server\n *\n * @param {Object} payload [description]\n * @return {[type]} [description]\n */\n update(attributes = {}) {\n this.setFlags(['isLoading', 'isSaving']);\n\n return this.store.update(this.attributes.id, attributes).then((response) => {\n this.setFlags(['isLoading', 'isSaving'], false);\n\n return response;\n });\n }\n\n /**\n * Deletes the resource instance on the server\n *\n * @return {[type]} [description]\n */\n destroy() {\n this.setFlags(['isLoading', 'isDestroying']);\n\n return this.store.destroy(this.attributes.id).then((response) => {\n this.setFlags(['isLoading', 'isDestroying'], false);\n\n return response;\n });\n }\n\n /**\n * Reloads the resource from the server.\n *\n * @return {[type]} [description]\n */\n reload() {\n this.setFlags(['isLoading', 'isReloading']);\n\n return this.store.findRecord(this.attributes.id).then((response) => {\n this.reset();\n\n return response;\n });\n }\n\n /**\n * Sets flag properties.\n *\n * @return this\n */\n setFlags(flags = [], state = true) {\n const validFlags = ['isLoading', 'isSaving', 'isReloading', 'isDestroying'];\n\n for(let i = 0; i < flags.length; i++) {\n const flag = flags[i];\n\n if (typeof flag !== 'string' || !validFlags.includes(flag)) {\n throw new Error(`${flag} is not a valid flag!`);\n }\n\n this[flag] = state;\n }\n\n return this;\n }\n\n /**\n * Resets tracked properties\n *\n * @return this\n */\n reset() {\n this.dirtyAttributes = {};\n this.changes = {};\n this.isLoading = false;\n this.isSaving = false;\n this.isReloading = false;\n\n return this;\n }\n\n /**\n * Emptys resource.\n *\n * @return this\n */\n empty() {\n this.reset();\n this.attribues = {};\n\n return this;\n }\n\n /**\n * Saves the resource instance on the server\n *\n * @return {[type]} [description]\n */\n save(options = {}) {\n const attributes = this.getAttributes();\n\n if (isEmpty(this.id)) {\n return this.create(attributes);\n }\n\n if (options.onlyDirty === true) {\n return this.savedirty();\n }\n\n return this.update(attributes);\n }\n\n /**\n * Saves only dirtied attributes.\n *\n * @return {[type]} [description]\n */\n saveDirty() {\n const dirtyAttributeKeys = Object.keys(this.dirtyAttributes);\n const dirtyAttributes = {};\n\n for (let i = 0; i < dirtyAttributeKeys.length; i++) {\n const key = dirtyAttributeKeys[i];\n dirtyAttributes[key] = this.getAttribute(key);\n }\n\n return this.update(dirtyAttributes);\n }\n\n /**\n * Returns the resource meta if exists.\n *\n * @return {Object}\n */\n get meta() {\n return this.getAttribute('meta', {});\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get createdAt() {\n return this.isAttributeFilled('created_at') ? new Date(this.getAttribute('created_at')) : null;\n }\n\n /**\n * Returns the date instance resource was created.\n *\n * @return {Date}\n */\n get updatedAt() {\n return this.isAttributeFilled('updated_at') ? new Date(this.getAttribute('updated_at')) : null;\n }\n\n /**\n * Checks if resource is loaded from the server.\n *\n * @return {Boolean}\n */\n get isLoaded() {\n return this.hasAttributes(['created_at', 'id']);\n }\n\n /**\n * Checks if resource ihas no attributes\n *\n * @return {Boolean}\n */\n get isEmpty() {\n return Object.values(this?.attributes).length === 0;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isNew() {\n return !this.id;\n }\n\n /**\n * Checks if resource is not saved to server.\n *\n * @return {Boolean}\n */\n get isSaved() {\n return !this.isNew && this.isLoaded;\n }\n\n /**\n * Checks if resource is deleted on server.\n *\n * @return {Boolean}\n */\n get isDeleted() {\n return this.hasAttributes(['deleted', 'time']);\n }\n\n /**\n * Iterates over each attribute value and property executing a user supplied callback.\n *\n * @return {Object}\n */\n eachAttribute(callback) {\n if (typeof callback !== 'function') {\n return this;\n }\n\n Object.keys(this?.attributes ?? {}).forEach((property) => {\n const value = this.getAttribute(property);\n callback.call(this, value, property);\n });\n\n return this;\n }\n\n /**\n * Gets all changes\n *\n * @return {Object}\n */\n changes() {\n return this.changes;\n }\n\n /**\n * Gets all dirty attributes.\n *\n * @return {Object}\n */\n getDirtyAttributes() {\n return this.dirtyAttributes;\n }\n\n /**\n * Checks if property is dirty.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n isDirty(property) {\n return property in this.dirtyAttributes;\n }\n\n /**\n * Checks if any properties is dirty.\n *\n * @return {Boolean}\n */\n hasDirtyAttributes() {\n return Object.keys(this?.dirtyAttributes ?? {}).length > 0;\n }\n\n /**\n * Updates a instance property without tracking changes or dirtying attribute.\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n mutate(property, value) {\n this.attributes[property] = value;\n }\n\n /**\n * Set an instance property locally\n *\n * @param {String} property [description]\n * @param {mixed} value [description]\n */\n setAttribute(property, value = null) {\n if (value === null && typeof property === 'object') {\n return this.setAttributes(property);\n }\n\n const previousValue = this?.attributes[property] ?? null;\n\n // use object setter\n set(this.attributes, property, value);\n set(this.dirtyAttributes, property, previousValue);\n \n // this.attributes[property] = value;\n // this.dirtyAttributes[property] = previousValue;\n\n // track changes\n if (!isArray(this?.changes[property])) {\n this.changes[property] = [];\n }\n\n this.changes[property].push({\n property,\n previousValue,\n value,\n changedAt: new Date(),\n });\n\n return this;\n }\n\n /**\n * Set multiple instance properties locally\n *\n * @param {Object} properties [description]\n */\n setAttributes(attributes = {}) {\n for (let property in attributes) {\n this.setAttribute(property, attributes[property]);\n }\n\n return this;\n }\n\n /**\n * Get an attribute\n *\n * @param {String} attribute The attribute key to get\n * @param {mixed} defaultValue The default value if no attribute value\n */\n getAttribute(attribute, defaultValue = null) {\n const value = get(this?.attributes ?? {}, attribute);\n\n if (value === undefined) {\n return defaultValue;\n }\n\n return value;\n }\n\n /**\n * Checks if attribute exists.\n *\n * @param {String} property [description]\n * @return {Boolean}\n */\n hasAttribute(property) {\n if (isArray(property)) {\n const properties = property;\n const attributeKeys = Object.keys(this.attributes ?? {});\n \n return properties.every((prop) => attributeKeys.includes(prop));\n }\n\n if (!this?.attributes) {\n return false;\n }\n\n return property in this.attributes;\n }\n\n /**\n * Alias for checking if has multiple attributes.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n hasAttributes(properties = []) {\n return this.hasAttribute(properties);\n }\n\n /**\n * Returns true if attribute has value.\n *\n * @param {Array} properties \n * @return {Boolean}\n */\n isAttributeFilled(property) {\n if (isArray(property)) {\n return this.hasAttribute(property) && property.every((prop) => !isEmpty(this.getAttribute(prop)));\n }\n\n return this.hasAttribute(property) && !isEmpty(this.getAttribute(property));\n }\n\n /**\n * Get multiple attributes.\n *\n * @param {Array} properties [description]\n * @param {[type]} value [description]\n */\n getAttributes(properties) {\n const attributes = {};\n\n if (properties === null || properties === undefined) {\n return this.getAttributes(Object.keys(this.attributes));\n }\n\n if (typeof properties === 'string') {\n return this.getAttribute([...arguments]);\n }\n\n if (!isArray(properties)) {\n throw new Error('No attribute properties provided!');\n }\n\n for (let i = 0; i < properties.length; i++) {\n const property = properties[i];\n\n if (typeof property !== 'string') {\n continue;\n }\n\n let value = this.getAttribute(property);\n\n if (typeof value?.attributes === 'object' && !isArray(value?.attributes)) {\n value = value.attributes;\n }\n\n attributes[property] = value;\n }\n\n return attributes;\n }\n\n /**\n * Serialize resource to a POJO\n *\n * @returns {Object}\n */\n serialize() {\n return this.getAttributes();\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n mergeAttributes(attributes = {}) {\n const modelAttributes = this?.attributes ?? {};\n this.attributes = { ...modelAttributes, ...attributes };\n\n return this.attributes;\n }\n\n /**\n * Merge and return attributes on the resource instance.\n *\n * @param {[type]} property [description]\n * @param {[type]} value [description]\n */\n syncAttributes(json = {}) {\n this.attributes = json;\n }\n}\n\nexport default Resource;\n","import Resource from '../resource';\nimport { StoreActions } from '../utils';\nimport { isValid as isValidDate } from 'date-fns';\n\nconst orderActions = new StoreActions({\n getDistanceAndTime: function (id, params = {}, options = {}) {\n return this.adapter.get(`${this.namespace}/${id}/distance-and-time`, params, options);\n },\n\n getNextActivity: function (id, params = {}, options = {}) {\n return this.adapter.get(`${this.namespace}/${id}/next-activity`, params, options);\n },\n\n dispatch: function (id, params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/dispatch`, params, options).then(this.afterFetch.bind(this));\n },\n\n start: function (id,params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/start`, params, options).then(this.afterFetch.bind(this));\n },\n\n updateActivity: function (id, params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/update-activity`, params, options).then(this.afterFetch.bind(this));\n },\n\n complete: function (id, params = {}, options = {}) {\n return this.adapter.post(`${this.namespace}/${id}/complete`, params, options).then(this.afterFetch.bind(this));\n },\n\n cancel: function (id, params = {}, options = {}) {\n return this.adapter.delete(`${this.namespace}/${id}/cancel`, params, options).then(this.afterFetch.bind(this));\n }\n});\n\nclass Order extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'order', { actions: orderActions, ...options });\n }\n\n getDistanceAndTime(params = {}, options = {}) {\n return this.store.getDistanceAndTime(this.id, params, options);\n }\n\n dispatch(params = {}, options = {}) {\n return this.store.dispatch(this.id, params, options);\n }\n\n start(params = {}, options = {}) {\n return this.store.start(this.id, params, options);\n }\n\n getNextActivity(params = {}, options = {}) {\n return this.store.getNextActivity(this.id, params, options);\n }\n\n updateActivity(params = {}, options = {}) {\n return this.store.updateActivity(this.id, params, options);\n }\n\n cancel(params = {}, options = {}) {\n return this.store.cancel(this.id, params, options);\n }\n\n complete(params = {}, options = {}) {\n return this.store.complete(this.id, params, options);\n }\n\n get isDispatched() {\n return this.getAttribute('dispatched_at') !== null;\n }\n\n get isNotDispatched() {\n return this.getAttribute('dispatched_at') == null;\n }\n\n get isStarted() {\n return this.getAttribute('started_at') !== null;\n }\n\n get isNotStarted() {\n return this.getAttribute('started_at') == null;\n }\n\n get isCompleted() {\n return this.getAttribute('status') == 'completed';\n }\n\n get isCanceled() {\n return this.getAttribute('status') == 'canceled';\n }\n\n get isEnroute() {\n return this.getAttribute('status') == 'driver_enroute' || this.getAttribute('status') === 'enroute';\n }\n\n get isInProgress() {\n return this.isStarted && !this.isCanceled && !this.isCompleted;\n }\n\n get scheduledAt() {\n return this.isAttributeFilled('scheduled_at') ? new Date(this.getAttribute('scheduled_at')) : null;\n }\n\n get startedAt() {\n return this.isAttributeFilled('started_at') ? new Date(this.getAttribute('started_at')) : null;\n }\n\n get dispatchedAt() {\n return this.isAttributeFilled('dispatched_at') ? new Date(this.getAttribute('dispatched_at')) : null;\n }\n\n get status() {\n return this.getAttribute('status');\n }\n}\n\nexport default Order;\n\nexport { orderActions };\n","import Resource from '../resource';\nimport Collection from '../utils/collection';\n\nclass Payload extends Resource {\n\tconstructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'payload', options);\n }\n\t\n /**\n\t * Attaches an entity to an existing payload and returns\n\t * the payload with the entity attached\n\t *\n\t * @param {[type]} Entity entity [description]\n\t * @return {[type]} [description]\n\t */\n attach(entity) {\n // perform op return payload\n }\n\n /**\n\t * Returns all of the entities attached to this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get entities() {\n\n }\n\n /**\n\t * Returns the dropoff for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get dropoff() {\n\n }\n\n /**\n\t * Returns the pickup for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get pickup() {\n\n }\n\n /**\n\t * Returns all the waypoints for this payload\n\t *\n\t * @return {[type]} [description]\n\t */\n get waypoints() {\n return new Collection(this.waypoints);\n }\n}\n\nexport default Payload;\n","import Resource from '../resource';\n\nclass Entity extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'entity', options);\n }\n}\n\nexport default Entity;\n","import Resource from '../resource';\nimport { isResource, Point } from '../utils';\n\nclass Place extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'place', options);\n }\n\n static fromGoogleAddress(googleAddress, adapter, options = {}) {\n const [ latitude, longitude ] = googleAddress.getAttribute('coordinates');\n const attributes = {\n name: null,\n address: googleAddress.getAttribute('address'),\n location: new Point(latitude, longitude),\n street1: googleAddress.getAttribute('streetName'),\n street2: null,\n city: googleAddress.getAttribute('city'),\n province: googleAddress.getAttribute('stateLong'),\n postal_code: googleAddress.getAttribute('postalCode'),\n neighborhood: googleAddress.get('neighborhood'),\n district: googleAddress.getAttribute('county'),\n building: googleAddress.get('building'),\n country: googleAddress.getAttribute('countryShort'),\n phone: null,\n security_access_code: null\n };\n\n return new Place(attributes, adapter, options);\n }\n\n /**\n * The latitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get latitude() {\n return this.getAttribute('location', new Point())?.coordinates[1];\n }\n\n /**\n * The longitude coordinate for the 'Place' location.\n * \n * @var {Integer}\n */\n get longitude() {\n return this.getAttribute('location', new Point())?.coordinates[0];\n }\n\n /**\n * Array coordinate pair for Place location.\n * \n * @var {Array}\n */\n get coordinates() {\n const { latitude, longitude } = this;\n\n return [ latitude, longitude ];\n }\n\n /**\n * Set the owner of the place.\n * \n * @param {Object|String} owner\n * @return {Place}\n */\n setOwner(owner) {\n if (isResource(owner)) {\n this.setAttribute('owner', owner.id);\n }\n\n if (typeof owner === 'string') {\n this.setAttribute('owner', owner);\n }\n\n return this;\n }\n}\n\nexport default Place;\n","import Place from './place';\n\nclass Waypoint extends Place {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'waypoint', options);\n }\n}\n\nexport default Waypoint;\n","import Resource from '../resource';\n\nclass TrackingStatus extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'tracking-status', options);\n }\n}\n\nexport default TrackingStatus;\n","import Resource from '../resource';\n\nclass Vehicle extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vehicle', options);\n }\n}\n\nexport default Vehicle;\n","import Resource from '../resource';\nimport { StoreActions, isPhone, isEmail } from '../utils';\n\nconst driverActions = new StoreActions({\n // const { error } = await fleetbase.drivers.login('+1 111-1111');\n login: function (identity, password = null, attributes = {}) {\n // handle phone number authentication\n if (isPhone(identity)) {\n return this.adapter.post('drivers/login-with-sms', { phone: identity });\n }\n\n if (!password) {\n throw new Error('Login requires password!');\n }\n\n return this.adapter.post('drivers/login', { identity, password, ...attributes }).then(this.afterFetch.bind(this));\n },\n\n verifyCode: function (identity, code, attributes = {}) {\n return this.adapter.post('drivers/verify-code', { identity, code, ...attributes }).then(this.afterFetch.bind(this));\n },\n\n retrieve: function (id) {\n return this.findRecord(id);\n },\n});\n\nclass Driver extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'driver', options);\n }\n\n get token() {\n return this.getAttribute('token');\n }\n\n get isOnline() {\n return this.getAttribute('online') === true;\n }\n\n syncDevice(token) {\n return this.adapter\n .setHeaders({ 'Driver-Token': this.token })\n .post('drivers/register-device', token)\n .then(() => {\n return this;\n });\n }\n}\n\nexport default Driver;\nexport { driverActions };\n","import Resource from '../resource';\n\nclass Vendor extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'vendor', options);\n }\n}\n\nexport default Vendor;\n","import Resource from '../resource';\n\nclass Contact extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'contact', options);\n }\n}\n\nexport default Contact;\n","import Resource from '../resource';\n\nclass Zone extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'zone', options);\n }\n}\n\nexport default Zone;\n","import Resource from '../resource';\n\nclass ServiceArea extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-area', options);\n }\n}\n\nexport default ServiceArea;\n","import Resource from '../resource';\n\nclass ServiceRate extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-rate', options);\n }\n}\n\nexport default ServiceRate;\n","import Resource from '../resource';\n\nclass ServiceQuote extends Resource {\n constructor(attributes = {}, adapter, options = {}) {\n super(attributes, adapter, 'service-quote', options);\n }\n\n fromPreliminary() {\n\n }\n\n fromPayload() {\n \n }\n}\n\nexport default ServiceQuote;\n","class Adapter {\n /**\n\t * Creates a configured base adapter for Fleetbase.\n\t *\n\t * @param {Object} config Configuration options for adapter\n\t */\n constructor(config = {}) {\n this.version = config.version || 'v1';\n this.host = config.host || null;\n this.namespace = config.namespace || null;\n this.headers = config.headers || {};\n }\n}\n\nexport default Adapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\n\nclass BrowserAdapter extends Adapter {\n /**\n * Setup browser adapter.\n * @param {Object} config\n */\n constructor(config) {\n super(config);\n\n this.setHeaders({\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;browser'\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n this.headers = { ...this.headers, ...headers };\n\n return this;\n }\n\n /**\n * Parses the JSON returned by a network request\n *\n * @param {Object} response A response from a network request\n * @return {Object} The parsed JSON, status from the response\n *\n * @return {Promise}\n */\n parseJSON(response) {\n return new Promise((resolve, reject) => response\n .json()\n .then((json) => resolve({\n statusText: response.statusText,\n status: response.status,\n ok: response.ok,\n json,\n }))\n .catch(() => {\n reject(new Error('Oops! Something went wrong when handling your request.'));\n }));\n }\n\n /**\n * The base request method\n *\n * @param {String} path\n * @param {String} method\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n request(path, method = 'GET', data = {}, options = {}) {\n return new Promise((resolve, reject) => fetch(options.url || `${this.host}/${this.namespace}/${path}`, {\n method,\n mode: options.mode || 'cors',\n headers: new Headers({\n ...(this.headers || {}),\n ...(options.headers || {}),\n }),\n ...data,\n })\n .then(this.parseJSON)\n .then((response) => {\n if (response.ok) {\n return resolve(response.json);\n }\n\n return reject(new Error(response.json.errors ? response.json.errors[0] : response.statusText));\n })\n .catch((error) => {\n reject(error);\n }));\n }\n\n /**\n * Makes a GET request with fetch\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.request(`${path}${urlParams ? `?${urlParams}` : ''}`, 'GET', {}, options);\n }\n\n /**\n * Makes a POST request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.request(path, 'POST', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a PUT request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.request(path, 'PUT', { body: JSON.stringify(data) }, options);\n }\n\n /**\n * Makes a DELETE request with fetch\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.request(path, 'DELETE', {}, options);\n }\n\n /**\n * Makes a PATCH request with fetch\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.request(path, 'PATCH', { body: JSON.stringify(data) }, options);\n }\n}\n\nexport default BrowserAdapter;\n","import Adapter from '../adapter';\nimport { isBlank } from '../utils';\nimport { isArray } from '../utils/array';\nimport axios from 'axios';\n\nclass NodeAdapter extends Adapter {\n constructor(config) {\n super(config);\n\n this.axios = axios.create({\n baseURL: `${this.host}/${this.namespace}`,\n headers: {\n Authorization: `Bearer ${config.publicKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': '@fleetbase/sdk;node',\n },\n });\n }\n\n /**\n * Updates the adapter headers.\n *\n * @param {Object} headers\n */\n setHeaders(headers = {}) {\n const commonHeaders = this.axios.defaults.headers.common;\n this.axios.defaults.headers.common = { ...commonHeaders, ...headers };\n\n return this;\n }\n\n /**\n * Tranform the response, and return the response data from axios.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n transform(response) {\n return response.data;\n }\n\n /**\n * Handles an erroneous request.\n *\n * @param {AxiosResponse} response\n * @returns {Object}\n */\n handleError(error) {\n if (error.response) {\n const { data } = error.response;\n\n if (isArray(data.errors)) {\n throw new Error(data.errors[0]);\n }\n\n if (data.error) {\n throw new Error(data.error);\n }\n }\n\n throw error;\n }\n\n /**\n * Makes a GET request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n get(path, query = {}, options = {}) {\n const urlParams = !isBlank(query) ? new URLSearchParams(query).toString() : '';\n\n return this.axios\n .get(`${path}${urlParams ? `?${urlParams}` : ''}`, options)\n .then(this.transform.bind(this))\n .catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a POST request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n post(path, data = {}, options = {}) {\n return this.axios.post(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PUT request with axios\n *\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n put(path, data = {}, options = {}) {\n return this.axios.put(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a DELETE request with axios\n *\n * @param {String} path\n * @param {Object} query\n * @param {Object} options\n *\n * @return {Promise}\n */\n delete(path, options = {}) {\n return this.axios.delete(path, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n\n /**\n * Makes a PATCH request with axios\n * @param {String} path\n * @param {Object} data\n * @param {Object} options\n *\n * @return {Promise}\n */\n patch(path, data = {}, options = {}) {\n return this.axios.patch(path, data, options).then(this.transform.bind(this)).catch(this.handleError.bind(this));\n }\n}\n\nexport default NodeAdapter;\n","import Adapter from '../adapter';\n\nclass EmberJsAdapter extends Adapter {}\n\nexport default EmberJsAdapter;\n","'use strict';\n\n/**\n * Javascript String\n *\n * instance\n * new String('hello_world').humanize().get() => \"Hello world\"\n *\n * instance\n * const string = new String();\n * string.humanize('hello_world').get() => \"Hello world\"\n * \n * no chain\n * new String('hello_world', false).humanize() => \"Hello world\"\n *\n * static\n * String.invoke('humanize', 'hello_world') => \"Hello world\"\n *\n * exports {}\n * humanize('hello_world') => \"Hello world\"\n */\n\nexport default class String {\n constructor(string, chain = true) {\n this.str = string;\n this.chain = chain;\n }\n\n uncountableWords = ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'moose', 'deer', 'news'];\n\n pluralRules = [\n [new RegExp('(m)an$', 'gi'), '$1en'],\n [new RegExp('(pe)rson$', 'gi'), '$1ople'],\n [new RegExp('(child)$', 'gi'), '$1ren'],\n [new RegExp('^(ox)$', 'gi'), '$1en'],\n [new RegExp('(ax|test)is$', 'gi'), '$1es'],\n [new RegExp('(octop|vir)us$', 'gi'), '$1i'],\n [new RegExp('(alias|status)$', 'gi'), '$1es'],\n [new RegExp('(bu)s$', 'gi'), '$1ses'],\n [new RegExp('(buffal|tomat|potat)o$', 'gi'), '$1oes'],\n [new RegExp('([ti])um$', 'gi'), '$1a'],\n [new RegExp('sis$', 'gi'), 'ses'],\n [new RegExp('(?:([^f])fe|([lr])f)$', 'gi'), '$1$2ves'],\n [new RegExp('(hive)$', 'gi'), '$1s'],\n [new RegExp('([^aeiouy]|qu)y$', 'gi'), '$1ies'],\n [new RegExp('(x|ch|ss|sh)$', 'gi'), '$1es'],\n [new RegExp('(matr|vert|ind)ix|ex$', 'gi'), '$1ices'],\n [new RegExp('([m|l])ouse$', 'gi'), '$1ice'],\n [new RegExp('(quiz)$', 'gi'), '$1zes'],\n [new RegExp('s$', 'gi'), 's'],\n [new RegExp('$', 'gi'), 's'],\n ];\n\n singularRules = [\n [new RegExp('(m)en$', 'gi'), '$1an'],\n [new RegExp('(pe)ople$', 'gi'), '$1rson'],\n [new RegExp('(child)ren$', 'gi'), '$1'],\n [new RegExp('([ti])a$', 'gi'), '$1um'],\n [new RegExp('((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$', 'gi'), '$1$2sis'],\n [new RegExp('(hive)s$', 'gi'), '$1'],\n [new RegExp('(tive)s$', 'gi'), '$1'],\n [new RegExp('(curve)s$', 'gi'), '$1'],\n [new RegExp('([lr])ves$', 'gi'), '$1f'],\n [new RegExp('([^fo])ves$', 'gi'), '$1fe'],\n [new RegExp('([^aeiouy]|qu)ies$', 'gi'), '$1y'],\n [new RegExp('(s)eries$', 'gi'), '$1eries'],\n [new RegExp('(m)ovies$', 'gi'), '$1ovie'],\n [new RegExp('(x|ch|ss|sh)es$', 'gi'), '$1'],\n [new RegExp('([m|l])ice$', 'gi'), '$1ouse'],\n [new RegExp('(bus)es$', 'gi'), '$1'],\n [new RegExp('(o)es$', 'gi'), '$1'],\n [new RegExp('(shoe)s$', 'gi'), '$1'],\n [new RegExp('(cris|ax|test)es$', 'gi'), '$1is'],\n [new RegExp('(octop|vir)i$', 'gi'), '$1us'],\n [new RegExp('(alias|status)es$', 'gi'), '$1'],\n [new RegExp('^(ox)en', 'gi'), '$1'],\n [new RegExp('(vert|ind)ices$', 'gi'), '$1ex'],\n [new RegExp('(matr)ices$', 'gi'), '$1ix'],\n [new RegExp('(quiz)zes$', 'gi'), '$1'],\n [new RegExp('s$', 'gi'), ''],\n ];\n\n nonTitlecasedWords = ['and', 'or', 'nor', 'a', 'an', 'the', 'so', 'but', 'to', 'of', 'at', 'by', 'from', 'into', 'on', 'onto', 'off', 'out', 'in', 'over', 'with', 'for'];\n\n idSuffix = new RegExp('(_ids|_id)$', 'g');\n underbar = new RegExp('_', 'g');\n spaceOrUnderbar = new RegExp('[ _]', 'g');\n uppercase = new RegExp('([A-Z])', 'g');\n underbarPrefix = new RegExp('^_');\n\n get() {\n return this.str;\n }\n\n applyRules(str, rules, skip, override) {\n if (override) {\n str = override;\n } else {\n var ignore = skip.indexOf(str.toLowerCase()) > -1;\n if (!ignore) {\n for (var x = 0; x < rules.length; x++) {\n if (str.match(rules[x][0])) {\n str = str.replace(rules[x][0], rules[x][1]);\n break;\n }\n }\n }\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.pluralize('person') -> 'people'\n String.pluralize('octopus') -> 'octopi'\n String.pluralize('Hat') -> 'Hats'\n String.pluralize('person', 'guys') -> 'guys' \n */\n pluralize(str, plural = null) {\n str = str || this.str;\n\n return this.applyRules(str, this.pluralRules, this.uncountableWords, plural);\n }\n\n /*\n String.singularize('person') -> 'person'\n String.singularize('octopi') -> 'octopus'\n String.singularize('hats') -> 'hat'\n String.singularize('guys', 'person') -> 'person'\n */\n singularize(str, singular) {\n str = str || this.str;\n\n return this.applyRules(str, this.singularRules, this.uncountableWords, singular);\n }\n\n /*\n String.camelize('message_properties') -> 'MessageProperties'\n String.camelize('message_properties', true) -> 'messageProperties'\n */\n camelize(str, lowFirstLetter) {\n str = str || this.str;\n\n let str_path = str.split('/');\n for (var i = 0; i < str_path.length; i++) {\n let str_arr = str_path[i].split('_');\n let initX = lowFirstLetter && i + 1 === str_path.length ? 1 : 0;\n\n for (let x = initX; x < str_arr.length; x++) {\n str_arr[x] = str_arr[x].charAt(0).toUpperCase() + str_arr[x].substring(1);\n }\n str_path[i] = str_arr.join('');\n }\n str = str_path.join('::');\n\n // fix\n if (lowFirstLetter === true) {\n let first = str.charAt(0).toLowerCase();\n let last = str.slice(1);\n str = first + last;\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.underscore('MessageProperties') -> 'message_properties'\n String.underscore('messageProperties') -> 'message_properties'\n */\n underscore(str) {\n str = str || this.str;\n\n var str_path = str.split('::');\n for (var i = 0; i < str_path.length; i++) {\n str_path[i] = str_path[i].replace(this.uppercase, '_$1');\n str_path[i] = str_path[i].replace(this.underbarPrefix, '');\n }\n str = str_path.join('/').toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.humanize('message_properties') -> 'Message properties'\n String.humanize('message_properties') -> 'message properties'\n */\n humanize(str, lowFirstLetter) {\n str = str || this.str;\n\n var str = str.toLowerCase();\n str = str.replace(this.idSuffix, '');\n str = str.replace(this.underbar, ' ');\n if (!lowFirstLetter) {\n str = this.capitalize(str);\n }\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.capitalize('message_properties') -> 'Message_properties'\n String.capitalize('message properties') -> 'Message properties'\n */\n capitalize(str) {\n str = str || this.str;\n\n str = str.toLowerCase();\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.dasherize('message_properties') -> 'message-properties'\n String.dasherize('message properties') -> 'message-properties'\n */\n dasherize(str) {\n str = str || this.str;\n\n str = str.replace(this.spaceOrUnderbar, '-');\n str = str.toLowerCase();\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.normify('message_properties') -> 'Message Properties'\n String.normify('message properties') -> 'Message Properties'\n Inflactor.normify('Message_propertyId', true) -> 'Message Properties Id'\n */\n normify(str, allFirstUpper) {\n str = str || this.str;\n\n //var str = str.toLowerCase();\n if (allFirstUpper === true) {\n str = this.camelize(str);\n str = this.underscore(str);\n } else {\n str = str.toLowerCase();\n }\n\n str = str.replace(this.underbar, ' ');\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var d = str_arr[x].split('-');\n for (var i = 0; i < d.length; i++) {\n if (this.nonTitlecasedWords.indexOf(d[i].toLowerCase()) < 0) {\n d[i] = this.capitalize(d[i]);\n }\n }\n str_arr[x] = d.join('-');\n }\n str = str_arr.join(' ');\n str = str.substring(0, 1).toUpperCase() + str.substring(1);\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.demodulize('Message::Bus::Properties') -> 'Properties'\n */\n demodulize(str) {\n str = str || this.str;\n\n var str_arr = str.split('::');\n str = str_arr[str_arr.length - 1];\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.tableize('MessageBusProperty') -> 'message_bus_properties'\n */\n tableize(str) {\n str = str || this.str;\n\n str = this.pluralize(this.underscore(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.classify('message_bus_properties') -> 'MessageBusProperty'\n */\n classify(str) {\n str = str || this.str;\n\n str = this.singularize(this.camelize(str));\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.foreignKey('MessageBusProperty') -> 'message_bus_property_id'\n String.foreignKey('MessageBusProperty', true) -> 'message_bus_propertyid'\n */\n foreignKey(str, dropIdUbar = false) {\n str = str || this.str;\n\n str = this.underscore(this.demodulize(str)) + (dropIdUbar ? '' : '_') + 'id';\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /*\n String.ordinalize('the 1 pitch') -> 'the 1st pitch'\n */\n ordinalize(str) {\n str = str || this.str;\n\n var str_arr = str.split(' ');\n for (var x = 0; x < str_arr.length; x++) {\n var i = parseInt(str_arr[x]);\n if (i === NaN) {\n var ltd = str_arr[x].substring(str_arr[x].length - 2);\n var ld = str_arr[x].substring(str_arr[x].length - 1);\n var suf = 'th';\n if (ltd != '11' && ltd != '12' && ltd != '13') {\n if (ld === '1') {\n suf = 'st';\n } else if (ld === '2') {\n suf = 'nd';\n } else if (ld === '3') {\n suf = 'rd';\n }\n }\n str_arr[x] += suf;\n }\n }\n str = str_arr.join(' ');\n\n // set str\n this.str = str;\n\n if (this.chain === true) {\n return this;\n }\n\n // return result\n return str;\n }\n\n /**\n * @method invoke\n **/\n static invoke() {\n const argz = Object.values(arguments);\n const instance = new String(null, false);\n const method = arguments[0];\n argz.shift();\n\n if (typeof instance[method] === 'function') {\n return instance[method](...argz);\n }\n\n return null;\n }\n}\n\nconst pluralize = function() {\n const argz = ['pluralize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst singularize = function() {\n const argz = ['singularize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst humanize = function() {\n const argz = ['humanize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst underscore = function() {\n const argz = ['underscore', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst camelize = function() {\n const argz = ['camelize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst capitalize = function() {\n const argz = ['capitalize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst dasherize = function() {\n const argz = ['dasherize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst normify = function() {\n const argz = ['normify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst demodulize = function() {\n const argz = ['demodulize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst tableize = function() {\n const argz = ['tableize', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst classify = function() {\n const argz = ['classify', ...arguments];\n\n return String.invoke(...argz);\n};\n\nconst foreignKey = function() {\n const argz = ['foreignKey', ...arguments];\n\n return String.invoke(...argz);\n};\n\nexport {\n pluralize,\n singularize,\n humanize,\n underscore,\n camelize,\n capitalize,\n dasherize,\n normify,\n demodulize,\n tableize,\n classify,\n foreignKey\n}","import { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter } from './adapters';\nimport { pluralize, singularize } from './utils/string';\n\nconst resources = {\n Contact,\n Driver,\n Entity,\n Order,\n Payload,\n Place,\n TrackingStatus,\n Vehicle,\n Vendor,\n Waypoint,\n Zone,\n ServiceArea,\n ServiceRate,\n ServiceQuote,\n};\n\nconst adapters = {\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter,\n};\n\nclass Resolver {\n constructor() {\n this.resources = resources;\n this.adapters = adapters;\n\n return this.lookup(...arguments);\n }\n\n lookup(type, className) {\n const key = pluralize(type);\n const params = [...arguments].slice(2);\n\n if (!this[key]) {\n throw new Error('Attempted to resolve invalid type');\n }\n\n if (!this[key][className]) {\n throw new Error(`No ${singularize(type)} named ${className} to resolve`);\n }\n\n return new this[key][className](...params);\n }\n}\n\nconst lookup = function () {\n return new Resolver(...arguments);\n};\n\nexport { Resolver, lookup };\n","import { lookup } from './resolver';\nimport { pluralize, classify } from './utils/string';\nimport { isArray } from './utils/array';\nimport { Collection, detectAdapter, isResource, StoreActions } from './utils';\nimport { set, isCallable, invoke } from './utils/object';\n\nconst extendStoreActions = (store, actions = []) => {\n store.actions = isArray(actions) ? actions : [actions];\n\n if (isArray(actions)) {\n for (let i = 0; i < actions.length; i++) {\n const action = actions[i];\n\n store.extendActions(action);\n }\n return;\n }\n\n if (actions instanceof StoreActions) {\n actions.extend(store);\n }\n\n return store;\n};\n\nconst afterFetch = (store, json) => {\n if (typeof store.options.onAfterFetch === 'function') {\n store.options.onAfterFetch(json);\n }\n\n if (isArray(json)) {\n const serialized = [];\n\n for (let i = 0; i < json.length; i++) {\n serialized.push(store.afterFetch(json[i]));\n }\n\n return new Collection(...serialized);\n }\n\n const resourceInstance = store.serialize(json);\n return store.deposit(resourceInstance);\n};\n\nclass Store {\n constructor(resource, adapter, options = {}) {\n this.resource = resource;\n this.adapter = adapter || detectAdapter();\n this.namespace = pluralize(resource);\n this.storage = new Collection();\n this.options = options;\n this.extendActions(options.actions);\n }\n\n extendActions(actions = []) {\n return extendStoreActions(this, actions);\n }\n\n deposit(resourceInstance) {\n // this.storage[this.namespace].pushObject(resourceInstance);\n\n return resourceInstance;\n }\n\n serialize(json) {\n return lookup('resource', classify(this.resource), json, this.adapter);\n }\n\n afterFetch(json) {\n return afterFetch(this, json);\n }\n\n create(attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.post(`${this.namespace}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n update(id, attributes = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.put(`${this.namespace}/${id}`, attributes, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findRecord(id, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n findAll(options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n query(query = {}, options = {}) {\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n queryRecord(query = {}, options = {}) {\n query.single = true;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.get(`${this.namespace}`, query, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n\n destroy(record, options = {}) {\n const id = isResource(record) ? record.getAttribute('id') : record;\n\n return new Promise(async (resolve, reject) => {\n const response = await this.adapter.delete(`${this.namespace}/${id}`, {}, options).then(this.afterFetch.bind(this)).catch(reject);\n\n resolve(response);\n });\n }\n}\n\nexport default Store;\n\nexport { extendStoreActions, afterFetch };\n","import Store from './store';\nimport Resource from './resource';\nimport { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources';\nimport { BrowserAdapter, NodeAdapter, EmberJsAdapter, Adapter } from './adapters';\nimport { isNodeEnvironment, detectAdapter, isLatitude, isLongitude, Point, isResource, GoogleAddress, Collection, StoreActions } from './utils';\nimport { pluralize, singularize, classify, dasherize, camelize } from './utils/string';\nimport { extendStoreActions } from './store';\nimport { orderActions } from './resources/order';\nimport { driverActions } from './resources/driver';\n\n/**\n * // instance\n * const fleetbase = new Fleetbase();\n *\n * const contact = fleetbase.contacts.create({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * constact.update({ name: 'Hollywood Ron' });\n *\n * // export\n * import { Contact } from '@fleetbase/sdk';\n *\n * const contact = new Contact({\n * \t\tname: 'Ron',\n * \t\tphone: '+65 9999 8888'\n * });\n *\n * contact.save();\n */\n\nexport default class Fleetbase {\n /**\n * Builds an instance of the Fleetbase SDK\n *\n * @param {String} publicKey The public key issued\n * @param {Object} config The version of resource to access\n * @param {Boolean} debug Debug mode for SDK\n * @return {Fleetbase} Instance\n */\n constructor(publicKey, config = {}, debug = false) {\n this.version = config.version || 'v1';\n this.options = {\n version: this.version,\n host: config.host || 'https://api.fleetbase.io',\n namespace: this.version || config.namespace,\n debug,\n publicKey,\n };\n\n if (typeof publicKey !== 'string' || publicKey.length === 0) {\n throw new Error('⚠️ Invalid public key given to Fleetbase SDK');\n }\n\n if (!isNodeEnvironment() && publicKey.toLowerCase().startsWith('$')) {\n throw new Error('Secret key provided. You must use a public key with Fleetbase Javascript SDK!');\n }\n\n this.adapter = config.adapter || detectAdapter(this.options);\n\n this.orders = new Store('order', this.adapter).extendActions(orderActions);\n this.entities = new Store('entity', this.adapter);\n this.places = new Store('place', this.adapter);\n this.drivers = new Store('driver', this.adapter).extendActions(driverActions);\n this.vehicles = new Store('vehicle', this.adapter);\n this.vendors = new Store('vendor', this.adapter);\n this.contacts = new Store('contact', this.adapter);\n }\n\n static newInstance() {\n return new Fleetbase(...arguments);\n }\n\n setAdapter(adapter) {\n this.adapter = adapter;\n }\n\n getAdapter() {\n return this.adapter;\n }\n}\n\nexport {\n Store,\n Resource,\n Contact,\n Driver,\n Entity,\n Order,\n Payload,\n Place,\n TrackingStatus,\n Vehicle,\n Vendor,\n Waypoint,\n Zone,\n ServiceArea,\n ServiceRate,\n ServiceQuote,\n BrowserAdapter,\n NodeAdapter,\n EmberJsAdapter,\n Adapter,\n isNodeEnvironment,\n isLatitude,\n isLongitude,\n Point,\n isResource,\n GoogleAddress,\n Collection,\n StoreActions,\n extendStoreActions,\n pluralize,\n singularize,\n classify,\n dasherize,\n camelize,\n};\n"],"names":["isArray","Array","replace","array","start","deleteCount","items","length","splice","i","chunk","slice","isCollection","arr","identityFunction","item","mixed","Collection","objectAt","index","iter","key","value","arguments","Boolean","findIndex","predicate","startAt","len","find","callback","target","bind","undefined","any","every","cb","indexOf","val","withNaNCheck","insertAt","this","indexes","map","idx","_this2","object","methodName","args","ret","forEach","push","_item$methodName","filter","sortKeys","sort","a","b","propA","propB","compareValue","compare","seen","Set","getter","get","has","add","uniqBy","includes","removeAt","obj","objects","toArray","reverse","clear","loc","removeObject","pushObject","_this3","addObject","isEmpty","none","size","objectType","isBlank","test","isLatitude","coordinate","isFinite","Math","abs","isLongitude","isResource","record","Resource","isPhone","phone","isNodeEnvironment","process","_typeof","_process","env","release","name","search","window","navigator","product","detectAdapter","options","lookup","GoogleAddress","place","geometry","components","parseComponents","attributes","parseProperties","address_components","reduce","acc","data","types","type","streetNumber","streetName","coordinates","location","Object","values","city","or","county","stateShort","stateLong","countryShort","country","countryLong","postalCode","address","join","keys","pkey","short","short_name","long_name","Point","latitude","longitude","coorindates","lat","lng","serialize","json","getResolved","func","path","resolved","current","isObject","isFunction","pathArray","split","newPath","set","iterations","StoreActions","actions","bindTo","binding","action","fn","adapter","resource","dirtyAttributes","changes","isLoading","isSaving","isDestroying","isReloading","version","setAdapter","store","Store","onAfterFetch","syncAttributes","_this$options","getAttribute","mergeAttributes","setFlags","create","then","response","_this","update","id","destroy","findRecord","_this4","reset","flags","state","validFlags","flag","Error","attribues","getAttributes","onlyDirty","savedirty","dirtyAttributeKeys","isAttributeFilled","Date","hasAttributes","isNew","isLoaded","property","_this5","call","setAttributes","previousValue","changedAt","setAttribute","attribute","defaultValue","properties","attributeKeys","prop","hasAttribute","_this6","_value","_value2","modelAttributes","orderActions","getDistanceAndTime","params","namespace","getNextActivity","dispatch","post","afterFetch","updateActivity","complete","cancel","Order","isStarted","isCanceled","isCompleted","Payload","entity","waypoints","Entity","Place","_this$getAttribute","_this$getAttribute2","owner","googleAddress","street1","street2","province","postal_code","neighborhood","district","building","security_access_code","Waypoint","TrackingStatus","Vehicle","driverActions","login","identity","password","verifyCode","code","retrieve","Driver","token","setHeaders","Vendor","Contact","Zone","ServiceArea","ServiceRate","ServiceQuote","Adapter","config","host","headers","BrowserAdapter","Authorization","publicKey","Promise","resolve","reject","statusText","status","ok","method","fetch","url","mode","Headers","parseJSON","errors","error","query","urlParams","URLSearchParams","toString","request","body","JSON","stringify","NodeAdapter","axios","baseURL","commonHeaders","defaults","common","transform","handleError","put","patch","EmberJsAdapter","String","string","chain","RegExp","str","rules","skip","override","toLowerCase","x","match","plural","applyRules","pluralRules","uncountableWords","singular","singularRules","lowFirstLetter","str_path","str_arr","charAt","toUpperCase","substring","first","last","uppercase","underbarPrefix","idSuffix","underbar","capitalize","spaceOrUnderbar","allFirstUpper","camelize","underscore","d","nonTitlecasedWords","pluralize","singularize","dropIdUbar","demodulize","NaN","parseInt","ltd","ld","suf","argz","instance","shift","invoke","dasherize","classify","resources","adapters","Resolver","className","extendStoreActions","extend","extendActions","storage","resourceInstance","serialized","deposit","single","_this7","Fleetbase","debug","startsWith","orders","entities","places","drivers","vehicles","vendors","contacts"],"mappings":"skJAAA,IAAQA,EAAYC,MAAZD,yDCWFE,EAAU,SAACC,EAAOC,EAAOC,OAAaC,yDAAQ,MAC5CN,EAAQG,MACJG,EAAMC,QANC,IAOPJ,EAAMK,aAANL,GAAaC,EAAOC,YAAgBC,SACjC,CACHH,EAAMK,OAAOJ,EAAOC,OAEf,IAAII,EAAI,EAAGA,EAAIH,EAAMC,OAAQE,GAX3B,IAW4C,KAC3CC,EAAQJ,EAAMK,MAAMF,EAAGA,EAZxB,KAaHN,EAAMK,aAANL,GAAaC,EAAQK,EAAG,YAAMC,WAG/BE,EAAaC,MACpBV,EAAMD,QAAQE,EAAOC,EAAaC,IAIpCQ,EAAmB,SAACC,UAASA,GAkB7BH,EAAe,SAACI,UAAUA,aAAiBC,GAE3CC,EAAW,SAACf,EAAOgB,UACjBnB,EAAQG,GACDA,EAAMgB,GACNP,EAAaT,GACbA,EAAMe,SAASC,GAGnB,MAGLC,EAAO,SAACC,EAAKC,UAC0B,IAArBC,EAAUhB,OACP,SAACQ,UAASO,IAAUP,EAAKM,IAAO,SAACN,UAASS,QAAQT,EAAKM,MAG5EI,EAAY,SAACtB,EAAOuB,WAAWC,yDAAU,EACvCC,EAAMzB,EAAMI,OACPY,EAAQQ,EAASR,EAAQS,EAAKT,IAAS,KACxCJ,EAAO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G,EAAWC,GAAUA,EAAO8F,aAAa,MAAQ9F,SAErD,IAAIqM,oDAAQ,WAAOC,EAASC,yGACR8F,EAAKtN,yBAAkBsN,EAAKvJ,sBAAaxC,GAAM,GAAItF,GAASkF,KAAKmM,EAAKnJ,WAAWhN,KAAKmW,UAAa9F,UAApHpG,SAENmG,EAAQnG,gHChGCmM,yBASLlG,OAAWL,yDAAS,GAAIwG,4EAC3BhN,QAAUwG,EAAOxG,SAAW,UAC5BvE,QAAU,CACXuE,QAAS5I,KAAK4I,QACdyG,KAAMD,EAAOC,MAAQ,2BACrBlD,UAAWnM,KAAK4I,SAAWwG,EAAOjD,UAClCyJ,MAAAA,EACAnG,UAAAA,GAGqB,iBAAdA,GAA+C,IAArBA,EAAU3R,aACrC,IAAIsM,MAAM,oDAGf3G,KAAuBgM,EAAU0C,cAAc0D,WAAW,WACrD,IAAIzL,MAAM,sFAGfhC,QAAUgH,EAAOhH,SAAWhE,EAAcpE,KAAKqE,cAE/CyR,OAAS,IAAI/M,GAAM,QAAS/I,KAAKoI,SAASgN,cAAcpJ,QACxD+J,SAAW,IAAIhN,GAAM,SAAU/I,KAAKoI,cACpC4N,OAAS,IAAIjN,GAAM,QAAS/I,KAAKoI,cACjC6N,QAAU,IAAIlN,GAAM,SAAU/I,KAAKoI,SAASgN,cAAcjH,SAC1D+H,SAAW,IAAInN,GAAM,UAAW/I,KAAKoI,cACrC+N,QAAU,IAAIpN,GAAM,SAAU/I,KAAKoI,cACnCgO,SAAW,IAAIrN,GAAM,UAAW/I,KAAKoI,6CAO9C,SAAWA,QACFA,QAAUA,4BAGnB,kBACWpI,KAAKoI,qCAThB,oBACeuN,6BAAa7W"} \ No newline at end of file diff --git a/package.json b/package.json index f22d1a2..96359cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/sdk", - "version": "1.2.1", + "version": "1.2.2", "description": "Fleetbase JS & Node SDK", "main": "dist/cjs/fleetbase.js", "module": "dist/esm/fleetbase.js", diff --git a/src/fleetbase.js b/src/fleetbase.js index fddad40..aae910e 100644 --- a/src/fleetbase.js +++ b/src/fleetbase.js @@ -6,6 +6,7 @@ import { isNodeEnvironment, detectAdapter, isLatitude, isLongitude, Point, isRes import { pluralize, singularize, classify, dasherize, camelize } from './utils/string'; import { extendStoreActions } from './store'; import { orderActions } from './resources/order'; +import { driverActions } from './resources/driver'; /** * // instance @@ -61,7 +62,7 @@ export default class Fleetbase { this.orders = new Store('order', this.adapter).extendActions(orderActions); this.entities = new Store('entity', this.adapter); this.places = new Store('place', this.adapter); - this.drivers = new Store('driver', this.adapter); + this.drivers = new Store('driver', this.adapter).extendActions(driverActions); this.vehicles = new Store('vehicle', this.adapter); this.vendors = new Store('vendor', this.adapter); this.contacts = new Store('contact', this.adapter); diff --git a/src/resolver.js b/src/resolver.js index 2e71830..23ab3dc 100644 --- a/src/resolver.js +++ b/src/resolver.js @@ -1,21 +1,32 @@ -import { Place, Payload, Order } from './resources'; +import { Contact, Driver, Entity, Order, Payload, Place, TrackingStatus, Vehicle, Vendor, Waypoint, Zone, ServiceArea, ServiceRate, ServiceQuote } from './resources'; import { BrowserAdapter, NodeAdapter, EmberJsAdapter } from './adapters'; import { pluralize, singularize } from './utils/string'; const resources = { - Place, + Contact, + Driver, + Entity, + Order, Payload, - Order + Place, + TrackingStatus, + Vehicle, + Vendor, + Waypoint, + Zone, + ServiceArea, + ServiceRate, + ServiceQuote, }; const adapters = { BrowserAdapter, NodeAdapter, - EmberJsAdapter + EmberJsAdapter, }; class Resolver { - constructor () { + constructor() { this.resources = resources; this.adapters = adapters; @@ -24,7 +35,7 @@ class Resolver { lookup(type, className) { const key = pluralize(type); - const params = [ ...arguments ].slice(2); + const params = [...arguments].slice(2); if (!this[key]) { throw new Error('Attempted to resolve invalid type'); @@ -38,11 +49,8 @@ class Resolver { } } -const lookup = function() { +const lookup = function () { return new Resolver(...arguments); }; -export { - Resolver, - lookup -}; +export { Resolver, lookup }; diff --git a/src/resource.js b/src/resource.js index f446de2..954bd6a 100644 --- a/src/resource.js +++ b/src/resource.js @@ -195,13 +195,22 @@ class Resource { return this.update(dirtyAttributes); } + /** + * Returns the resource meta if exists. + * + * @return {Object} + */ + get meta() { + return this.getAttribute('meta', {}); + } + /** * Returns the date instance resource was created. * * @return {Date} */ get createdAt() { - return this.hasAttribute('created_at') ? new Date(this.getAttribute('created_at')) : null; + return this.isAttributeFilled('created_at') ? new Date(this.getAttribute('created_at')) : null; } /** @@ -210,7 +219,7 @@ class Resource { * @return {Date} */ get updatedAt() { - return this.hasAttribute('updated_at') ? new Date(this.getAttribute('updated_at')) : null; + return this.isAttributeFilled('updated_at') ? new Date(this.getAttribute('updated_at')) : null; } /** diff --git a/src/resources/driver.js b/src/resources/driver.js index 6cf615e..1e06257 100644 --- a/src/resources/driver.js +++ b/src/resources/driver.js @@ -1,9 +1,52 @@ import Resource from '../resource'; +import { StoreActions, isPhone, isEmail } from '../utils'; + +const driverActions = new StoreActions({ + // const { error } = await fleetbase.drivers.login('+1 111-1111'); + login: function (identity, password = null, attributes = {}) { + // handle phone number authentication + if (isPhone(identity)) { + return this.adapter.post('drivers/login-with-sms', { phone: identity }); + } + + if (!password) { + throw new Error('Login requires password!'); + } + + return this.adapter.post('drivers/login', { identity, password, ...attributes }).then(this.afterFetch.bind(this)); + }, + + verifyCode: function (identity, code, attributes = {}) { + return this.adapter.post('drivers/verify-code', { identity, code, ...attributes }).then(this.afterFetch.bind(this)); + }, + + retrieve: function (id) { + return this.findRecord(id); + }, +}); class Driver extends Resource { constructor(attributes = {}, adapter, options = {}) { super(attributes, adapter, 'driver', options); } + + get token() { + return this.getAttribute('token'); + } + + get isOnline() { + return this.getAttribute('online') === true; + } + + syncDevice(token) { + return this.adapter + .setHeaders({ 'Driver-Token': this.token }) + .post('drivers/register-device', token) + .then(() => { + return this; + }); + } } export default Driver; +export { driverActions }; diff --git a/src/resources/order.js b/src/resources/order.js index 635c96c..887a28e 100644 --- a/src/resources/order.js +++ b/src/resources/order.js @@ -1,10 +1,35 @@ import Resource from '../resource'; import { StoreActions } from '../utils'; +import { isValid as isValidDate } from 'date-fns'; const orderActions = new StoreActions({ - getDistanceAndTime: function (id, options = {}) { - return this.adapter.get(`${this.namespace}/${id}/distance-and-time`, {}, options); + getDistanceAndTime: function (id, params = {}, options = {}) { + return this.adapter.get(`${this.namespace}/${id}/distance-and-time`, params, options); }, + + getNextActivity: function (id, params = {}, options = {}) { + return this.adapter.get(`${this.namespace}/${id}/next-activity`, params, options); + }, + + dispatch: function (id, params = {}, options = {}) { + return this.adapter.post(`${this.namespace}/${id}/dispatch`, params, options).then(this.afterFetch.bind(this)); + }, + + start: function (id,params = {}, options = {}) { + return this.adapter.post(`${this.namespace}/${id}/start`, params, options).then(this.afterFetch.bind(this)); + }, + + updateActivity: function (id, params = {}, options = {}) { + return this.adapter.post(`${this.namespace}/${id}/update-activity`, params, options).then(this.afterFetch.bind(this)); + }, + + complete: function (id, params = {}, options = {}) { + return this.adapter.post(`${this.namespace}/${id}/complete`, params, options).then(this.afterFetch.bind(this)); + }, + + cancel: function (id, params = {}, options = {}) { + return this.adapter.delete(`${this.namespace}/${id}/cancel`, params, options).then(this.afterFetch.bind(this)); + } }); class Order extends Resource { @@ -12,11 +37,83 @@ class Order extends Resource { super(attributes, adapter, 'order', { actions: orderActions, ...options }); } - getDistanceAndTime() { - return this.store.getDistanceAndTime(this.id); + getDistanceAndTime(params = {}, options = {}) { + return this.store.getDistanceAndTime(this.id, params, options); + } + + dispatch(params = {}, options = {}) { + return this.store.dispatch(this.id, params, options); + } + + start(params = {}, options = {}) { + return this.store.start(this.id, params, options); + } + + getNextActivity(params = {}, options = {}) { + return this.store.getNextActivity(this.id, params, options); + } + + updateActivity(params = {}, options = {}) { + return this.store.updateActivity(this.id, params, options); + } + + cancel(params = {}, options = {}) { + return this.store.cancel(this.id, params, options); + } + + complete(params = {}, options = {}) { + return this.store.complete(this.id, params, options); + } + + get isDispatched() { + return this.getAttribute('dispatched_at') !== null; + } + + get isNotDispatched() { + return this.getAttribute('dispatched_at') == null; + } + + get isStarted() { + return this.getAttribute('started_at') !== null; + } + + get isNotStarted() { + return this.getAttribute('started_at') == null; + } + + get isCompleted() { + return this.getAttribute('status') == 'completed'; + } + + get isCanceled() { + return this.getAttribute('status') == 'canceled'; + } + + get isEnroute() { + return this.getAttribute('status') == 'driver_enroute' || this.getAttribute('status') === 'enroute'; + } + + get isInProgress() { + return this.isStarted && !this.isCanceled && !this.isCompleted; + } + + get scheduledAt() { + return this.isAttributeFilled('scheduled_at') ? new Date(this.getAttribute('scheduled_at')) : null; + } + + get startedAt() { + return this.isAttributeFilled('started_at') ? new Date(this.getAttribute('started_at')) : null; + } + + get dispatchedAt() { + return this.isAttributeFilled('dispatched_at') ? new Date(this.getAttribute('dispatched_at')) : null; + } + + get status() { + return this.getAttribute('status'); } } export default Order; -export { orderActions }; \ No newline at end of file +export { orderActions }; diff --git a/src/utils/index.js b/src/utils/index.js index c588d18..9a4c2d8 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -4,6 +4,8 @@ import isEmpty from './is-empty'; import isLatitude from './is-latitude'; import isLongitude from './is-longitude'; import isResource from './is-resource'; +import isPhone from './is-phone'; +import isEmail from './is-email'; import isNodeEnvironment from './is-node-environment'; import detectAdapter from './detect-adapter'; import uuid from './uuid'; @@ -20,6 +22,8 @@ export { isLatitude, isLongitude, isResource, + isPhone, + isEmail, uuid, GoogleAddress, StoreActions, diff --git a/src/utils/is-email.js b/src/utils/is-email.js new file mode 100644 index 0000000..f418363 --- /dev/null +++ b/src/utils/is-email.js @@ -0,0 +1,5 @@ +const isEmail = (email = '') => { + return /\S+@\S+\.\S+/.test(email); +} + +export default isEmail; \ No newline at end of file diff --git a/src/utils/is-phone.js b/src/utils/is-phone.js new file mode 100644 index 0000000..509913d --- /dev/null +++ b/src/utils/is-phone.js @@ -0,0 +1,5 @@ +const isPhone = (phone = '') => { + return /^[+]?[\s./0-9]*[(]?[0-9]{1,4}[)]?[-\s./0-9]*$/g.test(phone); +} + +export default isPhone; \ No newline at end of file