UNPKG

evrythng-extended

Version:

Javascript SDK to communicate with EVRYTHNG REST API

10 lines (8 loc) 47.1 kB
// EVRYTHNG JS SDK v4.7.2 // (c) 2012-2017 EVRYTHNG Ltd. London / New York / San Francisco. // Released under the Apache Software License, Version 2.0. // For all details and usage: // https://github.com/evrythng/evrythng.js !function(a){"use strict";function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return g._invoke=j(a,c,h),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(a){["next","throw","return"].forEach(function(b){a[b]=function(a){return this._invoke(b,a)}})}function h(a){this.arg=a}function i(a){function b(d,e,f,g){var i=c(a[d],a,e);if("throw"!==i.type){var j=i.arg,k=j.value;return k instanceof h?Promise.resolve(k.arg).then(function(a){b("next",a,f,g)},function(a){b("throw",a,f,g)}):Promise.resolve(k).then(function(a){j.value=a,f(j)},g)}g(i.arg)}function d(a,c){function d(){return new Promise(function(d,e){b(a,c,d,e)})}return e=e?e.then(d,d):d()}"object"==typeof process&&process.domain&&(b=process.domain.bind(b));var e;this._invoke=d}function j(a,b,d){var e=w;return function(f,g){if(e===y)throw new Error("Generator is already running");if(e===z){if("throw"===f)throw g;return o()}for(;;){var h=d.delegate;if(h){if("return"===f||"throw"===f&&h.iterator[f]===p){d.delegate=null;var i=h.iterator.return;if(i){var j=c(i,h.iterator,g);if("throw"===j.type){f="throw",g=j.arg;continue}}if("return"===f)continue}var j=c(h.iterator[f],h.iterator,g);if("throw"===j.type){d.delegate=null,f="throw",g=j.arg;continue}f="next",g=p;var k=j.arg;if(!k.done)return e=x,k;d[h.resultName]=k.value,d.next=h.nextLoc,d.delegate=null}if("next"===f)d.sent=d._sent=g;else if("throw"===f){if(e===w)throw e=z,g;d.dispatchException(g)&&(f="next",g=p)}else"return"===f&&d.abrupt("return",g);e=y;var j=c(a,b,d);if("normal"===j.type){e=d.done?z:x;var k={value:j.arg,done:d.done};if(j.arg!==A)return k;d.delegate&&"next"===f&&(g=p)}else"throw"===j.type&&(e=z,f="throw",g=j.arg)}}}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=p,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:p,done:!0}}var p,q=Object.prototype.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.toStringTag||"@@toStringTag",u="object"==typeof module,v=a.regeneratorRuntime;if(v)return void(u&&(module.exports=v));v=a.regeneratorRuntime=u?module.exports:{},v.wrap=b;var w="suspendedStart",x="suspendedYield",y="executing",z="completed",A={},B=f.prototype=d.prototype;e.prototype=B.constructor=f,f.constructor=e,f[t]=e.displayName="GeneratorFunction",v.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},v.mark=function(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,f):(a.__proto__=f,t in a||(a[t]="GeneratorFunction")),a.prototype=Object.create(B),a},v.awrap=function(a){return new h(a)},g(i.prototype),v.async=function(a,c,d,e){var f=new i(b(a,c,d,e));return v.isGeneratorFunction(c)?f:f.next().then(function(a){return a.done?a.value:f.next()})},g(B),B[s]=function(){return this},B[t]="Generator",B.toString=function(){return"[object Generator]"},v.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},v.values=n,m.prototype={constructor:m,reset:function(a){if(this.prev=0,this.next=0,this.sent=this._sent=p,this.done=!1,this.delegate=null,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=p)},stop:function(){this.done=!0;var a=this.tryEntries[0],b=a.completion;if("throw"===b.type)throw b.arg;return this.rval},dispatchException:function(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;d>=0;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(g){if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}}}},abrupt:function(a,b){for(var c=this.tryEntries.length-1;c>=0;--c){var d=this.tryEntries[c];if(d.tryLoc<=this.prev&&q.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var e=d;break}}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?this.next=e.finallyLoc:this.complete(f),A},complete:function(a,b){if("throw"===a.type)throw a.arg;"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=a.arg,this.next="end"):"normal"===a.type&&b&&(this.next=b)},finish:function(a){for(var b=this.tryEntries.length-1;b>=0;--b){var c=this.tryEntries[b];if(c.finallyLoc===a)return this.complete(c.completion,c.afterLoc),l(c),A}},catch:function(a){for(var b=this.tryEntries.length-1;b>=0;--b){var c=this.tryEntries[b];if(c.tryLoc===a){var d=c.completion;if("throw"===d.type){var e=d.arg;l(c)}return e}}throw new Error("illegal catch attempt")},delegateYield:function(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},A}}}("object"==typeof global?global:"object"==typeof window?window:"object"==typeof self?self:this),function(a,b){module.exports=function(a,b){var c,d,e;return function(a){function b(a,b){return v.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o=b&&b.split("/"),p=t.map,q=p&&p["*"]||{};if(a){for(a=a.split("/"),g=a.length-1,t.nodeIdCompat&&x.test(a[g])&&(a[g]=a[g].replace(x,"")),"."===a[0].charAt(0)&&o&&(n=o.slice(0,o.length-1),a=n.concat(a)),k=0;k<a.length;k++)if("."===(m=a[k]))a.splice(k,1),k-=1;else if(".."===m){if(0===k||1===k&&".."===a[2]||".."===a[k-1])continue;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}if((o||q)&&p){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),o)for(l=o.length;l>0;l-=1)if((e=p[o.slice(0,l).join("/")])&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&q&&q[d]&&(i=q[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(b,c){return function(){var d=w.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),o.apply(a,d.concat([b,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){r[a]=b}}function j(c){if(b(s,c)){var d=s[c];delete s[c],u[c]=!0,n.apply(a,d)}if(!b(r,c)&&!b(u,c))throw new Error("No "+c);return r[c]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return a?k(a):[]}function m(a){return function(){return t&&t.config&&t.config[a]||{}}}var n,o,p,q,r={},s={},t={},u={},v=Object.prototype.hasOwnProperty,w=[].slice,x=/\.js$/;p=function(a,b){var c,d=k(a),e=d[0],g=b[1];return a=d[1],e&&(e=f(e,g),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(g)):f(a,g):(a=f(a,g),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},q={require:function(a){return g(a)},exports:function(a){var b=r[a];return void 0!==b?b:r[a]={}},module:function(a){return{id:a,uri:"",exports:r[a],config:m(a)}}},n=function(c,d,e,f){var h,k,m,n,o,t,v,w=[],x=typeof e;if(f=f||c,t=l(f),"undefined"===x||"function"===x){for(d=!d.length&&e.length?["require","exports","module"]:d,o=0;o<d.length;o+=1)if(n=p(d[o],t),"require"===(k=n.f))w[o]=q.require(c);else if("exports"===k)w[o]=q.exports(c),v=!0;else if("module"===k)h=w[o]=q.module(c);else if(b(r,k)||b(s,k)||b(u,k))w[o]=j(k);else{if(!n.p)throw new Error(c+" missing "+k);n.p.load(n.n,g(f,!0),i(k),{}),w[o]=r[k]}m=e?e.apply(r[c],w):void 0,c&&(h&&h.exports!==a&&h.exports!==r[c]?r[c]=h.exports:m===a&&v||(r[c]=m))}else c&&(r[c]=e)},c=d=o=function(b,c,d,e,f){if("string"==typeof b)return q[b]?q[b](c):j(p(b,l(c)).f);if(!b.splice){if(t=b,t.deps&&o(t.deps,t.callback),!c)return;c.splice?(b=c,c=d,d=null):b=a}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?n(a,b,c,d):setTimeout(function(){n(a,b,c,d)},4),o},o.config=function(a){return o(a)},c._defined=r,e=function(a,c,d){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");c.splice||(d=c,c=[]),b(r,a)||b(s,a)||(s[a]=[a,c,d])},e.amd={jQuery:!0}}(),e("almond",function(){}),function(a,b,c){b[a]=b[a]||c(),"function"==typeof e&&e.amd?e("promise",[],function(){return b[a]}):"undefined"!=typeof module&&module.exports&&(module.exports=b[a])}("Promise","undefined"!=typeof global?global:this,function(){"use strict";function a(a,b){m.add(a,b),l||(l=o(m.drain))}function b(a){var b,c=typeof a;return null==a||"object"!=c&&"function"!=c||(b=a.then),"function"==typeof b&&b}function c(){for(var a=0;a<this.chain.length;a++)d(this,1===this.state?this.chain[a].success:this.chain[a].failure,this.chain[a]);this.chain.length=0}function d(a,c,d){var e,f;try{!1===c?d.reject(a.msg):(e=!0===c?a.msg:c.call(void 0,a.msg),e===d.promise?d.reject(TypeError("Promise-chain cycle")):(f=b(e))?f.call(e,d.resolve,d.reject):d.resolve(e))}catch(a){d.reject(a)}}function e(d){var g,i,j=this;if(!j.triggered){j.triggered=!0,j.def&&(j=j.def);try{(g=b(d))?(i=new h(j),g.call(d,function(){e.apply(i,arguments)},function(){f.apply(i,arguments)})):(j.msg=d,j.state=1,j.chain.length>0&&a(c,j))}catch(a){f.call(i||new h(j),a)}}}function f(b){var d=this;d.triggered||(d.triggered=!0,d.def&&(d=d.def),d.msg=b,d.state=2,d.chain.length>0&&a(c,d))}function g(a,b,c,d){for(var e=0;e<b.length;e++)!function(e){a.resolve(b[e]).then(function(a){c(e,a)},d)}(e)}function h(a){this.def=a,this.triggered=!1}function i(a){this.promise=a,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function j(b){if("function"!=typeof b)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var d=new i(this);this.then=function(b,e){var f={success:"function"!=typeof b||b,failure:"function"==typeof e&&e};return f.promise=new this.constructor(function(a,b){if("function"!=typeof a||"function"!=typeof b)throw TypeError("Not a function");f.resolve=a,f.reject=b}),d.chain.push(f),0!==d.state&&a(c,d),f.promise},this.catch=function(a){return this.then(void 0,a)};try{b.call(void 0,function(a){e.call(d,a)},function(a){f.call(d,a)})}catch(a){f.call(d,a)}}var k,l,m,n=Object.prototype.toString,o="undefined"!=typeof setImmediate?function(a){return setImmediate(a)}:setTimeout;try{Object.defineProperty({},"x",{}),k=function(a,b,c,d){return Object.defineProperty(a,b,{value:c,writable:!0,configurable:!1!==d})}}catch(a){k=function(a,b,c){return a[b]=c,a}}m=function(){function a(a,b){this.fn=a,this.self=b,this.next=void 0}var b,c,d;return{add:function(e,f){d=new a(e,f),c?c.next=d:b=d,c=d,d=void 0},drain:function(){var a=b;for(b=c=l=void 0;a;)a.fn.call(a.self),a=a.next}}}();var p=k({},"constructor",j,!1);return j.prototype=p,k(p,"__NPO__",0,!1),k(j,"resolve",function(a){var b=this;return a&&"object"==typeof a&&1===a.__NPO__?a:new b(function(b,c){if("function"!=typeof b||"function"!=typeof c)throw TypeError("Not a function");b(a)})}),k(j,"reject",function(a){return new this(function(b,c){if("function"!=typeof b||"function"!=typeof c)throw TypeError("Not a function");c(a)})}),k(j,"all",function(a){var b=this;return"[object Array]"!=n.call(a)?b.reject(TypeError("Not an array")):0===a.length?b.resolve([]):new b(function(c,d){if("function"!=typeof c||"function"!=typeof d)throw TypeError("Not a function");var e=a.length,f=Array(e),h=0;g(b,a,function(a,b){f[a]=b,++h===e&&c(f)},d)})}),k(j,"race",function(a){var b=this;return"[object Array]"!=n.call(a)?b.reject(TypeError("Not an array")):new b(function(c,d){if("function"!=typeof c||"function"!=typeof d)throw TypeError("Not a function");g(b,a,function(a,b){c(b)},d)})}),j}),e("utils",["promise"],function(a){"use strict";return{isDefined:function(a){return void 0!==a},isFunction:function(a){return"[object Function]"==Object.prototype.toString.call(a)},isString:function(a){return"[object String]"==Object.prototype.toString.call(a)},isArray:function(a){return"[object Array]"==Object.prototype.toString.call(a)},isObject:function(a){return a===Object(a)&&!this.isArray(a)},extend:function(a,b,c){var d;if(c)d=a;else{d={};for(var e in a)a.hasOwnProperty(e)&&(d[e]=a[e])}for(var f in b)b.hasOwnProperty(f)&&(d[f]=b[f]);return d},extendCurried:function(a){var b=this;return function(c){return b.extend(a,c,!0)}},buildParams:function(a,b){if(this.isObject(a)){var c=[];for(var d in a)if(a.hasOwnProperty(d)&&void 0!==a[d]){var e=this.isObject(a[d])?this.buildParams(a[d],!0):a[d];c.push((b?d:encodeURIComponent(d))+"="+(b?this.escapeSpecials(e):encodeURIComponent(e)))}return c.join("&")}return a},buildUrl:function(a){var b=a.apiUrl+(a.url?a.url:"");return a.params&&(b+=(-1===b.indexOf("?")?"?":"&")+this.buildParams(a.params)),b},getCurrentPosition:function(b){if("undefined"!=typeof window&&window.navigator.geolocation){var c=this.extend({maximumAge:0,timeout:1e4,enableHighAccuracy:!0},b);return new a(function(a,b){window.navigator.geolocation.getCurrentPosition(function(b){a(b)},function(a){var c="Geolocation: ";c=1===a.code?"You didn't share your location.":2===a.code?"Couldn't detect your current location.":3===a.code?"Retrieving position timed out.":"Unknown error.",b(c)},c)})}return new a(function(a,b){b("Your browser/environment doesn't support geolocation.")})},escapeSpecials:function(a){var b=["&","|","!",">","<","=","~","(",")",","],c=new RegExp("["+b.join("\\")+"]","g");return a&&"string"==typeof a&&(a=a.replace(c,"\\$&")),a},parseLinkHeader:function(a){var b={};if(a&&a.length)for(var c=a.split(","),d=0;d<c.length;d++){var e=c[d].split(";");if(2!==e.length)throw new Error("section could not be split on ';'");var f=e[0].replace(/<(.*)>/,"$1").trim(),g=e[1].replace(/rel="(.*)"/,"$1").trim();b[g]=f}return b},spawn:function(b){function c(c,f){var g;try{g=b[c](f)}catch(b){return a.reject(b)}return g.done?g.value:a.resolve(g.value).then(d,e)}var d=c.bind(c,"next"),e=c.bind(c,"throw");return d()},forEachAsync:function(b,c){return new a(function(a){function d(){return b.next().then(function(a){return a.done?a.value:(c(a.value,e++),d())})}var e=0;a(d())})}}}),e("core",["utils"],function(a){"use strict";return{version:"4.7.2",settings:{apiUrl:"https://api.evrythng.com",fullResponse:!1,quiet:!1,geolocation:!0,interceptors:[]},Utils:a,Entity:{},setup:function(b){if(!a.isObject(b))throw new TypeError("Setup should be called with an options object.");return this.settings=a.extend(this.settings,b),this.settings},use:function(b){if(a.isObject(b)&&a.isFunction(b.install)){var c=[];return b.$inject&&b.$inject.forEach(function(a){c.push(d(a))}),b.install.apply(b,c),this}throw new TypeError("Plugin must implement 'install()' method.")}}}),e("logger",["core"],function(a){"use strict";return{error:function(b){!1===a.settings.quiet&&console.error("EvrythngJS Error:",b)},info:function(b){!1===a.settings.quiet&&console.info("EvrythngJS Info:",b)},warnCallbackDeprecation:function(){!1===a.settings.quiet&&console.warn("EvrythngJS Warning: Callbacks are deprecated, and are scheduled to be removed in the next major release of the library. Please, use the Promise API instead.")}}}),e("network/request",["core","promise","utils","logger"],function(a,c,d,e){"use strict";function f(a,b){var c=a.headers,d=a.body||null;if(d){var e=c["content-type"];if(e&&-1!==e.indexOf("application/json"))try{d=JSON.parse(d)}catch(a){}}return b&&(d={data:d,headers:c,status:a.statusCode},d.data&&d.data.errors&&(d.errors=d.data.errors,delete d.data.errors)),d}function g(a,b,c,d){var e=d||{};return e.status=a.statusCode,e.url=b,e.method=c,e}function h(a,h,i){a=a||{};var j=d.buildUrl(a),k=a.method||"get",l={url:j,method:k,headers:a.headers};return l.body=a.data?JSON.stringify(a.data):null,a.timeout>0&&(l.timeout=a.timeout),new c(function(c,d){try{b(l,function(b,l){if(b)d(b);else{var m=f(l,a.fullResponse);if(l.statusCode>=200&&l.statusCode<300)h&&(e.warnCallbackDeprecation(),h(m)),c(m);else{var n=g(l,j,k,m);i&&(e.warnCallbackDeprecation(),i(n)),d(n)}}})}catch(a){d(a)}})}return h}),e("transport",["network/request"],function(a){"use strict";return function(c,d,e){if("function"!=typeof b)throw new Error("Request module not available.");return a(c,d,e)}}),e("api",["core","transport","promise","utils"],function(a,b,c,d){"use strict";function e(e,f,g){function h(){n=!0}var i=d.extend({apiUrl:a.settings.apiUrl,url:"",fullResponse:a.settings.fullResponse,authorization:a.settings.apiKey||a.settings.authorization,timeout:a.settings.timeout,interceptors:a.settings.interceptors},e);i.headers=d.extend({authorization:i.authorization,accept:"*/*","content-type":"application/json"},e.headers);var j,k,l,m,n=!1;return l=c.resolve(i),d.isFunction(f)?j=f:e&&d.isFunction(e.success)&&(j=e.success),d.isFunction(g)?k=g:e&&d.isFunction(e.error)&&(k=e.error),d.isArray(i.interceptors)&&i.interceptors.forEach(function(a){a.request&&d.isFunction(a.request)&&(l=l.then(function(b){return n?b:a.request(b,h)||b}))}),l.then(function(a){return n?c.reject({errors:["Request cancelled on request interceptors."],cancelled:!0}):(m=b(a,j,k),d.isArray(a.interceptors)&&a.interceptors.forEach(function(a){a.response&&d.isFunction(a.response)&&(m=m.then(a.response))}),m)})}return a.api=e,a}),e("scope/scope",["core","utils"],function(a,b){"use strict";return function(c){if(this.parentScope=null,!b.isString(c))throw new TypeError("Scope constructor should be called with API Key.");this.apiKey=c,this.$init=a.api({url:"/access",authorization:this.apiKey})}}),e("iterator",["utils"],function(a){"use strict";return function(b){return regeneratorRuntime.mark(function c(d){var e,f,g;return regeneratorRuntime.async(function(c){for(;;)switch(c.prev=c.next){case 0:return g=function(b){return regeneratorRuntime.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,regeneratorRuntime.awrap(b);case 2:return e=c.sent,f=a.parseLinkHeader(e.headers.link),c.abrupt("return",e.data);case 5:case"end":return c.stop()}},null,this)},d=d||{},d.params=a.extend({sortOrder:"DESCENDING"},d.params),c.next=5,g(b.call(this,{url:this.path,fullResponse:!0},d));case 5:if(!f.next){c.next=10;break}return c.next=8,g(b.call(this,{apiUrl:decodeURIComponent(f.next),fullResponse:!0}));case 8:c.next=5;break;case 10:case"end":return c.stop()}},c,this)})}}),e("resource",["core","promise","iterator","scope/scope","utils","logger"],function(a,b,c,d,e,f){"use strict";function g(b,c,d,f){var g,i=d,j=f;return e.isFunction(c)||null===c?(i=c,j=d):e.isObject(c)&&(b=e.extend(b,c)),b.authorization=this.scope.apiKey,a.Operator&&this.scope.parentScope instanceof a.Operator&&(b.authorization=this.scope.parentScope.apiKey,this.scope instanceof a.App&&(b.params=b.params||{},b.params.project=this.scope.project)),g=a.api(b,i,j),h.call(this,g)}function h(a){var b=this;return a.then(function(a){return b.parse(a)})}var i=function(a,b,c){if(!(a&&a instanceof d))throw new TypeError("Scope should inherit from Scope (e.g. EVT.App).");if(this.scope=a,!e.isString(b))throw new TypeError("Resource must have a String path.");"/"!=b[0]&&(b="/"+b),this.path=b,e.isFunction(c)?e.isFunction(c.prototype.toJSON)?this.class=c:f.error('Class for resource "'+b+'" does not implement toJSON().'):f.info('Class for resource "'+b+'" undefined. It will not return proper Entities nor cascaded Entities.')};return i.prototype.parse=function(a){var b=null;if(this.class&&a){var c=this;if(e.isArray(a))b=a.map(this.parse,this);else if(e.isObject(a))if(a.hasOwnProperty("data"))b=a,b.data=c.parse(b.data),e.isObject(b.headers)&&e.isString(b.headers["x-result-count"])&&(b.count=parseInt(b.headers["x-result-count"]));else{var d,f=this.path;a.id&&(f+=-1===f.indexOf(a.id)?"/"+a.id:""),d=new i(this.scope,f,this.class),b=new this.class(a,d)}else b=a}else b=a;return b},i.prototype.jsonify=function(a){return this.class&&a instanceof this.class?a.toJSON():a||{}},i.prototype.create=function(a,b,c,d){if(!a||e.isFunction(a))throw new TypeError("Create method should have payload.");var f={url:this.path,method:"post",data:this.jsonify(a)};return g.call(this,f,b,c,d)},i.prototype.read=function(a,b,c){var d={url:this.path};return g.call(this,d,a,b,c)},i.prototype.update=function(a,b,c,d){var e={url:this.path,method:"put",data:this.jsonify(a)};return g.call(this,e,b,c,d)},i.prototype.delete=function(a,b,c){var d={url:this.path,method:"delete"};return g.call(this,d,a,b,c)},i.prototype.iterator=c(g),i.constructorFactory=function(a,b,c){return function(d){var f=a||"";if(d){if(!e.isString(d))throw new TypeError("ID must be a string.");f+="/"+encodeURIComponent(d)}var g=new i(this,f,b);if(c){var h=new b({id:d},g);if(!e.isArray(c))throw new TypeError("Nested resources should be an array.");c.forEach(function(a){h[a]&&(g[a]=function(){return h[a].apply(h,arguments)})})}return g}},i}),e("entity/entity",["resource","utils"],function(a,b){"use strict";var c=function(c,d){b.isObject(c)&&(c instanceof a?this.resource=c:(this.resource=d,b.extend(this,c,!0)))};return c.prototype.toJSON=function(){var a={};for(var c in this)this.hasOwnProperty(c)&&b.isDefined(this[c])&&!b.isFunction(this[c])&&"resource"!=c&&(a[c]=this[c]);return a},c.prototype.update=function(a){if(this.resource){var c=arguments,d=this;return null!==a&&a&&!b.isFunction(a)||(c=Array.prototype.slice.call(arguments,0),c.unshift(this.toJSON())),this.resource.update.apply(this.resource,c).then(function(a){return b.extend(d,a,!0),a})}throw new Error("This entity has no resource")},c.prototype.delete=function(){if(this.resource)return this.resource.delete.apply(this.resource,arguments);throw new Error("This entity has no resource")},c}),e("entity/property",["core","./entity","resource","utils"],function(a,b,c,d){"use strict";function e(a){var b=a[0];if(d.isString(b)||"number"==typeof b||"boolean"==typeof b)a[0]=[{value:b}];else if(d.isObject(b))if(d.isDefined(b.value))a[0]=[b];else{a[0]=[];for(var c in b)a[0].push({key:c,value:b[c]})}return a}var f=function(){b.apply(this,arguments)};return f.prototype=Object.create(b.prototype),f.prototype.constructor=f,a.Entity.Property=f,{class:f,resourceConstructor:function(b){if(!this.resource)throw new Error("This Entity does not have a Resource.");var f,g=this.resource.path+"/properties";if(b){if(!d.isString(b))throw new TypeError("Property must be a key/name string");g+="/"+encodeURIComponent(b)}return f=new c(this.resource.scope,g,a.Entity.Property),f.create=function(){return c.prototype.create.apply(this,e(arguments))},f.update=function(){return c.prototype.update.apply(this,e(arguments))},f}}}),e("entity/action",["core","./entity","scope/scope","resource","utils","logger"],function(a,b,c,d,e,f){"use strict";function g(a){var b=arguments;return a&&!e.isFunction(a)||(b=Array.prototype.slice.call(arguments,0),b.unshift({})),b}function h(b,c){return b.constructor===a.Entity.Product?c.product=b.id:b.constructor===a.Entity.Thng?c.thng=b.id:b.constructor===a.Entity.Collection&&(c.collection=b.id),c}function i(a,b,d){if(!(a instanceof c||a.id))throw new Error("This entity does not have an ID.");var f=b;return e.isArray(b)?f=b.map(function(b){return i(a,b,d)}):(f.type="all"!==d&&d||b.type||"",h(a,f)),f}function j(b){return b&&void 0!==b.geolocation?b.geolocation:a.settings.geolocation}var k=function(){b.apply(this,arguments)};return k.prototype=Object.create(b.prototype),k.prototype.constructor=k,a.Entity.Action=k,{class:k,resourceConstructor:function(b,h){var k,l,m=this,n=this instanceof c?this:this.resource.scope;if(!b)throw new TypeError("Action type cannot be empty.");if(!e.isString(b))throw new TypeError("Action type must be a name string");var o="/actions/"+b;return k=this instanceof c?o:this.resource.path+o,l=d.constructorFactory(k,a.Entity.Action).call(n,h),l.create=function(){var a=this,c=g.apply(this,arguments);return c[0]=i(m,c[0],b),j(c[1])?e.getCurrentPosition().then(function(b){return c[0].location={latitude:b.coords.latitude,longitude:b.coords.longitude},c[0].locationSource="sensor",d.prototype.create.apply(a,c)},function(b){return f.info(b),d.prototype.create.apply(a,c)}):d.prototype.create.apply(a,c)},l}}}),e("entity/product",["core","./entity","resource","./property","./action","utils"],function(a,b,c,d,e,f){"use strict";var g=function(){b.apply(this,arguments)};return g.prototype=Object.create(b.prototype),g.prototype.constructor=g,f.extend(g.prototype,{property:d.resourceConstructor,action:e.resourceConstructor},!0),a.Entity.Product=g,{class:g,resourceConstructor:c.constructorFactory("/products",a.Entity.Product,["property","action"])}}),e("entity/user",["core","./entity","resource","utils"],function(a,b,c,d){"use strict";function e(b){if(!b||!d.isString(b))throw new Error("Activation code must be a string.");if(this.type&&"anonymous"===this.type)throw new Error("Anonymous users can't be validated.");var c=this.scope,e=this.path;return this.id&&(c=this.resource.scope,e=this.resource.path+"/"+this.id),a.api({url:e+"/validate",method:"post",authorization:c.apiKey,data:{activationCode:b}})}function f(){var b=this;return a.api({url:this.path,method:"post",params:{anonymous:!0},data:{},authorization:this.scope.apiKey}).then(function(c){return new a.User({id:c.evrythngUser,apiKey:c.evrythngApiKey,type:"anonymous"},b.scope)})}var g=function(a){var c=arguments;a.evrythngUser&&(a.id=a.evrythngUser,delete a.evrythngUser),c[0]=a,b.apply(this,c)};return g.prototype=Object.create(b.prototype),g.prototype.constructor=g,d.extend(g.prototype,{validate:function(){return e.call(this,this.activationCode)}},!0),a.Entity.User=g,{class:g,resourceConstructor:function(b){var g=b||"/users";return function(b){var h=c.constructorFactory(g,a.Entity.User).call(this,b);return h.validate=function(){return e.apply(this,arguments)},h.update=function(){if(this.scope.type&&"anonymous"===this.scope.type)throw new Error("Anonymous users are read-only.");return c.prototype.update.apply(this,arguments)},h.create=function(){var a=this,b=arguments[0];return d.isObject(b)&&!0===b.anonymous?f.call(a):c.prototype.create.call(a,b)},h}}}}),e("entity/place",["core","./entity","resource","scope/scope","utils","logger"],function(a,b,c,d,e,f){"use strict";function g(a){var b=a[0];return b&&!e.isFunction(b)||(a=Array.prototype.slice.call(a,0),a.unshift({})),a}var h=function(){b.apply(this,arguments)};return h.prototype=Object.create(b.prototype),h.prototype.constructor=h,a.Entity.Place=h,{class:h,resourceConstructor:function(b){var d=c.constructorFactory("/places",a.Entity.Place).call(this,b);return d.read=function(){var d=this,h=g(arguments),i=h[0].params||{};return b||i.lat||i.lon||!a.settings.geolocation?c.prototype.read.apply(d,h):e.getCurrentPosition().then(function(a){return i.lat=a.coords.latitude,i.lon=a.coords.longitude,h[0].params=i,c.prototype.read.apply(d,h)},function(a){return f.info(a),c.prototype.read.apply(d,h)})},d}}}),e("social/facebook",["promise","utils"],function(a,b){"use strict";function c(c,d){return new a(function(a){window.fbAsyncInit=function(){FB.init(b.extend({appId:c,version:"v2.8"},d,!0)),FB.getLoginStatus(function(b){f(b).then(function(b){a(b)})})},function(a,b,c){var d,e=a.getElementsByTagName(b)[0];a.getElementById(c)||(d=a.createElement(b),d.id=c,d.src="//connect.facebook.net/en_US/sdk.js",e.parentNode.insertBefore(d,e))}(document,"script","facebook-jssdk")})}function d(b){return new a(function(a,c){FB.login(function(b){f(b).then(function(b){b.user?a(b):c(b)})},b)})}function e(){return new a(function(a){FB.logout(a)})}function f(c){return new a("connected"==c.status?function(a){FB.api("/me",{fields:["id","first_name","last_name","gender","link","picture","locale","name","timezone","updated_time","verified"].toString()},function(d){a(b.extend(c,{user:d}))})}:function(a){a(c)})}return{init:c,login:d,logout:e}}),e("authentication",["core","promise","social/facebook","utils","logger"],function(a,b,c,d,e){"use strict";function f(a,b,c,e){var f=c,i=e;if(!a)throw new TypeError("Credentials (for Evrythng) or type (for Third party) are missing.");return d.isString(a)?"facebook"===a?g.call(this,b,f,i):"evrythng"===a?h.call(this,b,f,i):void 0:h.call(this,a,b,f)}function g(a,f,g){var h={scope:"email"},j=this;if(d.isFunction(a)||null===a){var k=f;f=a,g=k}else d.isObject(a)&&(h=a);return new b(function(a,b){c.login(h).then(function(b){i.call(j,b).then(function(b){f&&(e.warnCallbackDeprecation(),f(b)),a(b)})},function(a){g&&(e.warnCallbackDeprecation(),g(a)),b(a)})})}function h(a,b,c){if(!a||d.isFunction(a))throw new TypeError("Credentials are missing.");return j.call(this,a).then(function(a){return b&&(e.warnCallbackDeprecation(),b(a)),a},function(a){throw c&&(e.warnCallbackDeprecation(),c(a)),a})}function i(b){var c=this;return a.api({url:"/auth/facebook",method:"post",data:{access:{token:b.authResponse.accessToken}},authorization:this.apiKey}).then(function(e){var f=new a.User({id:e.evrythngUser,apiKey:e.evrythngApiKey},c);return a.api({url:"/users/"+f.id,authorization:f.apiKey}).then(function(a){return d.extend(f,{facebook:b.user},!0),d.extend(f,a,!0),b.user=f,b})})}function j(b){var c=this;return a.api({url:"/auth/evrythng",method:"post",data:b,authorization:this.apiKey}).then(function(b){return a.api({url:"/users/"+b.evrythngUser,authorization:b.evrythngApiKey}).then(function(e){var f=d.extend(e,{id:b.evrythngUser,apiKey:b.evrythngApiKey});return{user:new a.User(f,c)}})})}function k(a,b,c){return a&&d.isString(a)?"facebook"===a?l.call(this,b,c):"evrythng"===a?m.call(this,b,c):void 0:m.call(this,a,b)}function l(a,b){var d=this;return c.logout().then(function(){return m.call(d,a,b)})}function m(b,c){return a.api({url:"/auth/all/logout",method:"post",authorization:this.apiKey}).then(function(a){return b&&(e.warnCallbackDeprecation(),b(a)),a},function(a){throw c&&(e.warnCallbackDeprecation(),c(a)),a})}return{login:f,logout:k,authFacebook:i}}),e("scope/application",["core","./scope","entity/product","entity/action","entity/user","entity/place","authentication","social/facebook","utils","logger"],function(a,b,c,d,e,f,g,h,i,j){"use strict";var k=function(c,d){var e=this;i.isObject(c)?(b.call(this,c.apiKey),i.extend(this,c,!0)):b.call(this,c),d instanceof b&&(this.parentScope=d),this.$init=this.$init.then(function(){return a.api({url:"/applications/me",authorization:e.apiKey})}).then(function(a){return delete a.appApiKey,a}).then(i.extendCurried(e)).catch(function(){var a="There is no application with this API Key.";throw j.error(a),new Error(a)}).then(function(a){return c.facebook?a.socialNetworks&&a.socialNetworks.facebook?h.init(a.socialNetworks.facebook.appId,c.facebook).then(function(a){return"connected"===a.status?g.authFacebook.call(e,a):a}).then(i.extendCurried({app:a})):void j.error("The Facebook configuration for this application is incorrect."):a})};return k.prototype=Object.create(b.prototype),k.prototype.constructor=k,i.extend(k.prototype,{product:c.resourceConstructor,action:d.resourceConstructor,appUser:e.resourceConstructor("/auth/evrythng/users"),place:f.resourceConstructor,login:g.login},!0),a.App=k}),e("entity/access",["core","./entity","resource","utils"],function(a,b,c,d){"use strict";var e=function(){b.apply(this,arguments)};return e.prototype=Object.create(b.prototype),e.prototype.constructor=e,a.Entity.Access=e,{class:e,resourceConstructor:c.constructorFactory("/accesses",a.Entity.Access)}}),e("entity/location",["core","./entity","resource","utils","logger"],function(a,b,c,d,e){"use strict";function f(a){var b=a[0];return d.isObject(b)?a[0]=[b]:b&&!d.isFunction(b)||(a=Array.prototype.slice.call(a,0),a.unshift([])),a}var g=function(){b.apply(this,arguments)};return g.prototype=Object.create(b.prototype), g.prototype.constructor=g,a.Entity.Location=g,{class:g,resourceConstructor:function(){var b=this.resource.path+"/location",g=arguments[0]||[];if(d.isString(g)||d.isObject(g)&&d.isString(g.id))throw new TypeError("IDs not allowed here");var h=new c(this.resource.scope,b,a.Entity.Location);return h.update=function(){var b=this,g=f(arguments);return 0===g[0].length&&a.settings.geolocation?d.getCurrentPosition().then(function(a){return g[0]=[{position:{type:"Point",coordinates:[a.coords.longitude,a.coords.latitude]}}],c.prototype.update.apply(b,g)},function(a){return e.info(a),c.prototype.update.apply(b,g)}):c.prototype.update.apply(b,g)},h}}}),e("entity/share",["core","./entity","scope/scope","resource","utils"],function(a,b,c,d,e){"use strict";var f=function(){b.apply(this,arguments)};return f.prototype=Object.create(b.prototype),f.prototype.constructor=f,a.Entity.Share=f,{class:f,resourceConstructor:function(){var b=this.resource.scope,c=this.resource.path+"/shares";return new d(b,c,a.Entity.Share)}}}),e("entity/thng",["core","./entity","resource","./property","./action","./location","./share","utils"],function(a,b,c,d,e,f,g,h){"use strict";function i(){if(!this.product)throw new Error("Thng does not have a product.");if(!this.resource)throw new Error("Thng does not have a resource.");return this.resource.scope.product(this.product).read()}var j=function(){b.apply(this,arguments)};return j.prototype=Object.create(b.prototype),j.prototype.constructor=j,h.extend(j.prototype,{property:d.resourceConstructor,action:e.resourceConstructor,location:f.resourceConstructor,share:g.resourceConstructor,readProduct:i},!0),a.Entity.Thng=j,{class:j,resourceConstructor:c.constructorFactory("/thngs",a.Entity.Thng,["property","action","location","share"])}}),e("entity/actionType",["core","./entity","resource","utils","logger"],function(a,b,c,d,e){"use strict";function f(a){var b=arguments;a&&!d.isFunction(a)||(b=Array.prototype.slice.call(arguments,0),b.unshift({}));var c=this.path.split("/");return b[0].url="/"+c[1],b[0].params=d.extend(b[0].params,{filter:{name:decodeURIComponent(c[2])}}),b}var g=function(){b.apply(this,arguments)};return g.prototype=Object.create(b.prototype),g.prototype.constructor=g,a.Entity.ActionType=g,{class:g,resourceConstructor:function(b){var g,h="/actions";if(b){if(!d.isString(b))throw new TypeError("Action type must be a key/name string");h+="/"+encodeURIComponent(b)}return g=new c(this,h,a.Entity.ActionType),g.read=function(){if(b){var a=f.apply(this,arguments);return c.prototype.read.apply(this,a).then(function(a){if(a.length)return a[0];var b={status:404,errors:["The action type was not found."],url:h};throw e.error(b),b})}return c.prototype.read.apply(this,arguments)},g}}}),e("entity/collection",["core","./entity","resource","./action","utils"],function(a,b,c,d,e){"use strict";function f(b){if(!this.resource)throw new Error("This Entity does not have a Resource.");var d=this.resource.path+"/thngs";return c.constructorFactory(d,a.Entity.Thng).call(this.resource.scope,b)}function g(b){if(!this.resource)throw new Error("This Entity does not have a Resource.");var d=this.resource.path+"/collections";return c.constructorFactory(d,a.Entity.Collection).call(this.resource.scope,b)}var h=function(){b.apply(this,arguments)};return h.prototype=Object.create(b.prototype),h.prototype.constructor=h,e.extend(h.prototype,{thng:f,collection:g,action:d.resourceConstructor},!0),a.Entity.Collection=h,{class:h,resourceConstructor:c.constructorFactory("/collections",a.Entity.Collection,["thng","collection","action"])}}),e("entity/permission",["core","./entity","resource"],function(a,b,c){"use strict";var d=function(){b.apply(this,arguments)};return d.prototype=Object.create(b.prototype),d.prototype.constructor=d,a.Entity.Permission=d,{class:d,resourceConstructor:function(){if(!this.resource)throw new Error("This Entity does not have a Resource.");var b=this.resource.path+"/permissions",d=this.resource.scope;return c.constructorFactory(b,a.Entity.Permission).call(d)}}}),e("entity/policy",["core","./entity","resource"],function(a,b,c){"use strict";var d=function(){b.apply(this,arguments)};return d.prototype=Object.create(b.prototype),d.prototype.constructor=d,a.Entity.Policy=d,{class:d,resourceConstructor:function(b){if(!this.resource)throw new Error("This Entity does not have a Resource.");var d=this.resource.path+"/policies",e=this.resource.scope;return c.constructorFactory(d,a.Entity.Policy).call(e,b)}}}),e("entity/role",["core","./entity","./permission","./policy","resource","utils"],function(a,b,c,d,e,f){"use strict";var g=function(){b.apply(this,arguments)};return g.prototype=Object.create(b.prototype),g.prototype.constructor=g,a.Entity.Role=g,f.extend(g.prototype,{permission:c.resourceConstructor,policy:d.resourceConstructor},!0),{class:g,resourceConstructor:e.constructorFactory("/roles",a.Entity.Role,["permission","policy"])}}),e("scope/user",["core","./scope","entity/product","entity/access","entity/thng","entity/user","entity/actionType","entity/action","entity/collection","entity/place","entity/role","authentication","utils","logger"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){"use strict";function o(){var a=this,b=f.resourceConstructor().call(this,this.id);return b.update.apply(b,arguments).then(function(b){return m.extend(a,b,!0),b})}var p=function(c,d){var e=this;m.isObject(c)?(b.call(this,c.apiKey),m.extend(this,c,!0)):b.call(this,c),d instanceof b&&(this.parentScope=d),this.$init=this.$init.then(function(b){return a.api({url:"/users/"+b.actor.id,authorization:e.apiKey})}).then(m.extendCurried(e)).catch(function(){var a="There is no user with this API Key";throw n.error(a),new Error(a)})};return p.prototype=Object.create(b.prototype),p.prototype.constructor=p,m.extend(p.prototype,{product:c.resourceConstructor,access:d.resourceConstructor,thng:e.resourceConstructor,actionType:g.resourceConstructor,action:h.resourceConstructor,collection:i.resourceConstructor,place:j.resourceConstructor,role:k.resourceConstructor,logout:l.logout,update:o},!0),a.User=p}),e("scope/device",["core","./scope","entity/thng","utils","logger"],function(a,b,c,d,e){"use strict";function f(){var a=this,b=c.resourceConstructor.call(this,this.id);return b.update.apply(b,arguments).then(function(b){return d.extend(a,b,!0),b})}function g(){var a=c.resourceConstructor.call(this,this.id);return a.property.apply(a,arguments)}function h(){var a=c.resourceConstructor.call(this,this.id);return a.action.apply(a,arguments)}var i=function(a,f){var g=this;if(!d.isObject(a))throw new TypeError("DeviceScope constructor should be called with object containing API Key and ID of device.");b.call(this,a.apiKey),d.extend(this,a,!0),f instanceof b&&(this.parentScope=f),this.$init=this.$init.then(function(a){return c.resourceConstructor.call(g,a.actor.id).read()}).then(d.extendCurried(g)).catch(function(){var a="There is no device with this API Key.";throw e.error(a),new Error(a)})};return i.prototype=Object.create(b.prototype),i.prototype.constructor=i,d.extend(i.prototype,{property:g,action:h,update:f},!0),a.Device=i}),e("evrythng",["core","api","scope/application","scope/user","scope/device"],function(a){"use strict";return a}),e("entity/reactorLog",["core","./entity","resource","scope/scope","utils","logger"],function(a,b,c,d,e,f){"use strict";function g(a,b){var c=arguments;return e.isArray(a)&&(e.isObject(b)||(c=Array.prototype.slice.call(arguments,0),c.splice(1,0,{}))),c}var h=function(){b.apply(this,arguments)};return h.prototype=Object.create(b.prototype),h.prototype.constructor=h,a.Entity.ReactorLog=h,{class:h,resourceConstructor:function(a){if(a)throw new TypeError("IDs not allowed here");var b=!(this instanceof d);b||this.project&&this.id||f.error("Application details are not available! Wait for app.$init promise to complete or provide them to the EVT.App constructor if they are known (e.g.: EVT.App({apiKey:'', id: '', project: ''})).");var i,j,k=b?this.resource.scope:this;return i=b?this.resource.path+"/reactor/logs":"/projects/"+this.project+"/applications/"+this.id+"/reactor/logs",j=c.constructorFactory(i,h).call(k),j.create=function(){var a=g.apply(this,arguments);return e.isArray(a[0])&&(a[1].url=this.path+"/bulk"),c.prototype.create.apply(this,a)},j}}}),e("entity/status",["core","./entity","resource","utils"],function(a,b,c,d){"use strict";var e=function(){b.apply(this,arguments)};return e.prototype=Object.create(b.prototype),e.prototype.constructor=e,a.Entity.Status=e,{class:e,resourceConstructor:function(b){if(b)throw new TypeError("IDs not allowed here");if(!this.resource)throw new Error("This Entity does not have a Resource.");var d=this.resource.path+"/status",e=this.resource.scope;return c.constructorFactory(d,a.Entity.Status).call(e)}}}),e("entity/reactorScript",["core","./entity","./status","resource","scope/scope","utils","logger"],function(a,b,c,d,e,f,g){"use strict";var h=function(){b.apply(this,arguments)};return h.prototype=Object.create(b.prototype),h.prototype.constructor=h,a.Entity.ReactorScript=h,f.extend(h.prototype,{status:c.resourceConstructor},!0),{class:h,resourceConstructor:function(a){if(a)throw new TypeError("IDs not allowed here");var b=!(this instanceof e);b||this.project&&this.id||g.error("Application details are not available! Wait for app.$init promise to complete or provide them to the EVT.App constructor if they are known (e.g.: EVT.App({apiKey:'', id: '', project: ''})).");var c,f=b?this.resource.scope:this;return c=b?this.resource.path+"/reactor/script":"/projects/"+this.project+"/applications/"+this.id+"/reactor/script",d.constructorFactory(c,h,["status"]).call(f)}}}),e("entity/reactorSchedule",["core","./entity","resource","scope/scope","utils","logger"],function(a,b,c,d,e,f){"use strict";var g=function(){b.apply(this,arguments)};return g.prototype=Object.create(b.prototype),g.prototype.constructor=g,a.Entity.ReactorSchedule=g,{class:g,resourceConstructor:function(a){var b=!(this instanceof d);b||this.project&&this.id||f.error("Application details are not available! Wait for app.$init promise to complete or provide them to the EVT.App constructor if they are known (e.g.: EVT.App({apiKey:'', id: '', project: ''})).");var e,h=b?this.resource.scope:this;return e=b?this.resource.path+"/reactor/schedules":"/projects/"+this.project+"/applications/"+this.id+"/reactor/schedules",c.constructorFactory(e,g).call(h,a)}}}),e("namespaces/reactor",["../entity/reactorLog","../entity/reactorScript","../entity/reactorSchedule"],function(a,b,c){"use strict";return function(d){this.log=a.resourceConstructor.bind(d),this.script=b.resourceConstructor.bind(d),this.schedule=c.resourceConstructor.bind(d)}}),e("entity/application",["core","./entity","../namespaces/reactor","resource"],function(a,b,c,d){"use strict";var e=function(){b.apply(this,arguments),this.reactor=new c(this)};return e.prototype=Object.create(b.prototype),e.prototype.constructor=e,a.Entity.Application=e,{class:e,resourceConstructor:function(e){if(!this.resource)throw new Error("This Entity does not have a Resource.");var f,g=this.resource.path+"/applications",h=this.resource.scope;f=d.constructorFactory(g,a.Entity.Application).call(h,e);var i=new b({id:e},f);return f.reactor=new c(i),f}}}),e("entity/project",["core","./entity","./application","resource","utils"],function(a,b,c,d,e){"use strict";var f=function(){b.apply(this,arguments)};return f.prototype=Object.create(b.prototype),f.prototype.constructor=f,a.Entity.Project=f,e.extend(f.prototype,{application:c.resourceConstructor},!0),{class:f,resourceConstructor:function(b){return d.constructorFactory("/projects",a.Entity.Project,["application"]).call(this,b)}}}),e("entity/task",["core","./entity","resource","utils"],function(a,b,c,d){"use strict";var e=function(){b.apply(this,arguments)};return e.prototype=Object.create(b.prototype),e.prototype.constructor=e,a.Entity.Task=e,{class:e,resourceConstructor:function(b){if(!this.resource)throw new Error("This Entity does not have a Resource.");var d=this.resource.path+"/tasks",e=this.resource.scope;return c.constructorFactory(d,a.Entity.Task).call(e,b)}}}),e("entity/batch",["core","./entity","./task","resource","utils"],function(a,b,c,d,e){"use strict";var f=function(){b.apply(this,arguments)};return f.prototype=Object.create(b.prototype),f.prototype.constructor=f,a.Entity.Batch=f,e.extend(f.prototype,{task:c.resourceConstructor},!0),{class:f,resourceConstructor:d.constructorFactory("/batches",a.Entity.Batch,["task"])}}),e("entity/file",["core","./entity","resource"],function(a,b,c){"use strict";var d=function(){b.apply(this,arguments)};return d.prototype=Object.create(b.prototype),d.prototype.constructor=d,a.Entity.File=d,{class:d,resourceConstructor:function(b){return c.constructorFactory("/files",a.Entity.File).call(this,b)}}}),e("entity/schema",["core","./entity","resource"],function(a,b,c){"use strict";var d=function(){b.apply(this,arguments)};return d.prototype=Object.create(b.prototype),d.prototype.constructor=d,a.Entity.Schema=d,{class:d,resourceConstructor:c.constructorFactory("/schemas",a.Entity.Schema)}}),e("scope/operator",["core","./scope","entity/project","entity/product","entity/thng","entity/user","entity/actionType","entity/action","entity/collection","entity/batch","entity/place","entity/file","entity/role","entity/schema","utils","logger"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){"use strict";var q=function(c){var d=this;o.isObject(c)?(b.call(this,c.apiKey),o.extend(this,c,!0)):b.call(this,c),this.$init=this.$init.then(function(b){return d.id=b.actor.id,a.api({url:"/accounts",authorization:d.apiKey})}).then(function(a){return o.extend(d,{account:a[0]},!0)}).catch(function(){p.error("There is no operator with this API Key.")})};return q.prototype=Object.create(b.prototype),q.prototype.constructor=q,o.extend(q.prototype,{user:f.resourceConstructor(),project:c.resourceConstructor,product:d.resourceConstructor,thng:e.resourceConstructor,actionType:g.resourceConstructor,action:h.resourceConstructor,collection:i.resourceConstructor,batch:j.resourceConstructor,place:k.resourceConstructor,file:l.resourceConstructor,role:m.resourceConstructor,schema:n.resourceConstructor},!0),a.Operator=q}),e("scope/trustedApplication",["core","./application","entity/user","entity/thng","entity/actionType","entity/collection","namespaces/reactor","utils"],function(a,b,c,d,e,f,g,h){"use strict";var i=function(){b.apply(this,arguments),this.reactor=new g(this)};return i.prototype=Object.create(b.prototype),i.prototype.constructor=i,h.extend(i.prototype,{user:c.resourceConstructor(),thng:d.resourceConstructor,actionType:e.resourceConstructor,collection:f.resourceConstructor},!0),a.TrustedApp=i}),e("evrythng-extended",["evrythng","scope/operator","scope/trustedApplication"],function(a){"use strict";return a}),d("evrythng-extended")}(null,require("request"))}(); //# sourceMappingURL=evrythng-extended.min.js.map