diff --git a/dist/js-data-http.js b/dist/js-data-http.js index 0407a83..f9c163d 100644 --- a/dist/js-data-http.js +++ b/dist/js-data-http.js @@ -1,6 +1,6 @@ /*! * js-data-http -* @version 3.0.0-rc.3 - Homepage +* @version 3.0.0 - Homepage * @copyright (c) 2014-2016 js-data-http project authors * @license MIT * @@ -10,4241 +10,4562 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-data')) : typeof define === 'function' && define.amd ? define('js-data-http', ['exports', 'js-data'], factory) : (factory((global.JSDataHttp = global.JSDataHttp || {}),global.JSData)); -}(this, function (exports,jsData) { 'use strict'; +}(this, (function (exports,jsData) { 'use strict'; + +var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + + + + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var axios = createCommonjsModule(function (module, exports) { +/* axios v0.16.2 | (c) 2017 by Matt Zabriskie */ +(function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(); +})(commonjsGlobal, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(1); + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + var bind = __webpack_require__(3); + var Axios = __webpack_require__(5); + var defaults = __webpack_require__(6); + + /** + * Create an instance of Axios + * + * @param {Object} defaultConfig The default config for the instance + * @return {Axios} A new instance of Axios + */ + function createInstance(defaultConfig) { + var context = new Axios(defaultConfig); + var instance = bind(Axios.prototype.request, context); + + // Copy axios.prototype to instance + utils$$1.extend(instance, Axios.prototype, context); + + // Copy context to instance + utils$$1.extend(instance, context); + + return instance; + } + + // Create the default instance to be exported + var axios = createInstance(defaults); + + // Expose Axios class to allow class inheritance + axios.Axios = Axios; + + // Factory for creating new instances + axios.create = function create(instanceConfig) { + return createInstance(utils$$1.merge(defaults, instanceConfig)); + }; + + // Expose Cancel & CancelToken + axios.Cancel = __webpack_require__(23); + axios.CancelToken = __webpack_require__(24); + axios.isCancel = __webpack_require__(20); + + // Expose all/spread + axios.all = function all(promises) { + return Promise.all(promises); + }; + axios.spread = __webpack_require__(25); + + module.exports = axios; + + // Allow use of default import syntax in TypeScript + module.exports.default = axios; + + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bind = __webpack_require__(3); + var isBuffer = __webpack_require__(4); + + /*global toString:true*/ + + // utils is a library of generic helper functions non-specific to axios + + var toString = Object.prototype.toString; + + /** + * Determine if a value is an Array + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Array, otherwise false + */ + function isArray(val) { + return toString.call(val) === '[object Array]'; + } + + /** + * Determine if a value is an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an ArrayBuffer, otherwise false + */ + function isArrayBuffer(val) { + return toString.call(val) === '[object ArrayBuffer]'; + } + + /** + * Determine if a value is a FormData + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an FormData, otherwise false + */ + function isFormData(val) { + return (typeof FormData !== 'undefined') && (val instanceof FormData); + } + + /** + * Determine if a value is a view on an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false + */ + function isArrayBufferView(val) { + var result; + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { + result = ArrayBuffer.isView(val); + } else { + result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); + } + return result; + } + + /** + * Determine if a value is a String + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a String, otherwise false + */ + function isString(val) { + return typeof val === 'string'; + } + + /** + * Determine if a value is a Number + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Number, otherwise false + */ + function isNumber(val) { + return typeof val === 'number'; + } + + /** + * Determine if a value is undefined + * + * @param {Object} val The value to test + * @returns {boolean} True if the value is undefined, otherwise false + */ + function isUndefined(val) { + return typeof val === 'undefined'; + } + + /** + * Determine if a value is an Object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Object, otherwise false + */ + function isObject(val) { + return val !== null && typeof val === 'object'; + } + + /** + * Determine if a value is a Date + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Date, otherwise false + */ + function isDate(val) { + return toString.call(val) === '[object Date]'; + } + + /** + * Determine if a value is a File + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a File, otherwise false + */ + function isFile(val) { + return toString.call(val) === '[object File]'; + } + + /** + * Determine if a value is a Blob + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Blob, otherwise false + */ + function isBlob(val) { + return toString.call(val) === '[object Blob]'; + } + + /** + * Determine if a value is a Function + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Function, otherwise false + */ + function isFunction(val) { + return toString.call(val) === '[object Function]'; + } + + /** + * Determine if a value is a Stream + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Stream, otherwise false + */ + function isStream(val) { + return isObject(val) && isFunction(val.pipe); + } + + /** + * Determine if a value is a URLSearchParams object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a URLSearchParams object, otherwise false + */ + function isURLSearchParams(val) { + return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; + } + + /** + * Trim excess whitespace off the beginning and end of a string + * + * @param {String} str The String to trim + * @returns {String} The String freed of excess whitespace + */ + function trim(str) { + return str.replace(/^\s*/, '').replace(/\s*$/, ''); + } + + /** + * Determine if we're running in a standard browser environment + * + * This allows axios to run in a web worker, and react-native. + * Both environments support XMLHttpRequest, but not fully standard globals. + * + * web workers: + * typeof window -> undefined + * typeof document -> undefined + * + * react-native: + * navigator.product -> 'ReactNative' + */ + function isStandardBrowserEnv() { + if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { + return false; + } + return ( + typeof window !== 'undefined' && + typeof document !== 'undefined' + ); + } + + /** + * Iterate over an Array or an Object invoking a function for each item. + * + * If `obj` is an Array callback will be called passing + * the value, index, and complete array for each item. + * + * If 'obj' is an Object callback will be called passing + * the value, key, and complete object for each property. + * + * @param {Object|Array} obj The object to iterate + * @param {Function} fn The callback to invoke for each item + */ + function forEach(obj, fn) { + // Don't bother if no value provided + if (obj === null || typeof obj === 'undefined') { + return; + } + + // Force an array if not already something iterable + if (typeof obj !== 'object' && !isArray(obj)) { + /*eslint no-param-reassign:0*/ + obj = [obj]; + } + + if (isArray(obj)) { + // Iterate over array values + for (var i = 0, l = obj.length; i < l; i++) { + fn.call(null, obj[i], i, obj); + } + } else { + // Iterate over object keys + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + fn.call(null, obj[key], key, obj); + } + } + } + } + + /** + * Accepts varargs expecting each argument to be an object, then + * immutably merges the properties of each object and returns result. + * + * When multiple objects contain the same key the later object in + * the arguments list will take precedence. + * + * Example: + * + * ```js + * var result = merge({foo: 123}, {foo: 456}); + * console.log(result.foo); // outputs 456 + * ``` + * + * @param {Object} obj1 Object to merge + * @returns {Object} Result of all merge properties + */ + function merge(/* obj1, obj2, obj3, ... */) { + var result = {}; + function assignValue(val, key) { + if (typeof result[key] === 'object' && typeof val === 'object') { + result[key] = merge(result[key], val); + } else { + result[key] = val; + } + } + + for (var i = 0, l = arguments.length; i < l; i++) { + forEach(arguments[i], assignValue); + } + return result; + } + + /** + * Extends object a by mutably adding to it the properties of object b. + * + * @param {Object} a The object to be extended + * @param {Object} b The object to copy properties from + * @param {Object} thisArg The object to bind function to + * @return {Object} The resulting value of object a + */ + function extend(a, b, thisArg) { + forEach(b, function assignValue(val, key) { + if (thisArg && typeof val === 'function') { + a[key] = bind(val, thisArg); + } else { + a[key] = val; + } + }); + return a; + } + + module.exports = { + isArray: isArray, + isArrayBuffer: isArrayBuffer, + isBuffer: isBuffer, + isFormData: isFormData, + isArrayBufferView: isArrayBufferView, + isString: isString, + isNumber: isNumber, + isObject: isObject, + isUndefined: isUndefined, + isDate: isDate, + isFile: isFile, + isBlob: isBlob, + isFunction: isFunction, + isStream: isStream, + isURLSearchParams: isURLSearchParams, + isStandardBrowserEnv: isStandardBrowserEnv, + forEach: forEach, + merge: merge, + extend: extend, + trim: trim + }; + + +/***/ }, +/* 3 */ +/***/ function(module, exports) { - var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {} + 'use strict'; + + module.exports = function bind(fn, thisArg) { + return function wrap() { + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + return fn.apply(thisArg, args); + }; + }; + + +/***/ }, +/* 4 */ +/***/ function(module, exports) { - function interopDefault(ex) { - return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex; + /*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh + * @license MIT + */ + + // The _isBuffer check is for Safari 5-7 support, because it's missing + // Object.prototype.constructor. Remove this eventually + module.exports = function (obj) { + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) + }; + + function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) } + + // For Node v0.10 support. Remove this eventually. + function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) + } + - function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var defaults = __webpack_require__(6); + var utils$$1 = __webpack_require__(2); + var InterceptorManager = __webpack_require__(17); + var dispatchRequest = __webpack_require__(18); + var isAbsoluteURL = __webpack_require__(21); + var combineURLs = __webpack_require__(22); + + /** + * Create a new instance of Axios + * + * @param {Object} instanceConfig The default config for the instance + */ + function Axios(instanceConfig) { + this.defaults = instanceConfig; + this.interceptors = { + request: new InterceptorManager(), + response: new InterceptorManager() + }; } + + /** + * Dispatch a request + * + * @param {Object} config The config specific for this request (merged with this.defaults) + */ + Axios.prototype.request = function request(config) { + /*eslint no-param-reassign:0*/ + // Allow for axios('example/url'[, config]) a la fetch API + if (typeof config === 'string') { + config = utils$$1.merge({ + url: arguments[0] + }, arguments[1]); + } + + config = utils$$1.merge(defaults, this.defaults, { method: 'get' }, config); + config.method = config.method.toLowerCase(); + + // Support baseURL config + if (config.baseURL && !isAbsoluteURL(config.url)) { + config.url = combineURLs(config.baseURL, config.url); + } + + // Hook up interceptors middleware + var chain = [dispatchRequest, undefined]; + var promise = Promise.resolve(config); + + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { + chain.unshift(interceptor.fulfilled, interceptor.rejected); + }); + + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { + chain.push(interceptor.fulfilled, interceptor.rejected); + }); + + while (chain.length) { + promise = promise.then(chain.shift(), chain.shift()); + } + + return promise; + }; + + // Provide aliases for supported request methods + utils$$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, config) { + return this.request(utils$$1.merge(config || {}, { + method: method, + url: url + })); + }; + }); + + utils$$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, data, config) { + return this.request(utils$$1.merge(config || {}, { + method: method, + url: url, + data: data + })); + }; + }); + + module.exports = Axios; + + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { - var axios = createCommonjsModule(function (module, exports) { - /* axios v0.13.1 | (c) 2016 by Matt Zabriskie */ - (function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["axios"] = factory(); - else - root["axios"] = factory(); - })(commonjsGlobal, function() { - return /******/ (function(modules) { // webpackBootstrap - /******/ // The module cache - /******/ var installedModules = {}; - /******/ - /******/ // The require function - /******/ function __webpack_require__(moduleId) { - /******/ - /******/ // Check if module is in cache - /******/ if(installedModules[moduleId]) - /******/ return installedModules[moduleId].exports; - /******/ - /******/ // Create a new module (and put it into the cache) - /******/ var module = installedModules[moduleId] = { - /******/ exports: {}, - /******/ id: moduleId, - /******/ loaded: false - /******/ }; - /******/ - /******/ // Execute the module function - /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - /******/ - /******/ // Flag the module as loaded - /******/ module.loaded = true; - /******/ - /******/ // Return the exports of the module - /******/ return module.exports; - /******/ } - /******/ - /******/ - /******/ // expose the modules object (__webpack_modules__) - /******/ __webpack_require__.m = modules; - /******/ - /******/ // expose the module cache - /******/ __webpack_require__.c = installedModules; - /******/ - /******/ // __webpack_public_path__ - /******/ __webpack_require__.p = ""; - /******/ - /******/ // Load entry module and return exports - /******/ return __webpack_require__(0); - /******/ }) - /************************************************************************/ - /******/ ([ - /* 0 */ - /***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(1); - - /***/ }, - /* 1 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - var bind = __webpack_require__(3); - var Axios = __webpack_require__(4); - - /** - * Create an instance of Axios - * - * @param {Object} defaultConfig The default config for the instance - * @return {Axios} A new instance of Axios - */ - function createInstance(defaultConfig) { - var context = new Axios(defaultConfig); - var instance = bind(Axios.prototype.request, context); - - // Copy axios.prototype to instance - utils.extend(instance, Axios.prototype, context); - - // Copy context to instance - utils.extend(instance, context); - - return instance; - } - - // Create the default instance to be exported - var axios = module.exports = createInstance(); - - // Expose Axios class to allow class inheritance - axios.Axios = Axios; - - // Factory for creating new instances - axios.create = function create(defaultConfig) { - return createInstance(defaultConfig); - }; - - // Expose all/spread - axios.all = function all(promises) { - return Promise.all(promises); - }; - axios.spread = __webpack_require__(21); - - - /***/ }, - /* 2 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bind = __webpack_require__(3); - - /*global toString:true*/ - - // utils is a library of generic helper functions non-specific to axios - - var toString = Object.prototype.toString; - - /** - * Determine if a value is an Array - * - * @param {Object} val The value to test - * @returns {boolean} True if value is an Array, otherwise false - */ - function isArray(val) { - return toString.call(val) === '[object Array]'; - } - - /** - * Determine if a value is an ArrayBuffer - * - * @param {Object} val The value to test - * @returns {boolean} True if value is an ArrayBuffer, otherwise false - */ - function isArrayBuffer(val) { - return toString.call(val) === '[object ArrayBuffer]'; - } - - /** - * Determine if a value is a FormData - * - * @param {Object} val The value to test - * @returns {boolean} True if value is an FormData, otherwise false - */ - function isFormData(val) { - return (typeof FormData !== 'undefined') && (val instanceof FormData); - } - - /** - * Determine if a value is a view on an ArrayBuffer - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false - */ - function isArrayBufferView(val) { - var result; - if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { - result = ArrayBuffer.isView(val); - } else { - result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); - } - return result; - } - - /** - * Determine if a value is a String - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a String, otherwise false - */ - function isString(val) { - return typeof val === 'string'; - } - - /** - * Determine if a value is a Number - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a Number, otherwise false - */ - function isNumber(val) { - return typeof val === 'number'; - } - - /** - * Determine if a value is undefined - * - * @param {Object} val The value to test - * @returns {boolean} True if the value is undefined, otherwise false - */ - function isUndefined(val) { - return typeof val === 'undefined'; - } - - /** - * Determine if a value is an Object - * - * @param {Object} val The value to test - * @returns {boolean} True if value is an Object, otherwise false - */ - function isObject(val) { - return val !== null && typeof val === 'object'; - } - - /** - * Determine if a value is a Date - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a Date, otherwise false - */ - function isDate(val) { - return toString.call(val) === '[object Date]'; - } - - /** - * Determine if a value is a File - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a File, otherwise false - */ - function isFile(val) { - return toString.call(val) === '[object File]'; - } - - /** - * Determine if a value is a Blob - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a Blob, otherwise false - */ - function isBlob(val) { - return toString.call(val) === '[object Blob]'; - } - - /** - * Determine if a value is a Function - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a Function, otherwise false - */ - function isFunction(val) { - return toString.call(val) === '[object Function]'; - } - - /** - * Determine if a value is a Stream - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a Stream, otherwise false - */ - function isStream(val) { - return isObject(val) && isFunction(val.pipe); - } - - /** - * Determine if a value is a URLSearchParams object - * - * @param {Object} val The value to test - * @returns {boolean} True if value is a URLSearchParams object, otherwise false - */ - function isURLSearchParams(val) { - return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; - } - - /** - * Trim excess whitespace off the beginning and end of a string - * - * @param {String} str The String to trim - * @returns {String} The String freed of excess whitespace - */ - function trim(str) { - return str.replace(/^\s*/, '').replace(/\s*$/, ''); - } - - /** - * Determine if we're running in a standard browser environment - * - * This allows axios to run in a web worker, and react-native. - * Both environments support XMLHttpRequest, but not fully standard globals. - * - * web workers: - * typeof window -> undefined - * typeof document -> undefined - * - * react-native: - * typeof document.createElement -> undefined - */ - function isStandardBrowserEnv() { - return ( - typeof window !== 'undefined' && - typeof document !== 'undefined' && - typeof document.createElement === 'function' - ); - } - - /** - * Iterate over an Array or an Object invoking a function for each item. - * - * If `obj` is an Array callback will be called passing - * the value, index, and complete array for each item. - * - * If 'obj' is an Object callback will be called passing - * the value, key, and complete object for each property. - * - * @param {Object|Array} obj The object to iterate - * @param {Function} fn The callback to invoke for each item - */ - function forEach(obj, fn) { - // Don't bother if no value provided - if (obj === null || typeof obj === 'undefined') { - return; - } - - // Force an array if not already something iterable - if (typeof obj !== 'object' && !isArray(obj)) { - /*eslint no-param-reassign:0*/ - obj = [obj]; - } - - if (isArray(obj)) { - // Iterate over array values - for (var i = 0, l = obj.length; i < l; i++) { - fn.call(null, obj[i], i, obj); - } - } else { - // Iterate over object keys - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - fn.call(null, obj[key], key, obj); - } - } - } - } - - /** - * Accepts varargs expecting each argument to be an object, then - * immutably merges the properties of each object and returns result. - * - * When multiple objects contain the same key the later object in - * the arguments list will take precedence. - * - * Example: - * - * ```js - * var result = merge({foo: 123}, {foo: 456}); - * console.log(result.foo); // outputs 456 - * ``` - * - * @param {Object} obj1 Object to merge - * @returns {Object} Result of all merge properties - */ - function merge(/* obj1, obj2, obj3, ... */) { - var result = {}; - function assignValue(val, key) { - if (typeof result[key] === 'object' && typeof val === 'object') { - result[key] = merge(result[key], val); - } else { - result[key] = val; - } - } - - for (var i = 0, l = arguments.length; i < l; i++) { - forEach(arguments[i], assignValue); - } - return result; - } - - /** - * Extends object a by mutably adding to it the properties of object b. - * - * @param {Object} a The object to be extended - * @param {Object} b The object to copy properties from - * @param {Object} thisArg The object to bind function to - * @return {Object} The resulting value of object a - */ - function extend(a, b, thisArg) { - forEach(b, function assignValue(val, key) { - if (thisArg && typeof val === 'function') { - a[key] = bind(val, thisArg); - } else { - a[key] = val; - } - }); - return a; - } - - module.exports = { - isArray: isArray, - isArrayBuffer: isArrayBuffer, - isFormData: isFormData, - isArrayBufferView: isArrayBufferView, - isString: isString, - isNumber: isNumber, - isObject: isObject, - isUndefined: isUndefined, - isDate: isDate, - isFile: isFile, - isBlob: isBlob, - isFunction: isFunction, - isStream: isStream, - isURLSearchParams: isURLSearchParams, - isStandardBrowserEnv: isStandardBrowserEnv, - forEach: forEach, - merge: merge, - extend: extend, - trim: trim - }; - - - /***/ }, - /* 3 */ - /***/ function(module, exports) { - - 'use strict'; - - module.exports = function bind(fn, thisArg) { - return function wrap() { - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - return fn.apply(thisArg, args); - }; - }; - - - /***/ }, - /* 4 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var defaults = __webpack_require__(5); - var utils = __webpack_require__(2); - var InterceptorManager = __webpack_require__(7); - var dispatchRequest = __webpack_require__(8); - var isAbsoluteURL = __webpack_require__(19); - var combineURLs = __webpack_require__(20); - - /** - * Create a new instance of Axios - * - * @param {Object} defaultConfig The default config for the instance - */ - function Axios(defaultConfig) { - this.defaults = utils.merge(defaults, defaultConfig); - this.interceptors = { - request: new InterceptorManager(), - response: new InterceptorManager() - }; - } - - /** - * Dispatch a request - * - * @param {Object} config The config specific for this request (merged with this.defaults) - */ - Axios.prototype.request = function request(config) { - /*eslint no-param-reassign:0*/ - // Allow for axios('example/url'[, config]) a la fetch API - if (typeof config === 'string') { - config = utils.merge({ - url: arguments[0] - }, arguments[1]); - } - - config = utils.merge(defaults, this.defaults, { method: 'get' }, config); - - // Support baseURL config - if (config.baseURL && !isAbsoluteURL(config.url)) { - config.url = combineURLs(config.baseURL, config.url); - } - - // Hook up interceptors middleware - var chain = [dispatchRequest, undefined]; - var promise = Promise.resolve(config); - - this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { - chain.unshift(interceptor.fulfilled, interceptor.rejected); - }); - - this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { - chain.push(interceptor.fulfilled, interceptor.rejected); - }); - - while (chain.length) { - promise = promise.then(chain.shift(), chain.shift()); - } - - return promise; - }; - - // Provide aliases for supported request methods - utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { - /*eslint func-names:0*/ - Axios.prototype[method] = function(url, config) { - return this.request(utils.merge(config || {}, { - method: method, - url: url - })); - }; - }); - - utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { - /*eslint func-names:0*/ - Axios.prototype[method] = function(url, data, config) { - return this.request(utils.merge(config || {}, { - method: method, - url: url, - data: data - })); - }; - }); - - module.exports = Axios; - - - /***/ }, - /* 5 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - var normalizeHeaderName = __webpack_require__(6); - - var PROTECTION_PREFIX = /^\)\]\}',?\n/; - var DEFAULT_CONTENT_TYPE = { - 'Content-Type': 'application/x-www-form-urlencoded' - }; - - function setContentTypeIfUnset(headers, value) { - if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { - headers['Content-Type'] = value; - } - } - - module.exports = { - transformRequest: [function transformRequest(data, headers) { - normalizeHeaderName(headers, 'Content-Type'); - if (utils.isFormData(data) || - utils.isArrayBuffer(data) || - utils.isStream(data) || - utils.isFile(data) || - utils.isBlob(data) - ) { - return data; - } - if (utils.isArrayBufferView(data)) { - return data.buffer; - } - if (utils.isURLSearchParams(data)) { - setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); - return data.toString(); - } - if (utils.isObject(data)) { - setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); - return JSON.stringify(data); - } - return data; - }], - - transformResponse: [function transformResponse(data) { - /*eslint no-param-reassign:0*/ - if (typeof data === 'string') { - data = data.replace(PROTECTION_PREFIX, ''); - try { - data = JSON.parse(data); - } catch (e) { /* Ignore */ } - } - return data; - }], - - headers: { - common: { - 'Accept': 'application/json, text/plain, */*' - }, - patch: utils.merge(DEFAULT_CONTENT_TYPE), - post: utils.merge(DEFAULT_CONTENT_TYPE), - put: utils.merge(DEFAULT_CONTENT_TYPE) - }, - - timeout: 0, - - xsrfCookieName: 'XSRF-TOKEN', - xsrfHeaderName: 'X-XSRF-TOKEN', - - maxContentLength: -1, - - validateStatus: function validateStatus(status) { - return status >= 200 && status < 300; - } - }; - - - /***/ }, - /* 6 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - - module.exports = function normalizeHeaderName(headers, normalizedName) { - utils.forEach(headers, function processHeader(value, name) { - if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { - headers[normalizedName] = value; - delete headers[name]; - } - }); - }; - - - /***/ }, - /* 7 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - - function InterceptorManager() { - this.handlers = []; - } - - /** - * Add a new interceptor to the stack - * - * @param {Function} fulfilled The function to handle `then` for a `Promise` - * @param {Function} rejected The function to handle `reject` for a `Promise` - * - * @return {Number} An ID used to remove interceptor later - */ - InterceptorManager.prototype.use = function use(fulfilled, rejected) { - this.handlers.push({ - fulfilled: fulfilled, - rejected: rejected - }); - return this.handlers.length - 1; - }; - - /** - * Remove an interceptor from the stack - * - * @param {Number} id The ID that was returned by `use` - */ - InterceptorManager.prototype.eject = function eject(id) { - if (this.handlers[id]) { - this.handlers[id] = null; - } - }; - - /** - * Iterate over all the registered interceptors - * - * This method is particularly useful for skipping over any - * interceptors that may have become `null` calling `eject`. - * - * @param {Function} fn The function to call for each interceptor - */ - InterceptorManager.prototype.forEach = function forEach(fn) { - utils.forEach(this.handlers, function forEachHandler(h) { - if (h !== null) { - fn(h); - } - }); - }; - - module.exports = InterceptorManager; - - - /***/ }, - /* 8 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - var transformData = __webpack_require__(9); - - /** - * Dispatch a request to the server using whichever adapter - * is supported by the current environment. - * - * @param {object} config The config that is to be used for the request - * @returns {Promise} The Promise to be fulfilled - */ - module.exports = function dispatchRequest(config) { - // Ensure headers exist - config.headers = config.headers || {}; - - // Transform request data - config.data = transformData( - config.data, - config.headers, - config.transformRequest - ); - - // Flatten headers - config.headers = utils.merge( - config.headers.common || {}, - config.headers[config.method] || {}, - config.headers || {} - ); - - utils.forEach( - ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], - function cleanHeaderConfig(method) { - delete config.headers[method]; - } - ); - - var adapter; - - if (typeof config.adapter === 'function') { - // For custom adapter support - adapter = config.adapter; - } else if (typeof XMLHttpRequest !== 'undefined') { - // For browsers use XHR adapter - adapter = __webpack_require__(10); - } else if (typeof process !== 'undefined') { - // For node use HTTP adapter - adapter = __webpack_require__(10); - } - - return Promise.resolve(config) - // Wrap synchronous adapter errors and pass configuration - .then(adapter) - .then(function onFulfilled(response) { - // Transform response data - response.data = transformData( - response.data, - response.headers, - config.transformResponse - ); - - return response; - }, function onRejected(error) { - // Transform response data - if (error && error.response) { - error.response.data = transformData( - error.response.data, - error.response.headers, - config.transformResponse - ); - } - - return Promise.reject(error); - }); - }; - - - /***/ }, - /* 9 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - - /** - * Transform the data for a request or a response - * - * @param {Object|String} data The data to be transformed - * @param {Array} headers The headers for the request or response - * @param {Array|Function} fns A single function or Array of functions - * @returns {*} The resulting transformed data - */ - module.exports = function transformData(data, headers, fns) { - /*eslint no-param-reassign:0*/ - utils.forEach(fns, function transform(fn) { - data = fn(data, headers); - }); - - return data; - }; - - - /***/ }, - /* 10 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - var settle = __webpack_require__(11); - var buildURL = __webpack_require__(14); - var parseHeaders = __webpack_require__(15); - var isURLSameOrigin = __webpack_require__(16); - var createError = __webpack_require__(12); - var btoa = (typeof window !== 'undefined' && window.btoa) || __webpack_require__(17); - - module.exports = function xhrAdapter(config) { - return new Promise(function dispatchXhrRequest(resolve, reject) { - var requestData = config.data; - var requestHeaders = config.headers; - - if (utils.isFormData(requestData)) { - delete requestHeaders['Content-Type']; // Let the browser set it - } - - var request = new XMLHttpRequest(); - var loadEvent = 'onreadystatechange'; - var xDomain = false; - - // For IE 8/9 CORS support - // Only supports POST and GET calls and doesn't returns the response headers. - // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest. - if (("production") !== 'test' && - typeof window !== 'undefined' && - window.XDomainRequest && !('withCredentials' in request) && - !isURLSameOrigin(config.url)) { - request = new window.XDomainRequest(); - loadEvent = 'onload'; - xDomain = true; - request.onprogress = function handleProgress() {}; - request.ontimeout = function handleTimeout() {}; - } - - // HTTP basic authentication - if (config.auth) { - var username = config.auth.username || ''; - var password = config.auth.password || ''; - requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); - } - - request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true); - - // Set the request timeout in MS - request.timeout = config.timeout; - - // Listen for ready state - request[loadEvent] = function handleLoad() { - if (!request || (request.readyState !== 4 && !xDomain)) { - return; - } - - // The request errored out and we didn't get a response, this will be - // handled by onerror instead - if (request.status === 0) { - return; - } - - // Prepare the response - var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; - var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; - var response = { - data: responseData, - // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201) - status: request.status === 1223 ? 204 : request.status, - statusText: request.status === 1223 ? 'No Content' : request.statusText, - headers: responseHeaders, - config: config, - request: request - }; - - settle(resolve, reject, response); - - // Clean up request - request = null; - }; - - // Handle low level network errors - request.onerror = function handleError() { - // Real errors are hidden from us by the browser - // onerror should only fire if it's a network error - reject(createError('Network Error', config)); - - // Clean up request - request = null; - }; - - // Handle timeout - request.ontimeout = function handleTimeout() { - reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED')); - - // Clean up request - request = null; - }; - - // Add xsrf header - // This is only done if running in a standard browser environment. - // Specifically not if we're in a web worker, or react-native. - if (utils.isStandardBrowserEnv()) { - var cookies = __webpack_require__(18); - - // Add xsrf header - var xsrfValue = config.withCredentials || isURLSameOrigin(config.url) ? - cookies.read(config.xsrfCookieName) : - undefined; - - if (xsrfValue) { - requestHeaders[config.xsrfHeaderName] = xsrfValue; - } - } - - // Add headers to the request - if ('setRequestHeader' in request) { - utils.forEach(requestHeaders, function setRequestHeader(val, key) { - if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { - // Remove Content-Type if data is undefined - delete requestHeaders[key]; - } else { - // Otherwise add header to the request - request.setRequestHeader(key, val); - } - }); - } - - // Add withCredentials to request if needed - if (config.withCredentials) { - request.withCredentials = true; - } - - // Add responseType to request if needed - if (config.responseType) { - try { - request.responseType = config.responseType; - } catch (e) { - if (request.responseType !== 'json') { - throw e; - } - } - } - - // Handle progress if needed - if (typeof config.progress === 'function') { - if (config.method === 'post' || config.method === 'put') { - request.upload.addEventListener('progress', config.progress); - } else if (config.method === 'get') { - request.addEventListener('progress', config.progress); - } - } - - if (requestData === undefined) { - requestData = null; - } - - // Send the request - request.send(requestData); - }); - }; - - - /***/ }, - /* 11 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var createError = __webpack_require__(12); - - /** - * Resolve or reject a Promise based on response status. - * - * @param {Function} resolve A function that resolves the promise. - * @param {Function} reject A function that rejects the promise. - * @param {object} response The response. - */ - module.exports = function settle(resolve, reject, response) { - var validateStatus = response.config.validateStatus; - // Note: status is not exposed by XDomainRequest - if (!response.status || !validateStatus || validateStatus(response.status)) { - resolve(response); - } else { - reject(createError( - 'Request failed with status code ' + response.status, - response.config, - null, - response - )); - } - }; - - - /***/ }, - /* 12 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var enhanceError = __webpack_require__(13); - - /** - * Create an Error with the specified message, config, error code, and response. - * - * @param {string} message The error message. - * @param {Object} config The config. - * @param {string} [code] The error code (for example, 'ECONNABORTED'). - @ @param {Object} [response] The response. - * @returns {Error} The created error. - */ - module.exports = function createError(message, config, code, response) { - var error = new Error(message); - return enhanceError(error, config, code, response); - }; - - - /***/ }, - /* 13 */ - /***/ function(module, exports) { - - 'use strict'; - - /** - * Update an Error with the specified config, error code, and response. - * - * @param {Error} error The error to update. - * @param {Object} config The config. - * @param {string} [code] The error code (for example, 'ECONNABORTED'). - @ @param {Object} [response] The response. - * @returns {Error} The error. - */ - module.exports = function enhanceError(error, config, code, response) { - error.config = config; - if (code) { - error.code = code; - } - error.response = response; - return error; - }; - - - /***/ }, - /* 14 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - - function encode(val) { - return encodeURIComponent(val). - replace(/%40/gi, '@'). - replace(/%3A/gi, ':'). - replace(/%24/g, '$'). - replace(/%2C/gi, ','). - replace(/%20/g, '+'). - replace(/%5B/gi, '['). - replace(/%5D/gi, ']'); - } - - /** - * Build a URL by appending params to the end - * - * @param {string} url The base of the url (e.g., http://www.google.com) - * @param {object} [params] The params to be appended - * @returns {string} The formatted url - */ - module.exports = function buildURL(url, params, paramsSerializer) { - /*eslint no-param-reassign:0*/ - if (!params) { - return url; - } - - var serializedParams; - if (paramsSerializer) { - serializedParams = paramsSerializer(params); - } else if (utils.isURLSearchParams(params)) { - serializedParams = params.toString(); - } else { - var parts = []; - - utils.forEach(params, function serialize(val, key) { - if (val === null || typeof val === 'undefined') { - return; - } - - if (utils.isArray(val)) { - key = key + '[]'; - } - - if (!utils.isArray(val)) { - val = [val]; - } - - utils.forEach(val, function parseValue(v) { - if (utils.isDate(v)) { - v = v.toISOString(); - } else if (utils.isObject(v)) { - v = JSON.stringify(v); - } - parts.push(encode(key) + '=' + encode(v)); - }); - }); - - serializedParams = parts.join('&'); - } - - if (serializedParams) { - url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; - } - - return url; - }; - - - /***/ }, - /* 15 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - - /** - * Parse headers into an object - * - * ``` - * Date: Wed, 27 Aug 2014 08:58:49 GMT - * Content-Type: application/json - * Connection: keep-alive - * Transfer-Encoding: chunked - * ``` - * - * @param {String} headers Headers needing to be parsed - * @returns {Object} Headers parsed into an object - */ - module.exports = function parseHeaders(headers) { - var parsed = {}; - var key; - var val; - var i; - - if (!headers) { return parsed; } - - utils.forEach(headers.split('\n'), function parser(line) { - i = line.indexOf(':'); - key = utils.trim(line.substr(0, i)).toLowerCase(); - val = utils.trim(line.substr(i + 1)); - - if (key) { - parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; - } - }); - - return parsed; - }; - - - /***/ }, - /* 16 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - - module.exports = ( - utils.isStandardBrowserEnv() ? - - // Standard browser envs have full support of the APIs needed to test - // whether the request URL is of the same origin as current location. - (function standardBrowserEnv() { - var msie = /(msie|trident)/i.test(navigator.userAgent); - var urlParsingNode = document.createElement('a'); - var originURL; - - /** - * Parse a URL to discover it's components - * - * @param {String} url The URL to be parsed - * @returns {Object} - */ - function resolveURL(url) { - var href = url; - - if (msie) { - // IE needs attribute set twice to normalize properties - urlParsingNode.setAttribute('href', href); - href = urlParsingNode.href; - } - - urlParsingNode.setAttribute('href', href); - - // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils - return { - href: urlParsingNode.href, - protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', - host: urlParsingNode.host, - search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', - hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', - hostname: urlParsingNode.hostname, - port: urlParsingNode.port, - pathname: (urlParsingNode.pathname.charAt(0) === '/') ? - urlParsingNode.pathname : - '/' + urlParsingNode.pathname - }; - } - - originURL = resolveURL(window.location.href); - - /** - * Determine if a URL shares the same origin as the current location - * - * @param {String} requestURL The URL to test - * @returns {boolean} True if URL shares the same origin, otherwise false - */ - return function isURLSameOrigin(requestURL) { - var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; - return (parsed.protocol === originURL.protocol && - parsed.host === originURL.host); - }; - })() : - - // Non standard browser envs (web workers, react-native) lack needed support. - (function nonStandardBrowserEnv() { - return function isURLSameOrigin() { - return true; - }; - })() - ); - - - /***/ }, - /* 17 */ - /***/ function(module, exports) { - - 'use strict'; - - // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js - - var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - - function E() { - this.message = 'String contains an invalid character'; - } - E.prototype = new Error; - E.prototype.code = 5; - E.prototype.name = 'InvalidCharacterError'; - - function btoa(input) { - var str = String(input); - var output = ''; - for ( - // initialize result and counter - var block, charCode, idx = 0, map = chars; - // if the next str index does not exist: - // change the mapping table to "=" - // check if d has no fractional digits - str.charAt(idx | 0) || (map = '=', idx % 1); - // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 - output += map.charAt(63 & block >> 8 - idx % 1 * 8) - ) { - charCode = str.charCodeAt(idx += 3 / 4); - if (charCode > 0xFF) { - throw new E(); - } - block = block << 8 | charCode; - } - return output; - } - - module.exports = btoa; - - - /***/ }, - /* 18 */ - /***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(2); - - module.exports = ( - utils.isStandardBrowserEnv() ? - - // Standard browser envs support document.cookie - (function standardBrowserEnv() { - return { - write: function write(name, value, expires, path, domain, secure) { - var cookie = []; - cookie.push(name + '=' + encodeURIComponent(value)); - - if (utils.isNumber(expires)) { - cookie.push('expires=' + new Date(expires).toGMTString()); - } - - if (utils.isString(path)) { - cookie.push('path=' + path); - } - - if (utils.isString(domain)) { - cookie.push('domain=' + domain); - } - - if (secure === true) { - cookie.push('secure'); - } - - document.cookie = cookie.join('; '); - }, - - read: function read(name) { - var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); - return (match ? decodeURIComponent(match[3]) : null); - }, - - remove: function remove(name) { - this.write(name, '', Date.now() - 86400000); - } - }; - })() : - - // Non standard browser env (web workers, react-native) lack needed support. - (function nonStandardBrowserEnv() { - return { - write: function write() {}, - read: function read() { return null; }, - remove: function remove() {} - }; - })() - ); - - - /***/ }, - /* 19 */ - /***/ function(module, exports) { - - 'use strict'; - - /** - * Determines whether the specified URL is absolute - * - * @param {string} url The URL to test - * @returns {boolean} True if the specified URL is absolute, otherwise false - */ - module.exports = function isAbsoluteURL(url) { - // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). - // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed - // by any combination of letters, digits, plus, period, or hyphen. - return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); - }; - - - /***/ }, - /* 20 */ - /***/ function(module, exports) { - - 'use strict'; - - /** - * Creates a new URL by combining the specified URLs - * - * @param {string} baseURL The base URL - * @param {string} relativeURL The relative URL - * @returns {string} The combined URL - */ - module.exports = function combineURLs(baseURL, relativeURL) { - return baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, ''); - }; - - - /***/ }, - /* 21 */ - /***/ function(module, exports) { - - 'use strict'; - - /** - * Syntactic sugar for invoking a function and expanding an array for arguments. - * - * Common use case would be to use `Function.prototype.apply`. - * - * ```js - * function f(x, y, z) {} - * var args = [1, 2, 3]; - * f.apply(null, args); - * ``` - * - * With `spread` this example can be re-written. - * - * ```js - * spread(function(x, y, z) {})([1, 2, 3]); - * ``` - * - * @param {Function} callback - * @returns {Function} - */ - module.exports = function spread(callback) { - return function wrap(arr) { - return callback.apply(null, arr); - }; - }; - - - /***/ } - /******/ ]) + 'use strict'; + + var utils$$1 = __webpack_require__(2); + var normalizeHeaderName = __webpack_require__(7); + + var DEFAULT_CONTENT_TYPE = { + 'Content-Type': 'application/x-www-form-urlencoded' + }; + + function setContentTypeIfUnset(headers, value) { + if (!utils$$1.isUndefined(headers) && utils$$1.isUndefined(headers['Content-Type'])) { + headers['Content-Type'] = value; + } + } + + function getDefaultAdapter() { + var adapter; + if (typeof XMLHttpRequest !== 'undefined') { + // For browsers use XHR adapter + adapter = __webpack_require__(8); + } else if (typeof process !== 'undefined') { + // For node use HTTP adapter + adapter = __webpack_require__(8); + } + return adapter; + } + + var defaults = { + adapter: getDefaultAdapter(), + + transformRequest: [function transformRequest(data, headers) { + normalizeHeaderName(headers, 'Content-Type'); + if (utils$$1.isFormData(data) || + utils$$1.isArrayBuffer(data) || + utils$$1.isBuffer(data) || + utils$$1.isStream(data) || + utils$$1.isFile(data) || + utils$$1.isBlob(data) + ) { + return data; + } + if (utils$$1.isArrayBufferView(data)) { + return data.buffer; + } + if (utils$$1.isURLSearchParams(data)) { + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); + return data.toString(); + } + if (utils$$1.isObject(data)) { + setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); + return JSON.stringify(data); + } + return data; + }], + + transformResponse: [function transformResponse(data) { + /*eslint no-param-reassign:0*/ + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { /* Ignore */ } + } + return data; + }], + + timeout: 0, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN', + + maxContentLength: -1, + + validateStatus: function validateStatus(status) { + return status >= 200 && status < 300; + } + }; + + defaults.headers = { + common: { + 'Accept': 'application/json, text/plain, */*' + } + }; + + utils$$1.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { + defaults.headers[method] = {}; }); - ; + + utils$$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + defaults.headers[method] = utils$$1.merge(DEFAULT_CONTENT_TYPE); }); + + module.exports = defaults; + + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + module.exports = function normalizeHeaderName(headers, normalizedName) { + utils$$1.forEach(headers, function processHeader(value, name) { + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { + headers[normalizedName] = value; + delete headers[name]; + } + }); + }; - var axios$1 = interopDefault(axios); - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + var settle = __webpack_require__(9); + var buildURL = __webpack_require__(12); + var parseHeaders = __webpack_require__(13); + var isURLSameOrigin = __webpack_require__(14); + var createError = __webpack_require__(10); + var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15); + + module.exports = function xhrAdapter(config) { + return new Promise(function dispatchXhrRequest(resolve, reject) { + var requestData = config.data; + var requestHeaders = config.headers; + + if (utils$$1.isFormData(requestData)) { + delete requestHeaders['Content-Type']; // Let the browser set it + } + + var request = new XMLHttpRequest(); + var loadEvent = 'onreadystatechange'; + var xDomain = false; + + // For IE 8/9 CORS support + // Only supports POST and GET calls and doesn't returns the response headers. + // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest. + if (("production") !== 'test' && + typeof window !== 'undefined' && + window.XDomainRequest && !('withCredentials' in request) && + !isURLSameOrigin(config.url)) { + request = new window.XDomainRequest(); + loadEvent = 'onload'; + xDomain = true; + request.onprogress = function handleProgress() {}; + request.ontimeout = function handleTimeout() {}; + } + + // HTTP basic authentication + if (config.auth) { + var username = config.auth.username || ''; + var password = config.auth.password || ''; + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); + } + + request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true); + + // Set the request timeout in MS + request.timeout = config.timeout; + + // Listen for ready state + request[loadEvent] = function handleLoad() { + if (!request || (request.readyState !== 4 && !xDomain)) { + return; + } + + // The request errored out and we didn't get a response, this will be + // handled by onerror instead + // With one exception: request that using file: protocol, most browsers + // will return status as 0 even though it's a successful request + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { + return; + } + + // Prepare the response + var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; + var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; + var response = { + data: responseData, + // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201) + status: request.status === 1223 ? 204 : request.status, + statusText: request.status === 1223 ? 'No Content' : request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // Clean up request + request = null; + }; + + // Handle low level network errors + request.onerror = function handleError() { + // Real errors are hidden from us by the browser + // onerror should only fire if it's a network error + reject(createError('Network Error', config, null, request)); + + // Clean up request + request = null; + }; + + // Handle timeout + request.ontimeout = function handleTimeout() { + reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', + request)); + + // Clean up request + request = null; + }; + + // Add xsrf header + // This is only done if running in a standard browser environment. + // Specifically not if we're in a web worker, or react-native. + if (utils$$1.isStandardBrowserEnv()) { + var cookies = __webpack_require__(16); + + // Add xsrf header + var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? + cookies.read(config.xsrfCookieName) : + undefined; + + if (xsrfValue) { + requestHeaders[config.xsrfHeaderName] = xsrfValue; + } + } + + // Add headers to the request + if ('setRequestHeader' in request) { + utils$$1.forEach(requestHeaders, function setRequestHeader(val, key) { + if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { + // Remove Content-Type if data is undefined + delete requestHeaders[key]; + } else { + // Otherwise add header to the request + request.setRequestHeader(key, val); + } + }); + } + + // Add withCredentials to request if needed + if (config.withCredentials) { + request.withCredentials = true; + } + + // Add responseType to request if needed + if (config.responseType) { + try { + request.responseType = config.responseType; + } catch (e) { + // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. + // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. + if (config.responseType !== 'json') { + throw e; + } + } + } + + // Handle progress if needed + if (typeof config.onDownloadProgress === 'function') { + request.addEventListener('progress', config.onDownloadProgress); + } + + // Not all browsers support upload events + if (typeof config.onUploadProgress === 'function' && request.upload) { + request.upload.addEventListener('progress', config.onUploadProgress); + } + + if (config.cancelToken) { + // Handle cancellation + config.cancelToken.promise.then(function onCanceled(cancel) { + if (!request) { + return; + } + + request.abort(); + reject(cancel); + // Clean up request + request = null; + }); + } + + if (requestData === undefined) { + requestData = null; + } + + // Send the request + request.send(requestData); + }); }; - var defineProperty = function (obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var createError = __webpack_require__(10); + + /** + * Resolve or reject a Promise based on response status. + * + * @param {Function} resolve A function that resolves the promise. + * @param {Function} reject A function that rejects the promise. + * @param {object} response The response. + */ + module.exports = function settle(resolve, reject, response) { + var validateStatus = response.config.validateStatus; + // Note: status is not exposed by XDomainRequest + if (!response.status || !validateStatus || validateStatus(response.status)) { + resolve(response); } else { - obj[key] = value; + reject(createError( + 'Request failed with status code ' + response.status, + response.config, + null, + response.request, + response + )); } + }; + - return obj; +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var enhanceError = __webpack_require__(11); + + /** + * Create an Error with the specified message, config, error code, request and response. + * + * @param {string} message The error message. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The created error. + */ + module.exports = function createError(message, config, code, request, response) { + var error = new Error(message); + return enhanceError(error, config, code, request, response); + }; + + +/***/ }, +/* 11 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Update an Error with the specified config, error code, and response. + * + * @param {Error} error The error to update. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The error. + */ + module.exports = function enhanceError(error, config, code, request, response) { + error.config = config; + if (code) { + error.code = code; + } + error.request = request; + error.response = response; + return error; + }; + + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + function encode(val) { + return encodeURIComponent(val). + replace(/%40/gi, '@'). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%20/g, '+'). + replace(/%5B/gi, '['). + replace(/%5D/gi, ']'); + } + + /** + * Build a URL by appending params to the end + * + * @param {string} url The base of the url (e.g., http://www.google.com) + * @param {object} [params] The params to be appended + * @returns {string} The formatted url + */ + module.exports = function buildURL(url, params, paramsSerializer) { + /*eslint no-param-reassign:0*/ + if (!params) { + return url; + } + + var serializedParams; + if (paramsSerializer) { + serializedParams = paramsSerializer(params); + } else if (utils$$1.isURLSearchParams(params)) { + serializedParams = params.toString(); + } else { + var parts = []; + + utils$$1.forEach(params, function serialize(val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + + if (utils$$1.isArray(val)) { + key = key + '[]'; + } + + if (!utils$$1.isArray(val)) { + val = [val]; + } + + utils$$1.forEach(val, function parseValue(v) { + if (utils$$1.isDate(v)) { + v = v.toISOString(); + } else if (utils$$1.isObject(v)) { + v = JSON.stringify(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + serializedParams = parts.join('&'); + } + + if (serializedParams) { + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; + } + + return url; + }; + + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + /** + * Parse headers into an object + * + * ``` + * Date: Wed, 27 Aug 2014 08:58:49 GMT + * Content-Type: application/json + * Connection: keep-alive + * Transfer-Encoding: chunked + * ``` + * + * @param {String} headers Headers needing to be parsed + * @returns {Object} Headers parsed into an object + */ + module.exports = function parseHeaders(headers) { + var parsed = {}; + var key; + var val; + var i; + + if (!headers) { return parsed; } + + utils$$1.forEach(headers.split('\n'), function parser(line) { + i = line.indexOf(':'); + key = utils$$1.trim(line.substr(0, i)).toLowerCase(); + val = utils$$1.trim(line.substr(i + 1)); + + if (key) { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + }); + + return parsed; + }; + + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + module.exports = ( + utils$$1.isStandardBrowserEnv() ? + + // Standard browser envs have full support of the APIs needed to test + // whether the request URL is of the same origin as current location. + (function standardBrowserEnv() { + var msie = /(msie|trident)/i.test(navigator.userAgent); + var urlParsingNode = document.createElement('a'); + var originURL; + + /** + * Parse a URL to discover it's components + * + * @param {String} url The URL to be parsed + * @returns {Object} + */ + function resolveURL(url) { + var href = url; + + if (msie) { + // IE needs attribute set twice to normalize properties + urlParsingNode.setAttribute('href', href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') ? + urlParsingNode.pathname : + '/' + urlParsingNode.pathname + }; + } + + originURL = resolveURL(window.location.href); + + /** + * Determine if a URL shares the same origin as the current location + * + * @param {String} requestURL The URL to test + * @returns {boolean} True if URL shares the same origin, otherwise false + */ + return function isURLSameOrigin(requestURL) { + var parsed = (utils$$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL; + return (parsed.protocol === originURL.protocol && + parsed.host === originURL.host); + }; + })() : + + // Non standard browser envs (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return function isURLSameOrigin() { + return true; + }; + })() + ); + + +/***/ }, +/* 15 */ +/***/ function(module, exports) { + + 'use strict'; + + // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js + + var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + function E() { + this.message = 'String contains an invalid character'; + } + E.prototype = new Error; + E.prototype.code = 5; + E.prototype.name = 'InvalidCharacterError'; + + function btoa(input) { + var str = String(input); + var output = ''; + for ( + // initialize result and counter + var block, charCode, idx = 0, map = chars; + // if the next str index does not exist: + // change the mapping table to "=" + // check if d has no fractional digits + str.charAt(idx | 0) || (map = '=', idx % 1); + // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 + output += map.charAt(63 & block >> 8 - idx % 1 * 8) + ) { + charCode = str.charCodeAt(idx += 3 / 4); + if (charCode > 0xFF) { + throw new E(); + } + block = block << 8 | charCode; + } + return output; + } + + module.exports = btoa; + + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + module.exports = ( + utils$$1.isStandardBrowserEnv() ? + + // Standard browser envs support document.cookie + (function standardBrowserEnv() { + return { + write: function write(name, value, expires, path, domain, secure) { + var cookie = []; + cookie.push(name + '=' + encodeURIComponent(value)); + + if (utils$$1.isNumber(expires)) { + cookie.push('expires=' + new Date(expires).toGMTString()); + } + + if (utils$$1.isString(path)) { + cookie.push('path=' + path); + } + + if (utils$$1.isString(domain)) { + cookie.push('domain=' + domain); + } + + if (secure === true) { + cookie.push('secure'); + } + + document.cookie = cookie.join('; '); + }, + + read: function read(name) { + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, + + remove: function remove(name) { + this.write(name, '', Date.now() - 86400000); + } + }; + })() : + + // Non standard browser env (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return { + write: function write() {}, + read: function read() { return null; }, + remove: function remove() {} + }; + })() + ); + + +/***/ }, +/* 17 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + function InterceptorManager() { + this.handlers = []; + } + + /** + * Add a new interceptor to the stack + * + * @param {Function} fulfilled The function to handle `then` for a `Promise` + * @param {Function} rejected The function to handle `reject` for a `Promise` + * + * @return {Number} An ID used to remove interceptor later + */ + InterceptorManager.prototype.use = function use(fulfilled, rejected) { + this.handlers.push({ + fulfilled: fulfilled, + rejected: rejected + }); + return this.handlers.length - 1; + }; + + /** + * Remove an interceptor from the stack + * + * @param {Number} id The ID that was returned by `use` + */ + InterceptorManager.prototype.eject = function eject(id) { + if (this.handlers[id]) { + this.handlers[id] = null; + } + }; + + /** + * Iterate over all the registered interceptors + * + * This method is particularly useful for skipping over any + * interceptors that may have become `null` calling `eject`. + * + * @param {Function} fn The function to call for each interceptor + */ + InterceptorManager.prototype.forEach = function forEach(fn) { + utils$$1.forEach(this.handlers, function forEachHandler(h) { + if (h !== null) { + fn(h); + } + }); + }; + + module.exports = InterceptorManager; + + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + var transformData = __webpack_require__(19); + var isCancel = __webpack_require__(20); + var defaults = __webpack_require__(6); + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + function throwIfCancellationRequested(config) { + if (config.cancelToken) { + config.cancelToken.throwIfRequested(); + } + } + + /** + * Dispatch a request to the server using the configured adapter. + * + * @param {object} config The config that is to be used for the request + * @returns {Promise} The Promise to be fulfilled + */ + module.exports = function dispatchRequest(config) { + throwIfCancellationRequested(config); + + // Ensure headers exist + config.headers = config.headers || {}; + + // Transform request data + config.data = transformData( + config.data, + config.headers, + config.transformRequest + ); + + // Flatten headers + config.headers = utils$$1.merge( + config.headers.common || {}, + config.headers[config.method] || {}, + config.headers || {} + ); + + utils$$1.forEach( + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], + function cleanHeaderConfig(method) { + delete config.headers[method]; + } + ); + + var adapter = config.adapter || defaults.adapter; + + return adapter(config).then(function onAdapterResolution(response) { + throwIfCancellationRequested(config); + + // Transform response data + response.data = transformData( + response.data, + response.headers, + config.transformResponse + ); + + return response; + }, function onAdapterRejection(reason) { + if (!isCancel(reason)) { + throwIfCancellationRequested(config); + + // Transform response data + if (reason && reason.response) { + reason.response.data = transformData( + reason.response.data, + reason.response.headers, + config.transformResponse + ); + } + } + + return Promise.reject(reason); + }); + }; + + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + /** + * Transform the data for a request or a response + * + * @param {Object|String} data The data to be transformed + * @param {Array} headers The headers for the request or response + * @param {Array|Function} fns A single function or Array of functions + * @returns {*} The resulting transformed data + */ + module.exports = function transformData(data, headers, fns) { + /*eslint no-param-reassign:0*/ + utils$$1.forEach(fns, function transform(fn) { + data = fn(data, headers); + }); + + return data; + }; + + +/***/ }, +/* 20 */ +/***/ function(module, exports) { + + 'use strict'; + + module.exports = function isCancel(value) { + return !!(value && value.__CANCEL__); + }; + + +/***/ }, +/* 21 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ + module.exports = function isAbsoluteURL(url) { + // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed + // by any combination of letters, digits, plus, period, or hyphen. + return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); }; - var slicedToArray = function () { - function sliceIterator(arr, i) { - var _arr = []; - var _n = true; - var _d = false; - var _e = undefined; - - try { - for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"]) _i["return"](); - } finally { - if (_d) throw _e; - } - } +/***/ }, +/* 22 */ +/***/ function(module, exports) { - return _arr; - } + 'use strict'; + + /** + * Creates a new URL by combining the specified URLs + * + * @param {string} baseURL The base URL + * @param {string} relativeURL The relative URL + * @returns {string} The combined URL + */ + module.exports = function combineURLs(baseURL, relativeURL) { + return relativeURL + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') + : baseURL; + }; - return function (arr, i) { - if (Array.isArray(arr)) { - return arr; - } else if (Symbol.iterator in Object(arr)) { - return sliceIterator(arr, i); - } else { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); - } - }; - }(); - var noop = function noop() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } +/***/ }, +/* 23 */ +/***/ function(module, exports) { - var opts = args[args.length - 1]; - this.dbg.apply(this, [opts.op].concat(args)); - return jsData.utils.resolve(); + 'use strict'; + + /** + * A `Cancel` is an object that is thrown when an operation is canceled. + * + * @class + * @param {string=} message The message. + */ + function Cancel(message) { + this.message = message; + } + + Cancel.prototype.toString = function toString() { + return 'Cancel' + (this.message ? ': ' + this.message : ''); }; + + Cancel.prototype.__CANCEL__ = true; + + module.exports = Cancel; - var noop2 = function noop2() { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - var opts = args[args.length - 2]; - this.dbg.apply(this, [opts.op].concat(args)); - return jsData.utils.resolve(); - }; +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { - var unique = function unique(array) { - var seen = {}; - var final = []; - array.forEach(function (item) { - if (item in seen) { + 'use strict'; + + var Cancel = __webpack_require__(23); + + /** + * A `CancelToken` is an object that can be used to request cancellation of an operation. + * + * @class + * @param {Function} executor The executor function. + */ + function CancelToken(executor) { + if (typeof executor !== 'function') { + throw new TypeError('executor must be a function.'); + } + + var resolvePromise; + this.promise = new Promise(function promiseExecutor(resolve) { + resolvePromise = resolve; + }); + + var token = this; + executor(function cancel(message) { + if (token.reason) { + // Cancellation has already been requested return; } - final.push(item); - seen[item] = 0; + + token.reason = new Cancel(message); + resolvePromise(token.reason); }); - return final; + } + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + CancelToken.prototype.throwIfRequested = function throwIfRequested() { + if (this.reason) { + throw this.reason; + } }; - - var withoutRelations = function withoutRelations(mapper, props, opts) { - opts || (opts = {}); - opts.with || (opts.with = []); - var relationFields = mapper.relationFields || []; - var toStrip = relationFields.filter(function (value) { - return opts.with.indexOf(value) === -1; + + /** + * Returns an object that contains a new `CancelToken` and a function that, when called, + * cancels the `CancelToken`. + */ + CancelToken.source = function source() { + var cancel; + var token = new CancelToken(function executor(c) { + cancel = c; }); - return jsData.utils.omit(props, toStrip); + return { + token: token, + cancel: cancel + }; }; + + module.exports = CancelToken; - /** - * Response object used when `raw` is `true`. May contain other fields in - * addition to `data`. - * - * @class Response - */ - function Response(data, meta, op) { - meta || (meta = {}); - - /** - * Response data. - * - * @name Response#data - * @type {*} - */ - this.data = data; - - jsData.utils.fillIn(this, meta); - - /** - * The operation for which the response was created. - * - * @name Response#op - * @type {string} - */ - this.op = op; - } - var DEFAULTS$1 = { - /** - * Whether to log debugging information. - * - * @name Adapter#debug - * @type {boolean} - * @default false - */ - debug: false, - - /** - * Whether to return a more detailed response object. - * - * @name Adapter#raw - * @type {boolean} - * @default false - */ - raw: false - }; +/***/ }, +/* 25 */ +/***/ function(module, exports) { + 'use strict'; + /** - * Abstract class meant to be extended by adapters. + * Syntactic sugar for invoking a function and expanding an array for arguments. + * + * Common use case would be to use `Function.prototype.apply`. * - * @class Adapter - * @abstract - * @extends Component - * @param {Object} [opts] Configuration opts. - * @param {boolean} [opts.debug=false] Whether to log debugging information. - * @param {boolean} [opts.raw=false] Whether to return a more detailed response - * object. + * ```js + * function f(x, y, z) {} + * var args = [1, 2, 3]; + * f.apply(null, args); + * ``` + * + * With `spread` this example can be re-written. + * + * ```js + * spread(function(x, y, z) {})([1, 2, 3]); + * ``` + * + * @param {Function} callback + * @returns {Function} */ - function Adapter(opts) { - jsData.utils.classCallCheck(this, Adapter); - jsData.Component.call(this, opts); - opts || (opts = {}); - jsData.utils.fillIn(opts, DEFAULTS$1); - jsData.utils.fillIn(this, opts); - } + module.exports = function spread(callback) { + return function wrap(arr) { + return callback.apply(null, arr); + }; + }; - jsData.Component.extend({ - constructor: Adapter, - - /** - * Lifecycle method method called by count. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes count to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. - * - * @name Adapter#afterCount - * @method - * @param {Object} mapper The `mapper` argument passed to count. - * @param {Object} props The `props` argument passed to count. - * @param {Object} opts The `opts` argument passed to count. - * @property {string} opts.op `afterCount` - * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. - */ - afterCount: noop2, - - /** - * Lifecycle method method called by create. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes create to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. - * - * @name Adapter#afterCreate - * @method - * @param {Object} mapper The `mapper` argument passed to create. - * @param {Object} props The `props` argument passed to create. - * @param {Object} opts The `opts` argument passed to create. - * @property {string} opts.op `afterCreate` - * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. - */ - afterCreate: noop2, - - /** - * Lifecycle method method called by createMany. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. - * - * @name Adapter#afterCreate - * @method - * @param {Object} mapper The `mapper` argument passed to createMany. - * @param {Object[]} props The `props` argument passed to createMany. - * @param {Object} opts The `opts` argument passed to createMany. - * @property {string} opts.op `afterCreateMany` - * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. - */ - afterCreateMany: noop2, - - /** - * Lifecycle method method called by destroy. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. - * - * @name Adapter#afterDestroy - * @method - * @param {Object} mapper The `mapper` argument passed to destroy. - * @param {(string|number)} id The `id` argument passed to destroy. - * @param {Object} opts The `opts` argument passed to destroy. - * @property {string} opts.op `afterDestroy` - * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. - */ - afterDestroy: noop2, - - /** - * Lifecycle method method called by destroyAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. - * - * @name Adapter#afterDestroyAll - * @method - * @param {Object} mapper The `mapper` argument passed to destroyAll. - * @param {Object} query The `query` argument passed to destroyAll. - * @param {Object} opts The `opts` argument passed to destroyAll. - * @property {string} opts.op `afterDestroyAll` - * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. - */ - afterDestroyAll: noop2, - - /** - * Lifecycle method method called by find. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes find to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. - * - * @name Adapter#afterFind - * @method - * @param {Object} mapper The `mapper` argument passed to find. - * @param {(string|number)} id The `id` argument passed to find. - * @param {Object} opts The `opts` argument passed to find. - * @property {string} opts.op `afterFind` - * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`. - */ - afterFind: noop2, - - /** - * Lifecycle method method called by findAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. - * - * @name Adapter#afterFindAll - * @method - * @param {Object} mapper The `mapper` argument passed to findAll. - * @param {Object} query The `query` argument passed to findAll. - * @param {Object} opts The `opts` argument passed to findAll. - * @property {string} opts.op `afterFindAll` - * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`. - */ - afterFindAll: noop2, - - /** - * Lifecycle method method called by sum. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes sum to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. - * - * @name Adapter#afterSum - * @method - * @param {Object} mapper The `mapper` argument passed to sum. - * @param {string} field The `field` argument passed to sum. - * @param {Object} query The `query` argument passed to sum. - * @param {Object} opts The `opts` argument passed to sum. - * @property {string} opts.op `afterSum` - * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. - */ - afterSum: noop2, - - /** - * Lifecycle method method called by update. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes update to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. - * - * @name Adapter#afterUpdate - * @method - * @param {Object} mapper The `mapper` argument passed to update. - * @param {(string|number)} id The `id` argument passed to update. - * @param {Object} props The `props` argument passed to update. - * @param {Object} opts The `opts` argument passed to update. - * @property {string} opts.op `afterUpdate` - * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`. - */ - afterUpdate: noop2, - - /** - * Lifecycle method method called by updateAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. - * - * @name Adapter#afterUpdateAll - * @method - * @param {Object} mapper The `mapper` argument passed to updateAll. - * @param {Object} props The `props` argument passed to updateAll. - * @param {Object} query The `query` argument passed to updateAll. - * @param {Object} opts The `opts` argument passed to updateAll. - * @property {string} opts.op `afterUpdateAll` - * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. - */ - afterUpdateAll: noop2, - - /** - * Lifecycle method method called by updateMany. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. - * - * @name Adapter#afterUpdateMany - * @method - * @param {Object} mapper The `mapper` argument passed to updateMany. - * @param {Object[]} records The `records` argument passed to updateMany. - * @param {Object} opts The `opts` argument passed to updateMany. - * @property {string} opts.op `afterUpdateMany` - * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. - */ - afterUpdateMany: noop2, - - /** - * Lifecycle method method called by count. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes count to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. - * - * @name Adapter#beforeCount - * @method - * @param {Object} mapper The `mapper` argument passed to count. - * @param {Object} query The `query` argument passed to count. - * @param {Object} opts The `opts` argument passed to count. - * @property {string} opts.op `beforeCount` - */ - beforeCount: noop, - - /** - * Lifecycle method method called by create. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes create to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. - * - * @name Adapter#beforeCreate - * @method - * @param {Object} mapper The `mapper` argument passed to create. - * @param {Object} props The `props` argument passed to create. - * @param {Object} opts The `opts` argument passed to create. - * @property {string} opts.op `beforeCreate` - */ - beforeCreate: noop, - - /** - * Lifecycle method method called by createMany. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. - * - * @name Adapter#beforeCreateMany - * @method - * @param {Object} mapper The `mapper` argument passed to createMany. - * @param {Object[]} props The `props` argument passed to createMany. - * @param {Object} opts The `opts` argument passed to createMany. - * @property {string} opts.op `beforeCreateMany` - */ - beforeCreateMany: noop, - - /** - * Lifecycle method method called by destroy. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. - * - * @name Adapter#beforeDestroy - * @method - * @param {Object} mapper The `mapper` argument passed to destroy. - * @param {(string|number)} id The `id` argument passed to destroy. - * @param {Object} opts The `opts` argument passed to destroy. - * @property {string} opts.op `beforeDestroy` - */ - beforeDestroy: noop, - - /** - * Lifecycle method method called by destroyAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. - * - * @name Adapter#beforeDestroyAll - * @method - * @param {Object} mapper The `mapper` argument passed to destroyAll. - * @param {Object} query The `query` argument passed to destroyAll. - * @param {Object} opts The `opts` argument passed to destroyAll. - * @property {string} opts.op `beforeDestroyAll` - */ - beforeDestroyAll: noop, - - /** - * Lifecycle method method called by find. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes find to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. - * - * @name Adapter#beforeFind - * @method - * @param {Object} mapper The `mapper` argument passed to find. - * @param {(string|number)} id The `id` argument passed to find. - * @param {Object} opts The `opts` argument passed to find. - * @property {string} opts.op `beforeFind` - */ - beforeFind: noop, - - /** - * Lifecycle method method called by findAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. - * - * @name Adapter#beforeFindAll - * @method - * @param {Object} mapper The `mapper` argument passed to findAll. - * @param {Object} query The `query` argument passed to findAll. - * @param {Object} opts The `opts` argument passed to findAll. - * @property {string} opts.op `beforeFindAll` - */ - beforeFindAll: noop, - - /** - * Lifecycle method method called by sum. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes sum to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. - * - * @name Adapter#beforeSum - * @method - * @param {Object} mapper The `mapper` argument passed to sum. - * @param {Object} query The `query` argument passed to sum. - * @param {Object} opts The `opts` argument passed to sum. - * @property {string} opts.op `beforeSum` - */ - beforeSum: noop, - - /** - * Lifecycle method method called by update. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes update to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. - * - * @name Adapter#beforeUpdate - * @method - * @param {Object} mapper The `mapper` argument passed to update. - * @param {(string|number)} id The `id` argument passed to update. - * @param {Object} props The `props` argument passed to update. - * @param {Object} opts The `opts` argument passed to update. - * @property {string} opts.op `beforeUpdate` - */ - beforeUpdate: noop, - - /** - * Lifecycle method method called by updateAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. - * - * @name Adapter#beforeUpdateAll - * @method - * @param {Object} mapper The `mapper` argument passed to updateAll. - * @param {Object} props The `props` argument passed to updateAll. - * @param {Object} query The `query` argument passed to updateAll. - * @param {Object} opts The `opts` argument passed to updateAll. - * @property {string} opts.op `beforeUpdateAll` - */ - beforeUpdateAll: noop, - - /** - * Lifecycle method method called by updateMany. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. - * - * @name Adapter#beforeUpdateMany - * @method - * @param {Object} mapper The `mapper` argument passed to updateMany. - * @param {Object[]} props The `props` argument passed to updateMany. - * @param {Object} opts The `opts` argument passed to updateMany. - * @property {string} opts.op `beforeUpdateMany` - */ - beforeUpdateMany: noop, - - /** - * Retrieve the number of records that match the selection query. Called by - * `Mapper#count`. - * - * @name Adapter#count - * @method - * @param {Object} mapper The mapper. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - count: function count(mapper, query, opts) { - var _this = this; - - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeCount lifecycle hook - op = opts.op = 'beforeCount'; - return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'count'; - _this.dbg(op, mapper, query, opts); - return jsData.utils.resolve(_this._count(mapper, query, opts)); - }).then(function (results) { - var _results = slicedToArray(results, 2); - - var data = _results[0]; - var result = _results[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = _this.respond(response, opts); - - // afterCount lifecycle hook - op = opts.op = 'afterCount'; - return jsData.utils.resolve(_this[op](mapper, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Create a new record. Called by `Mapper#create`. - * - * @name Adapter#create - * @method - * @param {Object} mapper The mapper. - * @param {Object} props The record to be created. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - create: function create(mapper, props, opts) { - var _this2 = this; - - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreate lifecycle hook - op = opts.op = 'beforeCreate'; - return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = _props === undefined ? props : _props; - props = withoutRelations(mapper, props, opts); - op = opts.op = 'create'; - _this2.dbg(op, mapper, props, opts); - return jsData.utils.resolve(_this2._create(mapper, props, opts)); - }).then(function (results) { - var _results2 = slicedToArray(results, 2); - - var data = _results2[0]; - var result = _results2[1]; - - result || (result = {}); - var response = new Response(data, result, 'create'); - response.created = data ? 1 : 0; - response = _this2.respond(response, opts); - - // afterCreate lifecycle hook - op = opts.op = 'afterCreate'; - return jsData.utils.resolve(_this2[op](mapper, props, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Create multiple records in a single batch. Called by `Mapper#createMany`. - * - * @name Adapter#createMany - * @method - * @param {Object} mapper The mapper. - * @param {Object} props The records to be created. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - createMany: function createMany(mapper, props, opts) { - var _this3 = this; - - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreateMany lifecycle hook - op = opts.op = 'beforeCreateMany'; - return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = _props === undefined ? props : _props; - props = props.map(function (record) { - return withoutRelations(mapper, record, opts); - }); - op = opts.op = 'createMany'; - _this3.dbg(op, mapper, props, opts); - return jsData.utils.resolve(_this3._createMany(mapper, props, opts)); - }).then(function (results) { - var _results3 = slicedToArray(results, 2); - - var data = _results3[0]; - var result = _results3[1]; - - data || (data = []); - result || (result = {}); - var response = new Response(data, result, 'createMany'); - response.created = data.length; - response = _this3.respond(response, opts); - - // afterCreateMany lifecycle hook - op = opts.op = 'afterCreateMany'; - return jsData.utils.resolve(_this3[op](mapper, props, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Destroy the record with the given primary key. Called by - * `Mapper#destroy`. - * - * @name Adapter#destroy - * @method - * @param {Object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to destroy. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - destroy: function destroy(mapper, id, opts) { - var _this4 = this; - - var op = void 0; - opts || (opts = {}); - - // beforeDestroy lifecycle hook - op = opts.op = 'beforeDestroy'; - return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { - op = opts.op = 'destroy'; - _this4.dbg(op, mapper, id, opts); - return jsData.utils.resolve(_this4._destroy(mapper, id, opts)); - }).then(function (results) { - var _results4 = slicedToArray(results, 2); - - var data = _results4[0]; - var result = _results4[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroy'); - response = _this4.respond(response, opts); - - // afterDestroy lifecycle hook - op = opts.op = 'afterDestroy'; - return jsData.utils.resolve(_this4[op](mapper, id, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Destroy the records that match the selection query. Called by - * `Mapper#destroyAll`. - * - * @name Adapter#destroyAll - * @method - * @param {Object} mapper the mapper. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - destroyAll: function destroyAll(mapper, query, opts) { - var _this5 = this; - - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeDestroyAll lifecycle hook - op = opts.op = 'beforeDestroyAll'; - return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { - op = opts.op = 'destroyAll'; - _this5.dbg(op, mapper, query, opts); - return jsData.utils.resolve(_this5._destroyAll(mapper, query, opts)); - }).then(function (results) { - var _results5 = slicedToArray(results, 2); - - var data = _results5[0]; - var result = _results5[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroyAll'); - response = _this5.respond(response, opts); - - // afterDestroyAll lifecycle hook - op = opts.op = 'afterDestroyAll'; - return jsData.utils.resolve(_this5[op](mapper, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Load a belongsTo relationship. - * - * Override with care. - * - * @name Adapter#loadBelongsTo - * @method - * @return {Promise} - */ - loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { - var _this6 = this; - - var relationDef = def.getRelation(); - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - var _ret = function () { - var record = records; - return { - v: _this6.find(relationDef, _this6.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { - def.setLocalField(record, relatedItem); - }) - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; - } else { - var keys = records.map(function (record) { - return _this6.makeBelongsToForeignKey(mapper, def, record); - }).filter(function (key) { - return key; - }); - return this.findAll(relationDef, { - where: defineProperty({}, relationDef.idAttribute, { - 'in': keys - }) - }, __opts).then(function (relatedItems) { - records.forEach(function (record) { - relatedItems.forEach(function (relatedItem) { - if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { - def.setLocalField(record, relatedItem); - } - }); - }); - }); - } - }, - - - /** - * Retrieve the record with the given primary key. Called by `Mapper#find`. - * - * @name Adapter#find - * @method - * @param {Object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to retrieve. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @param {string[]} [opts.with=[]] Relations to eager load. - * @return {Promise} - */ - find: function find(mapper, id, opts) { - var _this7 = this; - - var record = void 0, - op = void 0; - var meta = {}; - opts || (opts = {}); - opts.with || (opts.with = []); - - // beforeFind lifecycle hook - op = opts.op = 'beforeFind'; - return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { - op = opts.op = 'find'; - _this7.dbg(op, mapper, id, opts); - return jsData.utils.resolve(_this7._find(mapper, id, opts)); - }).then(function (results) { - var _results6 = slicedToArray(results, 2); - - var _record = _results6[0]; - var _meta = _results6[1]; - - if (!_record) { - return; - } - record = _record; - meta = _meta; - var tasks = []; - - jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { - var task = void 0; - if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { - if (def.type === 'hasOne') { - task = _this7.loadHasOne(mapper, def, record, __opts); - } else { - task = _this7.loadHasMany(mapper, def, record, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = _this7.loadHasManyLocalKeys(mapper, def, record, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = _this7.loadHasManyForeignKeys(mapper, def, record, __opts); - } else if (def.type === 'belongsTo') { - task = _this7.loadBelongsTo(mapper, def, record, __opts); - } - if (task) { - tasks.push(task); - } - }); - return jsData.utils.Promise.all(tasks); - }).then(function () { - var response = new Response(record, meta, 'find'); - response.found = record ? 1 : 0; - response = _this7.respond(response, opts); +/***/ } +/******/ ]) +}); - // afterFind lifecycle hook - op = opts.op = 'afterFind'; - return jsData.utils.resolve(_this7[op](mapper, id, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Retrieve the records that match the selection query. - * - * @name Adapter#findAll - * @method - * @param {Object} mapper The mapper. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @param {string[]} [opts.with=[]] Relations to eager load. - * @return {Promise} - */ - findAll: function findAll(mapper, query, opts) { - var _this8 = this; - - opts || (opts = {}); - opts.with || (opts.with = []); - - var records = []; - var meta = {}; - var op = void 0; - var activeWith = opts._activeWith; - - if (jsData.utils.isObject(activeWith)) { - var activeQuery = activeWith.query || {}; - if (activeWith.replace) { - query = activeQuery; - } else { - jsData.utils.deepFillIn(query, activeQuery); - } - } - // beforeFindAll lifecycle hook - op = opts.op = 'beforeFindAll'; - return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { - op = opts.op = 'findAll'; - _this8.dbg(op, mapper, query, opts); - return jsData.utils.resolve(_this8._findAll(mapper, query, opts)); - }).then(function (results) { - var _results7 = slicedToArray(results, 2); - - var _records = _results7[0]; - var _meta = _results7[1]; - - _records || (_records = []); - records = _records; - meta = _meta; - var tasks = []; - jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { - var task = void 0; - if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { - if (def.type === 'hasMany') { - task = _this8.loadHasMany(mapper, def, records, __opts); - } else { - task = _this8.loadHasOne(mapper, def, records, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = _this8.loadHasManyLocalKeys(mapper, def, records, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = _this8.loadHasManyForeignKeys(mapper, def, records, __opts); - } else if (def.type === 'belongsTo') { - task = _this8.loadBelongsTo(mapper, def, records, __opts); - } - if (task) { - tasks.push(task); - } - }); - return jsData.utils.Promise.all(tasks); - }).then(function () { - var response = new Response(records, meta, 'findAll'); - response.found = records.length; - response = _this8.respond(response, opts); - - // afterFindAll lifecycle hook - op = opts.op = 'afterFindAll'; - return jsData.utils.resolve(_this8[op](mapper, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Resolve the value of the specified option based on the given options and - * this adapter's settings. Override with care. - * - * @name Adapter#getOpt - * @method - * @param {string} opt The name of the option. - * @param {Object} [opts] Configuration options. - * @return {*} The value of the specified option. - */ - getOpt: function getOpt(opt, opts) { - opts || (opts = {}); - return opts[opt] === undefined ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); - }, - - - /** - * Load a hasMany relationship. - * - * Override with care. - * - * @name Adapter#loadHasMany - * @method - * @return {Promise} - */ - loadHasMany: function loadHasMany(mapper, def, records, __opts) { - var _this9 = this; - - var singular = false; - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - singular = true; - records = [records]; - } - var IDs = records.map(function (record) { - return _this9.makeHasManyForeignKey(mapper, def, record); - }); - var query = { - where: {} - }; - var criteria = query.where[def.foreignKey] = {}; - if (singular) { - // more efficient query when we only have one record - criteria['=='] = IDs[0]; - } else { - criteria['in'] = IDs.filter(function (id) { - return id; - }); - } - return this.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { - records.forEach(function (record) { - var attached = []; - // avoid unneccesary iteration when we only have one record - if (singular) { - attached = relatedItems; - } else { - relatedItems.forEach(function (relatedItem) { - if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { - attached.push(relatedItem); - } - }); - } - def.setLocalField(record, attached); - }); - }); - }, - loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { - var _this10 = this; +}); - var record = void 0; - var relatedMapper = def.getRelation(); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - record = records; - } - if (record) { - return this.findAll(relatedMapper, { - where: defineProperty({}, relatedMapper.idAttribute, { - 'in': this.makeHasManyLocalKeys(mapper, def, record) - }) - }, __opts).then(function (relatedItems) { - def.setLocalField(record, relatedItems); - }); - } else { - var _ret2 = function () { - var localKeys = []; - records.forEach(function (record) { - localKeys = localKeys.concat(_this10.makeHasManyLocalKeys(mapper, def, record)); - }); - return { - v: _this10.findAll(relatedMapper, { - where: defineProperty({}, relatedMapper.idAttribute, { - 'in': unique(localKeys).filter(function (x) { - return x; - }) - }) - }, __opts).then(function (relatedItems) { - records.forEach(function (item) { - var attached = []; - var itemKeys = jsData.utils.get(item, def.localKeys) || []; - itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); - relatedItems.forEach(function (relatedItem) { - if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { - attached.push(relatedItem); - } - }); - def.setLocalField(item, attached); - }); - return relatedItems; - }) - }; - }(); - - if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v; - } - }, - loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { - var _this11 = this; - var relatedMapper = def.getRelation(); - var idAttribute = mapper.idAttribute; - var record = void 0; - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - record = records; - } - if (record) { - return this.findAll(def.getRelation(), { - where: defineProperty({}, def.foreignKeys, { - 'contains': this.makeHasManyForeignKeys(mapper, def, record) - }) - }, __opts).then(function (relatedItems) { - def.setLocalField(record, relatedItems); - }); - } else { - return this.findAll(relatedMapper, { - where: defineProperty({}, def.foreignKeys, { - 'isectNotEmpty': records.map(function (record) { - return _this11.makeHasManyForeignKeys(mapper, def, record); - }) - }) - }, __opts).then(function (relatedItems) { - var foreignKeysField = def.foreignKeys; - records.forEach(function (record) { - var _relatedItems = []; - var id = jsData.utils.get(record, idAttribute); - relatedItems.forEach(function (relatedItem) { - var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; - if (foreignKeys.indexOf(id) !== -1) { - _relatedItems.push(relatedItem); - } - }); - def.setLocalField(record, _relatedItems); - }); - }); - } - }, - - - /** - * Load a hasOne relationship. - * - * Override with care. - * - * @name Adapter#loadHasOne - * @method - * @return {Promise} - */ - loadHasOne: function loadHasOne(mapper, def, records, __opts) { - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - records = [records]; - } - return this.loadHasMany(mapper, def, records, __opts).then(function () { - records.forEach(function (record) { - var relatedData = def.getLocalField(record); - if (jsData.utils.isArray(relatedData) && relatedData.length) { - def.setLocalField(record, relatedData[0]); - } - }); - }); - }, - - - /** - * Return the foreignKey from the given record for the provided relationship. - * - * There may be reasons why you may want to override this method, like when - * the id of the parent doesn't exactly match up to the key on the child. - * - * Override with care. - * - * @name Adapter#makeHasManyForeignKey - * @method - * @return {*} - */ - makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) { - return def.getForeignKey(record); - }, - - - /** - * Return the localKeys from the given record for the provided relationship. - * - * Override with care. - * - * @name Adapter#makeHasManyLocalKeys - * @method - * @return {*} - */ - makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) { - var localKeys = []; - var itemKeys = jsData.utils.get(record, def.localKeys) || []; - itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); - localKeys = localKeys.concat(itemKeys); - return unique(localKeys).filter(function (x) { - return x; - }); - }, - - - /** - * Return the foreignKeys from the given record for the provided relationship. - * - * Override with care. - * - * @name Adapter#makeHasManyForeignKeys - * @method - * @return {*} - */ - makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) { - return jsData.utils.get(record, mapper.idAttribute); - }, - - - /** - * Return the foreignKey from the given record for the provided relationship. - * - * Override with care. - * - * @name Adapter#makeBelongsToForeignKey - * @method - * @return {*} - */ - makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) { - return def.getForeignKey(record); - }, - - - /** - * Retrieve sum of the specified field of the records that match the selection - * query. Called by `Mapper#sum`. - * - * @name Adapter#sum - * @method - * @param {Object} mapper The mapper. - * @param {string} field By to sum. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - sum: function sum(mapper, field, query, opts) { - var _this12 = this; - - var op = void 0; - if (!jsData.utils.isString(field)) { - throw new Error('field must be a string!'); - } - query || (query = {}); - opts || (opts = {}); - - // beforeSum lifecycle hook - op = opts.op = 'beforeSum'; - return jsData.utils.resolve(this[op](mapper, field, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'sum'; - _this12.dbg(op, mapper, field, query, opts); - return jsData.utils.resolve(_this12._sum(mapper, field, query, opts)); - }).then(function (results) { - var _results8 = slicedToArray(results, 2); - - var data = _results8[0]; - var result = _results8[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = _this12.respond(response, opts); - - // afterSum lifecycle hook - op = opts.op = 'afterSum'; - return jsData.utils.resolve(_this12[op](mapper, field, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * @name Adapter#respond - * @method - * @param {Object} response Response object. - * @param {Object} opts Configuration options. - * return {Object} If `opts.raw == true` then return `response`, else return - * `response.data`. - */ - respond: function respond(response, opts) { - return this.getOpt('raw', opts) ? response : response.data; - }, - - - /** - * Apply the given update to the record with the specified primary key. Called - * by `Mapper#update`. - * - * @name Adapter#update - * @method - * @param {Object} mapper The mapper. - * @param {(string|number)} id The primary key of the record to be updated. - * @param {Object} props The update to apply to the record. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - update: function update(mapper, id, props, opts) { - var _this13 = this; - - props || (props = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdate lifecycle hook - op = opts.op = 'beforeUpdate'; - return jsData.utils.resolve(this[op](mapper, id, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = _props === undefined ? props : _props; - props = withoutRelations(mapper, props, opts); - op = opts.op = 'update'; - _this13.dbg(op, mapper, id, props, opts); - return jsData.utils.resolve(_this13._update(mapper, id, props, opts)); - }).then(function (results) { - var _results9 = slicedToArray(results, 2); - - var data = _results9[0]; - var result = _results9[1]; - - result || (result = {}); - var response = new Response(data, result, 'update'); - response.updated = data ? 1 : 0; - response = _this13.respond(response, opts); - - // afterUpdate lifecycle hook - op = opts.op = 'afterUpdate'; - return jsData.utils.resolve(_this13[op](mapper, id, props, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Apply the given update to all records that match the selection query. - * Called by `Mapper#updateAll`. - * - * @name Adapter#updateAll - * @method - * @param {Object} mapper The mapper. - * @param {Object} props The update to apply to the selected records. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - updateAll: function updateAll(mapper, props, query, opts) { - var _this14 = this; - - props || (props = {}); - query || (query = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdateAll lifecycle hook - op = opts.op = 'beforeUpdateAll'; - return jsData.utils.resolve(this[op](mapper, props, query, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = _props === undefined ? props : _props; - props = withoutRelations(mapper, props, opts); - op = opts.op = 'updateAll'; - _this14.dbg(op, mapper, props, query, opts); - return jsData.utils.resolve(_this14._updateAll(mapper, props, query, opts)); - }).then(function (results) { - var _results10 = slicedToArray(results, 2); - - var data = _results10[0]; - var result = _results10[1]; - - data || (data = []); - result || (result = {}); - var response = new Response(data, result, 'updateAll'); - response.updated = data.length; - response = _this14.respond(response, opts); - - // afterUpdateAll lifecycle hook - op = opts.op = 'afterUpdateAll'; - return jsData.utils.resolve(_this14[op](mapper, props, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Update the given records in a single batch. Called by `Mapper#updateMany`. - * - * @name Adapter#updateMany - * @method - * @param {Object} mapper The mapper. - * @param {Object[]} records The records to update. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - updateMany: function updateMany(mapper, records, opts) { - var _this15 = this; - - records || (records = []); - opts || (opts = {}); - var op = void 0; - var idAttribute = mapper.idAttribute; - - records = records.filter(function (record) { - return jsData.utils.get(record, idAttribute); - }); - // beforeUpdateMany lifecycle hook - op = opts.op = 'beforeUpdateMany'; - return jsData.utils.resolve(this[op](mapper, records, opts)).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = _records === undefined ? records : _records; - records = records.map(function (record) { - return withoutRelations(mapper, record, opts); - }); - op = opts.op = 'updateMany'; - _this15.dbg(op, mapper, records, opts); - return jsData.utils.resolve(_this15._updateMany(mapper, records, opts)); - }).then(function (results) { - var _results11 = slicedToArray(results, 2); - - var data = _results11[0]; - var result = _results11[1]; - - data || (data = []); - result || (result = {}); - var response = new Response(data, result, 'updateMany'); - response.updated = data.length; - response = _this15.respond(response, opts); - - // afterUpdateMany lifecycle hook - op = opts.op = 'afterUpdateMany'; - return jsData.utils.resolve(_this15[op](mapper, records, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - } - }); - var hasFetch = false; - try { - hasFetch = window && window.fetch; - } catch (e) {} - function isValidString(value) { - return value != null && value !== ''; - } - function join(items, separator) { - separator || (separator = ''); - return items.filter(isValidString).join(separator); - } - function makePath() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - var result = join(args, '/'); - return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); - } - function encode(val) { - return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); - } - function buildUrl(url, params) { - if (!params) { - return url; - } - var parts = []; - jsData.utils.forOwn(params, function (val, key) { - if (val === null || typeof val === 'undefined') { - return; - } - if (!jsData.utils.isArray(val)) { - val = [val]; - } - val.forEach(function (v) { - if (toString.call(v) === '[object Date]') { - v = v.toISOString(); - } else if (jsData.utils.isObject(v)) { - v = jsData.utils.toJson(v); - } - parts.push(encode(key) + '=' + encode(v)); - }); - }); - if (parts.length > 0) { - url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); - } - return url; - } - var DEFAULTS = { - /** - * Set a base path in order to use absolute URLs instead of relative URLs. - * - * @example - * const httpAdapter = new HttpAdapter({ - * basePath: 'https://mydomain.com' - * }); - * - * @name HttpAdapter#basePath - * @type {string} - * @since 3.0.0 - */ - basePath: '', - - /** - * Ensure that the request url has a trailing forward slash. - * - * @name HttpAdapter#forceTrailingSlash - * @type {boolean} - * @default false - * @since 3.0.0 - */ - forceTrailingSlash: false, - - /** - * The HTTP function that actually makes the HTTP request. By default this is - * `axios`. - * - * @name HttpAdapter#http - * @type {function} - * @since 3.0.0 - * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library - */ - http: axios$1, - - /** - * Default configuration options to be mixed into the `config` argument passed - * to {@link HttpAdapter#http}. - * - * @name HttpAdapter#httpConfig - * @type {object} - * @since 3.0.0 - */ - httpConfig: {}, - - /** - * Add a suffix to the request url, e.g. ".json". - * - * @name HttpAdapter#suffix - * @type {string} - * @since 3.0.0 - */ - suffix: '', - - /** - * Use `window.fetch` if available. - * - * @name HttpAdapter#useFetch - * @type {boolean} - * @default false - * @since 3.0.0 - * @see http://www.js-data.io/docs/js-data-http#using-windowfetch - */ - useFetch: false - }; - /** - * HttpAdapter class. - * - * @example - * import { DataStore } from 'js-data'; - * import { HttpAdapter } from 'js-data-http'; - * - * const httpAdapter = new HttpAdapter(); - * const store = new DataStore(); - * - * store.registerAdapter('http', httpAdapter, { 'default': true }); - * - * store.defineMapper('school'); - * store.defineMapper('student'); - * - * // GET /school/1 - * store.find('school', 1).then((school) => { - * console.log('school'); - * }); - * - * @class HttpAdapter - * @extends Adapter - * @param {object} [opts] Configuration options. - * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}. - * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}. - * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}. - * @param {object} [opts.http=axios] See {@link HttpAdapter#http}. - * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}. - * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}. - * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}. - * @see http://www.js-data.io/docs/js-data-http - */ - function HttpAdapter(opts) { - jsData.utils.classCallCheck(this, HttpAdapter); +var defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } - opts || (opts = {}); - // Fill in any missing options with the defaults - jsData.utils.fillIn(opts, DEFAULTS); - Adapter.call(this, opts); - } + return obj; +}; - /** - * @name module:js-data-http.HttpAdapter - * @see HttpAdapter - */ - Adapter.extend({ - constructor: HttpAdapter, - - /** - * @name HttpAdapter#afterDEL - * @method - * @param {string} url - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterDEL: noop2, - - /** - * @name HttpAdapter#afterGET - * @method - * @param {string} url - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterGET: noop2, - - /** - * @name HttpAdapter#afterHTTP - * @method - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterHTTP: noop2, - - /** - * @name HttpAdapter#afterPOST - * @method - * @param {string} url - * @param {object} data - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterPOST: noop2, - - /** - * @name HttpAdapter#afterPUT - * @method - * @param {string} url - * @param {object} data - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterPUT: noop2, - - /** - * @name HttpAdapter#beforeDEL - * @method - * @param {object} url - * @param {object} config - * @param {object} opts - */ - beforeDEL: noop, - - /** - * @name HttpAdapter#beforeGET - * @method - * @param {object} url - * @param {object} config - * @param {object} opts - */ - beforeGET: noop, - - /** - * @name HttpAdapter#beforeHTTP - * @method - * @param {object} config - * @param {object} opts - */ - beforeHTTP: noop, - - /** - * @name HttpAdapter#beforePOST - * @method - * @param {object} url - * @param {object} data - * @param {object} config - * @param {object} opts - */ - beforePOST: noop, - - /** - * @name HttpAdapter#beforePUT - * @method - * @param {object} url - * @param {object} data - * @param {object} config - * @param {object} opts - */ - beforePUT: noop, - - _count: function _count(mapper, query, opts) { - var _this = this; - - return this.GET(this.getPath('count', mapper, opts.params, opts), opts).then(function (response) { - return _this._end(mapper, opts, response); - }); - }, - _create: function _create(mapper, props, opts) { - var _this2 = this; - return this.POST(this.getPath('create', mapper, props, opts), this.serialize(mapper, props, opts), opts).then(function (response) { - return _this2._end(mapper, opts, response); - }); - }, - _createMany: function _createMany(mapper, props, opts) { - var _this3 = this; - return this.POST(this.getPath('createMany', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { - return _this3._end(mapper, opts, response); - }); - }, - _destroy: function _destroy(mapper, id, opts) { - var _this4 = this; - return this.DEL(this.getPath('destroy', mapper, id, opts), opts).then(function (response) { - return _this4._end(mapper, opts, response); - }); - }, - _destroyAll: function _destroyAll(mapper, query, opts) { - var _this5 = this; - return this.DEL(this.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { - return _this5._end(mapper, opts, response); - }); - }, - _end: function _end(mapper, opts, response) { - return [this.deserialize(mapper, response, opts), response]; - }, - _find: function _find(mapper, id, opts) { - var _this6 = this; - - return this.GET(this.getPath('find', mapper, id, opts), opts).then(function (response) { - return _this6._end(mapper, opts, response); - }); - }, - _findAll: function _findAll(mapper, query, opts) { - var _this7 = this; - return this.GET(this.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { - return _this7._end(mapper, opts, response); - }); - }, - _sum: function _sum(mapper, field, query, opts) { - var _this8 = this; - return this.GET(this.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { - return _this8._end(mapper, opts, response); - }); - }, - _update: function _update(mapper, id, props, opts) { - var _this9 = this; - return this.PUT(this.getPath('update', mapper, id, opts), this.serialize(mapper, props, opts), opts).then(function (response) { - return _this9._end(mapper, opts, response); - }); - }, - _updateAll: function _updateAll(mapper, props, query, opts) { - var _this10 = this; - return this.PUT(this.getPath('updateAll', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { - return _this10._end(mapper, opts, response); - }); - }, - _updateMany: function _updateMany(mapper, records, opts) { - var _this11 = this; - return this.PUT(this.getPath('updateMany', mapper, null, opts), this.serialize(mapper, records, opts), opts).then(function (response) { - return _this11._end(mapper, opts, response); - }); - }, - - - /** - * Retrieve the number of records that match the selection `query`. - * - * @name HttpAdapter#count - * @method - * @param {object} mapper The mapper. - * @param {object} query Selection query. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - count: function count(mapper, query, opts) { - query || (query = {}); - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params.count = true; - opts.suffix = this.getSuffix(mapper, opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - return Adapter.prototype.count.call(this, mapper, query, opts); - }, - - - /** - * Create a new the record from the provided `props`. - * - * @name HttpAdapter#create - * @method - * @param {object} mapper The mapper. - * @param {object} props Properties to send as the payload. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - create: function create(mapper, props, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.create.call(this, mapper, props, opts); - }, - - - /** - * Create multiple new records in batch. - * - * @name HttpAdapter#createMany - * @method - * @param {object} mapper The mapper. - * @param {array} props Array of property objects to send as the payload. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - createMany: function createMany(mapper, props, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.createMany.call(this, mapper, props, opts); - }, - - - /** - * Make an Http request to `url` according to the configuration in `config`. - * - * @name HttpAdapter#DEL - * @method - * @param {string} url Url for the request. - * @param {object} [config] Http configuration that will be passed to - * {@link HttpAdapter#HTTP}. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - DEL: function DEL(url, config, opts) { - var _this12 = this; - - var op = void 0; - config || (config = {}); - opts || (opts = {}); - config.url = url || config.url; - config.method = config.method || 'delete'; - - // beforeDEL lifecycle hook - op = opts.op = 'beforeDEL'; - return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _config === undefined ? config : _config; - op = opts.op = 'DEL'; - _this12.dbg(op, url, config, opts); - return _this12.HTTP(config, opts); - }).then(function (response) { - // afterDEL lifecycle hook - op = opts.op = 'afterDEL'; - return jsData.utils.resolve(_this12[op](url, config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Transform the server response object into the payload that will be returned - * to JSData. - * - * @name HttpAdapter#deserialize - * @method - * @param {object} mapper The mapper used for the operation. - * @param {object} response Response object from {@link HttpAdapter#HTTP}. - * @param {object} opts Configuration options. - * @return {(object|array)} Deserialized data. - */ - deserialize: function deserialize(mapper, response, opts) { - opts || (opts = {}); - if (jsData.utils.isFunction(opts.deserialize)) { - return opts.deserialize(mapper, response, opts); - } - if (jsData.utils.isFunction(mapper.deserialize)) { - return mapper.deserialize(mapper, response, opts); - } - if (response && response.hasOwnProperty('data')) { - return response.data; - } - return response; - }, - - - /** - * Destroy the record with the given primary key. - * - * @name HttpAdapter#destroy - * @method - * @param {object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to destroy. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - destroy: function destroy(mapper, id, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.destroy.call(this, mapper, id, opts); - }, - - - /** - * Destroy the records that match the selection `query`. - * - * @name HttpAdapter#destroyAll - * @method - * @param {object} mapper The mapper. - * @param {object} query Selection query. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - destroyAll: function destroyAll(mapper, query, opts) { - query || (query = {}); - opts || (opts = {}); - opts.params = this.getParams(opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.destroyAll.call(this, mapper, query, opts); - }, - - - /** - * Log an error. - * - * @name HttpAdapter#error - * @method - * @param {...*} [args] Arguments to log. - */ - error: function error() { - if (console) { - var _console; - - (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); - } - }, - - - /** - * Make an Http request using `window.fetch`. - * - * @name HttpAdapter#fetch - * @method - * @param {object} config Request configuration. - * @param {object} config.data Payload for the request. - * @param {string} config.method Http method for the request. - * @param {object} config.headers Headers for the request. - * @param {object} config.params Querystring for the request. - * @param {string} config.url Url for the request. - */ - fetch: function (_fetch) { - function fetch(_x) { - return _fetch.apply(this, arguments); - } - fetch.toString = function () { - return _fetch.toString(); - }; - return fetch; - }(function (config) { - var requestConfig = { - method: config.method, - // turn the plain headers object into the Fetch Headers object - headers: new Headers(config.headers || {}) - }; - if (config.data) { - requestConfig.body = jsData.utils.toJson(config.data); - } - return fetch(buildUrl(config.url, config.params), requestConfig).then(function (response) { - response.config = { - method: config.method, - url: config.url - }; - return response.json().then(function (data) { - response.data = data; - return response; - }); - }); - }), - - - /** - * Retrieve the record with the given primary key. - * - * @name HttpAdapter#find - * @method - * @param {object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to retrieve. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - find: function find(mapper, id, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.find.call(this, mapper, id, opts); - }, - - - /** - * Retrieve the records that match the selection `query`. - * - * @name HttpAdapter#findAll - * @method - * @param {object} mapper The mapper. - * @param {object} query Selection query. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - findAll: function findAll(mapper, query, opts) { - query || (query = {}); - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.suffix = this.getSuffix(mapper, opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - return Adapter.prototype.findAll.call(this, mapper, query, opts); - }, - - - /** - * Make a GET request. - * - * @name HttpAdapter#GET - * @method - * @param {string} url The url for the request. - * @param {object} config Request configuration options. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - GET: function GET(url, config, opts) { - var _this13 = this; - - var op = void 0; - config || (config = {}); - opts || (opts = {}); - config.url = url || config.url; - config.method = config.method || 'get'; - - // beforeGET lifecycle hook - op = opts.op = 'beforeGET'; - return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _config === undefined ? config : _config; - op = opts.op = 'GET'; - _this13.dbg(op, url, config, opts); - return _this13.HTTP(config, opts); - }).then(function (response) { - // afterGET lifecycle hook - op = opts.op = 'afterGET'; - return jsData.utils.resolve(_this13[op](url, config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * @name HttpAdapter#getEndpoint - * @method - * @param {object} mapper The Mapper. - * @param {*} id The primary key, if any. - * @param {boolean} opts Configuration options. - * @return {string} Full path. - */ - getEndpoint: function getEndpoint(mapper, id, opts) { - var _this14 = this; - - opts || (opts = {}); - opts.params = jsData.utils.isUndefined(opts.params) ? {} : opts.params; - var relationList = mapper.relationList || []; - var endpoint = jsData.utils.isUndefined(opts.endpoint) ? jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; - - relationList.forEach(function (def) { - if (def.type !== 'belongsTo' || !def.parent) { - return; - } - var item = void 0; - var parentKey = def.foreignKey; - var parentDef = def.getRelation(); - var parentId = opts.params[parentKey]; - - if (parentId === false || !parentKey || !parentDef) { - if (parentId === false) { - delete opts.params[parentKey]; - } - return false; - } else { - delete opts.params[parentKey]; - if (jsData.utils.isObject(id)) { - item = id; - } - if (item) { - parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); - } - if (parentId) { - var _ret = function () { - delete opts.endpoint; - var _opts = {}; - jsData.utils.forOwn(opts, function (value, key) { - _opts[key] = value; - }); - jsData.utils._(_opts, parentDef); - endpoint = makePath(_this14.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); - return { - v: false - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; - } - } - }); - return endpoint; - }, - - - /** - * @name HttpAdapter#getPath - * @method - * @param {string} method The method being executed. - * @param {object} mapper The Mapper. - * @param {(string|number)?} id The primary key, if any. - * @param {object} opts Configuration options. - */ - getPath: function getPath(method, mapper, id, opts) { - opts || (opts = {}); - var args = [opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, this.getEndpoint(mapper, jsData.utils.isString(id) || jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; - if (method === 'find' || method === 'update' || method === 'destroy') { - args.push(id); - } - return makePath.apply(jsData.utils, args); - }, - getParams: function getParams(opts) { - opts || (opts = {}); - if (opts.params === undefined) { - return {}; - } - return jsData.utils.copy(opts.params); - }, - getSuffix: function getSuffix(mapper, opts) { - opts || (opts = {}); - if (opts.suffix === undefined) { - if (mapper.suffix === undefined) { - return this.suffix; - } - return mapper.suffix; - } - return opts.suffix; - }, - - - /** - * Make an Http request. - * - * @name HttpAdapter#HTTP - * @method - * @param {object} config Request configuration options. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - HTTP: function HTTP(config, opts) { - var _this15 = this; - - var start = new Date(); - opts || (opts = {}); - var payload = config.data; - var cache = config.cache; - var timeout = config.timeout; - config = jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); - config = jsData.utils.deepMixIn(config, this.httpConfig); - config.data = payload; - config.cache = cache; - config.timeout = timeout; - if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { - config.url += '/'; - } - config.method = config.method.toUpperCase(); - var suffix = config.suffix || opts.suffix || this.suffix; - if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { - config.url += suffix; - } - var logResponse = function logResponse(data) { - var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; - if (data.status >= 200 && data.status < 300) { - if (_this15.log) { - _this15.dbg(str, data); - } - return data; - } else { - if (_this15.error) { - _this15.error('\'FAILED: ' + str, data); - } - return jsData.utils.reject(data); - } - }; - if (!this.http) { - throw new Error('You have not configured this adapter with an http library!'); - } +var slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; - return jsData.utils.resolve(this.beforeHTTP(config, opts)).then(function (_config) { - config = _config || config; - if (hasFetch && (_this15.useFetch || opts.useFetch || !_this15.http)) { - return _this15.fetch(config, opts).then(logResponse, logResponse); - } - return _this15.http(config).then(logResponse, logResponse).catch(function (err) { - return _this15.responseError(err, config, opts); - }); - }).then(function (response) { - return jsData.utils.resolve(_this15.afterHTTP(config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Make a POST request. - * - * @name HttpAdapter#POST - * @method - * @param {*} url The url for the request. - * @param {object} data Payload for the request. - * @param {object} config Request configuration options. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - POST: function POST(url, data, config, opts) { - var _this16 = this; - - var op = void 0; - config || (config = {}); - opts || (opts = {}); - config.url = url || config.url; - config.data = data || config.data; - config.method = config.method || 'post'; - - // beforePOST lifecycle hook - op = opts.op = 'beforePOST'; - return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _config === undefined ? config : _config; - op = opts.op = 'POST'; - _this16.dbg(op, url, data, config, opts); - return _this16.HTTP(config, opts); - }).then(function (response) { - // afterPOST lifecycle hook - op = opts.op = 'afterPOST'; - return jsData.utils.resolve(_this16[op](url, data, config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Make a PUT request. - * - * @name HttpAdapter#PUT - * @method - * @param {*} url The url for the request. - * @param {object} data Payload for the request. - * @param {object} config Request configuration options. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - PUT: function PUT(url, data, config, opts) { - var _this17 = this; - - var op = void 0; - config || (config = {}); - opts || (opts = {}); - config.url = url || config.url; - config.data = data || config.data; - config.method = config.method || 'put'; - - // beforePUT lifecycle hook - op = opts.op = 'beforePUT'; - return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _config === undefined ? config : _config; - op = opts.op = 'PUT'; - _this17.dbg(op, url, data, config, opts); - return _this17.HTTP(config, opts); - }).then(function (response) { - // afterPUT lifecycle hook - op = opts.op = 'afterPUT'; - return jsData.utils.resolve(_this17[op](url, data, config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Transform the querystring object before it is serialized. This doesn't do - * anything by default. - * - * @name HttpAdapter#queryTransform - * @method - * @param {object} mapper The Mapper that triggered the request. - * @param {*} params The querystring object. - * @param {*} opts Configuration options - * @return {*} Transformed params. - */ - queryTransform: function queryTransform(mapper, params, opts) { - opts || (opts = {}); - if (jsData.utils.isFunction(opts.queryTransform)) { - return opts.queryTransform(mapper, params, opts); - } - if (jsData.utils.isFunction(mapper.queryTransform)) { - return mapper.queryTransform(mapper, params, opts); - } - return params; - }, - - - /** - * Error handler invoked when the promise returned by {@link HttpAdapter#http} - * is rejected. Default implementation is to just return the error wrapped in - * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is - * called by {@link HttpAdapter#HTTP}. - * - * @name HttpAdapter#responseError - * @method - * @param {*} err The error that {@link HttpAdapter#http} rejected with. - * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. - * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. - * @return {Promise} - */ - responseError: function responseError(err, config, opts) { - return jsData.utils.reject(err); - }, - - - /** - * Serialize request data. This doesn't do anything by default. - * - * @name HttpAdapter#serialize - * @method - * @param {object} mapper The Mapper that triggered the request. - * @param {object} data The request payload. - * @param {*} opts Configuration options. - * @return {*} Serialized data. - */ - serialize: function serialize(mapper, data, opts) { - opts || (opts = {}); - if (jsData.utils.isFunction(opts.serialize)) { - return opts.serialize(mapper, data, opts); - } - if (jsData.utils.isFunction(mapper.serialize)) { - return mapper.serialize(mapper, data, opts); - } - return data; - }, - - - /** - * Retrieve the sum of the field of the records that match the selection query. - * - * @name HttpAdapter#sum - * @method - * @param {object} mapper The mapper. - * @param {string} field The field to sum. - * @param {object} query Selection query. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - sum: function sum(mapper, field, query, opts) { - query || (query = {}); - opts || (opts = {}); - if (!jsData.utils.isString(field)) { - throw new Error('field must be a string!'); - } - opts.params = this.getParams(opts); - opts.params.sum = field; - opts.suffix = this.getSuffix(mapper, opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - return Adapter.prototype.sum.call(this, mapper, field, query, opts); - }, - - - /** - * Perform an update. Makes a PUT request by default. - * - * @name HttpAdapter#update - * @method - * @param {object} mapper The Mapper for the request. - * @param {*} id The primary key of the record being updated. - * @param {*} props The update payload. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - update: function update(mapper, id, props, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.update.call(this, mapper, id, props, opts); - }, - - - /** - * Perform an update against records that match the selection query. Makes a - * PUT request by default. - * - * @name HttpAdapter#updateAll - * @method - * @param {object} mapper The Mapper for the request. - * @param {object} props The update payload. - * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - updateAll: function updateAll(mapper, props, query, opts) { - query || (query = {}); - opts || (opts = {}); - opts.params = this.getParams(opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.updateAll.call(this, mapper, props, query, opts); - }, - - - /** - * Update multiple individual records in a batch. - * - * @name HttpAdapter#updateMany - * @method - * @param {object} mapper The Mapper for the request. - * @param {array} records Array of property objects to send as the payload. - * Each must contain the primary key of the record to be updated. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - updateMany: function updateMany(mapper, records, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.updateMany.call(this, mapper, records, opts); - } - }); + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); - /** - * Add an Http actions to a mapper. - * - * @example - * // CommonJS - * var JSData = require('js-data'); - * // It is recommended to use DataStore in the browser - * var DataStore = JSData.DataStore; - * - * var JSDataHttp = require('js-data-http'); - * var HttpAdapter = JSDataHttp.HttpAdapter; - * var addAction = JSDataHttp.addAction; - * - * var httpAdapter = new HttpAdapter(); - * var store = new DataStore(); - * - * store.registerAdapter('http', httpAdapter, { 'default': true }); - * store.defineMapper('school'); - * - * // GET /reports/schools/:school_id/teachers - * addAction('getTeacherReports', { - * endpoint: 'reports/schools', - * pathname: 'teachers', - * method: 'GET' - * })(store.getMapper('school')); - * - * // /reports/schools/1234/teachers - * store.getMapper('school').getTeacherReports(1234).then((response) => { - * // ... - * }); - * - * @name module:js-data-http.addAction - * @method - * @param {string} name Name of the new action. - * @param {object} [opts] Action configuration - * @param {string} [opts.adapter="http"] The name of the adapter to use. - * @param {string} [opts.pathname] Set the action's pathname. - * @param {function} [opts.request] Specify a request handler to be executed - * before the request is made. - * @param {function} [opts.response] Specify a response handler to be executed - * after the response is received. - * @param {function} [opts.responseError] Specify an error handler to be - * executed on error. - * @return {function} Decoration function, which should be passed the mapper to - * decorate when invoked. - */ - function addAction(name, opts) { - if (!name || !jsData.utils.isString(name)) { - throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); - } - return function (mapper) { - if (mapper[name]) { - throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); - } - opts.request = opts.request || function (config) { - return config; - }; - opts.response = opts.response || function (response) { - return response; - }; - opts.responseError = opts.responseError || function (err) { - return jsData.utils.reject(err); - }; - mapper[name] = function (id, _opts) { - var _this18 = this; + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } - _opts = _opts || {}; - if (jsData.utils.isObject(id)) { - _opts = id; - } - jsData.utils.fillIn(_opts, opts); - var adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http'); - var config = {}; - config.mapper = this.name; - jsData.utils.deepMixIn(config, _opts); - config.method = config.method || 'GET'; - if (typeof _opts.getEndpoint === 'function') { - config.url = _opts.getEndpoint(this, _opts); - } else { - var args = [_opts.basePath || this.basePath || adapter.basePath, adapter.getEndpoint(this, id, _opts)]; - if (jsData.utils.isSorN(id)) { - args.push(id); - } - args.push(opts.pathname || name); - config.url = makePath.apply(null, args); - } - return jsData.utils.resolve(config).then(_opts.request).then(function (config) { - return adapter.HTTP(config); - }).then(function (data) { - if (data && data.config) { - data.config.mapper = _this18.name; - } - return data; - }).then(_opts.response, _opts.responseError); - }; - return mapper; - }; - } + return _arr; + } - /** - * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for - * action configuration options. - * - * @example - * // CommonJS - * var JSData = require('js-data'); - * // It is recommended to use DataStore in the browser - * var DataStore = JSData.DataStore; - * - * var JSDataHttp = require('js-data-http'); - * var HttpAdapter = JSDataHttp.HttpAdapter; - * var addActions = JSDataHttp.addActions; - * - * var httpAdapter = new HttpAdapter(); - * var store = new DataStore(); - * - * store.registerAdapter('http', httpAdapter, { 'default': true }); - * store.defineMapper('school'); - * - * addActions({ - * // GET /reports/schools/:school_id/teachers - * getTeacherReports: { - * basePath: 'reports/schools', - * pathname: 'teachers', - * method: 'GET' - * } - * })(store.getMapper('school')); - * - * // /reports/schools/1234/teachers - * store.getMapper('school').getTeacherReports(1234).then((response) => { - * // ... - * }); - * - * @name module:js-data-http.addActions - * @method - * @param {object.} opts Object where the key is an action name - * and the value is the configuration for the action. - * @return {function} Decoration function, which should be passed the mapper to - * decorate when invoked. - */ - function addActions(opts) { - opts || (opts = {}); - return function (mapper) { - jsData.utils.forOwn(opts, function (value, key) { - addAction(key, value)(mapper); - }); - return mapper; - }; - } + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; +}(); - /** - * Details of the current version of the `js-data-http` module. - * - * @name module:js-data-http.version - * @type {object} - * @property {string} version.full The full semver value. - * @property {number} version.major The major version number. - * @property {number} version.minor The minor version number. - * @property {number} version.patch The patch version number. - * @property {(string|boolean)} version.alpha The alpha version value, - * otherwise `false` if the current version is not alpha. - * @property {(string|boolean)} version.beta The beta version value, - * otherwise `false` if the current version is not beta. - */ - var version = { - full: '3.0.0-rc.3', +var noop = function noop() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + this.dbg.apply(this, [opts.op].concat(args)); + return jsData.utils.resolve(); +}; + +var noop2 = function noop2() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + this.dbg.apply(this, [opts.op].concat(args)); + return jsData.utils.resolve(); +}; + +var unique = function unique(array) { + var seen = {}; + var final = []; + array.forEach(function (item) { + if (item in seen) { + return; + } + final.push(item); + seen[item] = 0; + }); + return final; +}; + +var withoutRelations = function withoutRelations(mapper, props, opts) { + opts || (opts = {}); + opts.with || (opts.with = []); + var relationFields = mapper.relationFields || []; + var toStrip = relationFields.filter(function (value) { + return opts.with.indexOf(value) === -1; + }); + return jsData.utils.omit(props, toStrip); +}; + + + +/** + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @class Response + */ +function Response(data, meta, op) { + meta || (meta = {}); + + /** + * Response data. + * + * @name Response#data + * @type {*} + */ + this.data = data; + + jsData.utils.fillIn(this, meta); + + /** + * The operation for which the response was created. + * + * @name Response#op + * @type {string} + */ + this.op = op; +} + +var DEFAULTS$1 = { + /** + * Whether to log debugging information. + * + * @name Adapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * Whether to return a more detailed response object. + * + * @name Adapter#raw + * @type {boolean} + * @default false + */ + raw: false + + /** + * Abstract class meant to be extended by adapters. + * + * @class Adapter + * @abstract + * @extends Component + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.debug=false] Whether to log debugging information. + * @param {boolean} [opts.raw=false] Whether to return a more detailed response + * object. + */ +};function Adapter(opts) { + jsData.utils.classCallCheck(this, Adapter); + jsData.Component.call(this, opts); + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS$1); + jsData.utils.fillIn(this, opts); +} + +jsData.Component.extend({ + constructor: Adapter, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#afterCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} props The `props` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `afterCount` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterCount: noop2, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `afterCreate` + * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreate: noop2, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `afterCreateMany` + * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreateMany: noop2, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#afterDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `afterDestroy` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroy: noop2, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#afterDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `afterDestroyAll` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroyAll: noop2, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#afterFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `afterFind` + * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`. + */ + afterFind: noop2, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#afterFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `afterFindAll` + * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`. + */ + afterFindAll: noop2, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#afterSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {string} field The `field` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `afterSum` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterSum: noop2, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#afterUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `afterUpdate` + * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdate: noop2, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#afterUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `afterUpdateAll` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateAll: noop2, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#afterUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} records The `records` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `afterUpdateMany` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateMany: noop2, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#beforeCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} query The `query` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `beforeCount` + */ + beforeCount: noop, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#beforeCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `beforeCreate` + */ + beforeCreate: noop, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#beforeCreateMany + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `beforeCreateMany` + */ + beforeCreateMany: noop, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#beforeDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `beforeDestroy` + */ + beforeDestroy: noop, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#beforeDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `beforeDestroyAll` + */ + beforeDestroyAll: noop, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#beforeFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `beforeFind` + */ + beforeFind: noop, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#beforeFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `beforeFindAll` + */ + beforeFindAll: noop, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#beforeSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `beforeSum` + */ + beforeSum: noop, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#beforeUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `beforeUpdate` + */ + beforeUpdate: noop, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#beforeUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `beforeUpdateAll` + */ + beforeUpdateAll: noop, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#beforeUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} props The `props` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `beforeUpdateMany` + */ + beforeUpdateMany: noop, + + /** + * Retrieve the number of records that match the selection query. Called by + * `Mapper#count`. + * + * @name Adapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var _this = this; + + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + _this.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this._count(mapper, query, opts)); + }).then(function (results) { + var _results = slicedToArray(results, 2), + data = _results[0], + result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = _this.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(_this[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Create a new record. Called by `Mapper#create`. + * + * @name Adapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var _this2 = this; + + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'create'; + _this2.dbg(op, mapper, props, opts); + return jsData.utils.resolve(_this2._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = slicedToArray(results, 2), + data = _results2[0], + result = _results2[1]; + + result || (result = {}); + var response = new Response(data, result, 'create'); + response.created = data ? 1 : 0; + response = _this2.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(_this2[op](mapper, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Create multiple records in a single batch. Called by `Mapper#createMany`. + * + * @name Adapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var _this3 = this; + + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record, opts); + }); + op = opts.op = 'createMany'; + _this3.dbg(op, mapper, props, opts); + return jsData.utils.resolve(_this3._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = slicedToArray(results, 2), + data = _results3[0], + result = _results3[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'createMany'); + response.created = data.length; + response = _this3.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(_this3[op](mapper, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Destroy the record with the given primary key. Called by + * `Mapper#destroy`. + * + * @name Adapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var _this4 = this; + + var op = void 0; + opts || (opts = {}); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + _this4.dbg(op, mapper, id, opts); + return jsData.utils.resolve(_this4._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = slicedToArray(results, 2), + data = _results4[0], + result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = _this4.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(_this4[op](mapper, id, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Destroy the records that match the selection query. Called by + * `Mapper#destroyAll`. + * + * @name Adapter#destroyAll + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var _this5 = this; + + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + _this5.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this5._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = slicedToArray(results, 2), + data = _results5[0], + result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = _this5.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(_this5[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo + * @method + * @return {Promise} + */ + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { + var _this6 = this; + + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var record = records; + return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }); + } else { + var keys = records.map(function (record) { + return _this6.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return this.findAll(relationDef, { + where: defineProperty({}, relationDef.idAttribute, { + 'in': keys + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (record) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { + def.setLocalField(record, relatedItem); + } + }); + }); + }); + } + }, + + + /** + * Retrieve the record with the given primary key. Called by `Mapper#find`. + * + * @name Adapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var _this7 = this; + + var op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + _this7.dbg(op, mapper, id, opts); + return jsData.utils.resolve(_this7._find(mapper, id, opts)); + }).then(function (results) { + return _this7.loadRelationsFor(mapper, results, opts); + }).then(function (_ref) { + var _ref2 = slicedToArray(_ref, 2), + record = _ref2[0], + meta = _ref2[1]; + + var response = new Response(record, meta, 'find'); + response.found = record ? 1 : 0; + response = _this7.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(_this7[op](mapper, id, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Retrieve the records that match the selection query. + * + * @name Adapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var _this8 = this; + + var op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + var activeWith = opts._activeWith; + + if (jsData.utils.isObject(activeWith)) { + var activeQuery = activeWith.query || {}; + if (activeWith.replace) { + query = activeQuery; + } else { + jsData.utils.deepFillIn(query, activeQuery); + } + } + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + _this8.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this8._findAll(mapper, query, opts)); + }).then(function (results) { + return _this8.loadRelationsFor(mapper, results, opts); + }).then(function (_ref3) { + var _ref4 = slicedToArray(_ref3, 2), + records = _ref4[0], + meta = _ref4[1]; + + var response = new Response(records, meta, 'findAll'); + response.found = records.length; + response = _this8.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(_this8[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + loadRelationsFor: function loadRelationsFor(mapper, results, opts) { + var _this9 = this; + + var _results6 = slicedToArray(results, 1), + records = _results6[0]; + + var tasks = []; + + if (records) { + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasOne') { + task = _this9.loadHasOne(mapper, def, records, __opts); + } else { + task = _this9.loadHasMany(mapper, def, records, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = _this9.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = _this9.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = _this9.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } + }); + } + + return jsData.utils.Promise.all(tasks).then(function () { + return results; + }); + }, + + + /** + * Resolve the value of the specified option based on the given options and + * this adapter's settings. Override with care. + * + * @name Adapter#getOpt + * @method + * @param {string} opt The name of the option. + * @param {Object} [opts] Configuration options. + * @return {*} The value of the specified option. + */ + getOpt: function getOpt(opt, opts) { + opts || (opts = {}); + return opts[opt] === undefined ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); + }, + + + /** + * Load a hasMany relationship. + * + * Override with care. + * + * @name Adapter#loadHasMany + * @method + * @return {Promise} + */ + loadHasMany: function loadHasMany(mapper, def, records, __opts) { + var _this10 = this; + + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return _this10.makeHasManyForeignKey(mapper, def, record); + }); + var query = { + where: {} + }; + var criteria = query.where[def.foreignKey] = {}; + if (singular) { + // more efficient query when we only have one record + criteria['=='] = IDs[0]; + } else { + criteria['in'] = IDs.filter(function (id) { + return id; + }); + } + return this.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { + records.forEach(function (record) { + var attached = []; + // avoid unneccesary iteration when we only have one record + if (singular) { + attached = relatedItems; + } else { + relatedItems.forEach(function (relatedItem) { + if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { + attached.push(relatedItem); + } + }); + } + def.setLocalField(record, attached); + }); + }); + }, + loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { + var _this11 = this; + + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return this.findAll(relatedMapper, { + where: defineProperty({}, relatedMapper.idAttribute, { + 'in': this.makeHasManyLocalKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + var localKeys = []; + records.forEach(function (record) { + localKeys = localKeys.concat(_this11.makeHasManyLocalKeys(mapper, def, record)); + }); + return this.findAll(relatedMapper, { + where: defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + var itemKeys = jsData.utils.get(item, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem); + } + }); + def.setLocalField(item, attached); + }); + return relatedItems; + }); + } + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var _this12 = this; + + var relatedMapper = def.getRelation(); + var idAttribute = mapper.idAttribute; + var record = void 0; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return this.findAll(def.getRelation(), { + where: defineProperty({}, def.foreignKeys, { + 'contains': this.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return this.findAll(relatedMapper, { + where: defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return _this12.makeHasManyForeignKeys(mapper, def, record); + }) + }) + }, __opts).then(function (relatedItems) { + var foreignKeysField = def.foreignKeys; + records.forEach(function (record) { + var _relatedItems = []; + var id = jsData.utils.get(record, idAttribute); + relatedItems.forEach(function (relatedItem) { + var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; + if (foreignKeys.indexOf(id) !== -1) { + _relatedItems.push(relatedItem); + } + }); + def.setLocalField(record, _relatedItems); + }); + }); + } + }, + + + /** + * Load a hasOne relationship. + * + * Override with care. + * + * @name Adapter#loadHasOne + * @method + * @return {Promise} + */ + loadHasOne: function loadHasOne(mapper, def, records, __opts) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + records = [records]; + } + return this.loadHasMany(mapper, def, records, __opts).then(function () { + records.forEach(function (record) { + var relatedData = def.getLocalField(record); + if (jsData.utils.isArray(relatedData) && relatedData.length) { + def.setLocalField(record, relatedData[0]); + } + }); + }); + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * There may be reasons why you may want to override this method, like when + * the id of the parent doesn't exactly match up to the key on the child. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKey + * @method + * @return {*} + */ + makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Return the localKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyLocalKeys + * @method + * @return {*} + */ + makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) { + var localKeys = []; + var itemKeys = jsData.utils.get(record, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + localKeys = localKeys.concat(itemKeys); + return unique(localKeys).filter(function (x) { + return x; + }); + }, + + + /** + * Return the foreignKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKeys + * @method + * @return {*} + */ + makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) { + return jsData.utils.get(record, mapper.idAttribute); + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeBelongsToForeignKey + * @method + * @return {*} + */ + makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Retrieve sum of the specified field of the records that match the selection + * query. Called by `Mapper#sum`. + * + * @name Adapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field By to sum. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var _this13 = this; + + var op = void 0; + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + query || (query = {}); + opts || (opts = {}); + + // beforeSum lifecycle hook + op = opts.op = 'beforeSum'; + return jsData.utils.resolve(this[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + _this13.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(_this13._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results7 = slicedToArray(results, 2), + data = _results7[0], + result = _results7[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = _this13.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(_this13[op](mapper, field, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * @name Adapter#respond + * @method + * @param {Object} response Response object. + * @param {Object} opts Configuration options. + * return {Object} If `opts.raw == true` then return `response`, else return + * `response.data`. + */ + respond: function respond(response, opts) { + return this.getOpt('raw', opts) ? response : response.data; + }, + + + /** + * Apply the given update to the record with the specified primary key. Called + * by `Mapper#update`. + * + * @name Adapter#update + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id The primary key of the record to be updated. + * @param {Object} props The update to apply to the record. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var _this14 = this; + + props || (props = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(this[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'update'; + _this14.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(_this14._update(mapper, id, props, opts)); + }).then(function (results) { + var _results8 = slicedToArray(results, 2), + data = _results8[0], + result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, 'update'); + response.updated = data ? 1 : 0; + response = _this14.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(_this14[op](mapper, id, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Apply the given update to all records that match the selection query. + * Called by `Mapper#updateAll`. + * + * @name Adapter#updateAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var _this15 = this; + + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(this[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'updateAll'; + _this15.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(_this15._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results9 = slicedToArray(results, 2), + data = _results9[0], + result = _results9[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateAll'); + response.updated = data.length; + response = _this15.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(_this15[op](mapper, props, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Update the given records in a single batch. Called by `Mapper#updateMany`. + * + * @name Adapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var _this16 = this; + + records || (records = []); + opts || (opts = {}); + var op = void 0; + var idAttribute = mapper.idAttribute; + + records = records.filter(function (record) { + return jsData.utils.get(record, idAttribute); + }); + + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return jsData.utils.resolve(this[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = _records === undefined ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record, opts); + }); + op = opts.op = 'updateMany'; + _this16.dbg(op, mapper, records, opts); + return jsData.utils.resolve(_this16._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results10 = slicedToArray(results, 2), + data = _results10[0], + result = _results10[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateMany'); + response.updated = data.length; + response = _this16.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(_this16[op](mapper, records, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + } +}); + +/** + * Create a subclass of this Adapter: + * + * @example Adapter.extend + * // Normally you would do: import {Adapter} from 'js-data' + * const JSData = require('js-data@3.0.0-beta.10') + * const {Adapter} = JSData + * console.log('Using JSData v' + JSData.version.full) + * + * // Extend the class using ES2015 class syntax. + * class CustomAdapterClass extends Adapter { + * foo () { return 'bar' } + * static beep () { return 'boop' } + * } + * const customAdapter = new CustomAdapterClass() + * console.log(customAdapter.foo()) + * console.log(CustomAdapterClass.beep()) + * + * // Extend the class using alternate method. + * const OtherAdapterClass = Adapter.extend({ + * foo () { return 'bar' } + * }, { + * beep () { return 'boop' } + * }) + * const otherAdapter = new OtherAdapterClass() + * console.log(otherAdapter.foo()) + * console.log(OtherAdapterClass.beep()) + * + * // Extend the class, providing a custom constructor. + * function AnotherAdapterClass () { + * Adapter.call(this) + * this.created_at = new Date().getTime() + * } + * Adapter.extend({ + * constructor: AnotherAdapterClass, + * foo () { return 'bar' } + * }, { + * beep () { return 'boop' } + * }) + * const anotherAdapter = new AnotherAdapterClass() + * console.log(anotherAdapter.created_at) + * console.log(anotherAdapter.foo()) + * console.log(AnotherAdapterClass.beep()) + * + * @method Adapter.extend + * @param {Object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {Object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {Object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this Adapter class. + */ + +var hasFetch = false; + +try { + hasFetch = window && window.fetch; +} catch (e) {} + +function isValidString(value) { + return value != null && value !== ''; +} +function join(items, separator) { + separator || (separator = ''); + return items.filter(isValidString).join(separator); +} +function makePath() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var result = join(args, '/'); + return result.replace(/([^:/]|^)\/{2,}/g, '$1/'); +} + +function encode(val) { + return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); +} + +function buildUrl(url, params) { + if (!params) { + return url; + } + + var parts = []; + + jsData.utils.forOwn(params, function (val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + if (!jsData.utils.isArray(val)) { + val = [val]; + } + + val.forEach(function (v) { + if (toString.call(v) === '[object Date]') { + v = v.toISOString(); + } else if (jsData.utils.isObject(v)) { + v = jsData.utils.toJson(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; +} + +var DEFAULTS = { + /** + * Set a base path in order to use absolute URLs instead of relative URLs. + * + * @example + * const httpAdapter = new HttpAdapter({ + * basePath: 'https://mydomain.com' + * }); + * + * @name HttpAdapter#basePath + * @type {string} + * @since 3.0.0 + */ + basePath: '', + + /** + * Ensure that the request url has a trailing forward slash. + * + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + * @since 3.0.0 + */ + forceTrailingSlash: false, + + hasFetch: hasFetch, + + /** + * The HTTP function that actually makes the HTTP request. By default this is + * `axios`. + * + * @name HttpAdapter#http + * @type {function} + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library + */ + http: axios, + + /** + * Default configuration options to be mixed into the `config` argument passed + * to {@link HttpAdapter#http}. + * + * @name HttpAdapter#httpConfig + * @type {object} + * @since 3.0.0 + */ + httpConfig: {}, + + /** + * Add a suffix to the request url, e.g. ".json". + * + * @name HttpAdapter#suffix + * @type {string} + * @since 3.0.0 + */ + suffix: '', + + /** + * Use `window.fetch` if available. + * + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-windowfetch + */ + useFetch: false + + /** + * HttpAdapter class. + * + * @example + * import { DataStore } from 'js-data'; + * import { HttpAdapter } from 'js-data-http'; + * + * const httpAdapter = new HttpAdapter(); + * const store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * + * store.defineMapper('school'); + * store.defineMapper('student'); + * + * // GET /school/1 + * store.find('school', 1).then((school) => { + * console.log('school'); + * }); + * + * @class HttpAdapter + * @extends Adapter + * @param {object} [opts] Configuration options. + * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}. + * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}. + * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}. + * @param {object} [opts.http=axios] See {@link HttpAdapter#http}. + * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}. + * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}. + * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}. + * @see http://www.js-data.io/docs/js-data-http + */ +};function HttpAdapter(opts) { + jsData.utils.classCallCheck(this, HttpAdapter); + + opts || (opts = {}); + // Fill in any missing options with the defaults + jsData.utils.fillIn(opts, DEFAULTS); + Adapter.call(this, opts); +} + +/** + * @name module:js-data-http.HttpAdapter + * @see HttpAdapter + */ + +Adapter.extend({ + constructor: HttpAdapter, + + /** + * @name HttpAdapter#afterDEL + * @method + * @param {string} url + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterDEL: noop2, + + /** + * @name HttpAdapter#afterGET + * @method + * @param {string} url + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterGET: noop2, + + /** + * @name HttpAdapter#afterHTTP + * @method + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterHTTP: noop2, + + /** + * @name HttpAdapter#afterPOST + * @method + * @param {string} url + * @param {object} data + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterPOST: noop2, + + /** + * @name HttpAdapter#afterPUT + * @method + * @param {string} url + * @param {object} data + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterPUT: noop2, + + /** + * @name HttpAdapter#beforeDEL + * @method + * @param {object} url + * @param {object} config + * @param {object} opts + */ + beforeDEL: noop, + + /** + * @name HttpAdapter#beforeGET + * @method + * @param {object} url + * @param {object} config + * @param {object} opts + */ + beforeGET: noop, + + /** + * @name HttpAdapter#beforeHTTP + * @method + * @param {object} config + * @param {object} opts + */ + beforeHTTP: noop, + + /** + * @name HttpAdapter#beforePOST + * @method + * @param {object} url + * @param {object} data + * @param {object} config + * @param {object} opts + */ + beforePOST: noop, + + /** + * @name HttpAdapter#beforePUT + * @method + * @param {object} url + * @param {object} data + * @param {object} config + * @param {object} opts + */ + beforePUT: noop, + + _count: function _count(mapper, query, opts) { + var _this = this; + + return this.GET(this.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return _this._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var _this2 = this; + + return this.POST(this.getPath('create', mapper, props, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this2._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var _this3 = this; + + return this.POST(this.getPath('createMany', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this3._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var _this4 = this; + + return this.DEL(this.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return _this4._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var _this5 = this; + + return this.DEL(this.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return _this5._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var _this6 = this; + + return this.GET(this.getPath('find', mapper, id, opts), opts).then(function (response) { + return _this6._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var _this7 = this; + + return this.GET(this.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return _this7._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var _this8 = this; + + return this.GET(this.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return _this8._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var _this9 = this; + + return this.PUT(this.getPath('update', mapper, id, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this9._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var _this10 = this; + + return this.PUT(this.getPath('updateAll', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this10._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var _this11 = this; + + return this.PUT(this.getPath('updateMany', mapper, null, opts), this.serialize(mapper, records, opts), opts).then(function (response) { + return _this11._end(mapper, opts, response); + }); + }, + + + /** + * Retrieve the number of records that match the selection `query`. + * + * @name HttpAdapter#count + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params.count = true; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.count.call(this, mapper, query, opts); + }, + + + /** + * Create a new the record from the provided `props`. + * + * @name HttpAdapter#create + * @method + * @param {object} mapper The mapper. + * @param {object} props Properties to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.create.call(this, mapper, props, opts); + }, + + + /** + * Create multiple new records in batch. + * + * @name HttpAdapter#createMany + * @method + * @param {object} mapper The mapper. + * @param {array} props Array of property objects to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.createMany.call(this, mapper, props, opts); + }, + + + /** + * Make an Http request to `url` according to the configuration in `config`. + * + * @name HttpAdapter#DEL + * @method + * @param {string} url Url for the request. + * @param {object} [config] Http configuration that will be passed to + * {@link HttpAdapter#HTTP}. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + DEL: function DEL(url, config, opts) { + var _this12 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'delete'; + + // beforeDEL lifecycle hook + op = opts.op = 'beforeDEL'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'DEL'; + _this12.dbg(op, url, config, opts); + return _this12.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return jsData.utils.resolve(_this12[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the server response object into the payload that will be returned + * to JSData. + * + * @name HttpAdapter#deserialize + * @method + * @param {object} mapper The mapper used for the operation. + * @param {object} response Response object from {@link HttpAdapter#HTTP}. + * @param {object} opts Configuration options. + * @return {(object|array)} Deserialized data. + */ + deserialize: function deserialize(mapper, response, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.deserialize)) { + return opts.deserialize(mapper, response, opts); + } + if (jsData.utils.isFunction(mapper.deserialize)) { + return mapper.deserialize(mapper, response, opts); + } + if (response && response.hasOwnProperty('data')) { + return response.data; + } + return response; + }, + + + /** + * Destroy the record with the given primary key. + * + * @name HttpAdapter#destroy + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.destroy.call(this, mapper, id, opts); + }, + + + /** + * Destroy the records that match the selection `query`. + * + * @name HttpAdapter#destroyAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.destroyAll.call(this, mapper, query, opts); + }, + + + /** + * Log an error. + * + * @name HttpAdapter#error + * @method + * @param {...*} [args] Arguments to log. + */ + error: function error() { + if (console) { + var _console; + + (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); + } + }, + + + /** + * Make an Http request using `window.fetch`. + * + * @name HttpAdapter#fetch + * @method + * @param {object} config Request configuration. + * @param {object} config.data Payload for the request. + * @param {string} config.method Http method for the request. + * @param {object} config.headers Headers for the request. + * @param {object} config.params Querystring for the request. + * @param {string} config.url Url for the request. + */ + fetch: function (_fetch) { + function fetch(_x) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config) { + var requestConfig = { + method: config.method, + // turn the plain headers object into the Fetch Headers object + headers: new Headers(config.headers || {}) + }; + + if (config.data) { + requestConfig.body = jsData.utils.toJson(config.data); + } + + return fetch(buildUrl(config.url, config.params), requestConfig).then(function (response) { + response.config = { + method: config.method, + url: config.url + }; + return response.json().then(function (data) { + response.data = data; + return response; + }); + }); + }), + + + /** + * Retrieve the record with the given primary key. + * + * @name HttpAdapter#find + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.find.call(this, mapper, id, opts); + }, + + + /** + * Retrieve the records that match the selection `query`. + * + * @name HttpAdapter#findAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.findAll.call(this, mapper, query, opts); + }, + + + /** + * Make a GET request. + * + * @name HttpAdapter#GET + * @method + * @param {string} url The url for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + GET: function GET(url, config, opts) { + var _this13 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'get'; + + // beforeGET lifecycle hook + op = opts.op = 'beforeGET'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'GET'; + _this13.dbg(op, url, config, opts); + return _this13.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return jsData.utils.resolve(_this13[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {object} mapper The Mapper. + * @param {*} id The primary key, if any. + * @param {boolean} opts Configuration options. + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var _this14 = this; + + opts || (opts = {}); + opts.params = jsData.utils.isUndefined(opts.params) ? {} : opts.params; + var relationList = mapper.relationList || []; + var endpoint = jsData.utils.isUndefined(opts.endpoint) ? jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; + + relationList.forEach(function (def) { + if (def.type !== 'belongsTo' || !def.parent) { + return; + } + var item = void 0; + var parentKey = def.foreignKey; + var parentDef = def.getRelation(); + var parentId = opts.params[parentKey]; + + if (parentId === false || !parentKey || !parentDef) { + if (parentId === false) { + delete opts.params[parentKey]; + } + return false; + } else { + delete opts.params[parentKey]; + + if (jsData.utils.isObject(id)) { + item = id; + } + + if (item) { + parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); + } + + if (parentId) { + delete opts.endpoint; + var _opts = {}; + jsData.utils.forOwn(opts, function (value, key) { + _opts[key] = value; + }); + jsData.utils._(_opts, parentDef); + endpoint = makePath(_this14.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return false; + } + } + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method The method being executed. + * @param {object} mapper The Mapper. + * @param {(string|number)?} id The primary key, if any. + * @param {object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + opts || (opts = {}); + var args = [opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, this.getEndpoint(mapper, jsData.utils.isString(id) || jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; + if (method === 'find' || method === 'update' || method === 'destroy') { + args.push(id); + } + return makePath.apply(jsData.utils, args); + }, + getParams: function getParams(opts) { + opts || (opts = {}); + if (opts.params === undefined) { + return {}; + } + return jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (opts.suffix === undefined) { + if (mapper.suffix === undefined) { + return this.suffix; + } + return mapper.suffix; + } + return opts.suffix; + }, + + + /** + * Make an Http request. + * + * @name HttpAdapter#HTTP + * @method + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + HTTP: function HTTP(config, opts) { + var _this15 = this; + + var start = new Date(); + opts || (opts = {}); + var payload = config.data; + var cache = config.cache; + var timeout = config.timeout; + config = jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); + config = jsData.utils.deepMixIn(config, this.httpConfig); + config.data = payload; + config.cache = cache; + if (timeout !== undefined) { + config.timeout = timeout; + } + if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || this.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + var logResponse = function logResponse(data) { + var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; + if (data.status >= 200 && data.status < 300) { + if (_this15.log) { + _this15.dbg(str, data); + } + return data; + } else { + if (_this15.error) { + _this15.error('\'FAILED: ' + str, data); + } + return jsData.utils.reject(data); + } + }; + + if (!this.http) { + if (this.useFetch || opts.useFetch) { + if (!hasFetch) { + throw new Error('Attempting to use window.fetch, but it is not available!'); + } + } else { + throw new Error('You have not configured this adapter with an http library!'); + } + } + + return jsData.utils.resolve(this.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (_this15.useFetch || opts.useFetch || !_this15.http)) { + return _this15.fetch(config, opts).then(logResponse, logResponse); + } + var httpConfig = jsData.utils.plainCopy(config); + delete httpConfig.adapter; + return _this15.http(httpConfig).then(logResponse, logResponse).catch(function (err) { + return _this15.responseError(err, config, opts); + }); + }).then(function (response) { + return jsData.utils.resolve(_this15.afterHTTP(config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Make a POST request. + * + * @name HttpAdapter#POST + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var _this16 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'post'; + + // beforePOST lifecycle hook + op = opts.op = 'beforePOST'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'POST'; + _this16.dbg(op, url, data, config, opts); + return _this16.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return jsData.utils.resolve(_this16[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Make a PUT request. + * + * @name HttpAdapter#PUT + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var _this17 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'put'; + + // beforePUT lifecycle hook + op = opts.op = 'beforePUT'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'PUT'; + _this17.dbg(op, url, data, config, opts); + return _this17.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return jsData.utils.resolve(_this17[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the querystring object before it is serialized. This doesn't do + * anything by default. + * + * @name HttpAdapter#queryTransform + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {*} params The querystring object. + * @param {*} opts Configuration options + * @return {*} Transformed params. + */ + queryTransform: function queryTransform(mapper, params, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts); + } + if (jsData.utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts); + } + return params; + }, + + + /** + * Error handler invoked when the promise returned by {@link HttpAdapter#http} + * is rejected. Default implementation is to just return the error wrapped in + * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is + * called by {@link HttpAdapter#HTTP}. + * + * @name HttpAdapter#responseError + * @method + * @param {*} err The error that {@link HttpAdapter#http} rejected with. + * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. + * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. + * @return {Promise} + */ + responseError: function responseError(err, config, opts) { + return jsData.utils.reject(err); + }, + + + /** + * Serialize request data. This doesn't do anything by default. + * + * @name HttpAdapter#serialize + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {object} data The request payload. + * @param {*} opts Configuration options. + * @return {*} Serialized data. + */ + serialize: function serialize(mapper, data, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts); + } + if (jsData.utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts); + } + return data; + }, + + + /** + * Retrieve the sum of the field of the records that match the selection query. + * + * @name HttpAdapter#sum + * @method + * @param {object} mapper The mapper. + * @param {string} field The field to sum. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + query || (query = {}); + opts || (opts = {}); + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = this.getParams(opts); + opts.params.sum = field; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.sum.call(this, mapper, field, query, opts); + }, + + + /** + * Perform an update. Makes a PUT request by default. + * + * @name HttpAdapter#update + * @method + * @param {object} mapper The Mapper for the request. + * @param {*} id The primary key of the record being updated. + * @param {*} props The update payload. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.update.call(this, mapper, id, props, opts); + }, + + + /** + * Perform an update against records that match the selection query. Makes a + * PUT request by default. + * + * @name HttpAdapter#updateAll + * @method + * @param {object} mapper The Mapper for the request. + * @param {object} props The update payload. + * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.updateAll.call(this, mapper, props, query, opts); + }, + + + /** + * Update multiple individual records in a batch. + * + * @name HttpAdapter#updateMany + * @method + * @param {object} mapper The Mapper for the request. + * @param {array} records Array of property objects to send as the payload. + * Each must contain the primary key of the record to be updated. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.updateMany.call(this, mapper, records, opts); + } +}); + +/** + * Add an Http actions to a mapper. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addAction = JSDataHttp.addAction; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * // GET /reports/schools/:school_id/teachers + * addAction('getTeacherReports', { + * endpoint: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addAction + * @method + * @param {string} name Name of the new action. + * @param {object} [opts] Action configuration + * @param {string} [opts.adapter="http"] The name of the adapter to use. + * @param {string} [opts.pathname] Set the action's pathname. + * @param {function} [opts.request] Specify a request handler to be executed + * before the request is made. + * @param {function} [opts.response] Specify a response handler to be executed + * after the response is received. + * @param {function} [opts.responseError] Specify an error handler to be + * executed on error. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addAction(name, opts) { + if (!name || !jsData.utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + } + return function (mapper) { + if (mapper[name]) { + throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); + } + opts.request = opts.request || function (config) { + return config; + }; + opts.response = opts.response || function (response) { + return response; + }; + opts.responseError = opts.responseError || function (err) { + return jsData.utils.reject(err); + }; + mapper[name] = function (id, _opts) { + var _this18 = this; + + _opts = _opts || {}; + if (jsData.utils.isObject(id)) { + _opts = id; + } + jsData.utils.fillIn(_opts, opts); + var adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http'); + var config = {}; + config.mapper = this.name; + jsData.utils.deepMixIn(config, _opts); + config.method = config.method || 'GET'; + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(this, _opts); + } else { + var args = [_opts.basePath || this.basePath || adapter.basePath, adapter.getEndpoint(this, id, _opts)]; + if (jsData.utils.isSorN(id)) { + args.push(id); + } + args.push(opts.pathname || name); + config.url = makePath.apply(null, args); + } + return jsData.utils.resolve(config).then(_opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = _this18.name; + } + return data; + }).then(_opts.response, _opts.responseError); + }; + return mapper; + }; +} + +/** + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addActions = JSDataHttp.addActions; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * addActions({ + * // GET /reports/schools/:school_id/teachers + * getTeacherReports: { + * basePath: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * } + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addActions + * @method + * @param {object.} opts Object where the key is an action name + * and the value is the configuration for the action. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addActions(opts) { + opts || (opts = {}); + return function (mapper) { + jsData.utils.forOwn(opts, function (value, key) { + addAction(key, value)(mapper); + }); + return mapper; + }; +} + +/** + * Details of the current version of the `js-data-http` module. + * + * @name module:js-data-http.version + * @type {object} + * @property {string} version.full The full semver value. + * @property {number} version.major The major version number. + * @property {number} version.minor The minor version number. + * @property {number} version.patch The patch version number. + * @property {(string|boolean)} version.alpha The alpha version value, + * otherwise `false` if the current version is not alpha. + * @property {(string|boolean)} version.beta The beta version value, + * otherwise `false` if the current version is not beta. + */ +var version = { + full: '3.0.0', major: 3, minor: 0, patch: 0 }; - exports.HttpAdapter = HttpAdapter; - exports.addAction = addAction; - exports.addActions = addActions; - exports.version = version; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); +/** + * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http` + * that works on Node.js is registered in NPM as `js-data-http-node`. The build + * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower + * as `js-data-fetch`. + * + * @example Script tag + * var HttpAdapter = window.JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example CommonJS + * var HttpAdapter = require('js-data-Http').HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example ES2015 Modules + * import { HttpAdapter } from 'js-data-Http'; + * const httpAdapter = new HttpAdapter(); + * + * @example AMD + * define('myApp', ['js-data-Http'], function (JSDataHttp) { + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * // ... + * }); + * + * @module js-data-http + */ + +/** + * Create a subclass of this HttpAdapter: + * @example HttpAdapter.extend + * // Normally you would do: import { HttpAdapter } from 'js-data-http'; + * // or: import { HttpAdapter } from 'js-data-http-node'; + * const JSDataHttp = require('js-data-http-node'); + * const { HttpAdapter } = JSDataHttp; + * console.log('Using JSDataHttp v' + JSDataHttp.version.full); + * + * // Extend the class using ES2015 class syntax. + * class CustomHttpAdapterClass extends HttpAdapter { + * foo () { return 'bar'; } + * static beep () { return 'boop'; } + * } + * const customHttpAdapter = new CustomHttpAdapterClass(); + * console.log(customHttpAdapter.foo()); + * console.log(CustomHttpAdapterClass.beep()); + * + * // Extend the class using alternate method. + * const OtherHttpAdapterClass = HttpAdapter.extend({ + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const otherHttpAdapter = new OtherHttpAdapterClass(); + * console.log(otherHttpAdapter.foo()); + * console.log(OtherHttpAdapterClass.beep()); + * + * // Extend the class, providing a custom constructor. + * function AnotherHttpAdapterClass () { + * HttpAdapter.call(this); + * this.created_at = new Date().getTime(); + * } + * HttpAdapter.extend({ + * constructor: AnotherHttpAdapterClass, + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const anotherHttpAdapter = new AnotherHttpAdapterClass(); + * console.log(anotherHttpAdapter.created_at); + * console.log(anotherHttpAdapter.foo()); + * console.log(AnotherHttpAdapterClass.beep()); + * + * @method HttpAdapter.extend + * @param {object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this HttpAdapter class. + * @since 3.0.0 + */ + +exports.HttpAdapter = HttpAdapter; +exports.addAction = addAction; +exports.addActions = addActions; +exports.version = version; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); //# sourceMappingURL=js-data-http.js.map diff --git a/dist/js-data-http.js.map b/dist/js-data-http.js.map index 30360f8..efeaa60 100644 --- a/dist/js-data-http.js.map +++ b/dist/js-data-http.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["../node_modules/axios/dist/axios.js","../node_modules/js-data-adapter/src/index.js","../src/index.js"],"sourcesContent":["/* axios v0.13.1 | (c) 2016 by Matt Zabriskie */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axios\"] = factory();\n\telse\n\t\troot[\"axios\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(1);\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar bind = __webpack_require__(3);\n\tvar Axios = __webpack_require__(4);\n\t\n\t/**\n\t * Create an instance of Axios\n\t *\n\t * @param {Object} defaultConfig The default config for the instance\n\t * @return {Axios} A new instance of Axios\n\t */\n\tfunction createInstance(defaultConfig) {\n\t var context = new Axios(defaultConfig);\n\t var instance = bind(Axios.prototype.request, context);\n\t\n\t // Copy axios.prototype to instance\n\t utils.extend(instance, Axios.prototype, context);\n\t\n\t // Copy context to instance\n\t utils.extend(instance, context);\n\t\n\t return instance;\n\t}\n\t\n\t// Create the default instance to be exported\n\tvar axios = module.exports = createInstance();\n\t\n\t// Expose Axios class to allow class inheritance\n\taxios.Axios = Axios;\n\t\n\t// Factory for creating new instances\n\taxios.create = function create(defaultConfig) {\n\t return createInstance(defaultConfig);\n\t};\n\t\n\t// Expose all/spread\n\taxios.all = function all(promises) {\n\t return Promise.all(promises);\n\t};\n\taxios.spread = __webpack_require__(21);\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar bind = __webpack_require__(3);\n\t\n\t/*global toString:true*/\n\t\n\t// utils is a library of generic helper functions non-specific to axios\n\t\n\tvar toString = Object.prototype.toString;\n\t\n\t/**\n\t * Determine if a value is an Array\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Array, otherwise false\n\t */\n\tfunction isArray(val) {\n\t return toString.call(val) === '[object Array]';\n\t}\n\t\n\t/**\n\t * Determine if a value is an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBuffer(val) {\n\t return toString.call(val) === '[object ArrayBuffer]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a FormData\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an FormData, otherwise false\n\t */\n\tfunction isFormData(val) {\n\t return (typeof FormData !== 'undefined') && (val instanceof FormData);\n\t}\n\t\n\t/**\n\t * Determine if a value is a view on an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBufferView(val) {\n\t var result;\n\t if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n\t result = ArrayBuffer.isView(val);\n\t } else {\n\t result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Determine if a value is a String\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a String, otherwise false\n\t */\n\tfunction isString(val) {\n\t return typeof val === 'string';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Number\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Number, otherwise false\n\t */\n\tfunction isNumber(val) {\n\t return typeof val === 'number';\n\t}\n\t\n\t/**\n\t * Determine if a value is undefined\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if the value is undefined, otherwise false\n\t */\n\tfunction isUndefined(val) {\n\t return typeof val === 'undefined';\n\t}\n\t\n\t/**\n\t * Determine if a value is an Object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Object, otherwise false\n\t */\n\tfunction isObject(val) {\n\t return val !== null && typeof val === 'object';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Date\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Date, otherwise false\n\t */\n\tfunction isDate(val) {\n\t return toString.call(val) === '[object Date]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a File\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a File, otherwise false\n\t */\n\tfunction isFile(val) {\n\t return toString.call(val) === '[object File]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Blob\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Blob, otherwise false\n\t */\n\tfunction isBlob(val) {\n\t return toString.call(val) === '[object Blob]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Function\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Function, otherwise false\n\t */\n\tfunction isFunction(val) {\n\t return toString.call(val) === '[object Function]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Stream\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Stream, otherwise false\n\t */\n\tfunction isStream(val) {\n\t return isObject(val) && isFunction(val.pipe);\n\t}\n\t\n\t/**\n\t * Determine if a value is a URLSearchParams object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n\t */\n\tfunction isURLSearchParams(val) {\n\t return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n\t}\n\t\n\t/**\n\t * Trim excess whitespace off the beginning and end of a string\n\t *\n\t * @param {String} str The String to trim\n\t * @returns {String} The String freed of excess whitespace\n\t */\n\tfunction trim(str) {\n\t return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n\t}\n\t\n\t/**\n\t * Determine if we're running in a standard browser environment\n\t *\n\t * This allows axios to run in a web worker, and react-native.\n\t * Both environments support XMLHttpRequest, but not fully standard globals.\n\t *\n\t * web workers:\n\t * typeof window -> undefined\n\t * typeof document -> undefined\n\t *\n\t * react-native:\n\t * typeof document.createElement -> undefined\n\t */\n\tfunction isStandardBrowserEnv() {\n\t return (\n\t typeof window !== 'undefined' &&\n\t typeof document !== 'undefined' &&\n\t typeof document.createElement === 'function'\n\t );\n\t}\n\t\n\t/**\n\t * Iterate over an Array or an Object invoking a function for each item.\n\t *\n\t * If `obj` is an Array callback will be called passing\n\t * the value, index, and complete array for each item.\n\t *\n\t * If 'obj' is an Object callback will be called passing\n\t * the value, key, and complete object for each property.\n\t *\n\t * @param {Object|Array} obj The object to iterate\n\t * @param {Function} fn The callback to invoke for each item\n\t */\n\tfunction forEach(obj, fn) {\n\t // Don't bother if no value provided\n\t if (obj === null || typeof obj === 'undefined') {\n\t return;\n\t }\n\t\n\t // Force an array if not already something iterable\n\t if (typeof obj !== 'object' && !isArray(obj)) {\n\t /*eslint no-param-reassign:0*/\n\t obj = [obj];\n\t }\n\t\n\t if (isArray(obj)) {\n\t // Iterate over array values\n\t for (var i = 0, l = obj.length; i < l; i++) {\n\t fn.call(null, obj[i], i, obj);\n\t }\n\t } else {\n\t // Iterate over object keys\n\t for (var key in obj) {\n\t if (obj.hasOwnProperty(key)) {\n\t fn.call(null, obj[key], key, obj);\n\t }\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * Accepts varargs expecting each argument to be an object, then\n\t * immutably merges the properties of each object and returns result.\n\t *\n\t * When multiple objects contain the same key the later object in\n\t * the arguments list will take precedence.\n\t *\n\t * Example:\n\t *\n\t * ```js\n\t * var result = merge({foo: 123}, {foo: 456});\n\t * console.log(result.foo); // outputs 456\n\t * ```\n\t *\n\t * @param {Object} obj1 Object to merge\n\t * @returns {Object} Result of all merge properties\n\t */\n\tfunction merge(/* obj1, obj2, obj3, ... */) {\n\t var result = {};\n\t function assignValue(val, key) {\n\t if (typeof result[key] === 'object' && typeof val === 'object') {\n\t result[key] = merge(result[key], val);\n\t } else {\n\t result[key] = val;\n\t }\n\t }\n\t\n\t for (var i = 0, l = arguments.length; i < l; i++) {\n\t forEach(arguments[i], assignValue);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Extends object a by mutably adding to it the properties of object b.\n\t *\n\t * @param {Object} a The object to be extended\n\t * @param {Object} b The object to copy properties from\n\t * @param {Object} thisArg The object to bind function to\n\t * @return {Object} The resulting value of object a\n\t */\n\tfunction extend(a, b, thisArg) {\n\t forEach(b, function assignValue(val, key) {\n\t if (thisArg && typeof val === 'function') {\n\t a[key] = bind(val, thisArg);\n\t } else {\n\t a[key] = val;\n\t }\n\t });\n\t return a;\n\t}\n\t\n\tmodule.exports = {\n\t isArray: isArray,\n\t isArrayBuffer: isArrayBuffer,\n\t isFormData: isFormData,\n\t isArrayBufferView: isArrayBufferView,\n\t isString: isString,\n\t isNumber: isNumber,\n\t isObject: isObject,\n\t isUndefined: isUndefined,\n\t isDate: isDate,\n\t isFile: isFile,\n\t isBlob: isBlob,\n\t isFunction: isFunction,\n\t isStream: isStream,\n\t isURLSearchParams: isURLSearchParams,\n\t isStandardBrowserEnv: isStandardBrowserEnv,\n\t forEach: forEach,\n\t merge: merge,\n\t extend: extend,\n\t trim: trim\n\t};\n\n\n/***/ },\n/* 3 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = function bind(fn, thisArg) {\n\t return function wrap() {\n\t var args = new Array(arguments.length);\n\t for (var i = 0; i < args.length; i++) {\n\t args[i] = arguments[i];\n\t }\n\t return fn.apply(thisArg, args);\n\t };\n\t};\n\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar defaults = __webpack_require__(5);\n\tvar utils = __webpack_require__(2);\n\tvar InterceptorManager = __webpack_require__(7);\n\tvar dispatchRequest = __webpack_require__(8);\n\tvar isAbsoluteURL = __webpack_require__(19);\n\tvar combineURLs = __webpack_require__(20);\n\t\n\t/**\n\t * Create a new instance of Axios\n\t *\n\t * @param {Object} defaultConfig The default config for the instance\n\t */\n\tfunction Axios(defaultConfig) {\n\t this.defaults = utils.merge(defaults, defaultConfig);\n\t this.interceptors = {\n\t request: new InterceptorManager(),\n\t response: new InterceptorManager()\n\t };\n\t}\n\t\n\t/**\n\t * Dispatch a request\n\t *\n\t * @param {Object} config The config specific for this request (merged with this.defaults)\n\t */\n\tAxios.prototype.request = function request(config) {\n\t /*eslint no-param-reassign:0*/\n\t // Allow for axios('example/url'[, config]) a la fetch API\n\t if (typeof config === 'string') {\n\t config = utils.merge({\n\t url: arguments[0]\n\t }, arguments[1]);\n\t }\n\t\n\t config = utils.merge(defaults, this.defaults, { method: 'get' }, config);\n\t\n\t // Support baseURL config\n\t if (config.baseURL && !isAbsoluteURL(config.url)) {\n\t config.url = combineURLs(config.baseURL, config.url);\n\t }\n\t\n\t // Hook up interceptors middleware\n\t var chain = [dispatchRequest, undefined];\n\t var promise = Promise.resolve(config);\n\t\n\t this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n\t chain.unshift(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n\t chain.push(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t while (chain.length) {\n\t promise = promise.then(chain.shift(), chain.shift());\n\t }\n\t\n\t return promise;\n\t};\n\t\n\t// Provide aliases for supported request methods\n\tutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, config) {\n\t return this.request(utils.merge(config || {}, {\n\t method: method,\n\t url: url\n\t }));\n\t };\n\t});\n\t\n\tutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, data, config) {\n\t return this.request(utils.merge(config || {}, {\n\t method: method,\n\t url: url,\n\t data: data\n\t }));\n\t };\n\t});\n\t\n\tmodule.exports = Axios;\n\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar normalizeHeaderName = __webpack_require__(6);\n\t\n\tvar PROTECTION_PREFIX = /^\\)\\]\\}',?\\n/;\n\tvar DEFAULT_CONTENT_TYPE = {\n\t 'Content-Type': 'application/x-www-form-urlencoded'\n\t};\n\t\n\tfunction setContentTypeIfUnset(headers, value) {\n\t if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n\t headers['Content-Type'] = value;\n\t }\n\t}\n\t\n\tmodule.exports = {\n\t transformRequest: [function transformRequest(data, headers) {\n\t normalizeHeaderName(headers, 'Content-Type');\n\t if (utils.isFormData(data) ||\n\t utils.isArrayBuffer(data) ||\n\t utils.isStream(data) ||\n\t utils.isFile(data) ||\n\t utils.isBlob(data)\n\t ) {\n\t return data;\n\t }\n\t if (utils.isArrayBufferView(data)) {\n\t return data.buffer;\n\t }\n\t if (utils.isURLSearchParams(data)) {\n\t setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n\t return data.toString();\n\t }\n\t if (utils.isObject(data)) {\n\t setContentTypeIfUnset(headers, 'application/json;charset=utf-8');\n\t return JSON.stringify(data);\n\t }\n\t return data;\n\t }],\n\t\n\t transformResponse: [function transformResponse(data) {\n\t /*eslint no-param-reassign:0*/\n\t if (typeof data === 'string') {\n\t data = data.replace(PROTECTION_PREFIX, '');\n\t try {\n\t data = JSON.parse(data);\n\t } catch (e) { /* Ignore */ }\n\t }\n\t return data;\n\t }],\n\t\n\t headers: {\n\t common: {\n\t 'Accept': 'application/json, text/plain, */*'\n\t },\n\t patch: utils.merge(DEFAULT_CONTENT_TYPE),\n\t post: utils.merge(DEFAULT_CONTENT_TYPE),\n\t put: utils.merge(DEFAULT_CONTENT_TYPE)\n\t },\n\t\n\t timeout: 0,\n\t\n\t xsrfCookieName: 'XSRF-TOKEN',\n\t xsrfHeaderName: 'X-XSRF-TOKEN',\n\t\n\t maxContentLength: -1,\n\t\n\t validateStatus: function validateStatus(status) {\n\t return status >= 200 && status < 300;\n\t }\n\t};\n\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n\t utils.forEach(headers, function processHeader(value, name) {\n\t if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n\t headers[normalizedName] = value;\n\t delete headers[name];\n\t }\n\t });\n\t};\n\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction InterceptorManager() {\n\t this.handlers = [];\n\t}\n\t\n\t/**\n\t * Add a new interceptor to the stack\n\t *\n\t * @param {Function} fulfilled The function to handle `then` for a `Promise`\n\t * @param {Function} rejected The function to handle `reject` for a `Promise`\n\t *\n\t * @return {Number} An ID used to remove interceptor later\n\t */\n\tInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n\t this.handlers.push({\n\t fulfilled: fulfilled,\n\t rejected: rejected\n\t });\n\t return this.handlers.length - 1;\n\t};\n\t\n\t/**\n\t * Remove an interceptor from the stack\n\t *\n\t * @param {Number} id The ID that was returned by `use`\n\t */\n\tInterceptorManager.prototype.eject = function eject(id) {\n\t if (this.handlers[id]) {\n\t this.handlers[id] = null;\n\t }\n\t};\n\t\n\t/**\n\t * Iterate over all the registered interceptors\n\t *\n\t * This method is particularly useful for skipping over any\n\t * interceptors that may have become `null` calling `eject`.\n\t *\n\t * @param {Function} fn The function to call for each interceptor\n\t */\n\tInterceptorManager.prototype.forEach = function forEach(fn) {\n\t utils.forEach(this.handlers, function forEachHandler(h) {\n\t if (h !== null) {\n\t fn(h);\n\t }\n\t });\n\t};\n\t\n\tmodule.exports = InterceptorManager;\n\n\n/***/ },\n/* 8 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar transformData = __webpack_require__(9);\n\t\n\t/**\n\t * Dispatch a request to the server using whichever adapter\n\t * is supported by the current environment.\n\t *\n\t * @param {object} config The config that is to be used for the request\n\t * @returns {Promise} The Promise to be fulfilled\n\t */\n\tmodule.exports = function dispatchRequest(config) {\n\t // Ensure headers exist\n\t config.headers = config.headers || {};\n\t\n\t // Transform request data\n\t config.data = transformData(\n\t config.data,\n\t config.headers,\n\t config.transformRequest\n\t );\n\t\n\t // Flatten headers\n\t config.headers = utils.merge(\n\t config.headers.common || {},\n\t config.headers[config.method] || {},\n\t config.headers || {}\n\t );\n\t\n\t utils.forEach(\n\t ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n\t function cleanHeaderConfig(method) {\n\t delete config.headers[method];\n\t }\n\t );\n\t\n\t var adapter;\n\t\n\t if (typeof config.adapter === 'function') {\n\t // For custom adapter support\n\t adapter = config.adapter;\n\t } else if (typeof XMLHttpRequest !== 'undefined') {\n\t // For browsers use XHR adapter\n\t adapter = __webpack_require__(10);\n\t } else if (typeof process !== 'undefined') {\n\t // For node use HTTP adapter\n\t adapter = __webpack_require__(10);\n\t }\n\t\n\t return Promise.resolve(config)\n\t // Wrap synchronous adapter errors and pass configuration\n\t .then(adapter)\n\t .then(function onFulfilled(response) {\n\t // Transform response data\n\t response.data = transformData(\n\t response.data,\n\t response.headers,\n\t config.transformResponse\n\t );\n\t\n\t return response;\n\t }, function onRejected(error) {\n\t // Transform response data\n\t if (error && error.response) {\n\t error.response.data = transformData(\n\t error.response.data,\n\t error.response.headers,\n\t config.transformResponse\n\t );\n\t }\n\t\n\t return Promise.reject(error);\n\t });\n\t};\n\n\n/***/ },\n/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t/**\n\t * Transform the data for a request or a response\n\t *\n\t * @param {Object|String} data The data to be transformed\n\t * @param {Array} headers The headers for the request or response\n\t * @param {Array|Function} fns A single function or Array of functions\n\t * @returns {*} The resulting transformed data\n\t */\n\tmodule.exports = function transformData(data, headers, fns) {\n\t /*eslint no-param-reassign:0*/\n\t utils.forEach(fns, function transform(fn) {\n\t data = fn(data, headers);\n\t });\n\t\n\t return data;\n\t};\n\n\n/***/ },\n/* 10 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar settle = __webpack_require__(11);\n\tvar buildURL = __webpack_require__(14);\n\tvar parseHeaders = __webpack_require__(15);\n\tvar isURLSameOrigin = __webpack_require__(16);\n\tvar createError = __webpack_require__(12);\n\tvar btoa = (typeof window !== 'undefined' && window.btoa) || __webpack_require__(17);\n\t\n\tmodule.exports = function xhrAdapter(config) {\n\t return new Promise(function dispatchXhrRequest(resolve, reject) {\n\t var requestData = config.data;\n\t var requestHeaders = config.headers;\n\t\n\t if (utils.isFormData(requestData)) {\n\t delete requestHeaders['Content-Type']; // Let the browser set it\n\t }\n\t\n\t var request = new XMLHttpRequest();\n\t var loadEvent = 'onreadystatechange';\n\t var xDomain = false;\n\t\n\t // For IE 8/9 CORS support\n\t // Only supports POST and GET calls and doesn't returns the response headers.\n\t // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.\n\t if ((\"production\") !== 'test' &&\n\t typeof window !== 'undefined' &&\n\t window.XDomainRequest && !('withCredentials' in request) &&\n\t !isURLSameOrigin(config.url)) {\n\t request = new window.XDomainRequest();\n\t loadEvent = 'onload';\n\t xDomain = true;\n\t request.onprogress = function handleProgress() {};\n\t request.ontimeout = function handleTimeout() {};\n\t }\n\t\n\t // HTTP basic authentication\n\t if (config.auth) {\n\t var username = config.auth.username || '';\n\t var password = config.auth.password || '';\n\t requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n\t }\n\t\n\t request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);\n\t\n\t // Set the request timeout in MS\n\t request.timeout = config.timeout;\n\t\n\t // Listen for ready state\n\t request[loadEvent] = function handleLoad() {\n\t if (!request || (request.readyState !== 4 && !xDomain)) {\n\t return;\n\t }\n\t\n\t // The request errored out and we didn't get a response, this will be\n\t // handled by onerror instead\n\t if (request.status === 0) {\n\t return;\n\t }\n\t\n\t // Prepare the response\n\t var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n\t var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n\t var response = {\n\t data: responseData,\n\t // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)\n\t status: request.status === 1223 ? 204 : request.status,\n\t statusText: request.status === 1223 ? 'No Content' : request.statusText,\n\t headers: responseHeaders,\n\t config: config,\n\t request: request\n\t };\n\t\n\t settle(resolve, reject, response);\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle low level network errors\n\t request.onerror = function handleError() {\n\t // Real errors are hidden from us by the browser\n\t // onerror should only fire if it's a network error\n\t reject(createError('Network Error', config));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle timeout\n\t request.ontimeout = function handleTimeout() {\n\t reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED'));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Add xsrf header\n\t // This is only done if running in a standard browser environment.\n\t // Specifically not if we're in a web worker, or react-native.\n\t if (utils.isStandardBrowserEnv()) {\n\t var cookies = __webpack_require__(18);\n\t\n\t // Add xsrf header\n\t var xsrfValue = config.withCredentials || isURLSameOrigin(config.url) ?\n\t cookies.read(config.xsrfCookieName) :\n\t undefined;\n\t\n\t if (xsrfValue) {\n\t requestHeaders[config.xsrfHeaderName] = xsrfValue;\n\t }\n\t }\n\t\n\t // Add headers to the request\n\t if ('setRequestHeader' in request) {\n\t utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n\t if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n\t // Remove Content-Type if data is undefined\n\t delete requestHeaders[key];\n\t } else {\n\t // Otherwise add header to the request\n\t request.setRequestHeader(key, val);\n\t }\n\t });\n\t }\n\t\n\t // Add withCredentials to request if needed\n\t if (config.withCredentials) {\n\t request.withCredentials = true;\n\t }\n\t\n\t // Add responseType to request if needed\n\t if (config.responseType) {\n\t try {\n\t request.responseType = config.responseType;\n\t } catch (e) {\n\t if (request.responseType !== 'json') {\n\t throw e;\n\t }\n\t }\n\t }\n\t\n\t // Handle progress if needed\n\t if (typeof config.progress === 'function') {\n\t if (config.method === 'post' || config.method === 'put') {\n\t request.upload.addEventListener('progress', config.progress);\n\t } else if (config.method === 'get') {\n\t request.addEventListener('progress', config.progress);\n\t }\n\t }\n\t\n\t if (requestData === undefined) {\n\t requestData = null;\n\t }\n\t\n\t // Send the request\n\t request.send(requestData);\n\t });\n\t};\n\n\n/***/ },\n/* 11 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar createError = __webpack_require__(12);\n\t\n\t/**\n\t * Resolve or reject a Promise based on response status.\n\t *\n\t * @param {Function} resolve A function that resolves the promise.\n\t * @param {Function} reject A function that rejects the promise.\n\t * @param {object} response The response.\n\t */\n\tmodule.exports = function settle(resolve, reject, response) {\n\t var validateStatus = response.config.validateStatus;\n\t // Note: status is not exposed by XDomainRequest\n\t if (!response.status || !validateStatus || validateStatus(response.status)) {\n\t resolve(response);\n\t } else {\n\t reject(createError(\n\t 'Request failed with status code ' + response.status,\n\t response.config,\n\t null,\n\t response\n\t ));\n\t }\n\t};\n\n\n/***/ },\n/* 12 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar enhanceError = __webpack_require__(13);\n\t\n\t/**\n\t * Create an Error with the specified message, config, error code, and response.\n\t *\n\t * @param {string} message The error message.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t @ @param {Object} [response] The response.\n\t * @returns {Error} The created error.\n\t */\n\tmodule.exports = function createError(message, config, code, response) {\n\t var error = new Error(message);\n\t return enhanceError(error, config, code, response);\n\t};\n\n\n/***/ },\n/* 13 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Update an Error with the specified config, error code, and response.\n\t *\n\t * @param {Error} error The error to update.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t @ @param {Object} [response] The response.\n\t * @returns {Error} The error.\n\t */\n\tmodule.exports = function enhanceError(error, config, code, response) {\n\t error.config = config;\n\t if (code) {\n\t error.code = code;\n\t }\n\t error.response = response;\n\t return error;\n\t};\n\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction encode(val) {\n\t return encodeURIComponent(val).\n\t replace(/%40/gi, '@').\n\t replace(/%3A/gi, ':').\n\t replace(/%24/g, '$').\n\t replace(/%2C/gi, ',').\n\t replace(/%20/g, '+').\n\t replace(/%5B/gi, '[').\n\t replace(/%5D/gi, ']');\n\t}\n\t\n\t/**\n\t * Build a URL by appending params to the end\n\t *\n\t * @param {string} url The base of the url (e.g., http://www.google.com)\n\t * @param {object} [params] The params to be appended\n\t * @returns {string} The formatted url\n\t */\n\tmodule.exports = function buildURL(url, params, paramsSerializer) {\n\t /*eslint no-param-reassign:0*/\n\t if (!params) {\n\t return url;\n\t }\n\t\n\t var serializedParams;\n\t if (paramsSerializer) {\n\t serializedParams = paramsSerializer(params);\n\t } else if (utils.isURLSearchParams(params)) {\n\t serializedParams = params.toString();\n\t } else {\n\t var parts = [];\n\t\n\t utils.forEach(params, function serialize(val, key) {\n\t if (val === null || typeof val === 'undefined') {\n\t return;\n\t }\n\t\n\t if (utils.isArray(val)) {\n\t key = key + '[]';\n\t }\n\t\n\t if (!utils.isArray(val)) {\n\t val = [val];\n\t }\n\t\n\t utils.forEach(val, function parseValue(v) {\n\t if (utils.isDate(v)) {\n\t v = v.toISOString();\n\t } else if (utils.isObject(v)) {\n\t v = JSON.stringify(v);\n\t }\n\t parts.push(encode(key) + '=' + encode(v));\n\t });\n\t });\n\t\n\t serializedParams = parts.join('&');\n\t }\n\t\n\t if (serializedParams) {\n\t url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n\t }\n\t\n\t return url;\n\t};\n\n\n/***/ },\n/* 15 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t/**\n\t * Parse headers into an object\n\t *\n\t * ```\n\t * Date: Wed, 27 Aug 2014 08:58:49 GMT\n\t * Content-Type: application/json\n\t * Connection: keep-alive\n\t * Transfer-Encoding: chunked\n\t * ```\n\t *\n\t * @param {String} headers Headers needing to be parsed\n\t * @returns {Object} Headers parsed into an object\n\t */\n\tmodule.exports = function parseHeaders(headers) {\n\t var parsed = {};\n\t var key;\n\t var val;\n\t var i;\n\t\n\t if (!headers) { return parsed; }\n\t\n\t utils.forEach(headers.split('\\n'), function parser(line) {\n\t i = line.indexOf(':');\n\t key = utils.trim(line.substr(0, i)).toLowerCase();\n\t val = utils.trim(line.substr(i + 1));\n\t\n\t if (key) {\n\t parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n\t }\n\t });\n\t\n\t return parsed;\n\t};\n\n\n/***/ },\n/* 16 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs have full support of the APIs needed to test\n\t // whether the request URL is of the same origin as current location.\n\t (function standardBrowserEnv() {\n\t var msie = /(msie|trident)/i.test(navigator.userAgent);\n\t var urlParsingNode = document.createElement('a');\n\t var originURL;\n\t\n\t /**\n\t * Parse a URL to discover it's components\n\t *\n\t * @param {String} url The URL to be parsed\n\t * @returns {Object}\n\t */\n\t function resolveURL(url) {\n\t var href = url;\n\t\n\t if (msie) {\n\t // IE needs attribute set twice to normalize properties\n\t urlParsingNode.setAttribute('href', href);\n\t href = urlParsingNode.href;\n\t }\n\t\n\t urlParsingNode.setAttribute('href', href);\n\t\n\t // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n\t return {\n\t href: urlParsingNode.href,\n\t protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n\t host: urlParsingNode.host,\n\t search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n\t hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n\t hostname: urlParsingNode.hostname,\n\t port: urlParsingNode.port,\n\t pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n\t urlParsingNode.pathname :\n\t '/' + urlParsingNode.pathname\n\t };\n\t }\n\t\n\t originURL = resolveURL(window.location.href);\n\t\n\t /**\n\t * Determine if a URL shares the same origin as the current location\n\t *\n\t * @param {String} requestURL The URL to test\n\t * @returns {boolean} True if URL shares the same origin, otherwise false\n\t */\n\t return function isURLSameOrigin(requestURL) {\n\t var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n\t return (parsed.protocol === originURL.protocol &&\n\t parsed.host === originURL.host);\n\t };\n\t })() :\n\t\n\t // Non standard browser envs (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return function isURLSameOrigin() {\n\t return true;\n\t };\n\t })()\n\t);\n\n\n/***/ },\n/* 17 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js\n\t\n\tvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\t\n\tfunction E() {\n\t this.message = 'String contains an invalid character';\n\t}\n\tE.prototype = new Error;\n\tE.prototype.code = 5;\n\tE.prototype.name = 'InvalidCharacterError';\n\t\n\tfunction btoa(input) {\n\t var str = String(input);\n\t var output = '';\n\t for (\n\t // initialize result and counter\n\t var block, charCode, idx = 0, map = chars;\n\t // if the next str index does not exist:\n\t // change the mapping table to \"=\"\n\t // check if d has no fractional digits\n\t str.charAt(idx | 0) || (map = '=', idx % 1);\n\t // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n\t output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n\t ) {\n\t charCode = str.charCodeAt(idx += 3 / 4);\n\t if (charCode > 0xFF) {\n\t throw new E();\n\t }\n\t block = block << 8 | charCode;\n\t }\n\t return output;\n\t}\n\t\n\tmodule.exports = btoa;\n\n\n/***/ },\n/* 18 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs support document.cookie\n\t (function standardBrowserEnv() {\n\t return {\n\t write: function write(name, value, expires, path, domain, secure) {\n\t var cookie = [];\n\t cookie.push(name + '=' + encodeURIComponent(value));\n\t\n\t if (utils.isNumber(expires)) {\n\t cookie.push('expires=' + new Date(expires).toGMTString());\n\t }\n\t\n\t if (utils.isString(path)) {\n\t cookie.push('path=' + path);\n\t }\n\t\n\t if (utils.isString(domain)) {\n\t cookie.push('domain=' + domain);\n\t }\n\t\n\t if (secure === true) {\n\t cookie.push('secure');\n\t }\n\t\n\t document.cookie = cookie.join('; ');\n\t },\n\t\n\t read: function read(name) {\n\t var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n\t return (match ? decodeURIComponent(match[3]) : null);\n\t },\n\t\n\t remove: function remove(name) {\n\t this.write(name, '', Date.now() - 86400000);\n\t }\n\t };\n\t })() :\n\t\n\t // Non standard browser env (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return {\n\t write: function write() {},\n\t read: function read() { return null; },\n\t remove: function remove() {}\n\t };\n\t })()\n\t);\n\n\n/***/ },\n/* 19 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Determines whether the specified URL is absolute\n\t *\n\t * @param {string} url The URL to test\n\t * @returns {boolean} True if the specified URL is absolute, otherwise false\n\t */\n\tmodule.exports = function isAbsoluteURL(url) {\n\t // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n\t // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n\t // by any combination of letters, digits, plus, period, or hyphen.\n\t return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n\t};\n\n\n/***/ },\n/* 20 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Creates a new URL by combining the specified URLs\n\t *\n\t * @param {string} baseURL The base URL\n\t * @param {string} relativeURL The relative URL\n\t * @returns {string} The combined URL\n\t */\n\tmodule.exports = function combineURLs(baseURL, relativeURL) {\n\t return baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '');\n\t};\n\n\n/***/ },\n/* 21 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Syntactic sugar for invoking a function and expanding an array for arguments.\n\t *\n\t * Common use case would be to use `Function.prototype.apply`.\n\t *\n\t * ```js\n\t * function f(x, y, z) {}\n\t * var args = [1, 2, 3];\n\t * f.apply(null, args);\n\t * ```\n\t *\n\t * With `spread` this example can be re-written.\n\t *\n\t * ```js\n\t * spread(function(x, y, z) {})([1, 2, 3]);\n\t * ```\n\t *\n\t * @param {Function} callback\n\t * @returns {Function}\n\t */\n\tmodule.exports = function spread(callback) {\n\t return function wrap(arr) {\n\t return callback.apply(null, arr);\n\t };\n\t};\n\n\n/***/ }\n/******/ ])\n});\n;\n//# sourceMappingURL=axios.map","import {Component, utils} from 'js-data'\n\nexport const noop = function (...args) {\n const opts = args[args.length - 1]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const opts = args[args.length - 2]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const unique = function (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\n\nexport const withoutRelations = function (mapper, props, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n const relationFields = mapper.relationFields || []\n const toStrip = relationFields.filter((value) => opts.with.indexOf(value) === -1)\n return utils.omit(props, toStrip)\n}\n\nexport const reserved = [\n 'orderBy',\n 'sort',\n 'limit',\n 'offset',\n 'skip',\n 'where'\n]\n\n/**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\nexport function Response (data, meta, op) {\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n this.data = data\n\n utils.fillIn(this, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n this.op = op\n}\n\nconst DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @extends Component\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\nexport function Adapter (opts) {\n utils.classCallCheck(this, Adapter)\n Component.call(this, opts)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(this, opts)\n}\n\nComponent.extend({\n constructor: Adapter,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {string} field The `field` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._count(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'create'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._create(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'create')\n response.created = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = props.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'createMany'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._createMany(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'createMany')\n response.created = data.length\n response = this.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'destroy'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._destroy(mapper, id, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = this.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'destroyAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._destroyAll(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = this.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo (mapper, def, records, __opts) {\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts)\n .then((relatedItem) => {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records\n .map((record) => this.makeBelongsToForeignKey(mapper, def, record))\n .filter((key) => key)\n return this.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((record) => {\n relatedItems.forEach((relatedItem) => {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem)\n }\n })\n })\n })\n }\n },\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n let record, op\n let meta = {}\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'find'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._find(mapper, id, opts))\n })\n .then((results) => {\n let [_record, _meta] = results\n if (!_record) {\n return\n }\n record = _record\n meta = _meta\n const tasks = []\n\n utils.forEachRelation(mapper, opts, (def, __opts) => {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = this.loadHasOne(mapper, def, record, __opts)\n } else {\n task = this.loadHasMany(mapper, def, record, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = this.loadHasManyLocalKeys(mapper, def, record, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = this.loadHasManyForeignKeys(mapper, def, record, __opts)\n } else if (def.type === 'belongsTo') {\n task = this.loadBelongsTo(mapper, def, record, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n\n return utils.Promise.all(tasks)\n })\n .then(() => {\n let response = new Response(record, meta, 'find')\n response.found = record ? 1 : 0\n response = this.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n let records = []\n let meta = {}\n let op\n const activeWith = opts._activeWith\n\n if (utils.isObject(activeWith)) {\n const activeQuery = activeWith.query || {}\n if (activeWith.replace) {\n query = activeQuery\n } else {\n utils.deepFillIn(query, activeQuery)\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'findAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._findAll(mapper, query, opts))\n })\n .then((results) => {\n let [_records, _meta] = results\n _records || (_records = [])\n records = _records\n meta = _meta\n const tasks = []\n utils.forEachRelation(mapper, opts, (def, __opts) => {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = this.loadHasMany(mapper, def, records, __opts)\n } else {\n task = this.loadHasOne(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = this.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = this.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = this.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks)\n })\n .then(() => {\n let response = new Response(records, meta, 'findAll')\n response.found = records.length\n response = this.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt (opt, opts) {\n opts || (opts = {})\n return opts[opt] === undefined ? utils.plainCopy(this[opt]) : utils.plainCopy(opts[opt])\n },\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany (mapper, def, records, __opts) {\n let singular = false\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n const IDs = records.map((record) => this.makeHasManyForeignKey(mapper, def, record))\n const query = {\n where: {}\n }\n const criteria = query.where[def.foreignKey] = {}\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0]\n } else {\n criteria['in'] = IDs.filter((id) => id)\n }\n return this.findAll(def.getRelation(), query, __opts).then((relatedItems) => {\n records.forEach((record) => {\n let attached = []\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems\n } else {\n relatedItems.forEach((relatedItem) => {\n if (utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem)\n }\n })\n }\n def.setLocalField(record, attached)\n })\n })\n },\n\n loadHasManyLocalKeys (mapper, def, records, __opts) {\n let record\n const relatedMapper = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': this.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach((record) => {\n localKeys = localKeys.concat(this.makeHasManyLocalKeys(mapper, def, record))\n })\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter((x) => x)\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((item) => {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach((relatedItem) => {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem)\n }\n })\n def.setLocalField(item, attached)\n })\n return relatedItems\n })\n }\n },\n\n loadHasManyForeignKeys (mapper, def, records, __opts) {\n const relatedMapper = def.getRelation()\n const idAttribute = mapper.idAttribute\n let record\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': this.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return this.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map((record) => this.makeHasManyForeignKeys(mapper, def, record))\n }\n }\n }, __opts).then((relatedItems) => {\n const foreignKeysField = def.foreignKeys\n records.forEach((record) => {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach((relatedItem) => {\n const foreignKeys = utils.get(relatedItems, foreignKeysField) || []\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem)\n }\n })\n def.setLocalField(record, _relatedItems)\n })\n })\n }\n },\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne (mapper, def, records, __opts) {\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n }\n return this.loadHasMany(mapper, def, records, __opts).then(() => {\n records.forEach((record) => {\n const relatedData = def.getLocalField(record)\n if (utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0])\n }\n })\n })\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n let localKeys = []\n let itemKeys = utils.get(record, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n return unique(localKeys).filter((x) => x)\n },\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys (mapper, def, record) {\n return utils.get(record, mapper.idAttribute)\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n let op\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n query || (query = {})\n opts || (opts = {})\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum'\n return utils.resolve(this[op](mapper, field, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n this.dbg(op, mapper, field, query, opts)\n return utils.resolve(this._sum(mapper, field, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(this[op](mapper, field, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond (response, opts) {\n return this.getOpt('raw', opts) ? response : response.data\n },\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(this[op](mapper, id, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'update'\n this.dbg(op, mapper, id, props, opts)\n return utils.resolve(this._update(mapper, id, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'update')\n response.updated = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(this[op](mapper, id, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let op\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'updateAll'\n this.dbg(op, mapper, props, query, opts)\n return utils.resolve(this._updateAll(mapper, props, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateAll')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter((record) => utils.get(record, idAttribute))\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(this[op](mapper, records, opts))\n .then((_records) => {\n // Allow for re-assignment from lifecycle hook\n records = _records === undefined ? records : _records\n records = records.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'updateMany'\n this.dbg(op, mapper, records, opts)\n return utils.resolve(this._updateMany(mapper, records, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateMany')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(this[op](mapper, records, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n }\n})\n\n/**\n * Create a subclass of this Adapter:\n *\n * @example Adapter.extend\n * // Normally you would do: import {Adapter} from 'js-data'\n * const JSData = require('js-data@3.0.0-beta.10')\n * const {Adapter} = JSData\n * console.log('Using JSData v' + JSData.version.full)\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomAdapterClass extends Adapter {\n * foo () { return 'bar' }\n * static beep () { return 'boop' }\n * }\n * const customAdapter = new CustomAdapterClass()\n * console.log(customAdapter.foo())\n * console.log(CustomAdapterClass.beep())\n *\n * // Extend the class using alternate method.\n * const OtherAdapterClass = Adapter.extend({\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const otherAdapter = new OtherAdapterClass()\n * console.log(otherAdapter.foo())\n * console.log(OtherAdapterClass.beep())\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherAdapterClass () {\n * Adapter.call(this)\n * this.created_at = new Date().getTime()\n * }\n * Adapter.extend({\n * constructor: AnotherAdapterClass,\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const anotherAdapter = new AnotherAdapterClass()\n * console.log(anotherAdapter.created_at)\n * console.log(anotherAdapter.foo())\n * console.log(AnotherAdapterClass.beep())\n *\n * @method Adapter.extend\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this Adapter class.\n */\n","import { utils } from 'js-data'\nimport axios from '../node_modules/axios/dist/axios'\nimport {\n Adapter,\n noop,\n noop2\n} from '../node_modules/js-data-adapter/src/index'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:\\/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst DEFAULTS = {\n /**\n * Set a base path in order to use absolute URLs instead of relative URLs.\n *\n * @example\n * const httpAdapter = new HttpAdapter({\n * basePath: 'https://mydomain.com'\n * });\n *\n * @name HttpAdapter#basePath\n * @type {string}\n * @since 3.0.0\n */\n basePath: '',\n\n /**\n * Ensure that the request url has a trailing forward slash.\n *\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n forceTrailingSlash: false,\n\n /**\n * The HTTP function that actually makes the HTTP request. By default this is\n * `axios`.\n *\n * @name HttpAdapter#http\n * @type {function}\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library\n */\n http: axios,\n\n /**\n * Default configuration options to be mixed into the `config` argument passed\n * to {@link HttpAdapter#http}.\n *\n * @name HttpAdapter#httpConfig\n * @type {object}\n * @since 3.0.0\n */\n httpConfig: {},\n\n /**\n * Add a suffix to the request url, e.g. \".json\".\n *\n * @name HttpAdapter#suffix\n * @type {string}\n * @since 3.0.0\n */\n suffix: '',\n\n /**\n * Use `window.fetch` if available.\n *\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-windowfetch\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @example\n * import { DataStore } from 'js-data';\n * import { HttpAdapter } from 'js-data-http';\n *\n * const httpAdapter = new HttpAdapter();\n * const store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n *\n * store.defineMapper('school');\n * store.defineMapper('student');\n *\n * // GET /school/1\n * store.find('school', 1).then((school) => {\n * console.log('school');\n * });\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}.\n * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}.\n * @param {object} [opts.http=axios] See {@link HttpAdapter#http}.\n * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}.\n * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}.\n * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}.\n * @see http://www.js-data.io/docs/js-data-http\n */\nexport function HttpAdapter (opts) {\n utils.classCallCheck(this, HttpAdapter)\n\n opts || (opts = {})\n // Fill in any missing options with the defaults\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(this, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\nAdapter.extend({\n constructor: HttpAdapter,\n\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n return this.GET(\n this.getPath('count', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _create (mapper, props, opts) {\n return this.POST(\n this.getPath('create', mapper, props, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _createMany (mapper, props, opts) {\n return this.POST(\n this.getPath('createMany', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroy (mapper, id, opts) {\n return this.DEL(\n this.getPath('destroy', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroyAll (mapper, query, opts) {\n return this.DEL(\n this.getPath('destroyAll', mapper, null, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n return this.GET(\n this.getPath('find', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _findAll (mapper, query, opts) {\n return this.GET(\n this.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _sum (mapper, field, query, opts) {\n return this.GET(\n this.getPath('sum', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _update (mapper, id, props, opts) {\n return this.PUT(\n this.getPath('update', mapper, id, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateAll (mapper, props, query, opts) {\n return this.PUT(\n this.getPath('updateAll', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateMany (mapper, records, opts) {\n return this.PUT(\n this.getPath('updateMany', mapper, null, opts),\n this.serialize(mapper, records, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params.count = true\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.count.call(this, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {object} mapper The mapper.\n * @param {object} props Properties to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.create.call(this, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {object} mapper The mapper.\n * @param {array} props Array of property objects to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.createMany.call(this, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'DEL'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {object} mapper The mapper used for the operation.\n * @param {object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {object} opts Configuration options.\n * @return {(object|array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroy.call(this, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroyAll.call(this, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {object} config Request configuration.\n * @param {object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {object} config.headers Headers for the request.\n * @param {object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n */\n fetch (config) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers || {})\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(buildUrl(config.url, config.params), requestConfig)\n .then((response) => {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json()\n .then((data) => {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.find.call(this, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.findAll.call(this, mapper, query, opts)\n },\n\n /**\n * Make a GET request.\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'GET'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {object} mapper The Mapper.\n * @param {*} id The primary key, if any.\n * @param {boolean} opts Configuration options.\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach((def) => {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, (value, key) => {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method The method being executed.\n * @param {object} mapper The Mapper.\n * @param {(string|number)?} id The primary key, if any.\n * @param {object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n opts || (opts = {})\n const args = [\n opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath,\n this.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (opts.params === undefined) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (opts.suffix === undefined) {\n if (mapper.suffix === undefined) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, this.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || this.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n const logResponse = (data) => {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (this.log) {\n this.dbg(str, data)\n }\n return data\n } else {\n if (this.error) {\n this.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!this.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(this.beforeHTTP(config, opts))\n .then((_config) => {\n config = _config || config\n if (hasFetch && (this.useFetch || opts.useFetch || !this.http)) {\n return this.fetch(config, opts).then(logResponse, logResponse)\n }\n return this.http(config).then(logResponse, logResponse)\n .catch((err) => this.responseError(err, config, opts))\n })\n .then((response) => {\n return utils.resolve(this.afterHTTP(config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a POST request.\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'POST'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a PUT request.\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'PUT'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the querystring object before it is serialized. This doesn't do\n * anything by default.\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {*} params The querystring object.\n * @param {*} opts Configuration options\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * Serialize request data. This doesn't do anything by default.\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {object} data The request payload.\n * @param {*} opts Configuration options.\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n query || (query = {})\n opts || (opts = {})\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = this.getParams(opts)\n opts.params.sum = field\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.sum.call(this, mapper, field, query, opts)\n },\n\n /**\n * Perform an update. Makes a PUT request by default.\n *\n * @name HttpAdapter#update\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {*} id The primary key of the record being updated.\n * @param {*} props The update payload.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.update.call(this, mapper, id, props, opts)\n },\n\n /**\n * Perform an update against records that match the selection query. Makes a\n * PUT request by default.\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {object} props The update payload.\n * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateAll.call(this, mapper, props, query, opts)\n },\n\n /**\n * Update multiple individual records in a batch.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {array} records Array of property objects to send as the payload.\n * Each must contain the primary key of the record to be updated.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateMany.call(this, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addAction = JSDataHttp.addAction;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * endpoint: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {object} [opts] Action configuration\n * @param {string} [opts.adapter=\"http\"] The name of the adapter to use.\n * @param {string} [opts.pathname] Set the action's pathname.\n * @param {function} [opts.request] Specify a request handler to be executed\n * before the request is made.\n * @param {function} [opts.response] Specify a response handler to be executed\n * after the response is received.\n * @param {function} [opts.responseError] Specify an error handler to be\n * executed on error.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addAction (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n _opts = _opts || {}\n if (utils.isObject(id)) {\n _opts = id\n }\n utils.fillIn(_opts, opts)\n let adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http')\n const config = {}\n config.mapper = this.name\n utils.deepMixIn(config, _opts)\n config.method = config.method || 'GET'\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(this, _opts)\n } else {\n let args = [\n _opts.basePath || this.basePath || adapter.basePath,\n adapter.getEndpoint(this, id, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n return utils.resolve(config)\n .then(_opts.request)\n .then((config) => adapter.HTTP(config))\n .then((data) => {\n if (data && data.config) {\n data.config.mapper = this.name\n }\n return data\n })\n .then(_opts.response, _opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addActions = JSDataHttp.addActions;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * addActions({\n * // GET /reports/schools/:school_id/teachers\n * getTeacherReports: {\n * basePath: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * }\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addActions\n * @method\n * @param {object.} opts Object where the key is an action name\n * and the value is the configuration for the action.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name module:js-data-http.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http`\n * that works on Node.js is registered in NPM as `js-data-http-node`. The build\n * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower\n * as `js-data-fetch`.\n *\n * @example Script tag\n * var HttpAdapter = window.JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example ES2015 Modules\n * import { HttpAdapter } from 'js-data-Http';\n * const httpAdapter = new HttpAdapter();\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * // ...\n * });\n *\n * @module js-data-http\n */\n\n/**\n * Create a subclass of this HttpAdapter:\n * @example HttpAdapter.extend\n * // Normally you would do: import { HttpAdapter } from 'js-data-http';\n * // or: import { HttpAdapter } from 'js-data-http-node';\n * const JSDataHttp = require('js-data-http-node');\n * const { HttpAdapter } = JSDataHttp;\n * console.log('Using JSDataHttp v' + JSDataHttp.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomHttpAdapterClass extends HttpAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customHttpAdapter = new CustomHttpAdapterClass();\n * console.log(customHttpAdapter.foo());\n * console.log(CustomHttpAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherHttpAdapterClass = HttpAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const otherHttpAdapter = new OtherHttpAdapterClass();\n * console.log(otherHttpAdapter.foo());\n * console.log(OtherHttpAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherHttpAdapterClass () {\n * HttpAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * HttpAdapter.extend({\n * constructor: AnotherHttpAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const anotherHttpAdapter = new AnotherHttpAdapterClass();\n * console.log(anotherHttpAdapter.created_at);\n * console.log(anotherHttpAdapter.foo());\n * console.log(AnotherHttpAdapterClass.beep());\n *\n * @method HttpAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this HttpAdapter class.\n * @since 3.0.0\n */\n"],"names":["this","utils","DEFAULTS","Component","axios"],"mappings":";;;;;;;;;;;;;;;;;AAAA,CAAA;AACA,CAAA,CAAC,SAAS,gCAAgC,CAAC,IAAI,EAAE,OAAO,EAAE;EACzD,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ;GAC3D,MAAM,CAAC,OAAO,GAAG,OAAO,EAAE,CAAC;OACvB,GAAG,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,CAAC,GAAG;GACjD,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;OAChB,GAAG,OAAO,OAAO,KAAK,QAAQ;GAClC,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;;GAE7B,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;EAC3B,EAAEA,cAAI,EAAE,WAAW;AACpB,CAAA,gBAAgB,CAAC,SAAS,OAAO,EAAE;;WAEzB,IAAI,gBAAgB,GAAG,EAAE,CAAC;;;WAG1B,SAAS,mBAAmB,CAAC,QAAQ,EAAE;;;YAGtC,GAAG,gBAAgB,CAAC,QAAQ,CAAC;aAC5B,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;;;YAG3C,IAAI,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG;aACzC,OAAO,EAAE,EAAE;aACX,EAAE,EAAE,QAAQ;aACZ,MAAM,EAAE,KAAK;aACb,CAAC;;;YAGF,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MA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AAU,GAAV,EAAe,KAAf,EAAsB,MAAtB;AACD,CAAA,KAFD;AAGA,CAAA,WAAO,MAAP;AACD,CAAA,GALD;AAMD,CAAA;;AAED,CAAA;;;;;;;;;;;;;;AAcA,AAAO,CAAA,IAAM,UAAU,gBAAhB,CAEP;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"js-data-http.js","sources":["../node_modules/axios/dist/axios.js","../node_modules/js-data-adapter/src/index.js","../src/index.js"],"sourcesContent":["/* axios v0.16.2 | (c) 2017 by Matt Zabriskie */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axios\"] = factory();\n\telse\n\t\troot[\"axios\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(1);\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar bind = __webpack_require__(3);\n\tvar Axios = __webpack_require__(5);\n\tvar defaults = __webpack_require__(6);\n\t\n\t/**\n\t * Create an instance of Axios\n\t *\n\t * @param {Object} defaultConfig The default config for the instance\n\t * @return {Axios} A new instance of Axios\n\t */\n\tfunction createInstance(defaultConfig) {\n\t var context = new Axios(defaultConfig);\n\t var instance = bind(Axios.prototype.request, context);\n\t\n\t // Copy axios.prototype to instance\n\t utils.extend(instance, Axios.prototype, context);\n\t\n\t // Copy context to instance\n\t utils.extend(instance, context);\n\t\n\t return instance;\n\t}\n\t\n\t// Create the default instance to be exported\n\tvar axios = createInstance(defaults);\n\t\n\t// Expose Axios class to allow class inheritance\n\taxios.Axios = Axios;\n\t\n\t// Factory for creating new instances\n\taxios.create = function create(instanceConfig) {\n\t return createInstance(utils.merge(defaults, instanceConfig));\n\t};\n\t\n\t// Expose Cancel & CancelToken\n\taxios.Cancel = __webpack_require__(23);\n\taxios.CancelToken = __webpack_require__(24);\n\taxios.isCancel = __webpack_require__(20);\n\t\n\t// Expose all/spread\n\taxios.all = function all(promises) {\n\t return Promise.all(promises);\n\t};\n\taxios.spread = __webpack_require__(25);\n\t\n\tmodule.exports = axios;\n\t\n\t// Allow use of default import syntax in TypeScript\n\tmodule.exports.default = axios;\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar bind = __webpack_require__(3);\n\tvar isBuffer = __webpack_require__(4);\n\t\n\t/*global toString:true*/\n\t\n\t// utils is a library of generic helper functions non-specific to axios\n\t\n\tvar toString = Object.prototype.toString;\n\t\n\t/**\n\t * Determine if a value is an Array\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Array, otherwise false\n\t */\n\tfunction isArray(val) {\n\t return toString.call(val) === '[object Array]';\n\t}\n\t\n\t/**\n\t * Determine if a value is an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBuffer(val) {\n\t return toString.call(val) === '[object ArrayBuffer]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a FormData\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an FormData, otherwise false\n\t */\n\tfunction isFormData(val) {\n\t return (typeof FormData !== 'undefined') && (val instanceof FormData);\n\t}\n\t\n\t/**\n\t * Determine if a value is a view on an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBufferView(val) {\n\t var result;\n\t if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n\t result = ArrayBuffer.isView(val);\n\t } else {\n\t result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Determine if a value is a String\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a String, otherwise false\n\t */\n\tfunction isString(val) {\n\t return typeof val === 'string';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Number\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Number, otherwise false\n\t */\n\tfunction isNumber(val) {\n\t return typeof val === 'number';\n\t}\n\t\n\t/**\n\t * Determine if a value is undefined\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if the value is undefined, otherwise false\n\t */\n\tfunction isUndefined(val) {\n\t return typeof val === 'undefined';\n\t}\n\t\n\t/**\n\t * Determine if a value is an Object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Object, otherwise false\n\t */\n\tfunction isObject(val) {\n\t return val !== null && typeof val === 'object';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Date\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Date, otherwise false\n\t */\n\tfunction isDate(val) {\n\t return toString.call(val) === '[object Date]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a File\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a File, otherwise false\n\t */\n\tfunction isFile(val) {\n\t return toString.call(val) === '[object File]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Blob\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Blob, otherwise false\n\t */\n\tfunction isBlob(val) {\n\t return toString.call(val) === '[object Blob]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Function\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Function, otherwise false\n\t */\n\tfunction isFunction(val) {\n\t return toString.call(val) === '[object Function]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Stream\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Stream, otherwise false\n\t */\n\tfunction isStream(val) {\n\t return isObject(val) && isFunction(val.pipe);\n\t}\n\t\n\t/**\n\t * Determine if a value is a URLSearchParams object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n\t */\n\tfunction isURLSearchParams(val) {\n\t return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n\t}\n\t\n\t/**\n\t * Trim excess whitespace off the beginning and end of a string\n\t *\n\t * @param {String} str The String to trim\n\t * @returns {String} The String freed of excess whitespace\n\t */\n\tfunction trim(str) {\n\t return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n\t}\n\t\n\t/**\n\t * Determine if we're running in a standard browser environment\n\t *\n\t * This allows axios to run in a web worker, and react-native.\n\t * Both environments support XMLHttpRequest, but not fully standard globals.\n\t *\n\t * web workers:\n\t * typeof window -> undefined\n\t * typeof document -> undefined\n\t *\n\t * react-native:\n\t * navigator.product -> 'ReactNative'\n\t */\n\tfunction isStandardBrowserEnv() {\n\t if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n\t return false;\n\t }\n\t return (\n\t typeof window !== 'undefined' &&\n\t typeof document !== 'undefined'\n\t );\n\t}\n\t\n\t/**\n\t * Iterate over an Array or an Object invoking a function for each item.\n\t *\n\t * If `obj` is an Array callback will be called passing\n\t * the value, index, and complete array for each item.\n\t *\n\t * If 'obj' is an Object callback will be called passing\n\t * the value, key, and complete object for each property.\n\t *\n\t * @param {Object|Array} obj The object to iterate\n\t * @param {Function} fn The callback to invoke for each item\n\t */\n\tfunction forEach(obj, fn) {\n\t // Don't bother if no value provided\n\t if (obj === null || typeof obj === 'undefined') {\n\t return;\n\t }\n\t\n\t // Force an array if not already something iterable\n\t if (typeof obj !== 'object' && !isArray(obj)) {\n\t /*eslint no-param-reassign:0*/\n\t obj = [obj];\n\t }\n\t\n\t if (isArray(obj)) {\n\t // Iterate over array values\n\t for (var i = 0, l = obj.length; i < l; i++) {\n\t fn.call(null, obj[i], i, obj);\n\t }\n\t } else {\n\t // Iterate over object keys\n\t for (var key in obj) {\n\t if (Object.prototype.hasOwnProperty.call(obj, key)) {\n\t fn.call(null, obj[key], key, obj);\n\t }\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * Accepts varargs expecting each argument to be an object, then\n\t * immutably merges the properties of each object and returns result.\n\t *\n\t * When multiple objects contain the same key the later object in\n\t * the arguments list will take precedence.\n\t *\n\t * Example:\n\t *\n\t * ```js\n\t * var result = merge({foo: 123}, {foo: 456});\n\t * console.log(result.foo); // outputs 456\n\t * ```\n\t *\n\t * @param {Object} obj1 Object to merge\n\t * @returns {Object} Result of all merge properties\n\t */\n\tfunction merge(/* obj1, obj2, obj3, ... */) {\n\t var result = {};\n\t function assignValue(val, key) {\n\t if (typeof result[key] === 'object' && typeof val === 'object') {\n\t result[key] = merge(result[key], val);\n\t } else {\n\t result[key] = val;\n\t }\n\t }\n\t\n\t for (var i = 0, l = arguments.length; i < l; i++) {\n\t forEach(arguments[i], assignValue);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Extends object a by mutably adding to it the properties of object b.\n\t *\n\t * @param {Object} a The object to be extended\n\t * @param {Object} b The object to copy properties from\n\t * @param {Object} thisArg The object to bind function to\n\t * @return {Object} The resulting value of object a\n\t */\n\tfunction extend(a, b, thisArg) {\n\t forEach(b, function assignValue(val, key) {\n\t if (thisArg && typeof val === 'function') {\n\t a[key] = bind(val, thisArg);\n\t } else {\n\t a[key] = val;\n\t }\n\t });\n\t return a;\n\t}\n\t\n\tmodule.exports = {\n\t isArray: isArray,\n\t isArrayBuffer: isArrayBuffer,\n\t isBuffer: isBuffer,\n\t isFormData: isFormData,\n\t isArrayBufferView: isArrayBufferView,\n\t isString: isString,\n\t isNumber: isNumber,\n\t isObject: isObject,\n\t isUndefined: isUndefined,\n\t isDate: isDate,\n\t isFile: isFile,\n\t isBlob: isBlob,\n\t isFunction: isFunction,\n\t isStream: isStream,\n\t isURLSearchParams: isURLSearchParams,\n\t isStandardBrowserEnv: isStandardBrowserEnv,\n\t forEach: forEach,\n\t merge: merge,\n\t extend: extend,\n\t trim: trim\n\t};\n\n\n/***/ },\n/* 3 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = function bind(fn, thisArg) {\n\t return function wrap() {\n\t var args = new Array(arguments.length);\n\t for (var i = 0; i < args.length; i++) {\n\t args[i] = arguments[i];\n\t }\n\t return fn.apply(thisArg, args);\n\t };\n\t};\n\n\n/***/ },\n/* 4 */\n/***/ function(module, exports) {\n\n\t/*!\n\t * Determine if an object is a Buffer\n\t *\n\t * @author Feross Aboukhadijeh \n\t * @license MIT\n\t */\n\t\n\t// The _isBuffer check is for Safari 5-7 support, because it's missing\n\t// Object.prototype.constructor. Remove this eventually\n\tmodule.exports = function (obj) {\n\t return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)\n\t}\n\t\n\tfunction isBuffer (obj) {\n\t return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)\n\t}\n\t\n\t// For Node v0.10 support. Remove this eventually.\n\tfunction isSlowBuffer (obj) {\n\t return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))\n\t}\n\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar defaults = __webpack_require__(6);\n\tvar utils = __webpack_require__(2);\n\tvar InterceptorManager = __webpack_require__(17);\n\tvar dispatchRequest = __webpack_require__(18);\n\tvar isAbsoluteURL = __webpack_require__(21);\n\tvar combineURLs = __webpack_require__(22);\n\t\n\t/**\n\t * Create a new instance of Axios\n\t *\n\t * @param {Object} instanceConfig The default config for the instance\n\t */\n\tfunction Axios(instanceConfig) {\n\t this.defaults = instanceConfig;\n\t this.interceptors = {\n\t request: new InterceptorManager(),\n\t response: new InterceptorManager()\n\t };\n\t}\n\t\n\t/**\n\t * Dispatch a request\n\t *\n\t * @param {Object} config The config specific for this request (merged with this.defaults)\n\t */\n\tAxios.prototype.request = function request(config) {\n\t /*eslint no-param-reassign:0*/\n\t // Allow for axios('example/url'[, config]) a la fetch API\n\t if (typeof config === 'string') {\n\t config = utils.merge({\n\t url: arguments[0]\n\t }, arguments[1]);\n\t }\n\t\n\t config = utils.merge(defaults, this.defaults, { method: 'get' }, config);\n\t config.method = config.method.toLowerCase();\n\t\n\t // Support baseURL config\n\t if (config.baseURL && !isAbsoluteURL(config.url)) {\n\t config.url = combineURLs(config.baseURL, config.url);\n\t }\n\t\n\t // Hook up interceptors middleware\n\t var chain = [dispatchRequest, undefined];\n\t var promise = Promise.resolve(config);\n\t\n\t this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n\t chain.unshift(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n\t chain.push(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t while (chain.length) {\n\t promise = promise.then(chain.shift(), chain.shift());\n\t }\n\t\n\t return promise;\n\t};\n\t\n\t// Provide aliases for supported request methods\n\tutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, config) {\n\t return this.request(utils.merge(config || {}, {\n\t method: method,\n\t url: url\n\t }));\n\t };\n\t});\n\t\n\tutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, data, config) {\n\t return this.request(utils.merge(config || {}, {\n\t method: method,\n\t url: url,\n\t data: data\n\t }));\n\t };\n\t});\n\t\n\tmodule.exports = Axios;\n\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar normalizeHeaderName = __webpack_require__(7);\n\t\n\tvar DEFAULT_CONTENT_TYPE = {\n\t 'Content-Type': 'application/x-www-form-urlencoded'\n\t};\n\t\n\tfunction setContentTypeIfUnset(headers, value) {\n\t if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n\t headers['Content-Type'] = value;\n\t }\n\t}\n\t\n\tfunction getDefaultAdapter() {\n\t var adapter;\n\t if (typeof XMLHttpRequest !== 'undefined') {\n\t // For browsers use XHR adapter\n\t adapter = __webpack_require__(8);\n\t } else if (typeof process !== 'undefined') {\n\t // For node use HTTP adapter\n\t adapter = __webpack_require__(8);\n\t }\n\t return adapter;\n\t}\n\t\n\tvar defaults = {\n\t adapter: getDefaultAdapter(),\n\t\n\t transformRequest: [function transformRequest(data, headers) {\n\t normalizeHeaderName(headers, 'Content-Type');\n\t if (utils.isFormData(data) ||\n\t utils.isArrayBuffer(data) ||\n\t utils.isBuffer(data) ||\n\t utils.isStream(data) ||\n\t utils.isFile(data) ||\n\t utils.isBlob(data)\n\t ) {\n\t return data;\n\t }\n\t if (utils.isArrayBufferView(data)) {\n\t return data.buffer;\n\t }\n\t if (utils.isURLSearchParams(data)) {\n\t setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n\t return data.toString();\n\t }\n\t if (utils.isObject(data)) {\n\t setContentTypeIfUnset(headers, 'application/json;charset=utf-8');\n\t return JSON.stringify(data);\n\t }\n\t return data;\n\t }],\n\t\n\t transformResponse: [function transformResponse(data) {\n\t /*eslint no-param-reassign:0*/\n\t if (typeof data === 'string') {\n\t try {\n\t data = JSON.parse(data);\n\t } catch (e) { /* Ignore */ }\n\t }\n\t return data;\n\t }],\n\t\n\t timeout: 0,\n\t\n\t xsrfCookieName: 'XSRF-TOKEN',\n\t xsrfHeaderName: 'X-XSRF-TOKEN',\n\t\n\t maxContentLength: -1,\n\t\n\t validateStatus: function validateStatus(status) {\n\t return status >= 200 && status < 300;\n\t }\n\t};\n\t\n\tdefaults.headers = {\n\t common: {\n\t 'Accept': 'application/json, text/plain, */*'\n\t }\n\t};\n\t\n\tutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n\t defaults.headers[method] = {};\n\t});\n\t\n\tutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n\t defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n\t});\n\t\n\tmodule.exports = defaults;\n\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n\t utils.forEach(headers, function processHeader(value, name) {\n\t if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n\t headers[normalizedName] = value;\n\t delete headers[name];\n\t }\n\t });\n\t};\n\n\n/***/ },\n/* 8 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar settle = __webpack_require__(9);\n\tvar buildURL = __webpack_require__(12);\n\tvar parseHeaders = __webpack_require__(13);\n\tvar isURLSameOrigin = __webpack_require__(14);\n\tvar createError = __webpack_require__(10);\n\tvar btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15);\n\t\n\tmodule.exports = function xhrAdapter(config) {\n\t return new Promise(function dispatchXhrRequest(resolve, reject) {\n\t var requestData = config.data;\n\t var requestHeaders = config.headers;\n\t\n\t if (utils.isFormData(requestData)) {\n\t delete requestHeaders['Content-Type']; // Let the browser set it\n\t }\n\t\n\t var request = new XMLHttpRequest();\n\t var loadEvent = 'onreadystatechange';\n\t var xDomain = false;\n\t\n\t // For IE 8/9 CORS support\n\t // Only supports POST and GET calls and doesn't returns the response headers.\n\t // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.\n\t if ((\"production\") !== 'test' &&\n\t typeof window !== 'undefined' &&\n\t window.XDomainRequest && !('withCredentials' in request) &&\n\t !isURLSameOrigin(config.url)) {\n\t request = new window.XDomainRequest();\n\t loadEvent = 'onload';\n\t xDomain = true;\n\t request.onprogress = function handleProgress() {};\n\t request.ontimeout = function handleTimeout() {};\n\t }\n\t\n\t // HTTP basic authentication\n\t if (config.auth) {\n\t var username = config.auth.username || '';\n\t var password = config.auth.password || '';\n\t requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n\t }\n\t\n\t request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);\n\t\n\t // Set the request timeout in MS\n\t request.timeout = config.timeout;\n\t\n\t // Listen for ready state\n\t request[loadEvent] = function handleLoad() {\n\t if (!request || (request.readyState !== 4 && !xDomain)) {\n\t return;\n\t }\n\t\n\t // The request errored out and we didn't get a response, this will be\n\t // handled by onerror instead\n\t // With one exception: request that using file: protocol, most browsers\n\t // will return status as 0 even though it's a successful request\n\t if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n\t return;\n\t }\n\t\n\t // Prepare the response\n\t var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n\t var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n\t var response = {\n\t data: responseData,\n\t // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)\n\t status: request.status === 1223 ? 204 : request.status,\n\t statusText: request.status === 1223 ? 'No Content' : request.statusText,\n\t headers: responseHeaders,\n\t config: config,\n\t request: request\n\t };\n\t\n\t settle(resolve, reject, response);\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle low level network errors\n\t request.onerror = function handleError() {\n\t // Real errors are hidden from us by the browser\n\t // onerror should only fire if it's a network error\n\t reject(createError('Network Error', config, null, request));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle timeout\n\t request.ontimeout = function handleTimeout() {\n\t reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',\n\t request));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Add xsrf header\n\t // This is only done if running in a standard browser environment.\n\t // Specifically not if we're in a web worker, or react-native.\n\t if (utils.isStandardBrowserEnv()) {\n\t var cookies = __webpack_require__(16);\n\t\n\t // Add xsrf header\n\t var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?\n\t cookies.read(config.xsrfCookieName) :\n\t undefined;\n\t\n\t if (xsrfValue) {\n\t requestHeaders[config.xsrfHeaderName] = xsrfValue;\n\t }\n\t }\n\t\n\t // Add headers to the request\n\t if ('setRequestHeader' in request) {\n\t utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n\t if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n\t // Remove Content-Type if data is undefined\n\t delete requestHeaders[key];\n\t } else {\n\t // Otherwise add header to the request\n\t request.setRequestHeader(key, val);\n\t }\n\t });\n\t }\n\t\n\t // Add withCredentials to request if needed\n\t if (config.withCredentials) {\n\t request.withCredentials = true;\n\t }\n\t\n\t // Add responseType to request if needed\n\t if (config.responseType) {\n\t try {\n\t request.responseType = config.responseType;\n\t } catch (e) {\n\t // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n\t // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n\t if (config.responseType !== 'json') {\n\t throw e;\n\t }\n\t }\n\t }\n\t\n\t // Handle progress if needed\n\t if (typeof config.onDownloadProgress === 'function') {\n\t request.addEventListener('progress', config.onDownloadProgress);\n\t }\n\t\n\t // Not all browsers support upload events\n\t if (typeof config.onUploadProgress === 'function' && request.upload) {\n\t request.upload.addEventListener('progress', config.onUploadProgress);\n\t }\n\t\n\t if (config.cancelToken) {\n\t // Handle cancellation\n\t config.cancelToken.promise.then(function onCanceled(cancel) {\n\t if (!request) {\n\t return;\n\t }\n\t\n\t request.abort();\n\t reject(cancel);\n\t // Clean up request\n\t request = null;\n\t });\n\t }\n\t\n\t if (requestData === undefined) {\n\t requestData = null;\n\t }\n\t\n\t // Send the request\n\t request.send(requestData);\n\t });\n\t};\n\n\n/***/ },\n/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar createError = __webpack_require__(10);\n\t\n\t/**\n\t * Resolve or reject a Promise based on response status.\n\t *\n\t * @param {Function} resolve A function that resolves the promise.\n\t * @param {Function} reject A function that rejects the promise.\n\t * @param {object} response The response.\n\t */\n\tmodule.exports = function settle(resolve, reject, response) {\n\t var validateStatus = response.config.validateStatus;\n\t // Note: status is not exposed by XDomainRequest\n\t if (!response.status || !validateStatus || validateStatus(response.status)) {\n\t resolve(response);\n\t } else {\n\t reject(createError(\n\t 'Request failed with status code ' + response.status,\n\t response.config,\n\t null,\n\t response.request,\n\t response\n\t ));\n\t }\n\t};\n\n\n/***/ },\n/* 10 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar enhanceError = __webpack_require__(11);\n\t\n\t/**\n\t * Create an Error with the specified message, config, error code, request and response.\n\t *\n\t * @param {string} message The error message.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t * @param {Object} [request] The request.\n\t * @param {Object} [response] The response.\n\t * @returns {Error} The created error.\n\t */\n\tmodule.exports = function createError(message, config, code, request, response) {\n\t var error = new Error(message);\n\t return enhanceError(error, config, code, request, response);\n\t};\n\n\n/***/ },\n/* 11 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Update an Error with the specified config, error code, and response.\n\t *\n\t * @param {Error} error The error to update.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t * @param {Object} [request] The request.\n\t * @param {Object} [response] The response.\n\t * @returns {Error} The error.\n\t */\n\tmodule.exports = function enhanceError(error, config, code, request, response) {\n\t error.config = config;\n\t if (code) {\n\t error.code = code;\n\t }\n\t error.request = request;\n\t error.response = response;\n\t return error;\n\t};\n\n\n/***/ },\n/* 12 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction encode(val) {\n\t return encodeURIComponent(val).\n\t replace(/%40/gi, '@').\n\t replace(/%3A/gi, ':').\n\t replace(/%24/g, '$').\n\t replace(/%2C/gi, ',').\n\t replace(/%20/g, '+').\n\t replace(/%5B/gi, '[').\n\t replace(/%5D/gi, ']');\n\t}\n\t\n\t/**\n\t * Build a URL by appending params to the end\n\t *\n\t * @param {string} url The base of the url (e.g., http://www.google.com)\n\t * @param {object} [params] The params to be appended\n\t * @returns {string} The formatted url\n\t */\n\tmodule.exports = function buildURL(url, params, paramsSerializer) {\n\t /*eslint no-param-reassign:0*/\n\t if (!params) {\n\t return url;\n\t }\n\t\n\t var serializedParams;\n\t if (paramsSerializer) {\n\t serializedParams = paramsSerializer(params);\n\t } else if (utils.isURLSearchParams(params)) {\n\t serializedParams = params.toString();\n\t } else {\n\t var parts = [];\n\t\n\t utils.forEach(params, function serialize(val, key) {\n\t if (val === null || typeof val === 'undefined') {\n\t return;\n\t }\n\t\n\t if (utils.isArray(val)) {\n\t key = key + '[]';\n\t }\n\t\n\t if (!utils.isArray(val)) {\n\t val = [val];\n\t }\n\t\n\t utils.forEach(val, function parseValue(v) {\n\t if (utils.isDate(v)) {\n\t v = v.toISOString();\n\t } else if (utils.isObject(v)) {\n\t v = JSON.stringify(v);\n\t }\n\t parts.push(encode(key) + '=' + encode(v));\n\t });\n\t });\n\t\n\t serializedParams = parts.join('&');\n\t }\n\t\n\t if (serializedParams) {\n\t url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n\t }\n\t\n\t return url;\n\t};\n\n\n/***/ },\n/* 13 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t/**\n\t * Parse headers into an object\n\t *\n\t * ```\n\t * Date: Wed, 27 Aug 2014 08:58:49 GMT\n\t * Content-Type: application/json\n\t * Connection: keep-alive\n\t * Transfer-Encoding: chunked\n\t * ```\n\t *\n\t * @param {String} headers Headers needing to be parsed\n\t * @returns {Object} Headers parsed into an object\n\t */\n\tmodule.exports = function parseHeaders(headers) {\n\t var parsed = {};\n\t var key;\n\t var val;\n\t var i;\n\t\n\t if (!headers) { return parsed; }\n\t\n\t utils.forEach(headers.split('\\n'), function parser(line) {\n\t i = line.indexOf(':');\n\t key = utils.trim(line.substr(0, i)).toLowerCase();\n\t val = utils.trim(line.substr(i + 1));\n\t\n\t if (key) {\n\t parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n\t }\n\t });\n\t\n\t return parsed;\n\t};\n\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs have full support of the APIs needed to test\n\t // whether the request URL is of the same origin as current location.\n\t (function standardBrowserEnv() {\n\t var msie = /(msie|trident)/i.test(navigator.userAgent);\n\t var urlParsingNode = document.createElement('a');\n\t var originURL;\n\t\n\t /**\n\t * Parse a URL to discover it's components\n\t *\n\t * @param {String} url The URL to be parsed\n\t * @returns {Object}\n\t */\n\t function resolveURL(url) {\n\t var href = url;\n\t\n\t if (msie) {\n\t // IE needs attribute set twice to normalize properties\n\t urlParsingNode.setAttribute('href', href);\n\t href = urlParsingNode.href;\n\t }\n\t\n\t urlParsingNode.setAttribute('href', href);\n\t\n\t // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n\t return {\n\t href: urlParsingNode.href,\n\t protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n\t host: urlParsingNode.host,\n\t search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n\t hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n\t hostname: urlParsingNode.hostname,\n\t port: urlParsingNode.port,\n\t pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n\t urlParsingNode.pathname :\n\t '/' + urlParsingNode.pathname\n\t };\n\t }\n\t\n\t originURL = resolveURL(window.location.href);\n\t\n\t /**\n\t * Determine if a URL shares the same origin as the current location\n\t *\n\t * @param {String} requestURL The URL to test\n\t * @returns {boolean} True if URL shares the same origin, otherwise false\n\t */\n\t return function isURLSameOrigin(requestURL) {\n\t var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n\t return (parsed.protocol === originURL.protocol &&\n\t parsed.host === originURL.host);\n\t };\n\t })() :\n\t\n\t // Non standard browser envs (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return function isURLSameOrigin() {\n\t return true;\n\t };\n\t })()\n\t);\n\n\n/***/ },\n/* 15 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js\n\t\n\tvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\t\n\tfunction E() {\n\t this.message = 'String contains an invalid character';\n\t}\n\tE.prototype = new Error;\n\tE.prototype.code = 5;\n\tE.prototype.name = 'InvalidCharacterError';\n\t\n\tfunction btoa(input) {\n\t var str = String(input);\n\t var output = '';\n\t for (\n\t // initialize result and counter\n\t var block, charCode, idx = 0, map = chars;\n\t // if the next str index does not exist:\n\t // change the mapping table to \"=\"\n\t // check if d has no fractional digits\n\t str.charAt(idx | 0) || (map = '=', idx % 1);\n\t // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n\t output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n\t ) {\n\t charCode = str.charCodeAt(idx += 3 / 4);\n\t if (charCode > 0xFF) {\n\t throw new E();\n\t }\n\t block = block << 8 | charCode;\n\t }\n\t return output;\n\t}\n\t\n\tmodule.exports = btoa;\n\n\n/***/ },\n/* 16 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs support document.cookie\n\t (function standardBrowserEnv() {\n\t return {\n\t write: function write(name, value, expires, path, domain, secure) {\n\t var cookie = [];\n\t cookie.push(name + '=' + encodeURIComponent(value));\n\t\n\t if (utils.isNumber(expires)) {\n\t cookie.push('expires=' + new Date(expires).toGMTString());\n\t }\n\t\n\t if (utils.isString(path)) {\n\t cookie.push('path=' + path);\n\t }\n\t\n\t if (utils.isString(domain)) {\n\t cookie.push('domain=' + domain);\n\t }\n\t\n\t if (secure === true) {\n\t cookie.push('secure');\n\t }\n\t\n\t document.cookie = cookie.join('; ');\n\t },\n\t\n\t read: function read(name) {\n\t var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n\t return (match ? decodeURIComponent(match[3]) : null);\n\t },\n\t\n\t remove: function remove(name) {\n\t this.write(name, '', Date.now() - 86400000);\n\t }\n\t };\n\t })() :\n\t\n\t // Non standard browser env (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return {\n\t write: function write() {},\n\t read: function read() { return null; },\n\t remove: function remove() {}\n\t };\n\t })()\n\t);\n\n\n/***/ },\n/* 17 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction InterceptorManager() {\n\t this.handlers = [];\n\t}\n\t\n\t/**\n\t * Add a new interceptor to the stack\n\t *\n\t * @param {Function} fulfilled The function to handle `then` for a `Promise`\n\t * @param {Function} rejected The function to handle `reject` for a `Promise`\n\t *\n\t * @return {Number} An ID used to remove interceptor later\n\t */\n\tInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n\t this.handlers.push({\n\t fulfilled: fulfilled,\n\t rejected: rejected\n\t });\n\t return this.handlers.length - 1;\n\t};\n\t\n\t/**\n\t * Remove an interceptor from the stack\n\t *\n\t * @param {Number} id The ID that was returned by `use`\n\t */\n\tInterceptorManager.prototype.eject = function eject(id) {\n\t if (this.handlers[id]) {\n\t this.handlers[id] = null;\n\t }\n\t};\n\t\n\t/**\n\t * Iterate over all the registered interceptors\n\t *\n\t * This method is particularly useful for skipping over any\n\t * interceptors that may have become `null` calling `eject`.\n\t *\n\t * @param {Function} fn The function to call for each interceptor\n\t */\n\tInterceptorManager.prototype.forEach = function forEach(fn) {\n\t utils.forEach(this.handlers, function forEachHandler(h) {\n\t if (h !== null) {\n\t fn(h);\n\t }\n\t });\n\t};\n\t\n\tmodule.exports = InterceptorManager;\n\n\n/***/ },\n/* 18 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar transformData = __webpack_require__(19);\n\tvar isCancel = __webpack_require__(20);\n\tvar defaults = __webpack_require__(6);\n\t\n\t/**\n\t * Throws a `Cancel` if cancellation has been requested.\n\t */\n\tfunction throwIfCancellationRequested(config) {\n\t if (config.cancelToken) {\n\t config.cancelToken.throwIfRequested();\n\t }\n\t}\n\t\n\t/**\n\t * Dispatch a request to the server using the configured adapter.\n\t *\n\t * @param {object} config The config that is to be used for the request\n\t * @returns {Promise} The Promise to be fulfilled\n\t */\n\tmodule.exports = function dispatchRequest(config) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Ensure headers exist\n\t config.headers = config.headers || {};\n\t\n\t // Transform request data\n\t config.data = transformData(\n\t config.data,\n\t config.headers,\n\t config.transformRequest\n\t );\n\t\n\t // Flatten headers\n\t config.headers = utils.merge(\n\t config.headers.common || {},\n\t config.headers[config.method] || {},\n\t config.headers || {}\n\t );\n\t\n\t utils.forEach(\n\t ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n\t function cleanHeaderConfig(method) {\n\t delete config.headers[method];\n\t }\n\t );\n\t\n\t var adapter = config.adapter || defaults.adapter;\n\t\n\t return adapter(config).then(function onAdapterResolution(response) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Transform response data\n\t response.data = transformData(\n\t response.data,\n\t response.headers,\n\t config.transformResponse\n\t );\n\t\n\t return response;\n\t }, function onAdapterRejection(reason) {\n\t if (!isCancel(reason)) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Transform response data\n\t if (reason && reason.response) {\n\t reason.response.data = transformData(\n\t reason.response.data,\n\t reason.response.headers,\n\t config.transformResponse\n\t );\n\t }\n\t }\n\t\n\t return Promise.reject(reason);\n\t });\n\t};\n\n\n/***/ },\n/* 19 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t/**\n\t * Transform the data for a request or a response\n\t *\n\t * @param {Object|String} data The data to be transformed\n\t * @param {Array} headers The headers for the request or response\n\t * @param {Array|Function} fns A single function or Array of functions\n\t * @returns {*} The resulting transformed data\n\t */\n\tmodule.exports = function transformData(data, headers, fns) {\n\t /*eslint no-param-reassign:0*/\n\t utils.forEach(fns, function transform(fn) {\n\t data = fn(data, headers);\n\t });\n\t\n\t return data;\n\t};\n\n\n/***/ },\n/* 20 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = function isCancel(value) {\n\t return !!(value && value.__CANCEL__);\n\t};\n\n\n/***/ },\n/* 21 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Determines whether the specified URL is absolute\n\t *\n\t * @param {string} url The URL to test\n\t * @returns {boolean} True if the specified URL is absolute, otherwise false\n\t */\n\tmodule.exports = function isAbsoluteURL(url) {\n\t // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n\t // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n\t // by any combination of letters, digits, plus, period, or hyphen.\n\t return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n\t};\n\n\n/***/ },\n/* 22 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Creates a new URL by combining the specified URLs\n\t *\n\t * @param {string} baseURL The base URL\n\t * @param {string} relativeURL The relative URL\n\t * @returns {string} The combined URL\n\t */\n\tmodule.exports = function combineURLs(baseURL, relativeURL) {\n\t return relativeURL\n\t ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n\t : baseURL;\n\t};\n\n\n/***/ },\n/* 23 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * A `Cancel` is an object that is thrown when an operation is canceled.\n\t *\n\t * @class\n\t * @param {string=} message The message.\n\t */\n\tfunction Cancel(message) {\n\t this.message = message;\n\t}\n\t\n\tCancel.prototype.toString = function toString() {\n\t return 'Cancel' + (this.message ? ': ' + this.message : '');\n\t};\n\t\n\tCancel.prototype.__CANCEL__ = true;\n\t\n\tmodule.exports = Cancel;\n\n\n/***/ },\n/* 24 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar Cancel = __webpack_require__(23);\n\t\n\t/**\n\t * A `CancelToken` is an object that can be used to request cancellation of an operation.\n\t *\n\t * @class\n\t * @param {Function} executor The executor function.\n\t */\n\tfunction CancelToken(executor) {\n\t if (typeof executor !== 'function') {\n\t throw new TypeError('executor must be a function.');\n\t }\n\t\n\t var resolvePromise;\n\t this.promise = new Promise(function promiseExecutor(resolve) {\n\t resolvePromise = resolve;\n\t });\n\t\n\t var token = this;\n\t executor(function cancel(message) {\n\t if (token.reason) {\n\t // Cancellation has already been requested\n\t return;\n\t }\n\t\n\t token.reason = new Cancel(message);\n\t resolvePromise(token.reason);\n\t });\n\t}\n\t\n\t/**\n\t * Throws a `Cancel` if cancellation has been requested.\n\t */\n\tCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n\t if (this.reason) {\n\t throw this.reason;\n\t }\n\t};\n\t\n\t/**\n\t * Returns an object that contains a new `CancelToken` and a function that, when called,\n\t * cancels the `CancelToken`.\n\t */\n\tCancelToken.source = function source() {\n\t var cancel;\n\t var token = new CancelToken(function executor(c) {\n\t cancel = c;\n\t });\n\t return {\n\t token: token,\n\t cancel: cancel\n\t };\n\t};\n\t\n\tmodule.exports = CancelToken;\n\n\n/***/ },\n/* 25 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Syntactic sugar for invoking a function and expanding an array for arguments.\n\t *\n\t * Common use case would be to use `Function.prototype.apply`.\n\t *\n\t * ```js\n\t * function f(x, y, z) {}\n\t * var args = [1, 2, 3];\n\t * f.apply(null, args);\n\t * ```\n\t *\n\t * With `spread` this example can be re-written.\n\t *\n\t * ```js\n\t * spread(function(x, y, z) {})([1, 2, 3]);\n\t * ```\n\t *\n\t * @param {Function} callback\n\t * @returns {Function}\n\t */\n\tmodule.exports = function spread(callback) {\n\t return function wrap(arr) {\n\t return callback.apply(null, arr);\n\t };\n\t};\n\n\n/***/ }\n/******/ ])\n});\n;\n//# sourceMappingURL=axios.map","import { Component, utils } from 'js-data'\n\nexport const noop = function (...args) {\n const opts = args[args.length - 1]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const opts = args[args.length - 2]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const unique = function (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\n\nexport const withoutRelations = function (mapper, props, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n const relationFields = mapper.relationFields || []\n const toStrip = relationFields.filter((value) => opts.with.indexOf(value) === -1)\n return utils.omit(props, toStrip)\n}\n\nexport const reserved = [\n 'orderBy',\n 'sort',\n 'limit',\n 'offset',\n 'skip',\n 'where'\n]\n\n/**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\nexport function Response (data, meta, op) {\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n this.data = data\n\n utils.fillIn(this, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n this.op = op\n}\n\nconst DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @extends Component\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\nexport function Adapter (opts) {\n utils.classCallCheck(this, Adapter)\n Component.call(this, opts)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(this, opts)\n}\n\nComponent.extend({\n constructor: Adapter,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {string} field The `field` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._count(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'create'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._create(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'create')\n response.created = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = props.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'createMany'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._createMany(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'createMany')\n response.created = data.length\n response = this.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'destroy'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._destroy(mapper, id, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = this.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'destroyAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._destroyAll(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = this.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo (mapper, def, records, __opts) {\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts)\n .then((relatedItem) => {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records\n .map((record) => this.makeBelongsToForeignKey(mapper, def, record))\n .filter((key) => key)\n return this.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((record) => {\n relatedItems.forEach((relatedItem) => {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem)\n }\n })\n })\n })\n }\n },\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'find'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._find(mapper, id, opts))\n })\n .then((results) => this.loadRelationsFor(mapper, results, opts))\n .then(([record, meta]) => {\n let response = new Response(record, meta, 'find')\n response.found = record ? 1 : 0\n response = this.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n const activeWith = opts._activeWith\n\n if (utils.isObject(activeWith)) {\n const activeQuery = activeWith.query || {}\n if (activeWith.replace) {\n query = activeQuery\n } else {\n utils.deepFillIn(query, activeQuery)\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'findAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._findAll(mapper, query, opts))\n })\n .then((results) => this.loadRelationsFor(mapper, results, opts))\n .then(([records, meta]) => {\n let response = new Response(records, meta, 'findAll')\n response.found = records.length\n response = this.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n loadRelationsFor (mapper, results, opts) {\n const [records] = results\n const tasks = []\n\n if (records) {\n utils.forEachRelation(mapper, opts, (def, __opts) => {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = this.loadHasOne(mapper, def, records, __opts)\n } else {\n task = this.loadHasMany(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = this.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = this.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = this.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n }\n\n return utils.Promise.all(tasks)\n .then(() => results)\n },\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt (opt, opts) {\n opts || (opts = {})\n return opts[opt] === undefined ? utils.plainCopy(this[opt]) : utils.plainCopy(opts[opt])\n },\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany (mapper, def, records, __opts) {\n let singular = false\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n const IDs = records.map((record) => this.makeHasManyForeignKey(mapper, def, record))\n const query = {\n where: {}\n }\n const criteria = query.where[def.foreignKey] = {}\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0]\n } else {\n criteria['in'] = IDs.filter((id) => id)\n }\n return this.findAll(def.getRelation(), query, __opts).then((relatedItems) => {\n records.forEach((record) => {\n let attached = []\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems\n } else {\n relatedItems.forEach((relatedItem) => {\n if (utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem)\n }\n })\n }\n def.setLocalField(record, attached)\n })\n })\n },\n\n loadHasManyLocalKeys (mapper, def, records, __opts) {\n let record\n const relatedMapper = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': this.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach((record) => {\n localKeys = localKeys.concat(this.makeHasManyLocalKeys(mapper, def, record))\n })\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter((x) => x)\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((item) => {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach((relatedItem) => {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem)\n }\n })\n def.setLocalField(item, attached)\n })\n return relatedItems\n })\n }\n },\n\n loadHasManyForeignKeys (mapper, def, records, __opts) {\n const relatedMapper = def.getRelation()\n const idAttribute = mapper.idAttribute\n let record\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': this.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return this.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map((record) => this.makeHasManyForeignKeys(mapper, def, record))\n }\n }\n }, __opts).then((relatedItems) => {\n const foreignKeysField = def.foreignKeys\n records.forEach((record) => {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach((relatedItem) => {\n const foreignKeys = utils.get(relatedItems, foreignKeysField) || []\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem)\n }\n })\n def.setLocalField(record, _relatedItems)\n })\n })\n }\n },\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne (mapper, def, records, __opts) {\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n }\n return this.loadHasMany(mapper, def, records, __opts).then(() => {\n records.forEach((record) => {\n const relatedData = def.getLocalField(record)\n if (utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0])\n }\n })\n })\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n let localKeys = []\n let itemKeys = utils.get(record, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n return unique(localKeys).filter((x) => x)\n },\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys (mapper, def, record) {\n return utils.get(record, mapper.idAttribute)\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n let op\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n query || (query = {})\n opts || (opts = {})\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum'\n return utils.resolve(this[op](mapper, field, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n this.dbg(op, mapper, field, query, opts)\n return utils.resolve(this._sum(mapper, field, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(this[op](mapper, field, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond (response, opts) {\n return this.getOpt('raw', opts) ? response : response.data\n },\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(this[op](mapper, id, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'update'\n this.dbg(op, mapper, id, props, opts)\n return utils.resolve(this._update(mapper, id, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'update')\n response.updated = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(this[op](mapper, id, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let op\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'updateAll'\n this.dbg(op, mapper, props, query, opts)\n return utils.resolve(this._updateAll(mapper, props, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateAll')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter((record) => utils.get(record, idAttribute))\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(this[op](mapper, records, opts))\n .then((_records) => {\n // Allow for re-assignment from lifecycle hook\n records = _records === undefined ? records : _records\n records = records.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'updateMany'\n this.dbg(op, mapper, records, opts)\n return utils.resolve(this._updateMany(mapper, records, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateMany')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(this[op](mapper, records, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n }\n})\n\n/**\n * Create a subclass of this Adapter:\n *\n * @example Adapter.extend\n * // Normally you would do: import {Adapter} from 'js-data'\n * const JSData = require('js-data@3.0.0-beta.10')\n * const {Adapter} = JSData\n * console.log('Using JSData v' + JSData.version.full)\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomAdapterClass extends Adapter {\n * foo () { return 'bar' }\n * static beep () { return 'boop' }\n * }\n * const customAdapter = new CustomAdapterClass()\n * console.log(customAdapter.foo())\n * console.log(CustomAdapterClass.beep())\n *\n * // Extend the class using alternate method.\n * const OtherAdapterClass = Adapter.extend({\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const otherAdapter = new OtherAdapterClass()\n * console.log(otherAdapter.foo())\n * console.log(OtherAdapterClass.beep())\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherAdapterClass () {\n * Adapter.call(this)\n * this.created_at = new Date().getTime()\n * }\n * Adapter.extend({\n * constructor: AnotherAdapterClass,\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const anotherAdapter = new AnotherAdapterClass()\n * console.log(anotherAdapter.created_at)\n * console.log(anotherAdapter.foo())\n * console.log(AnotherAdapterClass.beep())\n *\n * @method Adapter.extend\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this Adapter class.\n */\n","import { utils } from 'js-data'\nimport axios from '../node_modules/axios/dist/axios'\nimport {\n Adapter,\n noop,\n noop2\n} from '../node_modules/js-data-adapter/src/index'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst DEFAULTS = {\n /**\n * Set a base path in order to use absolute URLs instead of relative URLs.\n *\n * @example\n * const httpAdapter = new HttpAdapter({\n * basePath: 'https://mydomain.com'\n * });\n *\n * @name HttpAdapter#basePath\n * @type {string}\n * @since 3.0.0\n */\n basePath: '',\n\n /**\n * Ensure that the request url has a trailing forward slash.\n *\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n forceTrailingSlash: false,\n\n hasFetch: hasFetch,\n\n /**\n * The HTTP function that actually makes the HTTP request. By default this is\n * `axios`.\n *\n * @name HttpAdapter#http\n * @type {function}\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library\n */\n http: axios,\n\n /**\n * Default configuration options to be mixed into the `config` argument passed\n * to {@link HttpAdapter#http}.\n *\n * @name HttpAdapter#httpConfig\n * @type {object}\n * @since 3.0.0\n */\n httpConfig: {},\n\n /**\n * Add a suffix to the request url, e.g. \".json\".\n *\n * @name HttpAdapter#suffix\n * @type {string}\n * @since 3.0.0\n */\n suffix: '',\n\n /**\n * Use `window.fetch` if available.\n *\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-windowfetch\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @example\n * import { DataStore } from 'js-data';\n * import { HttpAdapter } from 'js-data-http';\n *\n * const httpAdapter = new HttpAdapter();\n * const store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n *\n * store.defineMapper('school');\n * store.defineMapper('student');\n *\n * // GET /school/1\n * store.find('school', 1).then((school) => {\n * console.log('school');\n * });\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}.\n * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}.\n * @param {object} [opts.http=axios] See {@link HttpAdapter#http}.\n * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}.\n * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}.\n * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}.\n * @see http://www.js-data.io/docs/js-data-http\n */\nexport function HttpAdapter (opts) {\n utils.classCallCheck(this, HttpAdapter)\n\n opts || (opts = {})\n // Fill in any missing options with the defaults\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(this, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\nAdapter.extend({\n constructor: HttpAdapter,\n\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n return this.GET(\n this.getPath('count', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _create (mapper, props, opts) {\n return this.POST(\n this.getPath('create', mapper, props, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _createMany (mapper, props, opts) {\n return this.POST(\n this.getPath('createMany', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroy (mapper, id, opts) {\n return this.DEL(\n this.getPath('destroy', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroyAll (mapper, query, opts) {\n return this.DEL(\n this.getPath('destroyAll', mapper, null, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n return this.GET(\n this.getPath('find', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _findAll (mapper, query, opts) {\n return this.GET(\n this.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _sum (mapper, field, query, opts) {\n return this.GET(\n this.getPath('sum', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _update (mapper, id, props, opts) {\n return this.PUT(\n this.getPath('update', mapper, id, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateAll (mapper, props, query, opts) {\n return this.PUT(\n this.getPath('updateAll', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateMany (mapper, records, opts) {\n return this.PUT(\n this.getPath('updateMany', mapper, null, opts),\n this.serialize(mapper, records, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params.count = true\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.count.call(this, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {object} mapper The mapper.\n * @param {object} props Properties to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.create.call(this, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {object} mapper The mapper.\n * @param {array} props Array of property objects to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.createMany.call(this, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'DEL'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {object} mapper The mapper used for the operation.\n * @param {object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {object} opts Configuration options.\n * @return {(object|array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroy.call(this, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroyAll.call(this, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {object} config Request configuration.\n * @param {object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {object} config.headers Headers for the request.\n * @param {object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n */\n fetch (config) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers || {})\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(buildUrl(config.url, config.params), requestConfig)\n .then((response) => {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json()\n .then((data) => {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.find.call(this, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.findAll.call(this, mapper, query, opts)\n },\n\n /**\n * Make a GET request.\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'GET'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {object} mapper The Mapper.\n * @param {*} id The primary key, if any.\n * @param {boolean} opts Configuration options.\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach((def) => {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, (value, key) => {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method The method being executed.\n * @param {object} mapper The Mapper.\n * @param {(string|number)?} id The primary key, if any.\n * @param {object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n opts || (opts = {})\n const args = [\n opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath,\n this.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (opts.params === undefined) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (opts.suffix === undefined) {\n if (mapper.suffix === undefined) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, this.httpConfig)\n config.data = payload\n config.cache = cache\n if (timeout !== undefined) {\n config.timeout = timeout\n }\n if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || this.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n const logResponse = (data) => {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (this.log) {\n this.dbg(str, data)\n }\n return data\n } else {\n if (this.error) {\n this.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!this.http) {\n if ((this.useFetch || opts.useFetch)) {\n if (!hasFetch) {\n throw new Error('Attempting to use window.fetch, but it is not available!')\n }\n } else {\n throw new Error('You have not configured this adapter with an http library!')\n }\n }\n\n return utils.resolve(this.beforeHTTP(config, opts))\n .then((_config) => {\n config = _config || config\n if (hasFetch && (this.useFetch || opts.useFetch || !this.http)) {\n return this.fetch(config, opts).then(logResponse, logResponse)\n }\n const httpConfig = utils.plainCopy(config)\n delete httpConfig.adapter\n return this.http(httpConfig).then(logResponse, logResponse)\n .catch((err) => this.responseError(err, config, opts))\n })\n .then((response) => {\n return utils.resolve(this.afterHTTP(config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a POST request.\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'POST'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a PUT request.\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'PUT'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the querystring object before it is serialized. This doesn't do\n * anything by default.\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {*} params The querystring object.\n * @param {*} opts Configuration options\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * Serialize request data. This doesn't do anything by default.\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {object} data The request payload.\n * @param {*} opts Configuration options.\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n query || (query = {})\n opts || (opts = {})\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = this.getParams(opts)\n opts.params.sum = field\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.sum.call(this, mapper, field, query, opts)\n },\n\n /**\n * Perform an update. Makes a PUT request by default.\n *\n * @name HttpAdapter#update\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {*} id The primary key of the record being updated.\n * @param {*} props The update payload.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.update.call(this, mapper, id, props, opts)\n },\n\n /**\n * Perform an update against records that match the selection query. Makes a\n * PUT request by default.\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {object} props The update payload.\n * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateAll.call(this, mapper, props, query, opts)\n },\n\n /**\n * Update multiple individual records in a batch.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {array} records Array of property objects to send as the payload.\n * Each must contain the primary key of the record to be updated.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateMany.call(this, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addAction = JSDataHttp.addAction;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * endpoint: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {object} [opts] Action configuration\n * @param {string} [opts.adapter=\"http\"] The name of the adapter to use.\n * @param {string} [opts.pathname] Set the action's pathname.\n * @param {function} [opts.request] Specify a request handler to be executed\n * before the request is made.\n * @param {function} [opts.response] Specify a response handler to be executed\n * after the response is received.\n * @param {function} [opts.responseError] Specify an error handler to be\n * executed on error.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addAction (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n _opts = _opts || {}\n if (utils.isObject(id)) {\n _opts = id\n }\n utils.fillIn(_opts, opts)\n let adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http')\n const config = {}\n config.mapper = this.name\n utils.deepMixIn(config, _opts)\n config.method = config.method || 'GET'\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(this, _opts)\n } else {\n let args = [\n _opts.basePath || this.basePath || adapter.basePath,\n adapter.getEndpoint(this, id, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n return utils.resolve(config)\n .then(_opts.request)\n .then((config) => adapter.HTTP(config))\n .then((data) => {\n if (data && data.config) {\n data.config.mapper = this.name\n }\n return data\n })\n .then(_opts.response, _opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addActions = JSDataHttp.addActions;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * addActions({\n * // GET /reports/schools/:school_id/teachers\n * getTeacherReports: {\n * basePath: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * }\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addActions\n * @method\n * @param {object.} opts Object where the key is an action name\n * and the value is the configuration for the action.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name module:js-data-http.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http`\n * that works on Node.js is registered in NPM as `js-data-http-node`. The build\n * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower\n * as `js-data-fetch`.\n *\n * @example Script tag\n * var HttpAdapter = window.JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example ES2015 Modules\n * import { HttpAdapter } from 'js-data-Http';\n * const httpAdapter = new HttpAdapter();\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * // ...\n * });\n *\n * @module js-data-http\n */\n\n/**\n * Create a subclass of this HttpAdapter:\n * @example HttpAdapter.extend\n * // Normally you would do: import { HttpAdapter } from 'js-data-http';\n * // or: import { HttpAdapter } from 'js-data-http-node';\n * const JSDataHttp = require('js-data-http-node');\n * const { HttpAdapter } = JSDataHttp;\n * console.log('Using JSDataHttp v' + JSDataHttp.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomHttpAdapterClass extends HttpAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customHttpAdapter = new CustomHttpAdapterClass();\n * console.log(customHttpAdapter.foo());\n * console.log(CustomHttpAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherHttpAdapterClass = HttpAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const otherHttpAdapter = new OtherHttpAdapterClass();\n * console.log(otherHttpAdapter.foo());\n * console.log(OtherHttpAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherHttpAdapterClass () {\n * HttpAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * HttpAdapter.extend({\n * constructor: AnotherHttpAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const anotherHttpAdapter = new AnotherHttpAdapterClass();\n * console.log(anotherHttpAdapter.created_at);\n * console.log(anotherHttpAdapter.foo());\n * console.log(AnotherHttpAdapterClass.beep());\n *\n * @method HttpAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this HttpAdapter class.\n * @since 3.0.0\n */\n"],"names":["this","utils","noop","args","opts","length","dbg","op","resolve","noop2","unique","array","seen","final","forEach","item","push","withoutRelations","mapper","props","with","relationFields","toStrip","filter","value","indexOf","omit","Response","data","meta","fillIn","DEFAULTS","Adapter","classCallCheck","call","Component","extend","query","then","_count","results","result","response","respond","_response","undefined","_props","_create","created","map","record","_createMany","id","_destroy","_destroyAll","def","records","__opts","relationDef","getRelation","isObject","isArray","find","makeBelongsToForeignKey","relatedItem","setLocalField","keys","key","findAll","idAttribute","relatedItems","foreignKey","_find","loadRelationsFor","found","activeWith","_activeWith","activeQuery","replace","deepFillIn","_findAll","tasks","forEachRelation","task","type","loadHasOne","loadHasMany","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadBelongsTo","Promise","all","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","where","attached","get","relatedMapper","makeHasManyLocalKeys","concat","x","itemKeys","Object","makeHasManyForeignKeys","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","field","isString","Error","_sum","getOpt","_update","updated","_updateAll","_records","_updateMany","hasFetch","window","fetch","e","isValidString","join","items","separator","makePath","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","v","toString","toISOString","toJson","axios","HttpAdapter","GET","getPath","_end","POST","serialize","DEL","deserialize","PUT","getParams","count","suffix","getSuffix","deepMixIn","queryTransform","prototype","create","createMany","config","method","_config","HTTP","isFunction","hasOwnProperty","destroy","destroyAll","console","error","requestConfig","Headers","headers","body","json","isUndefined","relationList","endpoint","name","parent","parentKey","parentDef","parentId","_opts","_","getEndpoint","basePath","isNumber","apply","copy","start","Date","payload","cache","timeout","httpConfig","forceTrailingSlash","toUpperCase","substr","logResponse","str","toUTCString","status","getTime","log","reject","http","useFetch","beforeHTTP","adapter","catch","err","responseError","afterHTTP","sum","update","updateAll","updateMany","addAction","TypeError","request","getAdapter","defaultAdapter","isSorN","pathname","addActions","version"],"mappings":";;;;;;;;;;;;;;;;;;AACA,CAAC,SAAS,gCAAgC,CAAC,IAAI,EAAE,OAAO,EAAE;CACzD,AACC,cAAc,GAAG,OAAO,EAAE,CAAC,AAMD;CAC3B,EAAEA,cAAI,EAAE,WAAW;AACpB,gBAAgB,CAAC,S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;;aAEGpC,IAAL,CAAUZ,KAAKiO,QAAL,IAAiB9C,IAA3B;eACO7C,GAAP,GAAaL,SAAS4D,KAAT,CAAe,IAAf,EAAqB9L,IAArB,CAAb;;aAEKF,aAAMO,OAAN,CAAc6J,MAAd,EACJ/H,IADI,CACCsJ,MAAMqC,OADP,EAEJ3L,IAFI,CAEC,UAAC+H,MAAD;eAAYiD,QAAQ9C,IAAR,CAAaH,MAAb,CAAZ;OAFD,EAGJ/H,IAHI,CAGC,UAACV,IAAD,EAAU;YACVA,QAAQA,KAAKyI,MAAjB,EAAyB;eAClBA,MAAL,CAAYnJ,MAAZ,GAAqB,QAAKqK,IAA1B;;eAEK3J,IAAP;OAPG,EASJU,IATI,CASCsJ,MAAMlJ,QATP,EASiBkJ,MAAM6B,aATvB,CAAP;KAxBF;WAmCOvM,MAAP;GA1CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFF,AAAO,SAASoN,UAAT,CAAqBlO,IAArB,EAA2B;WACvBA,OAAO,EAAhB;SACO,UAAUc,MAAV,EAAkB;iBACjB2H,MAAN,CAAazI,IAAb,EAAmB,UAAUoB,KAAV,EAAiB2C,GAAjB,EAAsB;gBAC7BA,GAAV,EAAe3C,KAAf,EAAsBN,MAAtB;KADF;WAGOA,MAAP;GAJF;;;;;;;;;;;;;;;;;AAsBF,AAAO,IAAMqN,UAAU,gBAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/js-data-http.min.js b/dist/js-data-http.min.js index 2ccdbc9..c506c23 100644 --- a/dist/js-data-http.min.js +++ b/dist/js-data-http.min.js @@ -1,11 +1,10 @@ /*! * js-data-http -* @version 3.0.0-rc.3 - Homepage +* @version 3.0.0 - Homepage * @copyright (c) 2014-2016 js-data-http project authors * @license MIT * * @overview HTTP (XHR) adapter for js-data in the browser. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-http",["exports","js-data"],e):e(t.JSDataHttp=t.JSDataHttp||{},t.JSData)}(this,function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t.default:t}function r(t,e){return e={exports:{}},t(e,e.exports),e.exports}function i(t,n,r){n||(n={}),this.data=t,e.utils.fillIn(this,n),this.op=r}function o(t){e.utils.classCallCheck(this,o),e.Component.call(this,t),t||(t={}),e.utils.fillIn(t,E),e.utils.fillIn(this,t)}function a(t){return null!=t&&""!==t}function u(t,e){return e||(e=""),t.filter(a).join(e)}function s(){for(var t=arguments.length,e=Array(t),n=0;n0&&(t+=(t.indexOf("?")===-1?"?":"&")+r.join("&")),t}function c(t){e.utils.classCallCheck(this,c),t||(t={}),e.utils.fillIn(t,P),o.call(this,t)}function d(t,n){if(!t||!e.utils.isString(t))throw new TypeError("action(name[, opts]): Expected: string, Found: "+("undefined"==typeof t?"undefined":m(t)));return function(r){if(r[t])throw new Error("action(name[, opts]): "+t+" already exists on target!");return n.request=n.request||function(t){return t},n.response=n.response||function(t){return t},n.responseError=n.responseError||function(t){return e.utils.reject(t)},r[t]=function(r,i){var o=this;i=i||{},e.utils.isObject(r)&&(i=r),e.utils.fillIn(i,n);var a=this.getAdapter(i.adapter||this.defaultAdapter||"http"),u={};if(u.mapper=this.name,e.utils.deepMixIn(u,i),u.method=u.method||"GET","function"==typeof i.getEndpoint)u.url=i.getEndpoint(this,i);else{var f=[i.basePath||this.basePath||a.basePath,a.getEndpoint(this,r,i)];e.utils.isSorN(r)&&f.push(r),f.push(n.pathname||t),u.url=s.apply(null,f)}return e.utils.resolve(u).then(i.request).then(function(t){return a.HTTP(t)}).then(function(t){return t&&t.config&&(t.config.mapper=o.name),t}).then(i.response,i.responseError)},r}}function p(t){return t||(t={}),function(n){return e.utils.forOwn(t,function(t,e){d(e,t)(n)}),n}}var h="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},y=r(function(t,e){!function(n,r){"object"==typeof e&&"object"==typeof t?t.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof e?e.axios=r():n.axios=r()}(h,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){function r(t){var e=new a(t),n=o(a.prototype.request,e);return i.extend(n,a.prototype,e),i.extend(n,e),n}var i=n(2),o=n(3),a=n(4),u=t.exports=r();u.Axios=a,u.create=function(t){return r(t)},u.all=function(t){return Promise.all(t)},u.spread=n(21)},function(t,e,n){function r(t){return"[object Array]"===T.call(t)}function i(t){return"[object ArrayBuffer]"===T.call(t)}function o(t){return"undefined"!=typeof FormData&&t instanceof FormData}function a(t){var e;return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer}function u(t){return"string"==typeof t}function s(t){return"number"==typeof t}function f(t){return"undefined"==typeof t}function l(t){return null!==t&&"object"==typeof t}function c(t){return"[object Date]"===T.call(t)}function d(t){return"[object File]"===T.call(t)}function p(t){return"[object Blob]"===T.call(t)}function h(t){return"[object Function]"===T.call(t)}function y(t){return l(t)&&h(t.pipe)}function v(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams}function m(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}function g(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function b(t,e){if(null!==t&&"undefined"!=typeof t)if("object"==typeof t||r(t)||(t=[t]),r(t))for(var n=0,i=t.length;n=200&&t<300}}},function(t,e,n){var r=n(2);t.exports=function(t,e){r.forEach(t,function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])})}},function(t,e,n){function r(){this.handlers=[]}var i=n(2);r.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},r.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},r.prototype.forEach=function(t){i.forEach(this.handlers,function(e){null!==e&&t(e)})},t.exports=r},function(t,e,n){var r=n(2),i=n(9);t.exports=function(t){t.headers=t.headers||{},t.data=i(t.data,t.headers,t.transformRequest),t.headers=r.merge(t.headers.common||{},t.headers[t.method]||{},t.headers||{}),r.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]});var e;return"function"==typeof t.adapter?e=t.adapter:"undefined"!=typeof XMLHttpRequest?e=n(10):"undefined"!=typeof process&&(e=n(10)),Promise.resolve(t).then(e).then(function(e){return e.data=i(e.data,e.headers,t.transformResponse),e},function(e){return e&&e.response&&(e.response.data=i(e.response.data,e.response.headers,t.transformResponse)),Promise.reject(e)})}},function(t,e,n){var r=n(2);t.exports=function(t,e,n){return r.forEach(n,function(n){t=n(t,e)}),t}},function(t,e,n){var r=n(2),i=n(11),o=n(14),a=n(15),u=n(16),s=n(12),f="undefined"!=typeof window&&window.btoa||n(17);t.exports=function(t){return new Promise(function(e,l){var c=t.data,d=t.headers;r.isFormData(c)&&delete d["Content-Type"];var p=new XMLHttpRequest,h="onreadystatechange",y=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in p||u(t.url)||(p=new window.XDomainRequest,h="onload",y=!0,p.onprogress=function(){},p.ontimeout=function(){}),t.auth){var v=t.auth.username||"",m=t.auth.password||"";d.Authorization="Basic "+f(v+":"+m)}if(p.open(t.method.toUpperCase(),o(t.url,t.params,t.paramsSerializer),!0),p.timeout=t.timeout,p[h]=function(){if(p&&(4===p.readyState||y)&&0!==p.status){var n="getAllResponseHeaders"in p?a(p.getAllResponseHeaders()):null,r=t.responseType&&"text"!==t.responseType?p.response:p.responseText,o={data:r,status:1223===p.status?204:p.status,statusText:1223===p.status?"No Content":p.statusText,headers:n,config:t,request:p};i(e,l,o),p=null}},p.onerror=function(){l(s("Network Error",t)),p=null},p.ontimeout=function(){l(s("timeout of "+t.timeout+"ms exceeded",t,"ECONNABORTED")),p=null},r.isStandardBrowserEnv()){var g=n(18),b=t.withCredentials||u(t.url)?g.read(t.xsrfCookieName):void 0;b&&(d[t.xsrfHeaderName]=b)}if("setRequestHeader"in p&&r.forEach(d,function(t,e){"undefined"==typeof c&&"content-type"===e.toLowerCase()?delete d[e]:p.setRequestHeader(e,t)}),t.withCredentials&&(p.withCredentials=!0),t.responseType)try{p.responseType=t.responseType}catch(t){if("json"!==p.responseType)throw t}"function"==typeof t.progress&&("post"===t.method||"put"===t.method?p.upload.addEventListener("progress",t.progress):"get"===t.method&&p.addEventListener("progress",t.progress)),void 0===c&&(c=null),p.send(c)})}},function(t,e,n){var r=n(12);t.exports=function(t,e,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?e(r("Request failed with status code "+n.status,n.config,null,n)):t(n)}},function(t,e,n){var r=n(13);t.exports=function(t,e,n,i){var o=new Error(t);return r(o,e,n,i)}},function(t,e){t.exports=function(t,e,n,r){return t.config=e,n&&(t.code=n),t.response=r,t}},function(t,e,n){function r(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var i=n(2);t.exports=function(t,e,n){if(!e)return t;var o;if(n)o=n(e);else if(i.isURLSearchParams(e))o=e.toString();else{var a=[];i.forEach(e,function(t,e){null!==t&&"undefined"!=typeof t&&(i.isArray(t)&&(e+="[]"),i.isArray(t)||(t=[t]),i.forEach(t,function(t){i.isDate(t)?t=t.toISOString():i.isObject(t)&&(t=JSON.stringify(t)),a.push(r(e)+"="+r(t))}))}),o=a.join("&")}return o&&(t+=(t.indexOf("?")===-1?"?":"&")+o),t}},function(t,e,n){var r=n(2);t.exports=function(t){var e,n,i,o={};return t?(r.forEach(t.split("\n"),function(t){i=t.indexOf(":"),e=r.trim(t.substr(0,i)).toLowerCase(),n=r.trim(t.substr(i+1)),e&&(o[e]=o[e]?o[e]+", "+n:n)}),o):o}},function(t,e,n){var r=n(2);t.exports=r.isStandardBrowserEnv()?function(){function t(t){var e=t;return n&&(i.setAttribute("href",e),e=i.href),i.setAttribute("href",e),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}var e,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");return e=t(window.location.href),function(n){var i=r.isString(n)?t(n):n;return i.protocol===e.protocol&&i.host===e.host}}():function(){return function(){return!0}}()},function(t,e){function n(){this.message="String contains an invalid character"}function r(t){for(var e,r,o=String(t),a="",u=0,s=i;o.charAt(0|u)||(s="=",u%1);a+=s.charAt(63&e>>8-u%1*8)){if(r=o.charCodeAt(u+=.75),r>255)throw new n;e=e<<8|r}return a}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",t.exports=r},function(t,e,n){var r=n(2);t.exports=r.isStandardBrowserEnv()?function(){return{write:function(t,e,n,i,o,a){var u=[];u.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),r.isString(i)&&u.push("path="+i),r.isString(o)&&u.push("domain="+o),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(t,e){t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e){t.exports=function(t,e){return t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,"")}},function(t,e){t.exports=function(t){return function(e){return t.apply(null,e)}}}])})}),v=n(y),m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},g=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},b=function(){function t(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&u.return&&u.return()}finally{if(i)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),w=function(){for(var t=arguments.length,n=Array(t),r=0;r=200&&n.status<300?(r.log&&r.dbg(o,n),n):(r.error&&r.error("'FAILED: "+o,n),e.utils.reject(n))};if(!this.http)throw new Error("You have not configured this adapter with an http library!");return e.utils.resolve(this.beforeHTTP(t,n)).then(function(e){return t=e||t,S&&(r.useFetch||n.useFetch||!r.http)?r.fetch(t,n).then(f,f):r.http(t).then(f,f).catch(function(e){return r.responseError(e,t,n)})}).then(function(i){return e.utils.resolve(r.afterHTTP(t,n,i)).then(function(t){return void 0===t?i:t})})},POST:function(t,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=t||r.url,r.data=n||r.data,r.method=r.method||"post",a=i.op="beforePOST",e.utils.resolve(this[a](t,n,r,i)).then(function(e){return r=void 0===e?r:e,a=i.op="POST",o.dbg(a,t,n,r,i),o.HTTP(r,i)}).then(function(u){return a=i.op="afterPOST",e.utils.resolve(o[a](t,n,r,i,u)).then(function(t){return void 0===t?u:t})})},PUT:function(t,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=t||r.url,r.data=n||r.data,r.method=r.method||"put",a=i.op="beforePUT",e.utils.resolve(this[a](t,n,r,i)).then(function(e){return r=void 0===e?r:e,a=i.op="PUT",o.dbg(a,t,n,r,i),o.HTTP(r,i)}).then(function(u){return a=i.op="afterPUT",e.utils.resolve(o[a](t,n,r,i,u)).then(function(t){ -return void 0===t?u:t})})},queryTransform:function(t,n,r){return r||(r={}),e.utils.isFunction(r.queryTransform)?r.queryTransform(t,n,r):e.utils.isFunction(t.queryTransform)?t.queryTransform(t,n,r):n},responseError:function(t,n,r){return e.utils.reject(t)},serialize:function(t,n,r){return r||(r={}),e.utils.isFunction(r.serialize)?r.serialize(t,n,r):e.utils.isFunction(t.serialize)?t.serialize(t,n,r):n},sum:function(t,n,r,i){if(r||(r={}),i||(i={}),!e.utils.isString(n))throw new Error("field must be a string!");return i.params=this.getParams(i),i.params.sum=n,i.suffix=this.getSuffix(t,i),e.utils.deepMixIn(i.params,r),i.params=this.queryTransform(t,i.params,i),o.prototype.sum.call(this,t,n,r,i)},update:function(t,e,n,r){return r||(r={}),r.params=this.getParams(r),r.params=this.queryTransform(t,r.params,r),r.suffix=this.getSuffix(t,r),o.prototype.update.call(this,t,e,n,r)},updateAll:function(t,n,r,i){return r||(r={}),i||(i={}),i.params=this.getParams(i),e.utils.deepMixIn(i.params,r),i.params=this.queryTransform(t,i.params,i),i.suffix=this.getSuffix(t,i),o.prototype.updateAll.call(this,t,n,r,i)},updateMany:function(t,e,n){return n||(n={}),n.params=this.getParams(n),n.params=this.queryTransform(t,n.params,n),n.suffix=this.getSuffix(t,n),o.prototype.updateMany.call(this,t,e,n)}});var M={full:"3.0.0-rc.3",major:3,minor:0,patch:0};t.HttpAdapter=c,t.addAction=d,t.addActions=p,t.version=M,Object.defineProperty(t,"__esModule",{value:!0})}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-http",["exports","js-data"],t):t(e.JSDataHttp=e.JSDataHttp||{},e.JSData)}(this,function(e,t){"use strict";function Response(e,n,r){n||(n={}),this.data=e,t.utils.fillIn(this,n),this.op=r}function Adapter(e){t.utils.classCallCheck(this,Adapter),t.Component.call(this,e),e||(e={}),t.utils.fillIn(e,l),t.utils.fillIn(this,e)}function isValidString(e){return null!=e&&""!==e}function join(e,t){return t||(t=""),e.filter(isValidString).join(t)}function makePath(){for(var e=arguments.length,t=Array(e),n=0;n0&&(e+=(-1===e.indexOf("?")?"?":"&")+r.join("&")),e}function HttpAdapter(e){t.utils.classCallCheck(this,HttpAdapter),e||(e={}),t.utils.fillIn(e,d),Adapter.call(this,e)}function addAction(e,n){if(!e||!t.utils.isString(e))throw new TypeError("action(name[, opts]): Expected: string, Found: "+(void 0===e?"undefined":r(e)));return function(r){if(r[e])throw new Error("action(name[, opts]): "+e+" already exists on target!");return n.request=n.request||function(e){return e},n.response=n.response||function(e){return e},n.responseError=n.responseError||function(e){return t.utils.reject(e)},r[e]=function(r,o){var i=this;o=o||{},t.utils.isObject(r)&&(o=r),t.utils.fillIn(o,n);var a=this.getAdapter(o.adapter||this.defaultAdapter||"http"),s={};if(s.mapper=this.name,t.utils.deepMixIn(s,o),s.method=s.method||"GET","function"==typeof o.getEndpoint)s.url=o.getEndpoint(this,o);else{var u=[o.basePath||this.basePath||a.basePath,a.getEndpoint(this,r,o)];t.utils.isSorN(r)&&u.push(r),u.push(n.pathname||e),s.url=makePath.apply(null,u)}return t.utils.resolve(s).then(o.request).then(function(e){return a.HTTP(e)}).then(function(e){return e&&e.config&&(e.config.mapper=i.name),e}).then(o.response,o.responseError)},r}}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var n=function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e,t){!function webpackUniversalModuleDefinition(t,n){e.exports=n()}(0,function(){return function(e){function __webpack_require__(n){if(t[n])return t[n].exports;var r=t[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,__webpack_require__),r.loaded=!0,r.exports}var t={};return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.p="",__webpack_require__(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){function createInstance(e){var t=new i(e),n=o(i.prototype.request,t);return r.extend(n,i.prototype,t),r.extend(n,t),n}var r=n(2),o=n(3),i=n(5),a=n(6),s=createInstance(a);s.Axios=i,s.create=function create(e){return createInstance(r.merge(a,e))},s.Cancel=n(23),s.CancelToken=n(24),s.isCancel=n(20),s.all=function all(e){return Promise.all(e)},s.spread=n(25),e.exports=s,e.exports.default=s},function(e,t,n){function isArray(e){return"[object Array]"===i.call(e)}function isObject(e){return null!==e&&"object"==typeof e}function isFunction(e){return"[object Function]"===i.call(e)}function forEach(e,t){if(null!==e&&void 0!==e)if("object"==typeof e||isArray(e)||(e=[e]),isArray(e))for(var n=0,r=e.length;n=200&&e<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}},r.forEach(["delete","get","head"],function forEachMethodNoData(e){a.headers[e]={}}),r.forEach(["post","put","patch"],function forEachMethodWithData(e){a.headers[e]=r.merge(i)}),e.exports=a},function(e,t,n){var r=n(2);e.exports=function normalizeHeaderName(e,t){r.forEach(e,function processHeader(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){var r=n(2),o=n(9),i=n(12),a=n(13),s=n(14),u=n(10),f="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(15);e.exports=function xhrAdapter(e){return new Promise(function dispatchXhrRequest(t,l){var c=e.data,d=e.headers;r.isFormData(c)&&delete d["Content-Type"];var p=new XMLHttpRequest,h="onreadystatechange",y=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in p||s(e.url)||(p=new window.XDomainRequest,h="onload",y=!0,p.onprogress=function handleProgress(){},p.ontimeout=function handleTimeout(){}),e.auth){var m=e.auth.username||"",v=e.auth.password||"";d.Authorization="Basic "+f(m+":"+v)}if(p.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,p[h]=function handleLoad(){if(p&&(4===p.readyState||y)&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in p?a(p.getAllResponseHeaders()):null,r={data:e.responseType&&"text"!==e.responseType?p.response:p.responseText,status:1223===p.status?204:p.status,statusText:1223===p.status?"No Content":p.statusText,headers:n,config:e,request:p};o(t,l,r),p=null}},p.onerror=function handleError(){l(u("Network Error",e,null,p)),p=null},p.ontimeout=function handleTimeout(){l(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",p)),p=null},r.isStandardBrowserEnv()){var g=n(16),b=(e.withCredentials||s(e.url))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;b&&(d[e.xsrfHeaderName]=b)}if("setRequestHeader"in p&&r.forEach(d,function setRequestHeader(e,t){void 0===c&&"content-type"===t.toLowerCase()?delete d[t]:p.setRequestHeader(t,e)}),e.withCredentials&&(p.withCredentials=!0),e.responseType)try{p.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function onCanceled(e){p&&(p.abort(),l(e),p=null)}),void 0===c&&(c=null),p.send(c)})}},function(e,t,n){var r=n(10);e.exports=function settle(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){var r=n(11);e.exports=function createError(e,t,n,o,i){var a=new Error(e);return r(a,t,n,o,i)}},function(e,t){e.exports=function enhanceError(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e}},function(e,t,n){function encode(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var r=n(2);e.exports=function buildURL(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(r.isURLSearchParams(t))o=t.toString();else{var i=[];r.forEach(t,function serialize(e,t){null!==e&&void 0!==e&&(r.isArray(e)&&(t+="[]"),r.isArray(e)||(e=[e]),r.forEach(e,function parseValue(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),i.push(encode(t)+"="+encode(e))}))}),o=i.join("&")}return o&&(e+=(-1===e.indexOf("?")?"?":"&")+o),e}},function(e,t,n){var r=n(2);e.exports=function parseHeaders(e){var t,n,o,i={};return e?(r.forEach(e.split("\n"),function parser(e){o=e.indexOf(":"),t=r.trim(e.substr(0,o)).toLowerCase(),n=r.trim(e.substr(o+1)),t&&(i[t]=i[t]?i[t]+", "+n:n)}),i):i}},function(e,t,n){var r=n(2);e.exports=r.isStandardBrowserEnv()?function standardBrowserEnv(){function resolveURL(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");return e=resolveURL(window.location.href),function isURLSameOrigin(t){var n=r.isString(t)?resolveURL(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function nonStandardBrowserEnv(){return function isURLSameOrigin(){return!0}}()},function(e,t){function E(){this.message="String contains an invalid character"}var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";E.prototype=new Error,E.prototype.code=5,E.prototype.name="InvalidCharacterError",e.exports=function btoa(e){for(var t,r,o=String(e),i="",a=0,s=n;o.charAt(0|a)||(s="=",a%1);i+=s.charAt(63&t>>8-a%1*8)){if((r=o.charCodeAt(a+=.75))>255)throw new E;t=t<<8|r}return i}},function(e,t,n){var r=n(2);e.exports=r.isStandardBrowserEnv()?function standardBrowserEnv(){return{write:function write(e,t,n,o,i,a){var s=[];s.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),r.isString(o)&&s.push("path="+o),r.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function read(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function remove(e){this.write(e,"",Date.now()-864e5)}}}():function nonStandardBrowserEnv(){return{write:function write(){},read:function read(){return null},remove:function remove(){}}}()},function(e,t,n){function InterceptorManager(){this.handlers=[]}var r=n(2);InterceptorManager.prototype.use=function use(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},InterceptorManager.prototype.eject=function eject(e){this.handlers[e]&&(this.handlers[e]=null)},InterceptorManager.prototype.forEach=function forEach(e){r.forEach(this.handlers,function forEachHandler(t){null!==t&&e(t)})},e.exports=InterceptorManager},function(e,t,n){function throwIfCancellationRequested(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var r=n(2),o=n(19),i=n(20),a=n(6);e.exports=function dispatchRequest(e){return throwIfCancellationRequested(e),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),r.forEach(["delete","get","head","post","put","patch","common"],function cleanHeaderConfig(t){delete e.headers[t]}),(e.adapter||a.adapter)(e).then(function onAdapterResolution(t){return throwIfCancellationRequested(e),t.data=o(t.data,t.headers,e.transformResponse),t},function onAdapterRejection(t){return i(t)||(throwIfCancellationRequested(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){var r=n(2);e.exports=function transformData(e,t,n){return r.forEach(n,function transform(n){e=n(e,t)}),e}},function(e,t){e.exports=function isCancel(e){return!(!e||!e.__CANCEL__)}},function(e,t){e.exports=function isAbsoluteURL(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){e.exports=function combineURLs(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t){function Cancel(e){this.message=e}Cancel.prototype.toString=function toString(){return"Cancel"+(this.message?": "+this.message:"")},Cancel.prototype.__CANCEL__=!0,e.exports=Cancel},function(e,t,n){function CancelToken(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function promiseExecutor(e){t=e});var n=this;e(function cancel(e){n.reason||(n.reason=new r(e),t(n.reason))})}var r=n(23);CancelToken.prototype.throwIfRequested=function throwIfRequested(){if(this.reason)throw this.reason},CancelToken.source=function source(){var e;return{token:new CancelToken(function executor(t){e=t}),cancel:e}},e.exports=CancelToken},function(e,t){e.exports=function spread(e){return function wrap(t){return e.apply(null,t)}}}])})}),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},i=function(){function sliceIterator(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return sliceIterator(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=function noop(){for(var e=arguments.length,n=Array(e),r=0;r=200&&n.status<300?(r.log&&r.dbg(i,n),n):(r.error&&r.error("'FAILED: "+i,n),t.utils.reject(n))};if(!this.http){if(!this.useFetch&&!n.useFetch)throw new Error("You have not configured this adapter with an http library!");if(!c)throw new Error("Attempting to use window.fetch, but it is not available!")}return t.utils.resolve(this.beforeHTTP(e,n)).then(function(o){if(e=o||e,c&&(r.useFetch||n.useFetch||!r.http))return r.fetch(e,n).then(f,f);var i=t.utils.plainCopy(e);return delete i.adapter,r.http(i).then(f,f).catch(function(t){return r.responseError(t,e,n)})}).then(function(o){return t.utils.resolve(r.afterHTTP(e,n,o)).then(function(e){return void 0===e?o:e})})},POST:function POST(e,n,r,o){var i=this,a=void 0;return r||(r={}),o||(o={}),r.url=e||r.url,r.data=n||r.data,r.method=r.method||"post",a=o.op="beforePOST",t.utils.resolve(this[a](e,n,r,o)).then(function(t){return r=void 0===t?r:t,a=o.op="POST",i.dbg(a,e,n,r,o),i.HTTP(r,o)}).then(function(s){return a=o.op="afterPOST",t.utils.resolve(i[a](e,n,r,o,s)).then(function(e){return void 0===e?s:e})})},PUT:function PUT(e,n,r,o){var i=this,a=void 0;return r||(r={}),o||(o={}),r.url=e||r.url,r.data=n||r.data,r.method=r.method||"put",a=o.op="beforePUT",t.utils.resolve(this[a](e,n,r,o)).then(function(t){return r=void 0===t?r:t,a=o.op="PUT",i.dbg(a,e,n,r,o),i.HTTP(r,o)}).then(function(s){return a=o.op="afterPUT",t.utils.resolve(i[a](e,n,r,o,s)).then(function(e){return void 0===e?s:e})})},queryTransform:function queryTransform(e,n,r){return r||(r={}),t.utils.isFunction(r.queryTransform)?r.queryTransform(e,n,r):t.utils.isFunction(e.queryTransform)?e.queryTransform(e,n,r):n},responseError:function responseError(e,n,r){return t.utils.reject(e)},serialize:function serialize(e,n,r){return r||(r={}),t.utils.isFunction(r.serialize)?r.serialize(e,n,r):t.utils.isFunction(e.serialize)?e.serialize(e,n,r):n},sum:function sum(e,n,r,o){if(r||(r={}),o||(o={}),!t.utils.isString(n))throw new Error("field must be a string!");return o.params=this.getParams(o),o.params.sum=n,o.suffix=this.getSuffix(e,o),t.utils.deepMixIn(o.params,r),o.params=this.queryTransform(e,o.params,o),Adapter.prototype.sum.call(this,e,n,r,o)},update:function update(e,t,n,r){return r||(r={}),r.params=this.getParams(r),r.params=this.queryTransform(e,r.params,r),r.suffix=this.getSuffix(e,r),Adapter.prototype.update.call(this,e,t,n,r)},updateAll:function updateAll(e,n,r,o){return r||(r={}),o||(o={}),o.params=this.getParams(o),t.utils.deepMixIn(o.params,r),o.params=this.queryTransform(e,o.params,o),o.suffix=this.getSuffix(e,o),Adapter.prototype.updateAll.call(this,e,n,r,o)},updateMany:function updateMany(e,t,n){return n||(n={}),n.params=this.getParams(n),n.params=this.queryTransform(e,n.params,n),n.suffix=this.getSuffix(e,n),Adapter.prototype.updateMany.call(this,e,t,n)}});var p={full:"3.0.0",major:3,minor:0,patch:0};e.HttpAdapter=HttpAdapter,e.addAction=addAction,e.addActions=function addActions(e){return e||(e={}),function(n){return t.utils.forOwn(e,function(e,t){addAction(t,e)(n)}),n}},e.version=p,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=js-data-http.min.map \ No newline at end of file diff --git a/dist/js-data-http.min.js.map b/dist/js-data-http.min.js.map new file mode 100644 index 0000000..769f32f --- /dev/null +++ b/dist/js-data-http.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["dist/js-data-http.js"],"names":["global","factory","exports","module","require","define","amd","JSDataHttp","JSData","this","jsData","Response","data","meta","op","utils","fillIn","Adapter","opts","classCallCheck","Component","call","DEFAULTS$1","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","isArray","forEach","v","toString","toISOString","isObject","toJson","push","indexOf","HttpAdapter","DEFAULTS","addAction","name","isString","TypeError","_typeof","mapper","Error","request","config","response","responseError","err","reject","id","_opts","_this18","adapter","getAdapter","defaultAdapter","deepMixIn","method","getEndpoint","basePath","isSorN","pathname","apply","resolve","then","HTTP","window","self","axios","createCommonjsModule","fn","webpackUniversalModuleDefinition","root","commonjsGlobal","modules","__webpack_require__","moduleId","installedModules","loaded","m","c","p","createInstance","defaultConfig","context","Axios","instance","bind","prototype","utils$$1","extend","defaults","create","instanceConfig","merge","Cancel","CancelToken","isCancel","all","promises","Promise","spread","default","isFunction","obj","i","l","Object","hasOwnProperty","result","assignValue","isBuffer","isArrayBuffer","isFormData","FormData","isArrayBufferView","ArrayBuffer","isView","buffer","isNumber","isUndefined","isDate","isFile","isBlob","isStream","pipe","isURLSearchParams","URLSearchParams","isStandardBrowserEnv","navigator","product","document","a","b","thisArg","trim","str","wrap","constructor","isSlowBuffer","readFloatLE","slice","_isBuffer","interceptors","InterceptorManager","dispatchRequest","isAbsoluteURL","combineURLs","toLowerCase","baseURL","chain","undefined","promise","unshiftRequestInterceptors","interceptor","unshift","fulfilled","rejected","pushResponseInterceptors","shift","forEachMethodNoData","forEachMethodWithData","setContentTypeIfUnset","headers","normalizeHeaderName","DEFAULT_CONTENT_TYPE","Content-Type","getDefaultAdapter","XMLHttpRequest","process","transformRequest","JSON","stringify","transformResponse","parse","e","timeout","xsrfCookieName","xsrfHeaderName","maxContentLength","validateStatus","status","common","Accept","normalizedName","processHeader","toUpperCase","settle","buildURL","parseHeaders","isURLSameOrigin","createError","btoa","xhrAdapter","dispatchXhrRequest","requestData","requestHeaders","loadEvent","xDomain","XDomainRequest","onprogress","handleProgress","ontimeout","handleTimeout","auth","username","password","Authorization","open","paramsSerializer","handleLoad","readyState","responseURL","responseHeaders","getAllResponseHeaders","responseType","responseText","statusText","onerror","handleError","cookies","xsrfValue","withCredentials","read","setRequestHeader","onDownloadProgress","addEventListener","onUploadProgress","upload","cancelToken","onCanceled","cancel","abort","send","enhanceError","message","code","error","serializedParams","serialize","parseValue","parsed","split","parser","line","substr","standardBrowserEnv","resolveURL","href","msie","urlParsingNode","setAttribute","protocol","host","search","hash","hostname","port","charAt","originURL","test","userAgent","createElement","location","requestURL","nonStandardBrowserEnv","E","chars","input","block","charCode","String","output","idx","map","charCodeAt","write","expires","path","domain","secure","cookie","Date","toGMTString","match","RegExp","decodeURIComponent","remove","now","handlers","use","eject","forEachHandler","h","throwIfCancellationRequested","throwIfRequested","transformData","cleanHeaderConfig","onAdapterResolution","onAdapterRejection","reason","fns","transform","__CANCEL__","relativeURL","executor","resolvePromise","promiseExecutor","token","source","callback","arr","Symbol","iterator","defineProperty","enumerable","configurable","writable","slicedToArray","sliceIterator","_arr","_n","_d","_e","_s","_i","next","done","noop","dbg","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","props","with","toStrip","relationFields","omit","debug","raw","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","count","query","_this","_count","results","_results","respond","_response","_this2","_props","_create","_results2","created","createMany","_this3","record","_createMany","_results3","destroy","_this4","_destroy","_results4","destroyAll","_this5","_destroyAll","_results5","loadBelongsTo","def","records","__opts","_this6","relationDef","getRelation","find","makeBelongsToForeignKey","relatedItem","setLocalField","keys","findAll","where","idAttribute","in","relatedItems","foreignKey","_this7","_find","loadRelationsFor","_ref","_ref2","found","_this8","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_ref3","_ref4","_this9","tasks","forEachRelation","task","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","getOpt","opt","plainCopy","_this10","singular","IDs","makeHasManyForeignKey","criteria","attached","get","_this11","relatedMapper","makeHasManyLocalKeys","x","itemKeys","_this12","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","sum","field","_this13","_sum","_results7","update","_this14","_update","_results8","updated","updateAll","_this15","_updateAll","_results9","updateMany","_this16","_records","_updateMany","_results10","hasFetch","fetch","forceTrailingSlash","http","httpConfig","suffix","useFetch","afterDEL","afterGET","afterHTTP","afterPOST","afterPUT","beforeDEL","beforeGET","beforeHTTP","beforePOST","beforePUT","GET","getPath","_end","POST","DEL","deserialize","PUT","getParams","getSuffix","queryTransform","_config","console","_console","_fetch","_x","requestConfig","Headers","body","json","relationList","endpoint","parent","parentKey","parentDef","parentId","_","copy","start","payload","cache","logResponse","toUTCString","getTime","log","catch","_this17","version","full","major","minor","patch","addActions"],"mappings":"CAAC,SAAUA,EAAQC,GACC,iBAAZC,SAA0C,oBAAXC,OAAyBF,EAAQC,QAASE,QAAQ,YACtE,mBAAXC,QAAyBA,OAAOC,IAAMD,OAAO,gBAAiB,UAAW,WAAYJ,GAC3FA,EAASD,EAAOO,WAAaP,EAAOO,eAAkBP,EAAOQ,SAC7DC,KAAM,SAAWP,EAAQQ,GAAU,aA6sDrC,SAASC,SAASC,EAAMC,EAAMC,GAC5BD,IAASA,MAQTJ,KAAKG,KAAOA,EAEZF,EAAOK,MAAMC,OAAOP,KAAMI,GAQ1BJ,KAAKK,GAAKA,EAiCV,SAASG,QAAQC,GACjBR,EAAOK,MAAMI,eAAeV,KAAMQ,SAClCP,EAAOU,UAAUC,KAAKZ,KAAMS,GAC5BA,IAASA,MACTR,EAAOK,MAAMC,OAAOE,EAAMI,GAC1BZ,EAAOK,MAAMC,OAAOP,KAAMS,GAs5C5B,SAASK,cAAcC,GACrB,OAAgB,MAATA,GAA2B,KAAVA,EAE1B,SAASC,KAAKC,EAAOC,GAEnB,OADAA,IAAcA,EAAY,IACnBD,EAAME,OAAOL,eAAeE,KAAKE,GAE1C,SAASE,WACP,IAAK,IAAIC,EAAOC,UAAUC,OAAQC,EAAOC,MAAMJ,GAAOK,EAAO,EAAGA,EAAOL,EAAMK,IAC3EF,EAAKE,GAAQJ,UAAUI,GAIzB,OADaV,KAAKQ,EAAM,KACVG,QAAQ,mBAAoB,OAG5C,SAASC,OAAOC,GACd,OAAOC,mBAAmBD,GAAKF,QAAQ,QAAS,KAAKA,QAAQ,QAAS,KAAKA,QAAQ,OAAQ,KAAKA,QAAQ,QAAS,KAAKA,QAAQ,OAAQ,KAAKA,QAAQ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wB,OAASjC,KAAKogB,UAAU3f,GAC7BA,EAAKwB,OAASjC,KAAKsgB,eAAejd,EAAQ5C,EAAKwB,OAAQxB,GACvDA,EAAKwe,OAASjf,KAAKqgB,UAAUhd,EAAQ5C,GAC9BD,QAAQ2F,UAAUoY,WAAW3d,KAAKZ,KAAMqD,EAAQmW,EAAS/Y,MAwKpE,IAAIwhB,GACFC,KAAM,QACNC,MAAO,EACPC,MAAO,EACPC,MAAO,GAsFT5iB,EAAQqD,YAAcA,YACtBrD,EAAQuD,UAAYA,UACpBvD,EAAQ6iB,WApHR,SAASA,WAAW7hB,GAElB,OADAA,IAASA,MACF,SAAU4C,GAIf,OAHApD,EAAOK,MAAM6B,OAAO1B,EAAM,SAAUM,EAAOqB,GACzCY,UAAUZ,EAAKrB,GAAOsC,KAEjBA,IA+GX5D,EAAQwiB,QAAUA,EAElB3a,OAAO+M,eAAe5U,EAAS,cAAgBsB,OAAO"} \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.js b/fetch/dist/js-data-fetch.js index 232e18b..fdf8541 100644 --- a/fetch/dist/js-data-fetch.js +++ b/fetch/dist/js-data-fetch.js @@ -1,2844 +1,2981 @@ /*! * js-data-fetch -* @version 3.0.0-rc.3 - Homepage +* @version 3.0.0 - Homepage * @copyright (c) 2014-2016 js-data-http project authors * @license MIT * * @overview HTTP adapter for js-data that uses the fetch API. */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-data')) : - typeof define === 'function' && define.amd ? define('js-data-fetch', ['exports', 'js-data'], factory) : - (factory((global.JSDataHttp = global.JSDataHttp || {}),global.JSData)); -}(this, function (exports,jsData) { 'use strict'; - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; - }; + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-data')) : + typeof define === 'function' && define.amd ? define('js-data-fetch', ['exports', 'js-data'], factory) : + (factory((global.JSDataHttp = global.JSDataHttp || {}),global.JSData)); +}(this, (function (exports,jsData) { 'use strict'; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; - var defineProperty = function (obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; - }; - var slicedToArray = function () { - function sliceIterator(arr, i) { - var _arr = []; - var _n = true; - var _d = false; - var _e = undefined; - try { - for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"]) _i["return"](); - } finally { - if (_d) throw _e; - } - } - return _arr; - } - return function (arr, i) { - if (Array.isArray(arr)) { - return arr; - } else if (Symbol.iterator in Object(arr)) { - return sliceIterator(arr, i); - } else { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); - } - }; - }(); - var noop = function noop() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - var opts = args[args.length - 1]; - this.dbg.apply(this, [opts.op].concat(args)); - return jsData.utils.resolve(); - }; - var noop2 = function noop2() { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - var opts = args[args.length - 2]; - this.dbg.apply(this, [opts.op].concat(args)); - return jsData.utils.resolve(); - }; - var unique = function unique(array) { - var seen = {}; - var final = []; - array.forEach(function (item) { - if (item in seen) { - return; - } - final.push(item); - seen[item] = 0; - }); - return final; - }; - var withoutRelations = function withoutRelations(mapper, props, opts) { - opts || (opts = {}); - opts.with || (opts.with = []); - var relationFields = mapper.relationFields || []; - var toStrip = relationFields.filter(function (value) { - return opts.with.indexOf(value) === -1; - }); - return jsData.utils.omit(props, toStrip); - }; - /** - * Response object used when `raw` is `true`. May contain other fields in - * addition to `data`. - * - * @class Response - */ - function Response(data, meta, op) { - meta || (meta = {}); - /** - * Response data. - * - * @name Response#data - * @type {*} - */ - this.data = data; - jsData.utils.fillIn(this, meta); - /** - * The operation for which the response was created. - * - * @name Response#op - * @type {string} - */ - this.op = op; - } - var DEFAULTS$1 = { - /** - * Whether to log debugging information. - * - * @name Adapter#debug - * @type {boolean} - * @default false - */ - debug: false, - - /** - * Whether to return a more detailed response object. - * - * @name Adapter#raw - * @type {boolean} - * @default false - */ - raw: false - }; - /** - * Abstract class meant to be extended by adapters. - * - * @class Adapter - * @abstract - * @extends Component - * @param {Object} [opts] Configuration opts. - * @param {boolean} [opts.debug=false] Whether to log debugging information. - * @param {boolean} [opts.raw=false] Whether to return a more detailed response - * object. - */ - function Adapter(opts) { - jsData.utils.classCallCheck(this, Adapter); - jsData.Component.call(this, opts); - opts || (opts = {}); - jsData.utils.fillIn(opts, DEFAULTS$1); - jsData.utils.fillIn(this, opts); +var defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; } - jsData.Component.extend({ - constructor: Adapter, - - /** - * Lifecycle method method called by count. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes count to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. - * - * @name Adapter#afterCount - * @method - * @param {Object} mapper The `mapper` argument passed to count. - * @param {Object} props The `props` argument passed to count. - * @param {Object} opts The `opts` argument passed to count. - * @property {string} opts.op `afterCount` - * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. - */ - afterCount: noop2, - - /** - * Lifecycle method method called by create. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes create to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. - * - * @name Adapter#afterCreate - * @method - * @param {Object} mapper The `mapper` argument passed to create. - * @param {Object} props The `props` argument passed to create. - * @param {Object} opts The `opts` argument passed to create. - * @property {string} opts.op `afterCreate` - * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. - */ - afterCreate: noop2, - - /** - * Lifecycle method method called by createMany. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. - * - * @name Adapter#afterCreate - * @method - * @param {Object} mapper The `mapper` argument passed to createMany. - * @param {Object[]} props The `props` argument passed to createMany. - * @param {Object} opts The `opts` argument passed to createMany. - * @property {string} opts.op `afterCreateMany` - * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. - */ - afterCreateMany: noop2, - - /** - * Lifecycle method method called by destroy. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. - * - * @name Adapter#afterDestroy - * @method - * @param {Object} mapper The `mapper` argument passed to destroy. - * @param {(string|number)} id The `id` argument passed to destroy. - * @param {Object} opts The `opts` argument passed to destroy. - * @property {string} opts.op `afterDestroy` - * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. - */ - afterDestroy: noop2, - - /** - * Lifecycle method method called by destroyAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. - * - * @name Adapter#afterDestroyAll - * @method - * @param {Object} mapper The `mapper` argument passed to destroyAll. - * @param {Object} query The `query` argument passed to destroyAll. - * @param {Object} opts The `opts` argument passed to destroyAll. - * @property {string} opts.op `afterDestroyAll` - * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. - */ - afterDestroyAll: noop2, - - /** - * Lifecycle method method called by find. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes find to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. - * - * @name Adapter#afterFind - * @method - * @param {Object} mapper The `mapper` argument passed to find. - * @param {(string|number)} id The `id` argument passed to find. - * @param {Object} opts The `opts` argument passed to find. - * @property {string} opts.op `afterFind` - * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`. - */ - afterFind: noop2, - - /** - * Lifecycle method method called by findAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. - * - * @name Adapter#afterFindAll - * @method - * @param {Object} mapper The `mapper` argument passed to findAll. - * @param {Object} query The `query` argument passed to findAll. - * @param {Object} opts The `opts` argument passed to findAll. - * @property {string} opts.op `afterFindAll` - * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`. - */ - afterFindAll: noop2, - - /** - * Lifecycle method method called by sum. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes sum to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. - * - * @name Adapter#afterSum - * @method - * @param {Object} mapper The `mapper` argument passed to sum. - * @param {string} field The `field` argument passed to sum. - * @param {Object} query The `query` argument passed to sum. - * @param {Object} opts The `opts` argument passed to sum. - * @property {string} opts.op `afterSum` - * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. - */ - afterSum: noop2, - - /** - * Lifecycle method method called by update. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes update to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. - * - * @name Adapter#afterUpdate - * @method - * @param {Object} mapper The `mapper` argument passed to update. - * @param {(string|number)} id The `id` argument passed to update. - * @param {Object} props The `props` argument passed to update. - * @param {Object} opts The `opts` argument passed to update. - * @property {string} opts.op `afterUpdate` - * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`. - */ - afterUpdate: noop2, - - /** - * Lifecycle method method called by updateAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. - * - * @name Adapter#afterUpdateAll - * @method - * @param {Object} mapper The `mapper` argument passed to updateAll. - * @param {Object} props The `props` argument passed to updateAll. - * @param {Object} query The `query` argument passed to updateAll. - * @param {Object} opts The `opts` argument passed to updateAll. - * @property {string} opts.op `afterUpdateAll` - * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. - */ - afterUpdateAll: noop2, - - /** - * Lifecycle method method called by updateMany. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. - * - * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. - * - * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. - * - * @name Adapter#afterUpdateMany - * @method - * @param {Object} mapper The `mapper` argument passed to updateMany. - * @param {Object[]} records The `records` argument passed to updateMany. - * @param {Object} opts The `opts` argument passed to updateMany. - * @property {string} opts.op `afterUpdateMany` - * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. - */ - afterUpdateMany: noop2, - - /** - * Lifecycle method method called by count. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes count to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. - * - * @name Adapter#beforeCount - * @method - * @param {Object} mapper The `mapper` argument passed to count. - * @param {Object} query The `query` argument passed to count. - * @param {Object} opts The `opts` argument passed to count. - * @property {string} opts.op `beforeCount` - */ - beforeCount: noop, - - /** - * Lifecycle method method called by create. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes create to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. - * - * @name Adapter#beforeCreate - * @method - * @param {Object} mapper The `mapper` argument passed to create. - * @param {Object} props The `props` argument passed to create. - * @param {Object} opts The `opts` argument passed to create. - * @property {string} opts.op `beforeCreate` - */ - beforeCreate: noop, - - /** - * Lifecycle method method called by createMany. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. - * - * @name Adapter#beforeCreateMany - * @method - * @param {Object} mapper The `mapper` argument passed to createMany. - * @param {Object[]} props The `props` argument passed to createMany. - * @param {Object} opts The `opts` argument passed to createMany. - * @property {string} opts.op `beforeCreateMany` - */ - beforeCreateMany: noop, - - /** - * Lifecycle method method called by destroy. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. - * - * @name Adapter#beforeDestroy - * @method - * @param {Object} mapper The `mapper` argument passed to destroy. - * @param {(string|number)} id The `id` argument passed to destroy. - * @param {Object} opts The `opts` argument passed to destroy. - * @property {string} opts.op `beforeDestroy` - */ - beforeDestroy: noop, - - /** - * Lifecycle method method called by destroyAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. - * - * @name Adapter#beforeDestroyAll - * @method - * @param {Object} mapper The `mapper` argument passed to destroyAll. - * @param {Object} query The `query` argument passed to destroyAll. - * @param {Object} opts The `opts` argument passed to destroyAll. - * @property {string} opts.op `beforeDestroyAll` - */ - beforeDestroyAll: noop, - - /** - * Lifecycle method method called by find. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes find to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. - * - * @name Adapter#beforeFind - * @method - * @param {Object} mapper The `mapper` argument passed to find. - * @param {(string|number)} id The `id` argument passed to find. - * @param {Object} opts The `opts` argument passed to find. - * @property {string} opts.op `beforeFind` - */ - beforeFind: noop, - - /** - * Lifecycle method method called by findAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. - * - * @name Adapter#beforeFindAll - * @method - * @param {Object} mapper The `mapper` argument passed to findAll. - * @param {Object} query The `query` argument passed to findAll. - * @param {Object} opts The `opts` argument passed to findAll. - * @property {string} opts.op `beforeFindAll` - */ - beforeFindAll: noop, - - /** - * Lifecycle method method called by sum. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes sum to wait for the Promise to resolve before continuing. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. - * - * @name Adapter#beforeSum - * @method - * @param {Object} mapper The `mapper` argument passed to sum. - * @param {Object} query The `query` argument passed to sum. - * @param {Object} opts The `opts` argument passed to sum. - * @property {string} opts.op `beforeSum` - */ - beforeSum: noop, - - /** - * Lifecycle method method called by update. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes update to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. - * - * @name Adapter#beforeUpdate - * @method - * @param {Object} mapper The `mapper` argument passed to update. - * @param {(string|number)} id The `id` argument passed to update. - * @param {Object} props The `props` argument passed to update. - * @param {Object} opts The `opts` argument passed to update. - * @property {string} opts.op `beforeUpdate` - */ - beforeUpdate: noop, - - /** - * Lifecycle method method called by updateAll. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. - * - * @name Adapter#beforeUpdateAll - * @method - * @param {Object} mapper The `mapper` argument passed to updateAll. - * @param {Object} props The `props` argument passed to updateAll. - * @param {Object} query The `query` argument passed to updateAll. - * @param {Object} opts The `opts` argument passed to updateAll. - * @property {string} opts.op `beforeUpdateAll` - */ - beforeUpdateAll: noop, - - /** - * Lifecycle method method called by updateMany. - * - * Override this method to add custom behavior for this lifecycle hook. - * - * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. - * - * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. - * - * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. - * - * @name Adapter#beforeUpdateMany - * @method - * @param {Object} mapper The `mapper` argument passed to updateMany. - * @param {Object[]} props The `props` argument passed to updateMany. - * @param {Object} opts The `opts` argument passed to updateMany. - * @property {string} opts.op `beforeUpdateMany` - */ - beforeUpdateMany: noop, - - /** - * Retrieve the number of records that match the selection query. Called by - * `Mapper#count`. - * - * @name Adapter#count - * @method - * @param {Object} mapper The mapper. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - count: function count(mapper, query, opts) { - var _this = this; - - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeCount lifecycle hook - op = opts.op = 'beforeCount'; - return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'count'; - _this.dbg(op, mapper, query, opts); - return jsData.utils.resolve(_this._count(mapper, query, opts)); - }).then(function (results) { - var _results = slicedToArray(results, 2); - - var data = _results[0]; - var result = _results[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = _this.respond(response, opts); - - // afterCount lifecycle hook - op = opts.op = 'afterCount'; - return jsData.utils.resolve(_this[op](mapper, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Create a new record. Called by `Mapper#create`. - * - * @name Adapter#create - * @method - * @param {Object} mapper The mapper. - * @param {Object} props The record to be created. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - create: function create(mapper, props, opts) { - var _this2 = this; - - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreate lifecycle hook - op = opts.op = 'beforeCreate'; - return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = _props === undefined ? props : _props; - props = withoutRelations(mapper, props, opts); - op = opts.op = 'create'; - _this2.dbg(op, mapper, props, opts); - return jsData.utils.resolve(_this2._create(mapper, props, opts)); - }).then(function (results) { - var _results2 = slicedToArray(results, 2); - - var data = _results2[0]; - var result = _results2[1]; - - result || (result = {}); - var response = new Response(data, result, 'create'); - response.created = data ? 1 : 0; - response = _this2.respond(response, opts); - - // afterCreate lifecycle hook - op = opts.op = 'afterCreate'; - return jsData.utils.resolve(_this2[op](mapper, props, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Create multiple records in a single batch. Called by `Mapper#createMany`. - * - * @name Adapter#createMany - * @method - * @param {Object} mapper The mapper. - * @param {Object} props The records to be created. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - createMany: function createMany(mapper, props, opts) { - var _this3 = this; - - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreateMany lifecycle hook - op = opts.op = 'beforeCreateMany'; - return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = _props === undefined ? props : _props; - props = props.map(function (record) { - return withoutRelations(mapper, record, opts); - }); - op = opts.op = 'createMany'; - _this3.dbg(op, mapper, props, opts); - return jsData.utils.resolve(_this3._createMany(mapper, props, opts)); - }).then(function (results) { - var _results3 = slicedToArray(results, 2); - - var data = _results3[0]; - var result = _results3[1]; - - data || (data = []); - result || (result = {}); - var response = new Response(data, result, 'createMany'); - response.created = data.length; - response = _this3.respond(response, opts); - - // afterCreateMany lifecycle hook - op = opts.op = 'afterCreateMany'; - return jsData.utils.resolve(_this3[op](mapper, props, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Destroy the record with the given primary key. Called by - * `Mapper#destroy`. - * - * @name Adapter#destroy - * @method - * @param {Object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to destroy. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - destroy: function destroy(mapper, id, opts) { - var _this4 = this; - - var op = void 0; - opts || (opts = {}); - - // beforeDestroy lifecycle hook - op = opts.op = 'beforeDestroy'; - return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { - op = opts.op = 'destroy'; - _this4.dbg(op, mapper, id, opts); - return jsData.utils.resolve(_this4._destroy(mapper, id, opts)); - }).then(function (results) { - var _results4 = slicedToArray(results, 2); - - var data = _results4[0]; - var result = _results4[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroy'); - response = _this4.respond(response, opts); - - // afterDestroy lifecycle hook - op = opts.op = 'afterDestroy'; - return jsData.utils.resolve(_this4[op](mapper, id, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Destroy the records that match the selection query. Called by - * `Mapper#destroyAll`. - * - * @name Adapter#destroyAll - * @method - * @param {Object} mapper the mapper. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - destroyAll: function destroyAll(mapper, query, opts) { - var _this5 = this; - - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeDestroyAll lifecycle hook - op = opts.op = 'beforeDestroyAll'; - return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { - op = opts.op = 'destroyAll'; - _this5.dbg(op, mapper, query, opts); - return jsData.utils.resolve(_this5._destroyAll(mapper, query, opts)); - }).then(function (results) { - var _results5 = slicedToArray(results, 2); - - var data = _results5[0]; - var result = _results5[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroyAll'); - response = _this5.respond(response, opts); - - // afterDestroyAll lifecycle hook - op = opts.op = 'afterDestroyAll'; - return jsData.utils.resolve(_this5[op](mapper, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Load a belongsTo relationship. - * - * Override with care. - * - * @name Adapter#loadBelongsTo - * @method - * @return {Promise} - */ - loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { - var _this6 = this; - - var relationDef = def.getRelation(); - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - var _ret = function () { - var record = records; - return { - v: _this6.find(relationDef, _this6.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { - def.setLocalField(record, relatedItem); - }) - }; - }(); + return obj; +}; - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; - } else { - var keys = records.map(function (record) { - return _this6.makeBelongsToForeignKey(mapper, def, record); - }).filter(function (key) { - return key; - }); - return this.findAll(relationDef, { - where: defineProperty({}, relationDef.idAttribute, { - 'in': keys - }) - }, __opts).then(function (relatedItems) { - records.forEach(function (record) { - relatedItems.forEach(function (relatedItem) { - if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { - def.setLocalField(record, relatedItem); - } - }); - }); - }); - } - }, - - - /** - * Retrieve the record with the given primary key. Called by `Mapper#find`. - * - * @name Adapter#find - * @method - * @param {Object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to retrieve. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @param {string[]} [opts.with=[]] Relations to eager load. - * @return {Promise} - */ - find: function find(mapper, id, opts) { - var _this7 = this; - - var record = void 0, - op = void 0; - var meta = {}; - opts || (opts = {}); - opts.with || (opts.with = []); - - // beforeFind lifecycle hook - op = opts.op = 'beforeFind'; - return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { - op = opts.op = 'find'; - _this7.dbg(op, mapper, id, opts); - return jsData.utils.resolve(_this7._find(mapper, id, opts)); - }).then(function (results) { - var _results6 = slicedToArray(results, 2); - - var _record = _results6[0]; - var _meta = _results6[1]; - - if (!_record) { - return; - } - record = _record; - meta = _meta; - var tasks = []; - - jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { - var task = void 0; - if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { - if (def.type === 'hasOne') { - task = _this7.loadHasOne(mapper, def, record, __opts); - } else { - task = _this7.loadHasMany(mapper, def, record, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = _this7.loadHasManyLocalKeys(mapper, def, record, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = _this7.loadHasManyForeignKeys(mapper, def, record, __opts); - } else if (def.type === 'belongsTo') { - task = _this7.loadBelongsTo(mapper, def, record, __opts); - } - if (task) { - tasks.push(task); - } - }); - return jsData.utils.Promise.all(tasks); - }).then(function () { - var response = new Response(record, meta, 'find'); - response.found = record ? 1 : 0; - response = _this7.respond(response, opts); - // afterFind lifecycle hook - op = opts.op = 'afterFind'; - return jsData.utils.resolve(_this7[op](mapper, id, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Retrieve the records that match the selection query. - * - * @name Adapter#findAll - * @method - * @param {Object} mapper The mapper. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @param {string[]} [opts.with=[]] Relations to eager load. - * @return {Promise} - */ - findAll: function findAll(mapper, query, opts) { - var _this8 = this; - - opts || (opts = {}); - opts.with || (opts.with = []); - - var records = []; - var meta = {}; - var op = void 0; - var activeWith = opts._activeWith; - - if (jsData.utils.isObject(activeWith)) { - var activeQuery = activeWith.query || {}; - if (activeWith.replace) { - query = activeQuery; - } else { - jsData.utils.deepFillIn(query, activeQuery); - } - } - // beforeFindAll lifecycle hook - op = opts.op = 'beforeFindAll'; - return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { - op = opts.op = 'findAll'; - _this8.dbg(op, mapper, query, opts); - return jsData.utils.resolve(_this8._findAll(mapper, query, opts)); - }).then(function (results) { - var _results7 = slicedToArray(results, 2); - - var _records = _results7[0]; - var _meta = _results7[1]; - - _records || (_records = []); - records = _records; - meta = _meta; - var tasks = []; - jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { - var task = void 0; - if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { - if (def.type === 'hasMany') { - task = _this8.loadHasMany(mapper, def, records, __opts); - } else { - task = _this8.loadHasOne(mapper, def, records, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = _this8.loadHasManyLocalKeys(mapper, def, records, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = _this8.loadHasManyForeignKeys(mapper, def, records, __opts); - } else if (def.type === 'belongsTo') { - task = _this8.loadBelongsTo(mapper, def, records, __opts); - } - if (task) { - tasks.push(task); - } - }); - return jsData.utils.Promise.all(tasks); - }).then(function () { - var response = new Response(records, meta, 'findAll'); - response.found = records.length; - response = _this8.respond(response, opts); - - // afterFindAll lifecycle hook - op = opts.op = 'afterFindAll'; - return jsData.utils.resolve(_this8[op](mapper, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Resolve the value of the specified option based on the given options and - * this adapter's settings. Override with care. - * - * @name Adapter#getOpt - * @method - * @param {string} opt The name of the option. - * @param {Object} [opts] Configuration options. - * @return {*} The value of the specified option. - */ - getOpt: function getOpt(opt, opts) { - opts || (opts = {}); - return opts[opt] === undefined ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); - }, - - - /** - * Load a hasMany relationship. - * - * Override with care. - * - * @name Adapter#loadHasMany - * @method - * @return {Promise} - */ - loadHasMany: function loadHasMany(mapper, def, records, __opts) { - var _this9 = this; - - var singular = false; - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - singular = true; - records = [records]; - } - var IDs = records.map(function (record) { - return _this9.makeHasManyForeignKey(mapper, def, record); - }); - var query = { - where: {} - }; - var criteria = query.where[def.foreignKey] = {}; - if (singular) { - // more efficient query when we only have one record - criteria['=='] = IDs[0]; - } else { - criteria['in'] = IDs.filter(function (id) { - return id; - }); - } - return this.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { - records.forEach(function (record) { - var attached = []; - // avoid unneccesary iteration when we only have one record - if (singular) { - attached = relatedItems; - } else { - relatedItems.forEach(function (relatedItem) { - if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { - attached.push(relatedItem); - } - }); - } - def.setLocalField(record, attached); - }); - }); - }, - loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { - var _this10 = this; - var record = void 0; - var relatedMapper = def.getRelation(); - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - record = records; - } - if (record) { - return this.findAll(relatedMapper, { - where: defineProperty({}, relatedMapper.idAttribute, { - 'in': this.makeHasManyLocalKeys(mapper, def, record) - }) - }, __opts).then(function (relatedItems) { - def.setLocalField(record, relatedItems); - }); - } else { - var _ret2 = function () { - var localKeys = []; - records.forEach(function (record) { - localKeys = localKeys.concat(_this10.makeHasManyLocalKeys(mapper, def, record)); - }); - return { - v: _this10.findAll(relatedMapper, { - where: defineProperty({}, relatedMapper.idAttribute, { - 'in': unique(localKeys).filter(function (x) { - return x; - }) - }) - }, __opts).then(function (relatedItems) { - records.forEach(function (item) { - var attached = []; - var itemKeys = jsData.utils.get(item, def.localKeys) || []; - itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); - relatedItems.forEach(function (relatedItem) { - if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { - attached.push(relatedItem); - } - }); - def.setLocalField(item, attached); - }); - return relatedItems; - }) - }; - }(); - - if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v; - } - }, - loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { - var _this11 = this; - var relatedMapper = def.getRelation(); - var idAttribute = mapper.idAttribute; - var record = void 0; - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - record = records; - } - if (record) { - return this.findAll(def.getRelation(), { - where: defineProperty({}, def.foreignKeys, { - 'contains': this.makeHasManyForeignKeys(mapper, def, record) - }) - }, __opts).then(function (relatedItems) { - def.setLocalField(record, relatedItems); - }); - } else { - return this.findAll(relatedMapper, { - where: defineProperty({}, def.foreignKeys, { - 'isectNotEmpty': records.map(function (record) { - return _this11.makeHasManyForeignKeys(mapper, def, record); - }) - }) - }, __opts).then(function (relatedItems) { - var foreignKeysField = def.foreignKeys; - records.forEach(function (record) { - var _relatedItems = []; - var id = jsData.utils.get(record, idAttribute); - relatedItems.forEach(function (relatedItem) { - var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; - if (foreignKeys.indexOf(id) !== -1) { - _relatedItems.push(relatedItem); - } - }); - def.setLocalField(record, _relatedItems); - }); - }); - } - }, - - - /** - * Load a hasOne relationship. - * - * Override with care. - * - * @name Adapter#loadHasOne - * @method - * @return {Promise} - */ - loadHasOne: function loadHasOne(mapper, def, records, __opts) { - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - records = [records]; - } - return this.loadHasMany(mapper, def, records, __opts).then(function () { - records.forEach(function (record) { - var relatedData = def.getLocalField(record); - if (jsData.utils.isArray(relatedData) && relatedData.length) { - def.setLocalField(record, relatedData[0]); - } - }); - }); - }, - - - /** - * Return the foreignKey from the given record for the provided relationship. - * - * There may be reasons why you may want to override this method, like when - * the id of the parent doesn't exactly match up to the key on the child. - * - * Override with care. - * - * @name Adapter#makeHasManyForeignKey - * @method - * @return {*} - */ - makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) { - return def.getForeignKey(record); - }, - - - /** - * Return the localKeys from the given record for the provided relationship. - * - * Override with care. - * - * @name Adapter#makeHasManyLocalKeys - * @method - * @return {*} - */ - makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) { - var localKeys = []; - var itemKeys = jsData.utils.get(record, def.localKeys) || []; - itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); - localKeys = localKeys.concat(itemKeys); - return unique(localKeys).filter(function (x) { - return x; - }); - }, - - - /** - * Return the foreignKeys from the given record for the provided relationship. - * - * Override with care. - * - * @name Adapter#makeHasManyForeignKeys - * @method - * @return {*} - */ - makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) { - return jsData.utils.get(record, mapper.idAttribute); - }, - - - /** - * Return the foreignKey from the given record for the provided relationship. - * - * Override with care. - * - * @name Adapter#makeBelongsToForeignKey - * @method - * @return {*} - */ - makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) { - return def.getForeignKey(record); - }, - - - /** - * Retrieve sum of the specified field of the records that match the selection - * query. Called by `Mapper#sum`. - * - * @name Adapter#sum - * @method - * @param {Object} mapper The mapper. - * @param {string} field By to sum. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - sum: function sum(mapper, field, query, opts) { - var _this12 = this; - - var op = void 0; - if (!jsData.utils.isString(field)) { - throw new Error('field must be a string!'); - } - query || (query = {}); - opts || (opts = {}); - - // beforeSum lifecycle hook - op = opts.op = 'beforeSum'; - return jsData.utils.resolve(this[op](mapper, field, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'sum'; - _this12.dbg(op, mapper, field, query, opts); - return jsData.utils.resolve(_this12._sum(mapper, field, query, opts)); - }).then(function (results) { - var _results8 = slicedToArray(results, 2); - - var data = _results8[0]; - var result = _results8[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = _this12.respond(response, opts); - - // afterSum lifecycle hook - op = opts.op = 'afterSum'; - return jsData.utils.resolve(_this12[op](mapper, field, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * @name Adapter#respond - * @method - * @param {Object} response Response object. - * @param {Object} opts Configuration options. - * return {Object} If `opts.raw == true` then return `response`, else return - * `response.data`. - */ - respond: function respond(response, opts) { - return this.getOpt('raw', opts) ? response : response.data; - }, - - - /** - * Apply the given update to the record with the specified primary key. Called - * by `Mapper#update`. - * - * @name Adapter#update - * @method - * @param {Object} mapper The mapper. - * @param {(string|number)} id The primary key of the record to be updated. - * @param {Object} props The update to apply to the record. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - update: function update(mapper, id, props, opts) { - var _this13 = this; - - props || (props = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdate lifecycle hook - op = opts.op = 'beforeUpdate'; - return jsData.utils.resolve(this[op](mapper, id, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = _props === undefined ? props : _props; - props = withoutRelations(mapper, props, opts); - op = opts.op = 'update'; - _this13.dbg(op, mapper, id, props, opts); - return jsData.utils.resolve(_this13._update(mapper, id, props, opts)); - }).then(function (results) { - var _results9 = slicedToArray(results, 2); - - var data = _results9[0]; - var result = _results9[1]; - - result || (result = {}); - var response = new Response(data, result, 'update'); - response.updated = data ? 1 : 0; - response = _this13.respond(response, opts); - - // afterUpdate lifecycle hook - op = opts.op = 'afterUpdate'; - return jsData.utils.resolve(_this13[op](mapper, id, props, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Apply the given update to all records that match the selection query. - * Called by `Mapper#updateAll`. - * - * @name Adapter#updateAll - * @method - * @param {Object} mapper The mapper. - * @param {Object} props The update to apply to the selected records. - * @param {Object} [query] Selection query. - * @param {Object} [query.where] Filtering criteria. - * @param {string|Array} [query.orderBy] Sorting criteria. - * @param {string|Array} [query.sort] Same as `query.sort`. - * @param {number} [query.limit] Limit results. - * @param {number} [query.skip] Offset results. - * @param {number} [query.offset] Same as `query.skip`. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - updateAll: function updateAll(mapper, props, query, opts) { - var _this14 = this; - - props || (props = {}); - query || (query = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdateAll lifecycle hook - op = opts.op = 'beforeUpdateAll'; - return jsData.utils.resolve(this[op](mapper, props, query, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = _props === undefined ? props : _props; - props = withoutRelations(mapper, props, opts); - op = opts.op = 'updateAll'; - _this14.dbg(op, mapper, props, query, opts); - return jsData.utils.resolve(_this14._updateAll(mapper, props, query, opts)); - }).then(function (results) { - var _results10 = slicedToArray(results, 2); - - var data = _results10[0]; - var result = _results10[1]; - - data || (data = []); - result || (result = {}); - var response = new Response(data, result, 'updateAll'); - response.updated = data.length; - response = _this14.respond(response, opts); - - // afterUpdateAll lifecycle hook - op = opts.op = 'afterUpdateAll'; - return jsData.utils.resolve(_this14[op](mapper, props, query, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Update the given records in a single batch. Called by `Mapper#updateMany`. - * - * @name Adapter#updateMany - * @method - * @param {Object} mapper The mapper. - * @param {Object[]} records The records to update. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] Whether to return a more detailed - * response object. - * @return {Promise} - */ - updateMany: function updateMany(mapper, records, opts) { - var _this15 = this; - - records || (records = []); - opts || (opts = {}); - var op = void 0; - var idAttribute = mapper.idAttribute; - - records = records.filter(function (record) { - return jsData.utils.get(record, idAttribute); - }); - // beforeUpdateMany lifecycle hook - op = opts.op = 'beforeUpdateMany'; - return jsData.utils.resolve(this[op](mapper, records, opts)).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = _records === undefined ? records : _records; - records = records.map(function (record) { - return withoutRelations(mapper, record, opts); - }); - op = opts.op = 'updateMany'; - _this15.dbg(op, mapper, records, opts); - return jsData.utils.resolve(_this15._updateMany(mapper, records, opts)); - }).then(function (results) { - var _results11 = slicedToArray(results, 2); - - var data = _results11[0]; - var result = _results11[1]; - - data || (data = []); - result || (result = {}); - var response = new Response(data, result, 'updateMany'); - response.updated = data.length; - response = _this15.respond(response, opts); - - // afterUpdateMany lifecycle hook - op = opts.op = 'afterUpdateMany'; - return jsData.utils.resolve(_this15[op](mapper, records, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - } - }); - var axios = undefined; - var hasFetch = false; - try { - hasFetch = window && window.fetch; - } catch (e) {} - function isValidString(value) { - return value != null && value !== ''; - } - function join(items, separator) { - separator || (separator = ''); - return items.filter(isValidString).join(separator); - } - function makePath() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - var result = join(args, '/'); - return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); - } - function encode(val) { - return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); - } - function buildUrl(url, params) { - if (!params) { - return url; - } - var parts = []; - jsData.utils.forOwn(params, function (val, key) { - if (val === null || typeof val === 'undefined') { - return; - } - if (!jsData.utils.isArray(val)) { - val = [val]; - } - val.forEach(function (v) { - if (toString.call(v) === '[object Date]') { - v = v.toISOString(); - } else if (jsData.utils.isObject(v)) { - v = jsData.utils.toJson(v); - } - parts.push(encode(key) + '=' + encode(v)); - }); - }); - if (parts.length > 0) { - url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); +var slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } } - return url; + return _arr; } - var DEFAULTS = { - /** - * Set a base path in order to use absolute URLs instead of relative URLs. - * - * @example - * const httpAdapter = new HttpAdapter({ - * basePath: 'https://mydomain.com' - * }); - * - * @name HttpAdapter#basePath - * @type {string} - * @since 3.0.0 - */ - basePath: '', - - /** - * Ensure that the request url has a trailing forward slash. - * - * @name HttpAdapter#forceTrailingSlash - * @type {boolean} - * @default false - * @since 3.0.0 - */ - forceTrailingSlash: false, - - /** - * The HTTP function that actually makes the HTTP request. By default this is - * `axios`. - * - * @name HttpAdapter#http - * @type {function} - * @since 3.0.0 - * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library - */ - http: axios, - - /** - * Default configuration options to be mixed into the `config` argument passed - * to {@link HttpAdapter#http}. - * - * @name HttpAdapter#httpConfig - * @type {object} - * @since 3.0.0 - */ - httpConfig: {}, - - /** - * Add a suffix to the request url, e.g. ".json". - * - * @name HttpAdapter#suffix - * @type {string} - * @since 3.0.0 - */ - suffix: '', - - /** - * Use `window.fetch` if available. - * - * @name HttpAdapter#useFetch - * @type {boolean} - * @default false - * @since 3.0.0 - * @see http://www.js-data.io/docs/js-data-http#using-windowfetch - */ - useFetch: false + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } }; +}(); - /** - * HttpAdapter class. - * - * @example - * import { DataStore } from 'js-data'; - * import { HttpAdapter } from 'js-data-http'; - * - * const httpAdapter = new HttpAdapter(); - * const store = new DataStore(); - * - * store.registerAdapter('http', httpAdapter, { 'default': true }); - * - * store.defineMapper('school'); - * store.defineMapper('student'); - * - * // GET /school/1 - * store.find('school', 1).then((school) => { - * console.log('school'); - * }); - * - * @class HttpAdapter - * @extends Adapter - * @param {object} [opts] Configuration options. - * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}. - * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}. - * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}. - * @param {object} [opts.http=axios] See {@link HttpAdapter#http}. - * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}. - * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}. - * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}. - * @see http://www.js-data.io/docs/js-data-http - */ - function HttpAdapter(opts) { - jsData.utils.classCallCheck(this, HttpAdapter); - - opts || (opts = {}); - // Fill in any missing options with the defaults - jsData.utils.fillIn(opts, DEFAULTS); - Adapter.call(this, opts); +var noop = function noop() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - /** - * @name module:js-data-http.HttpAdapter - * @see HttpAdapter - */ - - Adapter.extend({ - constructor: HttpAdapter, - - /** - * @name HttpAdapter#afterDEL - * @method - * @param {string} url - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterDEL: noop2, - - /** - * @name HttpAdapter#afterGET - * @method - * @param {string} url - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterGET: noop2, - - /** - * @name HttpAdapter#afterHTTP - * @method - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterHTTP: noop2, - - /** - * @name HttpAdapter#afterPOST - * @method - * @param {string} url - * @param {object} data - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterPOST: noop2, - - /** - * @name HttpAdapter#afterPUT - * @method - * @param {string} url - * @param {object} data - * @param {object} config - * @param {object} opts - * @param {object} response - */ - afterPUT: noop2, - - /** - * @name HttpAdapter#beforeDEL - * @method - * @param {object} url - * @param {object} config - * @param {object} opts - */ - beforeDEL: noop, - - /** - * @name HttpAdapter#beforeGET - * @method - * @param {object} url - * @param {object} config - * @param {object} opts - */ - beforeGET: noop, - - /** - * @name HttpAdapter#beforeHTTP - * @method - * @param {object} config - * @param {object} opts - */ - beforeHTTP: noop, - - /** - * @name HttpAdapter#beforePOST - * @method - * @param {object} url - * @param {object} data - * @param {object} config - * @param {object} opts - */ - beforePOST: noop, - - /** - * @name HttpAdapter#beforePUT - * @method - * @param {object} url - * @param {object} data - * @param {object} config - * @param {object} opts - */ - beforePUT: noop, - - _count: function _count(mapper, query, opts) { - var _this = this; - - return this.GET(this.getPath('count', mapper, opts.params, opts), opts).then(function (response) { - return _this._end(mapper, opts, response); - }); - }, - _create: function _create(mapper, props, opts) { - var _this2 = this; + var opts = args[args.length - 1]; + this.dbg.apply(this, [opts.op].concat(args)); + return jsData.utils.resolve(); +}; - return this.POST(this.getPath('create', mapper, props, opts), this.serialize(mapper, props, opts), opts).then(function (response) { - return _this2._end(mapper, opts, response); - }); - }, - _createMany: function _createMany(mapper, props, opts) { - var _this3 = this; +var noop2 = function noop2() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } - return this.POST(this.getPath('createMany', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { - return _this3._end(mapper, opts, response); - }); - }, - _destroy: function _destroy(mapper, id, opts) { - var _this4 = this; + var opts = args[args.length - 2]; + this.dbg.apply(this, [opts.op].concat(args)); + return jsData.utils.resolve(); +}; - return this.DEL(this.getPath('destroy', mapper, id, opts), opts).then(function (response) { - return _this4._end(mapper, opts, response); - }); - }, - _destroyAll: function _destroyAll(mapper, query, opts) { - var _this5 = this; +var unique = function unique(array) { + var seen = {}; + var final = []; + array.forEach(function (item) { + if (item in seen) { + return; + } + final.push(item); + seen[item] = 0; + }); + return final; +}; - return this.DEL(this.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { - return _this5._end(mapper, opts, response); - }); - }, - _end: function _end(mapper, opts, response) { - return [this.deserialize(mapper, response, opts), response]; - }, - _find: function _find(mapper, id, opts) { - var _this6 = this; - - return this.GET(this.getPath('find', mapper, id, opts), opts).then(function (response) { - return _this6._end(mapper, opts, response); - }); - }, - _findAll: function _findAll(mapper, query, opts) { - var _this7 = this; +var withoutRelations = function withoutRelations(mapper, props, opts) { + opts || (opts = {}); + opts.with || (opts.with = []); + var relationFields = mapper.relationFields || []; + var toStrip = relationFields.filter(function (value) { + return opts.with.indexOf(value) === -1; + }); + return jsData.utils.omit(props, toStrip); +}; - return this.GET(this.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { - return _this7._end(mapper, opts, response); - }); - }, - _sum: function _sum(mapper, field, query, opts) { - var _this8 = this; - return this.GET(this.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { - return _this8._end(mapper, opts, response); - }); - }, - _update: function _update(mapper, id, props, opts) { - var _this9 = this; - return this.PUT(this.getPath('update', mapper, id, opts), this.serialize(mapper, props, opts), opts).then(function (response) { - return _this9._end(mapper, opts, response); - }); - }, - _updateAll: function _updateAll(mapper, props, query, opts) { - var _this10 = this; +/** + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @class Response + */ +function Response(data, meta, op) { + meta || (meta = {}); - return this.PUT(this.getPath('updateAll', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { - return _this10._end(mapper, opts, response); - }); - }, - _updateMany: function _updateMany(mapper, records, opts) { - var _this11 = this; + /** + * Response data. + * + * @name Response#data + * @type {*} + */ + this.data = data; - return this.PUT(this.getPath('updateMany', mapper, null, opts), this.serialize(mapper, records, opts), opts).then(function (response) { - return _this11._end(mapper, opts, response); - }); - }, - - - /** - * Retrieve the number of records that match the selection `query`. - * - * @name HttpAdapter#count - * @method - * @param {object} mapper The mapper. - * @param {object} query Selection query. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - count: function count(mapper, query, opts) { - query || (query = {}); - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params.count = true; - opts.suffix = this.getSuffix(mapper, opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - return Adapter.prototype.count.call(this, mapper, query, opts); - }, - - - /** - * Create a new the record from the provided `props`. - * - * @name HttpAdapter#create - * @method - * @param {object} mapper The mapper. - * @param {object} props Properties to send as the payload. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - create: function create(mapper, props, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.create.call(this, mapper, props, opts); - }, - - - /** - * Create multiple new records in batch. - * - * @name HttpAdapter#createMany - * @method - * @param {object} mapper The mapper. - * @param {array} props Array of property objects to send as the payload. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - createMany: function createMany(mapper, props, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.createMany.call(this, mapper, props, opts); - }, - - - /** - * Make an Http request to `url` according to the configuration in `config`. - * - * @name HttpAdapter#DEL - * @method - * @param {string} url Url for the request. - * @param {object} [config] Http configuration that will be passed to - * {@link HttpAdapter#HTTP}. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - DEL: function DEL(url, config, opts) { - var _this12 = this; - - var op = void 0; - config || (config = {}); - opts || (opts = {}); - config.url = url || config.url; - config.method = config.method || 'delete'; - - // beforeDEL lifecycle hook - op = opts.op = 'beforeDEL'; - return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _config === undefined ? config : _config; - op = opts.op = 'DEL'; - _this12.dbg(op, url, config, opts); - return _this12.HTTP(config, opts); - }).then(function (response) { - // afterDEL lifecycle hook - op = opts.op = 'afterDEL'; - return jsData.utils.resolve(_this12[op](url, config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Transform the server response object into the payload that will be returned - * to JSData. - * - * @name HttpAdapter#deserialize - * @method - * @param {object} mapper The mapper used for the operation. - * @param {object} response Response object from {@link HttpAdapter#HTTP}. - * @param {object} opts Configuration options. - * @return {(object|array)} Deserialized data. - */ - deserialize: function deserialize(mapper, response, opts) { - opts || (opts = {}); - if (jsData.utils.isFunction(opts.deserialize)) { - return opts.deserialize(mapper, response, opts); - } - if (jsData.utils.isFunction(mapper.deserialize)) { - return mapper.deserialize(mapper, response, opts); - } - if (response && response.hasOwnProperty('data')) { - return response.data; - } - return response; - }, - - - /** - * Destroy the record with the given primary key. - * - * @name HttpAdapter#destroy - * @method - * @param {object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to destroy. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - destroy: function destroy(mapper, id, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.destroy.call(this, mapper, id, opts); - }, - - - /** - * Destroy the records that match the selection `query`. - * - * @name HttpAdapter#destroyAll - * @method - * @param {object} mapper The mapper. - * @param {object} query Selection query. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - destroyAll: function destroyAll(mapper, query, opts) { - query || (query = {}); - opts || (opts = {}); - opts.params = this.getParams(opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.destroyAll.call(this, mapper, query, opts); - }, - - - /** - * Log an error. - * - * @name HttpAdapter#error - * @method - * @param {...*} [args] Arguments to log. - */ - error: function error() { - if (console) { - var _console; - - (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); - } - }, - - - /** - * Make an Http request using `window.fetch`. - * - * @name HttpAdapter#fetch - * @method - * @param {object} config Request configuration. - * @param {object} config.data Payload for the request. - * @param {string} config.method Http method for the request. - * @param {object} config.headers Headers for the request. - * @param {object} config.params Querystring for the request. - * @param {string} config.url Url for the request. - */ - fetch: function (_fetch) { - function fetch(_x) { - return _fetch.apply(this, arguments); - } + jsData.utils.fillIn(this, meta); - fetch.toString = function () { - return _fetch.toString(); - }; + /** + * The operation for which the response was created. + * + * @name Response#op + * @type {string} + */ + this.op = op; +} - return fetch; - }(function (config) { - var requestConfig = { - method: config.method, - // turn the plain headers object into the Fetch Headers object - headers: new Headers(config.headers || {}) - }; +var DEFAULTS$1 = { + /** + * Whether to log debugging information. + * + * @name Adapter#debug + * @type {boolean} + * @default false + */ + debug: false, - if (config.data) { - requestConfig.body = jsData.utils.toJson(config.data); - } + /** + * Whether to return a more detailed response object. + * + * @name Adapter#raw + * @type {boolean} + * @default false + */ + raw: false - return fetch(buildUrl(config.url, config.params), requestConfig).then(function (response) { - response.config = { - method: config.method, - url: config.url - }; - return response.json().then(function (data) { - response.data = data; - return response; - }); - }); - }), - - - /** - * Retrieve the record with the given primary key. - * - * @name HttpAdapter#find - * @method - * @param {object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to retrieve. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - find: function find(mapper, id, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.find.call(this, mapper, id, opts); - }, - - - /** - * Retrieve the records that match the selection `query`. - * - * @name HttpAdapter#findAll - * @method - * @param {object} mapper The mapper. - * @param {object} query Selection query. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - findAll: function findAll(mapper, query, opts) { - query || (query = {}); - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.suffix = this.getSuffix(mapper, opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - return Adapter.prototype.findAll.call(this, mapper, query, opts); - }, - - - /** - * Make a GET request. - * - * @name HttpAdapter#GET - * @method - * @param {string} url The url for the request. - * @param {object} config Request configuration options. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - GET: function GET(url, config, opts) { - var _this13 = this; - - var op = void 0; - config || (config = {}); - opts || (opts = {}); - config.url = url || config.url; - config.method = config.method || 'get'; - - // beforeGET lifecycle hook - op = opts.op = 'beforeGET'; - return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _config === undefined ? config : _config; - op = opts.op = 'GET'; - _this13.dbg(op, url, config, opts); - return _this13.HTTP(config, opts); - }).then(function (response) { - // afterGET lifecycle hook - op = opts.op = 'afterGET'; - return jsData.utils.resolve(_this13[op](url, config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * @name HttpAdapter#getEndpoint - * @method - * @param {object} mapper The Mapper. - * @param {*} id The primary key, if any. - * @param {boolean} opts Configuration options. - * @return {string} Full path. - */ - getEndpoint: function getEndpoint(mapper, id, opts) { - var _this14 = this; - - opts || (opts = {}); - opts.params = jsData.utils.isUndefined(opts.params) ? {} : opts.params; - var relationList = mapper.relationList || []; - var endpoint = jsData.utils.isUndefined(opts.endpoint) ? jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; - - relationList.forEach(function (def) { - if (def.type !== 'belongsTo' || !def.parent) { - return; - } - var item = void 0; - var parentKey = def.foreignKey; - var parentDef = def.getRelation(); - var parentId = opts.params[parentKey]; - - if (parentId === false || !parentKey || !parentDef) { - if (parentId === false) { - delete opts.params[parentKey]; - } - return false; - } else { - delete opts.params[parentKey]; + /** + * Abstract class meant to be extended by adapters. + * + * @class Adapter + * @abstract + * @extends Component + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.debug=false] Whether to log debugging information. + * @param {boolean} [opts.raw=false] Whether to return a more detailed response + * object. + */ +};function Adapter(opts) { + jsData.utils.classCallCheck(this, Adapter); + jsData.Component.call(this, opts); + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS$1); + jsData.utils.fillIn(this, opts); +} - if (jsData.utils.isObject(id)) { - item = id; - } +jsData.Component.extend({ + constructor: Adapter, - if (item) { - parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); - } + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#afterCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} props The `props` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `afterCount` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterCount: noop2, - if (parentId) { - var _ret = function () { - delete opts.endpoint; - var _opts = {}; - jsData.utils.forOwn(opts, function (value, key) { - _opts[key] = value; - }); - jsData.utils._(_opts, parentDef); - endpoint = makePath(_this14.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); - return { - v: false - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `afterCreate` + * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreate: noop2, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `afterCreateMany` + * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreateMany: noop2, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#afterDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `afterDestroy` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroy: noop2, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#afterDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `afterDestroyAll` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroyAll: noop2, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#afterFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `afterFind` + * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`. + */ + afterFind: noop2, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#afterFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `afterFindAll` + * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`. + */ + afterFindAll: noop2, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#afterSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {string} field The `field` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `afterSum` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterSum: noop2, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#afterUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `afterUpdate` + * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdate: noop2, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#afterUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `afterUpdateAll` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateAll: noop2, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#afterUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} records The `records` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `afterUpdateMany` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateMany: noop2, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#beforeCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} query The `query` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `beforeCount` + */ + beforeCount: noop, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#beforeCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `beforeCreate` + */ + beforeCreate: noop, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#beforeCreateMany + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `beforeCreateMany` + */ + beforeCreateMany: noop, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#beforeDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `beforeDestroy` + */ + beforeDestroy: noop, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#beforeDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `beforeDestroyAll` + */ + beforeDestroyAll: noop, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#beforeFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `beforeFind` + */ + beforeFind: noop, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#beforeFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `beforeFindAll` + */ + beforeFindAll: noop, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#beforeSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `beforeSum` + */ + beforeSum: noop, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#beforeUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `beforeUpdate` + */ + beforeUpdate: noop, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#beforeUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `beforeUpdateAll` + */ + beforeUpdateAll: noop, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#beforeUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} props The `props` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `beforeUpdateMany` + */ + beforeUpdateMany: noop, + + /** + * Retrieve the number of records that match the selection query. Called by + * `Mapper#count`. + * + * @name Adapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var _this = this; + + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + _this.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this._count(mapper, query, opts)); + }).then(function (results) { + var _results = slicedToArray(results, 2), + data = _results[0], + result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = _this.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(_this[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Create a new record. Called by `Mapper#create`. + * + * @name Adapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var _this2 = this; + + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'create'; + _this2.dbg(op, mapper, props, opts); + return jsData.utils.resolve(_this2._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = slicedToArray(results, 2), + data = _results2[0], + result = _results2[1]; + + result || (result = {}); + var response = new Response(data, result, 'create'); + response.created = data ? 1 : 0; + response = _this2.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(_this2[op](mapper, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Create multiple records in a single batch. Called by `Mapper#createMany`. + * + * @name Adapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var _this3 = this; + + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record, opts); + }); + op = opts.op = 'createMany'; + _this3.dbg(op, mapper, props, opts); + return jsData.utils.resolve(_this3._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = slicedToArray(results, 2), + data = _results3[0], + result = _results3[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'createMany'); + response.created = data.length; + response = _this3.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(_this3[op](mapper, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Destroy the record with the given primary key. Called by + * `Mapper#destroy`. + * + * @name Adapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var _this4 = this; + + var op = void 0; + opts || (opts = {}); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + _this4.dbg(op, mapper, id, opts); + return jsData.utils.resolve(_this4._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = slicedToArray(results, 2), + data = _results4[0], + result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = _this4.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(_this4[op](mapper, id, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Destroy the records that match the selection query. Called by + * `Mapper#destroyAll`. + * + * @name Adapter#destroyAll + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var _this5 = this; + + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + _this5.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this5._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = slicedToArray(results, 2), + data = _results5[0], + result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = _this5.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(_this5[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo + * @method + * @return {Promise} + */ + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { + var _this6 = this; + + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var record = records; + return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }); + } else { + var keys = records.map(function (record) { + return _this6.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return this.findAll(relationDef, { + where: defineProperty({}, relationDef.idAttribute, { + 'in': keys + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (record) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { + def.setLocalField(record, relatedItem); + } + }); + }); + }); + } + }, + + + /** + * Retrieve the record with the given primary key. Called by `Mapper#find`. + * + * @name Adapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var _this7 = this; + + var op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + _this7.dbg(op, mapper, id, opts); + return jsData.utils.resolve(_this7._find(mapper, id, opts)); + }).then(function (results) { + return _this7.loadRelationsFor(mapper, results, opts); + }).then(function (_ref) { + var _ref2 = slicedToArray(_ref, 2), + record = _ref2[0], + meta = _ref2[1]; + + var response = new Response(record, meta, 'find'); + response.found = record ? 1 : 0; + response = _this7.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(_this7[op](mapper, id, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Retrieve the records that match the selection query. + * + * @name Adapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var _this8 = this; + + var op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + var activeWith = opts._activeWith; + + if (jsData.utils.isObject(activeWith)) { + var activeQuery = activeWith.query || {}; + if (activeWith.replace) { + query = activeQuery; + } else { + jsData.utils.deepFillIn(query, activeQuery); + } + } + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + _this8.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this8._findAll(mapper, query, opts)); + }).then(function (results) { + return _this8.loadRelationsFor(mapper, results, opts); + }).then(function (_ref3) { + var _ref4 = slicedToArray(_ref3, 2), + records = _ref4[0], + meta = _ref4[1]; + + var response = new Response(records, meta, 'findAll'); + response.found = records.length; + response = _this8.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(_this8[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + loadRelationsFor: function loadRelationsFor(mapper, results, opts) { + var _this9 = this; + + var _results6 = slicedToArray(results, 1), + records = _results6[0]; + + var tasks = []; + + if (records) { + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasOne') { + task = _this9.loadHasOne(mapper, def, records, __opts); + } else { + task = _this9.loadHasMany(mapper, def, records, __opts); } + } else if (def.type === 'hasMany' && def.localKeys) { + task = _this9.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = _this9.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = _this9.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } + }); + } + + return jsData.utils.Promise.all(tasks).then(function () { + return results; + }); + }, + + + /** + * Resolve the value of the specified option based on the given options and + * this adapter's settings. Override with care. + * + * @name Adapter#getOpt + * @method + * @param {string} opt The name of the option. + * @param {Object} [opts] Configuration options. + * @return {*} The value of the specified option. + */ + getOpt: function getOpt(opt, opts) { + opts || (opts = {}); + return opts[opt] === undefined ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); + }, + + + /** + * Load a hasMany relationship. + * + * Override with care. + * + * @name Adapter#loadHasMany + * @method + * @return {Promise} + */ + loadHasMany: function loadHasMany(mapper, def, records, __opts) { + var _this10 = this; + + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return _this10.makeHasManyForeignKey(mapper, def, record); + }); + var query = { + where: {} + }; + var criteria = query.where[def.foreignKey] = {}; + if (singular) { + // more efficient query when we only have one record + criteria['=='] = IDs[0]; + } else { + criteria['in'] = IDs.filter(function (id) { + return id; + }); + } + return this.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { + records.forEach(function (record) { + var attached = []; + // avoid unneccesary iteration when we only have one record + if (singular) { + attached = relatedItems; + } else { + relatedItems.forEach(function (relatedItem) { + if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { + attached.push(relatedItem); + } + }); + } + def.setLocalField(record, attached); + }); + }); + }, + loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { + var _this11 = this; + + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return this.findAll(relatedMapper, { + where: defineProperty({}, relatedMapper.idAttribute, { + 'in': this.makeHasManyLocalKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + var localKeys = []; + records.forEach(function (record) { + localKeys = localKeys.concat(_this11.makeHasManyLocalKeys(mapper, def, record)); + }); + return this.findAll(relatedMapper, { + where: defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + var itemKeys = jsData.utils.get(item, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem); + } + }); + def.setLocalField(item, attached); + }); + return relatedItems; + }); + } + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var _this12 = this; + + var relatedMapper = def.getRelation(); + var idAttribute = mapper.idAttribute; + var record = void 0; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return this.findAll(def.getRelation(), { + where: defineProperty({}, def.foreignKeys, { + 'contains': this.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return this.findAll(relatedMapper, { + where: defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return _this12.makeHasManyForeignKeys(mapper, def, record); + }) + }) + }, __opts).then(function (relatedItems) { + var foreignKeysField = def.foreignKeys; + records.forEach(function (record) { + var _relatedItems = []; + var id = jsData.utils.get(record, idAttribute); + relatedItems.forEach(function (relatedItem) { + var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; + if (foreignKeys.indexOf(id) !== -1) { + _relatedItems.push(relatedItem); + } + }); + def.setLocalField(record, _relatedItems); + }); + }); + } + }, + + + /** + * Load a hasOne relationship. + * + * Override with care. + * + * @name Adapter#loadHasOne + * @method + * @return {Promise} + */ + loadHasOne: function loadHasOne(mapper, def, records, __opts) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + records = [records]; + } + return this.loadHasMany(mapper, def, records, __opts).then(function () { + records.forEach(function (record) { + var relatedData = def.getLocalField(record); + if (jsData.utils.isArray(relatedData) && relatedData.length) { + def.setLocalField(record, relatedData[0]); } }); + }); + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * There may be reasons why you may want to override this method, like when + * the id of the parent doesn't exactly match up to the key on the child. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKey + * @method + * @return {*} + */ + makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Return the localKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyLocalKeys + * @method + * @return {*} + */ + makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) { + var localKeys = []; + var itemKeys = jsData.utils.get(record, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + localKeys = localKeys.concat(itemKeys); + return unique(localKeys).filter(function (x) { + return x; + }); + }, + + + /** + * Return the foreignKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKeys + * @method + * @return {*} + */ + makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) { + return jsData.utils.get(record, mapper.idAttribute); + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeBelongsToForeignKey + * @method + * @return {*} + */ + makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Retrieve sum of the specified field of the records that match the selection + * query. Called by `Mapper#sum`. + * + * @name Adapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field By to sum. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var _this13 = this; + + var op = void 0; + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + query || (query = {}); + opts || (opts = {}); + + // beforeSum lifecycle hook + op = opts.op = 'beforeSum'; + return jsData.utils.resolve(this[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + _this13.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(_this13._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results7 = slicedToArray(results, 2), + data = _results7[0], + result = _results7[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = _this13.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(_this13[op](mapper, field, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * @name Adapter#respond + * @method + * @param {Object} response Response object. + * @param {Object} opts Configuration options. + * return {Object} If `opts.raw == true` then return `response`, else return + * `response.data`. + */ + respond: function respond(response, opts) { + return this.getOpt('raw', opts) ? response : response.data; + }, + + + /** + * Apply the given update to the record with the specified primary key. Called + * by `Mapper#update`. + * + * @name Adapter#update + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id The primary key of the record to be updated. + * @param {Object} props The update to apply to the record. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var _this14 = this; + + props || (props = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(this[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'update'; + _this14.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(_this14._update(mapper, id, props, opts)); + }).then(function (results) { + var _results8 = slicedToArray(results, 2), + data = _results8[0], + result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, 'update'); + response.updated = data ? 1 : 0; + response = _this14.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(_this14[op](mapper, id, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Apply the given update to all records that match the selection query. + * Called by `Mapper#updateAll`. + * + * @name Adapter#updateAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var _this15 = this; + + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(this[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'updateAll'; + _this15.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(_this15._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results9 = slicedToArray(results, 2), + data = _results9[0], + result = _results9[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateAll'); + response.updated = data.length; + response = _this15.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(_this15[op](mapper, props, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Update the given records in a single batch. Called by `Mapper#updateMany`. + * + * @name Adapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var _this16 = this; + + records || (records = []); + opts || (opts = {}); + var op = void 0; + var idAttribute = mapper.idAttribute; + + records = records.filter(function (record) { + return jsData.utils.get(record, idAttribute); + }); + + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return jsData.utils.resolve(this[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = _records === undefined ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record, opts); + }); + op = opts.op = 'updateMany'; + _this16.dbg(op, mapper, records, opts); + return jsData.utils.resolve(_this16._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results10 = slicedToArray(results, 2), + data = _results10[0], + result = _results10[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateMany'); + response.updated = data.length; + response = _this16.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(_this16[op](mapper, records, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + } +}); + +/** + * Create a subclass of this Adapter: + * + * @example Adapter.extend + * // Normally you would do: import {Adapter} from 'js-data' + * const JSData = require('js-data@3.0.0-beta.10') + * const {Adapter} = JSData + * console.log('Using JSData v' + JSData.version.full) + * + * // Extend the class using ES2015 class syntax. + * class CustomAdapterClass extends Adapter { + * foo () { return 'bar' } + * static beep () { return 'boop' } + * } + * const customAdapter = new CustomAdapterClass() + * console.log(customAdapter.foo()) + * console.log(CustomAdapterClass.beep()) + * + * // Extend the class using alternate method. + * const OtherAdapterClass = Adapter.extend({ + * foo () { return 'bar' } + * }, { + * beep () { return 'boop' } + * }) + * const otherAdapter = new OtherAdapterClass() + * console.log(otherAdapter.foo()) + * console.log(OtherAdapterClass.beep()) + * + * // Extend the class, providing a custom constructor. + * function AnotherAdapterClass () { + * Adapter.call(this) + * this.created_at = new Date().getTime() + * } + * Adapter.extend({ + * constructor: AnotherAdapterClass, + * foo () { return 'bar' } + * }, { + * beep () { return 'boop' } + * }) + * const anotherAdapter = new AnotherAdapterClass() + * console.log(anotherAdapter.created_at) + * console.log(anotherAdapter.foo()) + * console.log(AnotherAdapterClass.beep()) + * + * @method Adapter.extend + * @param {Object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {Object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {Object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this Adapter class. + */ + +var axios = undefined; +var hasFetch = false; + +try { + hasFetch = window && window.fetch; +} catch (e) {} + +function isValidString(value) { + return value != null && value !== ''; +} +function join(items, separator) { + separator || (separator = ''); + return items.filter(isValidString).join(separator); +} +function makePath() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var result = join(args, '/'); + return result.replace(/([^:/]|^)\/{2,}/g, '$1/'); +} + +function encode(val) { + return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); +} + +function buildUrl(url, params) { + if (!params) { + return url; + } + + var parts = []; + + jsData.utils.forOwn(params, function (val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + if (!jsData.utils.isArray(val)) { + val = [val]; + } + + val.forEach(function (v) { + if (toString.call(v) === '[object Date]') { + v = v.toISOString(); + } else if (jsData.utils.isObject(v)) { + v = jsData.utils.toJson(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; +} + +var DEFAULTS = { + /** + * Set a base path in order to use absolute URLs instead of relative URLs. + * + * @example + * const httpAdapter = new HttpAdapter({ + * basePath: 'https://mydomain.com' + * }); + * + * @name HttpAdapter#basePath + * @type {string} + * @since 3.0.0 + */ + basePath: '', + + /** + * Ensure that the request url has a trailing forward slash. + * + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + * @since 3.0.0 + */ + forceTrailingSlash: false, + + hasFetch: hasFetch, + + /** + * The HTTP function that actually makes the HTTP request. By default this is + * `axios`. + * + * @name HttpAdapter#http + * @type {function} + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library + */ + http: axios, + + /** + * Default configuration options to be mixed into the `config` argument passed + * to {@link HttpAdapter#http}. + * + * @name HttpAdapter#httpConfig + * @type {object} + * @since 3.0.0 + */ + httpConfig: {}, + + /** + * Add a suffix to the request url, e.g. ".json". + * + * @name HttpAdapter#suffix + * @type {string} + * @since 3.0.0 + */ + suffix: '', + + /** + * Use `window.fetch` if available. + * + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-windowfetch + */ + useFetch: false + + /** + * HttpAdapter class. + * + * @example + * import { DataStore } from 'js-data'; + * import { HttpAdapter } from 'js-data-http'; + * + * const httpAdapter = new HttpAdapter(); + * const store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * + * store.defineMapper('school'); + * store.defineMapper('student'); + * + * // GET /school/1 + * store.find('school', 1).then((school) => { + * console.log('school'); + * }); + * + * @class HttpAdapter + * @extends Adapter + * @param {object} [opts] Configuration options. + * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}. + * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}. + * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}. + * @param {object} [opts.http=axios] See {@link HttpAdapter#http}. + * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}. + * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}. + * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}. + * @see http://www.js-data.io/docs/js-data-http + */ +};function HttpAdapter(opts) { + jsData.utils.classCallCheck(this, HttpAdapter); + + opts || (opts = {}); + // Fill in any missing options with the defaults + jsData.utils.fillIn(opts, DEFAULTS); + Adapter.call(this, opts); +} + +/** + * @name module:js-data-http.HttpAdapter + * @see HttpAdapter + */ + +Adapter.extend({ + constructor: HttpAdapter, + + /** + * @name HttpAdapter#afterDEL + * @method + * @param {string} url + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterDEL: noop2, + + /** + * @name HttpAdapter#afterGET + * @method + * @param {string} url + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterGET: noop2, + + /** + * @name HttpAdapter#afterHTTP + * @method + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterHTTP: noop2, + + /** + * @name HttpAdapter#afterPOST + * @method + * @param {string} url + * @param {object} data + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterPOST: noop2, + + /** + * @name HttpAdapter#afterPUT + * @method + * @param {string} url + * @param {object} data + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterPUT: noop2, + + /** + * @name HttpAdapter#beforeDEL + * @method + * @param {object} url + * @param {object} config + * @param {object} opts + */ + beforeDEL: noop, + + /** + * @name HttpAdapter#beforeGET + * @method + * @param {object} url + * @param {object} config + * @param {object} opts + */ + beforeGET: noop, + + /** + * @name HttpAdapter#beforeHTTP + * @method + * @param {object} config + * @param {object} opts + */ + beforeHTTP: noop, + + /** + * @name HttpAdapter#beforePOST + * @method + * @param {object} url + * @param {object} data + * @param {object} config + * @param {object} opts + */ + beforePOST: noop, + + /** + * @name HttpAdapter#beforePUT + * @method + * @param {object} url + * @param {object} data + * @param {object} config + * @param {object} opts + */ + beforePUT: noop, + + _count: function _count(mapper, query, opts) { + var _this = this; + + return this.GET(this.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return _this._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var _this2 = this; + + return this.POST(this.getPath('create', mapper, props, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this2._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var _this3 = this; + + return this.POST(this.getPath('createMany', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this3._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var _this4 = this; + + return this.DEL(this.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return _this4._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var _this5 = this; + + return this.DEL(this.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return _this5._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var _this6 = this; + + return this.GET(this.getPath('find', mapper, id, opts), opts).then(function (response) { + return _this6._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var _this7 = this; + + return this.GET(this.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return _this7._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var _this8 = this; + + return this.GET(this.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return _this8._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var _this9 = this; + + return this.PUT(this.getPath('update', mapper, id, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this9._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var _this10 = this; + + return this.PUT(this.getPath('updateAll', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this10._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var _this11 = this; + + return this.PUT(this.getPath('updateMany', mapper, null, opts), this.serialize(mapper, records, opts), opts).then(function (response) { + return _this11._end(mapper, opts, response); + }); + }, + + + /** + * Retrieve the number of records that match the selection `query`. + * + * @name HttpAdapter#count + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params.count = true; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.count.call(this, mapper, query, opts); + }, + + + /** + * Create a new the record from the provided `props`. + * + * @name HttpAdapter#create + * @method + * @param {object} mapper The mapper. + * @param {object} props Properties to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.create.call(this, mapper, props, opts); + }, + + + /** + * Create multiple new records in batch. + * + * @name HttpAdapter#createMany + * @method + * @param {object} mapper The mapper. + * @param {array} props Array of property objects to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.createMany.call(this, mapper, props, opts); + }, + + + /** + * Make an Http request to `url` according to the configuration in `config`. + * + * @name HttpAdapter#DEL + * @method + * @param {string} url Url for the request. + * @param {object} [config] Http configuration that will be passed to + * {@link HttpAdapter#HTTP}. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + DEL: function DEL(url, config, opts) { + var _this12 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'delete'; + + // beforeDEL lifecycle hook + op = opts.op = 'beforeDEL'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'DEL'; + _this12.dbg(op, url, config, opts); + return _this12.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return jsData.utils.resolve(_this12[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the server response object into the payload that will be returned + * to JSData. + * + * @name HttpAdapter#deserialize + * @method + * @param {object} mapper The mapper used for the operation. + * @param {object} response Response object from {@link HttpAdapter#HTTP}. + * @param {object} opts Configuration options. + * @return {(object|array)} Deserialized data. + */ + deserialize: function deserialize(mapper, response, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.deserialize)) { + return opts.deserialize(mapper, response, opts); + } + if (jsData.utils.isFunction(mapper.deserialize)) { + return mapper.deserialize(mapper, response, opts); + } + if (response && response.hasOwnProperty('data')) { + return response.data; + } + return response; + }, + + + /** + * Destroy the record with the given primary key. + * + * @name HttpAdapter#destroy + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.destroy.call(this, mapper, id, opts); + }, + + + /** + * Destroy the records that match the selection `query`. + * + * @name HttpAdapter#destroyAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.destroyAll.call(this, mapper, query, opts); + }, + + + /** + * Log an error. + * + * @name HttpAdapter#error + * @method + * @param {...*} [args] Arguments to log. + */ + error: function error() { + if (console) { + var _console; + + (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); + } + }, + + + /** + * Make an Http request using `window.fetch`. + * + * @name HttpAdapter#fetch + * @method + * @param {object} config Request configuration. + * @param {object} config.data Payload for the request. + * @param {string} config.method Http method for the request. + * @param {object} config.headers Headers for the request. + * @param {object} config.params Querystring for the request. + * @param {string} config.url Url for the request. + */ + fetch: function (_fetch) { + function fetch(_x) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config) { + var requestConfig = { + method: config.method, + // turn the plain headers object into the Fetch Headers object + headers: new Headers(config.headers || {}) + }; + + if (config.data) { + requestConfig.body = jsData.utils.toJson(config.data); + } + + return fetch(buildUrl(config.url, config.params), requestConfig).then(function (response) { + response.config = { + method: config.method, + url: config.url + }; + return response.json().then(function (data) { + response.data = data; + return response; + }); + }); + }), - return endpoint; - }, - - - /** - * @name HttpAdapter#getPath - * @method - * @param {string} method The method being executed. - * @param {object} mapper The Mapper. - * @param {(string|number)?} id The primary key, if any. - * @param {object} opts Configuration options. - */ - getPath: function getPath(method, mapper, id, opts) { - opts || (opts = {}); - var args = [opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, this.getEndpoint(mapper, jsData.utils.isString(id) || jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; - if (method === 'find' || method === 'update' || method === 'destroy') { - args.push(id); - } - return makePath.apply(jsData.utils, args); - }, - getParams: function getParams(opts) { - opts || (opts = {}); - if (opts.params === undefined) { - return {}; + + /** + * Retrieve the record with the given primary key. + * + * @name HttpAdapter#find + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.find.call(this, mapper, id, opts); + }, + + + /** + * Retrieve the records that match the selection `query`. + * + * @name HttpAdapter#findAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.findAll.call(this, mapper, query, opts); + }, + + + /** + * Make a GET request. + * + * @name HttpAdapter#GET + * @method + * @param {string} url The url for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + GET: function GET(url, config, opts) { + var _this13 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'get'; + + // beforeGET lifecycle hook + op = opts.op = 'beforeGET'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'GET'; + _this13.dbg(op, url, config, opts); + return _this13.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return jsData.utils.resolve(_this13[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {object} mapper The Mapper. + * @param {*} id The primary key, if any. + * @param {boolean} opts Configuration options. + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var _this14 = this; + + opts || (opts = {}); + opts.params = jsData.utils.isUndefined(opts.params) ? {} : opts.params; + var relationList = mapper.relationList || []; + var endpoint = jsData.utils.isUndefined(opts.endpoint) ? jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; + + relationList.forEach(function (def) { + if (def.type !== 'belongsTo' || !def.parent) { + return; } - return jsData.utils.copy(opts.params); - }, - getSuffix: function getSuffix(mapper, opts) { - opts || (opts = {}); - if (opts.suffix === undefined) { - if (mapper.suffix === undefined) { - return this.suffix; + var item = void 0; + var parentKey = def.foreignKey; + var parentDef = def.getRelation(); + var parentId = opts.params[parentKey]; + + if (parentId === false || !parentKey || !parentDef) { + if (parentId === false) { + delete opts.params[parentKey]; } - return mapper.suffix; - } - return opts.suffix; - }, - - - /** - * Make an Http request. - * - * @name HttpAdapter#HTTP - * @method - * @param {object} config Request configuration options. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - HTTP: function HTTP(config, opts) { - var _this15 = this; - - var start = new Date(); - opts || (opts = {}); - var payload = config.data; - var cache = config.cache; - var timeout = config.timeout; - config = jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); - config = jsData.utils.deepMixIn(config, this.httpConfig); - config.data = payload; - config.cache = cache; - config.timeout = timeout; - if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { - config.url += '/'; - } - config.method = config.method.toUpperCase(); - var suffix = config.suffix || opts.suffix || this.suffix; - if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { - config.url += suffix; - } + return false; + } else { + delete opts.params[parentKey]; - var logResponse = function logResponse(data) { - var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; - if (data.status >= 200 && data.status < 300) { - if (_this15.log) { - _this15.dbg(str, data); - } - return data; - } else { - if (_this15.error) { - _this15.error('\'FAILED: ' + str, data); - } - return jsData.utils.reject(data); + if (jsData.utils.isObject(id)) { + item = id; } - }; - if (!this.http) { - throw new Error('You have not configured this adapter with an http library!'); - } + if (item) { + parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); + } - return jsData.utils.resolve(this.beforeHTTP(config, opts)).then(function (_config) { - config = _config || config; - if (hasFetch && (_this15.useFetch || opts.useFetch || !_this15.http)) { - return _this15.fetch(config, opts).then(logResponse, logResponse); + if (parentId) { + delete opts.endpoint; + var _opts = {}; + jsData.utils.forOwn(opts, function (value, key) { + _opts[key] = value; + }); + jsData.utils._(_opts, parentDef); + endpoint = makePath(_this14.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return false; } - return _this15.http(config).then(logResponse, logResponse).catch(function (err) { - return _this15.responseError(err, config, opts); - }); - }).then(function (response) { - return jsData.utils.resolve(_this15.afterHTTP(config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Make a POST request. - * - * @name HttpAdapter#POST - * @method - * @param {*} url The url for the request. - * @param {object} data Payload for the request. - * @param {object} config Request configuration options. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - POST: function POST(url, data, config, opts) { - var _this16 = this; - - var op = void 0; - config || (config = {}); - opts || (opts = {}); - config.url = url || config.url; - config.data = data || config.data; - config.method = config.method || 'post'; - - // beforePOST lifecycle hook - op = opts.op = 'beforePOST'; - return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _config === undefined ? config : _config; - op = opts.op = 'POST'; - _this16.dbg(op, url, data, config, opts); - return _this16.HTTP(config, opts); - }).then(function (response) { - // afterPOST lifecycle hook - op = opts.op = 'afterPOST'; - return jsData.utils.resolve(_this16[op](url, data, config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Make a PUT request. - * - * @name HttpAdapter#PUT - * @method - * @param {*} url The url for the request. - * @param {object} data Payload for the request. - * @param {object} config Request configuration options. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - PUT: function PUT(url, data, config, opts) { - var _this17 = this; - - var op = void 0; - config || (config = {}); - opts || (opts = {}); - config.url = url || config.url; - config.data = data || config.data; - config.method = config.method || 'put'; - - // beforePUT lifecycle hook - op = opts.op = 'beforePUT'; - return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _config === undefined ? config : _config; - op = opts.op = 'PUT'; - _this17.dbg(op, url, data, config, opts); - return _this17.HTTP(config, opts); - }).then(function (response) { - // afterPUT lifecycle hook - op = opts.op = 'afterPUT'; - return jsData.utils.resolve(_this17[op](url, data, config, opts, response)).then(function (_response) { - return _response === undefined ? response : _response; - }); - }); - }, - - - /** - * Transform the querystring object before it is serialized. This doesn't do - * anything by default. - * - * @name HttpAdapter#queryTransform - * @method - * @param {object} mapper The Mapper that triggered the request. - * @param {*} params The querystring object. - * @param {*} opts Configuration options - * @return {*} Transformed params. - */ - queryTransform: function queryTransform(mapper, params, opts) { - opts || (opts = {}); - if (jsData.utils.isFunction(opts.queryTransform)) { - return opts.queryTransform(mapper, params, opts); - } - if (jsData.utils.isFunction(mapper.queryTransform)) { - return mapper.queryTransform(mapper, params, opts); } - return params; - }, - - - /** - * Error handler invoked when the promise returned by {@link HttpAdapter#http} - * is rejected. Default implementation is to just return the error wrapped in - * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is - * called by {@link HttpAdapter#HTTP}. - * - * @name HttpAdapter#responseError - * @method - * @param {*} err The error that {@link HttpAdapter#http} rejected with. - * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. - * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. - * @return {Promise} - */ - responseError: function responseError(err, config, opts) { - return jsData.utils.reject(err); - }, - - - /** - * Serialize request data. This doesn't do anything by default. - * - * @name HttpAdapter#serialize - * @method - * @param {object} mapper The Mapper that triggered the request. - * @param {object} data The request payload. - * @param {*} opts Configuration options. - * @return {*} Serialized data. - */ - serialize: function serialize(mapper, data, opts) { - opts || (opts = {}); - if (jsData.utils.isFunction(opts.serialize)) { - return opts.serialize(mapper, data, opts); - } - if (jsData.utils.isFunction(mapper.serialize)) { - return mapper.serialize(mapper, data, opts); - } - return data; - }, - - - /** - * Retrieve the sum of the field of the records that match the selection query. - * - * @name HttpAdapter#sum - * @method - * @param {object} mapper The mapper. - * @param {string} field The field to sum. - * @param {object} query Selection query. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - sum: function sum(mapper, field, query, opts) { - query || (query = {}); - opts || (opts = {}); - if (!jsData.utils.isString(field)) { - throw new Error('field must be a string!'); + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method The method being executed. + * @param {object} mapper The Mapper. + * @param {(string|number)?} id The primary key, if any. + * @param {object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + opts || (opts = {}); + var args = [opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, this.getEndpoint(mapper, jsData.utils.isString(id) || jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; + if (method === 'find' || method === 'update' || method === 'destroy') { + args.push(id); + } + return makePath.apply(jsData.utils, args); + }, + getParams: function getParams(opts) { + opts || (opts = {}); + if (opts.params === undefined) { + return {}; + } + return jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (opts.suffix === undefined) { + if (mapper.suffix === undefined) { + return this.suffix; } - opts.params = this.getParams(opts); - opts.params.sum = field; - opts.suffix = this.getSuffix(mapper, opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - return Adapter.prototype.sum.call(this, mapper, field, query, opts); - }, - - - /** - * Perform an update. Makes a PUT request by default. - * - * @name HttpAdapter#update - * @method - * @param {object} mapper The Mapper for the request. - * @param {*} id The primary key of the record being updated. - * @param {*} props The update payload. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - update: function update(mapper, id, props, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.update.call(this, mapper, id, props, opts); - }, - - - /** - * Perform an update against records that match the selection query. Makes a - * PUT request by default. - * - * @name HttpAdapter#updateAll - * @method - * @param {object} mapper The Mapper for the request. - * @param {object} props The update payload. - * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}. - * @param {object} [opts] Configuration options. - * @return {Promise} - */ - updateAll: function updateAll(mapper, props, query, opts) { - query || (query = {}); - opts || (opts = {}); - opts.params = this.getParams(opts); - jsData.utils.deepMixIn(opts.params, query); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.updateAll.call(this, mapper, props, query, opts); - }, - - - /** - * Update multiple individual records in a batch. - * - * @name HttpAdapter#updateMany - * @method - * @param {object} mapper The Mapper for the request. - * @param {array} records Array of property objects to send as the payload. - * Each must contain the primary key of the record to be updated. - * @param {object} [opts] Configuration options. - * @param {string} [opts.params] Querystring parameters. - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. - * @return {Promise} - */ - updateMany: function updateMany(mapper, records, opts) { - opts || (opts = {}); - opts.params = this.getParams(opts); - opts.params = this.queryTransform(mapper, opts.params, opts); - opts.suffix = this.getSuffix(mapper, opts); - return Adapter.prototype.updateMany.call(this, mapper, records, opts); + return mapper.suffix; } - }); + return opts.suffix; + }, + /** - * Add an Http actions to a mapper. - * - * @example - * // CommonJS - * var JSData = require('js-data'); - * // It is recommended to use DataStore in the browser - * var DataStore = JSData.DataStore; - * - * var JSDataHttp = require('js-data-http'); - * var HttpAdapter = JSDataHttp.HttpAdapter; - * var addAction = JSDataHttp.addAction; - * - * var httpAdapter = new HttpAdapter(); - * var store = new DataStore(); - * - * store.registerAdapter('http', httpAdapter, { 'default': true }); - * store.defineMapper('school'); + * Make an Http request. * - * // GET /reports/schools/:school_id/teachers - * addAction('getTeacherReports', { - * endpoint: 'reports/schools', - * pathname: 'teachers', - * method: 'GET' - * })(store.getMapper('school')); - * - * // /reports/schools/1234/teachers - * store.getMapper('school').getTeacherReports(1234).then((response) => { - * // ... - * }); - * - * @name module:js-data-http.addAction - * @method - * @param {string} name Name of the new action. - * @param {object} [opts] Action configuration - * @param {string} [opts.adapter="http"] The name of the adapter to use. - * @param {string} [opts.pathname] Set the action's pathname. - * @param {function} [opts.request] Specify a request handler to be executed - * before the request is made. - * @param {function} [opts.response] Specify a response handler to be executed - * after the response is received. - * @param {function} [opts.responseError] Specify an error handler to be - * executed on error. - * @return {function} Decoration function, which should be passed the mapper to - * decorate when invoked. - */ - function addAction(name, opts) { - if (!name || !jsData.utils.isString(name)) { - throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + * @name HttpAdapter#HTTP + * @method + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + HTTP: function HTTP(config, opts) { + var _this15 = this; + + var start = new Date(); + opts || (opts = {}); + var payload = config.data; + var cache = config.cache; + var timeout = config.timeout; + config = jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); + config = jsData.utils.deepMixIn(config, this.httpConfig); + config.data = payload; + config.cache = cache; + if (timeout !== undefined) { + config.timeout = timeout; + } + if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || this.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; } - return function (mapper) { - if (mapper[name]) { - throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); - } - opts.request = opts.request || function (config) { - return config; - }; - opts.response = opts.response || function (response) { - return response; - }; - opts.responseError = opts.responseError || function (err) { - return jsData.utils.reject(err); - }; - mapper[name] = function (id, _opts) { - var _this18 = this; - _opts = _opts || {}; - if (jsData.utils.isObject(id)) { - _opts = id; + var logResponse = function logResponse(data) { + var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; + if (data.status >= 200 && data.status < 300) { + if (_this15.log) { + _this15.dbg(str, data); } - jsData.utils.fillIn(_opts, opts); - var adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http'); - var config = {}; - config.mapper = this.name; - jsData.utils.deepMixIn(config, _opts); - config.method = config.method || 'GET'; - if (typeof _opts.getEndpoint === 'function') { - config.url = _opts.getEndpoint(this, _opts); - } else { - var args = [_opts.basePath || this.basePath || adapter.basePath, adapter.getEndpoint(this, id, _opts)]; - if (jsData.utils.isSorN(id)) { - args.push(id); - } - args.push(opts.pathname || name); - config.url = makePath.apply(null, args); + return data; + } else { + if (_this15.error) { + _this15.error('\'FAILED: ' + str, data); } - return jsData.utils.resolve(config).then(_opts.request).then(function (config) { - return adapter.HTTP(config); - }).then(function (data) { - if (data && data.config) { - data.config.mapper = _this18.name; - } - return data; - }).then(_opts.response, _opts.responseError); - }; - return mapper; + return jsData.utils.reject(data); + } }; - } + + if (!this.http) { + if (this.useFetch || opts.useFetch) { + if (!hasFetch) { + throw new Error('Attempting to use window.fetch, but it is not available!'); + } + } else { + throw new Error('You have not configured this adapter with an http library!'); + } + } + + return jsData.utils.resolve(this.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (_this15.useFetch || opts.useFetch || !_this15.http)) { + return _this15.fetch(config, opts).then(logResponse, logResponse); + } + var httpConfig = jsData.utils.plainCopy(config); + delete httpConfig.adapter; + return _this15.http(httpConfig).then(logResponse, logResponse).catch(function (err) { + return _this15.responseError(err, config, opts); + }); + }).then(function (response) { + return jsData.utils.resolve(_this15.afterHTTP(config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + /** - * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for - * action configuration options. + * Make a POST request. * - * @example - * // CommonJS - * var JSData = require('js-data'); - * // It is recommended to use DataStore in the browser - * var DataStore = JSData.DataStore; + * @name HttpAdapter#POST + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var _this16 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'post'; + + // beforePOST lifecycle hook + op = opts.op = 'beforePOST'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'POST'; + _this16.dbg(op, url, data, config, opts); + return _this16.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return jsData.utils.resolve(_this16[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Make a PUT request. + * + * @name HttpAdapter#PUT + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var _this17 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'put'; + + // beforePUT lifecycle hook + op = opts.op = 'beforePUT'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'PUT'; + _this17.dbg(op, url, data, config, opts); + return _this17.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return jsData.utils.resolve(_this17[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the querystring object before it is serialized. This doesn't do + * anything by default. + * + * @name HttpAdapter#queryTransform + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {*} params The querystring object. + * @param {*} opts Configuration options + * @return {*} Transformed params. + */ + queryTransform: function queryTransform(mapper, params, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts); + } + if (jsData.utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts); + } + return params; + }, + + + /** + * Error handler invoked when the promise returned by {@link HttpAdapter#http} + * is rejected. Default implementation is to just return the error wrapped in + * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is + * called by {@link HttpAdapter#HTTP}. * - * var JSDataHttp = require('js-data-http'); - * var HttpAdapter = JSDataHttp.HttpAdapter; - * var addActions = JSDataHttp.addActions; + * @name HttpAdapter#responseError + * @method + * @param {*} err The error that {@link HttpAdapter#http} rejected with. + * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. + * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. + * @return {Promise} + */ + responseError: function responseError(err, config, opts) { + return jsData.utils.reject(err); + }, + + + /** + * Serialize request data. This doesn't do anything by default. * - * var httpAdapter = new HttpAdapter(); - * var store = new DataStore(); + * @name HttpAdapter#serialize + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {object} data The request payload. + * @param {*} opts Configuration options. + * @return {*} Serialized data. + */ + serialize: function serialize(mapper, data, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts); + } + if (jsData.utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts); + } + return data; + }, + + + /** + * Retrieve the sum of the field of the records that match the selection query. * - * store.registerAdapter('http', httpAdapter, { 'default': true }); - * store.defineMapper('school'); + * @name HttpAdapter#sum + * @method + * @param {object} mapper The mapper. + * @param {string} field The field to sum. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + query || (query = {}); + opts || (opts = {}); + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = this.getParams(opts); + opts.params.sum = field; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.sum.call(this, mapper, field, query, opts); + }, + + + /** + * Perform an update. Makes a PUT request by default. * - * addActions({ - * // GET /reports/schools/:school_id/teachers - * getTeacherReports: { - * basePath: 'reports/schools', - * pathname: 'teachers', - * method: 'GET' - * } - * })(store.getMapper('school')); - * - * // /reports/schools/1234/teachers - * store.getMapper('school').getTeacherReports(1234).then((response) => { - * // ... - * }); + * @name HttpAdapter#update + * @method + * @param {object} mapper The Mapper for the request. + * @param {*} id The primary key of the record being updated. + * @param {*} props The update payload. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.update.call(this, mapper, id, props, opts); + }, + + + /** + * Perform an update against records that match the selection query. Makes a + * PUT request by default. * - * @name module:js-data-http.addActions + * @name HttpAdapter#updateAll * @method - * @param {object.} opts Object where the key is an action name - * and the value is the configuration for the action. - * @return {function} Decoration function, which should be passed the mapper to - * decorate when invoked. + * @param {object} mapper The Mapper for the request. + * @param {object} props The update payload. + * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}. + * @param {object} [opts] Configuration options. + * @return {Promise} */ - function addActions(opts) { + updateAll: function updateAll(mapper, props, query, opts) { + query || (query = {}); opts || (opts = {}); - return function (mapper) { - jsData.utils.forOwn(opts, function (value, key) { - addAction(key, value)(mapper); - }); - return mapper; - }; - } + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.updateAll.call(this, mapper, props, query, opts); + }, + /** - * Details of the current version of the `js-data-http` module. + * Update multiple individual records in a batch. * - * @name module:js-data-http.version - * @type {object} - * @property {string} version.full The full semver value. - * @property {number} version.major The major version number. - * @property {number} version.minor The minor version number. - * @property {number} version.patch The patch version number. - * @property {(string|boolean)} version.alpha The alpha version value, - * otherwise `false` if the current version is not alpha. - * @property {(string|boolean)} version.beta The beta version value, - * otherwise `false` if the current version is not beta. - */ - var version = { - full: '3.0.0-rc.3', + * @name HttpAdapter#updateMany + * @method + * @param {object} mapper The Mapper for the request. + * @param {array} records Array of property objects to send as the payload. + * Each must contain the primary key of the record to be updated. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.updateMany.call(this, mapper, records, opts); + } +}); + +/** + * Add an Http actions to a mapper. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addAction = JSDataHttp.addAction; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * // GET /reports/schools/:school_id/teachers + * addAction('getTeacherReports', { + * endpoint: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addAction + * @method + * @param {string} name Name of the new action. + * @param {object} [opts] Action configuration + * @param {string} [opts.adapter="http"] The name of the adapter to use. + * @param {string} [opts.pathname] Set the action's pathname. + * @param {function} [opts.request] Specify a request handler to be executed + * before the request is made. + * @param {function} [opts.response] Specify a response handler to be executed + * after the response is received. + * @param {function} [opts.responseError] Specify an error handler to be + * executed on error. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addAction(name, opts) { + if (!name || !jsData.utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + } + return function (mapper) { + if (mapper[name]) { + throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); + } + opts.request = opts.request || function (config) { + return config; + }; + opts.response = opts.response || function (response) { + return response; + }; + opts.responseError = opts.responseError || function (err) { + return jsData.utils.reject(err); + }; + mapper[name] = function (id, _opts) { + var _this18 = this; + + _opts = _opts || {}; + if (jsData.utils.isObject(id)) { + _opts = id; + } + jsData.utils.fillIn(_opts, opts); + var adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http'); + var config = {}; + config.mapper = this.name; + jsData.utils.deepMixIn(config, _opts); + config.method = config.method || 'GET'; + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(this, _opts); + } else { + var args = [_opts.basePath || this.basePath || adapter.basePath, adapter.getEndpoint(this, id, _opts)]; + if (jsData.utils.isSorN(id)) { + args.push(id); + } + args.push(opts.pathname || name); + config.url = makePath.apply(null, args); + } + return jsData.utils.resolve(config).then(_opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = _this18.name; + } + return data; + }).then(_opts.response, _opts.responseError); + }; + return mapper; + }; +} + +/** + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addActions = JSDataHttp.addActions; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * addActions({ + * // GET /reports/schools/:school_id/teachers + * getTeacherReports: { + * basePath: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * } + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addActions + * @method + * @param {object.} opts Object where the key is an action name + * and the value is the configuration for the action. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addActions(opts) { + opts || (opts = {}); + return function (mapper) { + jsData.utils.forOwn(opts, function (value, key) { + addAction(key, value)(mapper); + }); + return mapper; + }; +} + +/** + * Details of the current version of the `js-data-http` module. + * + * @name module:js-data-http.version + * @type {object} + * @property {string} version.full The full semver value. + * @property {number} version.major The major version number. + * @property {number} version.minor The minor version number. + * @property {number} version.patch The patch version number. + * @property {(string|boolean)} version.alpha The alpha version value, + * otherwise `false` if the current version is not alpha. + * @property {(string|boolean)} version.beta The beta version value, + * otherwise `false` if the current version is not beta. + */ +var version = { + full: '3.0.0', major: 3, minor: 0, patch: 0 }; - exports.HttpAdapter = HttpAdapter; - exports.addAction = addAction; - exports.addActions = addActions; - exports.version = version; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); +/** + * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http` + * that works on Node.js is registered in NPM as `js-data-http-node`. The build + * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower + * as `js-data-fetch`. + * + * @example Script tag + * var HttpAdapter = window.JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example CommonJS + * var HttpAdapter = require('js-data-Http').HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example ES2015 Modules + * import { HttpAdapter } from 'js-data-Http'; + * const httpAdapter = new HttpAdapter(); + * + * @example AMD + * define('myApp', ['js-data-Http'], function (JSDataHttp) { + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * // ... + * }); + * + * @module js-data-http + */ + +/** + * Create a subclass of this HttpAdapter: + * @example HttpAdapter.extend + * // Normally you would do: import { HttpAdapter } from 'js-data-http'; + * // or: import { HttpAdapter } from 'js-data-http-node'; + * const JSDataHttp = require('js-data-http-node'); + * const { HttpAdapter } = JSDataHttp; + * console.log('Using JSDataHttp v' + JSDataHttp.version.full); + * + * // Extend the class using ES2015 class syntax. + * class CustomHttpAdapterClass extends HttpAdapter { + * foo () { return 'bar'; } + * static beep () { return 'boop'; } + * } + * const customHttpAdapter = new CustomHttpAdapterClass(); + * console.log(customHttpAdapter.foo()); + * console.log(CustomHttpAdapterClass.beep()); + * + * // Extend the class using alternate method. + * const OtherHttpAdapterClass = HttpAdapter.extend({ + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const otherHttpAdapter = new OtherHttpAdapterClass(); + * console.log(otherHttpAdapter.foo()); + * console.log(OtherHttpAdapterClass.beep()); + * + * // Extend the class, providing a custom constructor. + * function AnotherHttpAdapterClass () { + * HttpAdapter.call(this); + * this.created_at = new Date().getTime(); + * } + * HttpAdapter.extend({ + * constructor: AnotherHttpAdapterClass, + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const anotherHttpAdapter = new AnotherHttpAdapterClass(); + * console.log(anotherHttpAdapter.created_at); + * console.log(anotherHttpAdapter.foo()); + * console.log(AnotherHttpAdapterClass.beep()); + * + * @method HttpAdapter.extend + * @param {object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this HttpAdapter class. + * @since 3.0.0 + */ + +exports.HttpAdapter = HttpAdapter; +exports.addAction = addAction; +exports.addActions = addActions; +exports.version = version; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); //# sourceMappingURL=js-data-fetch.js.map diff --git a/fetch/dist/js-data-fetch.js.map b/fetch/dist/js-data-fetch.js.map index 0464131..2286e14 100644 --- a/fetch/dist/js-data-fetch.js.map +++ b/fetch/dist/js-data-fetch.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["../../node_modules/js-data-adapter/src/index.js","../../src/index.js"],"sourcesContent":["import {Component, utils} from 'js-data'\n\nexport const noop = function (...args) {\n const opts = args[args.length - 1]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const opts = args[args.length - 2]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const unique = function (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\n\nexport const withoutRelations = function (mapper, props, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n const relationFields = mapper.relationFields || []\n const toStrip = relationFields.filter((value) => opts.with.indexOf(value) === -1)\n return utils.omit(props, toStrip)\n}\n\nexport const reserved = [\n 'orderBy',\n 'sort',\n 'limit',\n 'offset',\n 'skip',\n 'where'\n]\n\n/**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\nexport function Response (data, meta, op) {\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n this.data = data\n\n utils.fillIn(this, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n this.op = op\n}\n\nconst DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @extends Component\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\nexport function Adapter (opts) {\n utils.classCallCheck(this, Adapter)\n Component.call(this, opts)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(this, opts)\n}\n\nComponent.extend({\n constructor: Adapter,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {string} field The `field` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._count(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'create'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._create(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'create')\n response.created = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = props.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'createMany'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._createMany(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'createMany')\n response.created = data.length\n response = this.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'destroy'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._destroy(mapper, id, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = this.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'destroyAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._destroyAll(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = this.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo (mapper, def, records, __opts) {\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts)\n .then((relatedItem) => {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records\n .map((record) => this.makeBelongsToForeignKey(mapper, def, record))\n .filter((key) => key)\n return this.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((record) => {\n relatedItems.forEach((relatedItem) => {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem)\n }\n })\n })\n })\n }\n },\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n let record, op\n let meta = {}\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'find'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._find(mapper, id, opts))\n })\n .then((results) => {\n let [_record, _meta] = results\n if (!_record) {\n return\n }\n record = _record\n meta = _meta\n const tasks = []\n\n utils.forEachRelation(mapper, opts, (def, __opts) => {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = this.loadHasOne(mapper, def, record, __opts)\n } else {\n task = this.loadHasMany(mapper, def, record, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = this.loadHasManyLocalKeys(mapper, def, record, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = this.loadHasManyForeignKeys(mapper, def, record, __opts)\n } else if (def.type === 'belongsTo') {\n task = this.loadBelongsTo(mapper, def, record, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n\n return utils.Promise.all(tasks)\n })\n .then(() => {\n let response = new Response(record, meta, 'find')\n response.found = record ? 1 : 0\n response = this.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n let records = []\n let meta = {}\n let op\n const activeWith = opts._activeWith\n\n if (utils.isObject(activeWith)) {\n const activeQuery = activeWith.query || {}\n if (activeWith.replace) {\n query = activeQuery\n } else {\n utils.deepFillIn(query, activeQuery)\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'findAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._findAll(mapper, query, opts))\n })\n .then((results) => {\n let [_records, _meta] = results\n _records || (_records = [])\n records = _records\n meta = _meta\n const tasks = []\n utils.forEachRelation(mapper, opts, (def, __opts) => {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = this.loadHasMany(mapper, def, records, __opts)\n } else {\n task = this.loadHasOne(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = this.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = this.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = this.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n return utils.Promise.all(tasks)\n })\n .then(() => {\n let response = new Response(records, meta, 'findAll')\n response.found = records.length\n response = this.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt (opt, opts) {\n opts || (opts = {})\n return opts[opt] === undefined ? utils.plainCopy(this[opt]) : utils.plainCopy(opts[opt])\n },\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany (mapper, def, records, __opts) {\n let singular = false\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n const IDs = records.map((record) => this.makeHasManyForeignKey(mapper, def, record))\n const query = {\n where: {}\n }\n const criteria = query.where[def.foreignKey] = {}\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0]\n } else {\n criteria['in'] = IDs.filter((id) => id)\n }\n return this.findAll(def.getRelation(), query, __opts).then((relatedItems) => {\n records.forEach((record) => {\n let attached = []\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems\n } else {\n relatedItems.forEach((relatedItem) => {\n if (utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem)\n }\n })\n }\n def.setLocalField(record, attached)\n })\n })\n },\n\n loadHasManyLocalKeys (mapper, def, records, __opts) {\n let record\n const relatedMapper = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': this.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach((record) => {\n localKeys = localKeys.concat(this.makeHasManyLocalKeys(mapper, def, record))\n })\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter((x) => x)\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((item) => {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach((relatedItem) => {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem)\n }\n })\n def.setLocalField(item, attached)\n })\n return relatedItems\n })\n }\n },\n\n loadHasManyForeignKeys (mapper, def, records, __opts) {\n const relatedMapper = def.getRelation()\n const idAttribute = mapper.idAttribute\n let record\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': this.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return this.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map((record) => this.makeHasManyForeignKeys(mapper, def, record))\n }\n }\n }, __opts).then((relatedItems) => {\n const foreignKeysField = def.foreignKeys\n records.forEach((record) => {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach((relatedItem) => {\n const foreignKeys = utils.get(relatedItems, foreignKeysField) || []\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem)\n }\n })\n def.setLocalField(record, _relatedItems)\n })\n })\n }\n },\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne (mapper, def, records, __opts) {\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n }\n return this.loadHasMany(mapper, def, records, __opts).then(() => {\n records.forEach((record) => {\n const relatedData = def.getLocalField(record)\n if (utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0])\n }\n })\n })\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n let localKeys = []\n let itemKeys = utils.get(record, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n return unique(localKeys).filter((x) => x)\n },\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys (mapper, def, record) {\n return utils.get(record, mapper.idAttribute)\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n let op\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n query || (query = {})\n opts || (opts = {})\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum'\n return utils.resolve(this[op](mapper, field, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n this.dbg(op, mapper, field, query, opts)\n return utils.resolve(this._sum(mapper, field, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(this[op](mapper, field, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond (response, opts) {\n return this.getOpt('raw', opts) ? response : response.data\n },\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(this[op](mapper, id, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'update'\n this.dbg(op, mapper, id, props, opts)\n return utils.resolve(this._update(mapper, id, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'update')\n response.updated = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(this[op](mapper, id, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let op\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'updateAll'\n this.dbg(op, mapper, props, query, opts)\n return utils.resolve(this._updateAll(mapper, props, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateAll')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter((record) => utils.get(record, idAttribute))\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(this[op](mapper, records, opts))\n .then((_records) => {\n // Allow for re-assignment from lifecycle hook\n records = _records === undefined ? records : _records\n records = records.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'updateMany'\n this.dbg(op, mapper, records, opts)\n return utils.resolve(this._updateMany(mapper, records, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateMany')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(this[op](mapper, records, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n }\n})\n\n/**\n * Create a subclass of this Adapter:\n *\n * @example Adapter.extend\n * // Normally you would do: import {Adapter} from 'js-data'\n * const JSData = require('js-data@3.0.0-beta.10')\n * const {Adapter} = JSData\n * console.log('Using JSData v' + JSData.version.full)\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomAdapterClass extends Adapter {\n * foo () { return 'bar' }\n * static beep () { return 'boop' }\n * }\n * const customAdapter = new CustomAdapterClass()\n * console.log(customAdapter.foo())\n * console.log(CustomAdapterClass.beep())\n *\n * // Extend the class using alternate method.\n * const OtherAdapterClass = Adapter.extend({\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const otherAdapter = new OtherAdapterClass()\n * console.log(otherAdapter.foo())\n * console.log(OtherAdapterClass.beep())\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherAdapterClass () {\n * Adapter.call(this)\n * this.created_at = new Date().getTime()\n * }\n * Adapter.extend({\n * constructor: AnotherAdapterClass,\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const anotherAdapter = new AnotherAdapterClass()\n * console.log(anotherAdapter.created_at)\n * console.log(anotherAdapter.foo())\n * console.log(AnotherAdapterClass.beep())\n *\n * @method Adapter.extend\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this Adapter class.\n */\n","import { utils } from 'js-data'\nimport axios from '../node_modules/axios/dist/axios'\nimport {\n Adapter,\n noop,\n noop2\n} from '../node_modules/js-data-adapter/src/index'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:\\/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst DEFAULTS = {\n /**\n * Set a base path in order to use absolute URLs instead of relative URLs.\n *\n * @example\n * const httpAdapter = new HttpAdapter({\n * basePath: 'https://mydomain.com'\n * });\n *\n * @name HttpAdapter#basePath\n * @type {string}\n * @since 3.0.0\n */\n basePath: '',\n\n /**\n * Ensure that the request url has a trailing forward slash.\n *\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n forceTrailingSlash: false,\n\n /**\n * The HTTP function that actually makes the HTTP request. By default this is\n * `axios`.\n *\n * @name HttpAdapter#http\n * @type {function}\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library\n */\n http: axios,\n\n /**\n * Default configuration options to be mixed into the `config` argument passed\n * to {@link HttpAdapter#http}.\n *\n * @name HttpAdapter#httpConfig\n * @type {object}\n * @since 3.0.0\n */\n httpConfig: {},\n\n /**\n * Add a suffix to the request url, e.g. \".json\".\n *\n * @name HttpAdapter#suffix\n * @type {string}\n * @since 3.0.0\n */\n suffix: '',\n\n /**\n * Use `window.fetch` if available.\n *\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-windowfetch\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @example\n * import { DataStore } from 'js-data';\n * import { HttpAdapter } from 'js-data-http';\n *\n * const httpAdapter = new HttpAdapter();\n * const store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n *\n * store.defineMapper('school');\n * store.defineMapper('student');\n *\n * // GET /school/1\n * store.find('school', 1).then((school) => {\n * console.log('school');\n * });\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}.\n * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}.\n * @param {object} [opts.http=axios] See {@link HttpAdapter#http}.\n * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}.\n * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}.\n * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}.\n * @see http://www.js-data.io/docs/js-data-http\n */\nexport function HttpAdapter (opts) {\n utils.classCallCheck(this, HttpAdapter)\n\n opts || (opts = {})\n // Fill in any missing options with the defaults\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(this, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\nAdapter.extend({\n constructor: HttpAdapter,\n\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n return this.GET(\n this.getPath('count', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _create (mapper, props, opts) {\n return this.POST(\n this.getPath('create', mapper, props, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _createMany (mapper, props, opts) {\n return this.POST(\n this.getPath('createMany', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroy (mapper, id, opts) {\n return this.DEL(\n this.getPath('destroy', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroyAll (mapper, query, opts) {\n return this.DEL(\n this.getPath('destroyAll', mapper, null, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n return this.GET(\n this.getPath('find', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _findAll (mapper, query, opts) {\n return this.GET(\n this.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _sum (mapper, field, query, opts) {\n return this.GET(\n this.getPath('sum', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _update (mapper, id, props, opts) {\n return this.PUT(\n this.getPath('update', mapper, id, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateAll (mapper, props, query, opts) {\n return this.PUT(\n this.getPath('updateAll', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateMany (mapper, records, opts) {\n return this.PUT(\n this.getPath('updateMany', mapper, null, opts),\n this.serialize(mapper, records, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params.count = true\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.count.call(this, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {object} mapper The mapper.\n * @param {object} props Properties to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.create.call(this, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {object} mapper The mapper.\n * @param {array} props Array of property objects to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.createMany.call(this, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'DEL'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {object} mapper The mapper used for the operation.\n * @param {object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {object} opts Configuration options.\n * @return {(object|array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroy.call(this, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroyAll.call(this, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {object} config Request configuration.\n * @param {object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {object} config.headers Headers for the request.\n * @param {object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n */\n fetch (config) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers || {})\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(buildUrl(config.url, config.params), requestConfig)\n .then((response) => {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json()\n .then((data) => {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.find.call(this, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.findAll.call(this, mapper, query, opts)\n },\n\n /**\n * Make a GET request.\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'GET'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {object} mapper The Mapper.\n * @param {*} id The primary key, if any.\n * @param {boolean} opts Configuration options.\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach((def) => {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, (value, key) => {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method The method being executed.\n * @param {object} mapper The Mapper.\n * @param {(string|number)?} id The primary key, if any.\n * @param {object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n opts || (opts = {})\n const args = [\n opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath,\n this.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (opts.params === undefined) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (opts.suffix === undefined) {\n if (mapper.suffix === undefined) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, this.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || this.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n const logResponse = (data) => {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (this.log) {\n this.dbg(str, data)\n }\n return data\n } else {\n if (this.error) {\n this.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!this.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(this.beforeHTTP(config, opts))\n .then((_config) => {\n config = _config || config\n if (hasFetch && (this.useFetch || opts.useFetch || !this.http)) {\n return this.fetch(config, opts).then(logResponse, logResponse)\n }\n return this.http(config).then(logResponse, logResponse)\n .catch((err) => this.responseError(err, config, opts))\n })\n .then((response) => {\n return utils.resolve(this.afterHTTP(config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a POST request.\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'POST'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a PUT request.\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'PUT'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the querystring object before it is serialized. This doesn't do\n * anything by default.\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {*} params The querystring object.\n * @param {*} opts Configuration options\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * Serialize request data. This doesn't do anything by default.\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {object} data The request payload.\n * @param {*} opts Configuration options.\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n query || (query = {})\n opts || (opts = {})\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = this.getParams(opts)\n opts.params.sum = field\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.sum.call(this, mapper, field, query, opts)\n },\n\n /**\n * Perform an update. Makes a PUT request by default.\n *\n * @name HttpAdapter#update\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {*} id The primary key of the record being updated.\n * @param {*} props The update payload.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.update.call(this, mapper, id, props, opts)\n },\n\n /**\n * Perform an update against records that match the selection query. Makes a\n * PUT request by default.\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {object} props The update payload.\n * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateAll.call(this, mapper, props, query, opts)\n },\n\n /**\n * Update multiple individual records in a batch.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {array} records Array of property objects to send as the payload.\n * Each must contain the primary key of the record to be updated.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateMany.call(this, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addAction = JSDataHttp.addAction;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * endpoint: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {object} [opts] Action configuration\n * @param {string} [opts.adapter=\"http\"] The name of the adapter to use.\n * @param {string} [opts.pathname] Set the action's pathname.\n * @param {function} [opts.request] Specify a request handler to be executed\n * before the request is made.\n * @param {function} [opts.response] Specify a response handler to be executed\n * after the response is received.\n * @param {function} [opts.responseError] Specify an error handler to be\n * executed on error.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addAction (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n _opts = _opts || {}\n if (utils.isObject(id)) {\n _opts = id\n }\n utils.fillIn(_opts, opts)\n let adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http')\n const config = {}\n config.mapper = this.name\n utils.deepMixIn(config, _opts)\n config.method = config.method || 'GET'\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(this, _opts)\n } else {\n let args = [\n _opts.basePath || this.basePath || adapter.basePath,\n adapter.getEndpoint(this, id, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n return utils.resolve(config)\n .then(_opts.request)\n .then((config) => adapter.HTTP(config))\n .then((data) => {\n if (data && data.config) {\n data.config.mapper = this.name\n }\n return data\n })\n .then(_opts.response, _opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addActions = JSDataHttp.addActions;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * addActions({\n * // GET /reports/schools/:school_id/teachers\n * getTeacherReports: {\n * basePath: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * }\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addActions\n * @method\n * @param {object.} opts Object where the key is an action name\n * and the value is the configuration for the action.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name module:js-data-http.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http`\n * that works on Node.js is registered in NPM as `js-data-http-node`. The build\n * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower\n * as `js-data-fetch`.\n *\n * @example Script tag\n * var HttpAdapter = window.JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example ES2015 Modules\n * import { HttpAdapter } from 'js-data-Http';\n * const httpAdapter = new HttpAdapter();\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * // ...\n * });\n *\n * @module js-data-http\n */\n\n/**\n * Create a subclass of this HttpAdapter:\n * @example HttpAdapter.extend\n * // Normally you would do: import { HttpAdapter } from 'js-data-http';\n * // or: import { HttpAdapter } from 'js-data-http-node';\n * const JSDataHttp = require('js-data-http-node');\n * const { HttpAdapter } = JSDataHttp;\n * console.log('Using JSDataHttp v' + JSDataHttp.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomHttpAdapterClass extends HttpAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customHttpAdapter = new CustomHttpAdapterClass();\n * console.log(customHttpAdapter.foo());\n * console.log(CustomHttpAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherHttpAdapterClass = HttpAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const otherHttpAdapter = new OtherHttpAdapterClass();\n * console.log(otherHttpAdapter.foo());\n * console.log(OtherHttpAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherHttpAdapterClass () {\n * HttpAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * HttpAdapter.extend({\n * constructor: AnotherHttpAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const anotherHttpAdapter = new AnotherHttpAdapterClass();\n * console.log(anotherHttpAdapter.created_at);\n * console.log(anotherHttpAdapter.foo());\n * console.log(AnotherHttpAdapterClass.beep());\n *\n * @method HttpAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this HttpAdapter class.\n * @since 3.0.0\n */\n"],"names":["utils","DEFAULTS","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EASJ,IATI,CASC,MAAM,QATP,EASiB,MAAM,aATvB,CAAP;AAUD,EAAA,KAlCD;AAmCA,EAAA,WAAO,MAAP;AACD,EAAA,GA3CD;AA4CD,EAAA;;AAED,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,AAAO,EAAA,SAAS,UAAT,CAAqB,IAArB,EAA2B;AAChC,EAAA,WAAS,OAAO,EAAhB;AACA,EAAA,SAAO,UAAU,MAAV,EAAkB;AACvB,EAAA,iBAAM,MAAN,CAAa,IAAb,EAAmB,UAAU,KAAV,EAAiB,GAAjB,EAAsB;AACvC,EAAA,gBAAU,GAAV,EAAe,KAAf,EAAsB,MAAtB;AACD,EAAA,KAFD;AAGA,EAAA,WAAO,MAAP;AACD,EAAA,GALD;AAMD,EAAA;;AAED,EAAA;;;;;;;;;;;;;;AAcA,AAAO,EAAA,IAAM,UAAU,gBAAhB,CAEP;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"js-data-fetch.js","sources":["../../node_modules/js-data-adapter/src/index.js","../../src/index.js"],"sourcesContent":["import { Component, utils } from 'js-data'\n\nexport const noop = function (...args) {\n const opts = args[args.length - 1]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const opts = args[args.length - 2]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const unique = function (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\n\nexport const withoutRelations = function (mapper, props, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n const relationFields = mapper.relationFields || []\n const toStrip = relationFields.filter((value) => opts.with.indexOf(value) === -1)\n return utils.omit(props, toStrip)\n}\n\nexport const reserved = [\n 'orderBy',\n 'sort',\n 'limit',\n 'offset',\n 'skip',\n 'where'\n]\n\n/**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\nexport function Response (data, meta, op) {\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n this.data = data\n\n utils.fillIn(this, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n this.op = op\n}\n\nconst DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @extends Component\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\nexport function Adapter (opts) {\n utils.classCallCheck(this, Adapter)\n Component.call(this, opts)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(this, opts)\n}\n\nComponent.extend({\n constructor: Adapter,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {string} field The `field` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._count(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'create'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._create(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'create')\n response.created = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = props.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'createMany'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._createMany(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'createMany')\n response.created = data.length\n response = this.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'destroy'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._destroy(mapper, id, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = this.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'destroyAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._destroyAll(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = this.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo (mapper, def, records, __opts) {\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts)\n .then((relatedItem) => {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records\n .map((record) => this.makeBelongsToForeignKey(mapper, def, record))\n .filter((key) => key)\n return this.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((record) => {\n relatedItems.forEach((relatedItem) => {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem)\n }\n })\n })\n })\n }\n },\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'find'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._find(mapper, id, opts))\n })\n .then((results) => this.loadRelationsFor(mapper, results, opts))\n .then(([record, meta]) => {\n let response = new Response(record, meta, 'find')\n response.found = record ? 1 : 0\n response = this.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n const activeWith = opts._activeWith\n\n if (utils.isObject(activeWith)) {\n const activeQuery = activeWith.query || {}\n if (activeWith.replace) {\n query = activeQuery\n } else {\n utils.deepFillIn(query, activeQuery)\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'findAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._findAll(mapper, query, opts))\n })\n .then((results) => this.loadRelationsFor(mapper, results, opts))\n .then(([records, meta]) => {\n let response = new Response(records, meta, 'findAll')\n response.found = records.length\n response = this.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n loadRelationsFor (mapper, results, opts) {\n const [records] = results\n const tasks = []\n\n if (records) {\n utils.forEachRelation(mapper, opts, (def, __opts) => {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = this.loadHasOne(mapper, def, records, __opts)\n } else {\n task = this.loadHasMany(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = this.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = this.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = this.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n }\n\n return utils.Promise.all(tasks)\n .then(() => results)\n },\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt (opt, opts) {\n opts || (opts = {})\n return opts[opt] === undefined ? utils.plainCopy(this[opt]) : utils.plainCopy(opts[opt])\n },\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany (mapper, def, records, __opts) {\n let singular = false\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n const IDs = records.map((record) => this.makeHasManyForeignKey(mapper, def, record))\n const query = {\n where: {}\n }\n const criteria = query.where[def.foreignKey] = {}\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0]\n } else {\n criteria['in'] = IDs.filter((id) => id)\n }\n return this.findAll(def.getRelation(), query, __opts).then((relatedItems) => {\n records.forEach((record) => {\n let attached = []\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems\n } else {\n relatedItems.forEach((relatedItem) => {\n if (utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem)\n }\n })\n }\n def.setLocalField(record, attached)\n })\n })\n },\n\n loadHasManyLocalKeys (mapper, def, records, __opts) {\n let record\n const relatedMapper = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': this.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach((record) => {\n localKeys = localKeys.concat(this.makeHasManyLocalKeys(mapper, def, record))\n })\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter((x) => x)\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((item) => {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach((relatedItem) => {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem)\n }\n })\n def.setLocalField(item, attached)\n })\n return relatedItems\n })\n }\n },\n\n loadHasManyForeignKeys (mapper, def, records, __opts) {\n const relatedMapper = def.getRelation()\n const idAttribute = mapper.idAttribute\n let record\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': this.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return this.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map((record) => this.makeHasManyForeignKeys(mapper, def, record))\n }\n }\n }, __opts).then((relatedItems) => {\n const foreignKeysField = def.foreignKeys\n records.forEach((record) => {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach((relatedItem) => {\n const foreignKeys = utils.get(relatedItems, foreignKeysField) || []\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem)\n }\n })\n def.setLocalField(record, _relatedItems)\n })\n })\n }\n },\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne (mapper, def, records, __opts) {\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n }\n return this.loadHasMany(mapper, def, records, __opts).then(() => {\n records.forEach((record) => {\n const relatedData = def.getLocalField(record)\n if (utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0])\n }\n })\n })\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n let localKeys = []\n let itemKeys = utils.get(record, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n return unique(localKeys).filter((x) => x)\n },\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys (mapper, def, record) {\n return utils.get(record, mapper.idAttribute)\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n let op\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n query || (query = {})\n opts || (opts = {})\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum'\n return utils.resolve(this[op](mapper, field, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n this.dbg(op, mapper, field, query, opts)\n return utils.resolve(this._sum(mapper, field, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(this[op](mapper, field, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond (response, opts) {\n return this.getOpt('raw', opts) ? response : response.data\n },\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(this[op](mapper, id, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'update'\n this.dbg(op, mapper, id, props, opts)\n return utils.resolve(this._update(mapper, id, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'update')\n response.updated = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(this[op](mapper, id, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let op\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'updateAll'\n this.dbg(op, mapper, props, query, opts)\n return utils.resolve(this._updateAll(mapper, props, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateAll')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter((record) => utils.get(record, idAttribute))\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(this[op](mapper, records, opts))\n .then((_records) => {\n // Allow for re-assignment from lifecycle hook\n records = _records === undefined ? records : _records\n records = records.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'updateMany'\n this.dbg(op, mapper, records, opts)\n return utils.resolve(this._updateMany(mapper, records, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateMany')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(this[op](mapper, records, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n }\n})\n\n/**\n * Create a subclass of this Adapter:\n *\n * @example Adapter.extend\n * // Normally you would do: import {Adapter} from 'js-data'\n * const JSData = require('js-data@3.0.0-beta.10')\n * const {Adapter} = JSData\n * console.log('Using JSData v' + JSData.version.full)\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomAdapterClass extends Adapter {\n * foo () { return 'bar' }\n * static beep () { return 'boop' }\n * }\n * const customAdapter = new CustomAdapterClass()\n * console.log(customAdapter.foo())\n * console.log(CustomAdapterClass.beep())\n *\n * // Extend the class using alternate method.\n * const OtherAdapterClass = Adapter.extend({\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const otherAdapter = new OtherAdapterClass()\n * console.log(otherAdapter.foo())\n * console.log(OtherAdapterClass.beep())\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherAdapterClass () {\n * Adapter.call(this)\n * this.created_at = new Date().getTime()\n * }\n * Adapter.extend({\n * constructor: AnotherAdapterClass,\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const anotherAdapter = new AnotherAdapterClass()\n * console.log(anotherAdapter.created_at)\n * console.log(anotherAdapter.foo())\n * console.log(AnotherAdapterClass.beep())\n *\n * @method Adapter.extend\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this Adapter class.\n */\n","import { utils } from 'js-data'\nimport axios from '../node_modules/axios/dist/axios'\nimport {\n Adapter,\n noop,\n noop2\n} from '../node_modules/js-data-adapter/src/index'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst DEFAULTS = {\n /**\n * Set a base path in order to use absolute URLs instead of relative URLs.\n *\n * @example\n * const httpAdapter = new HttpAdapter({\n * basePath: 'https://mydomain.com'\n * });\n *\n * @name HttpAdapter#basePath\n * @type {string}\n * @since 3.0.0\n */\n basePath: '',\n\n /**\n * Ensure that the request url has a trailing forward slash.\n *\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n forceTrailingSlash: false,\n\n hasFetch: hasFetch,\n\n /**\n * The HTTP function that actually makes the HTTP request. By default this is\n * `axios`.\n *\n * @name HttpAdapter#http\n * @type {function}\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library\n */\n http: axios,\n\n /**\n * Default configuration options to be mixed into the `config` argument passed\n * to {@link HttpAdapter#http}.\n *\n * @name HttpAdapter#httpConfig\n * @type {object}\n * @since 3.0.0\n */\n httpConfig: {},\n\n /**\n * Add a suffix to the request url, e.g. \".json\".\n *\n * @name HttpAdapter#suffix\n * @type {string}\n * @since 3.0.0\n */\n suffix: '',\n\n /**\n * Use `window.fetch` if available.\n *\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-windowfetch\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @example\n * import { DataStore } from 'js-data';\n * import { HttpAdapter } from 'js-data-http';\n *\n * const httpAdapter = new HttpAdapter();\n * const store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n *\n * store.defineMapper('school');\n * store.defineMapper('student');\n *\n * // GET /school/1\n * store.find('school', 1).then((school) => {\n * console.log('school');\n * });\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}.\n * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}.\n * @param {object} [opts.http=axios] See {@link HttpAdapter#http}.\n * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}.\n * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}.\n * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}.\n * @see http://www.js-data.io/docs/js-data-http\n */\nexport function HttpAdapter (opts) {\n utils.classCallCheck(this, HttpAdapter)\n\n opts || (opts = {})\n // Fill in any missing options with the defaults\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(this, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\nAdapter.extend({\n constructor: HttpAdapter,\n\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n return this.GET(\n this.getPath('count', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _create (mapper, props, opts) {\n return this.POST(\n this.getPath('create', mapper, props, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _createMany (mapper, props, opts) {\n return this.POST(\n this.getPath('createMany', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroy (mapper, id, opts) {\n return this.DEL(\n this.getPath('destroy', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroyAll (mapper, query, opts) {\n return this.DEL(\n this.getPath('destroyAll', mapper, null, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n return this.GET(\n this.getPath('find', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _findAll (mapper, query, opts) {\n return this.GET(\n this.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _sum (mapper, field, query, opts) {\n return this.GET(\n this.getPath('sum', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _update (mapper, id, props, opts) {\n return this.PUT(\n this.getPath('update', mapper, id, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateAll (mapper, props, query, opts) {\n return this.PUT(\n this.getPath('updateAll', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateMany (mapper, records, opts) {\n return this.PUT(\n this.getPath('updateMany', mapper, null, opts),\n this.serialize(mapper, records, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params.count = true\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.count.call(this, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {object} mapper The mapper.\n * @param {object} props Properties to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.create.call(this, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {object} mapper The mapper.\n * @param {array} props Array of property objects to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.createMany.call(this, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'DEL'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {object} mapper The mapper used for the operation.\n * @param {object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {object} opts Configuration options.\n * @return {(object|array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroy.call(this, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroyAll.call(this, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {object} config Request configuration.\n * @param {object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {object} config.headers Headers for the request.\n * @param {object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n */\n fetch (config) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers || {})\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(buildUrl(config.url, config.params), requestConfig)\n .then((response) => {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json()\n .then((data) => {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.find.call(this, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.findAll.call(this, mapper, query, opts)\n },\n\n /**\n * Make a GET request.\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'GET'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {object} mapper The Mapper.\n * @param {*} id The primary key, if any.\n * @param {boolean} opts Configuration options.\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach((def) => {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, (value, key) => {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method The method being executed.\n * @param {object} mapper The Mapper.\n * @param {(string|number)?} id The primary key, if any.\n * @param {object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n opts || (opts = {})\n const args = [\n opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath,\n this.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (opts.params === undefined) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (opts.suffix === undefined) {\n if (mapper.suffix === undefined) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, this.httpConfig)\n config.data = payload\n config.cache = cache\n if (timeout !== undefined) {\n config.timeout = timeout\n }\n if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || this.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n const logResponse = (data) => {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (this.log) {\n this.dbg(str, data)\n }\n return data\n } else {\n if (this.error) {\n this.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!this.http) {\n if ((this.useFetch || opts.useFetch)) {\n if (!hasFetch) {\n throw new Error('Attempting to use window.fetch, but it is not available!')\n }\n } else {\n throw new Error('You have not configured this adapter with an http library!')\n }\n }\n\n return utils.resolve(this.beforeHTTP(config, opts))\n .then((_config) => {\n config = _config || config\n if (hasFetch && (this.useFetch || opts.useFetch || !this.http)) {\n return this.fetch(config, opts).then(logResponse, logResponse)\n }\n const httpConfig = utils.plainCopy(config)\n delete httpConfig.adapter\n return this.http(httpConfig).then(logResponse, logResponse)\n .catch((err) => this.responseError(err, config, opts))\n })\n .then((response) => {\n return utils.resolve(this.afterHTTP(config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a POST request.\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'POST'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a PUT request.\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'PUT'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the querystring object before it is serialized. This doesn't do\n * anything by default.\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {*} params The querystring object.\n * @param {*} opts Configuration options\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * Serialize request data. This doesn't do anything by default.\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {object} data The request payload.\n * @param {*} opts Configuration options.\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n query || (query = {})\n opts || (opts = {})\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = this.getParams(opts)\n opts.params.sum = field\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.sum.call(this, mapper, field, query, opts)\n },\n\n /**\n * Perform an update. Makes a PUT request by default.\n *\n * @name HttpAdapter#update\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {*} id The primary key of the record being updated.\n * @param {*} props The update payload.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.update.call(this, mapper, id, props, opts)\n },\n\n /**\n * Perform an update against records that match the selection query. Makes a\n * PUT request by default.\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {object} props The update payload.\n * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateAll.call(this, mapper, props, query, opts)\n },\n\n /**\n * Update multiple individual records in a batch.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {array} records Array of property objects to send as the payload.\n * Each must contain the primary key of the record to be updated.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateMany.call(this, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addAction = JSDataHttp.addAction;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * endpoint: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {object} [opts] Action configuration\n * @param {string} [opts.adapter=\"http\"] The name of the adapter to use.\n * @param {string} [opts.pathname] Set the action's pathname.\n * @param {function} [opts.request] Specify a request handler to be executed\n * before the request is made.\n * @param {function} [opts.response] Specify a response handler to be executed\n * after the response is received.\n * @param {function} [opts.responseError] Specify an error handler to be\n * executed on error.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addAction (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n _opts = _opts || {}\n if (utils.isObject(id)) {\n _opts = id\n }\n utils.fillIn(_opts, opts)\n let adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http')\n const config = {}\n config.mapper = this.name\n utils.deepMixIn(config, _opts)\n config.method = config.method || 'GET'\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(this, _opts)\n } else {\n let args = [\n _opts.basePath || this.basePath || adapter.basePath,\n adapter.getEndpoint(this, id, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n return utils.resolve(config)\n .then(_opts.request)\n .then((config) => adapter.HTTP(config))\n .then((data) => {\n if (data && data.config) {\n data.config.mapper = this.name\n }\n return data\n })\n .then(_opts.response, _opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addActions = JSDataHttp.addActions;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * addActions({\n * // GET /reports/schools/:school_id/teachers\n * getTeacherReports: {\n * basePath: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * }\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addActions\n * @method\n * @param {object.} opts Object where the key is an action name\n * and the value is the configuration for the action.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name module:js-data-http.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http`\n * that works on Node.js is registered in NPM as `js-data-http-node`. The build\n * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower\n * as `js-data-fetch`.\n *\n * @example Script tag\n * var HttpAdapter = window.JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example ES2015 Modules\n * import { HttpAdapter } from 'js-data-Http';\n * const httpAdapter = new HttpAdapter();\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * // ...\n * });\n *\n * @module js-data-http\n */\n\n/**\n * Create a subclass of this HttpAdapter:\n * @example HttpAdapter.extend\n * // Normally you would do: import { HttpAdapter } from 'js-data-http';\n * // or: import { HttpAdapter } from 'js-data-http-node';\n * const JSDataHttp = require('js-data-http-node');\n * const { HttpAdapter } = JSDataHttp;\n * console.log('Using JSDataHttp v' + JSDataHttp.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomHttpAdapterClass extends HttpAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customHttpAdapter = new CustomHttpAdapterClass();\n * console.log(customHttpAdapter.foo());\n * console.log(CustomHttpAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherHttpAdapterClass = HttpAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const otherHttpAdapter = new OtherHttpAdapterClass();\n * console.log(otherHttpAdapter.foo());\n * console.log(OtherHttpAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherHttpAdapterClass () {\n * HttpAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * HttpAdapter.extend({\n * constructor: AnotherHttpAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const anotherHttpAdapter = new AnotherHttpAdapterClass();\n * console.log(anotherHttpAdapter.created_at);\n * console.log(anotherHttpAdapter.foo());\n * console.log(AnotherHttpAdapterClass.beep());\n *\n * @method HttpAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this HttpAdapter class.\n * @since 3.0.0\n */\n"],"names":["noop","args","opts","length","dbg","op","utils","resolve","noop2","unique","array","seen","final","forEach","item","push","withoutRelations","mapper","props","with","relationFields","toStrip","filter","value","indexOf","omit","Response","data","meta","fillIn","DEFAULTS","Adapter","classCallCheck","call","Component","extend","query","then","_count","results","result","response","respond","_response","undefined","_props","_create","created","map","record","_createMany","id","_destroy","_destroyAll","def","records","__opts","relationDef","getRelation","isObject","isArray","find","makeBelongsToForeignKey","relatedItem","setLocalField","keys","key","findAll","idAttribute","relatedItems","foreignKey","_find","loadRelationsFor","found","activeWith","_activeWith","activeQuery","replace","deepFillIn","_findAll","tasks","forEachRelation","task","type","loadHasOne","loadHasMany","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadBelongsTo","Promise","all","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","where","attached","get","relatedMapper","makeHasManyLocalKeys","concat","x","itemKeys","Object","makeHasManyForeignKeys","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","field","isString","Error","_sum","getOpt","_update","updated","_updateAll","_records","_updateMany","hasFetch","window","fetch","e","isValidString","join","items","separator","makePath","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","v","toString","toISOString","toJson","axios","HttpAdapter","GET","getPath","_end","POST","serialize","DEL","deserialize","PUT","getParams","count","suffix","getSuffix","deepMixIn","queryTransform","prototype","create","createMany","config","method","_config","HTTP","isFunction","hasOwnProperty","destroy","destroyAll","console","error","requestConfig","Headers","headers","body","json","isUndefined","relationList","endpoint","name","parent","parentKey","parentDef","parentId","_opts","_","getEndpoint","basePath","isNumber","apply","copy","start","Date","payload","cache","timeout","httpConfig","forceTrailingSlash","toUpperCase","substr","logResponse","str","toUTCString","status","getTime","log","reject","http","useFetch","beforeHTTP","adapter","catch","err","responseError","afterHTTP","sum","update","updateAll","updateMany","addAction","TypeError","request","getAdapter","defaultAdapter","isSorN","pathname","addActions","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,OAAO,SAAPA,IAAO,GAAmB;oCAANC,IAAM;QAAA;;;MAC/BC,OAAOD,KAAKA,KAAKE,MAAL,GAAc,CAAnB,CAAb;OACKC,GAAL,cAASF,KAAKG,EAAd,SAAqBJ,IAArB;SACOK,aAAMC,OAAN,EAAP;CAHK;;AAMP,AAAO,IAAMC,QAAQ,SAARA,KAAQ,GAAmB;qCAANP,IAAM;QAAA;;;MAChCC,OAAOD,KAAKA,KAAKE,MAAL,GAAc,CAAnB,CAAb;OACKC,GAAL,cAASF,KAAKG,EAAd,SAAqBJ,IAArB;SACOK,aAAMC,OAAN,EAAP;CAHK;;AAMP,AAAO,IAAME,SAAS,SAATA,MAAS,CAAUC,KAAV,EAAiB;MAC/BC,OAAO,EAAb;MACMC,QAAQ,EAAd;QACMC,OAAN,CAAc,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AAf,EAAqB/L,IAArB,CAAb;;aAEKK,aAAMC,OAAN,CAAc6J,MAAd,EACJ/H,IADI,CACCsJ,MAAMqC,OADP,EAEJ3L,IAFI,CAEC,UAAC+H,MAAD;eAAYiD,QAAQ9C,IAAR,CAAaH,MAAb,CAAZ;OAFD,EAGJ/H,IAHI,CAGC,UAACV,IAAD,EAAU;YACVA,QAAQA,KAAKyI,MAAjB,EAAyB;eAClBA,MAAL,CAAYnJ,MAAZ,GAAqB,QAAKqK,IAA1B;;eAEK3J,IAAP;OAPG,EASJU,IATI,CASCsJ,MAAMlJ,QATP,EASiBkJ,MAAM6B,aATvB,CAAP;KAxBF;WAmCOvM,MAAP;GA1CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFF,AAAO,SAASoN,UAAT,CAAqBnO,IAArB,EAA2B;WACvBA,OAAO,EAAhB;SACO,UAAUe,MAAV,EAAkB;iBACjB2H,MAAN,CAAa1I,IAAb,EAAmB,UAAUqB,KAAV,EAAiB2C,GAAjB,EAAsB;gBAC7BA,GAAV,EAAe3C,KAAf,EAAsBN,MAAtB;KADF;WAGOA,MAAP;GAJF;;;;;;;;;;;;;;;;;AAsBF,AAAO,IAAMqN,UAAU,gBAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.min.js b/fetch/dist/js-data-fetch.min.js index 668d5fe..59ad8db 100644 --- a/fetch/dist/js-data-fetch.min.js +++ b/fetch/dist/js-data-fetch.min.js @@ -1,10 +1,10 @@ /*! * js-data-fetch -* @version 3.0.0-rc.3 - Homepage +* @version 3.0.0 - Homepage * @copyright (c) 2014-2016 js-data-http project authors * @license MIT * * @overview HTTP adapter for js-data that uses the fetch API. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-fetch",["exports","js-data"],e):e(t.JSDataHttp=t.JSDataHttp||{},t.JSData)}(this,function(t,e){"use strict";function n(t,n,r){n||(n={}),this.data=t,e.utils.fillIn(this,n),this.op=r}function r(t){e.utils.classCallCheck(this,r),e.Component.call(this,t),t||(t={}),e.utils.fillIn(t,b),e.utils.fillIn(this,t)}function i(t){return null!=t&&""!==t}function o(t,e){return e||(e=""),t.filter(i).join(e)}function a(){for(var t=arguments.length,e=Array(t),n=0;n0&&(t+=(t.indexOf("?")===-1?"?":"&")+r.join("&")),t}function l(t){e.utils.classCallCheck(this,l),t||(t={}),e.utils.fillIn(t,P),r.call(this,t)}function f(t,n){if(!t||!e.utils.isString(t))throw new TypeError("action(name[, opts]): Expected: string, Found: "+("undefined"==typeof t?"undefined":h(t)));return function(r){if(r[t])throw new Error("action(name[, opts]): "+t+" already exists on target!");return n.request=n.request||function(t){return t},n.response=n.response||function(t){return t},n.responseError=n.responseError||function(t){return e.utils.reject(t)},r[t]=function(r,i){var o=this;i=i||{},e.utils.isObject(r)&&(i=r),e.utils.fillIn(i,n);var u=this.getAdapter(i.adapter||this.defaultAdapter||"http"),s={};if(s.mapper=this.name,e.utils.deepMixIn(s,i),s.method=s.method||"GET","function"==typeof i.getEndpoint)s.url=i.getEndpoint(this,i);else{var l=[i.basePath||this.basePath||u.basePath,u.getEndpoint(this,r,i)];e.utils.isSorN(r)&&l.push(r),l.push(n.pathname||t),s.url=a.apply(null,l)}return e.utils.resolve(s).then(i.request).then(function(t){return u.HTTP(t)}).then(function(t){return t&&t.config&&(t.config.mapper=o.name),t}).then(i.response,i.responseError)},r}}function c(t){return t||(t={}),function(n){return e.utils.forOwn(t,function(t,e){f(e,t)(n)}),n}}var h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},d=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},p=function(){function t(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&u.return&&u.return()}finally{if(i)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),v=function(){for(var t=arguments.length,n=Array(t),r=0;r=200&&n.status<300?(r.log&&r.dbg(o,n),n):(r.error&&r.error("'FAILED: "+o,n),e.utils.reject(n))};if(!this.http)throw new Error("You have not configured this adapter with an http library!");return e.utils.resolve(this.beforeHTTP(t,n)).then(function(e){return t=e||t,A&&(r.useFetch||n.useFetch||!r.http)?r.fetch(t,n).then(l,l):r.http(t).then(l,l).catch(function(e){return r.responseError(e,t,n)})}).then(function(i){return e.utils.resolve(r.afterHTTP(t,n,i)).then(function(t){return void 0===t?i:t})})},POST:function(t,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=t||r.url,r.data=n||r.data,r.method=r.method||"post",a=i.op="beforePOST",e.utils.resolve(this[a](t,n,r,i)).then(function(e){return r=void 0===e?r:e,a=i.op="POST",o.dbg(a,t,n,r,i),o.HTTP(r,i)}).then(function(u){return a=i.op="afterPOST",e.utils.resolve(o[a](t,n,r,i,u)).then(function(t){return void 0===t?u:t})})},PUT:function(t,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=t||r.url,r.data=n||r.data,r.method=r.method||"put",a=i.op="beforePUT",e.utils.resolve(this[a](t,n,r,i)).then(function(e){return r=void 0===e?r:e,a=i.op="PUT",o.dbg(a,t,n,r,i),o.HTTP(r,i)}).then(function(u){return a=i.op="afterPUT",e.utils.resolve(o[a](t,n,r,i,u)).then(function(t){return void 0===t?u:t})})},queryTransform:function(t,n,r){return r||(r={}),e.utils.isFunction(r.queryTransform)?r.queryTransform(t,n,r):e.utils.isFunction(t.queryTransform)?t.queryTransform(t,n,r):n},responseError:function(t,n,r){return e.utils.reject(t)},serialize:function(t,n,r){return r||(r={}),e.utils.isFunction(r.serialize)?r.serialize(t,n,r):e.utils.isFunction(t.serialize)?t.serialize(t,n,r):n},sum:function(t,n,i,o){if(i||(i={}),o||(o={}),!e.utils.isString(n))throw new Error("field must be a string!");return o.params=this.getParams(o),o.params.sum=n,o.suffix=this.getSuffix(t,o),e.utils.deepMixIn(o.params,i),o.params=this.queryTransform(t,o.params,o),r.prototype.sum.call(this,t,n,i,o)},update:function(t,e,n,i){return i||(i={}),i.params=this.getParams(i),i.params=this.queryTransform(t,i.params,i),i.suffix=this.getSuffix(t,i),r.prototype.update.call(this,t,e,n,i)},updateAll:function(t,n,i,o){return i||(i={}),o||(o={}),o.params=this.getParams(o),e.utils.deepMixIn(o.params,i),o.params=this.queryTransform(t,o.params,o),o.suffix=this.getSuffix(t,o),r.prototype.updateAll.call(this,t,n,i,o)},updateMany:function(t,e,n){return n||(n={}),n.params=this.getParams(n),n.params=this.queryTransform(t,n.params,n),n.suffix=this.getSuffix(t,n),r.prototype.updateMany.call(this,t,e,n)}});var M={full:"3.0.0-rc.3",major:3,minor:0,patch:0};t.HttpAdapter=l,t.addAction=f,t.addActions=c,t.version=M,Object.defineProperty(t,"__esModule",{value:!0})}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-fetch",["exports","js-data"],e):e(t.JSDataHttp=t.JSDataHttp||{},t.JSData)}(this,function(t,e){"use strict";function Response(t,n,r){n||(n={}),this.data=t,e.utils.fillIn(this,n),this.op=r}function Adapter(t){e.utils.classCallCheck(this,Adapter),e.Component.call(this,t),t||(t={}),e.utils.fillIn(t,l),e.utils.fillIn(this,t)}function isValidString(t){return null!=t&&""!==t}function join(t,e){return e||(e=""),t.filter(isValidString).join(e)}function makePath(){for(var t=arguments.length,e=Array(t),n=0;n0&&(t+=(-1===t.indexOf("?")?"?":"&")+r.join("&")),t}function HttpAdapter(t){e.utils.classCallCheck(this,HttpAdapter),t||(t={}),e.utils.fillIn(t,d),Adapter.call(this,t)}function addAction(t,r){if(!t||!e.utils.isString(t))throw new TypeError("action(name[, opts]): Expected: string, Found: "+(void 0===t?"undefined":n(t)));return function(n){if(n[t])throw new Error("action(name[, opts]): "+t+" already exists on target!");return r.request=r.request||function(t){return t},r.response=r.response||function(t){return t},r.responseError=r.responseError||function(t){return e.utils.reject(t)},n[t]=function(n,i){var o=this;i=i||{},e.utils.isObject(n)&&(i=n),e.utils.fillIn(i,r);var a=this.getAdapter(i.adapter||this.defaultAdapter||"http"),s={};if(s.mapper=this.name,e.utils.deepMixIn(s,i),s.method=s.method||"GET","function"==typeof i.getEndpoint)s.url=i.getEndpoint(this,i);else{var u=[i.basePath||this.basePath||a.basePath,a.getEndpoint(this,n,i)];e.utils.isSorN(n)&&u.push(n),u.push(r.pathname||t),s.url=makePath.apply(null,u)}return e.utils.resolve(s).then(i.request).then(function(t){return a.HTTP(t)}).then(function(t){return t&&t.config&&(t.config.mapper=o.name),t}).then(i.response,i.responseError)},n}}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},i=function(){function sliceIterator(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return sliceIterator(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function noop(){for(var t=arguments.length,n=Array(t),r=0;r=200&&n.status<300?(r.log&&r.dbg(o,n),n):(r.error&&r.error("'FAILED: "+o,n),e.utils.reject(n))};if(!this.http){if(!this.useFetch&&!n.useFetch)throw new Error("You have not configured this adapter with an http library!");if(!f)throw new Error("Attempting to use window.fetch, but it is not available!")}return e.utils.resolve(this.beforeHTTP(t,n)).then(function(i){if(t=i||t,f&&(r.useFetch||n.useFetch||!r.http))return r.fetch(t,n).then(l,l);var o=e.utils.plainCopy(t);return delete o.adapter,r.http(o).then(l,l).catch(function(e){return r.responseError(e,t,n)})}).then(function(i){return e.utils.resolve(r.afterHTTP(t,n,i)).then(function(t){return void 0===t?i:t})})},POST:function POST(t,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=t||r.url,r.data=n||r.data,r.method=r.method||"post",a=i.op="beforePOST",e.utils.resolve(this[a](t,n,r,i)).then(function(e){return r=void 0===e?r:e,a=i.op="POST",o.dbg(a,t,n,r,i),o.HTTP(r,i)}).then(function(s){return a=i.op="afterPOST",e.utils.resolve(o[a](t,n,r,i,s)).then(function(t){return void 0===t?s:t})})},PUT:function PUT(t,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=t||r.url,r.data=n||r.data,r.method=r.method||"put",a=i.op="beforePUT",e.utils.resolve(this[a](t,n,r,i)).then(function(e){return r=void 0===e?r:e,a=i.op="PUT",o.dbg(a,t,n,r,i),o.HTTP(r,i)}).then(function(s){return a=i.op="afterPUT",e.utils.resolve(o[a](t,n,r,i,s)).then(function(t){return void 0===t?s:t})})},queryTransform:function queryTransform(t,n,r){return r||(r={}),e.utils.isFunction(r.queryTransform)?r.queryTransform(t,n,r):e.utils.isFunction(t.queryTransform)?t.queryTransform(t,n,r):n},responseError:function responseError(t,n,r){return e.utils.reject(t)},serialize:function serialize(t,n,r){return r||(r={}),e.utils.isFunction(r.serialize)?r.serialize(t,n,r):e.utils.isFunction(t.serialize)?t.serialize(t,n,r):n},sum:function sum(t,n,r,i){if(r||(r={}),i||(i={}),!e.utils.isString(n))throw new Error("field must be a string!");return i.params=this.getParams(i),i.params.sum=n,i.suffix=this.getSuffix(t,i),e.utils.deepMixIn(i.params,r),i.params=this.queryTransform(t,i.params,i),Adapter.prototype.sum.call(this,t,n,r,i)},update:function update(t,e,n,r){return r||(r={}),r.params=this.getParams(r),r.params=this.queryTransform(t,r.params,r),r.suffix=this.getSuffix(t,r),Adapter.prototype.update.call(this,t,e,n,r)},updateAll:function updateAll(t,n,r,i){return r||(r={}),i||(i={}),i.params=this.getParams(i),e.utils.deepMixIn(i.params,r),i.params=this.queryTransform(t,i.params,i),i.suffix=this.getSuffix(t,i),Adapter.prototype.updateAll.call(this,t,n,r,i)},updateMany:function updateMany(t,e,n){return n||(n={}),n.params=this.getParams(n),n.params=this.queryTransform(t,n.params,n),n.suffix=this.getSuffix(t,n),Adapter.prototype.updateMany.call(this,t,e,n)}});var c={full:"3.0.0",major:3,minor:0,patch:0};t.HttpAdapter=HttpAdapter,t.addAction=addAction,t.addActions=function addActions(t){return t||(t={}),function(n){return e.utils.forOwn(t,function(t,e){addAction(e,t)(n)}),n}},t.version=c,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=js-data-fetch.min.map \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.min.js.map b/fetch/dist/js-data-fetch.min.js.map new file mode 100644 index 0000000..d641212 --- /dev/null +++ b/fetch/dist/js-data-fetch.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["fetch/dist/js-data-fetch.js"],"names":["global","factory","exports","module","require","define","amd","JSDataHttp","JSData","this","jsData","Response","data","meta","op","utils","fillIn","Adapter","opts","classCallCheck","Component","call","DEFAULTS$1","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","isArray","forEach","v","toString","toISOString","isObject","toJson","push","indexOf","HttpAdapter","DEFAULTS","addAction","name","isString","TypeError","_typeof","mapper","Error","request","config","response","responseError","err","reject","id","_opts","_this18","adapter","getAdapter","defaultAdapter","deepMixIn","method","getEndpoint","basePath","isSorN","pathname","apply","resolve","then","HTTP","Symbol","iterator","obj","constructor","prototype","defineProperty","Object","enumerable","configurable","writable","slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","next","done","noop","dbg","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","props","with","toStrip","relationFields","omit","debug","raw","extend","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","count","query","_this","_count","results","_results","result","respond","_response","create","_this2","_props","_create","_results2","created","createMany","_this3","map","record","_createMany","_results3","destroy","_this4","_destroy","_results4","destroyAll","_this5","_destroyAll","_results5","loadBelongsTo","def","records","__opts","_this6","relationDef","getRelation","find","makeBelongsToForeignKey","relatedItem","setLocalField","keys","findAll","where","idAttribute","in","relatedItems","foreignKey","_this7","_find","loadRelationsFor","_ref","_ref2","found","_this8","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_ref3","_ref4","_this9","tasks","forEachRelation","task","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","Promise","all","getOpt","opt","plainCopy","_this10","singular","IDs","makeHasManyForeignKey","criteria","attached","get","_this11","relatedMapper","makeHasManyLocalKeys","x","itemKeys","_this12","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","sum","field","_this13","_sum","_results7","update","_this14","_update","_results8","updated","updateAll","_this15","_updateAll","_results9","updateMany","_this16","_records","_updateMany","_results10","hasFetch","window","fetch","e","forceTrailingSlash","http","httpConfig","suffix","useFetch","afterDEL","afterGET","afterHTTP","afterPOST","afterPUT","beforeDEL","beforeGET","beforeHTTP","beforePOST","beforePUT","GET","getPath","_end","POST","serialize","DEL","deserialize","PUT","getParams","getSuffix","queryTransform","_config","isFunction","hasOwnProperty","error","console","_console","_fetch","_x","requestConfig","headers","Headers","body","json","isUndefined","relationList","endpoint","parent","parentKey","parentDef","parentId","_","isNumber","copy","start","Date","payload","cache","timeout","toUpperCase","substr","logResponse","str","toUTCString","status","getTime","log","catch","_this17","version","full","major","minor","patch","addActions"],"mappings":"CAAC,SAAUA,EAAQC,GACC,iBAAZC,SAA0C,oBAAXC,OAAyBF,EAAQC,QAASE,QAAQ,YACtE,mBAAXC,QAAyBA,OAAOC,IAAMD,OAAO,iBAAkB,UAAW,WAAYJ,GAC5FA,EAASD,EAAOO,WAAaP,EAAOO,eAAkBP,EAAOQ,SAC7DC,KAAM,SAAWP,EAAQQ,GAAU,aAsJrC,SAASC,SAASC,EAAMC,EAAMC,GAC5BD,IAASA,MAQTJ,KAAKG,KAAOA,EAEZF,EAAOK,MAAMC,OAAOP,KAAMI,GAQ1BJ,KAAKK,GAAKA,EAiCV,SAASG,QAAQC,GACjBR,EAAOK,MAAMI,eAAeV,KAAMQ,SAClCP,EAAOU,UAAUC,KAAKZ,KAAMS,GAC5BA,IAASA,MACTR,EAAOK,MAAMC,OAAOE,EAAMI,GAC1BZ,EAAOK,MAAMC,OAAOP,KAAMS,GAu5C5B,SAASK,cAAcC,GACrB,OAAgB,MAATA,GAA2B,KAAVA,EAE1B,SAASC,KAAKC,EAAOC,GAEnB,OADAA,IAAcA,EAAY,IACnBD,EAAME,OAAOL,eAAeE,KAAKE,GAE1C,SAASE,WACP,IAAK,IAAIC,EAAOC,UAAUC,OAAQC,EAAOC,MAAMJ,GAAOK,EAAO,EAAGA,EAAOL,EAAMK,IAC3EF,EAAKE,GAAQJ,UAAUI,GAIzB,OADaV,KAAKQ,EAAM,KACVG,QAAQ,mBAAoB,OAG5C,SAASC,OAAOC,GACd,OAAOC,mBAAmBD,GAAKF,QAAQ,QAAS,KAAKA,QAAQ,QAAS,KAAKA,QAAQ,OAAQ,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EAAKwB,OAASjC,KAAKgS,eAAe3O,EAAQ5C,EAAKwB,OAAQxB,GACvDA,EAAKiQ,OAAS1Q,KAAK+R,UAAU1O,EAAQ5C,GAC9BD,QAAQyE,UAAU6K,WAAWlP,KAAKZ,KAAMqD,EAAQwH,EAASpK,MAwKpE,IAAI8T,GACFC,KAAM,QACNC,MAAO,EACPC,MAAO,EACPC,MAAO,GAsFTlV,EAAQqD,YAAcA,YACtBrD,EAAQuD,UAAYA,UACpBvD,EAAQmV,WApHR,SAASA,WAAWnU,GAElB,OADAA,IAASA,MACF,SAAU4C,GAIf,OAHApD,EAAOK,MAAM6B,OAAO1B,EAAM,SAAUM,EAAOqB,GACzCY,UAAUZ,EAAKrB,GAAOsC,KAEjBA,IA+GX5D,EAAQ8U,QAAUA,EAElBpP,OAAOD,eAAezF,EAAS,cAAgBsB,OAAO"} \ No newline at end of file diff --git a/node/dist/js-data-http-node.js b/node/dist/js-data-http-node.js index c888f46..7301352 100644 --- a/node/dist/js-data-http-node.js +++ b/node/dist/js-data-http-node.js @@ -8,7 +8,7 @@ var jsDataAdapter = require('js-data-adapter'); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var axios = require('axios'); @@ -31,7 +31,7 @@ function makePath() { } var result = join(args, '/'); - return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); + return result.replace(/([^:/]|^)\/{2,}/g, '$1/'); } function encode(val) { @@ -95,6 +95,8 @@ var DEFAULTS = { */ forceTrailingSlash: false, + hasFetch: hasFetch, + /** * The HTTP function that actually makes the HTTP request. By default this is * `axios`. @@ -135,41 +137,40 @@ var DEFAULTS = { * @see http://www.js-data.io/docs/js-data-http#using-windowfetch */ useFetch: false -}; -/** - * HttpAdapter class. - * - * @example - * import { DataStore } from 'js-data'; - * import { HttpAdapter } from 'js-data-http'; - * - * const httpAdapter = new HttpAdapter(); - * const store = new DataStore(); - * - * store.registerAdapter('http', httpAdapter, { 'default': true }); - * - * store.defineMapper('school'); - * store.defineMapper('student'); - * - * // GET /school/1 - * store.find('school', 1).then((school) => { - * console.log('school'); - * }); - * - * @class HttpAdapter - * @extends Adapter - * @param {object} [opts] Configuration options. - * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}. - * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}. - * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}. - * @param {object} [opts.http=axios] See {@link HttpAdapter#http}. - * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}. - * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}. - * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}. - * @see http://www.js-data.io/docs/js-data-http - */ -function HttpAdapter(opts) { + /** + * HttpAdapter class. + * + * @example + * import { DataStore } from 'js-data'; + * import { HttpAdapter } from 'js-data-http'; + * + * const httpAdapter = new HttpAdapter(); + * const store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * + * store.defineMapper('school'); + * store.defineMapper('student'); + * + * // GET /school/1 + * store.find('school', 1).then((school) => { + * console.log('school'); + * }); + * + * @class HttpAdapter + * @extends Adapter + * @param {object} [opts] Configuration options. + * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}. + * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}. + * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}. + * @param {object} [opts.http=axios] See {@link HttpAdapter#http}. + * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}. + * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}. + * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}. + * @see http://www.js-data.io/docs/js-data-http + */ +};function HttpAdapter(opts) { jsData.utils.classCallCheck(this, HttpAdapter); opts || (opts = {}); @@ -724,20 +725,14 @@ jsDataAdapter.Adapter.extend({ } if (parentId) { - var _ret = function () { - delete opts.endpoint; - var _opts = {}; - jsData.utils.forOwn(opts, function (value, key) { - _opts[key] = value; - }); - jsData.utils._(_opts, parentDef); - endpoint = makePath(_this14.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); - return { - v: false - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + delete opts.endpoint; + var _opts = {}; + jsData.utils.forOwn(opts, function (value, key) { + _opts[key] = value; + }); + jsData.utils._(_opts, parentDef); + endpoint = makePath(_this14.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return false; } } }); @@ -802,7 +797,9 @@ jsDataAdapter.Adapter.extend({ config = jsData.utils.deepMixIn(config, this.httpConfig); config.data = payload; config.cache = cache; - config.timeout = timeout; + if (timeout !== undefined) { + config.timeout = timeout; + } if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { config.url += '/'; } @@ -828,7 +825,13 @@ jsDataAdapter.Adapter.extend({ }; if (!this.http) { - throw new Error('You have not configured this adapter with an http library!'); + if (this.useFetch || opts.useFetch) { + if (!hasFetch) { + throw new Error('Attempting to use window.fetch, but it is not available!'); + } + } else { + throw new Error('You have not configured this adapter with an http library!'); + } } return jsData.utils.resolve(this.beforeHTTP(config, opts)).then(function (_config) { @@ -836,7 +839,9 @@ jsDataAdapter.Adapter.extend({ if (hasFetch && (_this15.useFetch || opts.useFetch || !_this15.http)) { return _this15.fetch(config, opts).then(logResponse, logResponse); } - return _this15.http(config).then(logResponse, logResponse).catch(function (err) { + var httpConfig = jsData.utils.plainCopy(config); + delete httpConfig.adapter; + return _this15.http(httpConfig).then(logResponse, logResponse).catch(function (err) { return _this15.responseError(err, config, opts); }); }).then(function (response) { @@ -1246,12 +1251,95 @@ function addActions(opts) { * otherwise `false` if the current version is not beta. */ var version = { - full: '3.0.0-rc.3', + full: '3.0.0', major: 3, minor: 0, patch: 0 }; +/** + * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http` + * that works on Node.js is registered in NPM as `js-data-http-node`. The build + * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower + * as `js-data-fetch`. + * + * @example Script tag + * var HttpAdapter = window.JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example CommonJS + * var HttpAdapter = require('js-data-Http').HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example ES2015 Modules + * import { HttpAdapter } from 'js-data-Http'; + * const httpAdapter = new HttpAdapter(); + * + * @example AMD + * define('myApp', ['js-data-Http'], function (JSDataHttp) { + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * // ... + * }); + * + * @module js-data-http + */ + +/** + * Create a subclass of this HttpAdapter: + * @example HttpAdapter.extend + * // Normally you would do: import { HttpAdapter } from 'js-data-http'; + * // or: import { HttpAdapter } from 'js-data-http-node'; + * const JSDataHttp = require('js-data-http-node'); + * const { HttpAdapter } = JSDataHttp; + * console.log('Using JSDataHttp v' + JSDataHttp.version.full); + * + * // Extend the class using ES2015 class syntax. + * class CustomHttpAdapterClass extends HttpAdapter { + * foo () { return 'bar'; } + * static beep () { return 'boop'; } + * } + * const customHttpAdapter = new CustomHttpAdapterClass(); + * console.log(customHttpAdapter.foo()); + * console.log(CustomHttpAdapterClass.beep()); + * + * // Extend the class using alternate method. + * const OtherHttpAdapterClass = HttpAdapter.extend({ + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const otherHttpAdapter = new OtherHttpAdapterClass(); + * console.log(otherHttpAdapter.foo()); + * console.log(OtherHttpAdapterClass.beep()); + * + * // Extend the class, providing a custom constructor. + * function AnotherHttpAdapterClass () { + * HttpAdapter.call(this); + * this.created_at = new Date().getTime(); + * } + * HttpAdapter.extend({ + * constructor: AnotherHttpAdapterClass, + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const anotherHttpAdapter = new AnotherHttpAdapterClass(); + * console.log(anotherHttpAdapter.created_at); + * console.log(anotherHttpAdapter.foo()); + * console.log(AnotherHttpAdapterClass.beep()); + * + * @method HttpAdapter.extend + * @param {object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this HttpAdapter class. + * @since 3.0.0 + */ + exports.HttpAdapter = HttpAdapter; exports.addAction = addAction; exports.addActions = addActions; diff --git a/node/dist/js-data-http-node.js.map b/node/dist/js-data-http-node.js.map index 8793147..c35dc19 100644 --- a/node/dist/js-data-http-node.js.map +++ b/node/dist/js-data-http-node.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["../../src/index.js"],"sourcesContent":["import { utils } from 'js-data'\nimport axios from '../node_modules/axios/dist/axios'\nimport {\n Adapter,\n noop,\n noop2\n} from '../node_modules/js-data-adapter/src/index'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:\\/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst DEFAULTS = {\n /**\n * Set a base path in order to use absolute URLs instead of relative URLs.\n *\n * @example\n * const httpAdapter = new HttpAdapter({\n * basePath: 'https://mydomain.com'\n * });\n *\n * @name HttpAdapter#basePath\n * @type {string}\n * @since 3.0.0\n */\n basePath: '',\n\n /**\n * Ensure that the request url has a trailing forward slash.\n *\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n forceTrailingSlash: false,\n\n /**\n * The HTTP function that actually makes the HTTP request. By default this is\n * `axios`.\n *\n * @name HttpAdapter#http\n * @type {function}\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library\n */\n http: axios,\n\n /**\n * Default configuration options to be mixed into the `config` argument passed\n * to {@link HttpAdapter#http}.\n *\n * @name HttpAdapter#httpConfig\n * @type {object}\n * @since 3.0.0\n */\n httpConfig: {},\n\n /**\n * Add a suffix to the request url, e.g. \".json\".\n *\n * @name HttpAdapter#suffix\n * @type {string}\n * @since 3.0.0\n */\n suffix: '',\n\n /**\n * Use `window.fetch` if available.\n *\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-windowfetch\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @example\n * import { DataStore } from 'js-data';\n * import { HttpAdapter } from 'js-data-http';\n *\n * const httpAdapter = new HttpAdapter();\n * const store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n *\n * store.defineMapper('school');\n * store.defineMapper('student');\n *\n * // GET /school/1\n * store.find('school', 1).then((school) => {\n * console.log('school');\n * });\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}.\n * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}.\n * @param {object} [opts.http=axios] See {@link HttpAdapter#http}.\n * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}.\n * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}.\n * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}.\n * @see http://www.js-data.io/docs/js-data-http\n */\nexport function HttpAdapter (opts) {\n utils.classCallCheck(this, HttpAdapter)\n\n opts || (opts = {})\n // Fill in any missing options with the defaults\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(this, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\nAdapter.extend({\n constructor: HttpAdapter,\n\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n return this.GET(\n this.getPath('count', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _create (mapper, props, opts) {\n return this.POST(\n this.getPath('create', mapper, props, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _createMany (mapper, props, opts) {\n return this.POST(\n this.getPath('createMany', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroy (mapper, id, opts) {\n return this.DEL(\n this.getPath('destroy', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroyAll (mapper, query, opts) {\n return this.DEL(\n this.getPath('destroyAll', mapper, null, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n return this.GET(\n this.getPath('find', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _findAll (mapper, query, opts) {\n return this.GET(\n this.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _sum (mapper, field, query, opts) {\n return this.GET(\n this.getPath('sum', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _update (mapper, id, props, opts) {\n return this.PUT(\n this.getPath('update', mapper, id, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateAll (mapper, props, query, opts) {\n return this.PUT(\n this.getPath('updateAll', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateMany (mapper, records, opts) {\n return this.PUT(\n this.getPath('updateMany', mapper, null, opts),\n this.serialize(mapper, records, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params.count = true\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.count.call(this, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {object} mapper The mapper.\n * @param {object} props Properties to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.create.call(this, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {object} mapper The mapper.\n * @param {array} props Array of property objects to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.createMany.call(this, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'DEL'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {object} mapper The mapper used for the operation.\n * @param {object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {object} opts Configuration options.\n * @return {(object|array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroy.call(this, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroyAll.call(this, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {object} config Request configuration.\n * @param {object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {object} config.headers Headers for the request.\n * @param {object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n */\n fetch (config) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers || {})\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(buildUrl(config.url, config.params), requestConfig)\n .then((response) => {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json()\n .then((data) => {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.find.call(this, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.findAll.call(this, mapper, query, opts)\n },\n\n /**\n * Make a GET request.\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'GET'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {object} mapper The Mapper.\n * @param {*} id The primary key, if any.\n * @param {boolean} opts Configuration options.\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach((def) => {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, (value, key) => {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method The method being executed.\n * @param {object} mapper The Mapper.\n * @param {(string|number)?} id The primary key, if any.\n * @param {object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n opts || (opts = {})\n const args = [\n opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath,\n this.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (opts.params === undefined) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (opts.suffix === undefined) {\n if (mapper.suffix === undefined) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, this.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || this.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n const logResponse = (data) => {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (this.log) {\n this.dbg(str, data)\n }\n return data\n } else {\n if (this.error) {\n this.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!this.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(this.beforeHTTP(config, opts))\n .then((_config) => {\n config = _config || config\n if (hasFetch && (this.useFetch || opts.useFetch || !this.http)) {\n return this.fetch(config, opts).then(logResponse, logResponse)\n }\n return this.http(config).then(logResponse, logResponse)\n .catch((err) => this.responseError(err, config, opts))\n })\n .then((response) => {\n return utils.resolve(this.afterHTTP(config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a POST request.\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'POST'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a PUT request.\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'PUT'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the querystring object before it is serialized. This doesn't do\n * anything by default.\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {*} params The querystring object.\n * @param {*} opts Configuration options\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * Serialize request data. This doesn't do anything by default.\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {object} data The request payload.\n * @param {*} opts Configuration options.\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n query || (query = {})\n opts || (opts = {})\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = this.getParams(opts)\n opts.params.sum = field\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.sum.call(this, mapper, field, query, opts)\n },\n\n /**\n * Perform an update. Makes a PUT request by default.\n *\n * @name HttpAdapter#update\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {*} id The primary key of the record being updated.\n * @param {*} props The update payload.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.update.call(this, mapper, id, props, opts)\n },\n\n /**\n * Perform an update against records that match the selection query. Makes a\n * PUT request by default.\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {object} props The update payload.\n * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateAll.call(this, mapper, props, query, opts)\n },\n\n /**\n * Update multiple individual records in a batch.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {array} records Array of property objects to send as the payload.\n * Each must contain the primary key of the record to be updated.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateMany.call(this, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addAction = JSDataHttp.addAction;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * endpoint: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {object} [opts] Action configuration\n * @param {string} [opts.adapter=\"http\"] The name of the adapter to use.\n * @param {string} [opts.pathname] Set the action's pathname.\n * @param {function} [opts.request] Specify a request handler to be executed\n * before the request is made.\n * @param {function} [opts.response] Specify a response handler to be executed\n * after the response is received.\n * @param {function} [opts.responseError] Specify an error handler to be\n * executed on error.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addAction (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n _opts = _opts || {}\n if (utils.isObject(id)) {\n _opts = id\n }\n utils.fillIn(_opts, opts)\n let adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http')\n const config = {}\n config.mapper = this.name\n utils.deepMixIn(config, _opts)\n config.method = config.method || 'GET'\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(this, _opts)\n } else {\n let args = [\n _opts.basePath || this.basePath || adapter.basePath,\n adapter.getEndpoint(this, id, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n return utils.resolve(config)\n .then(_opts.request)\n .then((config) => adapter.HTTP(config))\n .then((data) => {\n if (data && data.config) {\n data.config.mapper = this.name\n }\n return data\n })\n .then(_opts.response, _opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addActions = JSDataHttp.addActions;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * addActions({\n * // GET /reports/schools/:school_id/teachers\n * getTeacherReports: {\n * basePath: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * }\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addActions\n * @method\n * @param {object.} opts Object where the key is an action name\n * and the value is the configuration for the action.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name module:js-data-http.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http`\n * that works on Node.js is registered in NPM as `js-data-http-node`. The build\n * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower\n * as `js-data-fetch`.\n *\n * @example Script tag\n * var HttpAdapter = window.JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example ES2015 Modules\n * import { HttpAdapter } from 'js-data-Http';\n * const httpAdapter = new HttpAdapter();\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * // ...\n * });\n *\n * @module js-data-http\n */\n\n/**\n * Create a subclass of this HttpAdapter:\n * @example HttpAdapter.extend\n * // Normally you would do: import { HttpAdapter } from 'js-data-http';\n * // or: import { HttpAdapter } from 'js-data-http-node';\n * const JSDataHttp = require('js-data-http-node');\n * const { HttpAdapter } = JSDataHttp;\n * console.log('Using JSDataHttp v' + JSDataHttp.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomHttpAdapterClass extends HttpAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customHttpAdapter = new CustomHttpAdapterClass();\n * console.log(customHttpAdapter.foo());\n * console.log(CustomHttpAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherHttpAdapterClass = HttpAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const otherHttpAdapter = new OtherHttpAdapterClass();\n * console.log(otherHttpAdapter.foo());\n * console.log(OtherHttpAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherHttpAdapterClass () {\n * HttpAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * HttpAdapter.extend({\n * constructor: AnotherHttpAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const anotherHttpAdapter = new AnotherHttpAdapterClass();\n * console.log(anotherHttpAdapter.created_at);\n * console.log(anotherHttpAdapter.foo());\n * console.log(AnotherHttpAdapterClass.beep());\n *\n * @method HttpAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this HttpAdapter class.\n * @since 3.0.0\n */\n"],"names":["utils","Adapter","noop2","noop"],"mappings":";;;;;;;;;;;;;AACA,4BAAA;AACA,AAMA,IAAI,WAAW,KAAf;;AAEA,IAAI;aACS,UAAU,OAAO,KAA5B;CADF,CAEE,OAAO,CAAP,EAAU;;AAEZ,SAAS,aAAT,CAAwB,KAAxB,EAA+B;SACrB,SAAS,IAAT,IAAiB,UAAU,EAAnC;;AAEF,SAAS,IAAT,CAAe,KAAf,EAAsB,SAAtB,EAAiC;gBACjB,YAAY,EAA1B;SACO,MAAM,MAAN,CAAa,aAAb,EAA4B,IAA5B,CAAiC,SAAjC,CAAP;;AAEF,SAAS,QAAT,GAA4B;oCAAN,IAAM;QAAA;;;MACtB,SAAS,KAAK,IAAL,EAAW,GAAX,CAAb;SACO,OAAO,OAAP,CAAe,mBAAf,EAAoC,KAApC,CAAP;;;AAGF,SAAS,MAAT,CAAiB,GAAjB,EAAsB;SACb,mBAAmB,GAAnB,EACJ,OADI,CACI,OADJ,EACa,GADb,EAEJ,OAFI,CAEI,OAFJ,EAEa,GAFb,EAGJ,OAHI,CAGI,MAHJ,EAGY,GAHZ,EAIJ,OAJI,CAII,OAJJ,EAIa,GAJb,EAKJ,OALI,CAKI,MALJ,EAKY,GALZ,EAMJ,OANI,CAMI,OANJ,EAMa,GANb,EAOJ,OAPI,CAOI,OAPJ,EAOa,GAPb,CAAP;;;AAUF,SAAS,QAAT,CAAmB,GAAnB,EAAwB,MAAxB,EAAgC;MAC1B,CAAC,MAAL,EAAa;WACJ,GAAP;;;MAGI,QAAQ,EAAd;;eAEM,MAAN,CAAa,MAAb,EAAqB,UAAU,GAAV,EAAe,GAAf,EAAoB;QACnC,QAAQ,IAAR,IAAgB,OAAO,GAAP,KAAe,WAAnC,EAAgD;;;QAG5C,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OAAO,CACT,MAAM,QAAN,IAAkB,KAAK,QAAvB,IAAmC,QAAQ,QADlC,EAET,QAAQ,WAAR,CAAoB,IAApB,EAA0B,EAA1B,EAA8B,KAA9B,CAFS,CAAX;YAIIA,aAAM,MAAN,CAAa,EAAb,CAAJ,EAAsB;eACf,IAAL,CAAU,EAAV;;aAEG,IAAL,CAAU,KAAK,QAAL,IAAiB,IAA3B;eACO,GAAP,GAAa,SAAS,KAAT,CAAe,IAAf,EAAqB,IAArB,CAAb;;aAEKA,aAAM,OAAN,CAAc,MAAd,EACJ,IADI,CACC,MAAM,OADP,EAEJ,IAFI,CAEC,UAAC,MAAD;eAAY,QAAQ,IAAR,CAAa,MAAb,CAAZ;OAFD,EAGJ,IAHI,CAGC,UAAC,IAAD,EAAU;YACV,QAAQ,KAAK,MAAjB,EAAyB;eAClB,MAAL,CAAY,MAAZ,GAAqB,QAAK,IAA1B;;eAEK,IAAP;OAPG,EASJ,IATI,CASC,MAAM,QATP,EASiB,MAAM,aATvB,CAAP;KAxBF;WAmCO,MAAP;GA1CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFF,AAAO,SAAS,UAAT,CAAqB,IAArB,EAA2B;WACvB,OAAO,EAAhB;SACO,UAAU,MAAV,EAAkB;iBACjB,MAAN,CAAa,IAAb,EAAmB,UAAU,KAAV,EAAiB,GAAjB,EAAsB;gBAC7B,GAAV,EAAe,KAAf,EAAsB,MAAtB;KADF;WAGO,MAAP;GAJF;;;;;;;;;;;;;;;;;AAsBF,AAAO,IAAM,UAAU,gBAAhB,CAEP;;;;;"} \ No newline at end of file +{"version":3,"file":"js-data-http-node.js","sources":["../../src/index.js"],"sourcesContent":["import { utils } from 'js-data'\nimport axios from '../node_modules/axios/dist/axios'\nimport {\n Adapter,\n noop,\n noop2\n} from '../node_modules/js-data-adapter/src/index'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst DEFAULTS = {\n /**\n * Set a base path in order to use absolute URLs instead of relative URLs.\n *\n * @example\n * const httpAdapter = new HttpAdapter({\n * basePath: 'https://mydomain.com'\n * });\n *\n * @name HttpAdapter#basePath\n * @type {string}\n * @since 3.0.0\n */\n basePath: '',\n\n /**\n * Ensure that the request url has a trailing forward slash.\n *\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n forceTrailingSlash: false,\n\n hasFetch: hasFetch,\n\n /**\n * The HTTP function that actually makes the HTTP request. By default this is\n * `axios`.\n *\n * @name HttpAdapter#http\n * @type {function}\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library\n */\n http: axios,\n\n /**\n * Default configuration options to be mixed into the `config` argument passed\n * to {@link HttpAdapter#http}.\n *\n * @name HttpAdapter#httpConfig\n * @type {object}\n * @since 3.0.0\n */\n httpConfig: {},\n\n /**\n * Add a suffix to the request url, e.g. \".json\".\n *\n * @name HttpAdapter#suffix\n * @type {string}\n * @since 3.0.0\n */\n suffix: '',\n\n /**\n * Use `window.fetch` if available.\n *\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-windowfetch\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @example\n * import { DataStore } from 'js-data';\n * import { HttpAdapter } from 'js-data-http';\n *\n * const httpAdapter = new HttpAdapter();\n * const store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n *\n * store.defineMapper('school');\n * store.defineMapper('student');\n *\n * // GET /school/1\n * store.find('school', 1).then((school) => {\n * console.log('school');\n * });\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}.\n * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}.\n * @param {object} [opts.http=axios] See {@link HttpAdapter#http}.\n * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}.\n * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}.\n * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}.\n * @see http://www.js-data.io/docs/js-data-http\n */\nexport function HttpAdapter (opts) {\n utils.classCallCheck(this, HttpAdapter)\n\n opts || (opts = {})\n // Fill in any missing options with the defaults\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(this, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\nAdapter.extend({\n constructor: HttpAdapter,\n\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n return this.GET(\n this.getPath('count', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _create (mapper, props, opts) {\n return this.POST(\n this.getPath('create', mapper, props, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _createMany (mapper, props, opts) {\n return this.POST(\n this.getPath('createMany', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroy (mapper, id, opts) {\n return this.DEL(\n this.getPath('destroy', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroyAll (mapper, query, opts) {\n return this.DEL(\n this.getPath('destroyAll', mapper, null, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n return this.GET(\n this.getPath('find', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _findAll (mapper, query, opts) {\n return this.GET(\n this.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _sum (mapper, field, query, opts) {\n return this.GET(\n this.getPath('sum', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _update (mapper, id, props, opts) {\n return this.PUT(\n this.getPath('update', mapper, id, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateAll (mapper, props, query, opts) {\n return this.PUT(\n this.getPath('updateAll', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateMany (mapper, records, opts) {\n return this.PUT(\n this.getPath('updateMany', mapper, null, opts),\n this.serialize(mapper, records, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params.count = true\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.count.call(this, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {object} mapper The mapper.\n * @param {object} props Properties to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.create.call(this, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {object} mapper The mapper.\n * @param {array} props Array of property objects to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.createMany.call(this, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'DEL'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {object} mapper The mapper used for the operation.\n * @param {object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {object} opts Configuration options.\n * @return {(object|array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroy.call(this, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroyAll.call(this, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {object} config Request configuration.\n * @param {object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {object} config.headers Headers for the request.\n * @param {object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n */\n fetch (config) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers || {})\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(buildUrl(config.url, config.params), requestConfig)\n .then((response) => {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json()\n .then((data) => {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.find.call(this, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.findAll.call(this, mapper, query, opts)\n },\n\n /**\n * Make a GET request.\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'GET'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {object} mapper The Mapper.\n * @param {*} id The primary key, if any.\n * @param {boolean} opts Configuration options.\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach((def) => {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, (value, key) => {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method The method being executed.\n * @param {object} mapper The Mapper.\n * @param {(string|number)?} id The primary key, if any.\n * @param {object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n opts || (opts = {})\n const args = [\n opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath,\n this.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (opts.params === undefined) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (opts.suffix === undefined) {\n if (mapper.suffix === undefined) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, this.httpConfig)\n config.data = payload\n config.cache = cache\n if (timeout !== undefined) {\n config.timeout = timeout\n }\n if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || this.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n const logResponse = (data) => {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (this.log) {\n this.dbg(str, data)\n }\n return data\n } else {\n if (this.error) {\n this.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!this.http) {\n if ((this.useFetch || opts.useFetch)) {\n if (!hasFetch) {\n throw new Error('Attempting to use window.fetch, but it is not available!')\n }\n } else {\n throw new Error('You have not configured this adapter with an http library!')\n }\n }\n\n return utils.resolve(this.beforeHTTP(config, opts))\n .then((_config) => {\n config = _config || config\n if (hasFetch && (this.useFetch || opts.useFetch || !this.http)) {\n return this.fetch(config, opts).then(logResponse, logResponse)\n }\n const httpConfig = utils.plainCopy(config)\n delete httpConfig.adapter\n return this.http(httpConfig).then(logResponse, logResponse)\n .catch((err) => this.responseError(err, config, opts))\n })\n .then((response) => {\n return utils.resolve(this.afterHTTP(config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a POST request.\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'POST'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a PUT request.\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'PUT'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the querystring object before it is serialized. This doesn't do\n * anything by default.\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {*} params The querystring object.\n * @param {*} opts Configuration options\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * Serialize request data. This doesn't do anything by default.\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {object} data The request payload.\n * @param {*} opts Configuration options.\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n query || (query = {})\n opts || (opts = {})\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = this.getParams(opts)\n opts.params.sum = field\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.sum.call(this, mapper, field, query, opts)\n },\n\n /**\n * Perform an update. Makes a PUT request by default.\n *\n * @name HttpAdapter#update\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {*} id The primary key of the record being updated.\n * @param {*} props The update payload.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.update.call(this, mapper, id, props, opts)\n },\n\n /**\n * Perform an update against records that match the selection query. Makes a\n * PUT request by default.\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {object} props The update payload.\n * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateAll.call(this, mapper, props, query, opts)\n },\n\n /**\n * Update multiple individual records in a batch.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {array} records Array of property objects to send as the payload.\n * Each must contain the primary key of the record to be updated.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateMany.call(this, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addAction = JSDataHttp.addAction;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * endpoint: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {object} [opts] Action configuration\n * @param {string} [opts.adapter=\"http\"] The name of the adapter to use.\n * @param {string} [opts.pathname] Set the action's pathname.\n * @param {function} [opts.request] Specify a request handler to be executed\n * before the request is made.\n * @param {function} [opts.response] Specify a response handler to be executed\n * after the response is received.\n * @param {function} [opts.responseError] Specify an error handler to be\n * executed on error.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addAction (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n _opts = _opts || {}\n if (utils.isObject(id)) {\n _opts = id\n }\n utils.fillIn(_opts, opts)\n let adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http')\n const config = {}\n config.mapper = this.name\n utils.deepMixIn(config, _opts)\n config.method = config.method || 'GET'\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(this, _opts)\n } else {\n let args = [\n _opts.basePath || this.basePath || adapter.basePath,\n adapter.getEndpoint(this, id, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n return utils.resolve(config)\n .then(_opts.request)\n .then((config) => adapter.HTTP(config))\n .then((data) => {\n if (data && data.config) {\n data.config.mapper = this.name\n }\n return data\n })\n .then(_opts.response, _opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addActions = JSDataHttp.addActions;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * addActions({\n * // GET /reports/schools/:school_id/teachers\n * getTeacherReports: {\n * basePath: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * }\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addActions\n * @method\n * @param {object.} opts Object where the key is an action name\n * and the value is the configuration for the action.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name module:js-data-http.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http`\n * that works on Node.js is registered in NPM as `js-data-http-node`. The build\n * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower\n * as `js-data-fetch`.\n *\n * @example Script tag\n * var HttpAdapter = window.JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example ES2015 Modules\n * import { HttpAdapter } from 'js-data-Http';\n * const httpAdapter = new HttpAdapter();\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * // ...\n * });\n *\n * @module js-data-http\n */\n\n/**\n * Create a subclass of this HttpAdapter:\n * @example HttpAdapter.extend\n * // Normally you would do: import { HttpAdapter } from 'js-data-http';\n * // or: import { HttpAdapter } from 'js-data-http-node';\n * const JSDataHttp = require('js-data-http-node');\n * const { HttpAdapter } = JSDataHttp;\n * console.log('Using JSDataHttp v' + JSDataHttp.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomHttpAdapterClass extends HttpAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customHttpAdapter = new CustomHttpAdapterClass();\n * console.log(customHttpAdapter.foo());\n * console.log(CustomHttpAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherHttpAdapterClass = HttpAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const otherHttpAdapter = new OtherHttpAdapterClass();\n * console.log(otherHttpAdapter.foo());\n * console.log(OtherHttpAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherHttpAdapterClass () {\n * HttpAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * HttpAdapter.extend({\n * constructor: AnotherHttpAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const anotherHttpAdapter = new AnotherHttpAdapterClass();\n * console.log(anotherHttpAdapter.created_at);\n * console.log(anotherHttpAdapter.foo());\n * console.log(AnotherHttpAdapterClass.beep());\n *\n * @method HttpAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this HttpAdapter class.\n * @since 3.0.0\n */\n"],"names":["hasFetch","window","fetch","e","isValidString","value","join","items","separator","filter","makePath","args","result","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","utils","isArray","forEach","v","toString","call","toISOString","isObject","toJson","push","length","indexOf","DEFAULTS","axios","HttpAdapter","opts","classCallCheck","fillIn","Adapter","extend","noop2","noop","mapper","query","GET","getPath","then","response","_end","props","POST","serialize","id","DEL","deserialize","field","PUT","records","getParams","count","suffix","getSuffix","deepMixIn","queryTransform","prototype","create","createMany","config","op","method","resolve","_config","undefined","dbg","HTTP","_response","isFunction","hasOwnProperty","data","destroy","destroyAll","console","error","requestConfig","Headers","headers","body","json","find","findAll","isUndefined","relationList","endpoint","name","def","type","parent","item","parentKey","foreignKey","parentDef","getRelation","parentId","getForeignKey","getLocalField","get","idAttribute","_opts","_","getEndpoint","basePath","isString","isNumber","apply","copy","start","Date","payload","cache","timeout","httpConfig","forceTrailingSlash","toUpperCase","substr","logResponse","str","toUTCString","status","getTime","log","reject","http","useFetch","Error","beforeHTTP","plainCopy","adapter","catch","err","responseError","afterHTTP","sum","update","updateAll","updateMany","addAction","TypeError","request","getAdapter","defaultAdapter","isSorN","pathname","addActions","version"],"mappings":";;;;;;;;;;;;;AACA,4BAAA;AACA,AAMA,IAAIA,WAAW,KAAf;;AAEA,IAAI;aACSC,UAAUA,OAAOC,KAA5B;CADF,CAEE,OAAOC,CAAP,EAAU;;AAEZ,SAASC,aAAT,CAAwBC,KAAxB,EAA+B;SACrBA,SAAS,IAAT,IAAiBA,UAAU,EAAnC;;AAEF,SAASC,IAAT,CAAeC,KAAf,EAAsBC,SAAtB,EAAiC;gBACjBA,YAAY,EAA1B;SACOD,MAAME,MAAN,CAAaL,aAAb,EAA4BE,IAA5B,CAAiCE,SAAjC,CAAP;;AAEF,SAASE,QAAT,GAA4B;oCAANC,IAAM;QAAA;;;MACtBC,SAASN,KAAKK,IAAL,EAAW,GAAX,CAAb;SACOC,OAAOC,OAAP,CAAe,kBAAf,EAAmC,KAAnC,CAAP;;;AAGF,SAASC,MAAT,CAAiBC,GAAjB,EAAsB;SACbC,mBAAmBD,GAAnB,EACJF,OADI,CACI,OADJ,EACa,GADb,EAEJA,OAFI,CAEI,OAFJ,EAEa,GAFb,EAGJA,OAHI,CAGI,MAHJ,EAGY,GAHZ,EAIJA,OAJI,CAII,OAJJ,EAIa,GAJb,EAKJA,OALI,CAKI,MALJ,EAKY,GALZ,EAMJA,OANI,CAMI,OANJ,EAMa,GANb,EAOJA,OAPI,CAOI,OAPJ,EAOa,GAPb,CAAP;;;AAUF,SAASI,QAAT,CAAmBC,GAAnB,EAAwBC,MAAxB,E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