diff --git a/dist/js-data-http.js b/dist/js-data-http.js index 8647eea..c7e86f6 100644 --- a/dist/js-data-http.js +++ b/dist/js-data-http.js @@ -1,4289 +1,4163 @@ /*! * js-data-http -* @version 3.0.0-beta.5 - Homepage +* @version 3.0.0-beta.6 - Homepage * @copyright (c) 2014-2016 js-data-http project authors * @license MIT * * @overview HTTP (XHR) adapter for js-data in the browser. */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("js-data")); - else if(typeof define === 'function' && define.amd) - define(["js-data"], factory); - else if(typeof exports === 'object') - exports["JSDataHttp"] = factory(require("js-data")); - else - root["JSDataHttp"] = factory(root["JSData"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) { -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__) { - - '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; }; - - var _jsData = __webpack_require__(1); - - var _jsDataAdapter = __webpack_require__(2); - - /* global fetch:true Headers:true Request:true */ - - var axios = __webpack_require__(3); - - - 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() { +(function (global, factory) { + 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'; + + var __commonjs_global = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : this; + function __commonjs(fn, module) { return module = { exports: {} }, fn(module, module.exports, __commonjs_global), module.exports; } + + + var babelHelpers = {}; + babelHelpers.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; + }; + + babelHelpers.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; + }; + + babelHelpers.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"); + } + }; + }(); + + babelHelpers; + + var axios = __commonjs(function (module, exports, global) { + /* axios v0.11.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(); + })(__commonjs_global, 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 defaults = __webpack_require__(2); + var utils = __webpack_require__(3); + var dispatchRequest = __webpack_require__(4); + var InterceptorManager = __webpack_require__(13); + var isAbsoluteURL = __webpack_require__(14); + var combineURLs = __webpack_require__(15); + var bind = __webpack_require__(16); + var transformData = __webpack_require__(8); + + function Axios(defaultConfig) { + this.defaults = utils.merge({}, defaultConfig); + this.interceptors = { + request: new InterceptorManager(), + response: new InterceptorManager() + }; + } + + 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); + } + + // Don't allow overriding defaults.withCredentials + config.withCredentials = config.withCredentials || this.defaults.withCredentials; + + // 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]; + } + ); + + // 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; + }; + + var defaultInstance = new Axios(defaults); + var axios = module.exports = bind(Axios.prototype.request, defaultInstance); + module.exports.Axios = Axios; + + // Expose properties from defaultInstance + axios.defaults = defaultInstance.defaults; + axios.interceptors = defaultInstance.interceptors; + + // Factory for creating new instances + axios.create = function create(defaultConfig) { + return new Axios(defaultConfig); + }; + + // Expose all/spread + axios.all = function all(promises) { + return Promise.all(promises); + }; + axios.spread = __webpack_require__(17); + + // 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 + })); + }; + axios[method] = bind(Axios.prototype[method], defaultInstance); + }); + + 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 + })); + }; + axios[method] = bind(Axios.prototype[method], defaultInstance); + }); + + + /***/ }, + /* 2 */ + /***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(3); + + var PROTECTION_PREFIX = /^\)\]\}',?\n/; + var DEFAULT_CONTENT_TYPE = { + 'Content-Type': 'application/x-www-form-urlencoded' + }; + + module.exports = { + transformRequest: [function transformRequest(data, headers) { + if (utils.isFormData(data) || utils.isArrayBuffer(data) || utils.isStream(data)) { + return data; + } + if (utils.isArrayBufferView(data)) { + return data.buffer; + } + if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) { + // Set application/json if no Content-Type has been specified + if (!utils.isUndefined(headers)) { + utils.forEach(headers, function processContentTypeHeader(val, key) { + if (key.toLowerCase() === 'content-type') { + headers['Content-Type'] = val; + } + }); + + if (utils.isUndefined(headers['Content-Type'])) { + headers['Content-Type'] = '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; + } + }; + + + /***/ }, + /* 3 */ + /***/ function(module, exports) { + + 'use strict'; + + /*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); + } + + /** + * 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; + } + + 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, + isStandardBrowserEnv: isStandardBrowserEnv, + forEach: forEach, + merge: merge, + trim: trim + }; + + + /***/ }, + /* 4 */ + /***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * 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) { + return new Promise(function executor(resolve, reject) { + try { + 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__(5); + } else if (typeof process !== 'undefined') { + // For node use HTTP adapter + adapter = __webpack_require__(5); + } + + if (typeof adapter === 'function') { + adapter(resolve, reject, config); + } + } catch (e) { + reject(e); + } + }); + }; + + + + /***/ }, + /* 5 */ + /***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(3); + var buildURL = __webpack_require__(6); + var parseHeaders = __webpack_require__(7); + var transformData = __webpack_require__(8); + var isURLSameOrigin = __webpack_require__(9); + var btoa = (typeof window !== 'undefined' && window.btoa) || __webpack_require__(10); + var settle = __webpack_require__(11); + + module.exports = function xhrAdapter(resolve, reject, config) { + 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: transformData( + responseData, + responseHeaders, + config.transformResponse + ), + // 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(new Error('Network Error')); + + // Clean up request + request = null; + }; + + // Handle timeout + request.ontimeout = function handleTimeout() { + var err = new Error('timeout of ' + config.timeout + 'ms exceeded'); + err.timeout = config.timeout; + err.code = 'ECONNABORTED'; + reject(err); + + // 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__(12); + + // 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 (config.progress) { + 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); + }; + + + /***/ }, + /* 6 */ + /***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(3); + + 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 { + 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; + }; + + + + /***/ }, + /* 7 */ + /***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(3); + + /** + * 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; + }; + + + /***/ }, + /* 8 */ + /***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(3); + + /** + * 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; + }; + + + /***/ }, + /* 9 */ + /***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(3); + + 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; + }; + })() + ); + + + /***/ }, + /* 10 */ + /***/ 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; + + + /***/ }, + /* 11 */ + /***/ function(module, exports) { + + 'use strict'; + + /** + * 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(response); + } + }; + + + /***/ }, + /* 12 */ + /***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(3); + + 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() {} + }; + })() + ); + + + /***/ }, + /* 13 */ + /***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils = __webpack_require__(3); + + 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; + + + /***/ }, + /* 14 */ + /***/ 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); + }; + + + /***/ }, + /* 15 */ + /***/ 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(/^\/+/, ''); + }; + + + /***/ }, + /* 16 */ + /***/ 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); + }; + }; + + + /***/ }, + /* 17 */ + /***/ 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); + }; + }; + + + /***/ } + /******/ ]) + }); + ; + }); + + var axios$1 = (axios && typeof axios === 'object' && 'default' in axios ? axios['default'] : axios); + + var noop = function noop() { + var self = this; + 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 opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - - var parts = []; - - _jsData.utils.forOwn(params, function (val, key) { - if (val === null || typeof val === 'undefined') { + + var opts = args[args.length - 2]; + self.dbg.apply(self, [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; } - if (!_jsData.utils.isArray(val)) { - val = [val]; - } - - val.forEach(function (v) { - if (window.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)); - }); + final.push(item); + seen[item] = 0; }); - - if (parts.length > 0) { - url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); - } - - return url; - } - - var __super__ = _jsDataAdapter.Adapter.prototype; - - var DEFAULTS = { - // Default and user-defined settings - /** - * @name HttpAdapter#basePath - * @type {string} - */ - basePath: '', - + return final; + }; + + var withoutRelations = function withoutRelations(mapper, props) { + return jsData.utils.omit(props, mapper.relationFields || []); + }; + + var DEFAULTS$1 = { /** - * @name HttpAdapter#forceTrailingSlash + * Whether to log debugging information. + * + * @name Adapter#debug * @type {boolean} * @default false */ - forceTrailingSlash: false, - - /** - * @name HttpAdapter#http - * @type {Function} - */ - http: axios, - - /** - * @name HttpAdapter#httpConfig - * @type {Object} - */ - httpConfig: {}, - - /** - * @name HttpAdapter#suffix - * @type {string} - */ - suffix: '', - + debug: false, + /** - * @name HttpAdapter#useFetch + * Whether to return a more detailed response object. + * + * @name Adapter#raw * @type {boolean} * @default false */ - useFetch: false + raw: false }; - + /** - * HttpAdapter class. + * Abstract class meant to be extended by adapters. * - * @class HttpAdapter - * @extends Adapter - * @param {Object} [opts] Configuration options. - * @param {string} [opts.basePath=''] TODO - * @param {boolean} [opts.debug=false] TODO - * @param {boolean} [opts.forceTrailingSlash=false] TODO - * @param {Object} [opts.http=axios] TODO - * @param {Object} [opts.httpConfig={}] TODO - * @param {string} [opts.suffix=''] TODO - * @param {boolean} [opts.useFetch=false] TODO + * @class Adapter + * @abstract + * @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 HttpAdapter(opts) { + function Adapter(opts) { var self = this; opts || (opts = {}); - _jsData.utils.fillIn(opts, DEFAULTS); - _jsDataAdapter.Adapter.call(self, opts); + jsData.utils.fillIn(opts, DEFAULTS$1); + jsData.utils.fillIn(self, opts); } - + /** - * @name module:js-data-http.HttpAdapter - * @see HttpAdapter + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @class Response */ - exports.HttpAdapter = HttpAdapter; - - // Setup prototype inheritance from Adapter - HttpAdapter.prototype = Object.create(_jsDataAdapter.Adapter.prototype, { - constructor: { - value: HttpAdapter, - enumerable: false, - writable: true, - configurable: true - } - }); - - Object.defineProperty(HttpAdapter, '__super__', { - configurable: true, - value: _jsDataAdapter.Adapter - }); - + function Response(data, meta, op) { + var self = this; + meta || (meta = {}); + + /** + * Response data. + * + * @name Response#data + * @type {*} + */ + self.data = data; + + jsData.utils.fillIn(self, meta); + + /** + * The operation for which the response was created. + * + * @name Response#op + * @type {string} + */ + self.op = op; + } + /** - * Alternative to ES6 class syntax for extending `HttpAdapter`. - * - * @example Using the ES2015 class syntax. - * class MyHttpAdapter extends HttpAdapter {...} - * const adapter = new MyHttpAdapter() - * - * @example Using {@link HttpAdapter.extend}. - * var instanceProps = {...} - * var classProps = {...} - * - * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) - * var adapter = new MyHttpAdapter() + * Alternative to ES6 class syntax for extending `Adapter`. * - * @name HttpAdapter.extend + * @name Adapter.extend * @method * @param {Object} [instanceProps] Properties that will be added to the * prototype of the subclass. * @param {Object} [classProps] Properties that will be added as static * properties to the subclass itself. - * @return {Object} Subclass of `HttpAdapter`. + * @return {Object} Subclass of `Adapter`. */ - HttpAdapter.extend = _jsData.utils.extend; - - _jsData.utils.addHiddenPropsToTarget(HttpAdapter.prototype, { + Adapter.extend = jsData.utils.extend; + + jsData.utils.addHiddenPropsToTarget(Adapter.prototype, { /** - * @name HttpAdapter#afterDEL + * 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 {string} url - * @param {Object} config - * @param {Object} opts - * @param {Object} response + * @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`. */ - afterDEL: _jsDataAdapter.noop2, - + afterCount: noop2, + /** - * @name HttpAdapter#afterGET + * 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 {string} url - * @param {Object} config - * @param {Object} opts - * @param {Object} response + * @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`. */ - afterGET: _jsDataAdapter.noop2, - + afterCreate: noop2, + /** - * @name HttpAdapter#afterHTTP + * 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} config - * @param {Object} opts - * @param {Object} response + * @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`. */ - afterHTTP: _jsDataAdapter.noop2, - + afterCreateMany: noop2, + /** - * @name HttpAdapter#afterPOST - * @method - * @param {string} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - * @param {Object} response + * 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`. */ - afterPOST: _jsDataAdapter.noop2, - + afterDestroy: noop2, + /** - * @name HttpAdapter#afterPUT + * 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 {string} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - * @param {Object} response + * @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`. */ - afterPUT: _jsDataAdapter.noop2, - + afterDestroyAll: noop2, + /** - * @name HttpAdapter#beforeDEL + * 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} url - * @param {Object} config - * @param {Object} opts + * @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`. */ - beforeDEL: _jsDataAdapter.noop, - + afterFind: noop2, + /** - * @name HttpAdapter#beforeGET + * 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} url - * @param {Object} config - * @param {Object} opts + * @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`. */ - beforeGET: _jsDataAdapter.noop, - + afterFindAll: noop2, + /** - * @name HttpAdapter#beforeHTTP + * 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} config - * @param {Object} opts + * @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`. */ - beforeHTTP: _jsDataAdapter.noop, - + afterSum: noop2, + /** - * @name HttpAdapter#beforePOST + * 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} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts + * @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`. */ - beforePOST: _jsDataAdapter.noop, - + afterUpdate: noop2, + /** - * @name HttpAdapter#beforePUT + * 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} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts + * @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`. */ - beforePUT: _jsDataAdapter.noop, - - _count: function _count(mapper, query, opts) { - var self = this; - return self.GET(self.getPath('count', mapper, opts.params, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _create: function _create(mapper, props, opts) { - var self = this; - return self.POST(self.getPath('create', mapper, props, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _createMany: function _createMany(mapper, props, opts) { - var self = this; - return self.POST(self.getPath('createMany', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _destroy: function _destroy(mapper, id, opts) { - var self = this; - return self.DEL(self.getPath('destroy', mapper, id, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _destroyAll: function _destroyAll(mapper, query, opts) { - var self = this; - return self.DEL(self.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _end: function _end(mapper, opts, response) { - return [this.deserialize(mapper, response, opts), response]; - }, - _find: function _find(mapper, id, opts) { - var self = this; - return self.GET(self.getPath('find', mapper, id, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _findAll: function _findAll(mapper, query, opts) { - var self = this; - return self.GET(self.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _sum: function _sum(mapper, field, query, opts) { - var self = this; - return self.GET(self.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _update: function _update(mapper, id, props, opts) { - var self = this; - return self.PUT(self.getPath('update', mapper, id, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _updateAll: function _updateAll(mapper, props, query, opts) { - var self = this; - return self.PUT(self.getPath('updateAll', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _updateMany: function _updateMany(mapper, records, opts) { - var self = this; - return self.PUT(self.getPath('updateMany', mapper, null, opts), self.serialize(mapper, records, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - - + afterUpdateAll: noop2, + /** - * Retrieve the number of records that match the selection `query`. + * Lifecycle method method called by updateMany. * - * @name HttpAdapter#count + * 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. - * @param {Object} query Selection query. - * @param {Object} [opts] Configuration options. - * @param {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} + * @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`. */ - count: function count(mapper, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params.count = true; - opts.suffix = self.getSuffix(mapper, opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - - return __super__.count.call(self, mapper, query, opts); - }, - - + afterUpdateMany: noop2, + /** - * Create a new the record from the provided `props`. + * Lifecycle method method called by count. * - * @name HttpAdapter#create + * 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. - * @param {Object} props Properties to send as the payload. - * @param {Object} [opts] Configuration options. - * @param {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} + * @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` */ - create: function create(mapper, props, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.create.call(self, mapper, props, opts); - }, - - + beforeCount: noop, + /** - * Create multiple new records in batch. + * Lifecycle method method called by create. * - * @name HttpAdapter#createMany + * 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. - * @param {Array} props Array of property objects to send as the payload. - * @param {Object} [opts] Configuration options. - * @param {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} + * @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` */ - createMany: function createMany(mapper, props, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.createMany.call(self, mapper, props, opts); - }, - - + beforeCreate: noop, + /** - * Make an Http request to `url` according to the configuration in `config`. + * Lifecycle method method called by createMany. * - * @name HttpAdapter#DEL + * 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 {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} + * @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` */ - DEL: function DEL(url, config, opts) { - var self = 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(self[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'DEL'; - self.dbg(op, url, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterDEL lifecycle hook - op = opts.op = 'afterDEL'; - return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - + beforeCreateMany: noop, + /** - * Transform the server response object into the payload that will be returned - * to JSData. + * Lifecycle method method called by destroy. * - * @name HttpAdapter#deserialize + * 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 used for the operation. - * @param {Object} response Response object from {@link HttpAdapter#HTTP}. - * @param {Object} opts Configuration options. - * @return {(Object|Array)} Deserialized data. + * @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` */ - 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; - }, - - + beforeDestroy: noop, + /** - * Destroy the record with the given primary key. + * Lifecycle method method called by destroyAll. * - * @name HttpAdapter#destroy + * 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. - * @param {(string|number)} id Primary key of the record to destroy. - * @param {Object} [opts] Configuration options. - * @param {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} + * @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` */ - destroy: function destroy(mapper, id, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.destroy.call(self, mapper, id, opts); + 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, + + /** + * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`. + * + * @name Adapter#dbg + * @method + */ + dbg: function dbg() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + this.log.apply(this, ['debug'].concat(args)); }, - - + + /** - * Destroy the records that match the selection `query`. + * Retrieve the number of records that match the selection query. Called by + * `Mapper#count`. * - * @name HttpAdapter#destroyAll + * @name Adapter#count * @method * @param {Object} mapper The mapper. - * @param {Object} query Selection query. + * @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 {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. * @return {Promise} */ - destroyAll: function destroyAll(mapper, query, opts) { + count: function count(mapper, query, opts) { var self = this; + var op = void 0; query || (query = {}); opts || (opts = {}); - opts.params = self.getParams(opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.destroyAll.call(self, 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); - } + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._count(mapper, query, opts)); + }).then(function (results) { + var _results = babelHelpers.slicedToArray(results, 2); + + var data = _results[0]; + var result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); }, - - + + /** - * Make an Http request using `window.fetch`. + * Create a new record. Called by `Mapper#create`. * - * @name HttpAdapter#fetch + * @name Adapter#create * @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. + * @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} */ - fetch: function (_fetch) { - function fetch(_x, _x2) { - return _fetch.apply(this, arguments); - } - - fetch.toString = function () { - return _fetch.toString(); - }; - - return fetch; - }(function (config, opts) { - 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(new Request(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; + create: function create(mapper, props, opts) { + var self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'create'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = babelHelpers.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 = self.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; }); }); - }), - - + }, + + /** - * Retrieve the record with the given primary key. + * Create multiple records in a single batch. Called by `Mapper#createMany`. * - * @name HttpAdapter#find + * @name Adapter#createMany * @method * @param {Object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} props The records to be created. * @param {Object} [opts] Configuration options. - * @param {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. * @return {Promise} */ - find: function find(mapper, id, opts) { + createMany: function createMany(mapper, props, opts) { var self = this; + var op = void 0; + props || (props = {}); opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.find.call(self, mapper, id, opts); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'createMany'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = babelHelpers.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 = self.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); }, - - + + /** - * Retrieve the records that match the selection `query`. + * Destroy the record with the given primary key. Called by + * `Mapper#destroy`. * - * @name HttpAdapter#findAll + * @name Adapter#destroy * @method * @param {Object} mapper The mapper. - * @param {Object} query Selection query. + * @param {(string|number)} id Primary key of the record to destroy. * @param {Object} [opts] Configuration options. - * @param {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. * @return {Promise} */ - findAll: function findAll(mapper, query, opts) { + destroy: function destroy(mapper, id, opts) { var self = this; - query || (query = {}); + var op = void 0; opts || (opts = {}); - opts.params = self.getParams(opts); - opts.suffix = self.getSuffix(mapper, opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - - return __super__.findAll.call(self, mapper, query, opts); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = babelHelpers.slicedToArray(results, 2); + + var data = _results4[0]; + var result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = self.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); }, - - + + /** - * TODO + * Destroy the records that match the selection query. Called by + * `Mapper#destroyAll`. * - * @name HttpAdapter#GET + * @name Adapter#destroyAll * @method - * @param {string} url The url for the request. - * @param {Object} config Request configuration options. + * @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} */ - GET: function GET(url, config, opts) { + destroyAll: function destroyAll(mapper, query, opts) { var self = this; var op = void 0; - config || (config = {}); + query || (query = {}); opts || (opts = {}); - config.url = url || config.url; - config.method = config.method || 'get'; - - // beforeGET lifecycle hook - op = opts.op = 'beforeGET'; - return _jsData.utils.resolve(self[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'GET'; - self.dbg(op, url, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterGET lifecycle hook - op = opts.op = 'afterGET'; - return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = babelHelpers.slicedToArray(results, 2); + + var data = _results5[0]; + var result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = self.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, - - + + /** - * @name HttpAdapter#getEndpoint + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo * @method - * @param {Object} mapper TODO - * @param {*} id TODO - * @param {boolean} opts TODO - * @return {string} Full path. + * @return {Promise} */ - getEndpoint: function getEndpoint(mapper, id, opts) { + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { var self = 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(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); - return { - v: false - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; - } - } - }); - - return endpoint; + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var _ret = function () { + var record = records; + return { + v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }) + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; + } else { + var keys = records.map(function (record) { + return self.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return self.findAll(relationDef, { + where: babelHelpers.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); + } + }); + }); + }); + } }, - - + + /** - * @name HttpAdapter#getPath + * Retrieve the record with the given primary key. Called by `Mapper#find`. + * + * @name Adapter#find * @method - * @param {string} method TODO - * @param {Object} mapper TODO - * @param {(string|number)?} id TODO - * @param {Object} opts Configuration options. + * @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} */ - getPath: function getPath(method, mapper, id, opts) { + find: function find(mapper, id, opts) { var self = this; + var record = void 0, + op = void 0; opts || (opts = {}); - var args = [_jsData.utils.isUndefined(opts.basePath) ? _jsData.utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath : opts.basePath, self.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 (_jsData.utils.isUndefined(opts.params)) { - return {}; - } - return _jsData.utils.copy(opts.params); - }, - getSuffix: function getSuffix(mapper, opts) { - opts || (opts = {}); - if (_jsData.utils.isUndefined(opts.suffix)) { - if (_jsData.utils.isUndefined(mapper.suffix)) { - return this.suffix; + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._find(mapper, id, opts)); + }).then(function (results) { + var _results6 = babelHelpers.slicedToArray(results, 1); + + var _record = _results6[0]; + + if (!_record) { + return; } - return mapper.suffix; - } - return opts.suffix; + record = _record; + 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 = self.loadHasOne(mapper, def, record, __opts); + } else { + task = self.loadHasMany(mapper, def, record, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, record, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, record, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, record, __opts); + } + if (task) { + tasks.push(task); + } + }); + + return Promise.all(tasks); + }).then(function () { + var response = new Response(record, {}, 'find'); + response.found = record ? 1 : 0; + response = self.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); }, - - + + /** - * Make an Http request. + * Retrieve the records that match the selection query. * - * @name HttpAdapter#HTTP + * @name Adapter#findAll * @method - * @param {Object} config Request configuration options. + * @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} */ - HTTP: function HTTP(config, opts) { + findAll: function findAll(mapper, query, opts) { var self = 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, self.httpConfig); - config.data = payload; - config.cache = cache; - config.timeout = timeout; - if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { - config.url += '/'; - } - config.method = config.method.toUpperCase(); - var suffix = config.suffix || opts.suffix || self.suffix; - if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { - config.url += suffix; - } - - 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 (self.log) { - self.dbg('debug', str, data); - } - return data; + opts.with || (opts.with = []); + + var records = []; + var op = void 0; + var activeWith = opts._activeWith; + + if (jsData.utils.isObject(activeWith)) { + var activeQuery = activeWith.query || {}; + if (activeWith.replace) { + query = activeQuery; } else { - if (self.error) { - self.error('\'FAILED: ' + str, data); - } - return _jsData.utils.reject(data); + jsData.utils.deepFillIn(query, activeQuery); } } - - if (!self.http) { - throw new Error('You have not configured this adapter with an http library!'); - } - - return _jsData.utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { - config = _config || config; - if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { - return self.fetch(config, opts).then(logResponse, logResponse); - } - return self.http(config).then(logResponse, logResponse).catch(function (err) { - return self.responseError(err, config, opts); + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._findAll(mapper, query, opts)); + }).then(function (results) { + var _results7 = babelHelpers.slicedToArray(results, 1); + + var _records = _results7[0]; + + _records || (_records = []); + records = _records; + 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 = self.loadHasMany(mapper, def, records, __opts); + } else { + task = self.loadHasOne(mapper, def, records, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } }); - }).then(function (response) { - return _jsData.utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { - return _response || response; + return Promise.all(tasks); + }).then(function () { + var response = new Response(records, {}, 'findAll'); + response.found = records.length; + response = self.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, - - + + /** - * TODO + * Resolve the value of the specified option based on the given options and + * this adapter's settings. Override with care. * - * @name HttpAdapter#POST + * @name Adapter#getOpt * @method - * @param {*} url TODO - * @param {Object} data TODO - * @param {Object} config TODO + * @param {string} opt The name of the option. * @param {Object} [opts] Configuration options. - * @return {Promise} + * @return {*} The value of the specified option. */ - POST: function POST(url, data, config, opts) { - var self = this; - var op = void 0; - config || (config = {}); + getOpt: function getOpt(opt, opts) { 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(self[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'POST'; - self.dbg(op, url, data, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterPOST lifecycle hook - op = opts.op = 'afterPOST'; - return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; - }); - }); + return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); }, - - + + /** - * TODO + * Load a hasMany relationship. * - * @name HttpAdapter#PUT + * Override with care. + * + * @name Adapter#loadHasMany * @method - * @param {*} url TODO - * @param {Object} data TODO - * @param {Object} config TODO - * @param {Object} [opts] Configuration options. * @return {Promise} */ - PUT: function PUT(url, data, config, opts) { + loadHasMany: function loadHasMany(mapper, def, records, __opts) { var self = 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(self[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'PUT'; - self.dbg(op, url, data, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterPUT lifecycle hook - op = opts.op = 'afterPUT'; - return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return self.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 self.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 self = this; + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': self.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(self.self.makeHasManyLocalKeys(mapper, def, record)); + }); + return { + v: self.findAll(relatedMapper, { + where: babelHelpers.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' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v; + } + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var self = 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 self.findAll(def.getRelation(), { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'contains': self.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return self.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); + }); + }); + } + }, + + /** - * TODO + * Load a hasOne relationship. * - * @name HttpAdapter#queryTransform + * Override with care. + * + * @name Adapter#loadHasOne * @method - * @param {Object} mapper TODO - * @param {*} params TODO - * @param {*} opts TODO - * @return {*} Transformed params. + * @return {Promise} */ - 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); + loadHasOne: function loadHasOne(mapper, def, records, __opts) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + records = [records]; } - return params; + 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]); + } + }); + }); }, - - + + /** - * 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}. + * Logging utility method. Override this method if you want to send log + * messages to something other than the console. * - * @name HttpAdapter#responseError + * @name Adapter#log * @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} + * @param {string} level Log level. + * @param {...*} values Values to log. */ - responseError: function responseError(err, config, opts) { - return _jsData.utils.reject(err); + log: function log(level) { + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + if (level && !args.length) { + args.push(level); + level = 'debug'; + } + if (level === 'debug' && !this.debug) { + return; + } + var prefix = level.toUpperCase() + ': (Adapter)'; + if (console[level]) { + var _console; + + (_console = console)[level].apply(_console, [prefix].concat(args)); + } else { + var _console2; + + (_console2 = console).log.apply(_console2, [prefix].concat(args)); + } }, - - + + /** - * TODO + * Return the foreignKey from the given record for the provided relationship. * - * @name HttpAdapter#serialize + * 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 - * @param {Object} mapper TODO - * @param {Object} data TODO - * @param {*} opts TODO - * @return {*} Serialized data. + * @return {*} */ - 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; + makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) { + return def.getForeignKey(record); }, - - + + /** - * Retrieve the sum of the field of the records that match the selection query. + * Return the localKeys from the given record for the provided relationship. * - * @name HttpAdapter#sum + * 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 The field to sum. - * @param {Object} query Selection query. + * @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 {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. * @return {Promise} */ sum: function sum(mapper, field, query, opts) { var self = this; - query || (query = {}); - opts || (opts = {}); - if (!_jsData.utils.utils.isString(field)) { + var op = void 0; + if (!jsData.utils.isString(field)) { throw new Error('field must be a string!'); } - opts.params = self.getParams(opts); - opts.params.sum = field; - opts.suffix = self.getSuffix(mapper, opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - - return __super__.sum.call(self, mapper, field, query, opts); + query || (query = {}); + opts || (opts = {}); + + // beforeSum lifecycle hook + op = opts.op = 'beforeSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + self.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(self._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results8 = babelHelpers.slicedToArray(results, 2); + + var data = _results8[0]; + var result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); }, - - + + /** - * TODO + * @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 HttpAdapter#update + * @name Adapter#update * @method - * @param {Object} mapper TODO - * @param {*} id TODO - * @param {*} props TODO + * @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 self = this; + props || (props = {}); opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.update.call(self, mapper, id, props, opts); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'update'; + self.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(self._update(mapper, id, props, opts)); + }).then(function (results) { + var _results9 = babelHelpers.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 = self.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); }, - - + + /** - * TODO + * Apply the given update to all records that match the selection query. + * Called by `Mapper#updateAll`. * - * @name HttpAdapter#updateAll + * @name Adapter#updateAll * @method - * @param {Object} mapper TODO - * @param {Object} props TODO - * @param {Object} query TODO + * @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 self = this; + props || (props = {}); query || (query = {}); opts || (opts = {}); - opts.params = self.getParams(opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.updateAll.call(self, mapper, props, query, opts); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'updateAll'; + self.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results10 = babelHelpers.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 = self.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); }, - - + + /** - * Update multiple records in batch. - * - * {@link HttpAdapter#beforeUpdateMany} will be called before calling - * {@link HttpAdapter#PUT}. - * {@link HttpAdapter#afterUpdateMany} will be called after calling - * {@link HttpAdapter#PUT}. + * Update the given records in a single batch. Called by `Mapper#updateMany`. * - * @name HttpAdapter#updateMany + * @name Adapter#updateMany * @method * @param {Object} mapper The mapper. - * @param {Array} records Array of property objects to send as the payload. + * @param {Object[]} records The records to update. * @param {Object} [opts] Configuration options. - * @param {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. * @return {Promise} */ updateMany: function updateMany(mapper, records, opts) { var self = this; + records || (records = []); opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.updateMany.call(self, mapper, records, 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(self[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = jsData.utils.isUndefined(_records) ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'updateMany'; + self.dbg(op, mapper, records, opts); + return jsData.utils.resolve(self._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results11 = babelHelpers.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 = self.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); } }); - - /** - * 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 adapter = new HttpAdapter() - * var store = new DataStore() - * - * store.registerAdapter('http', adapter, { default: true }) - * store.defineMapper('school') - * - * // GET /reports/schools/:school_id/teachers - * addAction('getTeacherReports', { - * basePath: 'reports/schools', - * pathname: 'teachers', - * method: 'GET' - * })(store.getMapper('school')) - * - * // /reports/schools/1234/teachers - * store.getMapper('school').getTeacherReports(1234).then(function (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] - * @param {string} [opts.pathname] - * @param {Function} [opts.request] - * @param {Function} [opts.response] - * @param {Function} [opts.responseError] - * @return {Function} Decoration function, which should be passed the mapper to - * decorate when invoked. - */ - exports.addAction = 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))); + + 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]; } - return function (mapper) { - if (mapper[name]) { - throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); + + 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; } - 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 self = this; - if (_jsData.utils.isObject(id)) { - _opts = id; - } - _opts = _opts || {}; - var adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http'); - var config = {}; - _jsData.utils.fillIn(config, opts); - if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { - _opts.endpoint = config.endpoint; - } - if (typeof _opts.getEndpoint === 'function') { - config.url = _opts.getEndpoint(self, _opts); - } else { - var args = [_opts.basePath || self.basePath || adapter.basePath, adapter.getEndpoint(self, _jsData.utils.isSorN(id) ? id : null, _opts)]; - if (_jsData.utils.isSorN(id)) { - args.push(id); - } - args.push(opts.pathname || name); - config.url = makePath.apply(null, args); + if (!jsData.utils.isArray(val)) { + val = [val]; + } + + val.forEach(function (v) { + if (window.toString.call(v) === '[object Date]') { + v = v.toISOString(); + } else if (jsData.utils.isObject(v)) { + v = jsData.utils.toJson(v); } - config.method = config.method || 'GET'; - config.mapper = self.name; - _jsData.utils.deepMixIn(config, _opts); - return _jsData.utils.resolve(config).then(_opts.request || opts.request).then(function (config) { - return adapter.HTTP(config); - }).then(function (data) { - if (data && data.config) { - data.config.mapper = self.name; - } - return data; - }).then(_opts.response || opts.response, _opts.responseError || opts.responseError); - }; - return mapper; - }; + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; + } + + var __super__ = Adapter.prototype; + + var DEFAULTS = { + // Default and user-defined settings + /** + * @name HttpAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + */ + forceTrailingSlash: false, + + /** + * @name HttpAdapter#http + * @type {Function} + */ + http: axios$1, + + /** + * @name HttpAdapter#httpConfig + * @type {Object} + */ + httpConfig: {}, + + /** + * @name HttpAdapter#suffix + * @type {string} + */ + suffix: '', + + /** + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + */ + useFetch: false }; - + /** - * 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 adapter = new HttpAdapter() - * var store = new DataStore() - * - * store.registerAdapter('http', adapter, { 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(function (response) { - * // ... - * }) + * HttpAdapter class. * - * @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. + * @class HttpAdapter + * @extends Adapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.basePath=''] TODO + * @param {boolean} [opts.debug=false] TODO + * @param {boolean} [opts.forceTrailingSlash=false] TODO + * @param {Object} [opts.http=axios] TODO + * @param {Object} [opts.httpConfig={}] TODO + * @param {string} [opts.suffix=''] TODO + * @param {boolean} [opts.useFetch=false] TODO */ - exports.addActions = function addActions(opts) { + function HttpAdapter(opts) { + var self = this; opts || (opts = {}); - return function (mapper) { - _jsData.utils.forOwn(opts, function (value, key) { - exports.addAction(key, value)(mapper); - }); - return mapper; - }; - }; - + jsData.utils.fillIn(opts, DEFAULTS); + Adapter.call(self, opts); + } + /** - * 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. + * @name module:js-data-http.HttpAdapter + * @see HttpAdapter */ - exports.version = { - beta: 5, - full: '3.0.0-beta.5', - major: 3, - minor: 0, - patch: 0 -}; - + + // Setup prototype inheritance from Adapter + HttpAdapter.prototype = Object.create(Adapter.prototype, { + constructor: { + value: HttpAdapter, + enumerable: false, + writable: true, + configurable: true + } + }); + + Object.defineProperty(HttpAdapter, '__super__', { + configurable: true, + value: Adapter + }); + /** - * 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 adapter = new HttpAdapter() - * - * @example CommonJS - * var HttpAdapter = require('js-data-Http').HttpAdapter - * var adapter = new HttpAdapter() + * Alternative to ES6 class syntax for extending `HttpAdapter`. * - * @example ES2015 Modules - * import {HttpAdapter} from 'js-data-Http' - * const adapter = new HttpAdapter() + * @example Using the ES2015 class syntax. + * class MyHttpAdapter extends HttpAdapter {...} + * const adapter = new MyHttpAdapter() * - * @example AMD - * define('myApp', ['js-data-Http'], function (JSDataHttp) { - * var HttpAdapter = JSDataHttp.HttpAdapter - * var adapter = new HttpAdapter() + * @example Using {@link HttpAdapter.extend}. + * var instanceProps = {...} + * var classProps = {...} * - * // ... - * }) + * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) + * var adapter = new MyHttpAdapter() * - * @module js-data-http + * @name HttpAdapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `HttpAdapter`. */ - exports.default = HttpAdapter; - -/***/ }, -/* 1 */ -/***/ function(module, exports) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_1__; - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - (function (global, factory) { - true ? factory(exports, __webpack_require__(1)) : - typeof define === 'function' && define.amd ? define('js-data-adapter', ['exports', 'js-data'], factory) : - (factory((global.Adapter = global.Adapter || {}),global.JSData)); - }(this, function (exports,jsData) { 'use strict'; - - var babelHelpers = {}; - babelHelpers.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; - }; - - babelHelpers.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; - }; - - babelHelpers.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"); - } - }; - }(); - - babelHelpers; - - var noop = function noop() { - var self = this; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var opts = args[args.length - 1]; - self.dbg.apply(self, [opts.op].concat(args)); - return jsData.utils.resolve(); - }; - - var noop2 = function noop2() { - var self = this; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - var opts = args[args.length - 2]; - self.dbg.apply(self, [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) { - return jsData.utils.omit(props, mapper.relationFields || []); - }; - - var DEFAULTS = { - /** - * 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 - * @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) { - var self = this; - opts || (opts = {}); - jsData.utils.fillIn(opts, DEFAULTS); - jsData.utils.fillIn(self, opts); - } - - var reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where']; - - /** - * Response object used when `raw` is `true`. May contain other fields in - * addition to `data`. - * - * @class Response - */ - function Response(data, meta, op) { - var self = this; - meta || (meta = {}); - - /** - * Response data. - * - * @name Response#data - * @type {*} - */ - self.data = data; - - jsData.utils.fillIn(self, meta); - - /** - * The operation for which the response was created. - * - * @name Response#op - * @type {string} - */ - self.op = op; - } - + HttpAdapter.extend = jsData.utils.extend; + + jsData.utils.addHiddenPropsToTarget(HttpAdapter.prototype, { /** - * Alternative to ES6 class syntax for extending `Adapter`. - * - * @name Adapter.extend + * @name HttpAdapter#afterDEL * @method - * @param {Object} [instanceProps] Properties that will be added to the - * prototype of the subclass. - * @param {Object} [classProps] Properties that will be added as static - * properties to the subclass itself. - * @return {Object} Subclass of `Adapter`. + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response */ - Adapter.extend = jsData.utils.extend; - - jsData.utils.addHiddenPropsToTarget(Adapter.prototype, { - /** - * 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, - - /** - * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`. - * - * @name Adapter#dbg - * @method - */ - dbg: function dbg() { - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - this.log.apply(this, ['debug'].concat(args)); - }, - - - /** - * 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 self = this; - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeCount lifecycle hook - op = opts.op = 'beforeCount'; - return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'count'; - self.dbg(op, mapper, query, opts); - return jsData.utils.resolve(self._count(mapper, query, opts)); - }).then(function (results) { - var _results = babelHelpers.slicedToArray(results, 2); - - var data = _results[0]; - var result = _results[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = self.respond(response, opts); - - // afterCount lifecycle hook - op = opts.op = 'afterCount'; - return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreate lifecycle hook - op = opts.op = 'beforeCreate'; - return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = withoutRelations(mapper, props); - op = opts.op = 'create'; - self.dbg(op, mapper, props, opts); - return jsData.utils.resolve(self._create(mapper, props, opts)); - }).then(function (results) { - var _results2 = babelHelpers.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 = self.respond(response, opts); - - // afterCreate lifecycle hook - op = opts.op = 'afterCreate'; - return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreateMany lifecycle hook - op = opts.op = 'beforeCreateMany'; - return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = props.map(function (record) { - return withoutRelations(mapper, record); - }); - op = opts.op = 'createMany'; - self.dbg(op, mapper, props, opts); - return jsData.utils.resolve(self._createMany(mapper, props, opts)); - }).then(function (results) { - var _results3 = babelHelpers.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 = self.respond(response, opts); - - // afterCreateMany lifecycle hook - op = opts.op = 'afterCreateMany'; - return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - opts || (opts = {}); - - // beforeDestroy lifecycle hook - op = opts.op = 'beforeDestroy'; - return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'destroy'; - self.dbg(op, mapper, id, opts); - return jsData.utils.resolve(self._destroy(mapper, id, opts)); - }).then(function (results) { - var _results4 = babelHelpers.slicedToArray(results, 2); - - var data = _results4[0]; - var result = _results4[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroy'); - response = self.respond(response, opts); - - // afterDestroy lifecycle hook - op = opts.op = 'afterDestroy'; - return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeDestroyAll lifecycle hook - op = opts.op = 'beforeDestroyAll'; - return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'destroyAll'; - self.dbg(op, mapper, query, opts); - return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); - }).then(function (results) { - var _results5 = babelHelpers.slicedToArray(results, 2); - - var data = _results5[0]; - var result = _results5[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroyAll'); - response = self.respond(response, opts); - - // afterDestroyAll lifecycle hook - op = opts.op = 'afterDestroyAll'; - return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - - /** - * Load a belongsTo relationship. - * - * Override with care. - * - * @name Adapter#loadBelongsTo - * @method - * @return {Promise} - */ - loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { - var self = this; - var relationDef = def.getRelation(); - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - var _ret = function () { - var record = records; - return { - v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { - def.setLocalField(record, relatedItem); - }) - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; - } else { - var keys = records.map(function (record) { - return self.makeBelongsToForeignKey(mapper, def, record); - }).filter(function (key) { - return key; - }); - return self.findAll(relationDef, { - where: babelHelpers.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 self = this; - var record = void 0, - op = void 0; - opts || (opts = {}); - opts.with || (opts.with = []); - - // beforeFind lifecycle hook - op = opts.op = 'beforeFind'; - return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'find'; - self.dbg(op, mapper, id, opts); - return jsData.utils.resolve(self._find(mapper, id, opts)); - }).then(function (results) { - var _results6 = babelHelpers.slicedToArray(results, 1); - - var _record = _results6[0]; - - if (!_record) { - return; - } - record = _record; - 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 = self.loadHasOne(mapper, def, record, __opts); - } else { - task = self.loadHasMany(mapper, def, record, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = self.loadHasManyLocalKeys(mapper, def, record, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = self.loadHasManyForeignKeys(mapper, def, record, __opts); - } else if (def.type === 'belongsTo') { - task = self.loadBelongsTo(mapper, def, record, __opts); - } - if (task) { - tasks.push(task); - } - }); - - return Promise.all(tasks); - }).then(function () { - var response = new Response(record, {}, 'find'); - response.found = record ? 1 : 0; - response = self.respond(response, opts); - - // afterFind lifecycle hook - op = opts.op = 'afterFind'; - return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - opts || (opts = {}); - opts.with || (opts.with = []); - - var records = []; - 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(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'findAll'; - self.dbg(op, mapper, query, opts); - return jsData.utils.resolve(self._findAll(mapper, query, opts)); - }).then(function (results) { - var _results7 = babelHelpers.slicedToArray(results, 1); - - var _records = _results7[0]; - - _records || (_records = []); - records = _records; - 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 = self.loadHasMany(mapper, def, records, __opts); - } else { - task = self.loadHasOne(mapper, def, records, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = self.loadHasManyLocalKeys(mapper, def, records, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = self.loadHasManyForeignKeys(mapper, def, records, __opts); - } else if (def.type === 'belongsTo') { - task = self.loadBelongsTo(mapper, def, records, __opts); - } - if (task) { - tasks.push(task); - } - }); - return Promise.all(tasks); - }).then(function () { - var response = new Response(records, {}, 'findAll'); - response.found = records.length; - response = self.respond(response, opts); - - // afterFindAll lifecycle hook - op = opts.op = 'afterFindAll'; - return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 jsData.utils.isUndefined(opts[opt]) ? 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 self = this; - var singular = false; - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - singular = true; - records = [records]; - } - var IDs = records.map(function (record) { - return self.makeHasManyForeignKey(mapper, def, record); + 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 self = this; + return self.GET(self.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('create', mapper, props, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('createMany', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var self = this; + return self.DEL(self.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var self = this; + return self.DEL(self.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var self = this; + return self.GET(self.getPath('find', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var self = this; + return self.GET(self.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var self = this; + return self.PUT(self.getPath('update', mapper, id, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var self = this; + return self.PUT(self.getPath('updateAll', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var self = this; + return self.PUT(self.getPath('updateMany', mapper, null, opts), self.serialize(mapper, records, opts), opts).then(function (response) { + return self._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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params.count = true; + opts.suffix = self.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.count.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.create.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.createMany.call(self, 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 self = 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(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'DEL'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; }); - var query = { - where: {} + }); + }, + + + /** + * 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroy.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroyAll.call(self, 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. + * @param {Object} [opts] Configuration options. + */ + fetch: function (_fetch) { + function fetch(_x, _x2) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config, opts) { + 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(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) { + response.config = { + method: config.method, + url: config.url }; - 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 self.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); - }); + return response.json().then(function (data) { + response.data = data; + return response; }); - }, - loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { - var self = this; - var record = void 0; - var relatedMapper = def.getRelation(); - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - record = records; - } - - if (record) { - return self.findAll(relatedMapper, { - where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { - 'in': self.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(self.self.makeHasManyLocalKeys(mapper, def, record)); - }); - return { - v: self.findAll(relatedMapper, { - where: babelHelpers.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' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v; - } - }, - loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { - var self = this; - var relatedMapper = def.getRelation(); - var idAttribute = mapper.idAttribute; - var record = void 0; - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - record = records; + }); + }), + + + /** + * 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.find.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.suffix = self.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.findAll.call(self, mapper, query, opts); + }, + + + /** + * TODO + * + * @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 self = 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(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'GET'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {boolean} opts TODO + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var self = 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; } - - if (record) { - return self.findAll(def.getRelation(), { - where: babelHelpers.defineProperty({}, def.foreignKeys, { - 'contains': self.makeHasManyForeignKeys(mapper, def, record) - }) - }, __opts).then(function (relatedItems) { - def.setLocalField(record, relatedItems); - }); + 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 { - return self.findAll(relatedMapper, { - where: babelHelpers.defineProperty({}, def.foreignKeys, { - 'isectNotEmpty': records.map(function (record) { - return self.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); - } + 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; }); - 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]); - } - }); - }); - }, - - - /** - * Logging utility method. Override this method if you want to send log - * messages to something other than the console. - * - * @name Adapter#log - * @method - * @param {string} level Log level. - * @param {...*} values Values to log. - */ - log: function log(level) { - for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { - args[_key4 - 1] = arguments[_key4]; - } - - if (level && !args.length) { - args.push(level); - level = 'debug'; + jsData.utils._(_opts, parentDef); + endpoint = makePath(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return { + v: false + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; + } } - if (level === 'debug' && !this.debug) { - return; + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method TODO + * @param {Object} mapper TODO + * @param {(string|number)?} id TODO + * @param {Object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + var self = this; + opts || (opts = {}); + var args = [jsData.utils.isUndefined(opts.basePath) ? jsData.utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath : opts.basePath, self.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 (jsData.utils.isUndefined(opts.params)) { + return {}; + } + return jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (jsData.utils.isUndefined(opts.suffix)) { + if (jsData.utils.isUndefined(mapper.suffix)) { + return this.suffix; } - var prefix = level.toUpperCase() + ': (Adapter)'; - if (console[level]) { - var _console; - - (_console = console)[level].apply(_console, [prefix].concat(args)); + 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 self = 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, self.httpConfig); + config.data = payload; + config.cache = cache; + config.timeout = timeout; + if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || self.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + 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 (self.log) { + self.dbg('debug', str, data); + } + return data; } else { - var _console2; - - (_console2 = console).log.apply(_console2, [prefix].concat(args)); + if (self.error) { + self.error('\'FAILED: ' + str, data); + } + return jsData.utils.reject(data); } - }, - - - /** - * 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 self = this; - var op = void 0; - if (!jsData.utils.isString(field)) { - throw new Error('field must be a string!'); + } + + if (!self.http) { + throw new Error('You have not configured this adapter with an http library!'); + } + + return jsData.utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { + return self.fetch(config, opts).then(logResponse, logResponse); } - query || (query = {}); - opts || (opts = {}); - - // beforeSum lifecycle hook - op = opts.op = 'beforeSum'; - return jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'sum'; - self.dbg(op, mapper, field, query, opts); - return jsData.utils.resolve(self._sum(mapper, field, query, opts)); - }).then(function (results) { - var _results8 = babelHelpers.slicedToArray(results, 2); - - var data = _results8[0]; - var result = _results8[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = self.respond(response, opts); - - // afterSum lifecycle hook - op = opts.op = 'afterSum'; - return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - props || (props = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdate lifecycle hook - op = opts.op = 'beforeUpdate'; - return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = withoutRelations(mapper, props); - op = opts.op = 'update'; - self.dbg(op, mapper, id, props, opts); - return jsData.utils.resolve(self._update(mapper, id, props, opts)); - }).then(function (results) { - var _results9 = babelHelpers.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 = self.respond(response, opts); - - // afterUpdate lifecycle hook - op = opts.op = 'afterUpdate'; - return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? response : _response; - }); + return self.http(config).then(logResponse, logResponse).catch(function (err) { + return self.responseError(err, config, opts); }); - }, - - - /** - * 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 self = this; - props || (props = {}); - query || (query = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdateAll lifecycle hook - op = opts.op = 'beforeUpdateAll'; - return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = withoutRelations(mapper, props); - op = opts.op = 'updateAll'; - self.dbg(op, mapper, props, query, opts); - return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); - }).then(function (results) { - var _results10 = babelHelpers.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 = self.respond(response, opts); - - // afterUpdateAll lifecycle hook - op = opts.op = 'afterUpdateAll'; - return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? response : _response; - }); + }).then(function (response) { + return jsData.utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { + return _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 self = this; - records || (records = []); - opts || (opts = {}); - var op = void 0; - var idAttribute = mapper.idAttribute; - - records = records.filter(function (record) { - return jsData.utils.get(record, idAttribute); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#POST + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var self = 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(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'POST'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; }); - - // beforeUpdateMany lifecycle hook - op = opts.op = 'beforeUpdateMany'; - return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = jsData.utils.isUndefined(_records) ? records : _records; - records = records.map(function (record) { - return withoutRelations(mapper, record); - }); - op = opts.op = 'updateMany'; - self.dbg(op, mapper, records, opts); - return jsData.utils.resolve(self._updateMany(mapper, records, opts)); - }).then(function (results) { - var _results11 = babelHelpers.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 = self.respond(response, opts); - - // afterUpdateMany lifecycle hook - op = opts.op = 'afterUpdateMany'; - return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? response : _response; - }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#PUT + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var self = 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(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'PUT'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#queryTransform + * @method + * @param {Object} mapper TODO + * @param {*} params TODO + * @param {*} opts TODO + * @return {*} Transformed params. + */ + queryTransform: function queryTransform(mapper, params, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts); } - }); - - exports.noop = noop; - exports.noop2 = noop2; - exports.unique = unique; - exports.withoutRelations = withoutRelations; - exports.Adapter = Adapter; - exports.reserved = reserved; - exports.Response = Response; - - })); - //# sourceMappingURL=js-data-adapter.js.map - -/***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(4); - -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var defaults = __webpack_require__(5); - var utils = __webpack_require__(6); - var dispatchRequest = __webpack_require__(7); - var InterceptorManager = __webpack_require__(17); - var isAbsoluteURL = __webpack_require__(18); - var combineURLs = __webpack_require__(19); - var bind = __webpack_require__(20); - var transformData = __webpack_require__(12); - - function Axios(defaultConfig) { - this.defaults = utils.merge({}, defaultConfig); - this.interceptors = { - request: new InterceptorManager(), - response: new InterceptorManager() - }; - } - - 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); - } - - // Don't allow overriding defaults.withCredentials - config.withCredentials = config.withCredentials || this.defaults.withCredentials; - - // 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]; + if (jsData.utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts); } - ); - - // 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; - }; - - var defaultInstance = new Axios(defaults); - var axios = module.exports = bind(Axios.prototype.request, defaultInstance); - - // Expose properties from defaultInstance - axios.defaults = defaultInstance.defaults; - axios.interceptors = defaultInstance.interceptors; - - // Factory for creating new instances - axios.create = function create(defaultConfig) { - return new Axios(defaultConfig); - }; - - // Expose all/spread - axios.all = function all(promises) { - return Promise.all(promises); - }; - axios.spread = __webpack_require__(21); - - // 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 - })); - }; - axios[method] = bind(Axios.prototype[method], defaultInstance); - }); - - 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 - })); - }; - axios[method] = bind(Axios.prototype[method], defaultInstance); - }); + 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); + }, -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var utils = __webpack_require__(6); - - var PROTECTION_PREFIX = /^\)\]\}',?\n/; - var DEFAULT_CONTENT_TYPE = { - 'Content-Type': 'application/x-www-form-urlencoded' - }; - - module.exports = { - transformRequest: [function transformRequest(data, headers) { - if (utils.isFormData(data) || utils.isArrayBuffer(data) || utils.isStream(data)) { - return data; - } - if (utils.isArrayBufferView(data)) { - return data.buffer; - } - if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) { - // Set application/json if no Content-Type has been specified - if (!utils.isUndefined(headers)) { - utils.forEach(headers, function processContentTypeHeader(val, key) { - if (key.toLowerCase() === 'content-type') { - headers['Content-Type'] = val; - } - }); - - if (utils.isUndefined(headers['Content-Type'])) { - headers['Content-Type'] = 'application/json;charset=utf-8'; - } - } - return JSON.stringify(data); + /** + * TODO + * + * @name HttpAdapter#serialize + * @method + * @param {Object} mapper TODO + * @param {Object} data TODO + * @param {*} opts TODO + * @return {*} Serialized data. + */ + serialize: function serialize(mapper, data, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts); } - 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 */ } + if (jsData.utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts); } 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) { - - 'use strict'; - - /*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 toString.call(val) === '[object 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); - } - - /** - * 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; + /** + * 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + if (!jsData.utils.utils.isString(field)) { + throw new Error('field must be a string!'); } - } - - for (var i = 0, l = arguments.length; i < l; i++) { - forEach(arguments[i], assignValue); - } - return result; - } - - 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, - isStandardBrowserEnv: isStandardBrowserEnv, - forEach: forEach, - merge: merge, - trim: trim - }; + opts.params = self.getParams(opts); + opts.params.sum = field; + opts.suffix = self.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + return __super__.sum.call(self, mapper, field, query, opts); + }, -/***/ }, -/* 7 */ -/***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {'use strict'; - - /** - * 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) { - return new Promise(function executor(resolve, reject) { - try { - 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__(9); - } else if (typeof process !== 'undefined') { - // For node use HTTP adapter - adapter = __webpack_require__(9); - } - - if (typeof adapter === 'function') { - adapter(resolve, reject, config); - } - } catch (e) { - reject(e); - } - }); - }; - - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) - -/***/ }, -/* 8 */ -/***/ function(module, exports) { - - // shim for using process in browser - - var process = module.exports = {}; - var queue = []; - var draining = false; - var currentQueue; - var queueIndex = -1; - - function cleanUpNextTick() { - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } - } - - function drainQueue() { - if (draining) { - return; - } - var timeout = setTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - clearTimeout(timeout); - } - - process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - setTimeout(drainQueue, 0); - } - }; - - // v8 likes predictible objects - function Item(fun, array) { - this.fun = fun; - this.array = array; - } - Item.prototype.run = function () { - this.fun.apply(null, this.array); - }; - process.title = 'browser'; - process.browser = true; - process.env = {}; - process.argv = []; - process.version = ''; // empty string to avoid regexp issues - process.versions = {}; - - function noop() {} - - process.on = noop; - process.addListener = noop; - process.once = noop; - process.off = noop; - process.removeListener = noop; - process.removeAllListeners = noop; - process.emit = noop; - - process.binding = function (name) { - throw new Error('process.binding is not supported'); - }; - - process.cwd = function () { return '/' }; - process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); - }; - process.umask = function() { return 0; }; - - -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {'use strict'; - - var utils = __webpack_require__(6); - var buildURL = __webpack_require__(10); - var parseHeaders = __webpack_require__(11); - var transformData = __webpack_require__(12); - var isURLSameOrigin = __webpack_require__(13); - var btoa = (typeof window !== 'undefined' && window.btoa) || __webpack_require__(14); - var settle = __webpack_require__(15); - - module.exports = function xhrAdapter(resolve, reject, config) { - 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 (process.env.NODE_ENV !== 'test' && typeof window !== 'undefined' && window.XDomainRequest && !('withCredentials' in request) && !isURLSameOrigin(config.url)) { - request = new window.XDomainRequest(); - loadEvent = 'onload'; - xDomain = true; - } - - // 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; - - // For IE 9 CORS support. - request.onprogress = function handleProgress() {}; - request.ontimeout = function handleTimeout() {}; - - // 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: transformData( - responseData, - responseHeaders, - config.transformResponse - ), - // 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(new Error('Network Error')); - - // Clean up request - request = null; - }; - - // Handle timeout - request.ontimeout = function handleTimeout() { - var err = new Error('timeout of ' + config.timeout + 'ms exceeded'); - err.timeout = config.timeout; - err.code = 'ECONNABORTED'; - reject(err); - - // 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__(16); - - // 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 (config.progress) { - 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); - }; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) + /** + * TODO + * + * @name HttpAdapter#update + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {*} props TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { + return __super__.update.call(self, mapper, id, props, opts); + }, - 'use strict'; - - var utils = __webpack_require__(6); - - 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 { - 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; - }; - + /** + * TODO + * + * @name HttpAdapter#updateAll + * @method + * @param {Object} mapper TODO + * @param {Object} props TODO + * @param {Object} query TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { + return __super__.updateAll.call(self, mapper, props, query, opts); + }, - 'use strict'; - - var utils = __webpack_require__(6); - - /** - * 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; - }; + /** + * Update multiple records in batch. + * + * {@link HttpAdapter#beforeUpdateMany} will be called before calling + * {@link HttpAdapter#PUT}. + * {@link HttpAdapter#afterUpdateMany} will be called after calling + * {@link HttpAdapter#PUT}. + * + * @name HttpAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} records Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { + return __super__.updateMany.call(self, mapper, records, opts); + } + }); - 'use strict'; - - var utils = __webpack_require__(6); - /** - * Transform the data for a request or a response + * 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 adapter = new HttpAdapter() + * var store = new DataStore() + * + * store.registerAdapter('http', adapter, { default: true }) + * store.defineMapper('school') + * + * // GET /reports/schools/:school_id/teachers + * addAction('getTeacherReports', { + * basePath: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * })(store.getMapper('school')) + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then(function (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 + * @name module:js-data-http.addAction + * @method + * @param {string} name Name of the new action. + * @param {Object} [opts] Action configuration + * @param {string} [opts.adapter] + * @param {string} [opts.pathname] + * @param {Function} [opts.request] + * @param {Function} [opts.response] + * @param {Function} [opts.responseError] + * @return {Function} Decoration function, which should be passed the mapper to + * decorate when invoked. */ - module.exports = function transformData(data, headers, fns) { - /*eslint no-param-reassign:0*/ - utils.forEach(fns, function transform(fn) { - data = fn(data, headers); - }); - - return data; - }; - - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(6); - - 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 - }; + function addAction(name, opts) { + if (!name || !jsData.utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : babelHelpers.typeof(name))); + } + return function (mapper) { + if (mapper[name]) { + throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); } - - 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); + opts.request = opts.request || function (config) { + return config; }; - })() : - - // Non standard browser envs (web workers, react-native) lack needed support. - (function nonStandardBrowserEnv() { - return function isURLSameOrigin() { - return true; + opts.response = opts.response || function (response) { + return response; }; - })() - ); - - -/***/ }, -/* 14 */ -/***/ 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; - - -/***/ }, -/* 15 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * 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(response); - } - }; - - -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var utils = __webpack_require__(6); - - 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'); + opts.responseError = opts.responseError || function (err) { + return jsData.utils.reject(err); + }; + mapper[name] = function (id, _opts) { + var self = this; + if (jsData.utils.isObject(id)) { + _opts = id; + } + _opts = _opts || {}; + var adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http'); + var config = {}; + jsData.utils.fillIn(config, opts); + if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { + _opts.endpoint = config.endpoint; + } + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(self, _opts); + } else { + var args = [_opts.basePath || self.basePath || adapter.basePath, adapter.getEndpoint(self, jsData.utils.isSorN(id) ? id : null, _opts)]; + if (jsData.utils.isSorN(id)) { + args.push(id); } - - 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); + args.push(opts.pathname || name); + config.url = makePath.apply(null, args); } + config.method = config.method || 'GET'; + config.mapper = self.name; + jsData.utils.deepMixIn(config, _opts); + return jsData.utils.resolve(config).then(_opts.request || opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = self.name; + } + return data; + }).then(_opts.response || opts.response, _opts.responseError || opts.responseError); }; - })() : - - // 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 = __webpack_require__(6); - - function InterceptorManager() { - this.handlers = []; + return mapper; + }; } - + /** - * Add a new interceptor to the stack + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. * - * @param {Function} fulfilled The function to handle `then` for a `Promise` - * @param {Function} rejected The function to handle `reject` for a `Promise` + * @example + * // CommonJS + * var JSData = require('js-data') + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore * - * @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 + * var JSDataHttp = require('js-data-http') + * var HttpAdapter = JSDataHttp.HttpAdapter + * var addActions = JSDataHttp.addActions * - * @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 + * var adapter = new HttpAdapter() + * var store = new DataStore() * - * This method is particularly useful for skipping over any - * interceptors that may have become `null` calling `eject`. + * store.registerAdapter('http', adapter, { default: true }) + * store.defineMapper('school') * - * @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; - - -/***/ }, -/* 18 */ -/***/ function(module, exports) { - - 'use strict'; - - /** - * Determines whether the specified URL is absolute + * 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(function (response) { + * // ... + * }) * - * @param {string} url The URL to test - * @returns {boolean} True if the specified URL is absolute, otherwise false + * @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. */ - 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); - }; - - -/***/ }, -/* 19 */ -/***/ function(module, exports) { + function addActions(opts) { + opts || (opts = {}); + return function (mapper) { + jsData.utils.forOwn(opts, function (value, key) { + addAction(key, value)(mapper); + }); + return mapper; + }; + } - 'use strict'; - /** - * Creates a new URL by combining the specified URLs + * Details of the current version of the `js-data-http` module. * - * @param {string} baseURL The base URL - * @param {string} relativeURL The relative URL - * @returns {string} The combined URL + * @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. */ - module.exports = function combineURLs(baseURL, relativeURL) { - return baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, ''); - }; - - -/***/ }, -/* 20 */ -/***/ 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); - }; - }; - - -/***/ }, -/* 21 */ -/***/ function(module, exports) { + var version = { + beta: 6, + full: '3.0.0-beta.6', + major: 3, + minor: 0, + patch: 0 +}; - 'use strict'; - /** - * Syntactic sugar for invoking a function and expanding an array for arguments. + * 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 adapter = new HttpAdapter() * - * Common use case would be to use `Function.prototype.apply`. + * @example CommonJS + * var HttpAdapter = require('js-data-Http').HttpAdapter + * var adapter = new HttpAdapter() * - * ```js - * function f(x, y, z) {} - * var args = [1, 2, 3]; - * f.apply(null, args); - * ``` + * @example ES2015 Modules + * import {HttpAdapter} from 'js-data-Http' + * const adapter = new HttpAdapter() * - * With `spread` this example can be re-written. + * @example AMD + * define('myApp', ['js-data-Http'], function (JSDataHttp) { + * var HttpAdapter = JSDataHttp.HttpAdapter + * var adapter = new HttpAdapter() * - * ```js - * spread(function(x, y, z) {})([1, 2, 3]); - * ``` + * // ... + * }) * - * @param {Function} callback - * @returns {Function} + * @module js-data-http */ - module.exports = function spread(callback) { - return function wrap(arr) { - return callback.apply(null, arr); - }; - }; + exports.HttpAdapter = HttpAdapter; + exports.addAction = addAction; + exports.addActions = addActions; + exports.version = version; -/***/ } -/******/ ]) -}); -; +})); //# sourceMappingURL=js-data-http.js.map \ No newline at end of file diff --git a/dist/js-data-http.js.map b/dist/js-data-http.js.map index 19b7ad5..111e79d 100644 --- a/dist/js-data-http.js.map +++ b/dist/js-data-http.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 5ca3dba1258af7fede7c","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/js-data-adapter/dist/js-data-adapter.js","webpack:///./~/axios/index.js","webpack:///./~/axios/lib/axios.js","webpack:///./~/axios/lib/defaults.js","webpack:///./~/axios/lib/utils.js","webpack:///./~/axios/lib/core/dispatchRequest.js","webpack:///./~/process/browser.js","webpack:///./~/axios/lib/adapters/xhr.js","webpack:///./~/axios/lib/helpers/buildURL.js","webpack:///./~/axios/lib/helpers/parseHeaders.js","webpack:///./~/axios/lib/helpers/transformData.js","webpack:///./~/axios/lib/helpers/isURLSameOrigin.js","webpack:///./~/axios/lib/helpers/btoa.js","webpack:///./~/axios/lib/helpers/settle.js","webpack:///./~/axios/lib/helpers/cookies.js","webpack:///./~/axios/lib/core/InterceptorManager.js","webpack:///./~/axios/lib/helpers/isAbsoluteURL.js","webpack:///./~/axios/lib/helpers/combineURLs.js","webpack:///./~/axios/lib/helpers/bind.js","webpack:///./~/axios/lib/helpers/spread.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;ACnCA;;AACA;;;;AAFA,KAAM,QAAQ,oBAAQ,CAAR,CAAd;;;AAQA,KAAI,WAAW,KAAf;;AAEA,KAAI;AACF,cAAW,UAAU,OAAO,KAA5B;AACD,EAFD,CAEE,OAAO,CAAP,EAAU,CAAE;;AAEd,UAAS,aAAT,CAAwB,KAAxB,EAA+B;AAC7B,UAAQ,SAAS,IAAT,IAAiB,UAAU,EAAnC;AACD;AACD,UAAS,IAAT,CAAe,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB,cAAa,QAAQ;AACrB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,uBAAsB;AACtB;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAsB;;AAEtB;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB;AACA,cAAa,OAAO;AACpB;AACA,eAAc,OAAO;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,6BAA6B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,8BAA8B,eAAe;AAC9E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,+BAA+B,eAAe;AAC7E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,gCAAgC,eAAe;AAChF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,iCAAiC,eAAe;AAC/E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAwE,eAAe;AACvF;AACA;;AAEA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA,QAAO;AACP,+CAA8C;AAC9C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,QAAO;AACP,gDAA+C;AAC/C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,iBAAgB,EAAE;AAClB;AACA;AACA,yBAAwB;AACxB;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA,oDAAmD;AACnD;AACA;AACA,kBAAiB;AACjB,gBAAe;AACf,cAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA,gBAAe;AACf;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA,gDAA+C;AAC/C;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,KAAK;AACpB;AACA;AACA,6FAA4F,eAAe;AAC3G;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,QAAO;AACP;;AAEA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;AACxB;AACA;;AAEA;AACA;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,EAAC;AACD,4C;;;;;;AC/mDA,yC;;;;;;ACAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iCAAgC;AAChC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;;AAEA,kDAAiD,gBAAgB;;AAEjE;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gCAA+B;AAC/B,wCAAuC;AACvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA,MAAK;AACL;AACA;AACA,EAAC;;AAED;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,EAAC;;;;;;;ACtHD;;AAEA;;AAEA,iCAAgC;AAChC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA,uDAAsD;AACtD;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,QAAO,YAAY;AACnB;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA,IAAG;;AAEH;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;;;;;;ACjEA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,aAAa;AACxB,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oCAAmC,OAAO;AAC1C;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAuB,SAAS,GAAG,SAAS;AAC5C,4BAA2B;AAC3B;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;;AAEA,wCAAuC,OAAO;AAC9C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACzQA;;AAEA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,QAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,IAAG;AACH;;;;;;;;;AChCA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,wBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,4BAA2B;AAC3B;AACA;AACA;AACA,6BAA4B,UAAU;;;;;;;AC1FtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,2CAA0C;AAC1C;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA,MAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;ACnKA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP,MAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;;;;;;;ACjEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAiB,eAAe;;AAEhC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACpCA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,cAAc;AACzB,YAAW,MAAM;AACjB,YAAW,eAAe;AAC1B,cAAa,EAAE;AACf;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACnBA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;;;;;;ACnEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACnCA;;AAEA;AACA;AACA;AACA,YAAW,SAAS;AACpB,YAAW,SAAS;AACpB,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;;;;;;;ACjBA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,yCAAwC;AACxC,QAAO;;AAEP;AACA,2DAA0D,wBAAwB;AAClF;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,iCAAgC;AAChC,8BAA6B,aAAa,EAAE;AAC5C;AACA;AACA,IAAG;AACH;;;;;;;ACpDA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,SAAS;AACpB,YAAW,SAAS;AACpB;AACA,aAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;AAEA;;;;;;;ACnDA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACbA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;;;;;;;ACXA;;AAEA;AACA;AACA;AACA,oBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;;;;;;;ACVA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAA+B;AAC/B;AACA;AACA,YAAW,SAAS;AACpB,cAAa;AACb;AACA;AACA;AACA;AACA;AACA","file":"./dist/js-data-http.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"js-data\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"js-data\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"JSDataHttp\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"JSDataHttp\"] = factory(root[\"JSData\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\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/** WEBPACK FOOTER **\n ** webpack/bootstrap 5ca3dba1258af7fede7c\n **/","/* global fetch:true Headers:true Request:true */\n\nconst axios = require('axios')\nimport {utils} from 'js-data'\nimport {\n Adapter,\n noop,\n noop2\n} from 'js-data-adapter'\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 (window.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 __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n // Default and user-defined settings\n /**\n * @name HttpAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n */\n forceTrailingSlash: false,\n\n /**\n * @name HttpAdapter#http\n * @type {Function}\n */\n http: axios,\n\n /**\n * @name HttpAdapter#httpConfig\n * @type {Object}\n */\n httpConfig: {},\n\n /**\n * @name HttpAdapter#suffix\n * @type {string}\n */\n suffix: '',\n\n /**\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {boolean} [opts.forceTrailingSlash=false] TODO\n * @param {Object} [opts.http=axios] TODO\n * @param {Object} [opts.httpConfig={}] TODO\n * @param {string} [opts.suffix=''] TODO\n * @param {boolean} [opts.useFetch=false] TODO\n */\nfunction HttpAdapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\nexports.HttpAdapter = HttpAdapter\n\n// Setup prototype inheritance from Adapter\nHttpAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: HttpAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(HttpAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `HttpAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyHttpAdapter extends HttpAdapter {...}\n * const adapter = new MyHttpAdapter()\n *\n * @example Using {@link HttpAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps)\n * var adapter = new MyHttpAdapter()\n *\n * @name HttpAdapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `HttpAdapter`.\n */\nHttpAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(HttpAdapter.prototype, {\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 const self = this\n return self.GET(\n self.getPath('count', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('create', mapper, props, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('createMany', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroy', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroyAll', mapper, null, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n const self = this\n return self.GET(\n self.getPath('find', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n return self.GET(\n self.getPath('sum', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n return self.PUT(\n self.getPath('update', mapper, id, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateAll', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateMany', mapper, null, opts),\n self.serialize(mapper, records, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params.count = true\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.count.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.create.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.createMany.call(self, 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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'DEL'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroy.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroyAll.call(self, 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 * @param {Object} [opts] Configuration options.\n */\n fetch (config, opts) {\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(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json().then(function (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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.find.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.findAll.call(self, mapper, query, opts)\n },\n\n /**\n * TODO\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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'GET'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {boolean} opts TODO\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n const self = this\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(function (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, function (value, key) {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(self.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 TODO\n * @param {Object} mapper TODO\n * @param {(string|number)?} id TODO\n * @param {Object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const args = [\n utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath,\n self.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 (utils.isUndefined(opts.params)) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.suffix)) {\n if (utils.isUndefined(mapper.suffix)) {\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 self = this\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, self.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || self.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n function 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 (self.log) {\n self.dbg('debug', str, data)\n }\n return data\n } else {\n if (self.error) {\n self.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!self.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) {\n config = _config || config\n if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) {\n return self.fetch(config, opts).then(logResponse, logResponse)\n }\n return self.http(config).then(logResponse, logResponse).catch(function (err) {\n return self.responseError(err, config, opts)\n })\n }).then(function (response) {\n return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) {\n return _response || response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'POST'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'PUT'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {Object} mapper TODO\n * @param {*} params TODO\n * @param {*} opts TODO\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 * TODO\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {Object} mapper TODO\n * @param {Object} data TODO\n * @param {*} opts TODO\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n if (!utils.utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = self.getParams(opts)\n opts.params.sum = field\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.sum.call(self, mapper, field, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#update\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {*} props TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.update.call(self, mapper, id, props, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {Object} mapper TODO\n * @param {Object} props TODO\n * @param {Object} query TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateAll.call(self, mapper, props, query, opts)\n },\n\n /**\n * Update multiple records in batch.\n *\n * {@link HttpAdapter#beforeUpdateMany} will be called before calling\n * {@link HttpAdapter#PUT}.\n * {@link HttpAdapter#afterUpdateMany} will be called after calling\n * {@link HttpAdapter#PUT}.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} records Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateMany.call(self, 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { default: true })\n * store.defineMapper('school')\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * basePath: '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(function (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]\n * @param {string} [opts.pathname]\n * @param {Function} [opts.request]\n * @param {Function} [opts.response]\n * @param {Function} [opts.responseError]\n * @return {Function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexports.addAction = 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 const self = this\n if (utils.isObject(id)) {\n _opts = id\n }\n _opts = _opts || {}\n let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http')\n let config = {}\n utils.fillIn(config, opts)\n if (!_opts.hasOwnProperty('endpoint') && config.endpoint) {\n _opts.endpoint = config.endpoint\n }\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(self, _opts)\n } else {\n let args = [\n _opts.basePath || self.basePath || adapter.basePath,\n adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _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 config.method = config.method || 'GET'\n config.mapper = self.name\n utils.deepMixIn(config, _opts)\n return utils.resolve(config)\n .then(_opts.request || opts.request)\n .then(function (config) { return adapter.HTTP(config) })\n .then(function (data) {\n if (data && data.config) {\n data.config.mapper = self.name\n }\n return data\n })\n .then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { 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(function (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 */\nexports.addActions = function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n exports.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 */\nexports.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 adapter = new HttpAdapter()\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * @example ES2015 Modules\n * import {HttpAdapter} from 'js-data-Http'\n * const adapter = new HttpAdapter()\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * // ...\n * })\n *\n * @module js-data-http\n */\nexports.default = HttpAdapter\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}\n ** module id = 1\n ** module chunks = 0\n **/","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-data')) :\n typeof define === 'function' && define.amd ? define('js-data-adapter', ['exports', 'js-data'], factory) :\n (factory((global.Adapter = global.Adapter || {}),global.JSData));\n}(this, function (exports,jsData) { 'use strict';\n\n var babelHelpers = {};\n babelHelpers.typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n };\n\n babelHelpers.defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n };\n\n babelHelpers.slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n }();\n\n babelHelpers;\n\n var noop = function noop() {\n var self = this;\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var opts = args[args.length - 1];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var noop2 = function noop2() {\n var self = this;\n\n for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n var opts = args[args.length - 2];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var unique = function unique(array) {\n var seen = {};\n var 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\n var withoutRelations = function withoutRelations(mapper, props) {\n return jsData.utils.omit(props, mapper.relationFields || []);\n };\n\n var 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 * @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 */\n function Adapter(opts) {\n var self = this;\n opts || (opts = {});\n jsData.utils.fillIn(opts, DEFAULTS);\n jsData.utils.fillIn(self, opts);\n }\n\n var reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where'];\n\n /**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\n function Response(data, meta, op) {\n var self = this;\n meta || (meta = {});\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n self.data = data;\n\n jsData.utils.fillIn(self, meta);\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n self.op = op;\n }\n\n /**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\n Adapter.extend = jsData.utils.extend;\n\n jsData.utils.addHiddenPropsToTarget(Adapter.prototype, {\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 * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg: function dbg() {\n for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n\n this.log.apply(this, ['debug'].concat(args));\n },\n\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: function count(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._count(mapper, query, opts));\n }).then(function (results) {\n var _results = babelHelpers.slicedToArray(results, 2);\n\n var data = _results[0];\n var result = _results[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function create(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'create';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._create(mapper, props, opts));\n }).then(function (results) {\n var _results2 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results2[0];\n var result = _results2[1];\n\n result || (result = {});\n var response = new Response(data, result, 'create');\n response.created = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function createMany(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = props.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'createMany';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._createMany(mapper, props, opts));\n }).then(function (results) {\n var _results3 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results3[0];\n var result = _results3[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'createMany');\n response.created = data.length;\n response = self.respond(response, opts);\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function destroy(mapper, id, opts) {\n var self = this;\n var op = void 0;\n opts || (opts = {});\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._destroy(mapper, id, opts));\n }).then(function (results) {\n var _results4 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results4[0];\n var result = _results4[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroy');\n response = self.respond(response, opts);\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function destroyAll(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._destroyAll(mapper, query, opts));\n }).then(function (results) {\n var _results5 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results5[0];\n var result = _results5[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroyAll');\n response = self.respond(response, opts);\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function loadBelongsTo(mapper, def, records, __opts) {\n var self = this;\n var relationDef = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n var _ret = function () {\n var record = records;\n return {\n v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem);\n })\n };\n }();\n\n if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === \"object\") return _ret.v;\n } else {\n var keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record);\n }).filter(function (key) {\n return key;\n });\n return self.findAll(relationDef, {\n where: babelHelpers.defineProperty({}, relationDef.idAttribute, {\n 'in': keys\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem);\n }\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: function find(mapper, id, opts) {\n var self = this;\n var record = void 0,\n op = void 0;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._find(mapper, id, opts));\n }).then(function (results) {\n var _results6 = babelHelpers.slicedToArray(results, 1);\n\n var _record = _results6[0];\n\n if (!_record) {\n return;\n }\n record = _record;\n var tasks = [];\n\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts);\n } else {\n task = self.loadHasMany(mapper, def, record, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(record, {}, 'find');\n response.found = record ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function findAll(mapper, query, opts) {\n var self = this;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n var records = [];\n var op = void 0;\n var activeWith = opts._activeWith;\n\n if (jsData.utils.isObject(activeWith)) {\n var activeQuery = activeWith.query || {};\n if (activeWith.replace) {\n query = activeQuery;\n } else {\n jsData.utils.deepFillIn(query, activeQuery);\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._findAll(mapper, query, opts));\n }).then(function (results) {\n var _results7 = babelHelpers.slicedToArray(results, 1);\n\n var _records = _results7[0];\n\n _records || (_records = []);\n records = _records;\n var tasks = [];\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts);\n } else {\n task = self.loadHasOne(mapper, def, records, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(records, {}, 'findAll');\n response.found = records.length;\n response = self.respond(response, opts);\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function getOpt(opt, opts) {\n opts || (opts = {});\n return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]);\n },\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: function loadHasMany(mapper, def, records, __opts) {\n var self = this;\n var singular = false;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n singular = true;\n records = [records];\n }\n var IDs = records.map(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record);\n });\n var query = {\n where: {}\n };\n var 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(function (id) {\n return id;\n });\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n var attached = [];\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems;\n } else {\n relatedItems.forEach(function (relatedItem) {\n if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem);\n }\n });\n }\n def.setLocalField(record, attached);\n });\n });\n },\n loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) {\n var self = this;\n var record = void 0;\n var relatedMapper = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n var _ret2 = function () {\n var localKeys = [];\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record));\n });\n return {\n v: self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': unique(localKeys).filter(function (x) {\n return x;\n })\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n var attached = [];\n var itemKeys = jsData.utils.get(item, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n relatedItems.forEach(function (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 if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === \"object\") return _ret2.v;\n }\n },\n loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) {\n var self = this;\n var relatedMapper = def.getRelation();\n var idAttribute = mapper.idAttribute;\n var record = void 0;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(def.getRelation(), {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record);\n })\n })\n }, __opts).then(function (relatedItems) {\n var foreignKeysField = def.foreignKeys;\n records.forEach(function (record) {\n var _relatedItems = [];\n var id = jsData.utils.get(record, idAttribute);\n relatedItems.forEach(function (relatedItem) {\n var foreignKeys = jsData.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 /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne: function loadHasOne(mapper, def, records, __opts) {\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n records = [records];\n }\n return this.loadHasMany(mapper, def, records, __opts).then(function () {\n records.forEach(function (record) {\n var relatedData = def.getLocalField(record);\n if (jsData.utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0]);\n }\n });\n });\n },\n\n\n /**\n * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log: function log(level) {\n for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n args[_key4 - 1] = arguments[_key4];\n }\n\n if (level && !args.length) {\n args.push(level);\n level = 'debug';\n }\n if (level === 'debug' && !this.debug) {\n return;\n }\n var prefix = level.toUpperCase() + ': (Adapter)';\n if (console[level]) {\n var _console;\n\n (_console = console)[level].apply(_console, [prefix].concat(args));\n } else {\n var _console2;\n\n (_console2 = console).log.apply(_console2, [prefix].concat(args));\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: function makeHasManyForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\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: function makeHasManyLocalKeys(mapper, def, record) {\n var localKeys = [];\n var itemKeys = jsData.utils.get(record, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n localKeys = localKeys.concat(itemKeys);\n return unique(localKeys).filter(function (x) {\n return x;\n });\n },\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: function makeHasManyForeignKeys(mapper, def, record) {\n return jsData.utils.get(record, mapper.idAttribute);\n },\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: function makeBelongsToForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\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: function sum(mapper, field, query, opts) {\n var self = this;\n var op = void 0;\n if (!jsData.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 jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum';\n self.dbg(op, mapper, field, query, opts);\n return jsData.utils.resolve(self._sum(mapper, field, query, opts));\n }).then(function (results) {\n var _results8 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results8[0];\n var result = _results8[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum';\n return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function respond(response, opts) {\n return this.getOpt('raw', opts) ? response : response.data;\n },\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: function update(mapper, id, props, opts) {\n var self = this;\n props || (props = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'update';\n self.dbg(op, mapper, id, props, opts);\n return jsData.utils.resolve(self._update(mapper, id, props, opts));\n }).then(function (results) {\n var _results9 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results9[0];\n var result = _results9[1];\n\n result || (result = {});\n var response = new Response(data, result, 'update');\n response.updated = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function updateAll(mapper, props, query, opts) {\n var self = this;\n props || (props = {});\n query || (query = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'updateAll';\n self.dbg(op, mapper, props, query, opts);\n return jsData.utils.resolve(self._updateAll(mapper, props, query, opts));\n }).then(function (results) {\n var _results10 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results10[0];\n var result = _results10[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateAll');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function updateMany(mapper, records, opts) {\n var self = this;\n records || (records = []);\n opts || (opts = {});\n var op = void 0;\n var idAttribute = mapper.idAttribute;\n\n records = records.filter(function (record) {\n return jsData.utils.get(record, idAttribute);\n });\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = jsData.utils.isUndefined(_records) ? records : _records;\n records = records.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'updateMany';\n self.dbg(op, mapper, records, opts);\n return jsData.utils.resolve(self._updateMany(mapper, records, opts));\n }).then(function (results) {\n var _results11 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results11[0];\n var result = _results11[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateMany');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n }\n });\n\n exports.noop = noop;\n exports.noop2 = noop2;\n exports.unique = unique;\n exports.withoutRelations = withoutRelations;\n exports.Adapter = Adapter;\n exports.reserved = reserved;\n exports.Response = Response;\n\n}));\n//# sourceMappingURL=js-data-adapter.js.map\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/js-data-adapter/dist/js-data-adapter.js\n ** module id = 2\n ** module chunks = 0\n **/","module.exports = require('./lib/axios');\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/index.js\n ** module id = 3\n ** module chunks = 0\n **/","'use strict';\n\nvar defaults = require('./defaults');\nvar utils = require('./utils');\nvar dispatchRequest = require('./core/dispatchRequest');\nvar InterceptorManager = require('./core/InterceptorManager');\nvar isAbsoluteURL = require('./helpers/isAbsoluteURL');\nvar combineURLs = require('./helpers/combineURLs');\nvar bind = require('./helpers/bind');\nvar transformData = require('./helpers/transformData');\n\nfunction Axios(defaultConfig) {\n this.defaults = utils.merge({}, defaultConfig);\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = utils.merge({\n url: arguments[0]\n }, arguments[1]);\n }\n\n config = utils.merge(defaults, this.defaults, { method: 'get' }, config);\n\n // Support baseURL config\n if (config.baseURL && !isAbsoluteURL(config.url)) {\n config.url = combineURLs(config.baseURL, config.url);\n }\n\n // Don't allow overriding defaults.withCredentials\n config.withCredentials = config.withCredentials || this.defaults.withCredentials;\n\n // Transform request data\n config.data = transformData(\n config.data,\n config.headers,\n config.transformRequest\n );\n\n // Flatten headers\n config.headers = utils.merge(\n config.headers.common || {},\n config.headers[config.method] || {},\n config.headers || {}\n );\n\n utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n function cleanHeaderConfig(method) {\n delete config.headers[method];\n }\n );\n\n // Hook up interceptors middleware\n var chain = [dispatchRequest, undefined];\n var promise = Promise.resolve(config);\n\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n chain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n chain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n};\n\nvar defaultInstance = new Axios(defaults);\nvar axios = module.exports = bind(Axios.prototype.request, defaultInstance);\n\n// Expose properties from defaultInstance\naxios.defaults = defaultInstance.defaults;\naxios.interceptors = defaultInstance.interceptors;\n\n// Factory for creating new instances\naxios.create = function create(defaultConfig) {\n return new Axios(defaultConfig);\n};\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url\n }));\n };\n axios[method] = bind(Axios.prototype[method], defaultInstance);\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n axios[method] = bind(Axios.prototype[method], defaultInstance);\n});\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/axios.js\n ** module id = 4\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./utils');\n\nvar PROTECTION_PREFIX = /^\\)\\]\\}',?\\n/;\nvar DEFAULT_CONTENT_TYPE = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nmodule.exports = {\n transformRequest: [function transformRequest(data, headers) {\n if (utils.isFormData(data) || utils.isArrayBuffer(data) || utils.isStream(data)) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) {\n // Set application/json if no Content-Type has been specified\n if (!utils.isUndefined(headers)) {\n utils.forEach(headers, function processContentTypeHeader(val, key) {\n if (key.toLowerCase() === 'content-type') {\n headers['Content-Type'] = val;\n }\n });\n\n if (utils.isUndefined(headers['Content-Type'])) {\n headers['Content-Type'] = 'application/json;charset=utf-8';\n }\n }\n return JSON.stringify(data);\n }\n return data;\n }],\n\n transformResponse: [function transformResponse(data) {\n /*eslint no-param-reassign:0*/\n if (typeof data === 'string') {\n data = data.replace(PROTECTION_PREFIX, '');\n try {\n data = JSON.parse(data);\n } catch (e) { /* Ignore */ }\n }\n return data;\n }],\n\n headers: {\n common: {\n 'Accept': 'application/json, text/plain, */*'\n },\n patch: utils.merge(DEFAULT_CONTENT_TYPE),\n post: utils.merge(DEFAULT_CONTENT_TYPE),\n put: utils.merge(DEFAULT_CONTENT_TYPE)\n },\n\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n\n maxContentLength: -1,\n\n validateStatus: function validateStatus(status) {\n return status >= 200 && status < 300;\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/defaults.js\n ** module id = 5\n ** module chunks = 0\n **/","'use strict';\n\n/*global toString:true*/\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return toString.call(val) === '[object FormData]';\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Determine if a value is a Function\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\nfunction isFunction(val) {\n return toString.call(val) === '[object Function]';\n}\n\n/**\n * Determine if a value is a Stream\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Stream, otherwise false\n */\nfunction isStream(val) {\n return isObject(val) && isFunction(val.pipe);\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * typeof document.createElement -> undefined\n */\nfunction isStandardBrowserEnv() {\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined' &&\n typeof document.createElement === 'function'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object' && !isArray(obj)) {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (obj.hasOwnProperty(key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (typeof result[key] === 'object' && typeof val === 'object') {\n result[key] = merge(result[key], val);\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isFunction: isFunction,\n isStream: isStream,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n trim: trim\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/utils.js\n ** module id = 6\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Dispatch a request to the server using whichever adapter\n * is supported by the current environment.\n *\n * @param {object} config The config that is to be used for the request\n * @returns {Promise} The Promise to be fulfilled\n */\nmodule.exports = function dispatchRequest(config) {\n return new Promise(function executor(resolve, reject) {\n try {\n var adapter;\n\n if (typeof config.adapter === 'function') {\n // For custom adapter support\n adapter = config.adapter;\n } else if (typeof XMLHttpRequest !== 'undefined') {\n // For browsers use XHR adapter\n adapter = require('../adapters/xhr');\n } else if (typeof process !== 'undefined') {\n // For node use HTTP adapter\n adapter = require('../adapters/http');\n }\n\n if (typeof adapter === 'function') {\n adapter(resolve, reject, config);\n }\n } catch (e) {\n reject(e);\n }\n });\n};\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/core/dispatchRequest.js\n ** module id = 7\n ** module chunks = 0\n **/","// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/process/browser.js\n ** module id = 8\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\nvar buildURL = require('./../helpers/buildURL');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar transformData = require('./../helpers/transformData');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar btoa = (typeof window !== 'undefined' && window.btoa) || require('./../helpers/btoa');\nvar settle = require('../helpers/settle');\n\nmodule.exports = function xhrAdapter(resolve, reject, config) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n var loadEvent = 'onreadystatechange';\n var xDomain = false;\n\n // For IE 8/9 CORS support\n // Only supports POST and GET calls and doesn't returns the response headers.\n // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.\n if (process.env.NODE_ENV !== 'test' && typeof window !== 'undefined' && window.XDomainRequest && !('withCredentials' in request) && !isURLSameOrigin(config.url)) {\n request = new window.XDomainRequest();\n loadEvent = 'onload';\n xDomain = true;\n }\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password || '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n // For IE 9 CORS support.\n request.onprogress = function handleProgress() {};\n request.ontimeout = function handleTimeout() {};\n\n // Listen for ready state\n request[loadEvent] = function handleLoad() {\n if (!request || (request.readyState !== 4 && !xDomain)) {\n return;\n }\n\n // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n if (request.status === 0) {\n return;\n }\n\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n var response = {\n data: transformData(\n responseData,\n responseHeaders,\n config.transformResponse\n ),\n // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)\n status: request.status === 1223 ? 204 : request.status,\n statusText: request.status === 1223 ? 'No Content' : request.statusText,\n headers: responseHeaders,\n config: config,\n request: request\n };\n\n settle(resolve, reject, response);\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(new Error('Network Error'));\n\n // Clean up request\n request = null;\n };\n\n // Handle timeout\n request.ontimeout = function handleTimeout() {\n var err = new Error('timeout of ' + config.timeout + 'ms exceeded');\n err.timeout = config.timeout;\n err.code = 'ECONNABORTED';\n reject(err);\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n var cookies = require('./../helpers/cookies');\n\n // Add xsrf header\n var xsrfValue = config.withCredentials || isURLSameOrigin(config.url) ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (config.withCredentials) {\n request.withCredentials = true;\n }\n\n // Add responseType to request if needed\n if (config.responseType) {\n try {\n request.responseType = config.responseType;\n } catch (e) {\n if (request.responseType !== 'json') {\n throw e;\n }\n }\n }\n\n // Handle progress if needed\n if (config.progress) {\n if (config.method === 'post' || config.method === 'put') {\n request.upload.addEventListener('progress', config.progress);\n } else if (config.method === 'get') {\n request.addEventListener('progress', config.progress);\n }\n }\n\n if (requestData === undefined) {\n requestData = null;\n }\n\n // Send the request\n request.send(requestData);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/adapters/xhr.js\n ** module id = 9\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\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\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @returns {string} The formatted url\n */\nmodule.exports = function buildURL(url, params, paramsSerializer) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n\n var serializedParams;\n if (paramsSerializer) {\n serializedParams = paramsSerializer(params);\n } else {\n var parts = [];\n\n utils.forEach(params, function serialize(val, key) {\n if (val === null || typeof val === 'undefined') {\n return;\n }\n\n if (utils.isArray(val)) {\n key = key + '[]';\n }\n\n if (!utils.isArray(val)) {\n val = [val];\n }\n\n utils.forEach(val, function parseValue(v) {\n if (utils.isDate(v)) {\n v = v.toISOString();\n } else if (utils.isObject(v)) {\n v = JSON.stringify(v);\n }\n parts.push(encode(key) + '=' + encode(v));\n });\n });\n\n serializedParams = parts.join('&');\n }\n\n if (serializedParams) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n};\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/buildURL.js\n ** module id = 10\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n });\n\n return parsed;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/parseHeaders.js\n ** module id = 11\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Object|String} data The data to be transformed\n * @param {Array} headers The headers for the request or response\n * @param {Array|Function} fns A single function or Array of functions\n * @returns {*} The resulting transformed data\n */\nmodule.exports = function transformData(data, headers, fns) {\n /*eslint no-param-reassign:0*/\n utils.forEach(fns, function transform(fn) {\n data = fn(data, headers);\n });\n\n return data;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/transformData.js\n ** module id = 12\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/isURLSameOrigin.js\n ** module id = 13\n ** module chunks = 0\n **/","'use strict';\n\n// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js\n\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\nfunction E() {\n this.message = 'String contains an invalid character';\n}\nE.prototype = new Error;\nE.prototype.code = 5;\nE.prototype.name = 'InvalidCharacterError';\n\nfunction btoa(input) {\n var str = String(input);\n var output = '';\n for (\n // initialize result and counter\n var block, charCode, idx = 0, map = chars;\n // if the next str index does not exist:\n // change the mapping table to \"=\"\n // check if d has no fractional digits\n str.charAt(idx | 0) || (map = '=', idx % 1);\n // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n ) {\n charCode = str.charCodeAt(idx += 3 / 4);\n if (charCode > 0xFF) {\n throw new E();\n }\n block = block << 8 | charCode;\n }\n return output;\n}\n\nmodule.exports = btoa;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/btoa.js\n ** module id = 14\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n */\nmodule.exports = function settle(resolve, reject, response) {\n var validateStatus = response.config.validateStatus;\n // Note: status is not exposed by XDomainRequest\n if (!response.status || !validateStatus || validateStatus(response.status)) {\n resolve(response);\n } else {\n reject(response);\n }\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/settle.js\n ** module id = 15\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs support document.cookie\n (function standardBrowserEnv() {\n return {\n write: function write(name, value, expires, path, domain, secure) {\n var cookie = [];\n cookie.push(name + '=' + encodeURIComponent(value));\n\n if (utils.isNumber(expires)) {\n cookie.push('expires=' + new Date(expires).toGMTString());\n }\n\n if (utils.isString(path)) {\n cookie.push('path=' + path);\n }\n\n if (utils.isString(domain)) {\n cookie.push('domain=' + domain);\n }\n\n if (secure === true) {\n cookie.push('secure');\n }\n\n document.cookie = cookie.join('; ');\n },\n\n read: function read(name) {\n var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove: function remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n };\n })() :\n\n // Non standard browser env (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return {\n write: function write() {},\n read: function read() { return null; },\n remove: function remove() {}\n };\n })()\n);\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/cookies.js\n ** module id = 16\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/core/InterceptorManager.js\n ** module id = 17\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nmodule.exports = function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/isAbsoluteURL.js\n ** module id = 18\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n * @returns {string} The combined URL\n */\nmodule.exports = function combineURLs(baseURL, relativeURL) {\n return baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '');\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/combineURLs.js\n ** module id = 19\n ** module chunks = 0\n **/","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/bind.js\n ** module id = 20\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n * @returns {Function}\n */\nmodule.exports = function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/spread.js\n ** module id = 21\n ** module chunks = 0\n **/"],"sourceRoot":""} \ 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.11.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 defaults = __webpack_require__(2);\n\tvar utils = __webpack_require__(3);\n\tvar dispatchRequest = __webpack_require__(4);\n\tvar InterceptorManager = __webpack_require__(13);\n\tvar isAbsoluteURL = __webpack_require__(14);\n\tvar combineURLs = __webpack_require__(15);\n\tvar bind = __webpack_require__(16);\n\tvar transformData = __webpack_require__(8);\n\t\n\tfunction Axios(defaultConfig) {\n\t this.defaults = utils.merge({}, defaultConfig);\n\t this.interceptors = {\n\t request: new InterceptorManager(),\n\t response: new InterceptorManager()\n\t };\n\t}\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 // Don't allow overriding defaults.withCredentials\n\t config.withCredentials = config.withCredentials || this.defaults.withCredentials;\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 // 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\tvar defaultInstance = new Axios(defaults);\n\tvar axios = module.exports = bind(Axios.prototype.request, defaultInstance);\n\tmodule.exports.Axios = Axios;\n\t\n\t// Expose properties from defaultInstance\n\taxios.defaults = defaultInstance.defaults;\n\taxios.interceptors = defaultInstance.interceptors;\n\t\n\t// Factory for creating new instances\n\taxios.create = function create(defaultConfig) {\n\t return new Axios(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__(17);\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 axios[method] = bind(Axios.prototype[method], defaultInstance);\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 axios[method] = bind(Axios.prototype[method], defaultInstance);\n\t});\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(3);\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\tmodule.exports = {\n\t transformRequest: [function transformRequest(data, headers) {\n\t if (utils.isFormData(data) || utils.isArrayBuffer(data) || utils.isStream(data)) {\n\t return data;\n\t }\n\t if (utils.isArrayBufferView(data)) {\n\t return data.buffer;\n\t }\n\t if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) {\n\t // Set application/json if no Content-Type has been specified\n\t if (!utils.isUndefined(headers)) {\n\t utils.forEach(headers, function processContentTypeHeader(val, key) {\n\t if (key.toLowerCase() === 'content-type') {\n\t headers['Content-Type'] = val;\n\t }\n\t });\n\t\n\t if (utils.isUndefined(headers['Content-Type'])) {\n\t headers['Content-Type'] = 'application/json;charset=utf-8';\n\t }\n\t }\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/* 3 */\n/***/ function(module, exports) {\n\n\t'use strict';\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 * 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\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 isStandardBrowserEnv: isStandardBrowserEnv,\n\t forEach: forEach,\n\t merge: merge,\n\t trim: trim\n\t};\n\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\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 return new Promise(function executor(resolve, reject) {\n\t try {\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__(5);\n\t } else if (typeof process !== 'undefined') {\n\t // For node use HTTP adapter\n\t adapter = __webpack_require__(5);\n\t }\n\t\n\t if (typeof adapter === 'function') {\n\t adapter(resolve, reject, config);\n\t }\n\t } catch (e) {\n\t reject(e);\n\t }\n\t });\n\t};\n\t\n\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(3);\n\tvar buildURL = __webpack_require__(6);\n\tvar parseHeaders = __webpack_require__(7);\n\tvar transformData = __webpack_require__(8);\n\tvar isURLSameOrigin = __webpack_require__(9);\n\tvar btoa = (typeof window !== 'undefined' && window.btoa) || __webpack_require__(10);\n\tvar settle = __webpack_require__(11);\n\t\n\tmodule.exports = function xhrAdapter(resolve, reject, config) {\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' && typeof window !== 'undefined' && window.XDomainRequest && !('withCredentials' in request) && !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: transformData(\n\t responseData,\n\t responseHeaders,\n\t config.transformResponse\n\t ),\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(new Error('Network Error'));\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 var err = new Error('timeout of ' + config.timeout + 'ms exceeded');\n\t err.timeout = config.timeout;\n\t err.code = 'ECONNABORTED';\n\t reject(err);\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__(12);\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 (config.progress) {\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\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(3);\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 {\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\t\n\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(3);\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/* 8 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(3);\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/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(3);\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/* 10 */\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/* 11 */\n/***/ function(module, exports) {\n\n\t'use strict';\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(response);\n\t }\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__(3);\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/* 13 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(3);\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/* 14 */\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/* 15 */\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/* 16 */\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/* 17 */\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","\nimport {utils} from 'js-data'\n\nexport const noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const self = this\n const opts = args[args.length - 2]\n self.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) {\n return utils.omit(props, mapper.relationFields || [])\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 * @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 const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(self, opts)\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 const self = this\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n self.data = data\n\n utils.fillIn(self, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n self.op = op\n}\n\n/**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\nAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(Adapter.prototype, {\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 * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\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 const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._count(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'create'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._create(mapper, props, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = props.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'createMany'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._createMany(mapper, props, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._destroy(mapper, id, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = self.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._destroyAll(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = self.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 self = this\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record)\n }).filter(function (key) {\n return key\n })\n return self.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (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 const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._find(mapper, id, opts))\n }).then(function (results) {\n let [_record] = results\n if (!_record) {\n return\n }\n record = _record\n const tasks = []\n\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts)\n } else {\n task = self.loadHasMany(mapper, def, record, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(record, {}, 'find')\n response.found = record ? 1 : 0\n response = self.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n let records = []\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(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._findAll(mapper, query, opts))\n }).then(function (results) {\n let [_records] = results\n _records || (_records = [])\n records = _records\n const tasks = []\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts)\n } else {\n task = self.loadHasOne(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(records, {}, 'findAll')\n response.found = records.length\n response = self.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 utils.isUndefined(opts[opt]) ? 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 const self = this\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(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record)\n })\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(function (id) {\n return id\n })\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (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(function (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 const self = this\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 self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record))\n })\n return self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach(function (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 self = this\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 self.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return self.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record)\n })\n }\n }\n }, __opts).then(function (relatedItems) {\n const foreignKeysField = def.foreignKeys\n records.forEach(function (record) {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach(function (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(function () {\n records.forEach(function (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 * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (Adapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\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(function (x) { return 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 const self = this\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(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n self.dbg(op, mapper, field, query, opts)\n return utils.resolve(self._sum(mapper, field, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'update'\n self.dbg(op, mapper, id, props, opts)\n return utils.resolve(self._update(mapper, id, props, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\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(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'updateAll'\n self.dbg(op, mapper, props, query, opts)\n return utils.resolve(self._updateAll(mapper, props, query, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter(function (record) {\n return utils.get(record, idAttribute)\n })\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = utils.isUndefined(_records) ? records : _records\n records = records.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'updateMany'\n self.dbg(op, mapper, records, opts)\n return utils.resolve(self._updateMany(mapper, records, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n }\n})\n","/* global fetch:true Headers:true Request:true */\n\nimport {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 (window.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 __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n // Default and user-defined settings\n /**\n * @name HttpAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n */\n forceTrailingSlash: false,\n\n /**\n * @name HttpAdapter#http\n * @type {Function}\n */\n http: axios,\n\n /**\n * @name HttpAdapter#httpConfig\n * @type {Object}\n */\n httpConfig: {},\n\n /**\n * @name HttpAdapter#suffix\n * @type {string}\n */\n suffix: '',\n\n /**\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {boolean} [opts.forceTrailingSlash=false] TODO\n * @param {Object} [opts.http=axios] TODO\n * @param {Object} [opts.httpConfig={}] TODO\n * @param {string} [opts.suffix=''] TODO\n * @param {boolean} [opts.useFetch=false] TODO\n */\nexport function HttpAdapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\n// Setup prototype inheritance from Adapter\nHttpAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: HttpAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(HttpAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `HttpAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyHttpAdapter extends HttpAdapter {...}\n * const adapter = new MyHttpAdapter()\n *\n * @example Using {@link HttpAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps)\n * var adapter = new MyHttpAdapter()\n *\n * @name HttpAdapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `HttpAdapter`.\n */\nHttpAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(HttpAdapter.prototype, {\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 const self = this\n return self.GET(\n self.getPath('count', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('create', mapper, props, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('createMany', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroy', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroyAll', mapper, null, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n const self = this\n return self.GET(\n self.getPath('find', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n return self.GET(\n self.getPath('sum', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n return self.PUT(\n self.getPath('update', mapper, id, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateAll', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateMany', mapper, null, opts),\n self.serialize(mapper, records, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params.count = true\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.count.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.create.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.createMany.call(self, 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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'DEL'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroy.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroyAll.call(self, 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 * @param {Object} [opts] Configuration options.\n */\n fetch (config, opts) {\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(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json().then(function (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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.find.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.findAll.call(self, mapper, query, opts)\n },\n\n /**\n * TODO\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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'GET'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {boolean} opts TODO\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n const self = this\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(function (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, function (value, key) {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(self.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 TODO\n * @param {Object} mapper TODO\n * @param {(string|number)?} id TODO\n * @param {Object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const args = [\n utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath,\n self.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 (utils.isUndefined(opts.params)) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.suffix)) {\n if (utils.isUndefined(mapper.suffix)) {\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 self = this\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, self.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || self.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n function 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 (self.log) {\n self.dbg('debug', str, data)\n }\n return data\n } else {\n if (self.error) {\n self.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!self.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) {\n config = _config || config\n if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) {\n return self.fetch(config, opts).then(logResponse, logResponse)\n }\n return self.http(config).then(logResponse, logResponse).catch(function (err) {\n return self.responseError(err, config, opts)\n })\n }).then(function (response) {\n return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) {\n return _response || response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'POST'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'PUT'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {Object} mapper TODO\n * @param {*} params TODO\n * @param {*} opts TODO\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 * TODO\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {Object} mapper TODO\n * @param {Object} data TODO\n * @param {*} opts TODO\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n if (!utils.utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = self.getParams(opts)\n opts.params.sum = field\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.sum.call(self, mapper, field, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#update\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {*} props TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.update.call(self, mapper, id, props, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {Object} mapper TODO\n * @param {Object} props TODO\n * @param {Object} query TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateAll.call(self, mapper, props, query, opts)\n },\n\n /**\n * Update multiple records in batch.\n *\n * {@link HttpAdapter#beforeUpdateMany} will be called before calling\n * {@link HttpAdapter#PUT}.\n * {@link HttpAdapter#afterUpdateMany} will be called after calling\n * {@link HttpAdapter#PUT}.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} records Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateMany.call(self, 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { default: true })\n * store.defineMapper('school')\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * basePath: '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(function (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]\n * @param {string} [opts.pathname]\n * @param {Function} [opts.request]\n * @param {Function} [opts.response]\n * @param {Function} [opts.responseError]\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 const self = this\n if (utils.isObject(id)) {\n _opts = id\n }\n _opts = _opts || {}\n let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http')\n let config = {}\n utils.fillIn(config, opts)\n if (!_opts.hasOwnProperty('endpoint') && config.endpoint) {\n _opts.endpoint = config.endpoint\n }\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(self, _opts)\n } else {\n let args = [\n _opts.basePath || self.basePath || adapter.basePath,\n adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _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 config.method = config.method || 'GET'\n config.mapper = self.name\n utils.deepMixIn(config, _opts)\n return utils.resolve(config)\n .then(_opts.request || opts.request)\n .then(function (config) { return adapter.HTTP(config) })\n .then(function (data) {\n if (data && data.config) {\n data.config.mapper = self.name\n }\n return data\n })\n .then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { 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(function (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 adapter = new HttpAdapter()\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * @example ES2015 Modules\n * import {HttpAdapter} from 'js-data-Http'\n * const adapter = new HttpAdapter()\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * // ...\n * })\n *\n * @module js-data-http\n */\n"],"names":["this","utils","DEFAULTS","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,iBAAI,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,EAA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,EAA2B;AAChC,CAAA,WAAS,OAAO,EAAhB;AACA,CAAA,SAAO,UAAU,MAAV,EAAkB;AACvB,CAAA,iBAAM,MAAN,CAAa,IAAb,EAAmB,UAAU,KAAV,EAAiB,GAAjB,EAAsB;AACvC,CAAA,gBAAU,GAAV,EAAe,KAAf,EAAsB,MAAtB;AACD,CAAA,KAFD;AAGA,CAAA,WAAO,MAAP;AACD,CAAA,GALD;AAMD,CAAA;;;;;;;;;;;;;;;;AAgBD,CAAO,IAAM,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 6a76dac..239bc5b 100644 --- a/dist/js-data-http.min.js +++ b/dist/js-data-http.min.js @@ -1,11 +1,11 @@ /*! * js-data-http -* @version 3.0.0-beta.5 - Homepage +* @version 3.0.0-beta.6 - Homepage * @copyright (c) 2014-2016 js-data-http project authors * @license MIT * * @overview HTTP (XHR) adapter for js-data in the browser. */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],t):"object"==typeof exports?exports.JSDataHttp=t(require("js-data")):e.JSDataHttp=t(e.JSData)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return null!=e&&""!==e}function o(e,t){return t||(t=""),e.filter(r).join(t)}function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var r=o(t,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(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,"]")}function a(e,t){if(!t)return e;var n=[];return l.utils.forOwn(t,function(e,t){null!==e&&"undefined"!=typeof e&&(l.utils.isArray(e)||(e=[e]),e.forEach(function(e){"[object Date]"===window.toString.call(e)?e=e.toISOString():l.utils.isObject(e)&&(e=l.utils.toJson(e)),n.push(u(t)+"="+u(e))}))}),n.length>0&&(e+=(-1===e.indexOf("?")?"?":"&")+n.join("&")),e}function s(e){var t=this;e||(e={}),l.utils.fillIn(e,y),c.Adapter.call(t,e)}var f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},l=n(1),c=n(2),d=n(3),p=!1;try{p=window&&window.fetch}catch(e){}var h=c.Adapter.prototype,y={basePath:"",forceTrailingSlash:!1,http:d,httpConfig:{},suffix:"",useFetch:!1};t.HttpAdapter=s,s.prototype=Object.create(c.Adapter.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(s,"__super__",{configurable:!0,value:c.Adapter}),s.extend=l.utils.extend,l.utils.addHiddenPropsToTarget(s.prototype,{afterDEL:c.noop2,afterGET:c.noop2,afterHTTP:c.noop2,afterPOST:c.noop2,afterPUT:c.noop2,beforeDEL:c.noop,beforeGET:c.noop,beforeHTTP:c.noop,beforePOST:c.noop,beforePUT:c.noop,_count:function(e,t,n){var r=this;return r.GET(r.getPath("count",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_create:function(e,t,n){var r=this;return r.POST(r.getPath("create",e,t,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_createMany:function(e,t,n){var r=this;return r.POST(r.getPath("createMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroy:function(e,t,n){var r=this;return r.DEL(r.getPath("destroy",e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroyAll:function(e,t,n){var r=this;return r.DEL(r.getPath("destroyAll",e,null,n),n).then(function(t){return r._end(e,n,t)})},_end:function(e,t,n){return[this.deserialize(e,n,t),n]},_find:function(e,t,n){var r=this;return r.GET(r.getPath("find",e,t,n),n).then(function(t){return r._end(e,n,t)})},_findAll:function(e,t,n){var r=this;return r.GET(r.getPath("findAll",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_sum:function(e,t,n,r){var o=this;return o.GET(o.getPath("sum",e,r.params,r),r).then(function(t){return o._end(e,r,t)})},_update:function(e,t,n,r){var o=this;return o.PUT(o.getPath("update",e,t,r),o.serialize(e,n,r),r).then(function(t){return o._end(e,r,t)})},_updateAll:function(e,t,n,r){var o=this;return o.PUT(o.getPath("updateAll",e,null,r),o.serialize(e,t,r),r).then(function(t){return o._end(e,r,t)})},_updateMany:function(e,t,n){var r=this;return r.PUT(r.getPath("updateMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},count:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),n.params.count=!0,n.suffix=r.getSuffix(e,n),l.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),h.count.call(r,e,t,n)},create:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.create.call(r,e,t,n)},createMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.createMany.call(r,e,t,n)},DEL:function(e,t,n){var r=this,o=void 0;return t||(t={}),n||(n={}),t.url=e||t.url,t.method=t.method||"delete",o=n.op="beforeDEL",l.utils.resolve(r[o](e,t,n)).then(function(i){return t=l.utils.isUndefined(i)?t:i,o=n.op="DEL",r.dbg(o,e,t,n),r.HTTP(t,n)}).then(function(i){return o=n.op="afterDEL",l.utils.resolve(r[o](e,t,n,i)).then(function(e){return l.utils.isUndefined(e)?i:e})})},deserialize:function(e,t,n){return n||(n={}),l.utils.isFunction(n.deserialize)?n.deserialize(e,t,n):l.utils.isFunction(e.deserialize)?e.deserialize(e,t,n):t&&t.hasOwnProperty("data")?t.data:t},destroy:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.destroy.call(r,e,t,n)},destroyAll:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),l.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.destroyAll.call(r,e,t,n)},error:function(){if(console){var e;(e=console)["function"==typeof console.error?"error":"log"].apply(e,arguments)}},fetch:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,t){var n={method:e.method,headers:new Headers(e.headers)};return e.data&&(n.body=l.utils.toJson(e.data)),fetch(new Request(a(e.url,e.params),n)).then(function(t){return t.config={method:e.method,url:e.url},t.json().then(function(e){return t.data=e,t})})}),find:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.find.call(r,e,t,n)},findAll:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),n.suffix=r.getSuffix(e,n),l.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),h.findAll.call(r,e,t,n)},GET:function(e,t,n){var r=this,o=void 0;return t||(t={}),n||(n={}),t.url=e||t.url,t.method=t.method||"get",o=n.op="beforeGET",l.utils.resolve(r[o](e,t,n)).then(function(i){return t=l.utils.isUndefined(i)?t:i,o=n.op="GET",r.dbg(o,e,t,n),r.HTTP(t,n)}).then(function(i){return o=n.op="afterGET",l.utils.resolve(r[o](e,t,n,i)).then(function(e){return l.utils.isUndefined(e)?i:e})})},getEndpoint:function(e,t,n){var r=this;n||(n={}),n.params=l.utils.isUndefined(n.params)?{}:n.params;var o=e.relationList||[],u=l.utils.isUndefined(n.endpoint)?l.utils.isUndefined(e.endpoint)?e.name:e.endpoint:n.endpoint;return o.forEach(function(e){if("belongsTo"===e.type&&e.parent){var o=void 0,a=e.foreignKey,s=e.getRelation(),c=n.params[a];if(c===!1||!a||!s)return c===!1&&delete n.params[a],!1;if(delete n.params[a],l.utils.isObject(t)&&(o=t),o&&(c=c||e.getForeignKey(o)||(e.getLocalField(o)?l.utils.get(e.getLocalField(o),s.idAttribute):null)),c){var d=function(){delete n.endpoint;var e={};return l.utils.forOwn(n,function(t,n){e[n]=t}),l.utils._(e,s),u=i(r.getEndpoint(s,c,e),c,u),{v:!1}}();if("object"===("undefined"==typeof d?"undefined":f(d)))return d.v}}}),u},getPath:function(e,t,n,r){var o=this;r||(r={});var u=[l.utils.isUndefined(r.basePath)?l.utils.isUndefined(t.basePath)?o.basePath:t.basePath:r.basePath,o.getEndpoint(t,l.utils.isString(n)||l.utils.isNumber(n)||"create"===e?n:null,r)];return"find"!==e&&"update"!==e&&"destroy"!==e||u.push(n),i.apply(l.utils,u)},getParams:function(e){return e||(e={}),l.utils.isUndefined(e.params)?{}:l.utils.copy(e.params)},getSuffix:function(e,t){return t||(t={}),l.utils.isUndefined(t.suffix)?l.utils.isUndefined(e.suffix)?this.suffix:e.suffix:t.suffix},HTTP:function(e,t){function n(t){var n=o.toUTCString()+" - "+e.method.toUpperCase()+" "+e.url+" - "+t.status+" "+((new Date).getTime()-o.getTime())+"ms";return t.status>=200&&t.status<300?(r.log&&r.dbg("debug",n,t),t):(r.error&&r.error("'FAILED: "+n,t),l.utils.reject(t))}var r=this,o=new Date;t||(t={});var i=e.data,u=e.cache,a=e.timeout;e=l.utils.copy(e,null,null,null,["data","cache","timeout"]),e=l.utils.deepMixIn(e,r.httpConfig),e.data=i,e.cache=u,e.timeout=a,r.forceTrailingSlash&&"/"!==e.url[e.url.length-1]&&(e.url+="/"),e.method=e.method.toUpperCase();var s=e.suffix||t.suffix||r.suffix;if(s&&e.url.substr(e.url.length-s.length)!==s&&(e.url+=s),!r.http)throw new Error("You have not configured this adapter with an http library!");return l.utils.resolve(r.beforeHTTP(e,t)).then(function(o){return e=o||e,p&&(r.useFetch||t.useFetch||!r.http)?r.fetch(e,t).then(n,n):r.http(e).then(n,n).catch(function(n){return r.responseError(n,e,t)})}).then(function(n){return l.utils.resolve(r.afterHTTP(e,t,n)).then(function(e){return e||n})})},POST:function(e,t,n,r){var o=this,i=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.data=t||n.data,n.method=n.method||"post",i=r.op="beforePOST",l.utils.resolve(o[i](e,t,n,r)).then(function(u){return n=l.utils.isUndefined(u)?n:u,i=r.op="POST",o.dbg(i,e,t,n,r),o.HTTP(n,r)}).then(function(u){return i=r.op="afterPOST",l.utils.resolve(o[i](e,t,n,r,u)).then(function(e){return l.utils.isUndefined(e)?u:e})})},PUT:function(e,t,n,r){var o=this,i=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.data=t||n.data,n.method=n.method||"put",i=r.op="beforePUT",l.utils.resolve(o[i](e,t,n,r)).then(function(u){return n=l.utils.isUndefined(u)?n:u,i=r.op="PUT",o.dbg(i,e,t,n,r),o.HTTP(n,r)}).then(function(u){return i=r.op="afterPUT",l.utils.resolve(o[i](e,t,n,r,u)).then(function(e){return l.utils.isUndefined(e)?u:e})})},queryTransform:function(e,t,n){return n||(n={}),l.utils.isFunction(n.queryTransform)?n.queryTransform(e,t,n):l.utils.isFunction(e.queryTransform)?e.queryTransform(e,t,n):t},responseError:function(e,t,n){return l.utils.reject(e)},serialize:function(e,t,n){return n||(n={}),l.utils.isFunction(n.serialize)?n.serialize(e,t,n):l.utils.isFunction(e.serialize)?e.serialize(e,t,n):t},sum:function(e,t,n,r){var o=this;if(n||(n={}),r||(r={}),!l.utils.utils.isString(t))throw new Error("field must be a string!");return r.params=o.getParams(r),r.params.sum=t,r.suffix=o.getSuffix(e,r),l.utils.deepMixIn(r.params,n),r.params=o.queryTransform(e,r.params,r),h.sum.call(o,e,t,n,r)},update:function(e,t,n,r){var o=this;return r||(r={}),r.params=o.getParams(r),r.params=o.queryTransform(e,r.params,r),r.suffix=o.getSuffix(e,r),h.update.call(o,e,t,n,r)},updateAll:function(e,t,n,r){var o=this;return n||(n={}),r||(r={}),r.params=o.getParams(r),l.utils.deepMixIn(r.params,n),r.params=o.queryTransform(e,r.params,r),r.suffix=o.getSuffix(e,r),h.updateAll.call(o,e,t,n,r)},updateMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.updateMany.call(r,e,t,n)}}),t.addAction=function(e,t){if(!e||!l.utils.isString(e))throw new TypeError("action(name[, opts]): Expected: string, Found: "+("undefined"==typeof e?"undefined":f(e)));return function(n){if(n[e])throw new Error("action(name[, opts]): "+e+" already exists on target!");return t.request=t.request||function(e){return e},t.response=t.response||function(e){return e},t.responseError=t.responseError||function(e){return l.utils.reject(e)},n[e]=function(n,r){var o=this;l.utils.isObject(n)&&(r=n),r=r||{};var u=o.getAdapter(t.adapter||o.defaultAdapter||"http"),a={};if(l.utils.fillIn(a,t),!r.hasOwnProperty("endpoint")&&a.endpoint&&(r.endpoint=a.endpoint),"function"==typeof r.getEndpoint)a.url=r.getEndpoint(o,r);else{var s=[r.basePath||o.basePath||u.basePath,u.getEndpoint(o,l.utils.isSorN(n)?n:null,r)];l.utils.isSorN(n)&&s.push(n),s.push(t.pathname||e),a.url=i.apply(null,s)}return a.method=a.method||"GET",a.mapper=o.name,l.utils.deepMixIn(a,r),l.utils.resolve(a).then(r.request||t.request).then(function(e){return u.HTTP(e)}).then(function(e){return e&&e.config&&(e.config.mapper=o.name),e}).then(r.response||t.response,r.responseError||t.responseError)},n}},t.addActions=function(e){return e||(e={}),function(n){return l.utils.forOwn(e,function(e,r){t.addAction(r,e)(n)}),n}},t.version={beta:5,full:"3.0.0-beta.5",major:3,minor:0,patch:0},t.default=s},function(t,n){t.exports=e},function(e,t,n){!function(e,r){r(t,n(1))}(this,function(e,t){"use strict";function n(e){var n=this;e||(e={}),t.utils.fillIn(e,f),t.utils.fillIn(n,e)}function r(e,n,r){var o=this;n||(n={}),o.data=e,t.utils.fillIn(o,n),o.op=r}var o={};o.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},o.slicedToArray=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var i=function(){for(var e=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-1];return e.dbg.apply(e,[i.op].concat(r)),t.utils.resolve()},u=function(){for(var e=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-2];return e.dbg.apply(e,[i.op].concat(r)),t.utils.resolve()},a=function(e){var t={},n=[];return e.forEach(function(e){e in t||(n.push(e),t[e]=0)}),n},s=function(e,n){return t.utils.omit(n,e.relationFields||[])},f={debug:!1,raw:!1},l=["orderBy","sort","limit","offset","skip","where"];n.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(n.prototype,{afterCount:u,afterCreate:u,afterCreateMany:u,afterDestroy:u,afterDestroyAll:u,afterFind:u,afterFindAll:u,afterSum:u,afterUpdate:u,afterUpdateAll:u,afterUpdateMany:u,beforeCount:i,beforeCreate:i,beforeCreateMany:i,beforeDestroy:i,beforeDestroyAll:i,beforeFind:i,beforeFindAll:i,beforeSum:i,beforeUpdate:i,beforeUpdateAll:i,beforeUpdateMany:i,dbg:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},count:function(e,n,i){var u=this,a=void 0;return n||(n={}),i||(i={}),a=i.op="beforeCount",t.utils.resolve(u[a](e,n,i)).then(function(){return a=i.op="count",u.dbg(a,e,n,i),t.utils.resolve(u._count(e,n,i))}).then(function(s){var f=o.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new r(l,c,a);return d=u.respond(d,i),a=i.op="afterCount",t.utils.resolve(u[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},create:function(e,n,i){var u=this,a=void 0;return n||(n={}),i||(i={}),a=i.op="beforeCreate",t.utils.resolve(u[a](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=s(e,n),a=i.op="create",u.dbg(a,e,n,i),t.utils.resolve(u._create(e,n,i))}).then(function(s){var f=o.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new r(l,c,"create");return d.created=l?1:0,d=u.respond(d,i),a=i.op="afterCreate",t.utils.resolve(u[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},createMany:function(e,n,i){var u=this,a=void 0;return n||(n={}),i||(i={}),a=i.op="beforeCreateMany",t.utils.resolve(u[a](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),a=i.op="createMany",u.dbg(a,e,n,i),t.utils.resolve(u._createMany(e,n,i))}).then(function(s){var f=o.slicedToArray(s,2),l=f[0],c=f[1];l||(l=[]),c||(c={});var d=new r(l,c,"createMany");return d.created=l.length,d=u.respond(d,i),a=i.op="afterCreateMany",t.utils.resolve(u[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroy:function(e,n,i){var u=this,a=void 0;return i||(i={}),a=i.op="beforeDestroy",t.utils.resolve(u[a](e,n,i)).then(function(){return a=i.op="destroy",u.dbg(a,e,n,i),t.utils.resolve(u._destroy(e,n,i))}).then(function(s){var f=o.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new r(l,c,"destroy");return d=u.respond(d,i),a=i.op="afterDestroy",t.utils.resolve(u[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroyAll:function(e,n,i){var u=this,a=void 0;return n||(n={}),i||(i={}),a=i.op="beforeDestroyAll",t.utils.resolve(u[a](e,n,i)).then(function(){return a=i.op="destroyAll",u.dbg(a,e,n,i),t.utils.resolve(u._destroyAll(e,n,i))}).then(function(s){var f=o.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new r(l,c,"destroyAll");return d=u.respond(d,i),a=i.op="afterDestroyAll",t.utils.resolve(u[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},loadBelongsTo:function(e,n,r,i){var u=this,a=n.getRelation();if(!t.utils.isObject(r)||t.utils.isArray(r)){var s=r.map(function(t){return u.makeBelongsToForeignKey(e,n,t)}).filter(function(e){return e});return u.findAll(a,{where:o.defineProperty({},a.idAttribute,{in:s})},i).then(function(e){r.forEach(function(t){e.forEach(function(e){e[a.idAttribute]===t[n.foreignKey]&&n.setLocalField(t,e)})})})}var f=function(){var t=r;return{v:u.find(a,u.makeBelongsToForeignKey(e,n,t),i).then(function(e){n.setLocalField(t,e)})}}();return"object"===("undefined"==typeof f?"undefined":o.typeof(f))?f.v:void 0},find:function(e,n,i){var u=this,a=void 0,s=void 0;return i||(i={}),i.with||(i.with=[]),s=i.op="beforeFind",t.utils.resolve(u[s](e,n,i)).then(function(){return s=i.op="find",u.dbg(s,e,n,i),t.utils.resolve(u._find(e,n,i))}).then(function(n){var r=o.slicedToArray(n,1),s=r[0];if(s){a=s;var f=[];return t.utils.forEachRelation(e,i,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=u.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=u.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=u.loadBelongsTo(e,t,a,n)):r="hasOne"===t.type?u.loadHasOne(e,t,a,n):u.loadHasMany(e,t,a,n),r&&f.push(r)}),Promise.all(f)}}).then(function(){var o=new r(a,{},"find");return o.found=a?1:0,o=u.respond(o,i),s=i.op="afterFind",t.utils.resolve(u[s](e,n,i,o)).then(function(e){return t.utils.isUndefined(e)?o:e})})},findAll:function(e,n,i){var u=this;i||(i={}),i.with||(i.with=[]);var a=[],s=void 0,f=i._activeWith;if(t.utils.isObject(f)){var l=f.query||{};f.replace?n=l:t.utils.deepFillIn(n,l)}return s=i.op="beforeFindAll",t.utils.resolve(u[s](e,n,i)).then(function(){return s=i.op="findAll",u.dbg(s,e,n,i),t.utils.resolve(u._findAll(e,n,i))}).then(function(n){var r=o.slicedToArray(n,1),s=r[0];s||(s=[]),a=s;var f=[];return t.utils.forEachRelation(e,i,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=u.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=u.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=u.loadBelongsTo(e,t,a,n)):r="hasMany"===t.type?u.loadHasMany(e,t,a,n):u.loadHasOne(e,t,a,n),r&&f.push(r)}),Promise.all(f)}).then(function(){var o=new r(a,{},"findAll");return o.found=a.length,o=u.respond(o,i),s=i.op="afterFindAll",t.utils.resolve(u[s](e,n,i,o)).then(function(e){return t.utils.isUndefined(e)?o:e})})},getOpt:function(e,n){return n||(n={}),t.utils.isUndefined(n[e])?t.utils.plainCopy(this[e]):t.utils.plainCopy(n[e])},loadHasMany:function(e,n,r,o){var i=this,u=!1;t.utils.isObject(r)&&!t.utils.isArray(r)&&(u=!0,r=[r]);var a=r.map(function(t){return i.makeHasManyForeignKey(e,n,t)}),s={where:{}},f=s.where[n.foreignKey]={};return u?f["=="]=a[0]:f.in=a.filter(function(e){return e}),i.findAll(n.getRelation(),s,o).then(function(o){r.forEach(function(r){var i=[];u?i=o:o.forEach(function(o){t.utils.get(o,n.foreignKey)===r[e.idAttribute]&&i.push(o)}),n.setLocalField(r,i)})})},loadHasManyLocalKeys:function(e,n,r,i){var u=this,s=void 0,f=n.getRelation();if(t.utils.isObject(r)&&!t.utils.isArray(r)&&(s=r),s)return u.findAll(f,{where:o.defineProperty({},f.idAttribute,{in:u.makeHasManyLocalKeys(e,n,s)})},i).then(function(e){n.setLocalField(s,e)});var l=function(){var s=[];return r.forEach(function(t){s=s.concat(u.self.makeHasManyLocalKeys(e,n,t))}),{v:u.findAll(f,{where:o.defineProperty({},f.idAttribute,{in:a(s).filter(function(e){return e})})},i).then(function(e){return r.forEach(function(r){var o=[],i=t.utils.get(r,n.localKeys)||[];i=t.utils.isArray(i)?i:Object.keys(i),e.forEach(function(e){i&&-1!==i.indexOf(e[f.idAttribute])&&o.push(e)}),n.setLocalField(r,o)}),e})}}();return"object"===("undefined"==typeof l?"undefined":o.typeof(l))?l.v:void 0},loadHasManyForeignKeys:function(e,n,r,i){var u=this,a=n.getRelation(),s=e.idAttribute,f=void 0;return t.utils.isObject(r)&&!t.utils.isArray(r)&&(f=r),f?u.findAll(n.getRelation(),{where:o.defineProperty({},n.foreignKeys,{contains:u.makeHasManyForeignKeys(e,n,f)})},i).then(function(e){n.setLocalField(f,e)}):u.findAll(a,{where:o.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(t){return u.makeHasManyForeignKeys(e,n,t)})})},i).then(function(e){var o=n.foreignKeys;r.forEach(function(r){var i=[],u=t.utils.get(r,s);e.forEach(function(n){var r=t.utils.get(e,o)||[];-1!==r.indexOf(u)&&i.push(n)}),n.setLocalField(r,i)})})},loadHasOne:function(e,n,r,o){return t.utils.isObject(r)&&!t.utils.isArray(r)&&(r=[r]),this.loadHasMany(e,n,r,o).then(function(){r.forEach(function(e){var r=n.getLocalField(e);t.utils.isArray(r)&&r.length&&n.setLocalField(e,r[0])})})},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var o=e.toUpperCase()+": (Adapter)";if(console[e]){var i;(i=console)[e].apply(i,[o].concat(n))}else{var u;(u=console).log.apply(u,[o].concat(n))}}},makeHasManyForeignKey:function(e,t,n){return t.getForeignKey(n)},makeHasManyLocalKeys:function(e,n,r){var o=[],i=t.utils.get(r,n.localKeys)||[];return i=t.utils.isArray(i)?i:Object.keys(i),o=o.concat(i),a(o).filter(function(e){return e})},makeHasManyForeignKeys:function(e,n,r){return t.utils.get(r,e.idAttribute)},makeBelongsToForeignKey:function(e,t,n){return t.getForeignKey(n)},sum:function(e,n,i,u){var a=this,s=void 0;if(!t.utils.isString(n))throw new Error("field must be a string!");return i||(i={}),u||(u={}),s=u.op="beforeSum",t.utils.resolve(a[s](e,n,i,u)).then(function(){return s=u.op="sum",a.dbg(s,e,n,i,u),t.utils.resolve(a._sum(e,n,i,u))}).then(function(f){var l=o.slicedToArray(f,2),c=l[0],d=l[1];d||(d={});var p=new r(c,d,s);return p=a.respond(p,u),s=u.op="afterSum",t.utils.resolve(a[s](e,n,i,u,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},respond:function(e,t){return this.getOpt("raw",t)?e:e.data},update:function(e,n,i,u){var a=this;i||(i={}),u||(u={});var f=void 0;return f=u.op="beforeUpdate",t.utils.resolve(a[f](e,n,i,u)).then(function(r){return i=t.utils.isUndefined(r)?i:r,i=s(e,i),f=u.op="update",a.dbg(f,e,n,i,u),t.utils.resolve(a._update(e,n,i,u))}).then(function(s){var l=o.slicedToArray(s,2),c=l[0],d=l[1];d||(d={});var p=new r(c,d,"update");return p.updated=c?1:0,p=a.respond(p,u),f=u.op="afterUpdate",t.utils.resolve(a[f](e,n,i,u,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateAll:function(e,n,i,u){var a=this;n||(n={}),i||(i={}),u||(u={});var f=void 0;return f=u.op="beforeUpdateAll",t.utils.resolve(a[f](e,n,i,u)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=s(e,n),f=u.op="updateAll",a.dbg(f,e,n,i,u),t.utils.resolve(a._updateAll(e,n,i,u))}).then(function(s){var l=o.slicedToArray(s,2),c=l[0],d=l[1];c||(c=[]),d||(d={});var p=new r(c,d,"updateAll");return p.updated=c.length,p=a.respond(p,u),f=u.op="afterUpdateAll",t.utils.resolve(a[f](e,n,i,u,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateMany:function(e,n,i){var u=this;n||(n=[]),i||(i={});var a=void 0,f=e.idAttribute;return n=n.filter(function(e){return t.utils.get(e,f)}),a=i.op="beforeUpdateMany",t.utils.resolve(u[a](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),a=i.op="updateMany",u.dbg(a,e,n,i),t.utils.resolve(u._updateMany(e,n,i))}).then(function(s){var f=o.slicedToArray(s,2),l=f[0],c=f[1];l||(l=[]),c||(c={});var d=new r(l,c,"updateMany");return d.updated=l.length,d=u.respond(d,i),a=i.op="afterUpdateMany",t.utils.resolve(u[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})}}),e.noop=i,e.noop2=u,e.unique=a,e.withoutRelations=s,e.Adapter=n,e.reserved=l,e.Response=r})},function(e,t,n){e.exports=n(4)},function(e,t,n){"use strict";function r(e){this.defaults=i.merge({},e),this.interceptors={request:new a,response:new a}}var o=n(5),i=n(6),u=n(7),a=n(17),s=n(18),f=n(19),l=n(20),c=n(12);r.prototype.request=function(e){"string"==typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),e=i.merge(o,this.defaults,{method:"get"},e),e.baseURL&&!s(e.url)&&(e.url=f(e.baseURL,e.url)),e.withCredentials=e.withCredentials||this.defaults.withCredentials,e.data=c(e.data,e.headers,e.transformRequest),e.headers=i.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),i.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=[u,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n};var d=new r(o),p=e.exports=l(r.prototype.request,d);p.defaults=d.defaults,p.interceptors=d.interceptors,p.create=function(e){return new r(e)},p.all=function(e){return Promise.all(e)},p.spread=n(21),i.forEach(["delete","get","head"],function(e){r.prototype[e]=function(t,n){return this.request(i.merge(n||{},{method:e,url:t}))},p[e]=l(r.prototype[e],d)}),i.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(i.merge(r||{},{method:e,url:t,data:n}))},p[e]=l(r.prototype[e],d)})},function(e,t,n){"use strict";var r=n(6),o=/^\)\]\}',?\n/,i={"Content-Type":"application/x-www-form-urlencoded"};e.exports={transformRequest:[function(e,t){return r.isFormData(e)||r.isArrayBuffer(e)||r.isStream(e)?e:r.isArrayBufferView(e)?e.buffer:!r.isObject(e)||r.isFile(e)||r.isBlob(e)?e:(r.isUndefined(t)||(r.forEach(t,function(e,n){"content-type"===n.toLowerCase()&&(t["Content-Type"]=e)}),r.isUndefined(t["Content-Type"])&&(t["Content-Type"]="application/json;charset=utf-8")),JSON.stringify(e))}],transformResponse:[function(e){if("string"==typeof e){e=e.replace(o,"");try{e=JSON.parse(e)}catch(e){}}return e}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:r.merge(i),post:r.merge(i),put:r.merge(i)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&300>e}}},function(e,t){"use strict";function n(e){return"[object Array]"===b.call(e)}function r(e){return"[object ArrayBuffer]"===b.call(e)}function o(e){return"[object FormData]"===b.call(e)}function i(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function u(e){return"string"==typeof e}function a(e){return"number"==typeof e}function s(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function l(e){return"[object Date]"===b.call(e)}function c(e){return"[object File]"===b.call(e)}function d(e){return"[object Blob]"===b.call(e)}function p(e){return"[object Function]"===b.call(e)}function h(e){return f(e)&&p(e.pipe)}function y(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function v(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function m(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||n(e)||(e=[e]),n(e))for(var r=0,o=e.length;o>r;r++)t.call(null,e[r],r,e);else for(var i in e)e.hasOwnProperty(i)&&t.call(null,e[i],i,e)}function g(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=g(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;r>n;n++)m(arguments[n],e);return t}var b=Object.prototype.toString;e.exports={isArray:n,isArrayBuffer:r,isFormData:o,isArrayBufferView:i,isString:u,isNumber:a,isObject:f,isUndefined:s,isDate:l,isFile:c,isBlob:d,isFunction:p,isStream:h,isStandardBrowserEnv:v,forEach:m,merge:g,trim:y}},function(e,t,n){(function(t){"use strict";e.exports=function(e){return new Promise(function(r,o){try{var i;"function"==typeof e.adapter?i=e.adapter:"undefined"!=typeof XMLHttpRequest?i=n(9):"undefined"!=typeof t&&(i=n(9)),"function"==typeof i&&i(r,o,e)}catch(e){o(e)}})}}).call(t,n(8))},function(e,t){function n(){f=!1,u.length?s=u.concat(s):l=-1,s.length&&r()}function r(){if(!f){var e=setTimeout(n);f=!0;for(var t=s.length;t;){for(u=s,s=[];++l1)for(var n=1;n>8-a%1*8)){if(r=i.charCodeAt(a+=.75),r>255)throw new n;t=t<<8|r}return u}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t){"use strict";e.exports=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(n):e(n)}},function(e,t,n){"use strict";var r=n(6);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,i,u){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),u===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(6);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,"")}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;rn;n++)t[n]=arguments[n];var r=a(t,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function s(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,"]")}function f(e,n){if(!n)return e;var r=[];return t.utils.forOwn(n,function(e,n){null!==e&&"undefined"!=typeof e&&(t.utils.isArray(e)||(e=[e]),e.forEach(function(e){"[object Date]"===window.toString.call(e)?e=e.toISOString():t.utils.isObject(e)&&(e=t.utils.toJson(e)),r.push(s(n)+"="+s(e))}))}),r.length>0&&(e+=(-1===e.indexOf("?")?"?":"&")+r.join("&")),e}function l(e){var n=this;e||(e={}),t.utils.fillIn(e,E),r.call(n,e)}function c(e,n){if(!e||!t.utils.isString(e))throw new TypeError("action(name[, opts]): Expected: string, Found: "+("undefined"==typeof e?"undefined":h.typeof(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,i){var o=this;t.utils.isObject(r)&&(i=r),i=i||{};var a=o.getAdapter(n.adapter||o.defaultAdapter||"http"),s={};if(t.utils.fillIn(s,n),!i.hasOwnProperty("endpoint")&&s.endpoint&&(i.endpoint=s.endpoint),"function"==typeof i.getEndpoint)s.url=i.getEndpoint(o,i);else{var f=[i.basePath||o.basePath||a.basePath,a.getEndpoint(o,t.utils.isSorN(r)?r:null,i)];t.utils.isSorN(r)&&f.push(r),f.push(n.pathname||e),s.url=u.apply(null,f)}return s.method=s.method||"GET",s.mapper=o.name,t.utils.deepMixIn(s,i),t.utils.resolve(s).then(i.request||n.request).then(function(e){return a.HTTP(e)}).then(function(e){return e&&e.config&&(e.config.mapper=o.name),e}).then(i.response||n.response,i.responseError||n.responseError)},r}}function d(e){return e||(e={}),function(n){return t.utils.forOwn(e,function(e,t){c(t,e)(n)}),n}}var p="undefined"!=typeof window?window:"undefined"!=typeof global?global:this,h={};h.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},h.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},h.slicedToArray=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&u.return&&u.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var y=n(function(e,t,n){!function(n,r){"object"==typeof t&&"object"==typeof e?e.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof t?t.axios=r():n.axios=r()}(p,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){function r(e){this.defaults=o.merge({},e),this.interceptors={request:new u,response:new u}}var i=n(2),o=n(3),a=n(4),u=n(13),s=n(14),f=n(15),l=n(16),c=n(8);r.prototype.request=function(e){"string"==typeof e&&(e=o.merge({url:arguments[0]},arguments[1])),e=o.merge(i,this.defaults,{method:"get"},e),e.baseURL&&!s(e.url)&&(e.url=f(e.baseURL,e.url)),e.withCredentials=e.withCredentials||this.defaults.withCredentials,e.data=c(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=[a,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n};var d=new r(i),p=e.exports=l(r.prototype.request,d);e.exports.Axios=r,p.defaults=d.defaults,p.interceptors=d.interceptors,p.create=function(e){return new r(e)},p.all=function(e){return Promise.all(e)},p.spread=n(17),o.forEach(["delete","get","head"],function(e){r.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))},p[e]=l(r.prototype[e],d)}),o.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))},p[e]=l(r.prototype[e],d)})},function(e,t,n){var r=n(3),i=/^\)\]\}',?\n/,o={"Content-Type":"application/x-www-form-urlencoded"};e.exports={transformRequest:[function(e,t){return r.isFormData(e)||r.isArrayBuffer(e)||r.isStream(e)?e:r.isArrayBufferView(e)?e.buffer:!r.isObject(e)||r.isFile(e)||r.isBlob(e)?e:(r.isUndefined(t)||(r.forEach(t,function(e,n){"content-type"===n.toLowerCase()&&(t["Content-Type"]=e)}),r.isUndefined(t["Content-Type"])&&(t["Content-Type"]="application/json;charset=utf-8")),JSON.stringify(e))}],transformResponse:[function(e){if("string"==typeof e){e=e.replace(i,"");try{e=JSON.parse(e)}catch(e){}}return e}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:r.merge(o),post:r.merge(o),put:r.merge(o)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&300>e}}},function(e,t){function n(e){return"[object Array]"===b.call(e)}function r(e){return"[object ArrayBuffer]"===b.call(e)}function i(e){return"undefined"!=typeof FormData&&e instanceof FormData}function o(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function a(e){return"string"==typeof e}function u(e){return"number"==typeof e}function s(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function l(e){return"[object Date]"===b.call(e)}function c(e){return"[object File]"===b.call(e)}function d(e){return"[object Blob]"===b.call(e)}function p(e){return"[object Function]"===b.call(e)}function h(e){return f(e)&&p(e.pipe)}function y(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function v(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function m(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||n(e)||(e=[e]),n(e))for(var r=0,i=e.length;i>r;r++)t.call(null,e[r],r,e);else for(var o in e)e.hasOwnProperty(o)&&t.call(null,e[o],o,e)}function g(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=g(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;r>n;n++)m(arguments[n],e);return t}var b=Object.prototype.toString;e.exports={isArray:n,isArrayBuffer:r,isFormData:i,isArrayBufferView:o,isString:a,isNumber:u,isObject:f,isUndefined:s,isDate:l,isFile:c,isBlob:d,isFunction:p,isStream:h,isStandardBrowserEnv:v,forEach:m,merge:g,trim:y}},function(e,t,n){e.exports=function(e){return new Promise(function(t,r){try{var i;"function"==typeof e.adapter?i=e.adapter:"undefined"!=typeof XMLHttpRequest?i=n(5):"undefined"!=typeof process&&(i=n(5)),"function"==typeof i&&i(t,r,e)}catch(e){r(e)}})}},function(e,t,n){var r=n(3),i=n(6),o=n(7),a=n(8),u=n(9),s="undefined"!=typeof window&&window.btoa||n(10),f=n(11);e.exports=function(e,t,l){var c=l.data,d=l.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(l.url)||(p=new window.XDomainRequest,h="onload",y=!0,p.onprogress=function(){},p.ontimeout=function(){}),l.auth){var v=l.auth.username||"",m=l.auth.password||"";d.Authorization="Basic "+s(v+":"+m)}if(p.open(l.method.toUpperCase(),i(l.url,l.params,l.paramsSerializer),!0),p.timeout=l.timeout,p[h]=function(){if(p&&(4===p.readyState||y)&&0!==p.status){var n="getAllResponseHeaders"in p?o(p.getAllResponseHeaders()):null,r=l.responseType&&"text"!==l.responseType?p.response:p.responseText,i={data:a(r,n,l.transformResponse),status:1223===p.status?204:p.status,statusText:1223===p.status?"No Content":p.statusText,headers:n,config:l,request:p};f(e,t,i),p=null}},p.onerror=function(){t(new Error("Network Error")),p=null},p.ontimeout=function(){var e=new Error("timeout of "+l.timeout+"ms exceeded");e.timeout=l.timeout,e.code="ECONNABORTED",t(e),p=null},r.isStandardBrowserEnv()){var g=n(12),b=l.withCredentials||u(l.url)?g.read(l.xsrfCookieName):void 0;b&&(d[l.xsrfHeaderName]=b)}if("setRequestHeader"in p&&r.forEach(d,function(e,t){"undefined"==typeof c&&"content-type"===t.toLowerCase()?delete d[t]:p.setRequestHeader(t,e)}),l.withCredentials&&(p.withCredentials=!0),l.responseType)try{p.responseType=l.responseType}catch(e){if("json"!==p.responseType)throw e}l.progress&&("post"===l.method||"put"===l.method?p.upload.addEventListener("progress",l.progress):"get"===l.method&&p.addEventListener("progress",l.progress)),void 0===c&&(c=null),p.send(c)}},function(e,t,n){function r(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 i=n(3);e.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else{var a=[];i.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(i.isArray(e)&&(t+="[]"),i.isArray(e)||(e=[e]),i.forEach(e,function(e){i.isDate(e)?e=e.toISOString():i.isObject(e)&&(e=JSON.stringify(e)),a.push(r(t)+"="+r(e))}))}),o=a.join("&")}return o&&(e+=(-1===e.indexOf("?")?"?":"&")+o),e}},function(e,t,n){var r=n(3);e.exports=function(e){var t,n,i,o={};return e?(r.forEach(e.split("\n"),function(e){i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t&&(o[t]=o[t]?o[t]+", "+n:n)}),o):o}},function(e,t,n){var r=n(3);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){var r=n(3);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(i.setAttribute("href",t),t=i.href),i.setAttribute("href",t),{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 t,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");return t=e(window.location.href),function(n){var i=r.isString(n)?e(n):n;return i.protocol===t.protocol&&i.host===t.host}}():function(){return function(){return!0}}()},function(e,t){function n(){this.message="String contains an invalid character"}function r(e){for(var t,r,o=String(e),a="",u=0,s=i;o.charAt(0|u)||(s="=",u%1);a+=s.charAt(63&t>>8-u%1*8)){if(r=o.charCodeAt(u+=.75),r>255)throw new n;t=t<<8|r}return a}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t){e.exports=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(n):e(n)}},function(e,t,n){var r=n(3);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,i,o,a){var u=[];u.push(e+"="+encodeURIComponent(t)),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(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){function r(){this.handlers=[]}var i=n(3);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){i.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t){e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){e.exports=function(e,t){return e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,"")}},function(e,t){e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;ri;i++)r[i]=arguments[i];var o=r[r.length-1];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},g=function(){for(var e=this,n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r[r.length-2];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},b=function(e){var t={},n=[];return e.forEach(function(e){e in t||(n.push(e),t[e]=0)}),n},w=function(e,n){return t.utils.omit(n,e.relationFields||[])},A={debug:!1,raw:!1};r.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(r.prototype,{afterCount:g,afterCreate:g,afterCreateMany:g,afterDestroy:g,afterDestroyAll:g,afterFind:g,afterFindAll:g,afterSum:g,afterUpdate:g,afterUpdateAll:g,afterUpdateMany:g,beforeCount:m,beforeCreate:m,beforeCreateMany:m,beforeDestroy:m,beforeDestroyAll:m,beforeFind:m,beforeFindAll:m,beforeSum:m,beforeUpdate:m,beforeUpdateAll:m,beforeUpdateMany:m,dbg:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},count:function(e,n,r){var o=this,a=void 0;return n||(n={}),r||(r={}),a=r.op="beforeCount",t.utils.resolve(o[a](e,n,r)).then(function(){return a=r.op="count",o.dbg(a,e,n,r),t.utils.resolve(o._count(e,n,r))}).then(function(u){var s=h.slicedToArray(u,2),f=s[0],l=s[1];l||(l={});var c=new i(f,l,a);return c=o.respond(c,r),a=r.op="afterCount",t.utils.resolve(o[a](e,n,r,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},create:function(e,n,r){var o=this,a=void 0;return n||(n={}),r||(r={}),a=r.op="beforeCreate",t.utils.resolve(o[a](e,n,r)).then(function(i){return n=t.utils.isUndefined(i)?n:i,n=w(e,n),a=r.op="create",o.dbg(a,e,n,r),t.utils.resolve(o._create(e,n,r))}).then(function(u){var s=h.slicedToArray(u,2),f=s[0],l=s[1];l||(l={});var c=new i(f,l,"create");return c.created=f?1:0,c=o.respond(c,r),a=r.op="afterCreate",t.utils.resolve(o[a](e,n,r,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},createMany:function(e,n,r){var o=this,a=void 0;return n||(n={}),r||(r={}),a=r.op="beforeCreateMany",t.utils.resolve(o[a](e,n,r)).then(function(i){return n=t.utils.isUndefined(i)?n:i,n=n.map(function(t){return w(e,t)}),a=r.op="createMany",o.dbg(a,e,n,r),t.utils.resolve(o._createMany(e,n,r))}).then(function(u){var s=h.slicedToArray(u,2),f=s[0],l=s[1];f||(f=[]),l||(l={});var c=new i(f,l,"createMany");return c.created=f.length,c=o.respond(c,r),a=r.op="afterCreateMany",t.utils.resolve(o[a](e,n,r,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},destroy:function(e,n,r){var o=this,a=void 0;return r||(r={}),a=r.op="beforeDestroy",t.utils.resolve(o[a](e,n,r)).then(function(){return a=r.op="destroy",o.dbg(a,e,n,r),t.utils.resolve(o._destroy(e,n,r))}).then(function(u){var s=h.slicedToArray(u,2),f=s[0],l=s[1];l||(l={});var c=new i(f,l,"destroy");return c=o.respond(c,r),a=r.op="afterDestroy",t.utils.resolve(o[a](e,n,r,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},destroyAll:function(e,n,r){var o=this,a=void 0;return n||(n={}),r||(r={}),a=r.op="beforeDestroyAll",t.utils.resolve(o[a](e,n,r)).then(function(){return a=r.op="destroyAll",o.dbg(a,e,n,r),t.utils.resolve(o._destroyAll(e,n,r))}).then(function(u){var s=h.slicedToArray(u,2),f=s[0],l=s[1];l||(l={});var c=new i(f,l,"destroyAll");return c=o.respond(c,r),a=r.op="afterDestroyAll",t.utils.resolve(o[a](e,n,r,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},loadBelongsTo:function(e,n,r,i){var o=this,a=n.getRelation();if(!t.utils.isObject(r)||t.utils.isArray(r)){var u=r.map(function(t){return o.makeBelongsToForeignKey(e,n,t)}).filter(function(e){return e});return o.findAll(a,{where:h.defineProperty({},a.idAttribute,{in:u})},i).then(function(e){r.forEach(function(t){e.forEach(function(e){e[a.idAttribute]===t[n.foreignKey]&&n.setLocalField(t,e)})})})}var s=function(){var t=r;return{v:o.find(a,o.makeBelongsToForeignKey(e,n,t),i).then(function(e){n.setLocalField(t,e)})}}();return"object"===("undefined"==typeof s?"undefined":h.typeof(s))?s.v:void 0},find:function(e,n,r){var o=this,a=void 0,u=void 0;return r||(r={}),r.with||(r.with=[]),u=r.op="beforeFind",t.utils.resolve(o[u](e,n,r)).then(function(){return u=r.op="find",o.dbg(u,e,n,r),t.utils.resolve(o._find(e,n,r))}).then(function(n){var i=h.slicedToArray(n,1),u=i[0];if(u){a=u;var s=[];return t.utils.forEachRelation(e,r,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=o.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=o.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=o.loadBelongsTo(e,t,a,n)):r="hasOne"===t.type?o.loadHasOne(e,t,a,n):o.loadHasMany(e,t,a,n),r&&s.push(r)}),Promise.all(s)}}).then(function(){var s=new i(a,{},"find");return s.found=a?1:0,s=o.respond(s,r),u=r.op="afterFind",t.utils.resolve(o[u](e,n,r,s)).then(function(e){return t.utils.isUndefined(e)?s:e})})},findAll:function(e,n,r){var o=this;r||(r={}),r.with||(r.with=[]);var a=[],u=void 0,s=r._activeWith;if(t.utils.isObject(s)){var f=s.query||{};s.replace?n=f:t.utils.deepFillIn(n,f)}return u=r.op="beforeFindAll",t.utils.resolve(o[u](e,n,r)).then(function(){return u=r.op="findAll",o.dbg(u,e,n,r),t.utils.resolve(o._findAll(e,n,r))}).then(function(n){var i=h.slicedToArray(n,1),u=i[0];u||(u=[]),a=u;var s=[];return t.utils.forEachRelation(e,r,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=o.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=o.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=o.loadBelongsTo(e,t,a,n)):r="hasMany"===t.type?o.loadHasMany(e,t,a,n):o.loadHasOne(e,t,a,n),r&&s.push(r)}),Promise.all(s)}).then(function(){var s=new i(a,{},"findAll");return s.found=a.length,s=o.respond(s,r),u=r.op="afterFindAll",t.utils.resolve(o[u](e,n,r,s)).then(function(e){return t.utils.isUndefined(e)?s:e})})},getOpt:function(e,n){return n||(n={}),t.utils.isUndefined(n[e])?t.utils.plainCopy(this[e]):t.utils.plainCopy(n[e])},loadHasMany:function(e,n,r,i){var o=this,a=!1;t.utils.isObject(r)&&!t.utils.isArray(r)&&(a=!0,r=[r]);var u=r.map(function(t){return o.makeHasManyForeignKey(e,n,t)}),s={where:{}},f=s.where[n.foreignKey]={};return a?f["=="]=u[0]:f.in=u.filter(function(e){return e}),o.findAll(n.getRelation(),s,i).then(function(i){r.forEach(function(r){var o=[];a?o=i:i.forEach(function(i){t.utils.get(i,n.foreignKey)===r[e.idAttribute]&&o.push(i)}),n.setLocalField(r,o)})})},loadHasManyLocalKeys:function(e,n,r,i){var o=this,a=void 0,u=n.getRelation();if(t.utils.isObject(r)&&!t.utils.isArray(r)&&(a=r),a)return o.findAll(u,{where:h.defineProperty({},u.idAttribute,{in:o.makeHasManyLocalKeys(e,n,a)})},i).then(function(e){n.setLocalField(a,e)});var s=function(){var a=[];return r.forEach(function(t){a=a.concat(o.self.makeHasManyLocalKeys(e,n,t))}),{v:o.findAll(u,{where:h.defineProperty({},u.idAttribute,{in:b(a).filter(function(e){return e})})},i).then(function(e){return r.forEach(function(r){var i=[],o=t.utils.get(r,n.localKeys)||[];o=t.utils.isArray(o)?o:Object.keys(o),e.forEach(function(e){o&&-1!==o.indexOf(e[u.idAttribute])&&i.push(e)}),n.setLocalField(r,i)}),e})}}();return"object"===("undefined"==typeof s?"undefined":h.typeof(s))?s.v:void 0},loadHasManyForeignKeys:function(e,n,r,i){var o=this,a=n.getRelation(),u=e.idAttribute,s=void 0;return t.utils.isObject(r)&&!t.utils.isArray(r)&&(s=r),s?o.findAll(n.getRelation(),{where:h.defineProperty({},n.foreignKeys,{contains:o.makeHasManyForeignKeys(e,n,s)})},i).then(function(e){n.setLocalField(s,e)}):o.findAll(a,{where:h.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(t){return o.makeHasManyForeignKeys(e,n,t)})})},i).then(function(e){var i=n.foreignKeys;r.forEach(function(r){var o=[],a=t.utils.get(r,u);e.forEach(function(n){var r=t.utils.get(e,i)||[];-1!==r.indexOf(a)&&o.push(n)}),n.setLocalField(r,o)})})},loadHasOne:function(e,n,r,i){return t.utils.isObject(r)&&!t.utils.isArray(r)&&(r=[r]),this.loadHasMany(e,n,r,i).then(function(){r.forEach(function(e){var r=n.getLocalField(e);t.utils.isArray(r)&&r.length&&n.setLocalField(e,r[0])})})},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var i=e.toUpperCase()+": (Adapter)";if(console[e]){var o;(o=console)[e].apply(o,[i].concat(n))}else{var a;(a=console).log.apply(a,[i].concat(n))}}},makeHasManyForeignKey:function(e,t,n){return t.getForeignKey(n)},makeHasManyLocalKeys:function(e,n,r){var i=[],o=t.utils.get(r,n.localKeys)||[];return o=t.utils.isArray(o)?o:Object.keys(o),i=i.concat(o),b(i).filter(function(e){return e})},makeHasManyForeignKeys:function(e,n,r){return t.utils.get(r,e.idAttribute)},makeBelongsToForeignKey:function(e,t,n){return t.getForeignKey(n)},sum:function(e,n,r,o){var a=this,u=void 0;if(!t.utils.isString(n))throw new Error("field must be a string!");return r||(r={}),o||(o={}),u=o.op="beforeSum",t.utils.resolve(a[u](e,n,r,o)).then(function(){return u=o.op="sum",a.dbg(u,e,n,r,o),t.utils.resolve(a._sum(e,n,r,o))}).then(function(s){var f=h.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new i(l,c,u);return d=a.respond(d,o),u=o.op="afterSum",t.utils.resolve(a[u](e,n,r,o,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},respond:function(e,t){return this.getOpt("raw",t)?e:e.data},update:function(e,n,r,o){var a=this;r||(r={}),o||(o={});var u=void 0;return u=o.op="beforeUpdate",t.utils.resolve(a[u](e,n,r,o)).then(function(i){return r=t.utils.isUndefined(i)?r:i,r=w(e,r),u=o.op="update",a.dbg(u,e,n,r,o),t.utils.resolve(a._update(e,n,r,o))}).then(function(s){var f=h.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new i(l,c,"update");return d.updated=l?1:0,d=a.respond(d,o),u=o.op="afterUpdate",t.utils.resolve(a[u](e,n,r,o,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},updateAll:function(e,n,r,o){var a=this;n||(n={}),r||(r={}),o||(o={});var u=void 0;return u=o.op="beforeUpdateAll",t.utils.resolve(a[u](e,n,r,o)).then(function(i){return n=t.utils.isUndefined(i)?n:i,n=w(e,n),u=o.op="updateAll",a.dbg(u,e,n,r,o),t.utils.resolve(a._updateAll(e,n,r,o))}).then(function(s){var f=h.slicedToArray(s,2),l=f[0],c=f[1];l||(l=[]),c||(c={});var d=new i(l,c,"updateAll");return d.updated=l.length,d=a.respond(d,o),u=o.op="afterUpdateAll",t.utils.resolve(a[u](e,n,r,o,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},updateMany:function(e,n,r){var o=this;n||(n=[]),r||(r={});var a=void 0,u=e.idAttribute;return n=n.filter(function(e){return t.utils.get(e,u)}),a=r.op="beforeUpdateMany",t.utils.resolve(o[a](e,n,r)).then(function(i){return n=t.utils.isUndefined(i)?n:i,n=n.map(function(t){return w(e,t)}),a=r.op="updateMany",o.dbg(a,e,n,r),t.utils.resolve(o._updateMany(e,n,r))}).then(function(u){var s=h.slicedToArray(u,2),f=s[0],l=s[1];f||(f=[]),l||(l={});var c=new i(f,l,"updateMany");return c.updated=f.length,c=o.respond(c,r),a=r.op="afterUpdateMany",t.utils.resolve(o[a](e,n,r,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})}});var T=!1;try{T=window&&window.fetch}catch(e){}var x=r.prototype,E={basePath:"",forceTrailingSlash:!1,http:v,httpConfig:{},suffix:"",useFetch:!1};l.prototype=Object.create(r.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(l,"__super__",{configurable:!0,value:r}),l.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(l.prototype,{afterDEL:g,afterGET:g,afterHTTP:g,afterPOST:g,afterPUT:g,beforeDEL:m,beforeGET:m,beforeHTTP:m,beforePOST:m,beforePUT:m,_count:function(e,t,n){var r=this;return r.GET(r.getPath("count",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_create:function(e,t,n){var r=this;return r.POST(r.getPath("create",e,t,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_createMany:function(e,t,n){var r=this;return r.POST(r.getPath("createMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroy:function(e,t,n){var r=this;return r.DEL(r.getPath("destroy",e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroyAll:function(e,t,n){var r=this;return r.DEL(r.getPath("destroyAll",e,null,n),n).then(function(t){return r._end(e,n,t)})},_end:function(e,t,n){return[this.deserialize(e,n,t),n]},_find:function(e,t,n){var r=this;return r.GET(r.getPath("find",e,t,n),n).then(function(t){return r._end(e,n,t)})},_findAll:function(e,t,n){var r=this;return r.GET(r.getPath("findAll",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_sum:function(e,t,n,r){var i=this;return i.GET(i.getPath("sum",e,r.params,r),r).then(function(t){return i._end(e,r,t)})},_update:function(e,t,n,r){var i=this;return i.PUT(i.getPath("update",e,t,r),i.serialize(e,n,r),r).then(function(t){return i._end(e,r,t)})},_updateAll:function(e,t,n,r){var i=this;return i.PUT(i.getPath("updateAll",e,null,r),i.serialize(e,t,r),r).then(function(t){return i._end(e,r,t)})},_updateMany:function(e,t,n){var r=this;return r.PUT(r.getPath("updateMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},count:function(e,n,r){var i=this;return n||(n={}),r||(r={}),r.params=i.getParams(r),r.params.count=!0,r.suffix=i.getSuffix(e,r),t.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),x.count.call(i,e,n,r)},create:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),x.create.call(r,e,t,n)},createMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),x.createMany.call(r,e,t,n)},DEL:function(e,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.method=n.method||"delete",o=r.op="beforeDEL",t.utils.resolve(i[o](e,n,r)).then(function(a){return n=t.utils.isUndefined(a)?n:a,o=r.op="DEL",i.dbg(o,e,n,r),i.HTTP(n,r)}).then(function(a){return o=r.op="afterDEL",t.utils.resolve(i[o](e,n,r,a)).then(function(e){return t.utils.isUndefined(e)?a:e})})},deserialize:function(e,n,r){return r||(r={}),t.utils.isFunction(r.deserialize)?r.deserialize(e,n,r):t.utils.isFunction(e.deserialize)?e.deserialize(e,n,r):n&&n.hasOwnProperty("data")?n.data:n},destroy:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),x.destroy.call(r,e,t,n)},destroyAll:function(e,n,r){var i=this;return n||(n={}),r||(r={}),r.params=i.getParams(r),t.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),x.destroyAll.call(i,e,n,r)},error:function(){if(console){var e;(e=console)["function"==typeof console.error?"error":"log"].apply(e,arguments)}},fetch:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,n){var r={method:e.method,headers:new Headers(e.headers)};return e.data&&(r.body=t.utils.toJson(e.data)),fetch(new Request(f(e.url,e.params),r)).then(function(t){return t.config={method:e.method,url:e.url},t.json().then(function(e){return t.data=e,t})})}),find:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),x.find.call(r,e,t,n)},findAll:function(e,n,r){var i=this;return n||(n={}),r||(r={}),r.params=i.getParams(r),r.suffix=i.getSuffix(e,r),t.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),x.findAll.call(i,e,n,r)},GET:function(e,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.method=n.method||"get",o=r.op="beforeGET",t.utils.resolve(i[o](e,n,r)).then(function(a){return n=t.utils.isUndefined(a)?n:a,o=r.op="GET",i.dbg(o,e,n,r),i.HTTP(n,r)}).then(function(a){return o=r.op="afterGET",t.utils.resolve(i[o](e,n,r,a)).then(function(e){return t.utils.isUndefined(e)?a:e})})},getEndpoint:function(e,n,r){var i=this;r||(r={}),r.params=t.utils.isUndefined(r.params)?{}:r.params;var o=e.relationList||[],a=t.utils.isUndefined(r.endpoint)?t.utils.isUndefined(e.endpoint)?e.name:e.endpoint:r.endpoint;return o.forEach(function(e){if("belongsTo"===e.type&&e.parent){var o=void 0,s=e.foreignKey,f=e.getRelation(),l=r.params[s];if(l===!1||!s||!f)return l===!1&&delete r.params[s],!1;if(delete r.params[s],t.utils.isObject(n)&&(o=n),o&&(l=l||e.getForeignKey(o)||(e.getLocalField(o)?t.utils.get(e.getLocalField(o),f.idAttribute):null)),l){var c=function(){delete r.endpoint;var e={};return t.utils.forOwn(r,function(t,n){e[n]=t}),t.utils._(e,f),a=u(i.getEndpoint(f,l,e),l,a),{v:!1}}();if("object"===("undefined"==typeof c?"undefined":h.typeof(c)))return c.v}}}),a},getPath:function(e,n,r,i){var o=this;i||(i={});var a=[t.utils.isUndefined(i.basePath)?t.utils.isUndefined(n.basePath)?o.basePath:n.basePath:i.basePath,o.getEndpoint(n,t.utils.isString(r)||t.utils.isNumber(r)||"create"===e?r:null,i)];return"find"!==e&&"update"!==e&&"destroy"!==e||a.push(r),u.apply(t.utils,a)},getParams:function(e){return e||(e={}),t.utils.isUndefined(e.params)?{}:t.utils.copy(e.params)},getSuffix:function(e,n){return n||(n={}),t.utils.isUndefined(n.suffix)?t.utils.isUndefined(e.suffix)?this.suffix:e.suffix:n.suffix},HTTP:function(e,n){function r(n){var r=o.toUTCString()+" - "+e.method.toUpperCase()+" "+e.url+" - "+n.status+" "+((new Date).getTime()-o.getTime())+"ms";return n.status>=200&&n.status<300?(i.log&&i.dbg("debug",r,n),n):(i.error&&i.error("'FAILED: "+r,n),t.utils.reject(n))}var i=this,o=new Date;n||(n={});var a=e.data,u=e.cache,s=e.timeout;e=t.utils.copy(e,null,null,null,["data","cache","timeout"]),e=t.utils.deepMixIn(e,i.httpConfig),e.data=a,e.cache=u,e.timeout=s,i.forceTrailingSlash&&"/"!==e.url[e.url.length-1]&&(e.url+="/"),e.method=e.method.toUpperCase();var f=e.suffix||n.suffix||i.suffix;if(f&&e.url.substr(e.url.length-f.length)!==f&&(e.url+=f),!i.http)throw new Error("You have not configured this adapter with an http library!");return t.utils.resolve(i.beforeHTTP(e,n)).then(function(t){return e=t||e,T&&(i.useFetch||n.useFetch||!i.http)?i.fetch(e,n).then(r,r):i.http(e).then(r,r).catch(function(t){return i.responseError(t,e,n)})}).then(function(r){return t.utils.resolve(i.afterHTTP(e,n,r)).then(function(e){return e||r})})},POST:function(e,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=e||r.url,r.data=n||r.data,r.method=r.method||"post",a=i.op="beforePOST",t.utils.resolve(o[a](e,n,r,i)).then(function(u){return r=t.utils.isUndefined(u)?r:u,a=i.op="POST",o.dbg(a,e,n,r,i),o.HTTP(r,i)}).then(function(u){return a=i.op="afterPOST",t.utils.resolve(o[a](e,n,r,i,u)).then(function(e){return t.utils.isUndefined(e)?u:e})})},PUT:function(e,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=e||r.url,r.data=n||r.data,r.method=r.method||"put",a=i.op="beforePUT",t.utils.resolve(o[a](e,n,r,i)).then(function(u){return r=t.utils.isUndefined(u)?r:u, +a=i.op="PUT",o.dbg(a,e,n,r,i),o.HTTP(r,i)}).then(function(u){return a=i.op="afterPUT",t.utils.resolve(o[a](e,n,r,i,u)).then(function(e){return t.utils.isUndefined(e)?u:e})})},queryTransform:function(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(e,n,r){return t.utils.reject(e)},serialize:function(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(e,n,r,i){var o=this;if(r||(r={}),i||(i={}),!t.utils.utils.isString(n))throw new Error("field must be a string!");return i.params=o.getParams(i),i.params.sum=n,i.suffix=o.getSuffix(e,i),t.utils.deepMixIn(i.params,r),i.params=o.queryTransform(e,i.params,i),x.sum.call(o,e,n,r,i)},update:function(e,t,n,r){var i=this;return r||(r={}),r.params=i.getParams(r),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),x.update.call(i,e,t,n,r)},updateAll:function(e,n,r,i){var o=this;return r||(r={}),i||(i={}),i.params=o.getParams(i),t.utils.deepMixIn(i.params,r),i.params=o.queryTransform(e,i.params,i),i.suffix=o.getSuffix(e,i),x.updateAll.call(o,e,n,r,i)},updateMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),x.updateMany.call(r,e,t,n)}});var P={beta:6,full:"3.0.0-beta.6",major:3,minor:0,patch:0};e.HttpAdapter=l,e.addAction=c,e.addActions=d,e.version=P}); //# sourceMappingURL=js-data-http.min.map \ No newline at end of file diff --git a/dist/js-data-http.min.map b/dist/js-data-http.min.map index b553c53..8e90b07 100644 --- a/dist/js-data-http.min.map +++ b/dist/js-data-http.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-http.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","_jsData","utils","forOwn","key","isArray","forEach","v","window","toString","toISOString","isObject","toJson","push","indexOf","HttpAdapter","opts","self","fillIn","DEFAULTS","_jsDataAdapter","Adapter","_typeof","Symbol","iterator","obj","constructor","axios","hasFetch","fetch","e","__super__","prototype","basePath","forceTrailingSlash","http","httpConfig","suffix","useFetch","Object","create","enumerable","writable","configurable","defineProperty","extend","addHiddenPropsToTarget","afterDEL","noop2","afterGET","afterHTTP","afterPOST","afterPUT","beforeDEL","noop","beforeGET","beforeHTTP","beforePOST","beforePUT","_count","mapper","query","GET","getPath","then","response","_end","_create","props","POST","serialize","_createMany","_destroy","DEL","_destroyAll","deserialize","_find","_findAll","_sum","field","_update","PUT","_updateAll","_updateMany","records","count","getParams","getSuffix","deepMixIn","queryTransform","createMany","config","op","method","resolve","_config","isUndefined","dbg","HTTP","_response","isFunction","hasOwnProperty","data","destroy","destroyAll","error","console","_console","apply","_fetch","_x","_x2","requestConfig","headers","Headers","body","Request","json","find","findAll","getEndpoint","relationList","endpoint","name","def","type","parent","item","parentKey","foreignKey","parentDef","getRelation","parentId","getForeignKey","getLocalField","get","idAttribute","_ret","_opts","_","isString","isNumber","copy","logResponse","str","start","toUTCString","toUpperCase","status","Date","getTime","log","reject","payload","cache","timeout","substr","Error","catch","err","responseError","sum","update","updateAll","updateMany","addAction","TypeError","request","adapter","getAdapter","defaultAdapter","isSorN","pathname","addActions","version","beta","full","major","minor","patch","default","global","jsData","Response","meta","babelHelpers","typeof","slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","next","done","concat","_len2","_key2","unique","array","seen","final","withoutRelations","omit","relationFields","debug","raw","reserved","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","results","_results","respond","_props","_results2","created","map","record","_results3","_results4","_results5","loadBelongsTo","__opts","relationDef","keys","makeBelongsToForeignKey","where","in","relatedItems","relatedItem","setLocalField","with","_results6","_record","tasks","forEachRelation","task","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","Promise","all","found","activeWith","_activeWith","activeQuery","deepFillIn","_results7","_records","getOpt","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","attached","relatedMapper","makeHasManyLocalKeys","_ret2","x","itemKeys","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","level","_len4","_key4","prefix","_console2","_results8","_results9","updated","_results10","_results11","Axios","defaultConfig","defaults","merge","interceptors","InterceptorManager","dispatchRequest","isAbsoluteURL","combineURLs","bind","transformData","baseURL","withCredentials","transformRequest","common","chain","promise","interceptor","unshift","fulfilled","rejected","shift","defaultInstance","promises","spread","PROTECTION_PREFIX","DEFAULT_CONTENT_TYPE","Content-Type","isFormData","isArrayBuffer","isStream","isArrayBufferView","buffer","isFile","isBlob","toLowerCase","JSON","stringify","transformResponse","parse","Accept","post","put","xsrfCookieName","xsrfHeaderName","maxContentLength","validateStatus","ArrayBuffer","isView","isDate","pipe","trim","isStandardBrowserEnv","document","createElement","fn","l","assignValue","process","XMLHttpRequest","cleanUpNextTick","draining","currentQueue","queue","queueIndex","drainQueue","setTimeout","len","run","clearTimeout","Item","fun","nextTick","title","browser","env","argv","versions","on","addListener","once","off","removeListener","removeAllListeners","emit","binding","cwd","chdir","dir","umask","buildURL","parseHeaders","isURLSameOrigin","btoa","settle","requestData","requestHeaders","loadEvent","xDomain","NODE_ENV","XDomainRequest","auth","username","password","Authorization","open","paramsSerializer","onprogress","ontimeout","readyState","responseHeaders","getAllResponseHeaders","responseData","responseType","responseText","statusText","onerror","code","cookies","xsrfValue","read","setRequestHeader","progress","upload","addEventListener","send","serializedParams","parsed","split","line","fns","resolveURL","href","msie","urlParsingNode","setAttribute","protocol","host","search","hash","hostname","port","charAt","originURL","test","navigator","userAgent","location","requestURL","E","message","input","block","charCode","String","output","idx","chars","charCodeAt","write","expires","path","domain","secure","cookie","toGMTString","match","RegExp","decodeURIComponent","remove","now","handlers","use","eject","h","relativeURL","thisArg","callback"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAAoB,WAAID,EAAQG,QAAQ,YAExCJ,EAAiB,WAAIC,EAAQD,EAAa,SACzCO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAmBA,SAASS,GAAcC,GACrB,MAAgB,OAATA,GAA2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sources":["dist/js-data-http.js"],"names":["global","factory","exports","module","require","define","amd","JSDataHttp","JSData","this","jsData","__commonjs","fn","__commonjs_global","Adapter","opts","self","utils","fillIn","DEFAULTS$1","Response","data","meta","op","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","isArray","forEach","v","window","toString","call","toISOString","isObject","toJson","push","indexOf","HttpAdapter","DEFAULTS","addAction","name","isString","TypeError","babelHelpers","typeof","mapper","Error","request","config","response","responseError","err","reject","id","_opts","adapter","getAdapter","defaultAdapter","hasOwnProperty","endpoint","getEndpoint","basePath","isSorN","pathname","apply","method","deepMixIn","resolve","then","HTTP","addActions","Symbol","iterator","obj","constructor","defineProperty","Object","enumerable","configurable","writable","slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","next","done","axios","root","modules","__webpack_require__","moduleId","installedModules","loaded","m","c","p","Axios","defaultConfig","defaults","merge","interceptors","InterceptorManager","dispatchRequest","isAbsoluteURL","combineURLs","bind","transformData","prototype","baseURL","withCredentials","headers","transformRequest","common","chain","promise","Promise","interceptor","unshift","fulfilled","rejected","shift","defaultInstance","create","all","promises","spread","PROTECTION_PREFIX","DEFAULT_CONTENT_TYPE","Content-Type","isFormData","isArrayBuffer","isStream","isArrayBufferView","buffer","isFile","isBlob","isUndefined","toLowerCase","JSON","stringify","transformResponse","parse","e","Accept","patch","post","put","timeout","xsrfCookieName","xsrfHeaderName","maxContentLength","validateStatus","status","FormData","ArrayBuffer","isView","isNumber","isDate","isFunction","pipe","trim","str","isStandardBrowserEnv","document","createElement","l","assignValue","XMLHttpRequest","process","buildURL","parseHeaders","isURLSameOrigin","btoa","settle","requestData","requestHeaders","loadEvent","xDomain","XDomainRequest","onprogress","ontimeout","auth","username","password","Authorization","open","toUpperCase","paramsSerializer","readyState","responseHeaders","getAllResponseHeaders","responseData","responseType","responseText","statusText","onerror","code","cookies","xsrfValue","read","setRequestHeader","progress","upload","addEventListener","send","serializedParams","parsed","split","line","substr","fns","resolveURL","href","msie","urlParsingNode","setAttribute","protocol","host","search","hash","hostname","port","charAt","originURL","test","navigator","userAgent","location","requestURL","E","message","input","block","charCode","String","output","idx","map","chars","charCodeAt","write","expires","path","domain","secure","cookie","Date","toGMTString","match","RegExp","decodeURIComponent","remove","now","handlers","use","eject","h","relativeURL","thisArg","callback","axios$1","noop","dbg","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","props","omit","relationFields","debug","raw","extend","addHiddenPropsToTarget","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","log","count","query","_count","results","_results","respond","_response","_props","_create","_results2","created","createMany","record","_createMany","_results3","destroy","_destroy","_results4","destroyAll","_destroyAll","_results5","loadBelongsTo","def","records","__opts","relationDef","getRelation","keys","makeBelongsToForeignKey","findAll","where","idAttribute","in","relatedItems","relatedItem","foreignKey","setLocalField","_ret","find","with","_find","_results6","_record","tasks","forEachRelation","task","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","found","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_results7","_records","getOpt","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","attached","get","relatedMapper","makeHasManyLocalKeys","_ret2","x","itemKeys","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","level","_len4","_key4","prefix","console","_console","_console2","getForeignKey","sum","field","_sum","_results8","update","_update","_results9","updated","updateAll","_updateAll","_results10","updateMany","_updateMany","_results11","hasFetch","fetch","__super__","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","error","_fetch","_x","_x2","requestConfig","Headers","body","Request","json","relationList","parent","parentKey","parentDef","parentId","_","copy","logResponse","start","toUTCString","getTime","payload","cache","catch","version","beta","full","major","minor"],"mappings":"CAAC,SAAUA,EAAQC,GACC,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,QAASE,QAAQ,YACtE,kBAAXC,SAAyBA,OAAOC,IAAMD,OAAO,gBAAiB,UAAW,WAAYJ,GAC3FA,EAASD,EAAOO,WAAaP,EAAOO,eAAkBP,EAAOQ,SAC7DC,KAAM,SAAUP,EAAQQ,GAAU,YAGnC,SAASC,GAAWC,EAAIT,GAAU,MAAOA,IAAWD,YAAeU,EAAGT,EAAQA,EAAOD,QAASW,GAAoBV,EAAOD,QAy1CzH,QAASY,GAAQC,GACf,GAAIC,GAAOP,IACXM,KAASA,MACTL,EAAOO,MAAMC,OAAOH,EAAMI,GAC1BT,EAAOO,MAAMC,OAAOF,EAAMD,GAS5B,QAASK,GAASC,EAAMC,EAAMC,GAC5B,GAAIP,GAAOP,IACXa,KAASA,MAQTN,EAAKK,KAAOA,EAEZX,EAAOO,MAAMC,OAAOF,EAAMM,GAQ1BN,EAAKO,GAAKA,EA87CZ,QAASC,GAAcC,GACrB,MAAgB,OAATA,GAA2B,KAAVA,EAE1B,QAASC,GAAKC,EAAOC,GAEnB,MADAA,KAAcA,EAAY,IACnBD,EAAME,OAAOL,GAAeE,KAAKE,GAE1C,QAASE,KACP,IAAK,GAAIC,GAAOC,UAAUC,OAAQC,EAAOC,MAAMJ,GAAOK,EAAO,EAAUL,EAAPK,EAAaA,IAC3EF,EAAKE,GAAQJ,UAAUI,EAGzB,IAAIC,GAASX,EAAKQ,EAAM,IACxB,OAAOG,GAAOC,QAAQ,oBAAqB,OAG7C,QAASC,GAAOC,GACd,MAAOC,oBAAmBD,GAAKF,QAAQ,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AM,eACNC,MAAO,EACPC,MAAO,EACPlU,MAAO,EAgCR3K,GAAQyD,YAAcA,EACtBzD,EAAQ2D,UAAYA,EACpB3D,EAAQ0F,WAAaA,EACrB1F,EAAQye,QAAUA","file":"dist/js-data-http.min.js"} \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.js b/fetch/dist/js-data-fetch.js index da746a5..abfa923 100644 --- a/fetch/dist/js-data-fetch.js +++ b/fetch/dist/js-data-fetch.js @@ -1,3024 +1,2927 @@ /*! * js-data-fetch -* @version 3.0.0-beta.5 - Homepage +* @version 3.0.0-beta.6 - Homepage * @copyright (c) 2014-2016 js-data-http project authors * @license MIT * * @overview HTTP adapter for js-data that uses the fetch API. */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("js-data"), require("undefined")); - else if(typeof define === 'function' && define.amd) - define(["js-data", "undefined"], factory); - else if(typeof exports === 'object') - exports["JSDataHttp"] = factory(require("js-data"), require("undefined")); - else - root["JSDataHttp"] = factory(root["JSData"], root["undefined"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_3__) { -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__) { - - '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; }; - - var _jsData = __webpack_require__(1); - - var _jsDataAdapter = __webpack_require__(2); - - /* global fetch:true Headers:true Request:true */ - - var axios = __webpack_require__(3); - - - 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 (window.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 __super__ = _jsDataAdapter.Adapter.prototype; - - var DEFAULTS = { - // Default and user-defined settings - /** - * @name HttpAdapter#basePath - * @type {string} - */ - basePath: '', - - /** - * @name HttpAdapter#forceTrailingSlash - * @type {boolean} - * @default false - */ - forceTrailingSlash: false, - - /** - * @name HttpAdapter#http - * @type {Function} - */ - http: axios, - - /** - * @name HttpAdapter#httpConfig - * @type {Object} - */ - httpConfig: {}, - - /** - * @name HttpAdapter#suffix - * @type {string} - */ - suffix: '', - - /** - * @name HttpAdapter#useFetch - * @type {boolean} - * @default false - */ - useFetch: false - }; - - /** - * HttpAdapter class. - * - * @class HttpAdapter - * @extends Adapter - * @param {Object} [opts] Configuration options. - * @param {string} [opts.basePath=''] TODO - * @param {boolean} [opts.debug=false] TODO - * @param {boolean} [opts.forceTrailingSlash=false] TODO - * @param {Object} [opts.http=axios] TODO - * @param {Object} [opts.httpConfig={}] TODO - * @param {string} [opts.suffix=''] TODO - * @param {boolean} [opts.useFetch=false] TODO - */ - function HttpAdapter(opts) { - var self = this; - opts || (opts = {}); - _jsData.utils.fillIn(opts, DEFAULTS); - _jsDataAdapter.Adapter.call(self, opts); - } - - /** - * @name module:js-data-http.HttpAdapter - * @see HttpAdapter - */ - exports.HttpAdapter = HttpAdapter; - - // Setup prototype inheritance from Adapter - HttpAdapter.prototype = Object.create(_jsDataAdapter.Adapter.prototype, { - constructor: { - value: HttpAdapter, - enumerable: false, - writable: true, - configurable: true - } - }); - - Object.defineProperty(HttpAdapter, '__super__', { - configurable: true, - value: _jsDataAdapter.Adapter - }); - - /** - * Alternative to ES6 class syntax for extending `HttpAdapter`. - * - * @example Using the ES2015 class syntax. - * class MyHttpAdapter extends HttpAdapter {...} - * const adapter = new MyHttpAdapter() - * - * @example Using {@link HttpAdapter.extend}. - * var instanceProps = {...} - * var classProps = {...} - * - * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) - * var adapter = new MyHttpAdapter() - * - * @name HttpAdapter.extend - * @method - * @param {Object} [instanceProps] Properties that will be added to the - * prototype of the subclass. - * @param {Object} [classProps] Properties that will be added as static - * properties to the subclass itself. - * @return {Object} Subclass of `HttpAdapter`. - */ - HttpAdapter.extend = _jsData.utils.extend; - - _jsData.utils.addHiddenPropsToTarget(HttpAdapter.prototype, { - /** - * @name HttpAdapter#afterDEL - * @method - * @param {string} url - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterDEL: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#afterGET - * @method - * @param {string} url - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterGET: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#afterHTTP - * @method - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterHTTP: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#afterPOST - * @method - * @param {string} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterPOST: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#afterPUT - * @method - * @param {string} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterPUT: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#beforeDEL - * @method - * @param {Object} url - * @param {Object} config - * @param {Object} opts - */ - beforeDEL: _jsDataAdapter.noop, - - /** - * @name HttpAdapter#beforeGET - * @method - * @param {Object} url - * @param {Object} config - * @param {Object} opts - */ - beforeGET: _jsDataAdapter.noop, - - /** - * @name HttpAdapter#beforeHTTP - * @method - * @param {Object} config - * @param {Object} opts - */ - beforeHTTP: _jsDataAdapter.noop, - - /** - * @name HttpAdapter#beforePOST - * @method - * @param {Object} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - */ - beforePOST: _jsDataAdapter.noop, - - /** - * @name HttpAdapter#beforePUT - * @method - * @param {Object} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - */ - beforePUT: _jsDataAdapter.noop, - - _count: function _count(mapper, query, opts) { - var self = this; - return self.GET(self.getPath('count', mapper, opts.params, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _create: function _create(mapper, props, opts) { - var self = this; - return self.POST(self.getPath('create', mapper, props, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _createMany: function _createMany(mapper, props, opts) { - var self = this; - return self.POST(self.getPath('createMany', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _destroy: function _destroy(mapper, id, opts) { - var self = this; - return self.DEL(self.getPath('destroy', mapper, id, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _destroyAll: function _destroyAll(mapper, query, opts) { - var self = this; - return self.DEL(self.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _end: function _end(mapper, opts, response) { - return [this.deserialize(mapper, response, opts), response]; - }, - _find: function _find(mapper, id, opts) { - var self = this; - return self.GET(self.getPath('find', mapper, id, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _findAll: function _findAll(mapper, query, opts) { - var self = this; - return self.GET(self.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _sum: function _sum(mapper, field, query, opts) { - var self = this; - return self.GET(self.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _update: function _update(mapper, id, props, opts) { - var self = this; - return self.PUT(self.getPath('update', mapper, id, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _updateAll: function _updateAll(mapper, props, query, opts) { - var self = this; - return self.PUT(self.getPath('updateAll', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _updateMany: function _updateMany(mapper, records, opts) { - var self = this; - return self.PUT(self.getPath('updateMany', mapper, null, opts), self.serialize(mapper, records, opts), opts).then(function (response) { - return self._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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - count: function count(mapper, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params.count = true; - opts.suffix = self.getSuffix(mapper, opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - - return __super__.count.call(self, 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - create: function create(mapper, props, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.create.call(self, 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - createMany: function createMany(mapper, props, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.createMany.call(self, 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 self = 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(self[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'DEL'; - self.dbg(op, url, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterDEL lifecycle hook - op = opts.op = 'afterDEL'; - return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - destroy: function destroy(mapper, id, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.destroy.call(self, 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - destroyAll: function destroyAll(mapper, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - opts.params = self.getParams(opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.destroyAll.call(self, 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. - * @param {Object} [opts] Configuration options. - */ - fetch: function (_fetch) { - function fetch(_x, _x2) { - return _fetch.apply(this, arguments); - } - - fetch.toString = function () { - return _fetch.toString(); - }; - - return fetch; - }(function (config, opts) { - 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(new Request(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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - find: function find(mapper, id, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.find.call(self, 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - findAll: function findAll(mapper, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.suffix = self.getSuffix(mapper, opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - - return __super__.findAll.call(self, mapper, query, opts); - }, - - - /** - * TODO - * - * @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 self = 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(self[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'GET'; - self.dbg(op, url, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterGET lifecycle hook - op = opts.op = 'afterGET'; - return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - - /** - * @name HttpAdapter#getEndpoint - * @method - * @param {Object} mapper TODO - * @param {*} id TODO - * @param {boolean} opts TODO - * @return {string} Full path. - */ - getEndpoint: function getEndpoint(mapper, id, opts) { - var self = 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(self.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 TODO - * @param {Object} mapper TODO - * @param {(string|number)?} id TODO - * @param {Object} opts Configuration options. - */ - getPath: function getPath(method, mapper, id, opts) { - var self = this; - opts || (opts = {}); - var args = [_jsData.utils.isUndefined(opts.basePath) ? _jsData.utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath : opts.basePath, self.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 (_jsData.utils.isUndefined(opts.params)) { - return {}; - } - return _jsData.utils.copy(opts.params); - }, - getSuffix: function getSuffix(mapper, opts) { - opts || (opts = {}); - if (_jsData.utils.isUndefined(opts.suffix)) { - if (_jsData.utils.isUndefined(mapper.suffix)) { - 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 self = 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, self.httpConfig); - config.data = payload; - config.cache = cache; - config.timeout = timeout; - if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { - config.url += '/'; - } - config.method = config.method.toUpperCase(); - var suffix = config.suffix || opts.suffix || self.suffix; - if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { - config.url += suffix; - } - - 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 (self.log) { - self.dbg('debug', str, data); - } - return data; - } else { - if (self.error) { - self.error('\'FAILED: ' + str, data); - } - return _jsData.utils.reject(data); - } - } - - if (!self.http) { - throw new Error('You have not configured this adapter with an http library!'); - } - - return _jsData.utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { - config = _config || config; - if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { - return self.fetch(config, opts).then(logResponse, logResponse); - } - return self.http(config).then(logResponse, logResponse).catch(function (err) { - return self.responseError(err, config, opts); - }); - }).then(function (response) { - return _jsData.utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { - return _response || response; - }); - }); - }, - - - /** - * TODO - * - * @name HttpAdapter#POST - * @method - * @param {*} url TODO - * @param {Object} data TODO - * @param {Object} config TODO - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - POST: function POST(url, data, config, opts) { - var self = 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(self[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'POST'; - self.dbg(op, url, data, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterPOST lifecycle hook - op = opts.op = 'afterPOST'; - return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - - /** - * TODO - * - * @name HttpAdapter#PUT - * @method - * @param {*} url TODO - * @param {Object} data TODO - * @param {Object} config TODO - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - PUT: function PUT(url, data, config, opts) { - var self = 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(self[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'PUT'; - self.dbg(op, url, data, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterPUT lifecycle hook - op = opts.op = 'afterPUT'; - return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - - /** - * TODO - * - * @name HttpAdapter#queryTransform - * @method - * @param {Object} mapper TODO - * @param {*} params TODO - * @param {*} opts TODO - * @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); - }, - - - /** - * TODO - * - * @name HttpAdapter#serialize - * @method - * @param {Object} mapper TODO - * @param {Object} data TODO - * @param {*} opts TODO - * @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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - sum: function sum(mapper, field, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - if (!_jsData.utils.utils.isString(field)) { - throw new Error('field must be a string!'); - } - opts.params = self.getParams(opts); - opts.params.sum = field; - opts.suffix = self.getSuffix(mapper, opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - - return __super__.sum.call(self, mapper, field, query, opts); - }, - - - /** - * TODO - * - * @name HttpAdapter#update - * @method - * @param {Object} mapper TODO - * @param {*} id TODO - * @param {*} props TODO - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - update: function update(mapper, id, props, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.update.call(self, mapper, id, props, opts); - }, - - - /** - * TODO - * - * @name HttpAdapter#updateAll - * @method - * @param {Object} mapper TODO - * @param {Object} props TODO - * @param {Object} query TODO - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - updateAll: function updateAll(mapper, props, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - opts.params = self.getParams(opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.updateAll.call(self, mapper, props, query, opts); - }, - - - /** - * Update multiple records in batch. - * - * {@link HttpAdapter#beforeUpdateMany} will be called before calling - * {@link HttpAdapter#PUT}. - * {@link HttpAdapter#afterUpdateMany} will be called after calling - * {@link HttpAdapter#PUT}. - * - * @name HttpAdapter#updateMany - * @method - * @param {Object} mapper The mapper. - * @param {Array} records Array of property objects to send as the payload. - * @param {Object} [opts] Configuration options. - * @param {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - updateMany: function updateMany(mapper, records, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.updateMany.call(self, 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 adapter = new HttpAdapter() - * var store = new DataStore() - * - * store.registerAdapter('http', adapter, { default: true }) - * store.defineMapper('school') - * - * // GET /reports/schools/:school_id/teachers - * addAction('getTeacherReports', { - * basePath: 'reports/schools', - * pathname: 'teachers', - * method: 'GET' - * })(store.getMapper('school')) - * - * // /reports/schools/1234/teachers - * store.getMapper('school').getTeacherReports(1234).then(function (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] - * @param {string} [opts.pathname] - * @param {Function} [opts.request] - * @param {Function} [opts.response] - * @param {Function} [opts.responseError] - * @return {Function} Decoration function, which should be passed the mapper to - * decorate when invoked. - */ - exports.addAction = 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 self = this; - if (_jsData.utils.isObject(id)) { - _opts = id; - } - _opts = _opts || {}; - var adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http'); - var config = {}; - _jsData.utils.fillIn(config, opts); - if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { - _opts.endpoint = config.endpoint; - } - if (typeof _opts.getEndpoint === 'function') { - config.url = _opts.getEndpoint(self, _opts); - } else { - var args = [_opts.basePath || self.basePath || adapter.basePath, adapter.getEndpoint(self, _jsData.utils.isSorN(id) ? id : null, _opts)]; - if (_jsData.utils.isSorN(id)) { - args.push(id); - } - args.push(opts.pathname || name); - config.url = makePath.apply(null, args); - } - config.method = config.method || 'GET'; - config.mapper = self.name; - _jsData.utils.deepMixIn(config, _opts); - return _jsData.utils.resolve(config).then(_opts.request || opts.request).then(function (config) { - return adapter.HTTP(config); - }).then(function (data) { - if (data && data.config) { - data.config.mapper = self.name; - } - return data; - }).then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter() - * var store = new DataStore() - * - * store.registerAdapter('http', adapter, { 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(function (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. - */ - exports.addActions = function addActions(opts) { - opts || (opts = {}); - return function (mapper) { - _jsData.utils.forOwn(opts, function (value, key) { - exports.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. - */ - exports.version = { - beta: 5, - full: '3.0.0-beta.5', +(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 babelHelpers = {}; + babelHelpers.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; + }; + + babelHelpers.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; + }; + + babelHelpers.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"); + } + }; + }(); + + babelHelpers; + + var noop = function noop() { + var self = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + self.dbg.apply(self, [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) { + return jsData.utils.omit(props, mapper.relationFields || []); + }; + + 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 + * @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) { + var self = this; + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS$1); + jsData.utils.fillIn(self, opts); + } + + /** + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @class Response + */ + function Response(data, meta, op) { + var self = this; + meta || (meta = {}); + + /** + * Response data. + * + * @name Response#data + * @type {*} + */ + self.data = data; + + jsData.utils.fillIn(self, meta); + + /** + * The operation for which the response was created. + * + * @name Response#op + * @type {string} + */ + self.op = op; + } + + /** + * Alternative to ES6 class syntax for extending `Adapter`. + * + * @name Adapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `Adapter`. + */ + Adapter.extend = jsData.utils.extend; + + jsData.utils.addHiddenPropsToTarget(Adapter.prototype, { + /** + * 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, + + /** + * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`. + * + * @name Adapter#dbg + * @method + */ + dbg: function dbg() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + this.log.apply(this, ['debug'].concat(args)); + }, + + + /** + * 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 self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._count(mapper, query, opts)); + }).then(function (results) { + var _results = babelHelpers.slicedToArray(results, 2); + + var data = _results[0]; + var result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'create'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = babelHelpers.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 = self.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'createMany'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = babelHelpers.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 = self.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 self = this; + var op = void 0; + opts || (opts = {}); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = babelHelpers.slicedToArray(results, 2); + + var data = _results4[0]; + var result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = self.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = babelHelpers.slicedToArray(results, 2); + + var data = _results5[0]; + var result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = self.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo + * @method + * @return {Promise} + */ + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { + var self = this; + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var _ret = function () { + var record = records; + return { + v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }) + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; + } else { + var keys = records.map(function (record) { + return self.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return self.findAll(relationDef, { + where: babelHelpers.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 self = this; + var record = void 0, + op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._find(mapper, id, opts)); + }).then(function (results) { + var _results6 = babelHelpers.slicedToArray(results, 1); + + var _record = _results6[0]; + + if (!_record) { + return; + } + record = _record; + 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 = self.loadHasOne(mapper, def, record, __opts); + } else { + task = self.loadHasMany(mapper, def, record, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, record, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, record, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, record, __opts); + } + if (task) { + tasks.push(task); + } + }); + + return Promise.all(tasks); + }).then(function () { + var response = new Response(record, {}, 'find'); + response.found = record ? 1 : 0; + response = self.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 self = this; + opts || (opts = {}); + opts.with || (opts.with = []); + + var records = []; + 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(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._findAll(mapper, query, opts)); + }).then(function (results) { + var _results7 = babelHelpers.slicedToArray(results, 1); + + var _records = _results7[0]; + + _records || (_records = []); + records = _records; + 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 = self.loadHasMany(mapper, def, records, __opts); + } else { + task = self.loadHasOne(mapper, def, records, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } + }); + return Promise.all(tasks); + }).then(function () { + var response = new Response(records, {}, 'findAll'); + response.found = records.length; + response = self.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 jsData.utils.isUndefined(opts[opt]) ? 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 self = this; + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return self.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 self.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 self = this; + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': self.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(self.self.makeHasManyLocalKeys(mapper, def, record)); + }); + return { + v: self.findAll(relatedMapper, { + where: babelHelpers.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' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v; + } + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var self = 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 self.findAll(def.getRelation(), { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'contains': self.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return self.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]); + } + }); + }); + }, + + + /** + * Logging utility method. Override this method if you want to send log + * messages to something other than the console. + * + * @name Adapter#log + * @method + * @param {string} level Log level. + * @param {...*} values Values to log. + */ + log: function log(level) { + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + if (level && !args.length) { + args.push(level); + level = 'debug'; + } + if (level === 'debug' && !this.debug) { + return; + } + var prefix = level.toUpperCase() + ': (Adapter)'; + if (console[level]) { + var _console; + + (_console = console)[level].apply(_console, [prefix].concat(args)); + } else { + var _console2; + + (_console2 = console).log.apply(_console2, [prefix].concat(args)); + } + }, + + + /** + * 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 self = 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(self[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + self.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(self._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results8 = babelHelpers.slicedToArray(results, 2); + + var data = _results8[0]; + var result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 self = this; + props || (props = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'update'; + self.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(self._update(mapper, id, props, opts)); + }).then(function (results) { + var _results9 = babelHelpers.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 = self.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 self = this; + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'updateAll'; + self.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results10 = babelHelpers.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 = self.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 self = 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(self[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = jsData.utils.isUndefined(_records) ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'updateMany'; + self.dbg(op, mapper, records, opts); + return jsData.utils.resolve(self._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results11 = babelHelpers.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 = self.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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 (window.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 __super__ = Adapter.prototype; + + var DEFAULTS = { + // Default and user-defined settings + /** + * @name HttpAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + */ + forceTrailingSlash: false, + + /** + * @name HttpAdapter#http + * @type {Function} + */ + http: axios, + + /** + * @name HttpAdapter#httpConfig + * @type {Object} + */ + httpConfig: {}, + + /** + * @name HttpAdapter#suffix + * @type {string} + */ + suffix: '', + + /** + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + */ + useFetch: false + }; + + /** + * HttpAdapter class. + * + * @class HttpAdapter + * @extends Adapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.basePath=''] TODO + * @param {boolean} [opts.debug=false] TODO + * @param {boolean} [opts.forceTrailingSlash=false] TODO + * @param {Object} [opts.http=axios] TODO + * @param {Object} [opts.httpConfig={}] TODO + * @param {string} [opts.suffix=''] TODO + * @param {boolean} [opts.useFetch=false] TODO + */ + function HttpAdapter(opts) { + var self = this; + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS); + Adapter.call(self, opts); + } + + /** + * @name module:js-data-http.HttpAdapter + * @see HttpAdapter + */ + + // Setup prototype inheritance from Adapter + HttpAdapter.prototype = Object.create(Adapter.prototype, { + constructor: { + value: HttpAdapter, + enumerable: false, + writable: true, + configurable: true + } + }); + + Object.defineProperty(HttpAdapter, '__super__', { + configurable: true, + value: Adapter + }); + + /** + * Alternative to ES6 class syntax for extending `HttpAdapter`. + * + * @example Using the ES2015 class syntax. + * class MyHttpAdapter extends HttpAdapter {...} + * const adapter = new MyHttpAdapter() + * + * @example Using {@link HttpAdapter.extend}. + * var instanceProps = {...} + * var classProps = {...} + * + * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) + * var adapter = new MyHttpAdapter() + * + * @name HttpAdapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `HttpAdapter`. + */ + HttpAdapter.extend = jsData.utils.extend; + + jsData.utils.addHiddenPropsToTarget(HttpAdapter.prototype, { + /** + * @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 self = this; + return self.GET(self.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('create', mapper, props, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('createMany', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var self = this; + return self.DEL(self.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var self = this; + return self.DEL(self.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var self = this; + return self.GET(self.getPath('find', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var self = this; + return self.GET(self.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var self = this; + return self.PUT(self.getPath('update', mapper, id, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var self = this; + return self.PUT(self.getPath('updateAll', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var self = this; + return self.PUT(self.getPath('updateMany', mapper, null, opts), self.serialize(mapper, records, opts), opts).then(function (response) { + return self._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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params.count = true; + opts.suffix = self.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.count.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.create.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.createMany.call(self, 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 self = 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(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'DEL'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroy.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroyAll.call(self, 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. + * @param {Object} [opts] Configuration options. + */ + fetch: function (_fetch) { + function fetch(_x, _x2) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config, opts) { + 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(new Request(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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.find.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.suffix = self.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.findAll.call(self, mapper, query, opts); + }, + + + /** + * TODO + * + * @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 self = 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(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'GET'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {boolean} opts TODO + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var self = 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(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return { + v: false + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; + } + } + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method TODO + * @param {Object} mapper TODO + * @param {(string|number)?} id TODO + * @param {Object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + var self = this; + opts || (opts = {}); + var args = [jsData.utils.isUndefined(opts.basePath) ? jsData.utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath : opts.basePath, self.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 (jsData.utils.isUndefined(opts.params)) { + return {}; + } + return jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (jsData.utils.isUndefined(opts.suffix)) { + if (jsData.utils.isUndefined(mapper.suffix)) { + 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 self = 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, self.httpConfig); + config.data = payload; + config.cache = cache; + config.timeout = timeout; + if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || self.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + 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 (self.log) { + self.dbg('debug', str, data); + } + return data; + } else { + if (self.error) { + self.error('\'FAILED: ' + str, data); + } + return jsData.utils.reject(data); + } + } + + if (!self.http) { + throw new Error('You have not configured this adapter with an http library!'); + } + + return jsData.utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { + return self.fetch(config, opts).then(logResponse, logResponse); + } + return self.http(config).then(logResponse, logResponse).catch(function (err) { + return self.responseError(err, config, opts); + }); + }).then(function (response) { + return jsData.utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { + return _response || response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#POST + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var self = 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(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'POST'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#PUT + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var self = 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(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'PUT'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#queryTransform + * @method + * @param {Object} mapper TODO + * @param {*} params TODO + * @param {*} opts TODO + * @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); + }, + + + /** + * TODO + * + * @name HttpAdapter#serialize + * @method + * @param {Object} mapper TODO + * @param {Object} data TODO + * @param {*} opts TODO + * @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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + if (!jsData.utils.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = self.getParams(opts); + opts.params.sum = field; + opts.suffix = self.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.sum.call(self, mapper, field, query, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#update + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {*} props TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.update.call(self, mapper, id, props, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#updateAll + * @method + * @param {Object} mapper TODO + * @param {Object} props TODO + * @param {Object} query TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateAll.call(self, mapper, props, query, opts); + }, + + + /** + * Update multiple records in batch. + * + * {@link HttpAdapter#beforeUpdateMany} will be called before calling + * {@link HttpAdapter#PUT}. + * {@link HttpAdapter#afterUpdateMany} will be called after calling + * {@link HttpAdapter#PUT}. + * + * @name HttpAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} records Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateMany.call(self, 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 adapter = new HttpAdapter() + * var store = new DataStore() + * + * store.registerAdapter('http', adapter, { default: true }) + * store.defineMapper('school') + * + * // GET /reports/schools/:school_id/teachers + * addAction('getTeacherReports', { + * basePath: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * })(store.getMapper('school')) + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then(function (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] + * @param {string} [opts.pathname] + * @param {Function} [opts.request] + * @param {Function} [opts.response] + * @param {Function} [opts.responseError] + * @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' : babelHelpers.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 self = this; + if (jsData.utils.isObject(id)) { + _opts = id; + } + _opts = _opts || {}; + var adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http'); + var config = {}; + jsData.utils.fillIn(config, opts); + if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { + _opts.endpoint = config.endpoint; + } + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(self, _opts); + } else { + var args = [_opts.basePath || self.basePath || adapter.basePath, adapter.getEndpoint(self, jsData.utils.isSorN(id) ? id : null, _opts)]; + if (jsData.utils.isSorN(id)) { + args.push(id); + } + args.push(opts.pathname || name); + config.url = makePath.apply(null, args); + } + config.method = config.method || 'GET'; + config.mapper = self.name; + jsData.utils.deepMixIn(config, _opts); + return jsData.utils.resolve(config).then(_opts.request || opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = self.name; + } + return data; + }).then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter() + * var store = new DataStore() + * + * store.registerAdapter('http', adapter, { 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(function (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 = { + beta: 6, + full: '3.0.0-beta.6', 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 adapter = new HttpAdapter() - * - * @example CommonJS - * var HttpAdapter = require('js-data-Http').HttpAdapter - * var adapter = new HttpAdapter() - * - * @example ES2015 Modules - * import {HttpAdapter} from 'js-data-Http' - * const adapter = new HttpAdapter() - * - * @example AMD - * define('myApp', ['js-data-Http'], function (JSDataHttp) { - * var HttpAdapter = JSDataHttp.HttpAdapter - * var adapter = new HttpAdapter() - * - * // ... - * }) - * - * @module js-data-http - */ - exports.default = HttpAdapter; - -/***/ }, -/* 1 */ -/***/ function(module, exports) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_1__; - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - (function (global, factory) { - true ? factory(exports, __webpack_require__(1)) : - typeof define === 'function' && define.amd ? define('js-data-adapter', ['exports', 'js-data'], factory) : - (factory((global.Adapter = global.Adapter || {}),global.JSData)); - }(this, function (exports,jsData) { 'use strict'; - - var babelHelpers = {}; - babelHelpers.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; - }; - - babelHelpers.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; - }; - - babelHelpers.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"); - } - }; - }(); - - babelHelpers; - - var noop = function noop() { - var self = this; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var opts = args[args.length - 1]; - self.dbg.apply(self, [opts.op].concat(args)); - return jsData.utils.resolve(); - }; - - var noop2 = function noop2() { - var self = this; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - var opts = args[args.length - 2]; - self.dbg.apply(self, [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) { - return jsData.utils.omit(props, mapper.relationFields || []); - }; - - var DEFAULTS = { - /** - * 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 - * @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) { - var self = this; - opts || (opts = {}); - jsData.utils.fillIn(opts, DEFAULTS); - jsData.utils.fillIn(self, opts); - } - - var reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where']; - - /** - * Response object used when `raw` is `true`. May contain other fields in - * addition to `data`. - * - * @class Response - */ - function Response(data, meta, op) { - var self = this; - meta || (meta = {}); - - /** - * Response data. - * - * @name Response#data - * @type {*} - */ - self.data = data; - - jsData.utils.fillIn(self, meta); - - /** - * The operation for which the response was created. - * - * @name Response#op - * @type {string} - */ - self.op = op; - } - - /** - * Alternative to ES6 class syntax for extending `Adapter`. - * - * @name Adapter.extend - * @method - * @param {Object} [instanceProps] Properties that will be added to the - * prototype of the subclass. - * @param {Object} [classProps] Properties that will be added as static - * properties to the subclass itself. - * @return {Object} Subclass of `Adapter`. - */ - Adapter.extend = jsData.utils.extend; - - jsData.utils.addHiddenPropsToTarget(Adapter.prototype, { - /** - * 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, - - /** - * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`. - * - * @name Adapter#dbg - * @method - */ - dbg: function dbg() { - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - this.log.apply(this, ['debug'].concat(args)); - }, - - - /** - * 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 self = this; - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeCount lifecycle hook - op = opts.op = 'beforeCount'; - return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'count'; - self.dbg(op, mapper, query, opts); - return jsData.utils.resolve(self._count(mapper, query, opts)); - }).then(function (results) { - var _results = babelHelpers.slicedToArray(results, 2); - - var data = _results[0]; - var result = _results[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = self.respond(response, opts); - - // afterCount lifecycle hook - op = opts.op = 'afterCount'; - return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreate lifecycle hook - op = opts.op = 'beforeCreate'; - return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = withoutRelations(mapper, props); - op = opts.op = 'create'; - self.dbg(op, mapper, props, opts); - return jsData.utils.resolve(self._create(mapper, props, opts)); - }).then(function (results) { - var _results2 = babelHelpers.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 = self.respond(response, opts); - - // afterCreate lifecycle hook - op = opts.op = 'afterCreate'; - return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreateMany lifecycle hook - op = opts.op = 'beforeCreateMany'; - return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = props.map(function (record) { - return withoutRelations(mapper, record); - }); - op = opts.op = 'createMany'; - self.dbg(op, mapper, props, opts); - return jsData.utils.resolve(self._createMany(mapper, props, opts)); - }).then(function (results) { - var _results3 = babelHelpers.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 = self.respond(response, opts); - - // afterCreateMany lifecycle hook - op = opts.op = 'afterCreateMany'; - return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - opts || (opts = {}); - - // beforeDestroy lifecycle hook - op = opts.op = 'beforeDestroy'; - return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'destroy'; - self.dbg(op, mapper, id, opts); - return jsData.utils.resolve(self._destroy(mapper, id, opts)); - }).then(function (results) { - var _results4 = babelHelpers.slicedToArray(results, 2); - - var data = _results4[0]; - var result = _results4[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroy'); - response = self.respond(response, opts); - - // afterDestroy lifecycle hook - op = opts.op = 'afterDestroy'; - return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeDestroyAll lifecycle hook - op = opts.op = 'beforeDestroyAll'; - return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'destroyAll'; - self.dbg(op, mapper, query, opts); - return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); - }).then(function (results) { - var _results5 = babelHelpers.slicedToArray(results, 2); - - var data = _results5[0]; - var result = _results5[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroyAll'); - response = self.respond(response, opts); - - // afterDestroyAll lifecycle hook - op = opts.op = 'afterDestroyAll'; - return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - - /** - * Load a belongsTo relationship. - * - * Override with care. - * - * @name Adapter#loadBelongsTo - * @method - * @return {Promise} - */ - loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { - var self = this; - var relationDef = def.getRelation(); - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - var _ret = function () { - var record = records; - return { - v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { - def.setLocalField(record, relatedItem); - }) - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; - } else { - var keys = records.map(function (record) { - return self.makeBelongsToForeignKey(mapper, def, record); - }).filter(function (key) { - return key; - }); - return self.findAll(relationDef, { - where: babelHelpers.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 self = this; - var record = void 0, - op = void 0; - opts || (opts = {}); - opts.with || (opts.with = []); - - // beforeFind lifecycle hook - op = opts.op = 'beforeFind'; - return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'find'; - self.dbg(op, mapper, id, opts); - return jsData.utils.resolve(self._find(mapper, id, opts)); - }).then(function (results) { - var _results6 = babelHelpers.slicedToArray(results, 1); - - var _record = _results6[0]; - - if (!_record) { - return; - } - record = _record; - 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 = self.loadHasOne(mapper, def, record, __opts); - } else { - task = self.loadHasMany(mapper, def, record, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = self.loadHasManyLocalKeys(mapper, def, record, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = self.loadHasManyForeignKeys(mapper, def, record, __opts); - } else if (def.type === 'belongsTo') { - task = self.loadBelongsTo(mapper, def, record, __opts); - } - if (task) { - tasks.push(task); - } - }); - - return Promise.all(tasks); - }).then(function () { - var response = new Response(record, {}, 'find'); - response.found = record ? 1 : 0; - response = self.respond(response, opts); - - // afterFind lifecycle hook - op = opts.op = 'afterFind'; - return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - opts || (opts = {}); - opts.with || (opts.with = []); - - var records = []; - 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(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'findAll'; - self.dbg(op, mapper, query, opts); - return jsData.utils.resolve(self._findAll(mapper, query, opts)); - }).then(function (results) { - var _results7 = babelHelpers.slicedToArray(results, 1); - - var _records = _results7[0]; - - _records || (_records = []); - records = _records; - 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 = self.loadHasMany(mapper, def, records, __opts); - } else { - task = self.loadHasOne(mapper, def, records, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = self.loadHasManyLocalKeys(mapper, def, records, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = self.loadHasManyForeignKeys(mapper, def, records, __opts); - } else if (def.type === 'belongsTo') { - task = self.loadBelongsTo(mapper, def, records, __opts); - } - if (task) { - tasks.push(task); - } - }); - return Promise.all(tasks); - }).then(function () { - var response = new Response(records, {}, 'findAll'); - response.found = records.length; - response = self.respond(response, opts); - - // afterFindAll lifecycle hook - op = opts.op = 'afterFindAll'; - return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 jsData.utils.isUndefined(opts[opt]) ? 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 self = this; - var singular = false; - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - singular = true; - records = [records]; - } - var IDs = records.map(function (record) { - return self.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 self.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 self = this; - var record = void 0; - var relatedMapper = def.getRelation(); - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - record = records; - } - - if (record) { - return self.findAll(relatedMapper, { - where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { - 'in': self.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(self.self.makeHasManyLocalKeys(mapper, def, record)); - }); - return { - v: self.findAll(relatedMapper, { - where: babelHelpers.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' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v; - } - }, - loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { - var self = 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 self.findAll(def.getRelation(), { - where: babelHelpers.defineProperty({}, def.foreignKeys, { - 'contains': self.makeHasManyForeignKeys(mapper, def, record) - }) - }, __opts).then(function (relatedItems) { - def.setLocalField(record, relatedItems); - }); - } else { - return self.findAll(relatedMapper, { - where: babelHelpers.defineProperty({}, def.foreignKeys, { - 'isectNotEmpty': records.map(function (record) { - return self.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]); - } - }); - }); - }, - - - /** - * Logging utility method. Override this method if you want to send log - * messages to something other than the console. - * - * @name Adapter#log - * @method - * @param {string} level Log level. - * @param {...*} values Values to log. - */ - log: function log(level) { - for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { - args[_key4 - 1] = arguments[_key4]; - } - - if (level && !args.length) { - args.push(level); - level = 'debug'; - } - if (level === 'debug' && !this.debug) { - return; - } - var prefix = level.toUpperCase() + ': (Adapter)'; - if (console[level]) { - var _console; - - (_console = console)[level].apply(_console, [prefix].concat(args)); - } else { - var _console2; - - (_console2 = console).log.apply(_console2, [prefix].concat(args)); - } - }, - - - /** - * 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 self = 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(self[op](mapper, field, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'sum'; - self.dbg(op, mapper, field, query, opts); - return jsData.utils.resolve(self._sum(mapper, field, query, opts)); - }).then(function (results) { - var _results8 = babelHelpers.slicedToArray(results, 2); - - var data = _results8[0]; - var result = _results8[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = self.respond(response, opts); - - // afterSum lifecycle hook - op = opts.op = 'afterSum'; - return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - props || (props = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdate lifecycle hook - op = opts.op = 'beforeUpdate'; - return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = withoutRelations(mapper, props); - op = opts.op = 'update'; - self.dbg(op, mapper, id, props, opts); - return jsData.utils.resolve(self._update(mapper, id, props, opts)); - }).then(function (results) { - var _results9 = babelHelpers.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 = self.respond(response, opts); - - // afterUpdate lifecycle hook - op = opts.op = 'afterUpdate'; - return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - props || (props = {}); - query || (query = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdateAll lifecycle hook - op = opts.op = 'beforeUpdateAll'; - return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = withoutRelations(mapper, props); - op = opts.op = 'updateAll'; - self.dbg(op, mapper, props, query, opts); - return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); - }).then(function (results) { - var _results10 = babelHelpers.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 = self.respond(response, opts); - - // afterUpdateAll lifecycle hook - op = opts.op = 'afterUpdateAll'; - return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = 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(self[op](mapper, records, opts)).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = jsData.utils.isUndefined(_records) ? records : _records; - records = records.map(function (record) { - return withoutRelations(mapper, record); - }); - op = opts.op = 'updateMany'; - self.dbg(op, mapper, records, opts); - return jsData.utils.resolve(self._updateMany(mapper, records, opts)); - }).then(function (results) { - var _results11 = babelHelpers.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 = self.respond(response, opts); - - // afterUpdateMany lifecycle hook - op = opts.op = 'afterUpdateMany'; - return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - } - }); - - exports.noop = noop; - exports.noop2 = noop2; - exports.unique = unique; - exports.withoutRelations = withoutRelations; - exports.Adapter = Adapter; - exports.reserved = reserved; - exports.Response = Response; - - })); - //# sourceMappingURL=js-data-adapter.js.map - -/***/ }, -/* 3 */ -/***/ function(module, exports) { - - module.exports = undefined; - -/***/ } -/******/ ]) -}); -; + + /** + * 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 adapter = new HttpAdapter() + * + * @example CommonJS + * var HttpAdapter = require('js-data-Http').HttpAdapter + * var adapter = new HttpAdapter() + * + * @example ES2015 Modules + * import {HttpAdapter} from 'js-data-Http' + * const adapter = new HttpAdapter() + * + * @example AMD + * define('myApp', ['js-data-Http'], function (JSDataHttp) { + * var HttpAdapter = JSDataHttp.HttpAdapter + * var adapter = new HttpAdapter() + * + * // ... + * }) + * + * @module js-data-http + */ + + exports.HttpAdapter = HttpAdapter; + exports.addAction = addAction; + exports.addActions = addActions; + exports.version = version; + +})); //# sourceMappingURL=js-data-fetch.js.map \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.js.map b/fetch/dist/js-data-fetch.js.map index a1ab4e4..08589fb 100644 --- a/fetch/dist/js-data-fetch.js.map +++ b/fetch/dist/js-data-fetch.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap c15a7e72a42c303f269e","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/js-data-adapter/dist/js-data-adapter.js","webpack:///external \"undefined\""],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;ACnCA;;AACA;;;;AAFA,KAAM,QAAQ,oBAAQ,CAAR,CAAd;;;AAQA,KAAI,WAAW,KAAf;;AAEA,KAAI;AACF,cAAW,UAAU,OAAO,KAA5B;AACD,EAFD,CAEE,OAAO,CAAP,EAAU,CAAE;;AAEd,UAAS,aAAT,CAAwB,KAAxB,EAA+B;AAC7B,UAAQ,SAAS,IAAT,IAAiB,UAAU,EAAnC;AACD;AACD,UAAS,IAAT,CAAe,KAAf,EAAsB,SAAtB,EAAiC;AAC/B,iBAAc,YAAY,EAA1B;AACA,UAAO,MAAM,MAAN,CAAa,aAAb,EAA4B,IAA5B,CAAiC,SAAjC,CAAP;AACD;AACD,UAAS,QAAT,GAA4B;AAAA,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;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB,cAAa,QAAQ;AACrB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,uBAAsB;AACtB;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAsB;;AAEtB;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB;AACA,cAAa,OAAO;AACpB;AACA,eAAc,OAAO;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,6BAA6B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,8BAA8B,eAAe;AAC9E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,+BAA+B,eAAe;AAC7E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,gCAAgC,eAAe;AAChF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,iCAAiC,eAAe;AAC/E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAwE,eAAe;AACvF;AACA;;AAEA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA,QAAO;AACP,+CAA8C;AAC9C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,QAAO;AACP,gDAA+C;AAC/C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,iBAAgB,EAAE;AAClB;AACA;AACA,yBAAwB;AACxB;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA,oDAAmD;AACnD;AACA;AACA,kBAAiB;AACjB,gBAAe;AACf,cAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA,gBAAe;AACf;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA,gDAA+C;AAC/C;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,KAAK;AACpB;AACA;AACA,6FAA4F,eAAe;AAC3G;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,QAAO;AACP;;AAEA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;AACxB;AACA;;AAEA;AACA;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,EAAC;AACD,4C;;;;;;AC/mDA,4B","file":"./fetch/dist/js-data-fetch.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"js-data\"), require(\"undefined\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"js-data\", \"undefined\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"JSDataHttp\"] = factory(require(\"js-data\"), require(\"undefined\"));\n\telse\n\t\troot[\"JSDataHttp\"] = factory(root[\"JSData\"], root[\"undefined\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_3__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\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/** WEBPACK FOOTER **\n ** webpack/bootstrap c15a7e72a42c303f269e\n **/","/* global fetch:true Headers:true Request:true */\n\nconst axios = require('axios')\nimport {utils} from 'js-data'\nimport {\n Adapter,\n noop,\n noop2\n} from 'js-data-adapter'\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 (window.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 __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n // Default and user-defined settings\n /**\n * @name HttpAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n */\n forceTrailingSlash: false,\n\n /**\n * @name HttpAdapter#http\n * @type {Function}\n */\n http: axios,\n\n /**\n * @name HttpAdapter#httpConfig\n * @type {Object}\n */\n httpConfig: {},\n\n /**\n * @name HttpAdapter#suffix\n * @type {string}\n */\n suffix: '',\n\n /**\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {boolean} [opts.forceTrailingSlash=false] TODO\n * @param {Object} [opts.http=axios] TODO\n * @param {Object} [opts.httpConfig={}] TODO\n * @param {string} [opts.suffix=''] TODO\n * @param {boolean} [opts.useFetch=false] TODO\n */\nfunction HttpAdapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\nexports.HttpAdapter = HttpAdapter\n\n// Setup prototype inheritance from Adapter\nHttpAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: HttpAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(HttpAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `HttpAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyHttpAdapter extends HttpAdapter {...}\n * const adapter = new MyHttpAdapter()\n *\n * @example Using {@link HttpAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps)\n * var adapter = new MyHttpAdapter()\n *\n * @name HttpAdapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `HttpAdapter`.\n */\nHttpAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(HttpAdapter.prototype, {\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 const self = this\n return self.GET(\n self.getPath('count', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('create', mapper, props, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('createMany', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroy', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroyAll', mapper, null, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n const self = this\n return self.GET(\n self.getPath('find', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n return self.GET(\n self.getPath('sum', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n return self.PUT(\n self.getPath('update', mapper, id, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateAll', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateMany', mapper, null, opts),\n self.serialize(mapper, records, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params.count = true\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.count.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.create.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.createMany.call(self, 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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'DEL'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroy.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroyAll.call(self, 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 * @param {Object} [opts] Configuration options.\n */\n fetch (config, opts) {\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(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json().then(function (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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.find.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.findAll.call(self, mapper, query, opts)\n },\n\n /**\n * TODO\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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'GET'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {boolean} opts TODO\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n const self = this\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(function (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, function (value, key) {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(self.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 TODO\n * @param {Object} mapper TODO\n * @param {(string|number)?} id TODO\n * @param {Object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const args = [\n utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath,\n self.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 (utils.isUndefined(opts.params)) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.suffix)) {\n if (utils.isUndefined(mapper.suffix)) {\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 self = this\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, self.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || self.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n function 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 (self.log) {\n self.dbg('debug', str, data)\n }\n return data\n } else {\n if (self.error) {\n self.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!self.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) {\n config = _config || config\n if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) {\n return self.fetch(config, opts).then(logResponse, logResponse)\n }\n return self.http(config).then(logResponse, logResponse).catch(function (err) {\n return self.responseError(err, config, opts)\n })\n }).then(function (response) {\n return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) {\n return _response || response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'POST'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'PUT'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {Object} mapper TODO\n * @param {*} params TODO\n * @param {*} opts TODO\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 * TODO\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {Object} mapper TODO\n * @param {Object} data TODO\n * @param {*} opts TODO\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n if (!utils.utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = self.getParams(opts)\n opts.params.sum = field\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.sum.call(self, mapper, field, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#update\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {*} props TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.update.call(self, mapper, id, props, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {Object} mapper TODO\n * @param {Object} props TODO\n * @param {Object} query TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateAll.call(self, mapper, props, query, opts)\n },\n\n /**\n * Update multiple records in batch.\n *\n * {@link HttpAdapter#beforeUpdateMany} will be called before calling\n * {@link HttpAdapter#PUT}.\n * {@link HttpAdapter#afterUpdateMany} will be called after calling\n * {@link HttpAdapter#PUT}.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} records Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateMany.call(self, 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { default: true })\n * store.defineMapper('school')\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * basePath: '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(function (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]\n * @param {string} [opts.pathname]\n * @param {Function} [opts.request]\n * @param {Function} [opts.response]\n * @param {Function} [opts.responseError]\n * @return {Function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexports.addAction = 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 const self = this\n if (utils.isObject(id)) {\n _opts = id\n }\n _opts = _opts || {}\n let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http')\n let config = {}\n utils.fillIn(config, opts)\n if (!_opts.hasOwnProperty('endpoint') && config.endpoint) {\n _opts.endpoint = config.endpoint\n }\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(self, _opts)\n } else {\n let args = [\n _opts.basePath || self.basePath || adapter.basePath,\n adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _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 config.method = config.method || 'GET'\n config.mapper = self.name\n utils.deepMixIn(config, _opts)\n return utils.resolve(config)\n .then(_opts.request || opts.request)\n .then(function (config) { return adapter.HTTP(config) })\n .then(function (data) {\n if (data && data.config) {\n data.config.mapper = self.name\n }\n return data\n })\n .then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { 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(function (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 */\nexports.addActions = function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n exports.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 */\nexports.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 adapter = new HttpAdapter()\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * @example ES2015 Modules\n * import {HttpAdapter} from 'js-data-Http'\n * const adapter = new HttpAdapter()\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * // ...\n * })\n *\n * @module js-data-http\n */\nexports.default = HttpAdapter\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}\n ** module id = 1\n ** module chunks = 0\n **/","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-data')) :\n typeof define === 'function' && define.amd ? define('js-data-adapter', ['exports', 'js-data'], factory) :\n (factory((global.Adapter = global.Adapter || {}),global.JSData));\n}(this, function (exports,jsData) { 'use strict';\n\n var babelHelpers = {};\n babelHelpers.typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n };\n\n babelHelpers.defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n };\n\n babelHelpers.slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n }();\n\n babelHelpers;\n\n var noop = function noop() {\n var self = this;\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var opts = args[args.length - 1];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var noop2 = function noop2() {\n var self = this;\n\n for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n var opts = args[args.length - 2];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var unique = function unique(array) {\n var seen = {};\n var 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\n var withoutRelations = function withoutRelations(mapper, props) {\n return jsData.utils.omit(props, mapper.relationFields || []);\n };\n\n var 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 * @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 */\n function Adapter(opts) {\n var self = this;\n opts || (opts = {});\n jsData.utils.fillIn(opts, DEFAULTS);\n jsData.utils.fillIn(self, opts);\n }\n\n var reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where'];\n\n /**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\n function Response(data, meta, op) {\n var self = this;\n meta || (meta = {});\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n self.data = data;\n\n jsData.utils.fillIn(self, meta);\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n self.op = op;\n }\n\n /**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\n Adapter.extend = jsData.utils.extend;\n\n jsData.utils.addHiddenPropsToTarget(Adapter.prototype, {\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 * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg: function dbg() {\n for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n\n this.log.apply(this, ['debug'].concat(args));\n },\n\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: function count(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._count(mapper, query, opts));\n }).then(function (results) {\n var _results = babelHelpers.slicedToArray(results, 2);\n\n var data = _results[0];\n var result = _results[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function create(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'create';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._create(mapper, props, opts));\n }).then(function (results) {\n var _results2 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results2[0];\n var result = _results2[1];\n\n result || (result = {});\n var response = new Response(data, result, 'create');\n response.created = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function createMany(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = props.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'createMany';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._createMany(mapper, props, opts));\n }).then(function (results) {\n var _results3 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results3[0];\n var result = _results3[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'createMany');\n response.created = data.length;\n response = self.respond(response, opts);\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function destroy(mapper, id, opts) {\n var self = this;\n var op = void 0;\n opts || (opts = {});\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._destroy(mapper, id, opts));\n }).then(function (results) {\n var _results4 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results4[0];\n var result = _results4[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroy');\n response = self.respond(response, opts);\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function destroyAll(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._destroyAll(mapper, query, opts));\n }).then(function (results) {\n var _results5 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results5[0];\n var result = _results5[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroyAll');\n response = self.respond(response, opts);\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function loadBelongsTo(mapper, def, records, __opts) {\n var self = this;\n var relationDef = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n var _ret = function () {\n var record = records;\n return {\n v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem);\n })\n };\n }();\n\n if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === \"object\") return _ret.v;\n } else {\n var keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record);\n }).filter(function (key) {\n return key;\n });\n return self.findAll(relationDef, {\n where: babelHelpers.defineProperty({}, relationDef.idAttribute, {\n 'in': keys\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem);\n }\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: function find(mapper, id, opts) {\n var self = this;\n var record = void 0,\n op = void 0;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._find(mapper, id, opts));\n }).then(function (results) {\n var _results6 = babelHelpers.slicedToArray(results, 1);\n\n var _record = _results6[0];\n\n if (!_record) {\n return;\n }\n record = _record;\n var tasks = [];\n\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts);\n } else {\n task = self.loadHasMany(mapper, def, record, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(record, {}, 'find');\n response.found = record ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function findAll(mapper, query, opts) {\n var self = this;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n var records = [];\n var op = void 0;\n var activeWith = opts._activeWith;\n\n if (jsData.utils.isObject(activeWith)) {\n var activeQuery = activeWith.query || {};\n if (activeWith.replace) {\n query = activeQuery;\n } else {\n jsData.utils.deepFillIn(query, activeQuery);\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._findAll(mapper, query, opts));\n }).then(function (results) {\n var _results7 = babelHelpers.slicedToArray(results, 1);\n\n var _records = _results7[0];\n\n _records || (_records = []);\n records = _records;\n var tasks = [];\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts);\n } else {\n task = self.loadHasOne(mapper, def, records, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(records, {}, 'findAll');\n response.found = records.length;\n response = self.respond(response, opts);\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function getOpt(opt, opts) {\n opts || (opts = {});\n return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]);\n },\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: function loadHasMany(mapper, def, records, __opts) {\n var self = this;\n var singular = false;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n singular = true;\n records = [records];\n }\n var IDs = records.map(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record);\n });\n var query = {\n where: {}\n };\n var 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(function (id) {\n return id;\n });\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n var attached = [];\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems;\n } else {\n relatedItems.forEach(function (relatedItem) {\n if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem);\n }\n });\n }\n def.setLocalField(record, attached);\n });\n });\n },\n loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) {\n var self = this;\n var record = void 0;\n var relatedMapper = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n var _ret2 = function () {\n var localKeys = [];\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record));\n });\n return {\n v: self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': unique(localKeys).filter(function (x) {\n return x;\n })\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n var attached = [];\n var itemKeys = jsData.utils.get(item, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n relatedItems.forEach(function (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 if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === \"object\") return _ret2.v;\n }\n },\n loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) {\n var self = this;\n var relatedMapper = def.getRelation();\n var idAttribute = mapper.idAttribute;\n var record = void 0;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(def.getRelation(), {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record);\n })\n })\n }, __opts).then(function (relatedItems) {\n var foreignKeysField = def.foreignKeys;\n records.forEach(function (record) {\n var _relatedItems = [];\n var id = jsData.utils.get(record, idAttribute);\n relatedItems.forEach(function (relatedItem) {\n var foreignKeys = jsData.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 /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne: function loadHasOne(mapper, def, records, __opts) {\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n records = [records];\n }\n return this.loadHasMany(mapper, def, records, __opts).then(function () {\n records.forEach(function (record) {\n var relatedData = def.getLocalField(record);\n if (jsData.utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0]);\n }\n });\n });\n },\n\n\n /**\n * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log: function log(level) {\n for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n args[_key4 - 1] = arguments[_key4];\n }\n\n if (level && !args.length) {\n args.push(level);\n level = 'debug';\n }\n if (level === 'debug' && !this.debug) {\n return;\n }\n var prefix = level.toUpperCase() + ': (Adapter)';\n if (console[level]) {\n var _console;\n\n (_console = console)[level].apply(_console, [prefix].concat(args));\n } else {\n var _console2;\n\n (_console2 = console).log.apply(_console2, [prefix].concat(args));\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: function makeHasManyForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\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: function makeHasManyLocalKeys(mapper, def, record) {\n var localKeys = [];\n var itemKeys = jsData.utils.get(record, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n localKeys = localKeys.concat(itemKeys);\n return unique(localKeys).filter(function (x) {\n return x;\n });\n },\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: function makeHasManyForeignKeys(mapper, def, record) {\n return jsData.utils.get(record, mapper.idAttribute);\n },\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: function makeBelongsToForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\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: function sum(mapper, field, query, opts) {\n var self = this;\n var op = void 0;\n if (!jsData.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 jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum';\n self.dbg(op, mapper, field, query, opts);\n return jsData.utils.resolve(self._sum(mapper, field, query, opts));\n }).then(function (results) {\n var _results8 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results8[0];\n var result = _results8[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum';\n return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function respond(response, opts) {\n return this.getOpt('raw', opts) ? response : response.data;\n },\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: function update(mapper, id, props, opts) {\n var self = this;\n props || (props = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'update';\n self.dbg(op, mapper, id, props, opts);\n return jsData.utils.resolve(self._update(mapper, id, props, opts));\n }).then(function (results) {\n var _results9 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results9[0];\n var result = _results9[1];\n\n result || (result = {});\n var response = new Response(data, result, 'update');\n response.updated = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function updateAll(mapper, props, query, opts) {\n var self = this;\n props || (props = {});\n query || (query = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'updateAll';\n self.dbg(op, mapper, props, query, opts);\n return jsData.utils.resolve(self._updateAll(mapper, props, query, opts));\n }).then(function (results) {\n var _results10 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results10[0];\n var result = _results10[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateAll');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function updateMany(mapper, records, opts) {\n var self = this;\n records || (records = []);\n opts || (opts = {});\n var op = void 0;\n var idAttribute = mapper.idAttribute;\n\n records = records.filter(function (record) {\n return jsData.utils.get(record, idAttribute);\n });\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = jsData.utils.isUndefined(_records) ? records : _records;\n records = records.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'updateMany';\n self.dbg(op, mapper, records, opts);\n return jsData.utils.resolve(self._updateMany(mapper, records, opts));\n }).then(function (results) {\n var _results11 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results11[0];\n var result = _results11[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateMany');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n }\n });\n\n exports.noop = noop;\n exports.noop2 = noop2;\n exports.unique = unique;\n exports.withoutRelations = withoutRelations;\n exports.Adapter = Adapter;\n exports.reserved = reserved;\n exports.Response = Response;\n\n}));\n//# sourceMappingURL=js-data-adapter.js.map\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/js-data-adapter/dist/js-data-adapter.js\n ** module id = 2\n ** module chunks = 0\n **/","module.exports = undefined;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"undefined\"\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":""} \ 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":["\nimport {utils} from 'js-data'\n\nexport const noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const self = this\n const opts = args[args.length - 2]\n self.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) {\n return utils.omit(props, mapper.relationFields || [])\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 * @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 const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(self, opts)\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 const self = this\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n self.data = data\n\n utils.fillIn(self, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n self.op = op\n}\n\n/**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\nAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(Adapter.prototype, {\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 * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\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 const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._count(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'create'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._create(mapper, props, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = props.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'createMany'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._createMany(mapper, props, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._destroy(mapper, id, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = self.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._destroyAll(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = self.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 self = this\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record)\n }).filter(function (key) {\n return key\n })\n return self.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (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 const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._find(mapper, id, opts))\n }).then(function (results) {\n let [_record] = results\n if (!_record) {\n return\n }\n record = _record\n const tasks = []\n\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts)\n } else {\n task = self.loadHasMany(mapper, def, record, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(record, {}, 'find')\n response.found = record ? 1 : 0\n response = self.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n let records = []\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(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._findAll(mapper, query, opts))\n }).then(function (results) {\n let [_records] = results\n _records || (_records = [])\n records = _records\n const tasks = []\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts)\n } else {\n task = self.loadHasOne(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(records, {}, 'findAll')\n response.found = records.length\n response = self.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 utils.isUndefined(opts[opt]) ? 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 const self = this\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(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record)\n })\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(function (id) {\n return id\n })\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (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(function (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 const self = this\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 self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record))\n })\n return self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach(function (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 self = this\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 self.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return self.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record)\n })\n }\n }\n }, __opts).then(function (relatedItems) {\n const foreignKeysField = def.foreignKeys\n records.forEach(function (record) {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach(function (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(function () {\n records.forEach(function (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 * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (Adapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\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(function (x) { return 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 const self = this\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(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n self.dbg(op, mapper, field, query, opts)\n return utils.resolve(self._sum(mapper, field, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'update'\n self.dbg(op, mapper, id, props, opts)\n return utils.resolve(self._update(mapper, id, props, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\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(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'updateAll'\n self.dbg(op, mapper, props, query, opts)\n return utils.resolve(self._updateAll(mapper, props, query, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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 const self = this\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter(function (record) {\n return utils.get(record, idAttribute)\n })\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = utils.isUndefined(_records) ? records : _records\n records = records.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'updateMany'\n self.dbg(op, mapper, records, opts)\n return utils.resolve(self._updateMany(mapper, records, opts))\n }).then(function (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 = self.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n }\n})\n","/* global fetch:true Headers:true Request:true */\n\nimport {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 (window.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 __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n // Default and user-defined settings\n /**\n * @name HttpAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n */\n forceTrailingSlash: false,\n\n /**\n * @name HttpAdapter#http\n * @type {Function}\n */\n http: axios,\n\n /**\n * @name HttpAdapter#httpConfig\n * @type {Object}\n */\n httpConfig: {},\n\n /**\n * @name HttpAdapter#suffix\n * @type {string}\n */\n suffix: '',\n\n /**\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {boolean} [opts.forceTrailingSlash=false] TODO\n * @param {Object} [opts.http=axios] TODO\n * @param {Object} [opts.httpConfig={}] TODO\n * @param {string} [opts.suffix=''] TODO\n * @param {boolean} [opts.useFetch=false] TODO\n */\nexport function HttpAdapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\n// Setup prototype inheritance from Adapter\nHttpAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: HttpAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(HttpAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `HttpAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyHttpAdapter extends HttpAdapter {...}\n * const adapter = new MyHttpAdapter()\n *\n * @example Using {@link HttpAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps)\n * var adapter = new MyHttpAdapter()\n *\n * @name HttpAdapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `HttpAdapter`.\n */\nHttpAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(HttpAdapter.prototype, {\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 const self = this\n return self.GET(\n self.getPath('count', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('create', mapper, props, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('createMany', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroy', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroyAll', mapper, null, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n const self = this\n return self.GET(\n self.getPath('find', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n return self.GET(\n self.getPath('sum', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n return self.PUT(\n self.getPath('update', mapper, id, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateAll', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateMany', mapper, null, opts),\n self.serialize(mapper, records, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params.count = true\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.count.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.create.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.createMany.call(self, 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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'DEL'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroy.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroyAll.call(self, 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 * @param {Object} [opts] Configuration options.\n */\n fetch (config, opts) {\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(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json().then(function (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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.find.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.findAll.call(self, mapper, query, opts)\n },\n\n /**\n * TODO\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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'GET'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {boolean} opts TODO\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n const self = this\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(function (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, function (value, key) {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(self.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 TODO\n * @param {Object} mapper TODO\n * @param {(string|number)?} id TODO\n * @param {Object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const args = [\n utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath,\n self.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 (utils.isUndefined(opts.params)) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.suffix)) {\n if (utils.isUndefined(mapper.suffix)) {\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 self = this\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, self.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || self.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n function 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 (self.log) {\n self.dbg('debug', str, data)\n }\n return data\n } else {\n if (self.error) {\n self.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!self.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) {\n config = _config || config\n if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) {\n return self.fetch(config, opts).then(logResponse, logResponse)\n }\n return self.http(config).then(logResponse, logResponse).catch(function (err) {\n return self.responseError(err, config, opts)\n })\n }).then(function (response) {\n return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) {\n return _response || response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'POST'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'PUT'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {Object} mapper TODO\n * @param {*} params TODO\n * @param {*} opts TODO\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 * TODO\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {Object} mapper TODO\n * @param {Object} data TODO\n * @param {*} opts TODO\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n if (!utils.utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = self.getParams(opts)\n opts.params.sum = field\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.sum.call(self, mapper, field, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#update\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {*} props TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.update.call(self, mapper, id, props, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {Object} mapper TODO\n * @param {Object} props TODO\n * @param {Object} query TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateAll.call(self, mapper, props, query, opts)\n },\n\n /**\n * Update multiple records in batch.\n *\n * {@link HttpAdapter#beforeUpdateMany} will be called before calling\n * {@link HttpAdapter#PUT}.\n * {@link HttpAdapter#afterUpdateMany} will be called after calling\n * {@link HttpAdapter#PUT}.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} records Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateMany.call(self, 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { default: true })\n * store.defineMapper('school')\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * basePath: '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(function (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]\n * @param {string} [opts.pathname]\n * @param {Function} [opts.request]\n * @param {Function} [opts.response]\n * @param {Function} [opts.responseError]\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 const self = this\n if (utils.isObject(id)) {\n _opts = id\n }\n _opts = _opts || {}\n let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http')\n let config = {}\n utils.fillIn(config, opts)\n if (!_opts.hasOwnProperty('endpoint') && config.endpoint) {\n _opts.endpoint = config.endpoint\n }\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(self, _opts)\n } else {\n let args = [\n _opts.basePath || self.basePath || adapter.basePath,\n adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _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 config.method = config.method || 'GET'\n config.mapper = self.name\n utils.deepMixIn(config, _opts)\n return utils.resolve(config)\n .then(_opts.request || opts.request)\n .then(function (config) { return adapter.HTTP(config) })\n .then(function (data) {\n if (data && data.config) {\n data.config.mapper = self.name\n }\n return data\n })\n .then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { 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(function (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 adapter = new HttpAdapter()\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * @example ES2015 Modules\n * import {HttpAdapter} from 'js-data-Http'\n * const adapter = new HttpAdapter()\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * // 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CAAa,MAAb,CAAP;AAA6B,EAAA,OAFlD,EAGJ,IAHI,CAGC,UAAU,IAAV,EAAgB;AACpB,EAAA,YAAI,QAAQ,KAAK,MAAjB,EAAyB;AACvB,EAAA,eAAK,MAAL,CAAY,MAAZ,GAAqB,KAAK,IAA1B;;AAEF,EAAA,eAAO,IAAP;AACD,EAAA,OARI,EASJ,IATI,CASC,MAAM,QAAN,IAAkB,KAAK,QATxB,EASkC,MAAM,aAAN,IAAuB,KAAK,aAT9D,CAAP;OA5BF;AAuCA,EAAA,WAAO,MAAP;KA9CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FF,EAAO,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;KAJF;;;;;;;;;;;;;;;;;AAsBF,EAAO,IAAM,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 ce0316a..ce12aee 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-beta.5 - Homepage +* @version 3.0.0-beta.6 - Homepage * @copyright (c) 2014-2016 js-data-http project authors * @license MIT * * @overview HTTP adapter for js-data that uses the fetch API. */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("js-data"),require("undefined")):"function"==typeof define&&define.amd?define(["js-data","undefined"],t):"object"==typeof exports?exports.JSDataHttp=t(require("js-data"),require("undefined")):e.JSDataHttp=t(e.JSData,e.undefined)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return null!=e&&""!==e}function i(e,t){return t||(t=""),e.filter(r).join(t)}function o(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var r=i(t,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function a(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,"]")}function u(e,t){if(!t)return e;var n=[];return f.utils.forOwn(t,function(e,t){null!==e&&"undefined"!=typeof e&&(f.utils.isArray(e)||(e=[e]),e.forEach(function(e){"[object Date]"===window.toString.call(e)?e=e.toISOString():f.utils.isObject(e)&&(e=f.utils.toJson(e)),n.push(a(t)+"="+a(e))}))}),n.length>0&&(e+=(-1===e.indexOf("?")?"?":"&")+n.join("&")),e}function s(e){var t=this;e||(e={}),f.utils.fillIn(e,y),d.Adapter.call(t,e)}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},f=n(1),d=n(2),c=n(3),p=!1;try{p=window&&window.fetch}catch(e){}var h=d.Adapter.prototype,y={basePath:"",forceTrailingSlash:!1,http:c,httpConfig:{},suffix:"",useFetch:!1};t.HttpAdapter=s,s.prototype=Object.create(d.Adapter.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(s,"__super__",{configurable:!0,value:d.Adapter}),s.extend=f.utils.extend,f.utils.addHiddenPropsToTarget(s.prototype,{afterDEL:d.noop2,afterGET:d.noop2,afterHTTP:d.noop2,afterPOST:d.noop2,afterPUT:d.noop2,beforeDEL:d.noop,beforeGET:d.noop,beforeHTTP:d.noop,beforePOST:d.noop,beforePUT:d.noop,_count:function(e,t,n){var r=this;return r.GET(r.getPath("count",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_create:function(e,t,n){var r=this;return r.POST(r.getPath("create",e,t,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_createMany:function(e,t,n){var r=this;return r.POST(r.getPath("createMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroy:function(e,t,n){var r=this;return r.DEL(r.getPath("destroy",e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroyAll:function(e,t,n){var r=this;return r.DEL(r.getPath("destroyAll",e,null,n),n).then(function(t){return r._end(e,n,t)})},_end:function(e,t,n){return[this.deserialize(e,n,t),n]},_find:function(e,t,n){var r=this;return r.GET(r.getPath("find",e,t,n),n).then(function(t){return r._end(e,n,t)})},_findAll:function(e,t,n){var r=this;return r.GET(r.getPath("findAll",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_sum:function(e,t,n,r){var i=this;return i.GET(i.getPath("sum",e,r.params,r),r).then(function(t){return i._end(e,r,t)})},_update:function(e,t,n,r){var i=this;return i.PUT(i.getPath("update",e,t,r),i.serialize(e,n,r),r).then(function(t){return i._end(e,r,t)})},_updateAll:function(e,t,n,r){var i=this;return i.PUT(i.getPath("updateAll",e,null,r),i.serialize(e,t,r),r).then(function(t){return i._end(e,r,t)})},_updateMany:function(e,t,n){var r=this;return r.PUT(r.getPath("updateMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},count:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),n.params.count=!0,n.suffix=r.getSuffix(e,n),f.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),h.count.call(r,e,t,n)},create:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.create.call(r,e,t,n)},createMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.createMany.call(r,e,t,n)},DEL:function(e,t,n){var r=this,i=void 0;return t||(t={}),n||(n={}),t.url=e||t.url,t.method=t.method||"delete",i=n.op="beforeDEL",f.utils.resolve(r[i](e,t,n)).then(function(o){return t=f.utils.isUndefined(o)?t:o,i=n.op="DEL",r.dbg(i,e,t,n),r.HTTP(t,n)}).then(function(o){return i=n.op="afterDEL",f.utils.resolve(r[i](e,t,n,o)).then(function(e){return f.utils.isUndefined(e)?o:e})})},deserialize:function(e,t,n){return n||(n={}),f.utils.isFunction(n.deserialize)?n.deserialize(e,t,n):f.utils.isFunction(e.deserialize)?e.deserialize(e,t,n):t&&t.hasOwnProperty("data")?t.data:t},destroy:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.destroy.call(r,e,t,n)},destroyAll:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),f.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.destroyAll.call(r,e,t,n)},error:function(){if(console){var e;(e=console)["function"==typeof console.error?"error":"log"].apply(e,arguments)}},fetch:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,t){var n={method:e.method,headers:new Headers(e.headers)};return e.data&&(n.body=f.utils.toJson(e.data)),fetch(new Request(u(e.url,e.params),n)).then(function(t){return t.config={method:e.method,url:e.url},t.json().then(function(e){return t.data=e,t})})}),find:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.find.call(r,e,t,n)},findAll:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),n.suffix=r.getSuffix(e,n),f.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),h.findAll.call(r,e,t,n)},GET:function(e,t,n){var r=this,i=void 0;return t||(t={}),n||(n={}),t.url=e||t.url,t.method=t.method||"get",i=n.op="beforeGET",f.utils.resolve(r[i](e,t,n)).then(function(o){return t=f.utils.isUndefined(o)?t:o,i=n.op="GET",r.dbg(i,e,t,n),r.HTTP(t,n)}).then(function(o){return i=n.op="afterGET",f.utils.resolve(r[i](e,t,n,o)).then(function(e){return f.utils.isUndefined(e)?o:e})})},getEndpoint:function(e,t,n){var r=this;n||(n={}),n.params=f.utils.isUndefined(n.params)?{}:n.params;var i=e.relationList||[],a=f.utils.isUndefined(n.endpoint)?f.utils.isUndefined(e.endpoint)?e.name:e.endpoint:n.endpoint;return i.forEach(function(e){if("belongsTo"===e.type&&e.parent){var i=void 0,u=e.foreignKey,s=e.getRelation(),d=n.params[u];if(d===!1||!u||!s)return d===!1&&delete n.params[u],!1;if(delete n.params[u],f.utils.isObject(t)&&(i=t),i&&(d=d||e.getForeignKey(i)||(e.getLocalField(i)?f.utils.get(e.getLocalField(i),s.idAttribute):null)),d){var c=function(){delete n.endpoint;var e={};return f.utils.forOwn(n,function(t,n){e[n]=t}),f.utils._(e,s),a=o(r.getEndpoint(s,d,e),d,a),{v:!1}}();if("object"===("undefined"==typeof c?"undefined":l(c)))return c.v}}}),a},getPath:function(e,t,n,r){var i=this;r||(r={});var a=[f.utils.isUndefined(r.basePath)?f.utils.isUndefined(t.basePath)?i.basePath:t.basePath:r.basePath,i.getEndpoint(t,f.utils.isString(n)||f.utils.isNumber(n)||"create"===e?n:null,r)];return"find"!==e&&"update"!==e&&"destroy"!==e||a.push(n),o.apply(f.utils,a)},getParams:function(e){return e||(e={}),f.utils.isUndefined(e.params)?{}:f.utils.copy(e.params)},getSuffix:function(e,t){return t||(t={}),f.utils.isUndefined(t.suffix)?f.utils.isUndefined(e.suffix)?this.suffix:e.suffix:t.suffix},HTTP:function(e,t){function n(t){var n=i.toUTCString()+" - "+e.method.toUpperCase()+" "+e.url+" - "+t.status+" "+((new Date).getTime()-i.getTime())+"ms";return t.status>=200&&t.status<300?(r.log&&r.dbg("debug",n,t),t):(r.error&&r.error("'FAILED: "+n,t),f.utils.reject(t))}var r=this,i=new Date;t||(t={});var o=e.data,a=e.cache,u=e.timeout;e=f.utils.copy(e,null,null,null,["data","cache","timeout"]),e=f.utils.deepMixIn(e,r.httpConfig),e.data=o,e.cache=a,e.timeout=u,r.forceTrailingSlash&&"/"!==e.url[e.url.length-1]&&(e.url+="/"),e.method=e.method.toUpperCase();var s=e.suffix||t.suffix||r.suffix;if(s&&e.url.substr(e.url.length-s.length)!==s&&(e.url+=s),!r.http)throw new Error("You have not configured this adapter with an http library!");return f.utils.resolve(r.beforeHTTP(e,t)).then(function(i){return e=i||e,p&&(r.useFetch||t.useFetch||!r.http)?r.fetch(e,t).then(n,n):r.http(e).then(n,n).catch(function(n){return r.responseError(n,e,t)})}).then(function(n){return f.utils.resolve(r.afterHTTP(e,t,n)).then(function(e){return e||n})})},POST:function(e,t,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.data=t||n.data,n.method=n.method||"post",o=r.op="beforePOST",f.utils.resolve(i[o](e,t,n,r)).then(function(a){return n=f.utils.isUndefined(a)?n:a,o=r.op="POST",i.dbg(o,e,t,n,r),i.HTTP(n,r)}).then(function(a){return o=r.op="afterPOST",f.utils.resolve(i[o](e,t,n,r,a)).then(function(e){return f.utils.isUndefined(e)?a:e})})},PUT:function(e,t,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.data=t||n.data,n.method=n.method||"put",o=r.op="beforePUT",f.utils.resolve(i[o](e,t,n,r)).then(function(a){return n=f.utils.isUndefined(a)?n:a,o=r.op="PUT",i.dbg(o,e,t,n,r),i.HTTP(n,r)}).then(function(a){return o=r.op="afterPUT",f.utils.resolve(i[o](e,t,n,r,a)).then(function(e){return f.utils.isUndefined(e)?a:e})})},queryTransform:function(e,t,n){return n||(n={}),f.utils.isFunction(n.queryTransform)?n.queryTransform(e,t,n):f.utils.isFunction(e.queryTransform)?e.queryTransform(e,t,n):t},responseError:function(e,t,n){return f.utils.reject(e)},serialize:function(e,t,n){return n||(n={}),f.utils.isFunction(n.serialize)?n.serialize(e,t,n):f.utils.isFunction(e.serialize)?e.serialize(e,t,n):t},sum:function(e,t,n,r){var i=this;if(n||(n={}),r||(r={}),!f.utils.utils.isString(t))throw new Error("field must be a string!");return r.params=i.getParams(r),r.params.sum=t,r.suffix=i.getSuffix(e,r),f.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),h.sum.call(i,e,t,n,r)},update:function(e,t,n,r){var i=this;return r||(r={}),r.params=i.getParams(r),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),h.update.call(i,e,t,n,r)},updateAll:function(e,t,n,r){var i=this;return n||(n={}),r||(r={}),r.params=i.getParams(r),f.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),h.updateAll.call(i,e,t,n,r)},updateMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),h.updateMany.call(r,e,t,n)}}),t.addAction=function(e,t){if(!e||!f.utils.isString(e))throw new TypeError("action(name[, opts]): Expected: string, Found: "+("undefined"==typeof e?"undefined":l(e)));return function(n){if(n[e])throw new Error("action(name[, opts]): "+e+" already exists on target!");return t.request=t.request||function(e){return e},t.response=t.response||function(e){return e},t.responseError=t.responseError||function(e){return f.utils.reject(e)},n[e]=function(n,r){var i=this;f.utils.isObject(n)&&(r=n),r=r||{};var a=i.getAdapter(t.adapter||i.defaultAdapter||"http"),u={};if(f.utils.fillIn(u,t),!r.hasOwnProperty("endpoint")&&u.endpoint&&(r.endpoint=u.endpoint),"function"==typeof r.getEndpoint)u.url=r.getEndpoint(i,r);else{var s=[r.basePath||i.basePath||a.basePath,a.getEndpoint(i,f.utils.isSorN(n)?n:null,r)];f.utils.isSorN(n)&&s.push(n),s.push(t.pathname||e),u.url=o.apply(null,s)}return u.method=u.method||"GET",u.mapper=i.name,f.utils.deepMixIn(u,r),f.utils.resolve(u).then(r.request||t.request).then(function(e){return a.HTTP(e)}).then(function(e){return e&&e.config&&(e.config.mapper=i.name),e}).then(r.response||t.response,r.responseError||t.responseError)},n}},t.addActions=function(e){return e||(e={}),function(n){return f.utils.forOwn(e,function(e,r){t.addAction(r,e)(n)}),n}},t.version={beta:5,full:"3.0.0-beta.5",major:3,minor:0,patch:0},t.default=s},function(t,n){t.exports=e},function(e,t,n){!function(e,r){r(t,n(1))}(this,function(e,t){"use strict";function n(e){var n=this;e||(e={}),t.utils.fillIn(e,l),t.utils.fillIn(n,e)}function r(e,n,r){var i=this;n||(n={}),i.data=e,t.utils.fillIn(i,n),i.op=r}var i={};i.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i.defineProperty=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.slicedToArray=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&u.return&&u.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var o=function(){for(var e=this,n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r[r.length-1];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},a=function(){for(var e=this,n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r[r.length-2];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},u=function(e){var t={},n=[];return e.forEach(function(e){e in t||(n.push(e),t[e]=0)}),n},s=function(e,n){return t.utils.omit(n,e.relationFields||[])},l={debug:!1,raw:!1},f=["orderBy","sort","limit","offset","skip","where"];n.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(n.prototype,{afterCount:a,afterCreate:a,afterCreateMany:a,afterDestroy:a,afterDestroyAll:a,afterFind:a,afterFindAll:a,afterSum:a,afterUpdate:a,afterUpdateAll:a,afterUpdateMany:a,beforeCount:o,beforeCreate:o,beforeCreateMany:o,beforeDestroy:o,beforeDestroyAll:o,beforeFind:o,beforeFindAll:o,beforeSum:o,beforeUpdate:o,beforeUpdateAll:o,beforeUpdateMany:o,dbg:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},count:function(e,n,o){var a=this,u=void 0;return n||(n={}),o||(o={}),u=o.op="beforeCount",t.utils.resolve(a[u](e,n,o)).then(function(){return u=o.op="count",a.dbg(u,e,n,o),t.utils.resolve(a._count(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var c=new r(f,d,u);return c=a.respond(c,o),u=o.op="afterCount",t.utils.resolve(a[u](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},create:function(e,n,o){var a=this,u=void 0;return n||(n={}),o||(o={}),u=o.op="beforeCreate",t.utils.resolve(a[u](e,n,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=s(e,n),u=o.op="create",a.dbg(u,e,n,o),t.utils.resolve(a._create(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var c=new r(f,d,"create");return c.created=f?1:0,c=a.respond(c,o),u=o.op="afterCreate",t.utils.resolve(a[u](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},createMany:function(e,n,o){var a=this,u=void 0;return n||(n={}),o||(o={}),u=o.op="beforeCreateMany",t.utils.resolve(a[u](e,n,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),u=o.op="createMany",a.dbg(u,e,n,o),t.utils.resolve(a._createMany(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];f||(f=[]),d||(d={});var c=new r(f,d,"createMany");return c.created=f.length,c=a.respond(c,o),u=o.op="afterCreateMany",t.utils.resolve(a[u](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},destroy:function(e,n,o){var a=this,u=void 0;return o||(o={}),u=o.op="beforeDestroy",t.utils.resolve(a[u](e,n,o)).then(function(){return u=o.op="destroy",a.dbg(u,e,n,o),t.utils.resolve(a._destroy(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var c=new r(f,d,"destroy");return c=a.respond(c,o),u=o.op="afterDestroy",t.utils.resolve(a[u](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},destroyAll:function(e,n,o){var a=this,u=void 0;return n||(n={}),o||(o={}),u=o.op="beforeDestroyAll",t.utils.resolve(a[u](e,n,o)).then(function(){return u=o.op="destroyAll",a.dbg(u,e,n,o),t.utils.resolve(a._destroyAll(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var c=new r(f,d,"destroyAll");return c=a.respond(c,o),u=o.op="afterDestroyAll",t.utils.resolve(a[u](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},loadBelongsTo:function(e,n,r,o){var a=this,u=n.getRelation();if(!t.utils.isObject(r)||t.utils.isArray(r)){var s=r.map(function(t){return a.makeBelongsToForeignKey(e,n,t)}).filter(function(e){return e});return a.findAll(u,{where:i.defineProperty({},u.idAttribute,{in:s})},o).then(function(e){r.forEach(function(t){e.forEach(function(e){e[u.idAttribute]===t[n.foreignKey]&&n.setLocalField(t,e)})})})}var l=function(){var t=r;return{v:a.find(u,a.makeBelongsToForeignKey(e,n,t),o).then(function(e){n.setLocalField(t,e)})}}();return"object"===("undefined"==typeof l?"undefined":i.typeof(l))?l.v:void 0},find:function(e,n,o){var a=this,u=void 0,s=void 0;return o||(o={}),o.with||(o.with=[]),s=o.op="beforeFind",t.utils.resolve(a[s](e,n,o)).then(function(){return s=o.op="find",a.dbg(s,e,n,o),t.utils.resolve(a._find(e,n,o))}).then(function(n){var r=i.slicedToArray(n,1),s=r[0];if(s){u=s;var l=[];return t.utils.forEachRelation(e,o,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=a.loadHasManyLocalKeys(e,t,u,n):"hasMany"===t.type&&t.foreignKeys?r=a.loadHasManyForeignKeys(e,t,u,n):"belongsTo"===t.type&&(r=a.loadBelongsTo(e,t,u,n)):r="hasOne"===t.type?a.loadHasOne(e,t,u,n):a.loadHasMany(e,t,u,n),r&&l.push(r)}),Promise.all(l)}}).then(function(){var i=new r(u,{},"find");return i.found=u?1:0,i=a.respond(i,o),s=o.op="afterFind",t.utils.resolve(a[s](e,n,o,i)).then(function(e){return t.utils.isUndefined(e)?i:e})})},findAll:function(e,n,o){var a=this;o||(o={}),o.with||(o.with=[]);var u=[],s=void 0,l=o._activeWith;if(t.utils.isObject(l)){var f=l.query||{};l.replace?n=f:t.utils.deepFillIn(n,f)}return s=o.op="beforeFindAll",t.utils.resolve(a[s](e,n,o)).then(function(){return s=o.op="findAll",a.dbg(s,e,n,o),t.utils.resolve(a._findAll(e,n,o))}).then(function(n){var r=i.slicedToArray(n,1),s=r[0];s||(s=[]),u=s;var l=[];return t.utils.forEachRelation(e,o,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=a.loadHasManyLocalKeys(e,t,u,n):"hasMany"===t.type&&t.foreignKeys?r=a.loadHasManyForeignKeys(e,t,u,n):"belongsTo"===t.type&&(r=a.loadBelongsTo(e,t,u,n)):r="hasMany"===t.type?a.loadHasMany(e,t,u,n):a.loadHasOne(e,t,u,n),r&&l.push(r)}),Promise.all(l)}).then(function(){var i=new r(u,{},"findAll");return i.found=u.length,i=a.respond(i,o),s=o.op="afterFindAll",t.utils.resolve(a[s](e,n,o,i)).then(function(e){return t.utils.isUndefined(e)?i:e})})},getOpt:function(e,n){return n||(n={}),t.utils.isUndefined(n[e])?t.utils.plainCopy(this[e]):t.utils.plainCopy(n[e])},loadHasMany:function(e,n,r,i){var o=this,a=!1;t.utils.isObject(r)&&!t.utils.isArray(r)&&(a=!0,r=[r]);var u=r.map(function(t){return o.makeHasManyForeignKey(e,n,t)}),s={where:{}},l=s.where[n.foreignKey]={};return a?l["=="]=u[0]:l.in=u.filter(function(e){return e}),o.findAll(n.getRelation(),s,i).then(function(i){r.forEach(function(r){var o=[];a?o=i:i.forEach(function(i){t.utils.get(i,n.foreignKey)===r[e.idAttribute]&&o.push(i)}),n.setLocalField(r,o)})})},loadHasManyLocalKeys:function(e,n,r,o){var a=this,s=void 0,l=n.getRelation();if(t.utils.isObject(r)&&!t.utils.isArray(r)&&(s=r),s)return a.findAll(l,{where:i.defineProperty({},l.idAttribute,{in:a.makeHasManyLocalKeys(e,n,s)})},o).then(function(e){n.setLocalField(s,e)});var f=function(){var s=[];return r.forEach(function(t){s=s.concat(a.self.makeHasManyLocalKeys(e,n,t))}),{v:a.findAll(l,{where:i.defineProperty({},l.idAttribute,{in:u(s).filter(function(e){return e})})},o).then(function(e){return r.forEach(function(r){var i=[],o=t.utils.get(r,n.localKeys)||[];o=t.utils.isArray(o)?o:Object.keys(o),e.forEach(function(e){o&&-1!==o.indexOf(e[l.idAttribute])&&i.push(e)}),n.setLocalField(r,i)}),e})}}();return"object"===("undefined"==typeof f?"undefined":i.typeof(f))?f.v:void 0},loadHasManyForeignKeys:function(e,n,r,o){var a=this,u=n.getRelation(),s=e.idAttribute,l=void 0;return t.utils.isObject(r)&&!t.utils.isArray(r)&&(l=r),l?a.findAll(n.getRelation(),{where:i.defineProperty({},n.foreignKeys,{contains:a.makeHasManyForeignKeys(e,n,l)})},o).then(function(e){n.setLocalField(l,e)}):a.findAll(u,{where:i.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(t){return a.makeHasManyForeignKeys(e,n,t)})})},o).then(function(e){var i=n.foreignKeys;r.forEach(function(r){var o=[],a=t.utils.get(r,s);e.forEach(function(n){var r=t.utils.get(e,i)||[];-1!==r.indexOf(a)&&o.push(n)}),n.setLocalField(r,o)})})},loadHasOne:function(e,n,r,i){return t.utils.isObject(r)&&!t.utils.isArray(r)&&(r=[r]),this.loadHasMany(e,n,r,i).then(function(){r.forEach(function(e){var r=n.getLocalField(e);t.utils.isArray(r)&&r.length&&n.setLocalField(e,r[0])})})},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var i=e.toUpperCase()+": (Adapter)";if(console[e]){var o;(o=console)[e].apply(o,[i].concat(n))}else{var a;(a=console).log.apply(a,[i].concat(n))}}},makeHasManyForeignKey:function(e,t,n){return t.getForeignKey(n)},makeHasManyLocalKeys:function(e,n,r){var i=[],o=t.utils.get(r,n.localKeys)||[];return o=t.utils.isArray(o)?o:Object.keys(o),i=i.concat(o),u(i).filter(function(e){return e})},makeHasManyForeignKeys:function(e,n,r){return t.utils.get(r,e.idAttribute)},makeBelongsToForeignKey:function(e,t,n){return t.getForeignKey(n)},sum:function(e,n,o,a){var u=this,s=void 0;if(!t.utils.isString(n))throw new Error("field must be a string!");return o||(o={}),a||(a={}),s=a.op="beforeSum",t.utils.resolve(u[s](e,n,o,a)).then(function(){return s=a.op="sum",u.dbg(s,e,n,o,a),t.utils.resolve(u._sum(e,n,o,a))}).then(function(l){var f=i.slicedToArray(l,2),d=f[0],c=f[1];c||(c={});var p=new r(d,c,s);return p=u.respond(p,a),s=a.op="afterSum",t.utils.resolve(u[s](e,n,o,a,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},respond:function(e,t){return this.getOpt("raw",t)?e:e.data},update:function(e,n,o,a){var u=this;o||(o={}),a||(a={});var l=void 0;return l=a.op="beforeUpdate",t.utils.resolve(u[l](e,n,o,a)).then(function(r){return o=t.utils.isUndefined(r)?o:r,o=s(e,o),l=a.op="update",u.dbg(l,e,n,o,a),t.utils.resolve(u._update(e,n,o,a))}).then(function(s){var f=i.slicedToArray(s,2),d=f[0],c=f[1];c||(c={});var p=new r(d,c,"update");return p.updated=d?1:0,p=u.respond(p,a),l=a.op="afterUpdate",t.utils.resolve(u[l](e,n,o,a,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateAll:function(e,n,o,a){var u=this;n||(n={}),o||(o={}),a||(a={});var l=void 0;return l=a.op="beforeUpdateAll",t.utils.resolve(u[l](e,n,o,a)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=s(e,n),l=a.op="updateAll",u.dbg(l,e,n,o,a),t.utils.resolve(u._updateAll(e,n,o,a))}).then(function(s){var f=i.slicedToArray(s,2),d=f[0],c=f[1];d||(d=[]),c||(c={});var p=new r(d,c,"updateAll");return p.updated=d.length,p=u.respond(p,a),l=a.op="afterUpdateAll",t.utils.resolve(u[l](e,n,o,a,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateMany:function(e,n,o){var a=this;n||(n=[]),o||(o={});var u=void 0,l=e.idAttribute;return n=n.filter(function(e){return t.utils.get(e,l)}),u=o.op="beforeUpdateMany",t.utils.resolve(a[u](e,n,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),u=o.op="updateMany",a.dbg(u,e,n,o),t.utils.resolve(a._updateMany(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];f||(f=[]),d||(d={});var c=new r(f,d,"updateMany");return c.updated=f.length,c=a.respond(c,o),u=o.op="afterUpdateMany",t.utils.resolve(a[u](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})}}),e.noop=o,e.noop2=a,e.unique=u,e.withoutRelations=s,e.Adapter=n,e.reserved=f,e.Response=r})},function(e,t){e.exports=void 0}])}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-fetch",["exports","js-data"],t):t(e.JSDataHttp=e.JSDataHttp||{},e.JSData)}(this,function(e,t){"use strict";function n(e){var n=this;e||(e={}),t.utils.fillIn(e,g),t.utils.fillIn(n,e)}function r(e,n,r){var i=this;n||(n={}),i.data=e,t.utils.fillIn(i,n),i.op=r}function i(e){return null!=e&&""!==e}function o(e,t){return t||(t=""),e.filter(i).join(t)}function a(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var r=o(t,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(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,"]")}function s(e,n){if(!n)return e;var r=[];return t.utils.forOwn(n,function(e,n){null!==e&&"undefined"!=typeof e&&(t.utils.isArray(e)||(e=[e]),e.forEach(function(e){"[object Date]"===window.toString.call(e)?e=e.toISOString():t.utils.isObject(e)&&(e=t.utils.toJson(e)),r.push(u(n)+"="+u(e))}))}),r.length>0&&(e+=(-1===e.indexOf("?")?"?":"&")+r.join("&")),e}function l(e){var r=this;e||(e={}),t.utils.fillIn(e,A),n.call(r,e)}function f(e,n){if(!e||!t.utils.isString(e))throw new TypeError("action(name[, opts]): Expected: string, Found: "+("undefined"==typeof e?"undefined":c.typeof(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,i){var o=this;t.utils.isObject(r)&&(i=r),i=i||{};var u=o.getAdapter(n.adapter||o.defaultAdapter||"http"),s={};if(t.utils.fillIn(s,n),!i.hasOwnProperty("endpoint")&&s.endpoint&&(i.endpoint=s.endpoint),"function"==typeof i.getEndpoint)s.url=i.getEndpoint(o,i);else{var l=[i.basePath||o.basePath||u.basePath,u.getEndpoint(o,t.utils.isSorN(r)?r:null,i)];t.utils.isSorN(r)&&l.push(r),l.push(n.pathname||e),s.url=a.apply(null,l)}return s.method=s.method||"GET",s.mapper=o.name,t.utils.deepMixIn(s,i),t.utils.resolve(s).then(i.request||n.request).then(function(e){return u.HTTP(e)}).then(function(e){return e&&e.config&&(e.config.mapper=o.name),e}).then(i.response||n.response,i.responseError||n.responseError)},r}}function d(e){return e||(e={}),function(n){return t.utils.forOwn(e,function(e,t){f(t,e)(n)}),n}}var c={};c.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},c.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},c.slicedToArray=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&u.return&&u.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var p=function(){for(var e=this,n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r[r.length-1];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},h=function(){for(var e=this,n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r[r.length-2];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},y=function(e){var t={},n=[];return e.forEach(function(e){e in t||(n.push(e),t[e]=0)}),n},v=function(e,n){return t.utils.omit(n,e.relationFields||[])},g={debug:!1,raw:!1};n.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(n.prototype,{afterCount:h,afterCreate:h,afterCreateMany:h,afterDestroy:h,afterDestroyAll:h,afterFind:h,afterFindAll:h,afterSum:h,afterUpdate:h,afterUpdateAll:h,afterUpdateMany:h,beforeCount:p,beforeCreate:p,beforeCreateMany:p,beforeDestroy:p,beforeDestroyAll:p,beforeFind:p,beforeFindAll:p,beforeSum:p,beforeUpdate:p,beforeUpdateAll:p,beforeUpdateMany:p,dbg:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},count:function(e,n,i){var o=this,a=void 0;return n||(n={}),i||(i={}),a=i.op="beforeCount",t.utils.resolve(o[a](e,n,i)).then(function(){return a=i.op="count",o.dbg(a,e,n,i),t.utils.resolve(o._count(e,n,i))}).then(function(u){var s=c.slicedToArray(u,2),l=s[0],f=s[1];f||(f={});var d=new r(l,f,a);return d=o.respond(d,i),a=i.op="afterCount",t.utils.resolve(o[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},create:function(e,n,i){var o=this,a=void 0;return n||(n={}),i||(i={}),a=i.op="beforeCreate",t.utils.resolve(o[a](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=v(e,n),a=i.op="create",o.dbg(a,e,n,i),t.utils.resolve(o._create(e,n,i))}).then(function(u){var s=c.slicedToArray(u,2),l=s[0],f=s[1];f||(f={});var d=new r(l,f,"create");return d.created=l?1:0,d=o.respond(d,i),a=i.op="afterCreate",t.utils.resolve(o[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},createMany:function(e,n,i){var o=this,a=void 0;return n||(n={}),i||(i={}),a=i.op="beforeCreateMany",t.utils.resolve(o[a](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return v(e,t)}),a=i.op="createMany",o.dbg(a,e,n,i),t.utils.resolve(o._createMany(e,n,i))}).then(function(u){var s=c.slicedToArray(u,2),l=s[0],f=s[1];l||(l=[]),f||(f={});var d=new r(l,f,"createMany");return d.created=l.length,d=o.respond(d,i),a=i.op="afterCreateMany",t.utils.resolve(o[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroy:function(e,n,i){var o=this,a=void 0;return i||(i={}),a=i.op="beforeDestroy",t.utils.resolve(o[a](e,n,i)).then(function(){return a=i.op="destroy",o.dbg(a,e,n,i),t.utils.resolve(o._destroy(e,n,i))}).then(function(u){var s=c.slicedToArray(u,2),l=s[0],f=s[1];f||(f={});var d=new r(l,f,"destroy");return d=o.respond(d,i),a=i.op="afterDestroy",t.utils.resolve(o[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroyAll:function(e,n,i){var o=this,a=void 0;return n||(n={}),i||(i={}),a=i.op="beforeDestroyAll",t.utils.resolve(o[a](e,n,i)).then(function(){return a=i.op="destroyAll",o.dbg(a,e,n,i),t.utils.resolve(o._destroyAll(e,n,i))}).then(function(u){var s=c.slicedToArray(u,2),l=s[0],f=s[1];f||(f={});var d=new r(l,f,"destroyAll");return d=o.respond(d,i),a=i.op="afterDestroyAll",t.utils.resolve(o[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},loadBelongsTo:function(e,n,r,i){var o=this,a=n.getRelation();if(!t.utils.isObject(r)||t.utils.isArray(r)){var u=r.map(function(t){return o.makeBelongsToForeignKey(e,n,t)}).filter(function(e){return e});return o.findAll(a,{where:c.defineProperty({},a.idAttribute,{in:u})},i).then(function(e){r.forEach(function(t){e.forEach(function(e){e[a.idAttribute]===t[n.foreignKey]&&n.setLocalField(t,e)})})})}var s=function(){var t=r;return{v:o.find(a,o.makeBelongsToForeignKey(e,n,t),i).then(function(e){n.setLocalField(t,e)})}}();return"object"===("undefined"==typeof s?"undefined":c.typeof(s))?s.v:void 0},find:function(e,n,i){var o=this,a=void 0,u=void 0;return i||(i={}),i.with||(i.with=[]),u=i.op="beforeFind",t.utils.resolve(o[u](e,n,i)).then(function(){return u=i.op="find",o.dbg(u,e,n,i),t.utils.resolve(o._find(e,n,i))}).then(function(n){var r=c.slicedToArray(n,1),u=r[0];if(u){a=u;var s=[];return t.utils.forEachRelation(e,i,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=o.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=o.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=o.loadBelongsTo(e,t,a,n)):r="hasOne"===t.type?o.loadHasOne(e,t,a,n):o.loadHasMany(e,t,a,n),r&&s.push(r)}),Promise.all(s)}}).then(function(){var s=new r(a,{},"find");return s.found=a?1:0,s=o.respond(s,i),u=i.op="afterFind",t.utils.resolve(o[u](e,n,i,s)).then(function(e){return t.utils.isUndefined(e)?s:e})})},findAll:function(e,n,i){var o=this;i||(i={}),i.with||(i.with=[]);var a=[],u=void 0,s=i._activeWith;if(t.utils.isObject(s)){var l=s.query||{};s.replace?n=l:t.utils.deepFillIn(n,l)}return u=i.op="beforeFindAll",t.utils.resolve(o[u](e,n,i)).then(function(){return u=i.op="findAll",o.dbg(u,e,n,i),t.utils.resolve(o._findAll(e,n,i))}).then(function(n){var r=c.slicedToArray(n,1),u=r[0];u||(u=[]),a=u;var s=[];return t.utils.forEachRelation(e,i,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=o.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=o.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=o.loadBelongsTo(e,t,a,n)):r="hasMany"===t.type?o.loadHasMany(e,t,a,n):o.loadHasOne(e,t,a,n),r&&s.push(r)}),Promise.all(s)}).then(function(){var s=new r(a,{},"findAll");return s.found=a.length,s=o.respond(s,i),u=i.op="afterFindAll",t.utils.resolve(o[u](e,n,i,s)).then(function(e){return t.utils.isUndefined(e)?s:e})})},getOpt:function(e,n){return n||(n={}),t.utils.isUndefined(n[e])?t.utils.plainCopy(this[e]):t.utils.plainCopy(n[e])},loadHasMany:function(e,n,r,i){var o=this,a=!1;t.utils.isObject(r)&&!t.utils.isArray(r)&&(a=!0,r=[r]);var u=r.map(function(t){return o.makeHasManyForeignKey(e,n,t)}),s={where:{}},l=s.where[n.foreignKey]={};return a?l["=="]=u[0]:l.in=u.filter(function(e){return e}),o.findAll(n.getRelation(),s,i).then(function(i){r.forEach(function(r){var o=[];a?o=i:i.forEach(function(i){t.utils.get(i,n.foreignKey)===r[e.idAttribute]&&o.push(i)}),n.setLocalField(r,o)})})},loadHasManyLocalKeys:function(e,n,r,i){var o=this,a=void 0,u=n.getRelation();if(t.utils.isObject(r)&&!t.utils.isArray(r)&&(a=r),a)return o.findAll(u,{where:c.defineProperty({},u.idAttribute,{in:o.makeHasManyLocalKeys(e,n,a)})},i).then(function(e){n.setLocalField(a,e)});var s=function(){var a=[];return r.forEach(function(t){a=a.concat(o.self.makeHasManyLocalKeys(e,n,t))}),{v:o.findAll(u,{where:c.defineProperty({},u.idAttribute,{in:y(a).filter(function(e){return e})})},i).then(function(e){return r.forEach(function(r){var i=[],o=t.utils.get(r,n.localKeys)||[];o=t.utils.isArray(o)?o:Object.keys(o),e.forEach(function(e){o&&-1!==o.indexOf(e[u.idAttribute])&&i.push(e)}),n.setLocalField(r,i)}),e})}}();return"object"===("undefined"==typeof s?"undefined":c.typeof(s))?s.v:void 0},loadHasManyForeignKeys:function(e,n,r,i){var o=this,a=n.getRelation(),u=e.idAttribute,s=void 0;return t.utils.isObject(r)&&!t.utils.isArray(r)&&(s=r),s?o.findAll(n.getRelation(),{where:c.defineProperty({},n.foreignKeys,{contains:o.makeHasManyForeignKeys(e,n,s)})},i).then(function(e){n.setLocalField(s,e)}):o.findAll(a,{where:c.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(t){return o.makeHasManyForeignKeys(e,n,t)})})},i).then(function(e){var i=n.foreignKeys;r.forEach(function(r){var o=[],a=t.utils.get(r,u);e.forEach(function(n){var r=t.utils.get(e,i)||[];-1!==r.indexOf(a)&&o.push(n)}),n.setLocalField(r,o)})})},loadHasOne:function(e,n,r,i){return t.utils.isObject(r)&&!t.utils.isArray(r)&&(r=[r]),this.loadHasMany(e,n,r,i).then(function(){r.forEach(function(e){var r=n.getLocalField(e);t.utils.isArray(r)&&r.length&&n.setLocalField(e,r[0])})})},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var i=e.toUpperCase()+": (Adapter)";if(console[e]){var o;(o=console)[e].apply(o,[i].concat(n))}else{var a;(a=console).log.apply(a,[i].concat(n))}}},makeHasManyForeignKey:function(e,t,n){return t.getForeignKey(n)},makeHasManyLocalKeys:function(e,n,r){var i=[],o=t.utils.get(r,n.localKeys)||[];return o=t.utils.isArray(o)?o:Object.keys(o),i=i.concat(o),y(i).filter(function(e){return e})},makeHasManyForeignKeys:function(e,n,r){return t.utils.get(r,e.idAttribute)},makeBelongsToForeignKey:function(e,t,n){return t.getForeignKey(n)},sum:function(e,n,i,o){var a=this,u=void 0;if(!t.utils.isString(n))throw new Error("field must be a string!");return i||(i={}),o||(o={}),u=o.op="beforeSum",t.utils.resolve(a[u](e,n,i,o)).then(function(){return u=o.op="sum",a.dbg(u,e,n,i,o),t.utils.resolve(a._sum(e,n,i,o))}).then(function(s){var l=c.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var p=new r(f,d,u);return p=a.respond(p,o),u=o.op="afterSum",t.utils.resolve(a[u](e,n,i,o,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},respond:function(e,t){return this.getOpt("raw",t)?e:e.data},update:function(e,n,i,o){var a=this;i||(i={}),o||(o={});var u=void 0;return u=o.op="beforeUpdate",t.utils.resolve(a[u](e,n,i,o)).then(function(r){return i=t.utils.isUndefined(r)?i:r,i=v(e,i),u=o.op="update",a.dbg(u,e,n,i,o),t.utils.resolve(a._update(e,n,i,o))}).then(function(s){var l=c.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var p=new r(f,d,"update");return p.updated=f?1:0,p=a.respond(p,o),u=o.op="afterUpdate",t.utils.resolve(a[u](e,n,i,o,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateAll:function(e,n,i,o){var a=this;n||(n={}),i||(i={}),o||(o={});var u=void 0;return u=o.op="beforeUpdateAll",t.utils.resolve(a[u](e,n,i,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=v(e,n),u=o.op="updateAll",a.dbg(u,e,n,i,o),t.utils.resolve(a._updateAll(e,n,i,o))}).then(function(s){var l=c.slicedToArray(s,2),f=l[0],d=l[1];f||(f=[]),d||(d={});var p=new r(f,d,"updateAll");return p.updated=f.length,p=a.respond(p,o),u=o.op="afterUpdateAll",t.utils.resolve(a[u](e,n,i,o,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateMany:function(e,n,i){var o=this;n||(n=[]),i||(i={});var a=void 0,u=e.idAttribute;return n=n.filter(function(e){return t.utils.get(e,u)}),a=i.op="beforeUpdateMany",t.utils.resolve(o[a](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return v(e,t)}),a=i.op="updateMany",o.dbg(a,e,n,i),t.utils.resolve(o._updateMany(e,n,i))}).then(function(u){var s=c.slicedToArray(u,2),l=s[0],f=s[1];l||(l=[]),f||(f={});var d=new r(l,f,"updateMany");return d.updated=l.length,d=o.respond(d,i),a=i.op="afterUpdateMany",t.utils.resolve(o[a](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})}});var m=void 0,b=!1;try{b=window&&window.fetch}catch(e){}var T=n.prototype,A={basePath:"",forceTrailingSlash:!1,http:m,httpConfig:{},suffix:"",useFetch:!1};l.prototype=Object.create(n.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(l,"__super__",{configurable:!0,value:n}),l.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(l.prototype,{afterDEL:h,afterGET:h,afterHTTP:h,afterPOST:h,afterPUT:h,beforeDEL:p,beforeGET:p,beforeHTTP:p,beforePOST:p,beforePUT:p,_count:function(e,t,n){var r=this;return r.GET(r.getPath("count",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_create:function(e,t,n){var r=this;return r.POST(r.getPath("create",e,t,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_createMany:function(e,t,n){var r=this;return r.POST(r.getPath("createMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroy:function(e,t,n){var r=this;return r.DEL(r.getPath("destroy",e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroyAll:function(e,t,n){var r=this;return r.DEL(r.getPath("destroyAll",e,null,n),n).then(function(t){return r._end(e,n,t)})},_end:function(e,t,n){return[this.deserialize(e,n,t),n]},_find:function(e,t,n){var r=this;return r.GET(r.getPath("find",e,t,n),n).then(function(t){return r._end(e,n,t)})},_findAll:function(e,t,n){var r=this;return r.GET(r.getPath("findAll",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_sum:function(e,t,n,r){var i=this;return i.GET(i.getPath("sum",e,r.params,r),r).then(function(t){return i._end(e,r,t)})},_update:function(e,t,n,r){var i=this;return i.PUT(i.getPath("update",e,t,r),i.serialize(e,n,r),r).then(function(t){return i._end(e,r,t)})},_updateAll:function(e,t,n,r){var i=this;return i.PUT(i.getPath("updateAll",e,null,r),i.serialize(e,t,r),r).then(function(t){return i._end(e,r,t)})},_updateMany:function(e,t,n){var r=this;return r.PUT(r.getPath("updateMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},count:function(e,n,r){var i=this;return n||(n={}),r||(r={}),r.params=i.getParams(r),r.params.count=!0,r.suffix=i.getSuffix(e,r),t.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),T.count.call(i,e,n,r)},create:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),T.create.call(r,e,t,n)},createMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),T.createMany.call(r,e,t,n)},DEL:function(e,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.method=n.method||"delete",o=r.op="beforeDEL",t.utils.resolve(i[o](e,n,r)).then(function(a){return n=t.utils.isUndefined(a)?n:a,o=r.op="DEL",i.dbg(o,e,n,r),i.HTTP(n,r)}).then(function(a){return o=r.op="afterDEL",t.utils.resolve(i[o](e,n,r,a)).then(function(e){return t.utils.isUndefined(e)?a:e})})},deserialize:function(e,n,r){return r||(r={}),t.utils.isFunction(r.deserialize)?r.deserialize(e,n,r):t.utils.isFunction(e.deserialize)?e.deserialize(e,n,r):n&&n.hasOwnProperty("data")?n.data:n},destroy:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),T.destroy.call(r,e,t,n)},destroyAll:function(e,n,r){var i=this;return n||(n={}),r||(r={}),r.params=i.getParams(r),t.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),T.destroyAll.call(i,e,n,r)},error:function(){if(console){var e;(e=console)["function"==typeof console.error?"error":"log"].apply(e,arguments)}},fetch:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,n){var r={method:e.method,headers:new Headers(e.headers)};return e.data&&(r.body=t.utils.toJson(e.data)),fetch(new Request(s(e.url,e.params),r)).then(function(t){return t.config={method:e.method,url:e.url},t.json().then(function(e){return t.data=e,t})})}),find:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),T.find.call(r,e,t,n)},findAll:function(e,n,r){var i=this;return n||(n={}),r||(r={}),r.params=i.getParams(r),r.suffix=i.getSuffix(e,r),t.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),T.findAll.call(i,e,n,r)},GET:function(e,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.method=n.method||"get",o=r.op="beforeGET",t.utils.resolve(i[o](e,n,r)).then(function(a){return n=t.utils.isUndefined(a)?n:a,o=r.op="GET",i.dbg(o,e,n,r),i.HTTP(n,r)}).then(function(a){return o=r.op="afterGET",t.utils.resolve(i[o](e,n,r,a)).then(function(e){return t.utils.isUndefined(e)?a:e})})},getEndpoint:function(e,n,r){var i=this;r||(r={}),r.params=t.utils.isUndefined(r.params)?{}:r.params;var o=e.relationList||[],u=t.utils.isUndefined(r.endpoint)?t.utils.isUndefined(e.endpoint)?e.name:e.endpoint:r.endpoint;return o.forEach(function(e){if("belongsTo"===e.type&&e.parent){var o=void 0,s=e.foreignKey,l=e.getRelation(),f=r.params[s];if(f===!1||!s||!l)return f===!1&&delete r.params[s],!1;if(delete r.params[s],t.utils.isObject(n)&&(o=n),o&&(f=f||e.getForeignKey(o)||(e.getLocalField(o)?t.utils.get(e.getLocalField(o),l.idAttribute):null)),f){var d=function(){delete r.endpoint;var e={};return t.utils.forOwn(r,function(t,n){e[n]=t}),t.utils._(e,l),u=a(i.getEndpoint(l,f,e),f,u),{v:!1}}();if("object"===("undefined"==typeof d?"undefined":c.typeof(d)))return d.v}}}),u},getPath:function(e,n,r,i){var o=this;i||(i={});var u=[t.utils.isUndefined(i.basePath)?t.utils.isUndefined(n.basePath)?o.basePath:n.basePath:i.basePath,o.getEndpoint(n,t.utils.isString(r)||t.utils.isNumber(r)||"create"===e?r:null,i)];return"find"!==e&&"update"!==e&&"destroy"!==e||u.push(r),a.apply(t.utils,u)},getParams:function(e){return e||(e={}),t.utils.isUndefined(e.params)?{}:t.utils.copy(e.params)},getSuffix:function(e,n){return n||(n={}),t.utils.isUndefined(n.suffix)?t.utils.isUndefined(e.suffix)?this.suffix:e.suffix:n.suffix},HTTP:function(e,n){function r(n){var r=o.toUTCString()+" - "+e.method.toUpperCase()+" "+e.url+" - "+n.status+" "+((new Date).getTime()-o.getTime())+"ms";return n.status>=200&&n.status<300?(i.log&&i.dbg("debug",r,n),n):(i.error&&i.error("'FAILED: "+r,n),t.utils.reject(n))}var i=this,o=new Date;n||(n={});var a=e.data,u=e.cache,s=e.timeout;e=t.utils.copy(e,null,null,null,["data","cache","timeout"]),e=t.utils.deepMixIn(e,i.httpConfig),e.data=a,e.cache=u,e.timeout=s,i.forceTrailingSlash&&"/"!==e.url[e.url.length-1]&&(e.url+="/"),e.method=e.method.toUpperCase();var l=e.suffix||n.suffix||i.suffix;if(l&&e.url.substr(e.url.length-l.length)!==l&&(e.url+=l),!i.http)throw new Error("You have not configured this adapter with an http library!");return t.utils.resolve(i.beforeHTTP(e,n)).then(function(t){return e=t||e,b&&(i.useFetch||n.useFetch||!i.http)?i.fetch(e,n).then(r,r):i.http(e).then(r,r).catch(function(t){return i.responseError(t,e,n)})}).then(function(r){return t.utils.resolve(i.afterHTTP(e,n,r)).then(function(e){return e||r})})},POST:function(e,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=e||r.url,r.data=n||r.data,r.method=r.method||"post",a=i.op="beforePOST",t.utils.resolve(o[a](e,n,r,i)).then(function(u){return r=t.utils.isUndefined(u)?r:u,a=i.op="POST",o.dbg(a,e,n,r,i),o.HTTP(r,i)}).then(function(u){return a=i.op="afterPOST",t.utils.resolve(o[a](e,n,r,i,u)).then(function(e){return t.utils.isUndefined(e)?u:e})})},PUT:function(e,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=e||r.url,r.data=n||r.data,r.method=r.method||"put",a=i.op="beforePUT",t.utils.resolve(o[a](e,n,r,i)).then(function(u){return r=t.utils.isUndefined(u)?r:u,a=i.op="PUT",o.dbg(a,e,n,r,i),o.HTTP(r,i)}).then(function(u){return a=i.op="afterPUT",t.utils.resolve(o[a](e,n,r,i,u)).then(function(e){return t.utils.isUndefined(e)?u:e})})},queryTransform:function(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(e,n,r){return t.utils.reject(e)},serialize:function(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(e,n,r,i){var o=this;if(r||(r={}),i||(i={}),!t.utils.utils.isString(n))throw new Error("field must be a string!");return i.params=o.getParams(i),i.params.sum=n,i.suffix=o.getSuffix(e,i),t.utils.deepMixIn(i.params,r),i.params=o.queryTransform(e,i.params,i),T.sum.call(o,e,n,r,i)},update:function(e,t,n,r){var i=this;return r||(r={}),r.params=i.getParams(r),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),T.update.call(i,e,t,n,r)},updateAll:function(e,n,r,i){var o=this;return r||(r={}),i||(i={}),i.params=o.getParams(i),t.utils.deepMixIn(i.params,r),i.params=o.queryTransform(e,i.params,i),i.suffix=o.getSuffix(e,i),T.updateAll.call(o,e,n,r,i)},updateMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),T.updateMany.call(r,e,t,n)}});var P={beta:6,full:"3.0.0-beta.6",major:3,minor:0,patch:0};e.HttpAdapter=l,e.addAction=f,e.addActions=d,e.version=P}); //# sourceMappingURL=js-data-fetch.min.map \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.min.map b/fetch/dist/js-data-fetch.min.map index 0054279..587364a 100644 --- a/fetch/dist/js-data-fetch.min.map +++ b/fetch/dist/js-data-fetch.min.map @@ -1 +1 @@ -{"version":3,"sources":["fetch/dist/js-data-fetch.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","__WEBPACK_EXTERNAL_MODULE_3__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","_jsData","utils","forOwn","key","isArray","forEach","v","window","toString","toISOString","isObject","toJson","push","indexOf","HttpAdapter","opts","self","fillIn","DEFAULTS","_jsDataAdapter","Adapter","_typeof","Symbol","iterator","obj","constructor","axios","hasFetch","fetch","e","__super__","prototype","basePath","forceTrailingSlash","http","httpConfig","suffix","useFetch","Object","create","enumerable","writable","configurable","defineProperty","extend","addHiddenPropsToTarget","afterDEL","noop2","afterGET","afterHTTP","afterPOST","afterPUT","beforeDEL","noop","beforeGET","beforeHTTP","beforePOST","beforePUT","_count","mapper","query","GET","getPath","then","response","_end","_create","props","POST","serialize","_createMany","_destroy","DEL","_destroyAll","deserialize","_find","_findAll","_sum","field","_update","PUT","_updateAll","_updateMany","records","count","getParams","getSuffix","deepMixIn","queryTransform","createMany","config","op","method","resolve","_config","isUndefined","dbg","HTTP","_response","isFunction","hasOwnProperty","data","destroy","destroyAll","error","console","_console","apply","_fetch","_x","_x2","requestConfig","headers","Headers","body","Request","json","find","findAll","getEndpoint","relationList","endpoint","name","def","type","parent","item","parentKey","foreignKey","parentDef","getRelation","parentId","getForeignKey","getLocalField","get","idAttribute","_ret","_opts","_","isString","isNumber","copy","logResponse","str","start","toUTCString","toUpperCase","status","Date","getTime","log","reject","payload","cache","timeout","substr","Error","catch","err","responseError","sum","update","updateAll","updateMany","addAction","TypeError","request","adapter","getAdapter","defaultAdapter","isSorN","pathname","addActions","version","beta","full","major","minor","patch","default","global","jsData","Response","meta","babelHelpers","typeof","slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","next","done","concat","_len2","_key2","unique","array","seen","final","withoutRelations","omit","relationFields","debug","raw","reserved","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","results","_results","respond","_props","_results2","created","map","record","_results3","_results4","_results5","loadBelongsTo","__opts","relationDef","keys","makeBelongsToForeignKey","where","in","relatedItems","relatedItem","setLocalField","with","_results6","_record","tasks","forEachRelation","task","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","Promise","all","found","activeWith","_activeWith","activeQuery","deepFillIn","_results7","_records","getOpt","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","attached","relatedMapper","makeHasManyLocalKeys","_ret2","x","itemKeys","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","level","_len4","_key4","prefix","_console2","_results8","_results9","updated","_results10","_results11"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,WAAYA,QAAQ,cAC5B,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,UAAW,aAAcJ,GACP,gBAAZC,SACdA,QAAoB,WAAID,EAAQG,QAAQ,WAAYA,QAAQ,cAE5DJ,EAAiB,WAAIC,EAAQD,EAAa,OAAGA,EAAgB,YAC5DO,KAAM,SAASC,EAA+BC,GACjD,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUV,OAGnC,IAAIC,GAASU,EAAiBD,IAC7BV,WACAY,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKb,EAAOD,QAASC,EAAQA,EAAOD,QAASS,GAG/DR,EAAOY,QAAS,EAGTZ,EAAOD,QAvBf,GAAIW,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxB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AMiD,IAAWD,KAAK,SAAUmC,GAEpF,MAAOmF,GAAOpL,MAAM8F,YAAYG,GAAalC,EAAWkC,SAMhE1I,EAAQ6F,KAAOA,EACf7F,EAAQuF,MAAQA,EAChBvF,EAAQkP,OAASA,EACjBlP,EAAQsP,iBAAmBA,EAC3BtP,EAAQ4D,QAAUA,EAClB5D,EAAQ2P,SAAWA,EACnB3P,EAAQ8N,SAAWA,KAOhB,SAAS7N,EAAQD,GAEtBC,EAAOD,QAAU0O","file":"fetch/dist/js-data-fetch.min.js"} \ No newline at end of file +{"version":3,"sources":["fetch/dist/js-data-fetch.js"],"names":["global","factory","exports","module","require","define","amd","JSDataHttp","JSData","this","jsData","Adapter","opts","self","utils","fillIn","DEFAULTS$1","Response","data","meta","op","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","isArray","forEach","v","window","toString","call","toISOString","isObject","toJson","push","indexOf","HttpAdapter","DEFAULTS","addAction","name","isString","TypeError","babelHelpers","typeof","mapper","Error","request","config","response","responseError","err","reject","id","_opts","adapter","getAdapter","defaultAdapter","hasOwnProperty","endpoint","getEndpoint","basePath","isSorN","pathname","apply","method","deepMixIn","resolve","then","HTTP","addActions","Symbol","iterator","obj","constructor","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","omit","relationFields","debug","raw","extend","addHiddenPropsToTarget","prototype","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","log","count","query","_count","results","_results","respond","_response","isUndefined","create","_props","_create","_results2","created","createMany","map","record","_createMany","_results3","destroy","_destroy","_results4","destroyAll","_destroyAll","_results5","loadBelongsTo","def","records","__opts","relationDef","getRelation","keys","makeBelongsToForeignKey","findAll","where","idAttribute","in","relatedItems","relatedItem","foreignKey","setLocalField","_ret","find","with","_find","_results6","_record","tasks","forEachRelation","task","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","Promise","all","found","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_results7","_records","getOpt","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","attached","get","relatedMapper","makeHasManyLocalKeys","_ret2","x","itemKeys","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","level","_len4","_key4","prefix","toUpperCase","console","_console","_console2","getForeignKey","sum","field","_sum","_results8","update","_update","_results9","updated","updateAll","_updateAll","_results10","updateMany","_updateMany","_results11","axios","hasFetch","fetch","e","__super__","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","error","_fetch","_x","_x2","requestConfig","headers","Headers","body","Request","json","relationList","parent","parentKey","parentDef","parentId","_","isNumber","copy","logResponse","str","start","toUTCString","status","Date","getTime","payload","cache","timeout","substr","catch","version","beta","full","major","minor","patch"],"mappings":"CAAC,SAAUA,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,QAASE,QAAQ,YACtE,kBAAXC,SAAyBA,OAAOC,IAAMD,OAAO,iBAAkB,UAAW,WAAYJ,GAC5FA,EAASD,EAAOO,WAAaP,EAAOO,eAAkBP,EAAOQ,SAC9DC,KAAM,SAAUP,EAAQQ,GAAU,YAuIlC,SAASC,GAAQC,GACf,GAAIC,GAAOJ,IACXG,KAASA,MACTF,EAAOI,MAAMC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MAAMuE,UAAUzE,EAAK6B,OAAQqH,GACpClJ,EAAK6B,OAAS5B,EAAK4R,eAAezO,EAAQpD,EAAK6B,OAAQ7B,GACvDA,EAAKuQ,OAAStQ,EAAK2R,UAAUxO,EAAQpD,GAE9BmQ,EAAUV,UAAUnN,KAAKrC,EAAMmD,EAAQ4D,EAAOkC,EAAOlJ,IAqB9D4P,WAAY,SAAoBxM,EAAQuH,EAAS3K,GAC/C,GAAIC,GAAOJ,IAMX,OALAG,KAASA,MACTA,EAAK6B,OAAS5B,EAAK0R,UAAU3R,GAC7BA,EAAK6B,OAAS5B,EAAK4R,eAAezO,EAAQpD,EAAK6B,OAAQ7B,GACvDA,EAAKuQ,OAAStQ,EAAK2R,UAAUxO,EAAQpD,GAE9BmQ,EAAUP,WAAWtN,KAAKrC,EAAMmD,EAAQuH,EAAS3K,KAuK5D,IAAI8T,IACJC,KAAM,EACNC,KAAM,eACNC,MAAO,EACPC,MAAO,EACPC,MAAO,EAgCP7U,GAAQsD,YAAcA,EACtBtD,EAAQwD,UAAYA,EACpBxD,EAAQuF,WAAaA,EACrBvF,EAAQwU,QAAUA","file":"fetch/dist/js-data-fetch.min.js"} \ 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 b5fe91c..57ad3fc 100644 --- a/node/dist/js-data-http-node.js +++ b/node/dist/js-data-http-node.js @@ -1,3016 +1,1294 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("js-data"), require("axios")); - else if(typeof define === 'function' && define.amd) - define(["js-data", "axios"], factory); - else { - var a = typeof exports === 'object' ? factory(require("js-data"), require("axios")) : factory(root["js-data"], root["axios"]); - for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; - } -})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_3__) { -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__) { - - '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; }; - - var _jsData = __webpack_require__(1); - - var _jsDataAdapter = __webpack_require__(2); - - /* global fetch:true Headers:true Request:true */ - - var axios = __webpack_require__(3); - - - 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 (window.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 __super__ = _jsDataAdapter.Adapter.prototype; - - var DEFAULTS = { - // Default and user-defined settings - /** - * @name HttpAdapter#basePath - * @type {string} - */ - basePath: '', - - /** - * @name HttpAdapter#forceTrailingSlash - * @type {boolean} - * @default false - */ - forceTrailingSlash: false, - - /** - * @name HttpAdapter#http - * @type {Function} - */ - http: axios, - - /** - * @name HttpAdapter#httpConfig - * @type {Object} - */ - httpConfig: {}, - - /** - * @name HttpAdapter#suffix - * @type {string} - */ - suffix: '', - - /** - * @name HttpAdapter#useFetch - * @type {boolean} - * @default false - */ - useFetch: false - }; - - /** - * HttpAdapter class. - * - * @class HttpAdapter - * @extends Adapter - * @param {Object} [opts] Configuration options. - * @param {string} [opts.basePath=''] TODO - * @param {boolean} [opts.debug=false] TODO - * @param {boolean} [opts.forceTrailingSlash=false] TODO - * @param {Object} [opts.http=axios] TODO - * @param {Object} [opts.httpConfig={}] TODO - * @param {string} [opts.suffix=''] TODO - * @param {boolean} [opts.useFetch=false] TODO - */ - function HttpAdapter(opts) { - var self = this; - opts || (opts = {}); - _jsData.utils.fillIn(opts, DEFAULTS); - _jsDataAdapter.Adapter.call(self, opts); - } - - /** - * @name module:js-data-http.HttpAdapter - * @see HttpAdapter - */ - exports.HttpAdapter = HttpAdapter; - - // Setup prototype inheritance from Adapter - HttpAdapter.prototype = Object.create(_jsDataAdapter.Adapter.prototype, { - constructor: { - value: HttpAdapter, - enumerable: false, - writable: true, - configurable: true - } - }); - - Object.defineProperty(HttpAdapter, '__super__', { - configurable: true, - value: _jsDataAdapter.Adapter - }); - - /** - * Alternative to ES6 class syntax for extending `HttpAdapter`. - * - * @example Using the ES2015 class syntax. - * class MyHttpAdapter extends HttpAdapter {...} - * const adapter = new MyHttpAdapter() - * - * @example Using {@link HttpAdapter.extend}. - * var instanceProps = {...} - * var classProps = {...} - * - * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) - * var adapter = new MyHttpAdapter() - * - * @name HttpAdapter.extend - * @method - * @param {Object} [instanceProps] Properties that will be added to the - * prototype of the subclass. - * @param {Object} [classProps] Properties that will be added as static - * properties to the subclass itself. - * @return {Object} Subclass of `HttpAdapter`. - */ - HttpAdapter.extend = _jsData.utils.extend; - - _jsData.utils.addHiddenPropsToTarget(HttpAdapter.prototype, { - /** - * @name HttpAdapter#afterDEL - * @method - * @param {string} url - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterDEL: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#afterGET - * @method - * @param {string} url - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterGET: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#afterHTTP - * @method - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterHTTP: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#afterPOST - * @method - * @param {string} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterPOST: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#afterPUT - * @method - * @param {string} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - * @param {Object} response - */ - afterPUT: _jsDataAdapter.noop2, - - /** - * @name HttpAdapter#beforeDEL - * @method - * @param {Object} url - * @param {Object} config - * @param {Object} opts - */ - beforeDEL: _jsDataAdapter.noop, - - /** - * @name HttpAdapter#beforeGET - * @method - * @param {Object} url - * @param {Object} config - * @param {Object} opts - */ - beforeGET: _jsDataAdapter.noop, - - /** - * @name HttpAdapter#beforeHTTP - * @method - * @param {Object} config - * @param {Object} opts - */ - beforeHTTP: _jsDataAdapter.noop, - - /** - * @name HttpAdapter#beforePOST - * @method - * @param {Object} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - */ - beforePOST: _jsDataAdapter.noop, - - /** - * @name HttpAdapter#beforePUT - * @method - * @param {Object} url - * @param {Object} data - * @param {Object} config - * @param {Object} opts - */ - beforePUT: _jsDataAdapter.noop, - - _count: function _count(mapper, query, opts) { - var self = this; - return self.GET(self.getPath('count', mapper, opts.params, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _create: function _create(mapper, props, opts) { - var self = this; - return self.POST(self.getPath('create', mapper, props, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _createMany: function _createMany(mapper, props, opts) { - var self = this; - return self.POST(self.getPath('createMany', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _destroy: function _destroy(mapper, id, opts) { - var self = this; - return self.DEL(self.getPath('destroy', mapper, id, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _destroyAll: function _destroyAll(mapper, query, opts) { - var self = this; - return self.DEL(self.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _end: function _end(mapper, opts, response) { - return [this.deserialize(mapper, response, opts), response]; - }, - _find: function _find(mapper, id, opts) { - var self = this; - return self.GET(self.getPath('find', mapper, id, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _findAll: function _findAll(mapper, query, opts) { - var self = this; - return self.GET(self.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _sum: function _sum(mapper, field, query, opts) { - var self = this; - return self.GET(self.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _update: function _update(mapper, id, props, opts) { - var self = this; - return self.PUT(self.getPath('update', mapper, id, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _updateAll: function _updateAll(mapper, props, query, opts) { - var self = this; - return self.PUT(self.getPath('updateAll', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { - return self._end(mapper, opts, response); - }); - }, - _updateMany: function _updateMany(mapper, records, opts) { - var self = this; - return self.PUT(self.getPath('updateMany', mapper, null, opts), self.serialize(mapper, records, opts), opts).then(function (response) { - return self._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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - count: function count(mapper, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params.count = true; - opts.suffix = self.getSuffix(mapper, opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - - return __super__.count.call(self, 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - create: function create(mapper, props, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.create.call(self, 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - createMany: function createMany(mapper, props, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.createMany.call(self, 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 self = 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(self[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'DEL'; - self.dbg(op, url, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterDEL lifecycle hook - op = opts.op = 'afterDEL'; - return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - destroy: function destroy(mapper, id, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.destroy.call(self, 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - destroyAll: function destroyAll(mapper, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - opts.params = self.getParams(opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.destroyAll.call(self, 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. - * @param {Object} [opts] Configuration options. - */ - fetch: function (_fetch) { - function fetch(_x, _x2) { - return _fetch.apply(this, arguments); - } - - fetch.toString = function () { - return _fetch.toString(); - }; - - return fetch; - }(function (config, opts) { - 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(new Request(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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - find: function find(mapper, id, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.find.call(self, 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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - findAll: function findAll(mapper, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.suffix = self.getSuffix(mapper, opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - - return __super__.findAll.call(self, mapper, query, opts); - }, - - - /** - * TODO - * - * @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 self = 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(self[op](url, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'GET'; - self.dbg(op, url, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterGET lifecycle hook - op = opts.op = 'afterGET'; - return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - - /** - * @name HttpAdapter#getEndpoint - * @method - * @param {Object} mapper TODO - * @param {*} id TODO - * @param {boolean} opts TODO - * @return {string} Full path. - */ - getEndpoint: function getEndpoint(mapper, id, opts) { - var self = 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(self.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 TODO - * @param {Object} mapper TODO - * @param {(string|number)?} id TODO - * @param {Object} opts Configuration options. - */ - getPath: function getPath(method, mapper, id, opts) { - var self = this; - opts || (opts = {}); - var args = [_jsData.utils.isUndefined(opts.basePath) ? _jsData.utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath : opts.basePath, self.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 (_jsData.utils.isUndefined(opts.params)) { - return {}; - } - return _jsData.utils.copy(opts.params); - }, - getSuffix: function getSuffix(mapper, opts) { - opts || (opts = {}); - if (_jsData.utils.isUndefined(opts.suffix)) { - if (_jsData.utils.isUndefined(mapper.suffix)) { - 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 self = 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, self.httpConfig); - config.data = payload; - config.cache = cache; - config.timeout = timeout; - if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { - config.url += '/'; - } - config.method = config.method.toUpperCase(); - var suffix = config.suffix || opts.suffix || self.suffix; - if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { - config.url += suffix; - } - - 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 (self.log) { - self.dbg('debug', str, data); - } - return data; - } else { - if (self.error) { - self.error('\'FAILED: ' + str, data); - } - return _jsData.utils.reject(data); - } - } - - if (!self.http) { - throw new Error('You have not configured this adapter with an http library!'); - } - - return _jsData.utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { - config = _config || config; - if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { - return self.fetch(config, opts).then(logResponse, logResponse); - } - return self.http(config).then(logResponse, logResponse).catch(function (err) { - return self.responseError(err, config, opts); - }); - }).then(function (response) { - return _jsData.utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { - return _response || response; - }); - }); - }, - - - /** - * TODO - * - * @name HttpAdapter#POST - * @method - * @param {*} url TODO - * @param {Object} data TODO - * @param {Object} config TODO - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - POST: function POST(url, data, config, opts) { - var self = 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(self[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'POST'; - self.dbg(op, url, data, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterPOST lifecycle hook - op = opts.op = 'afterPOST'; - return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - - /** - * TODO - * - * @name HttpAdapter#PUT - * @method - * @param {*} url TODO - * @param {Object} data TODO - * @param {Object} config TODO - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - PUT: function PUT(url, data, config, opts) { - var self = 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(self[op](url, data, config, opts)).then(function (_config) { - // Allow re-assignment from lifecycle hook - config = _jsData.utils.isUndefined(_config) ? config : _config; - op = opts.op = 'PUT'; - self.dbg(op, url, data, config, opts); - return self.HTTP(config, opts); - }).then(function (response) { - // afterPUT lifecycle hook - op = opts.op = 'afterPUT'; - return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { - // Allow re-assignment from lifecycle hook - return _jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - - /** - * TODO - * - * @name HttpAdapter#queryTransform - * @method - * @param {Object} mapper TODO - * @param {*} params TODO - * @param {*} opts TODO - * @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); - }, - - - /** - * TODO - * - * @name HttpAdapter#serialize - * @method - * @param {Object} mapper TODO - * @param {Object} data TODO - * @param {*} opts TODO - * @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] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - sum: function sum(mapper, field, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - if (!_jsData.utils.utils.isString(field)) { - throw new Error('field must be a string!'); - } - opts.params = self.getParams(opts); - opts.params.sum = field; - opts.suffix = self.getSuffix(mapper, opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - - return __super__.sum.call(self, mapper, field, query, opts); - }, - - - /** - * TODO - * - * @name HttpAdapter#update - * @method - * @param {Object} mapper TODO - * @param {*} id TODO - * @param {*} props TODO - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - update: function update(mapper, id, props, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.update.call(self, mapper, id, props, opts); - }, - - - /** - * TODO - * - * @name HttpAdapter#updateAll - * @method - * @param {Object} mapper TODO - * @param {Object} props TODO - * @param {Object} query TODO - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - updateAll: function updateAll(mapper, props, query, opts) { - var self = this; - query || (query = {}); - opts || (opts = {}); - opts.params = self.getParams(opts); - _jsData.utils.deepMixIn(opts.params, query); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.updateAll.call(self, mapper, props, query, opts); - }, - - - /** - * Update multiple records in batch. - * - * {@link HttpAdapter#beforeUpdateMany} will be called before calling - * {@link HttpAdapter#PUT}. - * {@link HttpAdapter#afterUpdateMany} will be called after calling - * {@link HttpAdapter#PUT}. - * - * @name HttpAdapter#updateMany - * @method - * @param {Object} mapper The mapper. - * @param {Array} records Array of property objects to send as the payload. - * @param {Object} [opts] Configuration options. - * @param {string} [opts.params] TODO - * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO - * @return {Promise} - */ - updateMany: function updateMany(mapper, records, opts) { - var self = this; - opts || (opts = {}); - opts.params = self.getParams(opts); - opts.params = self.queryTransform(mapper, opts.params, opts); - opts.suffix = self.getSuffix(mapper, opts); - - return __super__.updateMany.call(self, 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 adapter = new HttpAdapter() - * var store = new DataStore() - * - * store.registerAdapter('http', adapter, { default: true }) - * store.defineMapper('school') - * - * // GET /reports/schools/:school_id/teachers - * addAction('getTeacherReports', { - * basePath: 'reports/schools', - * pathname: 'teachers', - * method: 'GET' - * })(store.getMapper('school')) - * - * // /reports/schools/1234/teachers - * store.getMapper('school').getTeacherReports(1234).then(function (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] - * @param {string} [opts.pathname] - * @param {Function} [opts.request] - * @param {Function} [opts.response] - * @param {Function} [opts.responseError] - * @return {Function} Decoration function, which should be passed the mapper to - * decorate when invoked. - */ - exports.addAction = 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 self = this; - if (_jsData.utils.isObject(id)) { - _opts = id; - } - _opts = _opts || {}; - var adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http'); - var config = {}; - _jsData.utils.fillIn(config, opts); - if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { - _opts.endpoint = config.endpoint; - } - if (typeof _opts.getEndpoint === 'function') { - config.url = _opts.getEndpoint(self, _opts); - } else { - var args = [_opts.basePath || self.basePath || adapter.basePath, adapter.getEndpoint(self, _jsData.utils.isSorN(id) ? id : null, _opts)]; - if (_jsData.utils.isSorN(id)) { - args.push(id); - } - args.push(opts.pathname || name); - config.url = makePath.apply(null, args); - } - config.method = config.method || 'GET'; - config.mapper = self.name; - _jsData.utils.deepMixIn(config, _opts); - return _jsData.utils.resolve(config).then(_opts.request || opts.request).then(function (config) { - return adapter.HTTP(config); - }).then(function (data) { - if (data && data.config) { - data.config.mapper = self.name; - } - return data; - }).then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter() - * var store = new DataStore() - * - * store.registerAdapter('http', adapter, { 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(function (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. - */ - exports.addActions = function addActions(opts) { - opts || (opts = {}); - return function (mapper) { - _jsData.utils.forOwn(opts, function (value, key) { - exports.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. - */ - exports.version = { - beta: 5, - full: '3.0.0-beta.5', +'use strict'; + +var jsData = require('js-data'); +var jsDataAdapter = require('js-data-adapter'); + +var babelHelpers = {}; +babelHelpers.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; +}; +babelHelpers; + +var axios = require('axios'); +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 (window.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 __super__ = jsDataAdapter.Adapter.prototype; + +var DEFAULTS = { + // Default and user-defined settings + /** + * @name HttpAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + */ + forceTrailingSlash: false, + + /** + * @name HttpAdapter#http + * @type {Function} + */ + http: axios, + + /** + * @name HttpAdapter#httpConfig + * @type {Object} + */ + httpConfig: {}, + + /** + * @name HttpAdapter#suffix + * @type {string} + */ + suffix: '', + + /** + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + */ + useFetch: false +}; + +/** + * HttpAdapter class. + * + * @class HttpAdapter + * @extends Adapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.basePath=''] TODO + * @param {boolean} [opts.debug=false] TODO + * @param {boolean} [opts.forceTrailingSlash=false] TODO + * @param {Object} [opts.http=axios] TODO + * @param {Object} [opts.httpConfig={}] TODO + * @param {string} [opts.suffix=''] TODO + * @param {boolean} [opts.useFetch=false] TODO + */ +function HttpAdapter(opts) { + var self = this; + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS); + jsDataAdapter.Adapter.call(self, opts); +} + +/** + * @name module:js-data-http.HttpAdapter + * @see HttpAdapter + */ + +// Setup prototype inheritance from Adapter +HttpAdapter.prototype = Object.create(jsDataAdapter.Adapter.prototype, { + constructor: { + value: HttpAdapter, + enumerable: false, + writable: true, + configurable: true + } +}); + +Object.defineProperty(HttpAdapter, '__super__', { + configurable: true, + value: jsDataAdapter.Adapter +}); + +/** + * Alternative to ES6 class syntax for extending `HttpAdapter`. + * + * @example Using the ES2015 class syntax. + * class MyHttpAdapter extends HttpAdapter {...} + * const adapter = new MyHttpAdapter() + * + * @example Using {@link HttpAdapter.extend}. + * var instanceProps = {...} + * var classProps = {...} + * + * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) + * var adapter = new MyHttpAdapter() + * + * @name HttpAdapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `HttpAdapter`. + */ +HttpAdapter.extend = jsData.utils.extend; + +jsData.utils.addHiddenPropsToTarget(HttpAdapter.prototype, { + /** + * @name HttpAdapter#afterDEL + * @method + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterDEL: jsDataAdapter.noop2, + + /** + * @name HttpAdapter#afterGET + * @method + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterGET: jsDataAdapter.noop2, + + /** + * @name HttpAdapter#afterHTTP + * @method + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterHTTP: jsDataAdapter.noop2, + + /** + * @name HttpAdapter#afterPOST + * @method + * @param {string} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterPOST: jsDataAdapter.noop2, + + /** + * @name HttpAdapter#afterPUT + * @method + * @param {string} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterPUT: jsDataAdapter.noop2, + + /** + * @name HttpAdapter#beforeDEL + * @method + * @param {Object} url + * @param {Object} config + * @param {Object} opts + */ + beforeDEL: jsDataAdapter.noop, + + /** + * @name HttpAdapter#beforeGET + * @method + * @param {Object} url + * @param {Object} config + * @param {Object} opts + */ + beforeGET: jsDataAdapter.noop, + + /** + * @name HttpAdapter#beforeHTTP + * @method + * @param {Object} config + * @param {Object} opts + */ + beforeHTTP: jsDataAdapter.noop, + + /** + * @name HttpAdapter#beforePOST + * @method + * @param {Object} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + */ + beforePOST: jsDataAdapter.noop, + + /** + * @name HttpAdapter#beforePUT + * @method + * @param {Object} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + */ + beforePUT: jsDataAdapter.noop, + + _count: function _count(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('create', mapper, props, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('createMany', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var self = this; + return self.DEL(self.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var self = this; + return self.DEL(self.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var self = this; + return self.GET(self.getPath('find', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var self = this; + return self.GET(self.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var self = this; + return self.PUT(self.getPath('update', mapper, id, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var self = this; + return self.PUT(self.getPath('updateAll', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var self = this; + return self.PUT(self.getPath('updateMany', mapper, null, opts), self.serialize(mapper, records, opts), opts).then(function (response) { + return self._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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params.count = true; + opts.suffix = self.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.count.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.create.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.createMany.call(self, 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 self = 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(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'DEL'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroy.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroyAll.call(self, 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. + * @param {Object} [opts] Configuration options. + */ + fetch: function (_fetch) { + function fetch(_x, _x2) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config, opts) { + 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(new Request(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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.find.call(self, 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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.suffix = self.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.findAll.call(self, mapper, query, opts); + }, + + + /** + * TODO + * + * @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 self = 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(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'GET'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {boolean} opts TODO + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var self = 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(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return { + v: false + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; + } + } + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method TODO + * @param {Object} mapper TODO + * @param {(string|number)?} id TODO + * @param {Object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + var self = this; + opts || (opts = {}); + var args = [jsData.utils.isUndefined(opts.basePath) ? jsData.utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath : opts.basePath, self.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 (jsData.utils.isUndefined(opts.params)) { + return {}; + } + return jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (jsData.utils.isUndefined(opts.suffix)) { + if (jsData.utils.isUndefined(mapper.suffix)) { + 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 self = 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, self.httpConfig); + config.data = payload; + config.cache = cache; + config.timeout = timeout; + if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || self.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + 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 (self.log) { + self.dbg('debug', str, data); + } + return data; + } else { + if (self.error) { + self.error('\'FAILED: ' + str, data); + } + return jsData.utils.reject(data); + } + } + + if (!self.http) { + throw new Error('You have not configured this adapter with an http library!'); + } + + return jsData.utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { + return self.fetch(config, opts).then(logResponse, logResponse); + } + return self.http(config).then(logResponse, logResponse).catch(function (err) { + return self.responseError(err, config, opts); + }); + }).then(function (response) { + return jsData.utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { + return _response || response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#POST + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var self = 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(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'POST'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#PUT + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var self = 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(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'PUT'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#queryTransform + * @method + * @param {Object} mapper TODO + * @param {*} params TODO + * @param {*} opts TODO + * @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); + }, + + + /** + * TODO + * + * @name HttpAdapter#serialize + * @method + * @param {Object} mapper TODO + * @param {Object} data TODO + * @param {*} opts TODO + * @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] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + if (!jsData.utils.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = self.getParams(opts); + opts.params.sum = field; + opts.suffix = self.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.sum.call(self, mapper, field, query, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#update + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {*} props TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.update.call(self, mapper, id, props, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#updateAll + * @method + * @param {Object} mapper TODO + * @param {Object} props TODO + * @param {Object} query TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateAll.call(self, mapper, props, query, opts); + }, + + + /** + * Update multiple records in batch. + * + * {@link HttpAdapter#beforeUpdateMany} will be called before calling + * {@link HttpAdapter#PUT}. + * {@link HttpAdapter#afterUpdateMany} will be called after calling + * {@link HttpAdapter#PUT}. + * + * @name HttpAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} records Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateMany.call(self, 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 adapter = new HttpAdapter() + * var store = new DataStore() + * + * store.registerAdapter('http', adapter, { default: true }) + * store.defineMapper('school') + * + * // GET /reports/schools/:school_id/teachers + * addAction('getTeacherReports', { + * basePath: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * })(store.getMapper('school')) + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then(function (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] + * @param {string} [opts.pathname] + * @param {Function} [opts.request] + * @param {Function} [opts.response] + * @param {Function} [opts.responseError] + * @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' : babelHelpers.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 self = this; + if (jsData.utils.isObject(id)) { + _opts = id; + } + _opts = _opts || {}; + var adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http'); + var config = {}; + jsData.utils.fillIn(config, opts); + if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { + _opts.endpoint = config.endpoint; + } + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(self, _opts); + } else { + var args = [_opts.basePath || self.basePath || adapter.basePath, adapter.getEndpoint(self, jsData.utils.isSorN(id) ? id : null, _opts)]; + if (jsData.utils.isSorN(id)) { + args.push(id); + } + args.push(opts.pathname || name); + config.url = makePath.apply(null, args); + } + config.method = config.method || 'GET'; + config.mapper = self.name; + jsData.utils.deepMixIn(config, _opts); + return jsData.utils.resolve(config).then(_opts.request || opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = self.name; + } + return data; + }).then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter() + * var store = new DataStore() + * + * store.registerAdapter('http', adapter, { 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(function (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 = { + beta: 6, + full: '3.0.0-beta.6', 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 adapter = new HttpAdapter() - * - * @example CommonJS - * var HttpAdapter = require('js-data-Http').HttpAdapter - * var adapter = new HttpAdapter() - * - * @example ES2015 Modules - * import {HttpAdapter} from 'js-data-Http' - * const adapter = new HttpAdapter() - * - * @example AMD - * define('myApp', ['js-data-Http'], function (JSDataHttp) { - * var HttpAdapter = JSDataHttp.HttpAdapter - * var adapter = new HttpAdapter() - * - * // ... - * }) - * - * @module js-data-http - */ - exports.default = HttpAdapter; - -/***/ }, -/* 1 */ -/***/ function(module, exports) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_1__; - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - (function (global, factory) { - true ? factory(exports, __webpack_require__(1)) : - typeof define === 'function' && define.amd ? define('js-data-adapter', ['exports', 'js-data'], factory) : - (factory((global.Adapter = global.Adapter || {}),global.JSData)); - }(this, function (exports,jsData) { 'use strict'; - - var babelHelpers = {}; - babelHelpers.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; - }; - - babelHelpers.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; - }; - - babelHelpers.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"); - } - }; - }(); - - babelHelpers; - - var noop = function noop() { - var self = this; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var opts = args[args.length - 1]; - self.dbg.apply(self, [opts.op].concat(args)); - return jsData.utils.resolve(); - }; - - var noop2 = function noop2() { - var self = this; - - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - var opts = args[args.length - 2]; - self.dbg.apply(self, [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) { - return jsData.utils.omit(props, mapper.relationFields || []); - }; - - var DEFAULTS = { - /** - * 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 - * @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) { - var self = this; - opts || (opts = {}); - jsData.utils.fillIn(opts, DEFAULTS); - jsData.utils.fillIn(self, opts); - } - - var reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where']; - - /** - * Response object used when `raw` is `true`. May contain other fields in - * addition to `data`. - * - * @class Response - */ - function Response(data, meta, op) { - var self = this; - meta || (meta = {}); - - /** - * Response data. - * - * @name Response#data - * @type {*} - */ - self.data = data; - - jsData.utils.fillIn(self, meta); - - /** - * The operation for which the response was created. - * - * @name Response#op - * @type {string} - */ - self.op = op; - } - - /** - * Alternative to ES6 class syntax for extending `Adapter`. - * - * @name Adapter.extend - * @method - * @param {Object} [instanceProps] Properties that will be added to the - * prototype of the subclass. - * @param {Object} [classProps] Properties that will be added as static - * properties to the subclass itself. - * @return {Object} Subclass of `Adapter`. - */ - Adapter.extend = jsData.utils.extend; - - jsData.utils.addHiddenPropsToTarget(Adapter.prototype, { - /** - * 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, - - /** - * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`. - * - * @name Adapter#dbg - * @method - */ - dbg: function dbg() { - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - this.log.apply(this, ['debug'].concat(args)); - }, - - - /** - * 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 self = this; - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeCount lifecycle hook - op = opts.op = 'beforeCount'; - return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'count'; - self.dbg(op, mapper, query, opts); - return jsData.utils.resolve(self._count(mapper, query, opts)); - }).then(function (results) { - var _results = babelHelpers.slicedToArray(results, 2); - - var data = _results[0]; - var result = _results[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = self.respond(response, opts); - - // afterCount lifecycle hook - op = opts.op = 'afterCount'; - return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreate lifecycle hook - op = opts.op = 'beforeCreate'; - return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = withoutRelations(mapper, props); - op = opts.op = 'create'; - self.dbg(op, mapper, props, opts); - return jsData.utils.resolve(self._create(mapper, props, opts)); - }).then(function (results) { - var _results2 = babelHelpers.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 = self.respond(response, opts); - - // afterCreate lifecycle hook - op = opts.op = 'afterCreate'; - return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - props || (props = {}); - opts || (opts = {}); - - // beforeCreateMany lifecycle hook - op = opts.op = 'beforeCreateMany'; - return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = props.map(function (record) { - return withoutRelations(mapper, record); - }); - op = opts.op = 'createMany'; - self.dbg(op, mapper, props, opts); - return jsData.utils.resolve(self._createMany(mapper, props, opts)); - }).then(function (results) { - var _results3 = babelHelpers.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 = self.respond(response, opts); - - // afterCreateMany lifecycle hook - op = opts.op = 'afterCreateMany'; - return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - opts || (opts = {}); - - // beforeDestroy lifecycle hook - op = opts.op = 'beforeDestroy'; - return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'destroy'; - self.dbg(op, mapper, id, opts); - return jsData.utils.resolve(self._destroy(mapper, id, opts)); - }).then(function (results) { - var _results4 = babelHelpers.slicedToArray(results, 2); - - var data = _results4[0]; - var result = _results4[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroy'); - response = self.respond(response, opts); - - // afterDestroy lifecycle hook - op = opts.op = 'afterDestroy'; - return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - var op = void 0; - query || (query = {}); - opts || (opts = {}); - - // beforeDestroyAll lifecycle hook - op = opts.op = 'beforeDestroyAll'; - return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'destroyAll'; - self.dbg(op, mapper, query, opts); - return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); - }).then(function (results) { - var _results5 = babelHelpers.slicedToArray(results, 2); - - var data = _results5[0]; - var result = _results5[1]; - - result || (result = {}); - var response = new Response(data, result, 'destroyAll'); - response = self.respond(response, opts); - - // afterDestroyAll lifecycle hook - op = opts.op = 'afterDestroyAll'; - return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - }, - - - /** - * Load a belongsTo relationship. - * - * Override with care. - * - * @name Adapter#loadBelongsTo - * @method - * @return {Promise} - */ - loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { - var self = this; - var relationDef = def.getRelation(); - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - var _ret = function () { - var record = records; - return { - v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { - def.setLocalField(record, relatedItem); - }) - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; - } else { - var keys = records.map(function (record) { - return self.makeBelongsToForeignKey(mapper, def, record); - }).filter(function (key) { - return key; - }); - return self.findAll(relationDef, { - where: babelHelpers.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 self = this; - var record = void 0, - op = void 0; - opts || (opts = {}); - opts.with || (opts.with = []); - - // beforeFind lifecycle hook - op = opts.op = 'beforeFind'; - return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'find'; - self.dbg(op, mapper, id, opts); - return jsData.utils.resolve(self._find(mapper, id, opts)); - }).then(function (results) { - var _results6 = babelHelpers.slicedToArray(results, 1); - - var _record = _results6[0]; - - if (!_record) { - return; - } - record = _record; - 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 = self.loadHasOne(mapper, def, record, __opts); - } else { - task = self.loadHasMany(mapper, def, record, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = self.loadHasManyLocalKeys(mapper, def, record, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = self.loadHasManyForeignKeys(mapper, def, record, __opts); - } else if (def.type === 'belongsTo') { - task = self.loadBelongsTo(mapper, def, record, __opts); - } - if (task) { - tasks.push(task); - } - }); - - return Promise.all(tasks); - }).then(function () { - var response = new Response(record, {}, 'find'); - response.found = record ? 1 : 0; - response = self.respond(response, opts); - - // afterFind lifecycle hook - op = opts.op = 'afterFind'; - return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - opts || (opts = {}); - opts.with || (opts.with = []); - - var records = []; - 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(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'findAll'; - self.dbg(op, mapper, query, opts); - return jsData.utils.resolve(self._findAll(mapper, query, opts)); - }).then(function (results) { - var _results7 = babelHelpers.slicedToArray(results, 1); - - var _records = _results7[0]; - - _records || (_records = []); - records = _records; - 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 = self.loadHasMany(mapper, def, records, __opts); - } else { - task = self.loadHasOne(mapper, def, records, __opts); - } - } else if (def.type === 'hasMany' && def.localKeys) { - task = self.loadHasManyLocalKeys(mapper, def, records, __opts); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = self.loadHasManyForeignKeys(mapper, def, records, __opts); - } else if (def.type === 'belongsTo') { - task = self.loadBelongsTo(mapper, def, records, __opts); - } - if (task) { - tasks.push(task); - } - }); - return Promise.all(tasks); - }).then(function () { - var response = new Response(records, {}, 'findAll'); - response.found = records.length; - response = self.respond(response, opts); - - // afterFindAll lifecycle hook - op = opts.op = 'afterFindAll'; - return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 jsData.utils.isUndefined(opts[opt]) ? 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 self = this; - var singular = false; - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - singular = true; - records = [records]; - } - var IDs = records.map(function (record) { - return self.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 self.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 self = this; - var record = void 0; - var relatedMapper = def.getRelation(); - - if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { - record = records; - } - - if (record) { - return self.findAll(relatedMapper, { - where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { - 'in': self.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(self.self.makeHasManyLocalKeys(mapper, def, record)); - }); - return { - v: self.findAll(relatedMapper, { - where: babelHelpers.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' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v; - } - }, - loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { - var self = 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 self.findAll(def.getRelation(), { - where: babelHelpers.defineProperty({}, def.foreignKeys, { - 'contains': self.makeHasManyForeignKeys(mapper, def, record) - }) - }, __opts).then(function (relatedItems) { - def.setLocalField(record, relatedItems); - }); - } else { - return self.findAll(relatedMapper, { - where: babelHelpers.defineProperty({}, def.foreignKeys, { - 'isectNotEmpty': records.map(function (record) { - return self.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]); - } - }); - }); - }, - - - /** - * Logging utility method. Override this method if you want to send log - * messages to something other than the console. - * - * @name Adapter#log - * @method - * @param {string} level Log level. - * @param {...*} values Values to log. - */ - log: function log(level) { - for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { - args[_key4 - 1] = arguments[_key4]; - } - - if (level && !args.length) { - args.push(level); - level = 'debug'; - } - if (level === 'debug' && !this.debug) { - return; - } - var prefix = level.toUpperCase() + ': (Adapter)'; - if (console[level]) { - var _console; - - (_console = console)[level].apply(_console, [prefix].concat(args)); - } else { - var _console2; - - (_console2 = console).log.apply(_console2, [prefix].concat(args)); - } - }, - - - /** - * 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 self = 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(self[op](mapper, field, query, opts)).then(function () { - // Allow for re-assignment from lifecycle hook - op = opts.op = 'sum'; - self.dbg(op, mapper, field, query, opts); - return jsData.utils.resolve(self._sum(mapper, field, query, opts)); - }).then(function (results) { - var _results8 = babelHelpers.slicedToArray(results, 2); - - var data = _results8[0]; - var result = _results8[1]; - - result || (result = {}); - var response = new Response(data, result, op); - response = self.respond(response, opts); - - // afterSum lifecycle hook - op = opts.op = 'afterSum'; - return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - props || (props = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdate lifecycle hook - op = opts.op = 'beforeUpdate'; - return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = withoutRelations(mapper, props); - op = opts.op = 'update'; - self.dbg(op, mapper, id, props, opts); - return jsData.utils.resolve(self._update(mapper, id, props, opts)); - }).then(function (results) { - var _results9 = babelHelpers.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 = self.respond(response, opts); - - // afterUpdate lifecycle hook - op = opts.op = 'afterUpdate'; - return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = this; - props || (props = {}); - query || (query = {}); - opts || (opts = {}); - var op = void 0; - - // beforeUpdateAll lifecycle hook - op = opts.op = 'beforeUpdateAll'; - return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = jsData.utils.isUndefined(_props) ? props : _props; - props = withoutRelations(mapper, props); - op = opts.op = 'updateAll'; - self.dbg(op, mapper, props, query, opts); - return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); - }).then(function (results) { - var _results10 = babelHelpers.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 = self.respond(response, opts); - - // afterUpdateAll lifecycle hook - op = opts.op = 'afterUpdateAll'; - return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? 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 self = 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(self[op](mapper, records, opts)).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = jsData.utils.isUndefined(_records) ? records : _records; - records = records.map(function (record) { - return withoutRelations(mapper, record); - }); - op = opts.op = 'updateMany'; - self.dbg(op, mapper, records, opts); - return jsData.utils.resolve(self._updateMany(mapper, records, opts)); - }).then(function (results) { - var _results11 = babelHelpers.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 = self.respond(response, opts); - - // afterUpdateMany lifecycle hook - op = opts.op = 'afterUpdateMany'; - return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { - // Allow for re-assignment from lifecycle hook - return jsData.utils.isUndefined(_response) ? response : _response; - }); - }); - } - }); - - exports.noop = noop; - exports.noop2 = noop2; - exports.unique = unique; - exports.withoutRelations = withoutRelations; - exports.Adapter = Adapter; - exports.reserved = reserved; - exports.Response = Response; - - })); - //# sourceMappingURL=js-data-adapter.js.map - -/***/ }, -/* 3 */ -/***/ function(module, exports) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_3__; - -/***/ } -/******/ ]) -}); -; + +/** + * 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 adapter = new HttpAdapter() + * + * @example CommonJS + * var HttpAdapter = require('js-data-Http').HttpAdapter + * var adapter = new HttpAdapter() + * + * @example ES2015 Modules + * import {HttpAdapter} from 'js-data-Http' + * const adapter = new HttpAdapter() + * + * @example AMD + * define('myApp', ['js-data-Http'], function (JSDataHttp) { + * var HttpAdapter = JSDataHttp.HttpAdapter + * var adapter = new HttpAdapter() + * + * // ... + * }) + * + * @module js-data-http + */ + +exports.HttpAdapter = HttpAdapter; +exports.addAction = addAction; +exports.addActions = addActions; +exports.version = version; //# sourceMappingURL=js-data-http-node.js.map \ No newline at end of file diff --git a/node/dist/js-data-http-node.js.map b/node/dist/js-data-http-node.js.map index cf2f9d7..d5569ff 100644 --- a/node/dist/js-data-http-node.js.map +++ b/node/dist/js-data-http-node.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 868649eaf68a9c6dd1fd","webpack:///./src/index.js","webpack:///external \"js-data\"","webpack:///./~/js-data-adapter/dist/js-data-adapter.js","webpack:///external \"axios\""],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;ACnCA;;AACA;;;;AAFA,KAAM,QAAQ,oBAAQ,CAAR,CAAd;;;AAQA,KAAI,WAAW,KAAf;;AAEA,KAAI;AACF,cAAW,UAAU,OAAO,KAA5B;AACD,EAFD,CAEE,OAAO,CAAP,EAAU,CAAE;;AAEd,UAAS,aAAT,CAAwB,KAAxB,EAA+B;AAC7B,UAAQ,SAAS,IAAT,IAAiB,UAAU,EAAnC;AACD;AACD,UAAS,IAAT,CAAe,KAAf,EAAsB,SAAtB,EAAiC;AAC/B,iBAAc,YAAY,EAA1B;AACA,UAAO,MAAM,MAAN,CAAa,aAAb,EAA4B,IAA5B,CAAiC,SAAjC,CAAP;AACD;AACD,UAAS,QAAT,GAA4B;AAAA,qCAAN,IAAM;AAAN,SAAM;AAAA;;AAC1B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ACA;AACA,cAAa,OAAO;AACpB,cAAa,QAAQ;AACrB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,uBAAsB;AACtB;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAsB;;AAEtB;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB;AACA,cAAa,OAAO;AACpB;AACA,eAAc,OAAO;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,6BAA6B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,8BAA8B,eAAe;AAC9E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,+BAA+B,eAAe;AAC7E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,gCAAgC,eAAe;AAChF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,iCAAiC,eAAe;AAC/E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAwE,eAAe;AACvF;AACA;;AAEA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA,QAAO;AACP,+CAA8C;AAC9C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,QAAO;AACP,gDAA+C;AAC/C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,iBAAgB,EAAE;AAClB;AACA;AACA,yBAAwB;AACxB;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA,oDAAmD;AACnD;AACA;AACA,kBAAiB;AACjB,gBAAe;AACf,cAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA,gBAAe;AACf;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA,gDAA+C;AAC/C;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,KAAK;AACpB;AACA;AACA,6FAA4F,eAAe;AAC3G;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,QAAO;AACP;;AAEA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;AACxB;AACA;;AAEA;AACA;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,EAAC;AACD,4C;;;;;;AC/mDA,gD","file":"./node/dist/js-data-http-node.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"js-data\"), require(\"axios\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"js-data\", \"axios\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"js-data\"), require(\"axios\")) : factory(root[\"js-data\"], root[\"axios\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_3__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\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/** WEBPACK FOOTER **\n ** webpack/bootstrap 868649eaf68a9c6dd1fd\n **/","/* global fetch:true Headers:true Request:true */\n\nconst axios = require('axios')\nimport {utils} from 'js-data'\nimport {\n Adapter,\n noop,\n noop2\n} from 'js-data-adapter'\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 (window.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 __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n // Default and user-defined settings\n /**\n * @name HttpAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n */\n forceTrailingSlash: false,\n\n /**\n * @name HttpAdapter#http\n * @type {Function}\n */\n http: axios,\n\n /**\n * @name HttpAdapter#httpConfig\n * @type {Object}\n */\n httpConfig: {},\n\n /**\n * @name HttpAdapter#suffix\n * @type {string}\n */\n suffix: '',\n\n /**\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {boolean} [opts.forceTrailingSlash=false] TODO\n * @param {Object} [opts.http=axios] TODO\n * @param {Object} [opts.httpConfig={}] TODO\n * @param {string} [opts.suffix=''] TODO\n * @param {boolean} [opts.useFetch=false] TODO\n */\nfunction HttpAdapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\nexports.HttpAdapter = HttpAdapter\n\n// Setup prototype inheritance from Adapter\nHttpAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: HttpAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(HttpAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `HttpAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyHttpAdapter extends HttpAdapter {...}\n * const adapter = new MyHttpAdapter()\n *\n * @example Using {@link HttpAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps)\n * var adapter = new MyHttpAdapter()\n *\n * @name HttpAdapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `HttpAdapter`.\n */\nHttpAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(HttpAdapter.prototype, {\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 const self = this\n return self.GET(\n self.getPath('count', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('create', mapper, props, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('createMany', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroy', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroyAll', mapper, null, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n const self = this\n return self.GET(\n self.getPath('find', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n return self.GET(\n self.getPath('sum', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n return self.PUT(\n self.getPath('update', mapper, id, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateAll', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateMany', mapper, null, opts),\n self.serialize(mapper, records, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params.count = true\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.count.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.create.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.createMany.call(self, 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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'DEL'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroy.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroyAll.call(self, 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 * @param {Object} [opts] Configuration options.\n */\n fetch (config, opts) {\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(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json().then(function (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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.find.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.findAll.call(self, mapper, query, opts)\n },\n\n /**\n * TODO\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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'GET'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {boolean} opts TODO\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n const self = this\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(function (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, function (value, key) {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(self.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 TODO\n * @param {Object} mapper TODO\n * @param {(string|number)?} id TODO\n * @param {Object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const args = [\n utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath,\n self.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 (utils.isUndefined(opts.params)) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.suffix)) {\n if (utils.isUndefined(mapper.suffix)) {\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 self = this\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, self.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || self.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n function 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 (self.log) {\n self.dbg('debug', str, data)\n }\n return data\n } else {\n if (self.error) {\n self.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!self.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) {\n config = _config || config\n if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) {\n return self.fetch(config, opts).then(logResponse, logResponse)\n }\n return self.http(config).then(logResponse, logResponse).catch(function (err) {\n return self.responseError(err, config, opts)\n })\n }).then(function (response) {\n return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) {\n return _response || response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'POST'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'PUT'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {Object} mapper TODO\n * @param {*} params TODO\n * @param {*} opts TODO\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 * TODO\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {Object} mapper TODO\n * @param {Object} data TODO\n * @param {*} opts TODO\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n if (!utils.utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = self.getParams(opts)\n opts.params.sum = field\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.sum.call(self, mapper, field, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#update\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {*} props TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.update.call(self, mapper, id, props, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {Object} mapper TODO\n * @param {Object} props TODO\n * @param {Object} query TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateAll.call(self, mapper, props, query, opts)\n },\n\n /**\n * Update multiple records in batch.\n *\n * {@link HttpAdapter#beforeUpdateMany} will be called before calling\n * {@link HttpAdapter#PUT}.\n * {@link HttpAdapter#afterUpdateMany} will be called after calling\n * {@link HttpAdapter#PUT}.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} records Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateMany.call(self, 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { default: true })\n * store.defineMapper('school')\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * basePath: '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(function (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]\n * @param {string} [opts.pathname]\n * @param {Function} [opts.request]\n * @param {Function} [opts.response]\n * @param {Function} [opts.responseError]\n * @return {Function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexports.addAction = 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 const self = this\n if (utils.isObject(id)) {\n _opts = id\n }\n _opts = _opts || {}\n let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http')\n let config = {}\n utils.fillIn(config, opts)\n if (!_opts.hasOwnProperty('endpoint') && config.endpoint) {\n _opts.endpoint = config.endpoint\n }\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(self, _opts)\n } else {\n let args = [\n _opts.basePath || self.basePath || adapter.basePath,\n adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _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 config.method = config.method || 'GET'\n config.mapper = self.name\n utils.deepMixIn(config, _opts)\n return utils.resolve(config)\n .then(_opts.request || opts.request)\n .then(function (config) { return adapter.HTTP(config) })\n .then(function (data) {\n if (data && data.config) {\n data.config.mapper = self.name\n }\n return data\n })\n .then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { 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(function (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 */\nexports.addActions = function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n exports.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 */\nexports.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 adapter = new HttpAdapter()\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * @example ES2015 Modules\n * import {HttpAdapter} from 'js-data-Http'\n * const adapter = new HttpAdapter()\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * // ...\n * })\n *\n * @module js-data-http\n */\nexports.default = HttpAdapter\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"js-data\"\n ** module id = 1\n ** module chunks = 0\n **/","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-data')) :\n typeof define === 'function' && define.amd ? define('js-data-adapter', ['exports', 'js-data'], factory) :\n (factory((global.Adapter = global.Adapter || {}),global.JSData));\n}(this, function (exports,jsData) { 'use strict';\n\n var babelHelpers = {};\n babelHelpers.typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n };\n\n babelHelpers.defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n };\n\n babelHelpers.slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n }();\n\n babelHelpers;\n\n var noop = function noop() {\n var self = this;\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var opts = args[args.length - 1];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var noop2 = function noop2() {\n var self = this;\n\n for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n var opts = args[args.length - 2];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var unique = function unique(array) {\n var seen = {};\n var 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\n var withoutRelations = function withoutRelations(mapper, props) {\n return jsData.utils.omit(props, mapper.relationFields || []);\n };\n\n var 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 * @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 */\n function Adapter(opts) {\n var self = this;\n opts || (opts = {});\n jsData.utils.fillIn(opts, DEFAULTS);\n jsData.utils.fillIn(self, opts);\n }\n\n var reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where'];\n\n /**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\n function Response(data, meta, op) {\n var self = this;\n meta || (meta = {});\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n self.data = data;\n\n jsData.utils.fillIn(self, meta);\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n self.op = op;\n }\n\n /**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\n Adapter.extend = jsData.utils.extend;\n\n jsData.utils.addHiddenPropsToTarget(Adapter.prototype, {\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 * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg: function dbg() {\n for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n\n this.log.apply(this, ['debug'].concat(args));\n },\n\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: function count(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._count(mapper, query, opts));\n }).then(function (results) {\n var _results = babelHelpers.slicedToArray(results, 2);\n\n var data = _results[0];\n var result = _results[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function create(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'create';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._create(mapper, props, opts));\n }).then(function (results) {\n var _results2 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results2[0];\n var result = _results2[1];\n\n result || (result = {});\n var response = new Response(data, result, 'create');\n response.created = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function createMany(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = props.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'createMany';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._createMany(mapper, props, opts));\n }).then(function (results) {\n var _results3 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results3[0];\n var result = _results3[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'createMany');\n response.created = data.length;\n response = self.respond(response, opts);\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function destroy(mapper, id, opts) {\n var self = this;\n var op = void 0;\n opts || (opts = {});\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._destroy(mapper, id, opts));\n }).then(function (results) {\n var _results4 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results4[0];\n var result = _results4[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroy');\n response = self.respond(response, opts);\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function destroyAll(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._destroyAll(mapper, query, opts));\n }).then(function (results) {\n var _results5 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results5[0];\n var result = _results5[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroyAll');\n response = self.respond(response, opts);\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function loadBelongsTo(mapper, def, records, __opts) {\n var self = this;\n var relationDef = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n var _ret = function () {\n var record = records;\n return {\n v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem);\n })\n };\n }();\n\n if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === \"object\") return _ret.v;\n } else {\n var keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record);\n }).filter(function (key) {\n return key;\n });\n return self.findAll(relationDef, {\n where: babelHelpers.defineProperty({}, relationDef.idAttribute, {\n 'in': keys\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem);\n }\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: function find(mapper, id, opts) {\n var self = this;\n var record = void 0,\n op = void 0;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._find(mapper, id, opts));\n }).then(function (results) {\n var _results6 = babelHelpers.slicedToArray(results, 1);\n\n var _record = _results6[0];\n\n if (!_record) {\n return;\n }\n record = _record;\n var tasks = [];\n\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts);\n } else {\n task = self.loadHasMany(mapper, def, record, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(record, {}, 'find');\n response.found = record ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function findAll(mapper, query, opts) {\n var self = this;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n var records = [];\n var op = void 0;\n var activeWith = opts._activeWith;\n\n if (jsData.utils.isObject(activeWith)) {\n var activeQuery = activeWith.query || {};\n if (activeWith.replace) {\n query = activeQuery;\n } else {\n jsData.utils.deepFillIn(query, activeQuery);\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._findAll(mapper, query, opts));\n }).then(function (results) {\n var _results7 = babelHelpers.slicedToArray(results, 1);\n\n var _records = _results7[0];\n\n _records || (_records = []);\n records = _records;\n var tasks = [];\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts);\n } else {\n task = self.loadHasOne(mapper, def, records, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(records, {}, 'findAll');\n response.found = records.length;\n response = self.respond(response, opts);\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function getOpt(opt, opts) {\n opts || (opts = {});\n return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]);\n },\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: function loadHasMany(mapper, def, records, __opts) {\n var self = this;\n var singular = false;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n singular = true;\n records = [records];\n }\n var IDs = records.map(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record);\n });\n var query = {\n where: {}\n };\n var 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(function (id) {\n return id;\n });\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n var attached = [];\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems;\n } else {\n relatedItems.forEach(function (relatedItem) {\n if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem);\n }\n });\n }\n def.setLocalField(record, attached);\n });\n });\n },\n loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) {\n var self = this;\n var record = void 0;\n var relatedMapper = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n var _ret2 = function () {\n var localKeys = [];\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record));\n });\n return {\n v: self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': unique(localKeys).filter(function (x) {\n return x;\n })\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n var attached = [];\n var itemKeys = jsData.utils.get(item, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n relatedItems.forEach(function (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 if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === \"object\") return _ret2.v;\n }\n },\n loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) {\n var self = this;\n var relatedMapper = def.getRelation();\n var idAttribute = mapper.idAttribute;\n var record = void 0;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(def.getRelation(), {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record);\n })\n })\n }, __opts).then(function (relatedItems) {\n var foreignKeysField = def.foreignKeys;\n records.forEach(function (record) {\n var _relatedItems = [];\n var id = jsData.utils.get(record, idAttribute);\n relatedItems.forEach(function (relatedItem) {\n var foreignKeys = jsData.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 /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne: function loadHasOne(mapper, def, records, __opts) {\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n records = [records];\n }\n return this.loadHasMany(mapper, def, records, __opts).then(function () {\n records.forEach(function (record) {\n var relatedData = def.getLocalField(record);\n if (jsData.utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0]);\n }\n });\n });\n },\n\n\n /**\n * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log: function log(level) {\n for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n args[_key4 - 1] = arguments[_key4];\n }\n\n if (level && !args.length) {\n args.push(level);\n level = 'debug';\n }\n if (level === 'debug' && !this.debug) {\n return;\n }\n var prefix = level.toUpperCase() + ': (Adapter)';\n if (console[level]) {\n var _console;\n\n (_console = console)[level].apply(_console, [prefix].concat(args));\n } else {\n var _console2;\n\n (_console2 = console).log.apply(_console2, [prefix].concat(args));\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: function makeHasManyForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\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: function makeHasManyLocalKeys(mapper, def, record) {\n var localKeys = [];\n var itemKeys = jsData.utils.get(record, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n localKeys = localKeys.concat(itemKeys);\n return unique(localKeys).filter(function (x) {\n return x;\n });\n },\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: function makeHasManyForeignKeys(mapper, def, record) {\n return jsData.utils.get(record, mapper.idAttribute);\n },\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: function makeBelongsToForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\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: function sum(mapper, field, query, opts) {\n var self = this;\n var op = void 0;\n if (!jsData.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 jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum';\n self.dbg(op, mapper, field, query, opts);\n return jsData.utils.resolve(self._sum(mapper, field, query, opts));\n }).then(function (results) {\n var _results8 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results8[0];\n var result = _results8[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum';\n return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function respond(response, opts) {\n return this.getOpt('raw', opts) ? response : response.data;\n },\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: function update(mapper, id, props, opts) {\n var self = this;\n props || (props = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'update';\n self.dbg(op, mapper, id, props, opts);\n return jsData.utils.resolve(self._update(mapper, id, props, opts));\n }).then(function (results) {\n var _results9 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results9[0];\n var result = _results9[1];\n\n result || (result = {});\n var response = new Response(data, result, 'update');\n response.updated = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function updateAll(mapper, props, query, opts) {\n var self = this;\n props || (props = {});\n query || (query = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'updateAll';\n self.dbg(op, mapper, props, query, opts);\n return jsData.utils.resolve(self._updateAll(mapper, props, query, opts));\n }).then(function (results) {\n var _results10 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results10[0];\n var result = _results10[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateAll');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\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: function updateMany(mapper, records, opts) {\n var self = this;\n records || (records = []);\n opts || (opts = {});\n var op = void 0;\n var idAttribute = mapper.idAttribute;\n\n records = records.filter(function (record) {\n return jsData.utils.get(record, idAttribute);\n });\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = jsData.utils.isUndefined(_records) ? records : _records;\n records = records.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'updateMany';\n self.dbg(op, mapper, records, opts);\n return jsData.utils.resolve(self._updateMany(mapper, records, opts));\n }).then(function (results) {\n var _results11 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results11[0];\n var result = _results11[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateMany');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n }\n });\n\n exports.noop = noop;\n exports.noop2 = noop2;\n exports.unique = unique;\n exports.withoutRelations = withoutRelations;\n exports.Adapter = Adapter;\n exports.reserved = reserved;\n exports.Response = Response;\n\n}));\n//# sourceMappingURL=js-data-adapter.js.map\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/js-data-adapter/dist/js-data-adapter.js\n ** module id = 2\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_3__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"axios\"\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"js-data-http-node.js","sources":["../../src/index.js"],"sourcesContent":["/* global fetch:true Headers:true Request:true */\n\nimport {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 (window.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 __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n // Default and user-defined settings\n /**\n * @name HttpAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n */\n forceTrailingSlash: false,\n\n /**\n * @name HttpAdapter#http\n * @type {Function}\n */\n http: axios,\n\n /**\n * @name HttpAdapter#httpConfig\n * @type {Object}\n */\n httpConfig: {},\n\n /**\n * @name HttpAdapter#suffix\n * @type {string}\n */\n suffix: '',\n\n /**\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {boolean} [opts.forceTrailingSlash=false] TODO\n * @param {Object} [opts.http=axios] TODO\n * @param {Object} [opts.httpConfig={}] TODO\n * @param {string} [opts.suffix=''] TODO\n * @param {boolean} [opts.useFetch=false] TODO\n */\nexport function HttpAdapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\n// Setup prototype inheritance from Adapter\nHttpAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: HttpAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(HttpAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `HttpAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyHttpAdapter extends HttpAdapter {...}\n * const adapter = new MyHttpAdapter()\n *\n * @example Using {@link HttpAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps)\n * var adapter = new MyHttpAdapter()\n *\n * @name HttpAdapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `HttpAdapter`.\n */\nHttpAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(HttpAdapter.prototype, {\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 const self = this\n return self.GET(\n self.getPath('count', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('create', mapper, props, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('createMany', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroy', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroyAll', mapper, null, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n const self = this\n return self.GET(\n self.getPath('find', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n return self.GET(\n self.getPath('sum', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n return self.PUT(\n self.getPath('update', mapper, id, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateAll', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateMany', mapper, null, opts),\n self.serialize(mapper, records, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params.count = true\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.count.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.create.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.createMany.call(self, 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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'DEL'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroy.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroyAll.call(self, 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 * @param {Object} [opts] Configuration options.\n */\n fetch (config, opts) {\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(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json().then(function (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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.find.call(self, 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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.findAll.call(self, mapper, query, opts)\n },\n\n /**\n * TODO\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 const self = this\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(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'GET'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {boolean} opts TODO\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n const self = this\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(function (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, function (value, key) {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(self.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 TODO\n * @param {Object} mapper TODO\n * @param {(string|number)?} id TODO\n * @param {Object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const args = [\n utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath,\n self.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 (utils.isUndefined(opts.params)) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.suffix)) {\n if (utils.isUndefined(mapper.suffix)) {\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 self = this\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, self.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || self.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n function 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 (self.log) {\n self.dbg('debug', str, data)\n }\n return data\n } else {\n if (self.error) {\n self.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!self.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) {\n config = _config || config\n if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) {\n return self.fetch(config, opts).then(logResponse, logResponse)\n }\n return self.http(config).then(logResponse, logResponse).catch(function (err) {\n return self.responseError(err, config, opts)\n })\n }).then(function (response) {\n return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) {\n return _response || response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'POST'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n const self = this\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(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'PUT'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {Object} mapper TODO\n * @param {*} params TODO\n * @param {*} opts TODO\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 * TODO\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {Object} mapper TODO\n * @param {Object} data TODO\n * @param {*} opts TODO\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] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n if (!utils.utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = self.getParams(opts)\n opts.params.sum = field\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.sum.call(self, mapper, field, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#update\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {*} props TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.update.call(self, mapper, id, props, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {Object} mapper TODO\n * @param {Object} props TODO\n * @param {Object} query TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateAll.call(self, mapper, props, query, opts)\n },\n\n /**\n * Update multiple records in batch.\n *\n * {@link HttpAdapter#beforeUpdateMany} will be called before calling\n * {@link HttpAdapter#PUT}.\n * {@link HttpAdapter#afterUpdateMany} will be called after calling\n * {@link HttpAdapter#PUT}.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} records Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateMany.call(self, 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { default: true })\n * store.defineMapper('school')\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * basePath: '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(function (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]\n * @param {string} [opts.pathname]\n * @param {Function} [opts.request]\n * @param {Function} [opts.response]\n * @param {Function} [opts.responseError]\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 const self = this\n if (utils.isObject(id)) {\n _opts = id\n }\n _opts = _opts || {}\n let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http')\n let config = {}\n utils.fillIn(config, opts)\n if (!_opts.hasOwnProperty('endpoint') && config.endpoint) {\n _opts.endpoint = config.endpoint\n }\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(self, _opts)\n } else {\n let args = [\n _opts.basePath || self.basePath || adapter.basePath,\n adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _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 config.method = config.method || 'GET'\n config.mapper = self.name\n utils.deepMixIn(config, _opts)\n return utils.resolve(config)\n .then(_opts.request || opts.request)\n .then(function (config) { return adapter.HTTP(config) })\n .then(function (data) {\n if (data && data.config) {\n data.config.mapper = self.name\n }\n return data\n })\n .then(_opts.response || opts.response, _opts.responseError || 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 adapter = new HttpAdapter()\n * var store = new DataStore()\n *\n * store.registerAdapter('http', adapter, { 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(function (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 adapter = new HttpAdapter()\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * @example ES2015 Modules\n * import {HttpAdapter} from 'js-data-Http'\n * const adapter = new HttpAdapter()\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter\n * var adapter = new HttpAdapter()\n *\n * // ...\n * })\n *\n * @module js-data-http\n */\n"],"names":["utils","Adapter","noop2","noop"],"mappings":";;;;;;;;;;;;;;AAIA,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,O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