diff --git a/.gitignore b/.gitignore index 9773bff..fe4bf3a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -dist/*.js -dist/*.map bower_components/ .idea/ diff --git a/dist/js-data-http.js b/dist/js-data-http.js new file mode 100644 index 0000000..f9c163d --- /dev/null +++ b/dist/js-data-http.js @@ -0,0 +1,4571 @@ +/*! +* js-data-http +* @version 3.0.0 - Homepage +* @copyright (c) 2014-2016 js-data-http project authors +* @license MIT +* +* @overview HTTP (XHR) adapter for js-data in the browser. +*/ +(function (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 commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + + + + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var axios = createCommonjsModule(function (module, exports) { +/* axios v0.16.2 | (c) 2017 by Matt Zabriskie */ +(function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(); +})(commonjsGlobal, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(1); + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + var bind = __webpack_require__(3); + var Axios = __webpack_require__(5); + var defaults = __webpack_require__(6); + + /** + * Create an instance of Axios + * + * @param {Object} defaultConfig The default config for the instance + * @return {Axios} A new instance of Axios + */ + function createInstance(defaultConfig) { + var context = new Axios(defaultConfig); + var instance = bind(Axios.prototype.request, context); + + // Copy axios.prototype to instance + utils$$1.extend(instance, Axios.prototype, context); + + // Copy context to instance + utils$$1.extend(instance, context); + + return instance; + } + + // Create the default instance to be exported + var axios = createInstance(defaults); + + // Expose Axios class to allow class inheritance + axios.Axios = Axios; + + // Factory for creating new instances + axios.create = function create(instanceConfig) { + return createInstance(utils$$1.merge(defaults, instanceConfig)); + }; + + // Expose Cancel & CancelToken + axios.Cancel = __webpack_require__(23); + axios.CancelToken = __webpack_require__(24); + axios.isCancel = __webpack_require__(20); + + // Expose all/spread + axios.all = function all(promises) { + return Promise.all(promises); + }; + axios.spread = __webpack_require__(25); + + module.exports = axios; + + // Allow use of default import syntax in TypeScript + module.exports.default = axios; + + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bind = __webpack_require__(3); + var isBuffer = __webpack_require__(4); + + /*global toString:true*/ + + // utils is a library of generic helper functions non-specific to axios + + var toString = Object.prototype.toString; + + /** + * Determine if a value is an Array + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Array, otherwise false + */ + function isArray(val) { + return toString.call(val) === '[object Array]'; + } + + /** + * Determine if a value is an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an ArrayBuffer, otherwise false + */ + function isArrayBuffer(val) { + return toString.call(val) === '[object ArrayBuffer]'; + } + + /** + * Determine if a value is a FormData + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an FormData, otherwise false + */ + function isFormData(val) { + return (typeof FormData !== 'undefined') && (val instanceof FormData); + } + + /** + * Determine if a value is a view on an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false + */ + function isArrayBufferView(val) { + var result; + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { + result = ArrayBuffer.isView(val); + } else { + result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); + } + return result; + } + + /** + * Determine if a value is a String + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a String, otherwise false + */ + function isString(val) { + return typeof val === 'string'; + } + + /** + * Determine if a value is a Number + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Number, otherwise false + */ + function isNumber(val) { + return typeof val === 'number'; + } + + /** + * Determine if a value is undefined + * + * @param {Object} val The value to test + * @returns {boolean} True if the value is undefined, otherwise false + */ + function isUndefined(val) { + return typeof val === 'undefined'; + } + + /** + * Determine if a value is an Object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Object, otherwise false + */ + function isObject(val) { + return val !== null && typeof val === 'object'; + } + + /** + * Determine if a value is a Date + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Date, otherwise false + */ + function isDate(val) { + return toString.call(val) === '[object Date]'; + } + + /** + * Determine if a value is a File + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a File, otherwise false + */ + function isFile(val) { + return toString.call(val) === '[object File]'; + } + + /** + * Determine if a value is a Blob + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Blob, otherwise false + */ + function isBlob(val) { + return toString.call(val) === '[object Blob]'; + } + + /** + * Determine if a value is a Function + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Function, otherwise false + */ + function isFunction(val) { + return toString.call(val) === '[object Function]'; + } + + /** + * Determine if a value is a Stream + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Stream, otherwise false + */ + function isStream(val) { + return isObject(val) && isFunction(val.pipe); + } + + /** + * Determine if a value is a URLSearchParams object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a URLSearchParams object, otherwise false + */ + function isURLSearchParams(val) { + return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; + } + + /** + * Trim excess whitespace off the beginning and end of a string + * + * @param {String} str The String to trim + * @returns {String} The String freed of excess whitespace + */ + function trim(str) { + return str.replace(/^\s*/, '').replace(/\s*$/, ''); + } + + /** + * Determine if we're running in a standard browser environment + * + * This allows axios to run in a web worker, and react-native. + * Both environments support XMLHttpRequest, but not fully standard globals. + * + * web workers: + * typeof window -> undefined + * typeof document -> undefined + * + * react-native: + * navigator.product -> 'ReactNative' + */ + function isStandardBrowserEnv() { + if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { + return false; + } + return ( + typeof window !== 'undefined' && + typeof document !== 'undefined' + ); + } + + /** + * Iterate over an Array or an Object invoking a function for each item. + * + * If `obj` is an Array callback will be called passing + * the value, index, and complete array for each item. + * + * If 'obj' is an Object callback will be called passing + * the value, key, and complete object for each property. + * + * @param {Object|Array} obj The object to iterate + * @param {Function} fn The callback to invoke for each item + */ + function forEach(obj, fn) { + // Don't bother if no value provided + if (obj === null || typeof obj === 'undefined') { + return; + } + + // Force an array if not already something iterable + if (typeof obj !== 'object' && !isArray(obj)) { + /*eslint no-param-reassign:0*/ + obj = [obj]; + } + + if (isArray(obj)) { + // Iterate over array values + for (var i = 0, l = obj.length; i < l; i++) { + fn.call(null, obj[i], i, obj); + } + } else { + // Iterate over object keys + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + fn.call(null, obj[key], key, obj); + } + } + } + } + + /** + * Accepts varargs expecting each argument to be an object, then + * immutably merges the properties of each object and returns result. + * + * When multiple objects contain the same key the later object in + * the arguments list will take precedence. + * + * Example: + * + * ```js + * var result = merge({foo: 123}, {foo: 456}); + * console.log(result.foo); // outputs 456 + * ``` + * + * @param {Object} obj1 Object to merge + * @returns {Object} Result of all merge properties + */ + function merge(/* obj1, obj2, obj3, ... */) { + var result = {}; + function assignValue(val, key) { + if (typeof result[key] === 'object' && typeof val === 'object') { + result[key] = merge(result[key], val); + } else { + result[key] = val; + } + } + + for (var i = 0, l = arguments.length; i < l; i++) { + forEach(arguments[i], assignValue); + } + return result; + } + + /** + * Extends object a by mutably adding to it the properties of object b. + * + * @param {Object} a The object to be extended + * @param {Object} b The object to copy properties from + * @param {Object} thisArg The object to bind function to + * @return {Object} The resulting value of object a + */ + function extend(a, b, thisArg) { + forEach(b, function assignValue(val, key) { + if (thisArg && typeof val === 'function') { + a[key] = bind(val, thisArg); + } else { + a[key] = val; + } + }); + return a; + } + + module.exports = { + isArray: isArray, + isArrayBuffer: isArrayBuffer, + isBuffer: isBuffer, + isFormData: isFormData, + isArrayBufferView: isArrayBufferView, + isString: isString, + isNumber: isNumber, + isObject: isObject, + isUndefined: isUndefined, + isDate: isDate, + isFile: isFile, + isBlob: isBlob, + isFunction: isFunction, + isStream: isStream, + isURLSearchParams: isURLSearchParams, + isStandardBrowserEnv: isStandardBrowserEnv, + forEach: forEach, + merge: merge, + extend: extend, + trim: trim + }; + + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + 'use strict'; + + module.exports = function bind(fn, thisArg) { + return function wrap() { + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + return fn.apply(thisArg, args); + }; + }; + + +/***/ }, +/* 4 */ +/***/ function(module, exports) { + + /*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh + * @license MIT + */ + + // The _isBuffer check is for Safari 5-7 support, because it's missing + // Object.prototype.constructor. Remove this eventually + module.exports = function (obj) { + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) + }; + + function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) + } + + // For Node v0.10 support. Remove this eventually. + function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) + } + + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var defaults = __webpack_require__(6); + var utils$$1 = __webpack_require__(2); + var InterceptorManager = __webpack_require__(17); + var dispatchRequest = __webpack_require__(18); + var isAbsoluteURL = __webpack_require__(21); + var combineURLs = __webpack_require__(22); + + /** + * Create a new instance of Axios + * + * @param {Object} instanceConfig The default config for the instance + */ + function Axios(instanceConfig) { + this.defaults = instanceConfig; + this.interceptors = { + request: new InterceptorManager(), + response: new InterceptorManager() + }; + } + + /** + * Dispatch a request + * + * @param {Object} config The config specific for this request (merged with this.defaults) + */ + Axios.prototype.request = function request(config) { + /*eslint no-param-reassign:0*/ + // Allow for axios('example/url'[, config]) a la fetch API + if (typeof config === 'string') { + config = utils$$1.merge({ + url: arguments[0] + }, arguments[1]); + } + + config = utils$$1.merge(defaults, this.defaults, { method: 'get' }, config); + config.method = config.method.toLowerCase(); + + // Support baseURL config + if (config.baseURL && !isAbsoluteURL(config.url)) { + config.url = combineURLs(config.baseURL, config.url); + } + + // Hook up interceptors middleware + var chain = [dispatchRequest, undefined]; + var promise = Promise.resolve(config); + + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { + chain.unshift(interceptor.fulfilled, interceptor.rejected); + }); + + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { + chain.push(interceptor.fulfilled, interceptor.rejected); + }); + + while (chain.length) { + promise = promise.then(chain.shift(), chain.shift()); + } + + return promise; + }; + + // Provide aliases for supported request methods + utils$$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, config) { + return this.request(utils$$1.merge(config || {}, { + method: method, + url: url + })); + }; + }); + + utils$$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, data, config) { + return this.request(utils$$1.merge(config || {}, { + method: method, + url: url, + data: data + })); + }; + }); + + module.exports = Axios; + + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + var normalizeHeaderName = __webpack_require__(7); + + var DEFAULT_CONTENT_TYPE = { + 'Content-Type': 'application/x-www-form-urlencoded' + }; + + function setContentTypeIfUnset(headers, value) { + if (!utils$$1.isUndefined(headers) && utils$$1.isUndefined(headers['Content-Type'])) { + headers['Content-Type'] = value; + } + } + + function getDefaultAdapter() { + var adapter; + if (typeof XMLHttpRequest !== 'undefined') { + // For browsers use XHR adapter + adapter = __webpack_require__(8); + } else if (typeof process !== 'undefined') { + // For node use HTTP adapter + adapter = __webpack_require__(8); + } + return adapter; + } + + var defaults = { + adapter: getDefaultAdapter(), + + transformRequest: [function transformRequest(data, headers) { + normalizeHeaderName(headers, 'Content-Type'); + if (utils$$1.isFormData(data) || + utils$$1.isArrayBuffer(data) || + utils$$1.isBuffer(data) || + utils$$1.isStream(data) || + utils$$1.isFile(data) || + utils$$1.isBlob(data) + ) { + return data; + } + if (utils$$1.isArrayBufferView(data)) { + return data.buffer; + } + if (utils$$1.isURLSearchParams(data)) { + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); + return data.toString(); + } + if (utils$$1.isObject(data)) { + setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); + return JSON.stringify(data); + } + return data; + }], + + transformResponse: [function transformResponse(data) { + /*eslint no-param-reassign:0*/ + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { /* Ignore */ } + } + return data; + }], + + timeout: 0, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN', + + maxContentLength: -1, + + validateStatus: function validateStatus(status) { + return status >= 200 && status < 300; + } + }; + + defaults.headers = { + common: { + 'Accept': 'application/json, text/plain, */*' + } + }; + + utils$$1.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { + defaults.headers[method] = {}; + }); + + utils$$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + defaults.headers[method] = utils$$1.merge(DEFAULT_CONTENT_TYPE); + }); + + module.exports = defaults; + + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + module.exports = function normalizeHeaderName(headers, normalizedName) { + utils$$1.forEach(headers, function processHeader(value, name) { + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { + headers[normalizedName] = value; + delete headers[name]; + } + }); + }; + + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + var settle = __webpack_require__(9); + var buildURL = __webpack_require__(12); + var parseHeaders = __webpack_require__(13); + var isURLSameOrigin = __webpack_require__(14); + var createError = __webpack_require__(10); + var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15); + + module.exports = function xhrAdapter(config) { + return new Promise(function dispatchXhrRequest(resolve, reject) { + var requestData = config.data; + var requestHeaders = config.headers; + + if (utils$$1.isFormData(requestData)) { + delete requestHeaders['Content-Type']; // Let the browser set it + } + + var request = new XMLHttpRequest(); + var loadEvent = 'onreadystatechange'; + var xDomain = false; + + // For IE 8/9 CORS support + // Only supports POST and GET calls and doesn't returns the response headers. + // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest. + if (("production") !== 'test' && + typeof window !== 'undefined' && + window.XDomainRequest && !('withCredentials' in request) && + !isURLSameOrigin(config.url)) { + request = new window.XDomainRequest(); + loadEvent = 'onload'; + xDomain = true; + request.onprogress = function handleProgress() {}; + request.ontimeout = function handleTimeout() {}; + } + + // HTTP basic authentication + if (config.auth) { + var username = config.auth.username || ''; + var password = config.auth.password || ''; + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); + } + + request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true); + + // Set the request timeout in MS + request.timeout = config.timeout; + + // Listen for ready state + request[loadEvent] = function handleLoad() { + if (!request || (request.readyState !== 4 && !xDomain)) { + return; + } + + // The request errored out and we didn't get a response, this will be + // handled by onerror instead + // With one exception: request that using file: protocol, most browsers + // will return status as 0 even though it's a successful request + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { + return; + } + + // Prepare the response + var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; + var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; + var response = { + data: responseData, + // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201) + status: request.status === 1223 ? 204 : request.status, + statusText: request.status === 1223 ? 'No Content' : request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // Clean up request + request = null; + }; + + // Handle low level network errors + request.onerror = function handleError() { + // Real errors are hidden from us by the browser + // onerror should only fire if it's a network error + reject(createError('Network Error', config, null, request)); + + // Clean up request + request = null; + }; + + // Handle timeout + request.ontimeout = function handleTimeout() { + reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', + request)); + + // Clean up request + request = null; + }; + + // Add xsrf header + // This is only done if running in a standard browser environment. + // Specifically not if we're in a web worker, or react-native. + if (utils$$1.isStandardBrowserEnv()) { + var cookies = __webpack_require__(16); + + // Add xsrf header + var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? + cookies.read(config.xsrfCookieName) : + undefined; + + if (xsrfValue) { + requestHeaders[config.xsrfHeaderName] = xsrfValue; + } + } + + // Add headers to the request + if ('setRequestHeader' in request) { + utils$$1.forEach(requestHeaders, function setRequestHeader(val, key) { + if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { + // Remove Content-Type if data is undefined + delete requestHeaders[key]; + } else { + // Otherwise add header to the request + request.setRequestHeader(key, val); + } + }); + } + + // Add withCredentials to request if needed + if (config.withCredentials) { + request.withCredentials = true; + } + + // Add responseType to request if needed + if (config.responseType) { + try { + request.responseType = config.responseType; + } catch (e) { + // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. + // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. + if (config.responseType !== 'json') { + throw e; + } + } + } + + // Handle progress if needed + if (typeof config.onDownloadProgress === 'function') { + request.addEventListener('progress', config.onDownloadProgress); + } + + // Not all browsers support upload events + if (typeof config.onUploadProgress === 'function' && request.upload) { + request.upload.addEventListener('progress', config.onUploadProgress); + } + + if (config.cancelToken) { + // Handle cancellation + config.cancelToken.promise.then(function onCanceled(cancel) { + if (!request) { + return; + } + + request.abort(); + reject(cancel); + // Clean up request + request = null; + }); + } + + if (requestData === undefined) { + requestData = null; + } + + // Send the request + request.send(requestData); + }); + }; + + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var createError = __webpack_require__(10); + + /** + * Resolve or reject a Promise based on response status. + * + * @param {Function} resolve A function that resolves the promise. + * @param {Function} reject A function that rejects the promise. + * @param {object} response The response. + */ + module.exports = function settle(resolve, reject, response) { + var validateStatus = response.config.validateStatus; + // Note: status is not exposed by XDomainRequest + if (!response.status || !validateStatus || validateStatus(response.status)) { + resolve(response); + } else { + reject(createError( + 'Request failed with status code ' + response.status, + response.config, + null, + response.request, + response + )); + } + }; + + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var enhanceError = __webpack_require__(11); + + /** + * Create an Error with the specified message, config, error code, request and response. + * + * @param {string} message The error message. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The created error. + */ + module.exports = function createError(message, config, code, request, response) { + var error = new Error(message); + return enhanceError(error, config, code, request, response); + }; + + +/***/ }, +/* 11 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Update an Error with the specified config, error code, and response. + * + * @param {Error} error The error to update. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The error. + */ + module.exports = function enhanceError(error, config, code, request, response) { + error.config = config; + if (code) { + error.code = code; + } + error.request = request; + error.response = response; + return error; + }; + + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + function encode(val) { + return encodeURIComponent(val). + replace(/%40/gi, '@'). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%20/g, '+'). + replace(/%5B/gi, '['). + replace(/%5D/gi, ']'); + } + + /** + * Build a URL by appending params to the end + * + * @param {string} url The base of the url (e.g., http://www.google.com) + * @param {object} [params] The params to be appended + * @returns {string} The formatted url + */ + module.exports = function buildURL(url, params, paramsSerializer) { + /*eslint no-param-reassign:0*/ + if (!params) { + return url; + } + + var serializedParams; + if (paramsSerializer) { + serializedParams = paramsSerializer(params); + } else if (utils$$1.isURLSearchParams(params)) { + serializedParams = params.toString(); + } else { + var parts = []; + + utils$$1.forEach(params, function serialize(val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + + if (utils$$1.isArray(val)) { + key = key + '[]'; + } + + if (!utils$$1.isArray(val)) { + val = [val]; + } + + utils$$1.forEach(val, function parseValue(v) { + if (utils$$1.isDate(v)) { + v = v.toISOString(); + } else if (utils$$1.isObject(v)) { + v = JSON.stringify(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + serializedParams = parts.join('&'); + } + + if (serializedParams) { + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; + } + + return url; + }; + + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + /** + * Parse headers into an object + * + * ``` + * Date: Wed, 27 Aug 2014 08:58:49 GMT + * Content-Type: application/json + * Connection: keep-alive + * Transfer-Encoding: chunked + * ``` + * + * @param {String} headers Headers needing to be parsed + * @returns {Object} Headers parsed into an object + */ + module.exports = function parseHeaders(headers) { + var parsed = {}; + var key; + var val; + var i; + + if (!headers) { return parsed; } + + utils$$1.forEach(headers.split('\n'), function parser(line) { + i = line.indexOf(':'); + key = utils$$1.trim(line.substr(0, i)).toLowerCase(); + val = utils$$1.trim(line.substr(i + 1)); + + if (key) { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + }); + + return parsed; + }; + + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + module.exports = ( + utils$$1.isStandardBrowserEnv() ? + + // Standard browser envs have full support of the APIs needed to test + // whether the request URL is of the same origin as current location. + (function standardBrowserEnv() { + var msie = /(msie|trident)/i.test(navigator.userAgent); + var urlParsingNode = document.createElement('a'); + var originURL; + + /** + * Parse a URL to discover it's components + * + * @param {String} url The URL to be parsed + * @returns {Object} + */ + function resolveURL(url) { + var href = url; + + if (msie) { + // IE needs attribute set twice to normalize properties + urlParsingNode.setAttribute('href', href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') ? + urlParsingNode.pathname : + '/' + urlParsingNode.pathname + }; + } + + originURL = resolveURL(window.location.href); + + /** + * Determine if a URL shares the same origin as the current location + * + * @param {String} requestURL The URL to test + * @returns {boolean} True if URL shares the same origin, otherwise false + */ + return function isURLSameOrigin(requestURL) { + var parsed = (utils$$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL; + return (parsed.protocol === originURL.protocol && + parsed.host === originURL.host); + }; + })() : + + // Non standard browser envs (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return function isURLSameOrigin() { + return true; + }; + })() + ); + + +/***/ }, +/* 15 */ +/***/ function(module, exports) { + + 'use strict'; + + // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js + + var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + function E() { + this.message = 'String contains an invalid character'; + } + E.prototype = new Error; + E.prototype.code = 5; + E.prototype.name = 'InvalidCharacterError'; + + function btoa(input) { + var str = String(input); + var output = ''; + for ( + // initialize result and counter + var block, charCode, idx = 0, map = chars; + // if the next str index does not exist: + // change the mapping table to "=" + // check if d has no fractional digits + str.charAt(idx | 0) || (map = '=', idx % 1); + // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 + output += map.charAt(63 & block >> 8 - idx % 1 * 8) + ) { + charCode = str.charCodeAt(idx += 3 / 4); + if (charCode > 0xFF) { + throw new E(); + } + block = block << 8 | charCode; + } + return output; + } + + module.exports = btoa; + + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + module.exports = ( + utils$$1.isStandardBrowserEnv() ? + + // Standard browser envs support document.cookie + (function standardBrowserEnv() { + return { + write: function write(name, value, expires, path, domain, secure) { + var cookie = []; + cookie.push(name + '=' + encodeURIComponent(value)); + + if (utils$$1.isNumber(expires)) { + cookie.push('expires=' + new Date(expires).toGMTString()); + } + + if (utils$$1.isString(path)) { + cookie.push('path=' + path); + } + + if (utils$$1.isString(domain)) { + cookie.push('domain=' + domain); + } + + if (secure === true) { + cookie.push('secure'); + } + + document.cookie = cookie.join('; '); + }, + + read: function read(name) { + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, + + remove: function remove(name) { + this.write(name, '', Date.now() - 86400000); + } + }; + })() : + + // Non standard browser env (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return { + write: function write() {}, + read: function read() { return null; }, + remove: function remove() {} + }; + })() + ); + + +/***/ }, +/* 17 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + function InterceptorManager() { + this.handlers = []; + } + + /** + * Add a new interceptor to the stack + * + * @param {Function} fulfilled The function to handle `then` for a `Promise` + * @param {Function} rejected The function to handle `reject` for a `Promise` + * + * @return {Number} An ID used to remove interceptor later + */ + InterceptorManager.prototype.use = function use(fulfilled, rejected) { + this.handlers.push({ + fulfilled: fulfilled, + rejected: rejected + }); + return this.handlers.length - 1; + }; + + /** + * Remove an interceptor from the stack + * + * @param {Number} id The ID that was returned by `use` + */ + InterceptorManager.prototype.eject = function eject(id) { + if (this.handlers[id]) { + this.handlers[id] = null; + } + }; + + /** + * Iterate over all the registered interceptors + * + * This method is particularly useful for skipping over any + * interceptors that may have become `null` calling `eject`. + * + * @param {Function} fn The function to call for each interceptor + */ + InterceptorManager.prototype.forEach = function forEach(fn) { + utils$$1.forEach(this.handlers, function forEachHandler(h) { + if (h !== null) { + fn(h); + } + }); + }; + + module.exports = InterceptorManager; + + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + var transformData = __webpack_require__(19); + var isCancel = __webpack_require__(20); + var defaults = __webpack_require__(6); + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + function throwIfCancellationRequested(config) { + if (config.cancelToken) { + config.cancelToken.throwIfRequested(); + } + } + + /** + * Dispatch a request to the server using the configured adapter. + * + * @param {object} config The config that is to be used for the request + * @returns {Promise} The Promise to be fulfilled + */ + module.exports = function dispatchRequest(config) { + throwIfCancellationRequested(config); + + // Ensure headers exist + config.headers = config.headers || {}; + + // Transform request data + config.data = transformData( + config.data, + config.headers, + config.transformRequest + ); + + // Flatten headers + config.headers = utils$$1.merge( + config.headers.common || {}, + config.headers[config.method] || {}, + config.headers || {} + ); + + utils$$1.forEach( + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], + function cleanHeaderConfig(method) { + delete config.headers[method]; + } + ); + + var adapter = config.adapter || defaults.adapter; + + return adapter(config).then(function onAdapterResolution(response) { + throwIfCancellationRequested(config); + + // Transform response data + response.data = transformData( + response.data, + response.headers, + config.transformResponse + ); + + return response; + }, function onAdapterRejection(reason) { + if (!isCancel(reason)) { + throwIfCancellationRequested(config); + + // Transform response data + if (reason && reason.response) { + reason.response.data = transformData( + reason.response.data, + reason.response.headers, + config.transformResponse + ); + } + } + + return Promise.reject(reason); + }); + }; + + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var utils$$1 = __webpack_require__(2); + + /** + * Transform the data for a request or a response + * + * @param {Object|String} data The data to be transformed + * @param {Array} headers The headers for the request or response + * @param {Array|Function} fns A single function or Array of functions + * @returns {*} The resulting transformed data + */ + module.exports = function transformData(data, headers, fns) { + /*eslint no-param-reassign:0*/ + utils$$1.forEach(fns, function transform(fn) { + data = fn(data, headers); + }); + + return data; + }; + + +/***/ }, +/* 20 */ +/***/ function(module, exports) { + + 'use strict'; + + module.exports = function isCancel(value) { + return !!(value && value.__CANCEL__); + }; + + +/***/ }, +/* 21 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ + module.exports = function isAbsoluteURL(url) { + // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed + // by any combination of letters, digits, plus, period, or hyphen. + return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); + }; + + +/***/ }, +/* 22 */ +/***/ 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 relativeURL + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') + : baseURL; + }; + + +/***/ }, +/* 23 */ +/***/ function(module, exports) { + + 'use strict'; + + /** + * A `Cancel` is an object that is thrown when an operation is canceled. + * + * @class + * @param {string=} message The message. + */ + function Cancel(message) { + this.message = message; + } + + Cancel.prototype.toString = function toString() { + return 'Cancel' + (this.message ? ': ' + this.message : ''); + }; + + Cancel.prototype.__CANCEL__ = true; + + module.exports = Cancel; + + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var Cancel = __webpack_require__(23); + + /** + * A `CancelToken` is an object that can be used to request cancellation of an operation. + * + * @class + * @param {Function} executor The executor function. + */ + function CancelToken(executor) { + if (typeof executor !== 'function') { + throw new TypeError('executor must be a function.'); + } + + var resolvePromise; + this.promise = new Promise(function promiseExecutor(resolve) { + resolvePromise = resolve; + }); + + var token = this; + executor(function cancel(message) { + if (token.reason) { + // Cancellation has already been requested + return; + } + + token.reason = new Cancel(message); + resolvePromise(token.reason); + }); + } + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + CancelToken.prototype.throwIfRequested = function throwIfRequested() { + if (this.reason) { + throw this.reason; + } + }; + + /** + * Returns an object that contains a new `CancelToken` and a function that, when called, + * cancels the `CancelToken`. + */ + CancelToken.source = function source() { + var cancel; + var token = new CancelToken(function executor(c) { + cancel = c; + }); + return { + token: token, + cancel: cancel + }; + }; + + module.exports = CancelToken; + + +/***/ }, +/* 25 */ +/***/ 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 _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; + + + + + + + + + + + + + + + + + + + +var defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +}; + + + + + + + + + + + + + + + + + + + + + +var slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; +}(); + +var noop = function noop() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + this.dbg.apply(this, [opts.op].concat(args)); + return jsData.utils.resolve(); +}; + +var noop2 = function noop2() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + this.dbg.apply(this, [opts.op].concat(args)); + return jsData.utils.resolve(); +}; + +var unique = function unique(array) { + var seen = {}; + var final = []; + array.forEach(function (item) { + if (item in seen) { + return; + } + final.push(item); + seen[item] = 0; + }); + return final; +}; + +var withoutRelations = function withoutRelations(mapper, props, opts) { + opts || (opts = {}); + opts.with || (opts.with = []); + var relationFields = mapper.relationFields || []; + var toStrip = relationFields.filter(function (value) { + return opts.with.indexOf(value) === -1; + }); + return jsData.utils.omit(props, toStrip); +}; + + + +/** + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @class Response + */ +function Response(data, meta, op) { + meta || (meta = {}); + + /** + * Response data. + * + * @name Response#data + * @type {*} + */ + this.data = data; + + jsData.utils.fillIn(this, meta); + + /** + * The operation for which the response was created. + * + * @name Response#op + * @type {string} + */ + this.op = op; +} + +var DEFAULTS$1 = { + /** + * Whether to log debugging information. + * + * @name Adapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * Whether to return a more detailed response object. + * + * @name Adapter#raw + * @type {boolean} + * @default false + */ + raw: false + + /** + * Abstract class meant to be extended by adapters. + * + * @class Adapter + * @abstract + * @extends Component + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.debug=false] Whether to log debugging information. + * @param {boolean} [opts.raw=false] Whether to return a more detailed response + * object. + */ +};function Adapter(opts) { + jsData.utils.classCallCheck(this, Adapter); + jsData.Component.call(this, opts); + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS$1); + jsData.utils.fillIn(this, opts); +} + +jsData.Component.extend({ + constructor: Adapter, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#afterCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} props The `props` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `afterCount` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterCount: noop2, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `afterCreate` + * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreate: noop2, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `afterCreateMany` + * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreateMany: noop2, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#afterDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `afterDestroy` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroy: noop2, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#afterDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `afterDestroyAll` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroyAll: noop2, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#afterFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `afterFind` + * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`. + */ + afterFind: noop2, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#afterFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `afterFindAll` + * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`. + */ + afterFindAll: noop2, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#afterSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {string} field The `field` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `afterSum` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterSum: noop2, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#afterUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `afterUpdate` + * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdate: noop2, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#afterUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `afterUpdateAll` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateAll: noop2, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#afterUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} records The `records` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `afterUpdateMany` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateMany: noop2, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#beforeCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} query The `query` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `beforeCount` + */ + beforeCount: noop, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#beforeCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `beforeCreate` + */ + beforeCreate: noop, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#beforeCreateMany + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `beforeCreateMany` + */ + beforeCreateMany: noop, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#beforeDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `beforeDestroy` + */ + beforeDestroy: noop, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#beforeDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `beforeDestroyAll` + */ + beforeDestroyAll: noop, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#beforeFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `beforeFind` + */ + beforeFind: noop, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#beforeFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `beforeFindAll` + */ + beforeFindAll: noop, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#beforeSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `beforeSum` + */ + beforeSum: noop, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#beforeUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `beforeUpdate` + */ + beforeUpdate: noop, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#beforeUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `beforeUpdateAll` + */ + beforeUpdateAll: noop, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#beforeUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} props The `props` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `beforeUpdateMany` + */ + beforeUpdateMany: noop, + + /** + * Retrieve the number of records that match the selection query. Called by + * `Mapper#count`. + * + * @name Adapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var _this = this; + + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + _this.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this._count(mapper, query, opts)); + }).then(function (results) { + var _results = slicedToArray(results, 2), + data = _results[0], + result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = _this.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(_this[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Create a new record. Called by `Mapper#create`. + * + * @name Adapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var _this2 = this; + + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'create'; + _this2.dbg(op, mapper, props, opts); + return jsData.utils.resolve(_this2._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = slicedToArray(results, 2), + data = _results2[0], + result = _results2[1]; + + result || (result = {}); + var response = new Response(data, result, 'create'); + response.created = data ? 1 : 0; + response = _this2.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(_this2[op](mapper, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Create multiple records in a single batch. Called by `Mapper#createMany`. + * + * @name Adapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var _this3 = this; + + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record, opts); + }); + op = opts.op = 'createMany'; + _this3.dbg(op, mapper, props, opts); + return jsData.utils.resolve(_this3._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = slicedToArray(results, 2), + data = _results3[0], + result = _results3[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'createMany'); + response.created = data.length; + response = _this3.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(_this3[op](mapper, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Destroy the record with the given primary key. Called by + * `Mapper#destroy`. + * + * @name Adapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var _this4 = this; + + var op = void 0; + opts || (opts = {}); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + _this4.dbg(op, mapper, id, opts); + return jsData.utils.resolve(_this4._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = slicedToArray(results, 2), + data = _results4[0], + result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = _this4.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(_this4[op](mapper, id, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Destroy the records that match the selection query. Called by + * `Mapper#destroyAll`. + * + * @name Adapter#destroyAll + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var _this5 = this; + + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + _this5.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this5._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = slicedToArray(results, 2), + data = _results5[0], + result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = _this5.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(_this5[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo + * @method + * @return {Promise} + */ + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { + var _this6 = this; + + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var record = records; + return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }); + } else { + var keys = records.map(function (record) { + return _this6.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return this.findAll(relationDef, { + where: defineProperty({}, relationDef.idAttribute, { + 'in': keys + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (record) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { + def.setLocalField(record, relatedItem); + } + }); + }); + }); + } + }, + + + /** + * Retrieve the record with the given primary key. Called by `Mapper#find`. + * + * @name Adapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var _this7 = this; + + var op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + _this7.dbg(op, mapper, id, opts); + return jsData.utils.resolve(_this7._find(mapper, id, opts)); + }).then(function (results) { + return _this7.loadRelationsFor(mapper, results, opts); + }).then(function (_ref) { + var _ref2 = slicedToArray(_ref, 2), + record = _ref2[0], + meta = _ref2[1]; + + var response = new Response(record, meta, 'find'); + response.found = record ? 1 : 0; + response = _this7.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(_this7[op](mapper, id, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Retrieve the records that match the selection query. + * + * @name Adapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var _this8 = this; + + var op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + var activeWith = opts._activeWith; + + if (jsData.utils.isObject(activeWith)) { + var activeQuery = activeWith.query || {}; + if (activeWith.replace) { + query = activeQuery; + } else { + jsData.utils.deepFillIn(query, activeQuery); + } + } + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + _this8.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this8._findAll(mapper, query, opts)); + }).then(function (results) { + return _this8.loadRelationsFor(mapper, results, opts); + }).then(function (_ref3) { + var _ref4 = slicedToArray(_ref3, 2), + records = _ref4[0], + meta = _ref4[1]; + + var response = new Response(records, meta, 'findAll'); + response.found = records.length; + response = _this8.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(_this8[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + loadRelationsFor: function loadRelationsFor(mapper, results, opts) { + var _this9 = this; + + var _results6 = slicedToArray(results, 1), + records = _results6[0]; + + var tasks = []; + + if (records) { + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasOne') { + task = _this9.loadHasOne(mapper, def, records, __opts); + } else { + task = _this9.loadHasMany(mapper, def, records, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = _this9.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = _this9.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = _this9.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } + }); + } + + return jsData.utils.Promise.all(tasks).then(function () { + return results; + }); + }, + + + /** + * Resolve the value of the specified option based on the given options and + * this adapter's settings. Override with care. + * + * @name Adapter#getOpt + * @method + * @param {string} opt The name of the option. + * @param {Object} [opts] Configuration options. + * @return {*} The value of the specified option. + */ + getOpt: function getOpt(opt, opts) { + opts || (opts = {}); + return opts[opt] === undefined ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); + }, + + + /** + * Load a hasMany relationship. + * + * Override with care. + * + * @name Adapter#loadHasMany + * @method + * @return {Promise} + */ + loadHasMany: function loadHasMany(mapper, def, records, __opts) { + var _this10 = this; + + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return _this10.makeHasManyForeignKey(mapper, def, record); + }); + var query = { + where: {} + }; + var criteria = query.where[def.foreignKey] = {}; + if (singular) { + // more efficient query when we only have one record + criteria['=='] = IDs[0]; + } else { + criteria['in'] = IDs.filter(function (id) { + return id; + }); + } + return this.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { + records.forEach(function (record) { + var attached = []; + // avoid unneccesary iteration when we only have one record + if (singular) { + attached = relatedItems; + } else { + relatedItems.forEach(function (relatedItem) { + if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { + attached.push(relatedItem); + } + }); + } + def.setLocalField(record, attached); + }); + }); + }, + loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { + var _this11 = this; + + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return this.findAll(relatedMapper, { + where: defineProperty({}, relatedMapper.idAttribute, { + 'in': this.makeHasManyLocalKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + var localKeys = []; + records.forEach(function (record) { + localKeys = localKeys.concat(_this11.makeHasManyLocalKeys(mapper, def, record)); + }); + return this.findAll(relatedMapper, { + where: defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + var itemKeys = jsData.utils.get(item, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem); + } + }); + def.setLocalField(item, attached); + }); + return relatedItems; + }); + } + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var _this12 = this; + + var relatedMapper = def.getRelation(); + var idAttribute = mapper.idAttribute; + var record = void 0; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return this.findAll(def.getRelation(), { + where: defineProperty({}, def.foreignKeys, { + 'contains': this.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return this.findAll(relatedMapper, { + where: defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return _this12.makeHasManyForeignKeys(mapper, def, record); + }) + }) + }, __opts).then(function (relatedItems) { + var foreignKeysField = def.foreignKeys; + records.forEach(function (record) { + var _relatedItems = []; + var id = jsData.utils.get(record, idAttribute); + relatedItems.forEach(function (relatedItem) { + var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; + if (foreignKeys.indexOf(id) !== -1) { + _relatedItems.push(relatedItem); + } + }); + def.setLocalField(record, _relatedItems); + }); + }); + } + }, + + + /** + * Load a hasOne relationship. + * + * Override with care. + * + * @name Adapter#loadHasOne + * @method + * @return {Promise} + */ + loadHasOne: function loadHasOne(mapper, def, records, __opts) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + records = [records]; + } + return this.loadHasMany(mapper, def, records, __opts).then(function () { + records.forEach(function (record) { + var relatedData = def.getLocalField(record); + if (jsData.utils.isArray(relatedData) && relatedData.length) { + def.setLocalField(record, relatedData[0]); + } + }); + }); + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * There may be reasons why you may want to override this method, like when + * the id of the parent doesn't exactly match up to the key on the child. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKey + * @method + * @return {*} + */ + makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Return the localKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyLocalKeys + * @method + * @return {*} + */ + makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) { + var localKeys = []; + var itemKeys = jsData.utils.get(record, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + localKeys = localKeys.concat(itemKeys); + return unique(localKeys).filter(function (x) { + return x; + }); + }, + + + /** + * Return the foreignKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKeys + * @method + * @return {*} + */ + makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) { + return jsData.utils.get(record, mapper.idAttribute); + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeBelongsToForeignKey + * @method + * @return {*} + */ + makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Retrieve sum of the specified field of the records that match the selection + * query. Called by `Mapper#sum`. + * + * @name Adapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field By to sum. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var _this13 = this; + + var op = void 0; + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + query || (query = {}); + opts || (opts = {}); + + // beforeSum lifecycle hook + op = opts.op = 'beforeSum'; + return jsData.utils.resolve(this[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + _this13.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(_this13._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results7 = slicedToArray(results, 2), + data = _results7[0], + result = _results7[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = _this13.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(_this13[op](mapper, field, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * @name Adapter#respond + * @method + * @param {Object} response Response object. + * @param {Object} opts Configuration options. + * return {Object} If `opts.raw == true` then return `response`, else return + * `response.data`. + */ + respond: function respond(response, opts) { + return this.getOpt('raw', opts) ? response : response.data; + }, + + + /** + * Apply the given update to the record with the specified primary key. Called + * by `Mapper#update`. + * + * @name Adapter#update + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id The primary key of the record to be updated. + * @param {Object} props The update to apply to the record. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var _this14 = this; + + props || (props = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(this[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'update'; + _this14.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(_this14._update(mapper, id, props, opts)); + }).then(function (results) { + var _results8 = slicedToArray(results, 2), + data = _results8[0], + result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, 'update'); + response.updated = data ? 1 : 0; + response = _this14.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(_this14[op](mapper, id, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Apply the given update to all records that match the selection query. + * Called by `Mapper#updateAll`. + * + * @name Adapter#updateAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var _this15 = this; + + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(this[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'updateAll'; + _this15.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(_this15._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results9 = slicedToArray(results, 2), + data = _results9[0], + result = _results9[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateAll'); + response.updated = data.length; + response = _this15.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(_this15[op](mapper, props, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Update the given records in a single batch. Called by `Mapper#updateMany`. + * + * @name Adapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var _this16 = this; + + records || (records = []); + opts || (opts = {}); + var op = void 0; + var idAttribute = mapper.idAttribute; + + records = records.filter(function (record) { + return jsData.utils.get(record, idAttribute); + }); + + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return jsData.utils.resolve(this[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = _records === undefined ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record, opts); + }); + op = opts.op = 'updateMany'; + _this16.dbg(op, mapper, records, opts); + return jsData.utils.resolve(_this16._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results10 = slicedToArray(results, 2), + data = _results10[0], + result = _results10[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateMany'); + response.updated = data.length; + response = _this16.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(_this16[op](mapper, records, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + } +}); + +/** + * Create a subclass of this Adapter: + * + * @example Adapter.extend + * // Normally you would do: import {Adapter} from 'js-data' + * const JSData = require('js-data@3.0.0-beta.10') + * const {Adapter} = JSData + * console.log('Using JSData v' + JSData.version.full) + * + * // Extend the class using ES2015 class syntax. + * class CustomAdapterClass extends Adapter { + * foo () { return 'bar' } + * static beep () { return 'boop' } + * } + * const customAdapter = new CustomAdapterClass() + * console.log(customAdapter.foo()) + * console.log(CustomAdapterClass.beep()) + * + * // Extend the class using alternate method. + * const OtherAdapterClass = Adapter.extend({ + * foo () { return 'bar' } + * }, { + * beep () { return 'boop' } + * }) + * const otherAdapter = new OtherAdapterClass() + * console.log(otherAdapter.foo()) + * console.log(OtherAdapterClass.beep()) + * + * // Extend the class, providing a custom constructor. + * function AnotherAdapterClass () { + * Adapter.call(this) + * this.created_at = new Date().getTime() + * } + * Adapter.extend({ + * constructor: AnotherAdapterClass, + * foo () { return 'bar' } + * }, { + * beep () { return 'boop' } + * }) + * const anotherAdapter = new AnotherAdapterClass() + * console.log(anotherAdapter.created_at) + * console.log(anotherAdapter.foo()) + * console.log(AnotherAdapterClass.beep()) + * + * @method Adapter.extend + * @param {Object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {Object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {Object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this Adapter class. + */ + +var hasFetch = false; + +try { + hasFetch = window && window.fetch; +} catch (e) {} + +function isValidString(value) { + return value != null && value !== ''; +} +function join(items, separator) { + separator || (separator = ''); + return items.filter(isValidString).join(separator); +} +function makePath() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var result = join(args, '/'); + return result.replace(/([^:/]|^)\/{2,}/g, '$1/'); +} + +function encode(val) { + return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); +} + +function buildUrl(url, params) { + if (!params) { + return url; + } + + var parts = []; + + jsData.utils.forOwn(params, function (val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + if (!jsData.utils.isArray(val)) { + val = [val]; + } + + val.forEach(function (v) { + if (toString.call(v) === '[object Date]') { + v = v.toISOString(); + } else if (jsData.utils.isObject(v)) { + v = jsData.utils.toJson(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; +} + +var DEFAULTS = { + /** + * Set a base path in order to use absolute URLs instead of relative URLs. + * + * @example + * const httpAdapter = new HttpAdapter({ + * basePath: 'https://mydomain.com' + * }); + * + * @name HttpAdapter#basePath + * @type {string} + * @since 3.0.0 + */ + basePath: '', + + /** + * Ensure that the request url has a trailing forward slash. + * + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + * @since 3.0.0 + */ + forceTrailingSlash: false, + + hasFetch: hasFetch, + + /** + * The HTTP function that actually makes the HTTP request. By default this is + * `axios`. + * + * @name HttpAdapter#http + * @type {function} + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library + */ + http: axios, + + /** + * Default configuration options to be mixed into the `config` argument passed + * to {@link HttpAdapter#http}. + * + * @name HttpAdapter#httpConfig + * @type {object} + * @since 3.0.0 + */ + httpConfig: {}, + + /** + * Add a suffix to the request url, e.g. ".json". + * + * @name HttpAdapter#suffix + * @type {string} + * @since 3.0.0 + */ + suffix: '', + + /** + * Use `window.fetch` if available. + * + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-windowfetch + */ + useFetch: false + + /** + * HttpAdapter class. + * + * @example + * import { DataStore } from 'js-data'; + * import { HttpAdapter } from 'js-data-http'; + * + * const httpAdapter = new HttpAdapter(); + * const store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * + * store.defineMapper('school'); + * store.defineMapper('student'); + * + * // GET /school/1 + * store.find('school', 1).then((school) => { + * console.log('school'); + * }); + * + * @class HttpAdapter + * @extends Adapter + * @param {object} [opts] Configuration options. + * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}. + * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}. + * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}. + * @param {object} [opts.http=axios] See {@link HttpAdapter#http}. + * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}. + * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}. + * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}. + * @see http://www.js-data.io/docs/js-data-http + */ +};function HttpAdapter(opts) { + jsData.utils.classCallCheck(this, HttpAdapter); + + opts || (opts = {}); + // Fill in any missing options with the defaults + jsData.utils.fillIn(opts, DEFAULTS); + Adapter.call(this, opts); +} + +/** + * @name module:js-data-http.HttpAdapter + * @see HttpAdapter + */ + +Adapter.extend({ + constructor: HttpAdapter, + + /** + * @name HttpAdapter#afterDEL + * @method + * @param {string} url + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterDEL: noop2, + + /** + * @name HttpAdapter#afterGET + * @method + * @param {string} url + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterGET: noop2, + + /** + * @name HttpAdapter#afterHTTP + * @method + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterHTTP: noop2, + + /** + * @name HttpAdapter#afterPOST + * @method + * @param {string} url + * @param {object} data + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterPOST: noop2, + + /** + * @name HttpAdapter#afterPUT + * @method + * @param {string} url + * @param {object} data + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterPUT: noop2, + + /** + * @name HttpAdapter#beforeDEL + * @method + * @param {object} url + * @param {object} config + * @param {object} opts + */ + beforeDEL: noop, + + /** + * @name HttpAdapter#beforeGET + * @method + * @param {object} url + * @param {object} config + * @param {object} opts + */ + beforeGET: noop, + + /** + * @name HttpAdapter#beforeHTTP + * @method + * @param {object} config + * @param {object} opts + */ + beforeHTTP: noop, + + /** + * @name HttpAdapter#beforePOST + * @method + * @param {object} url + * @param {object} data + * @param {object} config + * @param {object} opts + */ + beforePOST: noop, + + /** + * @name HttpAdapter#beforePUT + * @method + * @param {object} url + * @param {object} data + * @param {object} config + * @param {object} opts + */ + beforePUT: noop, + + _count: function _count(mapper, query, opts) { + var _this = this; + + return this.GET(this.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return _this._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var _this2 = this; + + return this.POST(this.getPath('create', mapper, props, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this2._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var _this3 = this; + + return this.POST(this.getPath('createMany', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this3._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var _this4 = this; + + return this.DEL(this.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return _this4._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var _this5 = this; + + return this.DEL(this.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return _this5._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var _this6 = this; + + return this.GET(this.getPath('find', mapper, id, opts), opts).then(function (response) { + return _this6._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var _this7 = this; + + return this.GET(this.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return _this7._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var _this8 = this; + + return this.GET(this.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return _this8._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var _this9 = this; + + return this.PUT(this.getPath('update', mapper, id, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this9._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var _this10 = this; + + return this.PUT(this.getPath('updateAll', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this10._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var _this11 = this; + + return this.PUT(this.getPath('updateMany', mapper, null, opts), this.serialize(mapper, records, opts), opts).then(function (response) { + return _this11._end(mapper, opts, response); + }); + }, + + + /** + * Retrieve the number of records that match the selection `query`. + * + * @name HttpAdapter#count + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params.count = true; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.count.call(this, mapper, query, opts); + }, + + + /** + * Create a new the record from the provided `props`. + * + * @name HttpAdapter#create + * @method + * @param {object} mapper The mapper. + * @param {object} props Properties to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.create.call(this, mapper, props, opts); + }, + + + /** + * Create multiple new records in batch. + * + * @name HttpAdapter#createMany + * @method + * @param {object} mapper The mapper. + * @param {array} props Array of property objects to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.createMany.call(this, mapper, props, opts); + }, + + + /** + * Make an Http request to `url` according to the configuration in `config`. + * + * @name HttpAdapter#DEL + * @method + * @param {string} url Url for the request. + * @param {object} [config] Http configuration that will be passed to + * {@link HttpAdapter#HTTP}. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + DEL: function DEL(url, config, opts) { + var _this12 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'delete'; + + // beforeDEL lifecycle hook + op = opts.op = 'beforeDEL'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'DEL'; + _this12.dbg(op, url, config, opts); + return _this12.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return jsData.utils.resolve(_this12[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the server response object into the payload that will be returned + * to JSData. + * + * @name HttpAdapter#deserialize + * @method + * @param {object} mapper The mapper used for the operation. + * @param {object} response Response object from {@link HttpAdapter#HTTP}. + * @param {object} opts Configuration options. + * @return {(object|array)} Deserialized data. + */ + deserialize: function deserialize(mapper, response, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.deserialize)) { + return opts.deserialize(mapper, response, opts); + } + if (jsData.utils.isFunction(mapper.deserialize)) { + return mapper.deserialize(mapper, response, opts); + } + if (response && response.hasOwnProperty('data')) { + return response.data; + } + return response; + }, + + + /** + * Destroy the record with the given primary key. + * + * @name HttpAdapter#destroy + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.destroy.call(this, mapper, id, opts); + }, + + + /** + * Destroy the records that match the selection `query`. + * + * @name HttpAdapter#destroyAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.destroyAll.call(this, mapper, query, opts); + }, + + + /** + * Log an error. + * + * @name HttpAdapter#error + * @method + * @param {...*} [args] Arguments to log. + */ + error: function error() { + if (console) { + var _console; + + (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); + } + }, + + + /** + * Make an Http request using `window.fetch`. + * + * @name HttpAdapter#fetch + * @method + * @param {object} config Request configuration. + * @param {object} config.data Payload for the request. + * @param {string} config.method Http method for the request. + * @param {object} config.headers Headers for the request. + * @param {object} config.params Querystring for the request. + * @param {string} config.url Url for the request. + */ + fetch: function (_fetch) { + function fetch(_x) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config) { + var requestConfig = { + method: config.method, + // turn the plain headers object into the Fetch Headers object + headers: new Headers(config.headers || {}) + }; + + if (config.data) { + requestConfig.body = jsData.utils.toJson(config.data); + } + + return fetch(buildUrl(config.url, config.params), requestConfig).then(function (response) { + response.config = { + method: config.method, + url: config.url + }; + return response.json().then(function (data) { + response.data = data; + return response; + }); + }); + }), + + + /** + * Retrieve the record with the given primary key. + * + * @name HttpAdapter#find + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.find.call(this, mapper, id, opts); + }, + + + /** + * Retrieve the records that match the selection `query`. + * + * @name HttpAdapter#findAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.findAll.call(this, mapper, query, opts); + }, + + + /** + * Make a GET request. + * + * @name HttpAdapter#GET + * @method + * @param {string} url The url for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + GET: function GET(url, config, opts) { + var _this13 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'get'; + + // beforeGET lifecycle hook + op = opts.op = 'beforeGET'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'GET'; + _this13.dbg(op, url, config, opts); + return _this13.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return jsData.utils.resolve(_this13[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {object} mapper The Mapper. + * @param {*} id The primary key, if any. + * @param {boolean} opts Configuration options. + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var _this14 = this; + + opts || (opts = {}); + opts.params = jsData.utils.isUndefined(opts.params) ? {} : opts.params; + var relationList = mapper.relationList || []; + var endpoint = jsData.utils.isUndefined(opts.endpoint) ? jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; + + relationList.forEach(function (def) { + if (def.type !== 'belongsTo' || !def.parent) { + return; + } + var item = void 0; + var parentKey = def.foreignKey; + var parentDef = def.getRelation(); + var parentId = opts.params[parentKey]; + + if (parentId === false || !parentKey || !parentDef) { + if (parentId === false) { + delete opts.params[parentKey]; + } + return false; + } else { + delete opts.params[parentKey]; + + if (jsData.utils.isObject(id)) { + item = id; + } + + if (item) { + parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); + } + + if (parentId) { + delete opts.endpoint; + var _opts = {}; + jsData.utils.forOwn(opts, function (value, key) { + _opts[key] = value; + }); + jsData.utils._(_opts, parentDef); + endpoint = makePath(_this14.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return false; + } + } + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method The method being executed. + * @param {object} mapper The Mapper. + * @param {(string|number)?} id The primary key, if any. + * @param {object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + opts || (opts = {}); + var args = [opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, this.getEndpoint(mapper, jsData.utils.isString(id) || jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; + if (method === 'find' || method === 'update' || method === 'destroy') { + args.push(id); + } + return makePath.apply(jsData.utils, args); + }, + getParams: function getParams(opts) { + opts || (opts = {}); + if (opts.params === undefined) { + return {}; + } + return jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (opts.suffix === undefined) { + if (mapper.suffix === undefined) { + return this.suffix; + } + return mapper.suffix; + } + return opts.suffix; + }, + + + /** + * Make an Http request. + * + * @name HttpAdapter#HTTP + * @method + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + HTTP: function HTTP(config, opts) { + var _this15 = this; + + var start = new Date(); + opts || (opts = {}); + var payload = config.data; + var cache = config.cache; + var timeout = config.timeout; + config = jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); + config = jsData.utils.deepMixIn(config, this.httpConfig); + config.data = payload; + config.cache = cache; + if (timeout !== undefined) { + config.timeout = timeout; + } + if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || this.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + var logResponse = function logResponse(data) { + var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; + if (data.status >= 200 && data.status < 300) { + if (_this15.log) { + _this15.dbg(str, data); + } + return data; + } else { + if (_this15.error) { + _this15.error('\'FAILED: ' + str, data); + } + return jsData.utils.reject(data); + } + }; + + if (!this.http) { + if (this.useFetch || opts.useFetch) { + if (!hasFetch) { + throw new Error('Attempting to use window.fetch, but it is not available!'); + } + } else { + throw new Error('You have not configured this adapter with an http library!'); + } + } + + return jsData.utils.resolve(this.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (_this15.useFetch || opts.useFetch || !_this15.http)) { + return _this15.fetch(config, opts).then(logResponse, logResponse); + } + var httpConfig = jsData.utils.plainCopy(config); + delete httpConfig.adapter; + return _this15.http(httpConfig).then(logResponse, logResponse).catch(function (err) { + return _this15.responseError(err, config, opts); + }); + }).then(function (response) { + return jsData.utils.resolve(_this15.afterHTTP(config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Make a POST request. + * + * @name HttpAdapter#POST + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var _this16 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'post'; + + // beforePOST lifecycle hook + op = opts.op = 'beforePOST'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'POST'; + _this16.dbg(op, url, data, config, opts); + return _this16.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return jsData.utils.resolve(_this16[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Make a PUT request. + * + * @name HttpAdapter#PUT + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var _this17 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'put'; + + // beforePUT lifecycle hook + op = opts.op = 'beforePUT'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'PUT'; + _this17.dbg(op, url, data, config, opts); + return _this17.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return jsData.utils.resolve(_this17[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the querystring object before it is serialized. This doesn't do + * anything by default. + * + * @name HttpAdapter#queryTransform + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {*} params The querystring object. + * @param {*} opts Configuration options + * @return {*} Transformed params. + */ + queryTransform: function queryTransform(mapper, params, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts); + } + if (jsData.utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts); + } + return params; + }, + + + /** + * Error handler invoked when the promise returned by {@link HttpAdapter#http} + * is rejected. Default implementation is to just return the error wrapped in + * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is + * called by {@link HttpAdapter#HTTP}. + * + * @name HttpAdapter#responseError + * @method + * @param {*} err The error that {@link HttpAdapter#http} rejected with. + * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. + * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. + * @return {Promise} + */ + responseError: function responseError(err, config, opts) { + return jsData.utils.reject(err); + }, + + + /** + * Serialize request data. This doesn't do anything by default. + * + * @name HttpAdapter#serialize + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {object} data The request payload. + * @param {*} opts Configuration options. + * @return {*} Serialized data. + */ + serialize: function serialize(mapper, data, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts); + } + if (jsData.utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts); + } + return data; + }, + + + /** + * Retrieve the sum of the field of the records that match the selection query. + * + * @name HttpAdapter#sum + * @method + * @param {object} mapper The mapper. + * @param {string} field The field to sum. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + query || (query = {}); + opts || (opts = {}); + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = this.getParams(opts); + opts.params.sum = field; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.sum.call(this, mapper, field, query, opts); + }, + + + /** + * Perform an update. Makes a PUT request by default. + * + * @name HttpAdapter#update + * @method + * @param {object} mapper The Mapper for the request. + * @param {*} id The primary key of the record being updated. + * @param {*} props The update payload. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.update.call(this, mapper, id, props, opts); + }, + + + /** + * Perform an update against records that match the selection query. Makes a + * PUT request by default. + * + * @name HttpAdapter#updateAll + * @method + * @param {object} mapper The Mapper for the request. + * @param {object} props The update payload. + * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.updateAll.call(this, mapper, props, query, opts); + }, + + + /** + * Update multiple individual records in a batch. + * + * @name HttpAdapter#updateMany + * @method + * @param {object} mapper The Mapper for the request. + * @param {array} records Array of property objects to send as the payload. + * Each must contain the primary key of the record to be updated. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.updateMany.call(this, mapper, records, opts); + } +}); + +/** + * Add an Http actions to a mapper. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addAction = JSDataHttp.addAction; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * // GET /reports/schools/:school_id/teachers + * addAction('getTeacherReports', { + * endpoint: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addAction + * @method + * @param {string} name Name of the new action. + * @param {object} [opts] Action configuration + * @param {string} [opts.adapter="http"] The name of the adapter to use. + * @param {string} [opts.pathname] Set the action's pathname. + * @param {function} [opts.request] Specify a request handler to be executed + * before the request is made. + * @param {function} [opts.response] Specify a response handler to be executed + * after the response is received. + * @param {function} [opts.responseError] Specify an error handler to be + * executed on error. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addAction(name, opts) { + if (!name || !jsData.utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + } + return function (mapper) { + if (mapper[name]) { + throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); + } + opts.request = opts.request || function (config) { + return config; + }; + opts.response = opts.response || function (response) { + return response; + }; + opts.responseError = opts.responseError || function (err) { + return jsData.utils.reject(err); + }; + mapper[name] = function (id, _opts) { + var _this18 = this; + + _opts = _opts || {}; + if (jsData.utils.isObject(id)) { + _opts = id; + } + jsData.utils.fillIn(_opts, opts); + var adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http'); + var config = {}; + config.mapper = this.name; + jsData.utils.deepMixIn(config, _opts); + config.method = config.method || 'GET'; + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(this, _opts); + } else { + var args = [_opts.basePath || this.basePath || adapter.basePath, adapter.getEndpoint(this, id, _opts)]; + if (jsData.utils.isSorN(id)) { + args.push(id); + } + args.push(opts.pathname || name); + config.url = makePath.apply(null, args); + } + return jsData.utils.resolve(config).then(_opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = _this18.name; + } + return data; + }).then(_opts.response, _opts.responseError); + }; + return mapper; + }; +} + +/** + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addActions = JSDataHttp.addActions; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * addActions({ + * // GET /reports/schools/:school_id/teachers + * getTeacherReports: { + * basePath: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * } + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addActions + * @method + * @param {object.} opts Object where the key is an action name + * and the value is the configuration for the action. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addActions(opts) { + opts || (opts = {}); + return function (mapper) { + jsData.utils.forOwn(opts, function (value, key) { + addAction(key, value)(mapper); + }); + return mapper; + }; +} + +/** + * Details of the current version of the `js-data-http` module. + * + * @name module:js-data-http.version + * @type {object} + * @property {string} version.full The full semver value. + * @property {number} version.major The major version number. + * @property {number} version.minor The minor version number. + * @property {number} version.patch The patch version number. + * @property {(string|boolean)} version.alpha The alpha version value, + * otherwise `false` if the current version is not alpha. + * @property {(string|boolean)} version.beta The beta version value, + * otherwise `false` if the current version is not beta. + */ +var version = { + full: '3.0.0', + major: 3, + minor: 0, + patch: 0 +}; + +/** + * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http` + * that works on Node.js is registered in NPM as `js-data-http-node`. The build + * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower + * as `js-data-fetch`. + * + * @example Script tag + * var HttpAdapter = window.JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example CommonJS + * var HttpAdapter = require('js-data-Http').HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example ES2015 Modules + * import { HttpAdapter } from 'js-data-Http'; + * const httpAdapter = new HttpAdapter(); + * + * @example AMD + * define('myApp', ['js-data-Http'], function (JSDataHttp) { + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * // ... + * }); + * + * @module js-data-http + */ + +/** + * Create a subclass of this HttpAdapter: + * @example HttpAdapter.extend + * // Normally you would do: import { HttpAdapter } from 'js-data-http'; + * // or: import { HttpAdapter } from 'js-data-http-node'; + * const JSDataHttp = require('js-data-http-node'); + * const { HttpAdapter } = JSDataHttp; + * console.log('Using JSDataHttp v' + JSDataHttp.version.full); + * + * // Extend the class using ES2015 class syntax. + * class CustomHttpAdapterClass extends HttpAdapter { + * foo () { return 'bar'; } + * static beep () { return 'boop'; } + * } + * const customHttpAdapter = new CustomHttpAdapterClass(); + * console.log(customHttpAdapter.foo()); + * console.log(CustomHttpAdapterClass.beep()); + * + * // Extend the class using alternate method. + * const OtherHttpAdapterClass = HttpAdapter.extend({ + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const otherHttpAdapter = new OtherHttpAdapterClass(); + * console.log(otherHttpAdapter.foo()); + * console.log(OtherHttpAdapterClass.beep()); + * + * // Extend the class, providing a custom constructor. + * function AnotherHttpAdapterClass () { + * HttpAdapter.call(this); + * this.created_at = new Date().getTime(); + * } + * HttpAdapter.extend({ + * constructor: AnotherHttpAdapterClass, + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const anotherHttpAdapter = new AnotherHttpAdapterClass(); + * console.log(anotherHttpAdapter.created_at); + * console.log(anotherHttpAdapter.foo()); + * console.log(AnotherHttpAdapterClass.beep()); + * + * @method HttpAdapter.extend + * @param {object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this HttpAdapter class. + * @since 3.0.0 + */ + +exports.HttpAdapter = HttpAdapter; +exports.addAction = addAction; +exports.addActions = addActions; +exports.version = version; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=js-data-http.js.map diff --git a/dist/js-data-http.js.map b/dist/js-data-http.js.map new file mode 100644 index 0000000..efeaa60 --- /dev/null +++ b/dist/js-data-http.js.map @@ -0,0 +1 @@ +{"version":3,"file":"js-data-http.js","sources":["../node_modules/axios/dist/axios.js","../node_modules/js-data-adapter/src/index.js","../src/index.js"],"sourcesContent":["/* axios v0.16.2 | (c) 2017 by Matt Zabriskie */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"axios\"] = factory();\n\telse\n\t\troot[\"axios\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(1);\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar bind = __webpack_require__(3);\n\tvar Axios = __webpack_require__(5);\n\tvar defaults = __webpack_require__(6);\n\t\n\t/**\n\t * Create an instance of Axios\n\t *\n\t * @param {Object} defaultConfig The default config for the instance\n\t * @return {Axios} A new instance of Axios\n\t */\n\tfunction createInstance(defaultConfig) {\n\t var context = new Axios(defaultConfig);\n\t var instance = bind(Axios.prototype.request, context);\n\t\n\t // Copy axios.prototype to instance\n\t utils.extend(instance, Axios.prototype, context);\n\t\n\t // Copy context to instance\n\t utils.extend(instance, context);\n\t\n\t return instance;\n\t}\n\t\n\t// Create the default instance to be exported\n\tvar axios = createInstance(defaults);\n\t\n\t// Expose Axios class to allow class inheritance\n\taxios.Axios = Axios;\n\t\n\t// Factory for creating new instances\n\taxios.create = function create(instanceConfig) {\n\t return createInstance(utils.merge(defaults, instanceConfig));\n\t};\n\t\n\t// Expose Cancel & CancelToken\n\taxios.Cancel = __webpack_require__(23);\n\taxios.CancelToken = __webpack_require__(24);\n\taxios.isCancel = __webpack_require__(20);\n\t\n\t// Expose all/spread\n\taxios.all = function all(promises) {\n\t return Promise.all(promises);\n\t};\n\taxios.spread = __webpack_require__(25);\n\t\n\tmodule.exports = axios;\n\t\n\t// Allow use of default import syntax in TypeScript\n\tmodule.exports.default = axios;\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar bind = __webpack_require__(3);\n\tvar isBuffer = __webpack_require__(4);\n\t\n\t/*global toString:true*/\n\t\n\t// utils is a library of generic helper functions non-specific to axios\n\t\n\tvar toString = Object.prototype.toString;\n\t\n\t/**\n\t * Determine if a value is an Array\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Array, otherwise false\n\t */\n\tfunction isArray(val) {\n\t return toString.call(val) === '[object Array]';\n\t}\n\t\n\t/**\n\t * Determine if a value is an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBuffer(val) {\n\t return toString.call(val) === '[object ArrayBuffer]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a FormData\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an FormData, otherwise false\n\t */\n\tfunction isFormData(val) {\n\t return (typeof FormData !== 'undefined') && (val instanceof FormData);\n\t}\n\t\n\t/**\n\t * Determine if a value is a view on an ArrayBuffer\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n\t */\n\tfunction isArrayBufferView(val) {\n\t var result;\n\t if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n\t result = ArrayBuffer.isView(val);\n\t } else {\n\t result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Determine if a value is a String\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a String, otherwise false\n\t */\n\tfunction isString(val) {\n\t return typeof val === 'string';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Number\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Number, otherwise false\n\t */\n\tfunction isNumber(val) {\n\t return typeof val === 'number';\n\t}\n\t\n\t/**\n\t * Determine if a value is undefined\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if the value is undefined, otherwise false\n\t */\n\tfunction isUndefined(val) {\n\t return typeof val === 'undefined';\n\t}\n\t\n\t/**\n\t * Determine if a value is an Object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is an Object, otherwise false\n\t */\n\tfunction isObject(val) {\n\t return val !== null && typeof val === 'object';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Date\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Date, otherwise false\n\t */\n\tfunction isDate(val) {\n\t return toString.call(val) === '[object Date]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a File\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a File, otherwise false\n\t */\n\tfunction isFile(val) {\n\t return toString.call(val) === '[object File]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Blob\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Blob, otherwise false\n\t */\n\tfunction isBlob(val) {\n\t return toString.call(val) === '[object Blob]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Function\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Function, otherwise false\n\t */\n\tfunction isFunction(val) {\n\t return toString.call(val) === '[object Function]';\n\t}\n\t\n\t/**\n\t * Determine if a value is a Stream\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a Stream, otherwise false\n\t */\n\tfunction isStream(val) {\n\t return isObject(val) && isFunction(val.pipe);\n\t}\n\t\n\t/**\n\t * Determine if a value is a URLSearchParams object\n\t *\n\t * @param {Object} val The value to test\n\t * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n\t */\n\tfunction isURLSearchParams(val) {\n\t return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;\n\t}\n\t\n\t/**\n\t * Trim excess whitespace off the beginning and end of a string\n\t *\n\t * @param {String} str The String to trim\n\t * @returns {String} The String freed of excess whitespace\n\t */\n\tfunction trim(str) {\n\t return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n\t}\n\t\n\t/**\n\t * Determine if we're running in a standard browser environment\n\t *\n\t * This allows axios to run in a web worker, and react-native.\n\t * Both environments support XMLHttpRequest, but not fully standard globals.\n\t *\n\t * web workers:\n\t * typeof window -> undefined\n\t * typeof document -> undefined\n\t *\n\t * react-native:\n\t * navigator.product -> 'ReactNative'\n\t */\n\tfunction isStandardBrowserEnv() {\n\t if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {\n\t return false;\n\t }\n\t return (\n\t typeof window !== 'undefined' &&\n\t typeof document !== 'undefined'\n\t );\n\t}\n\t\n\t/**\n\t * Iterate over an Array or an Object invoking a function for each item.\n\t *\n\t * If `obj` is an Array callback will be called passing\n\t * the value, index, and complete array for each item.\n\t *\n\t * If 'obj' is an Object callback will be called passing\n\t * the value, key, and complete object for each property.\n\t *\n\t * @param {Object|Array} obj The object to iterate\n\t * @param {Function} fn The callback to invoke for each item\n\t */\n\tfunction forEach(obj, fn) {\n\t // Don't bother if no value provided\n\t if (obj === null || typeof obj === 'undefined') {\n\t return;\n\t }\n\t\n\t // Force an array if not already something iterable\n\t if (typeof obj !== 'object' && !isArray(obj)) {\n\t /*eslint no-param-reassign:0*/\n\t obj = [obj];\n\t }\n\t\n\t if (isArray(obj)) {\n\t // Iterate over array values\n\t for (var i = 0, l = obj.length; i < l; i++) {\n\t fn.call(null, obj[i], i, obj);\n\t }\n\t } else {\n\t // Iterate over object keys\n\t for (var key in obj) {\n\t if (Object.prototype.hasOwnProperty.call(obj, key)) {\n\t fn.call(null, obj[key], key, obj);\n\t }\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * Accepts varargs expecting each argument to be an object, then\n\t * immutably merges the properties of each object and returns result.\n\t *\n\t * When multiple objects contain the same key the later object in\n\t * the arguments list will take precedence.\n\t *\n\t * Example:\n\t *\n\t * ```js\n\t * var result = merge({foo: 123}, {foo: 456});\n\t * console.log(result.foo); // outputs 456\n\t * ```\n\t *\n\t * @param {Object} obj1 Object to merge\n\t * @returns {Object} Result of all merge properties\n\t */\n\tfunction merge(/* obj1, obj2, obj3, ... */) {\n\t var result = {};\n\t function assignValue(val, key) {\n\t if (typeof result[key] === 'object' && typeof val === 'object') {\n\t result[key] = merge(result[key], val);\n\t } else {\n\t result[key] = val;\n\t }\n\t }\n\t\n\t for (var i = 0, l = arguments.length; i < l; i++) {\n\t forEach(arguments[i], assignValue);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Extends object a by mutably adding to it the properties of object b.\n\t *\n\t * @param {Object} a The object to be extended\n\t * @param {Object} b The object to copy properties from\n\t * @param {Object} thisArg The object to bind function to\n\t * @return {Object} The resulting value of object a\n\t */\n\tfunction extend(a, b, thisArg) {\n\t forEach(b, function assignValue(val, key) {\n\t if (thisArg && typeof val === 'function') {\n\t a[key] = bind(val, thisArg);\n\t } else {\n\t a[key] = val;\n\t }\n\t });\n\t return a;\n\t}\n\t\n\tmodule.exports = {\n\t isArray: isArray,\n\t isArrayBuffer: isArrayBuffer,\n\t isBuffer: isBuffer,\n\t isFormData: isFormData,\n\t isArrayBufferView: isArrayBufferView,\n\t isString: isString,\n\t isNumber: isNumber,\n\t isObject: isObject,\n\t isUndefined: isUndefined,\n\t isDate: isDate,\n\t isFile: isFile,\n\t isBlob: isBlob,\n\t isFunction: isFunction,\n\t isStream: isStream,\n\t isURLSearchParams: isURLSearchParams,\n\t isStandardBrowserEnv: isStandardBrowserEnv,\n\t forEach: forEach,\n\t merge: merge,\n\t extend: extend,\n\t trim: trim\n\t};\n\n\n/***/ },\n/* 3 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = function bind(fn, thisArg) {\n\t return function wrap() {\n\t var args = new Array(arguments.length);\n\t for (var i = 0; i < args.length; i++) {\n\t args[i] = arguments[i];\n\t }\n\t return fn.apply(thisArg, args);\n\t };\n\t};\n\n\n/***/ },\n/* 4 */\n/***/ function(module, exports) {\n\n\t/*!\n\t * Determine if an object is a Buffer\n\t *\n\t * @author Feross Aboukhadijeh \n\t * @license MIT\n\t */\n\t\n\t// The _isBuffer check is for Safari 5-7 support, because it's missing\n\t// Object.prototype.constructor. Remove this eventually\n\tmodule.exports = function (obj) {\n\t return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)\n\t}\n\t\n\tfunction isBuffer (obj) {\n\t return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)\n\t}\n\t\n\t// For Node v0.10 support. Remove this eventually.\n\tfunction isSlowBuffer (obj) {\n\t return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))\n\t}\n\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar defaults = __webpack_require__(6);\n\tvar utils = __webpack_require__(2);\n\tvar InterceptorManager = __webpack_require__(17);\n\tvar dispatchRequest = __webpack_require__(18);\n\tvar isAbsoluteURL = __webpack_require__(21);\n\tvar combineURLs = __webpack_require__(22);\n\t\n\t/**\n\t * Create a new instance of Axios\n\t *\n\t * @param {Object} instanceConfig The default config for the instance\n\t */\n\tfunction Axios(instanceConfig) {\n\t this.defaults = instanceConfig;\n\t this.interceptors = {\n\t request: new InterceptorManager(),\n\t response: new InterceptorManager()\n\t };\n\t}\n\t\n\t/**\n\t * Dispatch a request\n\t *\n\t * @param {Object} config The config specific for this request (merged with this.defaults)\n\t */\n\tAxios.prototype.request = function request(config) {\n\t /*eslint no-param-reassign:0*/\n\t // Allow for axios('example/url'[, config]) a la fetch API\n\t if (typeof config === 'string') {\n\t config = utils.merge({\n\t url: arguments[0]\n\t }, arguments[1]);\n\t }\n\t\n\t config = utils.merge(defaults, this.defaults, { method: 'get' }, config);\n\t config.method = config.method.toLowerCase();\n\t\n\t // Support baseURL config\n\t if (config.baseURL && !isAbsoluteURL(config.url)) {\n\t config.url = combineURLs(config.baseURL, config.url);\n\t }\n\t\n\t // Hook up interceptors middleware\n\t var chain = [dispatchRequest, undefined];\n\t var promise = Promise.resolve(config);\n\t\n\t this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n\t chain.unshift(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n\t chain.push(interceptor.fulfilled, interceptor.rejected);\n\t });\n\t\n\t while (chain.length) {\n\t promise = promise.then(chain.shift(), chain.shift());\n\t }\n\t\n\t return promise;\n\t};\n\t\n\t// Provide aliases for supported request methods\n\tutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, config) {\n\t return this.request(utils.merge(config || {}, {\n\t method: method,\n\t url: url\n\t }));\n\t };\n\t});\n\t\n\tutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n\t /*eslint func-names:0*/\n\t Axios.prototype[method] = function(url, data, config) {\n\t return this.request(utils.merge(config || {}, {\n\t method: method,\n\t url: url,\n\t data: data\n\t }));\n\t };\n\t});\n\t\n\tmodule.exports = Axios;\n\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar normalizeHeaderName = __webpack_require__(7);\n\t\n\tvar DEFAULT_CONTENT_TYPE = {\n\t 'Content-Type': 'application/x-www-form-urlencoded'\n\t};\n\t\n\tfunction setContentTypeIfUnset(headers, value) {\n\t if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {\n\t headers['Content-Type'] = value;\n\t }\n\t}\n\t\n\tfunction getDefaultAdapter() {\n\t var adapter;\n\t if (typeof XMLHttpRequest !== 'undefined') {\n\t // For browsers use XHR adapter\n\t adapter = __webpack_require__(8);\n\t } else if (typeof process !== 'undefined') {\n\t // For node use HTTP adapter\n\t adapter = __webpack_require__(8);\n\t }\n\t return adapter;\n\t}\n\t\n\tvar defaults = {\n\t adapter: getDefaultAdapter(),\n\t\n\t transformRequest: [function transformRequest(data, headers) {\n\t normalizeHeaderName(headers, 'Content-Type');\n\t if (utils.isFormData(data) ||\n\t utils.isArrayBuffer(data) ||\n\t utils.isBuffer(data) ||\n\t utils.isStream(data) ||\n\t utils.isFile(data) ||\n\t utils.isBlob(data)\n\t ) {\n\t return data;\n\t }\n\t if (utils.isArrayBufferView(data)) {\n\t return data.buffer;\n\t }\n\t if (utils.isURLSearchParams(data)) {\n\t setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');\n\t return data.toString();\n\t }\n\t if (utils.isObject(data)) {\n\t setContentTypeIfUnset(headers, 'application/json;charset=utf-8');\n\t return JSON.stringify(data);\n\t }\n\t return data;\n\t }],\n\t\n\t transformResponse: [function transformResponse(data) {\n\t /*eslint no-param-reassign:0*/\n\t if (typeof data === 'string') {\n\t try {\n\t data = JSON.parse(data);\n\t } catch (e) { /* Ignore */ }\n\t }\n\t return data;\n\t }],\n\t\n\t timeout: 0,\n\t\n\t xsrfCookieName: 'XSRF-TOKEN',\n\t xsrfHeaderName: 'X-XSRF-TOKEN',\n\t\n\t maxContentLength: -1,\n\t\n\t validateStatus: function validateStatus(status) {\n\t return status >= 200 && status < 300;\n\t }\n\t};\n\t\n\tdefaults.headers = {\n\t common: {\n\t 'Accept': 'application/json, text/plain, */*'\n\t }\n\t};\n\t\n\tutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n\t defaults.headers[method] = {};\n\t});\n\t\n\tutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n\t defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n\t});\n\t\n\tmodule.exports = defaults;\n\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = function normalizeHeaderName(headers, normalizedName) {\n\t utils.forEach(headers, function processHeader(value, name) {\n\t if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {\n\t headers[normalizedName] = value;\n\t delete headers[name];\n\t }\n\t });\n\t};\n\n\n/***/ },\n/* 8 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar settle = __webpack_require__(9);\n\tvar buildURL = __webpack_require__(12);\n\tvar parseHeaders = __webpack_require__(13);\n\tvar isURLSameOrigin = __webpack_require__(14);\n\tvar createError = __webpack_require__(10);\n\tvar btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15);\n\t\n\tmodule.exports = function xhrAdapter(config) {\n\t return new Promise(function dispatchXhrRequest(resolve, reject) {\n\t var requestData = config.data;\n\t var requestHeaders = config.headers;\n\t\n\t if (utils.isFormData(requestData)) {\n\t delete requestHeaders['Content-Type']; // Let the browser set it\n\t }\n\t\n\t var request = new XMLHttpRequest();\n\t var loadEvent = 'onreadystatechange';\n\t var xDomain = false;\n\t\n\t // For IE 8/9 CORS support\n\t // Only supports POST and GET calls and doesn't returns the response headers.\n\t // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.\n\t if ((\"production\") !== 'test' &&\n\t typeof window !== 'undefined' &&\n\t window.XDomainRequest && !('withCredentials' in request) &&\n\t !isURLSameOrigin(config.url)) {\n\t request = new window.XDomainRequest();\n\t loadEvent = 'onload';\n\t xDomain = true;\n\t request.onprogress = function handleProgress() {};\n\t request.ontimeout = function handleTimeout() {};\n\t }\n\t\n\t // HTTP basic authentication\n\t if (config.auth) {\n\t var username = config.auth.username || '';\n\t var password = config.auth.password || '';\n\t requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n\t }\n\t\n\t request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);\n\t\n\t // Set the request timeout in MS\n\t request.timeout = config.timeout;\n\t\n\t // Listen for ready state\n\t request[loadEvent] = function handleLoad() {\n\t if (!request || (request.readyState !== 4 && !xDomain)) {\n\t return;\n\t }\n\t\n\t // The request errored out and we didn't get a response, this will be\n\t // handled by onerror instead\n\t // With one exception: request that using file: protocol, most browsers\n\t // will return status as 0 even though it's a successful request\n\t if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n\t return;\n\t }\n\t\n\t // Prepare the response\n\t var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n\t var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n\t var response = {\n\t data: responseData,\n\t // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)\n\t status: request.status === 1223 ? 204 : request.status,\n\t statusText: request.status === 1223 ? 'No Content' : request.statusText,\n\t headers: responseHeaders,\n\t config: config,\n\t request: request\n\t };\n\t\n\t settle(resolve, reject, response);\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle low level network errors\n\t request.onerror = function handleError() {\n\t // Real errors are hidden from us by the browser\n\t // onerror should only fire if it's a network error\n\t reject(createError('Network Error', config, null, request));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Handle timeout\n\t request.ontimeout = function handleTimeout() {\n\t reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',\n\t request));\n\t\n\t // Clean up request\n\t request = null;\n\t };\n\t\n\t // Add xsrf header\n\t // This is only done if running in a standard browser environment.\n\t // Specifically not if we're in a web worker, or react-native.\n\t if (utils.isStandardBrowserEnv()) {\n\t var cookies = __webpack_require__(16);\n\t\n\t // Add xsrf header\n\t var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?\n\t cookies.read(config.xsrfCookieName) :\n\t undefined;\n\t\n\t if (xsrfValue) {\n\t requestHeaders[config.xsrfHeaderName] = xsrfValue;\n\t }\n\t }\n\t\n\t // Add headers to the request\n\t if ('setRequestHeader' in request) {\n\t utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n\t if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n\t // Remove Content-Type if data is undefined\n\t delete requestHeaders[key];\n\t } else {\n\t // Otherwise add header to the request\n\t request.setRequestHeader(key, val);\n\t }\n\t });\n\t }\n\t\n\t // Add withCredentials to request if needed\n\t if (config.withCredentials) {\n\t request.withCredentials = true;\n\t }\n\t\n\t // Add responseType to request if needed\n\t if (config.responseType) {\n\t try {\n\t request.responseType = config.responseType;\n\t } catch (e) {\n\t // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n\t // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n\t if (config.responseType !== 'json') {\n\t throw e;\n\t }\n\t }\n\t }\n\t\n\t // Handle progress if needed\n\t if (typeof config.onDownloadProgress === 'function') {\n\t request.addEventListener('progress', config.onDownloadProgress);\n\t }\n\t\n\t // Not all browsers support upload events\n\t if (typeof config.onUploadProgress === 'function' && request.upload) {\n\t request.upload.addEventListener('progress', config.onUploadProgress);\n\t }\n\t\n\t if (config.cancelToken) {\n\t // Handle cancellation\n\t config.cancelToken.promise.then(function onCanceled(cancel) {\n\t if (!request) {\n\t return;\n\t }\n\t\n\t request.abort();\n\t reject(cancel);\n\t // Clean up request\n\t request = null;\n\t });\n\t }\n\t\n\t if (requestData === undefined) {\n\t requestData = null;\n\t }\n\t\n\t // Send the request\n\t request.send(requestData);\n\t });\n\t};\n\n\n/***/ },\n/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar createError = __webpack_require__(10);\n\t\n\t/**\n\t * Resolve or reject a Promise based on response status.\n\t *\n\t * @param {Function} resolve A function that resolves the promise.\n\t * @param {Function} reject A function that rejects the promise.\n\t * @param {object} response The response.\n\t */\n\tmodule.exports = function settle(resolve, reject, response) {\n\t var validateStatus = response.config.validateStatus;\n\t // Note: status is not exposed by XDomainRequest\n\t if (!response.status || !validateStatus || validateStatus(response.status)) {\n\t resolve(response);\n\t } else {\n\t reject(createError(\n\t 'Request failed with status code ' + response.status,\n\t response.config,\n\t null,\n\t response.request,\n\t response\n\t ));\n\t }\n\t};\n\n\n/***/ },\n/* 10 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar enhanceError = __webpack_require__(11);\n\t\n\t/**\n\t * Create an Error with the specified message, config, error code, request and response.\n\t *\n\t * @param {string} message The error message.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t * @param {Object} [request] The request.\n\t * @param {Object} [response] The response.\n\t * @returns {Error} The created error.\n\t */\n\tmodule.exports = function createError(message, config, code, request, response) {\n\t var error = new Error(message);\n\t return enhanceError(error, config, code, request, response);\n\t};\n\n\n/***/ },\n/* 11 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Update an Error with the specified config, error code, and response.\n\t *\n\t * @param {Error} error The error to update.\n\t * @param {Object} config The config.\n\t * @param {string} [code] The error code (for example, 'ECONNABORTED').\n\t * @param {Object} [request] The request.\n\t * @param {Object} [response] The response.\n\t * @returns {Error} The error.\n\t */\n\tmodule.exports = function enhanceError(error, config, code, request, response) {\n\t error.config = config;\n\t if (code) {\n\t error.code = code;\n\t }\n\t error.request = request;\n\t error.response = response;\n\t return error;\n\t};\n\n\n/***/ },\n/* 12 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction encode(val) {\n\t return encodeURIComponent(val).\n\t replace(/%40/gi, '@').\n\t replace(/%3A/gi, ':').\n\t replace(/%24/g, '$').\n\t replace(/%2C/gi, ',').\n\t replace(/%20/g, '+').\n\t replace(/%5B/gi, '[').\n\t replace(/%5D/gi, ']');\n\t}\n\t\n\t/**\n\t * Build a URL by appending params to the end\n\t *\n\t * @param {string} url The base of the url (e.g., http://www.google.com)\n\t * @param {object} [params] The params to be appended\n\t * @returns {string} The formatted url\n\t */\n\tmodule.exports = function buildURL(url, params, paramsSerializer) {\n\t /*eslint no-param-reassign:0*/\n\t if (!params) {\n\t return url;\n\t }\n\t\n\t var serializedParams;\n\t if (paramsSerializer) {\n\t serializedParams = paramsSerializer(params);\n\t } else if (utils.isURLSearchParams(params)) {\n\t serializedParams = params.toString();\n\t } else {\n\t var parts = [];\n\t\n\t utils.forEach(params, function serialize(val, key) {\n\t if (val === null || typeof val === 'undefined') {\n\t return;\n\t }\n\t\n\t if (utils.isArray(val)) {\n\t key = key + '[]';\n\t }\n\t\n\t if (!utils.isArray(val)) {\n\t val = [val];\n\t }\n\t\n\t utils.forEach(val, function parseValue(v) {\n\t if (utils.isDate(v)) {\n\t v = v.toISOString();\n\t } else if (utils.isObject(v)) {\n\t v = JSON.stringify(v);\n\t }\n\t parts.push(encode(key) + '=' + encode(v));\n\t });\n\t });\n\t\n\t serializedParams = parts.join('&');\n\t }\n\t\n\t if (serializedParams) {\n\t url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n\t }\n\t\n\t return url;\n\t};\n\n\n/***/ },\n/* 13 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t/**\n\t * Parse headers into an object\n\t *\n\t * ```\n\t * Date: Wed, 27 Aug 2014 08:58:49 GMT\n\t * Content-Type: application/json\n\t * Connection: keep-alive\n\t * Transfer-Encoding: chunked\n\t * ```\n\t *\n\t * @param {String} headers Headers needing to be parsed\n\t * @returns {Object} Headers parsed into an object\n\t */\n\tmodule.exports = function parseHeaders(headers) {\n\t var parsed = {};\n\t var key;\n\t var val;\n\t var i;\n\t\n\t if (!headers) { return parsed; }\n\t\n\t utils.forEach(headers.split('\\n'), function parser(line) {\n\t i = line.indexOf(':');\n\t key = utils.trim(line.substr(0, i)).toLowerCase();\n\t val = utils.trim(line.substr(i + 1));\n\t\n\t if (key) {\n\t parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n\t }\n\t });\n\t\n\t return parsed;\n\t};\n\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs have full support of the APIs needed to test\n\t // whether the request URL is of the same origin as current location.\n\t (function standardBrowserEnv() {\n\t var msie = /(msie|trident)/i.test(navigator.userAgent);\n\t var urlParsingNode = document.createElement('a');\n\t var originURL;\n\t\n\t /**\n\t * Parse a URL to discover it's components\n\t *\n\t * @param {String} url The URL to be parsed\n\t * @returns {Object}\n\t */\n\t function resolveURL(url) {\n\t var href = url;\n\t\n\t if (msie) {\n\t // IE needs attribute set twice to normalize properties\n\t urlParsingNode.setAttribute('href', href);\n\t href = urlParsingNode.href;\n\t }\n\t\n\t urlParsingNode.setAttribute('href', href);\n\t\n\t // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n\t return {\n\t href: urlParsingNode.href,\n\t protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n\t host: urlParsingNode.host,\n\t search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n\t hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n\t hostname: urlParsingNode.hostname,\n\t port: urlParsingNode.port,\n\t pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n\t urlParsingNode.pathname :\n\t '/' + urlParsingNode.pathname\n\t };\n\t }\n\t\n\t originURL = resolveURL(window.location.href);\n\t\n\t /**\n\t * Determine if a URL shares the same origin as the current location\n\t *\n\t * @param {String} requestURL The URL to test\n\t * @returns {boolean} True if URL shares the same origin, otherwise false\n\t */\n\t return function isURLSameOrigin(requestURL) {\n\t var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n\t return (parsed.protocol === originURL.protocol &&\n\t parsed.host === originURL.host);\n\t };\n\t })() :\n\t\n\t // Non standard browser envs (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return function isURLSameOrigin() {\n\t return true;\n\t };\n\t })()\n\t);\n\n\n/***/ },\n/* 15 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js\n\t\n\tvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\t\n\tfunction E() {\n\t this.message = 'String contains an invalid character';\n\t}\n\tE.prototype = new Error;\n\tE.prototype.code = 5;\n\tE.prototype.name = 'InvalidCharacterError';\n\t\n\tfunction btoa(input) {\n\t var str = String(input);\n\t var output = '';\n\t for (\n\t // initialize result and counter\n\t var block, charCode, idx = 0, map = chars;\n\t // if the next str index does not exist:\n\t // change the mapping table to \"=\"\n\t // check if d has no fractional digits\n\t str.charAt(idx | 0) || (map = '=', idx % 1);\n\t // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n\t output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n\t ) {\n\t charCode = str.charCodeAt(idx += 3 / 4);\n\t if (charCode > 0xFF) {\n\t throw new E();\n\t }\n\t block = block << 8 | charCode;\n\t }\n\t return output;\n\t}\n\t\n\tmodule.exports = btoa;\n\n\n/***/ },\n/* 16 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tmodule.exports = (\n\t utils.isStandardBrowserEnv() ?\n\t\n\t // Standard browser envs support document.cookie\n\t (function standardBrowserEnv() {\n\t return {\n\t write: function write(name, value, expires, path, domain, secure) {\n\t var cookie = [];\n\t cookie.push(name + '=' + encodeURIComponent(value));\n\t\n\t if (utils.isNumber(expires)) {\n\t cookie.push('expires=' + new Date(expires).toGMTString());\n\t }\n\t\n\t if (utils.isString(path)) {\n\t cookie.push('path=' + path);\n\t }\n\t\n\t if (utils.isString(domain)) {\n\t cookie.push('domain=' + domain);\n\t }\n\t\n\t if (secure === true) {\n\t cookie.push('secure');\n\t }\n\t\n\t document.cookie = cookie.join('; ');\n\t },\n\t\n\t read: function read(name) {\n\t var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n\t return (match ? decodeURIComponent(match[3]) : null);\n\t },\n\t\n\t remove: function remove(name) {\n\t this.write(name, '', Date.now() - 86400000);\n\t }\n\t };\n\t })() :\n\t\n\t // Non standard browser env (web workers, react-native) lack needed support.\n\t (function nonStandardBrowserEnv() {\n\t return {\n\t write: function write() {},\n\t read: function read() { return null; },\n\t remove: function remove() {}\n\t };\n\t })()\n\t);\n\n\n/***/ },\n/* 17 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\tfunction InterceptorManager() {\n\t this.handlers = [];\n\t}\n\t\n\t/**\n\t * Add a new interceptor to the stack\n\t *\n\t * @param {Function} fulfilled The function to handle `then` for a `Promise`\n\t * @param {Function} rejected The function to handle `reject` for a `Promise`\n\t *\n\t * @return {Number} An ID used to remove interceptor later\n\t */\n\tInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n\t this.handlers.push({\n\t fulfilled: fulfilled,\n\t rejected: rejected\n\t });\n\t return this.handlers.length - 1;\n\t};\n\t\n\t/**\n\t * Remove an interceptor from the stack\n\t *\n\t * @param {Number} id The ID that was returned by `use`\n\t */\n\tInterceptorManager.prototype.eject = function eject(id) {\n\t if (this.handlers[id]) {\n\t this.handlers[id] = null;\n\t }\n\t};\n\t\n\t/**\n\t * Iterate over all the registered interceptors\n\t *\n\t * This method is particularly useful for skipping over any\n\t * interceptors that may have become `null` calling `eject`.\n\t *\n\t * @param {Function} fn The function to call for each interceptor\n\t */\n\tInterceptorManager.prototype.forEach = function forEach(fn) {\n\t utils.forEach(this.handlers, function forEachHandler(h) {\n\t if (h !== null) {\n\t fn(h);\n\t }\n\t });\n\t};\n\t\n\tmodule.exports = InterceptorManager;\n\n\n/***/ },\n/* 18 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\tvar transformData = __webpack_require__(19);\n\tvar isCancel = __webpack_require__(20);\n\tvar defaults = __webpack_require__(6);\n\t\n\t/**\n\t * Throws a `Cancel` if cancellation has been requested.\n\t */\n\tfunction throwIfCancellationRequested(config) {\n\t if (config.cancelToken) {\n\t config.cancelToken.throwIfRequested();\n\t }\n\t}\n\t\n\t/**\n\t * Dispatch a request to the server using the configured adapter.\n\t *\n\t * @param {object} config The config that is to be used for the request\n\t * @returns {Promise} The Promise to be fulfilled\n\t */\n\tmodule.exports = function dispatchRequest(config) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Ensure headers exist\n\t config.headers = config.headers || {};\n\t\n\t // Transform request data\n\t config.data = transformData(\n\t config.data,\n\t config.headers,\n\t config.transformRequest\n\t );\n\t\n\t // Flatten headers\n\t config.headers = utils.merge(\n\t config.headers.common || {},\n\t config.headers[config.method] || {},\n\t config.headers || {}\n\t );\n\t\n\t utils.forEach(\n\t ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n\t function cleanHeaderConfig(method) {\n\t delete config.headers[method];\n\t }\n\t );\n\t\n\t var adapter = config.adapter || defaults.adapter;\n\t\n\t return adapter(config).then(function onAdapterResolution(response) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Transform response data\n\t response.data = transformData(\n\t response.data,\n\t response.headers,\n\t config.transformResponse\n\t );\n\t\n\t return response;\n\t }, function onAdapterRejection(reason) {\n\t if (!isCancel(reason)) {\n\t throwIfCancellationRequested(config);\n\t\n\t // Transform response data\n\t if (reason && reason.response) {\n\t reason.response.data = transformData(\n\t reason.response.data,\n\t reason.response.headers,\n\t config.transformResponse\n\t );\n\t }\n\t }\n\t\n\t return Promise.reject(reason);\n\t });\n\t};\n\n\n/***/ },\n/* 19 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(2);\n\t\n\t/**\n\t * Transform the data for a request or a response\n\t *\n\t * @param {Object|String} data The data to be transformed\n\t * @param {Array} headers The headers for the request or response\n\t * @param {Array|Function} fns A single function or Array of functions\n\t * @returns {*} The resulting transformed data\n\t */\n\tmodule.exports = function transformData(data, headers, fns) {\n\t /*eslint no-param-reassign:0*/\n\t utils.forEach(fns, function transform(fn) {\n\t data = fn(data, headers);\n\t });\n\t\n\t return data;\n\t};\n\n\n/***/ },\n/* 20 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = function isCancel(value) {\n\t return !!(value && value.__CANCEL__);\n\t};\n\n\n/***/ },\n/* 21 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Determines whether the specified URL is absolute\n\t *\n\t * @param {string} url The URL to test\n\t * @returns {boolean} True if the specified URL is absolute, otherwise false\n\t */\n\tmodule.exports = function isAbsoluteURL(url) {\n\t // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n\t // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n\t // by any combination of letters, digits, plus, period, or hyphen.\n\t return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n\t};\n\n\n/***/ },\n/* 22 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Creates a new URL by combining the specified URLs\n\t *\n\t * @param {string} baseURL The base URL\n\t * @param {string} relativeURL The relative URL\n\t * @returns {string} The combined URL\n\t */\n\tmodule.exports = function combineURLs(baseURL, relativeURL) {\n\t return relativeURL\n\t ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n\t : baseURL;\n\t};\n\n\n/***/ },\n/* 23 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * A `Cancel` is an object that is thrown when an operation is canceled.\n\t *\n\t * @class\n\t * @param {string=} message The message.\n\t */\n\tfunction Cancel(message) {\n\t this.message = message;\n\t}\n\t\n\tCancel.prototype.toString = function toString() {\n\t return 'Cancel' + (this.message ? ': ' + this.message : '');\n\t};\n\t\n\tCancel.prototype.__CANCEL__ = true;\n\t\n\tmodule.exports = Cancel;\n\n\n/***/ },\n/* 24 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar Cancel = __webpack_require__(23);\n\t\n\t/**\n\t * A `CancelToken` is an object that can be used to request cancellation of an operation.\n\t *\n\t * @class\n\t * @param {Function} executor The executor function.\n\t */\n\tfunction CancelToken(executor) {\n\t if (typeof executor !== 'function') {\n\t throw new TypeError('executor must be a function.');\n\t }\n\t\n\t var resolvePromise;\n\t this.promise = new Promise(function promiseExecutor(resolve) {\n\t resolvePromise = resolve;\n\t });\n\t\n\t var token = this;\n\t executor(function cancel(message) {\n\t if (token.reason) {\n\t // Cancellation has already been requested\n\t return;\n\t }\n\t\n\t token.reason = new Cancel(message);\n\t resolvePromise(token.reason);\n\t });\n\t}\n\t\n\t/**\n\t * Throws a `Cancel` if cancellation has been requested.\n\t */\n\tCancelToken.prototype.throwIfRequested = function throwIfRequested() {\n\t if (this.reason) {\n\t throw this.reason;\n\t }\n\t};\n\t\n\t/**\n\t * Returns an object that contains a new `CancelToken` and a function that, when called,\n\t * cancels the `CancelToken`.\n\t */\n\tCancelToken.source = function source() {\n\t var cancel;\n\t var token = new CancelToken(function executor(c) {\n\t cancel = c;\n\t });\n\t return {\n\t token: token,\n\t cancel: cancel\n\t };\n\t};\n\t\n\tmodule.exports = CancelToken;\n\n\n/***/ },\n/* 25 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t/**\n\t * Syntactic sugar for invoking a function and expanding an array for arguments.\n\t *\n\t * Common use case would be to use `Function.prototype.apply`.\n\t *\n\t * ```js\n\t * function f(x, y, z) {}\n\t * var args = [1, 2, 3];\n\t * f.apply(null, args);\n\t * ```\n\t *\n\t * With `spread` this example can be re-written.\n\t *\n\t * ```js\n\t * spread(function(x, y, z) {})([1, 2, 3]);\n\t * ```\n\t *\n\t * @param {Function} callback\n\t * @returns {Function}\n\t */\n\tmodule.exports = function spread(callback) {\n\t return function wrap(arr) {\n\t return callback.apply(null, arr);\n\t };\n\t};\n\n\n/***/ }\n/******/ ])\n});\n;\n//# sourceMappingURL=axios.map","import { Component, utils } from 'js-data'\n\nexport const noop = function (...args) {\n const opts = args[args.length - 1]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const opts = args[args.length - 2]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const unique = function (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\n\nexport const withoutRelations = function (mapper, props, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n const relationFields = mapper.relationFields || []\n const toStrip = relationFields.filter((value) => opts.with.indexOf(value) === -1)\n return utils.omit(props, toStrip)\n}\n\nexport const reserved = [\n 'orderBy',\n 'sort',\n 'limit',\n 'offset',\n 'skip',\n 'where'\n]\n\n/**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\nexport function Response (data, meta, op) {\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n this.data = data\n\n utils.fillIn(this, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n this.op = op\n}\n\nconst DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @extends Component\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\nexport function Adapter (opts) {\n utils.classCallCheck(this, Adapter)\n Component.call(this, opts)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(this, opts)\n}\n\nComponent.extend({\n constructor: Adapter,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {string} field The `field` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._count(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'create'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._create(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'create')\n response.created = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = props.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'createMany'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._createMany(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'createMany')\n response.created = data.length\n response = this.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'destroy'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._destroy(mapper, id, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = this.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'destroyAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._destroyAll(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = this.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo (mapper, def, records, __opts) {\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts)\n .then((relatedItem) => {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records\n .map((record) => this.makeBelongsToForeignKey(mapper, def, record))\n .filter((key) => key)\n return this.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((record) => {\n relatedItems.forEach((relatedItem) => {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem)\n }\n })\n })\n })\n }\n },\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'find'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._find(mapper, id, opts))\n })\n .then((results) => this.loadRelationsFor(mapper, results, opts))\n .then(([record, meta]) => {\n let response = new Response(record, meta, 'find')\n response.found = record ? 1 : 0\n response = this.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n const activeWith = opts._activeWith\n\n if (utils.isObject(activeWith)) {\n const activeQuery = activeWith.query || {}\n if (activeWith.replace) {\n query = activeQuery\n } else {\n utils.deepFillIn(query, activeQuery)\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'findAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._findAll(mapper, query, opts))\n })\n .then((results) => this.loadRelationsFor(mapper, results, opts))\n .then(([records, meta]) => {\n let response = new Response(records, meta, 'findAll')\n response.found = records.length\n response = this.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n loadRelationsFor (mapper, results, opts) {\n const [records] = results\n const tasks = []\n\n if (records) {\n utils.forEachRelation(mapper, opts, (def, __opts) => {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = this.loadHasOne(mapper, def, records, __opts)\n } else {\n task = this.loadHasMany(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = this.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = this.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = this.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n }\n\n return utils.Promise.all(tasks)\n .then(() => results)\n },\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt (opt, opts) {\n opts || (opts = {})\n return opts[opt] === undefined ? utils.plainCopy(this[opt]) : utils.plainCopy(opts[opt])\n },\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany (mapper, def, records, __opts) {\n let singular = false\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n const IDs = records.map((record) => this.makeHasManyForeignKey(mapper, def, record))\n const query = {\n where: {}\n }\n const criteria = query.where[def.foreignKey] = {}\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0]\n } else {\n criteria['in'] = IDs.filter((id) => id)\n }\n return this.findAll(def.getRelation(), query, __opts).then((relatedItems) => {\n records.forEach((record) => {\n let attached = []\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems\n } else {\n relatedItems.forEach((relatedItem) => {\n if (utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem)\n }\n })\n }\n def.setLocalField(record, attached)\n })\n })\n },\n\n loadHasManyLocalKeys (mapper, def, records, __opts) {\n let record\n const relatedMapper = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': this.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach((record) => {\n localKeys = localKeys.concat(this.makeHasManyLocalKeys(mapper, def, record))\n })\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter((x) => x)\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((item) => {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach((relatedItem) => {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem)\n }\n })\n def.setLocalField(item, attached)\n })\n return relatedItems\n })\n }\n },\n\n loadHasManyForeignKeys (mapper, def, records, __opts) {\n const relatedMapper = def.getRelation()\n const idAttribute = mapper.idAttribute\n let record\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': this.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return this.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map((record) => this.makeHasManyForeignKeys(mapper, def, record))\n }\n }\n }, __opts).then((relatedItems) => {\n const foreignKeysField = def.foreignKeys\n records.forEach((record) => {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach((relatedItem) => {\n const foreignKeys = utils.get(relatedItems, foreignKeysField) || []\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem)\n }\n })\n def.setLocalField(record, _relatedItems)\n })\n })\n }\n },\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne (mapper, def, records, __opts) {\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n }\n return this.loadHasMany(mapper, def, records, __opts).then(() => {\n records.forEach((record) => {\n const relatedData = def.getLocalField(record)\n if (utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0])\n }\n })\n })\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n let localKeys = []\n let itemKeys = utils.get(record, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n return unique(localKeys).filter((x) => x)\n },\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys (mapper, def, record) {\n return utils.get(record, mapper.idAttribute)\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n let op\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n query || (query = {})\n opts || (opts = {})\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum'\n return utils.resolve(this[op](mapper, field, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n this.dbg(op, mapper, field, query, opts)\n return utils.resolve(this._sum(mapper, field, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(this[op](mapper, field, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond (response, opts) {\n return this.getOpt('raw', opts) ? response : response.data\n },\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(this[op](mapper, id, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'update'\n this.dbg(op, mapper, id, props, opts)\n return utils.resolve(this._update(mapper, id, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'update')\n response.updated = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(this[op](mapper, id, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let op\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'updateAll'\n this.dbg(op, mapper, props, query, opts)\n return utils.resolve(this._updateAll(mapper, props, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateAll')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter((record) => utils.get(record, idAttribute))\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(this[op](mapper, records, opts))\n .then((_records) => {\n // Allow for re-assignment from lifecycle hook\n records = _records === undefined ? records : _records\n records = records.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'updateMany'\n this.dbg(op, mapper, records, opts)\n return utils.resolve(this._updateMany(mapper, records, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateMany')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(this[op](mapper, records, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n }\n})\n\n/**\n * Create a subclass of this Adapter:\n *\n * @example Adapter.extend\n * // Normally you would do: import {Adapter} from 'js-data'\n * const JSData = require('js-data@3.0.0-beta.10')\n * const {Adapter} = JSData\n * console.log('Using JSData v' + JSData.version.full)\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomAdapterClass extends Adapter {\n * foo () { return 'bar' }\n * static beep () { return 'boop' }\n * }\n * const customAdapter = new CustomAdapterClass()\n * console.log(customAdapter.foo())\n * console.log(CustomAdapterClass.beep())\n *\n * // Extend the class using alternate method.\n * const OtherAdapterClass = Adapter.extend({\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const otherAdapter = new OtherAdapterClass()\n * console.log(otherAdapter.foo())\n * console.log(OtherAdapterClass.beep())\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherAdapterClass () {\n * Adapter.call(this)\n * this.created_at = new Date().getTime()\n * }\n * Adapter.extend({\n * constructor: AnotherAdapterClass,\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const anotherAdapter = new AnotherAdapterClass()\n * console.log(anotherAdapter.created_at)\n * console.log(anotherAdapter.foo())\n * console.log(AnotherAdapterClass.beep())\n *\n * @method Adapter.extend\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this Adapter class.\n */\n","import { utils } from 'js-data'\nimport axios from '../node_modules/axios/dist/axios'\nimport {\n Adapter,\n noop,\n noop2\n} from '../node_modules/js-data-adapter/src/index'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst DEFAULTS = {\n /**\n * Set a base path in order to use absolute URLs instead of relative URLs.\n *\n * @example\n * const httpAdapter = new HttpAdapter({\n * basePath: 'https://mydomain.com'\n * });\n *\n * @name HttpAdapter#basePath\n * @type {string}\n * @since 3.0.0\n */\n basePath: '',\n\n /**\n * Ensure that the request url has a trailing forward slash.\n *\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n forceTrailingSlash: false,\n\n hasFetch: hasFetch,\n\n /**\n * The HTTP function that actually makes the HTTP request. By default this is\n * `axios`.\n *\n * @name HttpAdapter#http\n * @type {function}\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library\n */\n http: axios,\n\n /**\n * Default configuration options to be mixed into the `config` argument passed\n * to {@link HttpAdapter#http}.\n *\n * @name HttpAdapter#httpConfig\n * @type {object}\n * @since 3.0.0\n */\n httpConfig: {},\n\n /**\n * Add a suffix to the request url, e.g. \".json\".\n *\n * @name HttpAdapter#suffix\n * @type {string}\n * @since 3.0.0\n */\n suffix: '',\n\n /**\n * Use `window.fetch` if available.\n *\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-windowfetch\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @example\n * import { DataStore } from 'js-data';\n * import { HttpAdapter } from 'js-data-http';\n *\n * const httpAdapter = new HttpAdapter();\n * const store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n *\n * store.defineMapper('school');\n * store.defineMapper('student');\n *\n * // GET /school/1\n * store.find('school', 1).then((school) => {\n * console.log('school');\n * });\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}.\n * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}.\n * @param {object} [opts.http=axios] See {@link HttpAdapter#http}.\n * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}.\n * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}.\n * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}.\n * @see http://www.js-data.io/docs/js-data-http\n */\nexport function HttpAdapter (opts) {\n utils.classCallCheck(this, HttpAdapter)\n\n opts || (opts = {})\n // Fill in any missing options with the defaults\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(this, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\nAdapter.extend({\n constructor: HttpAdapter,\n\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n return this.GET(\n this.getPath('count', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _create (mapper, props, opts) {\n return this.POST(\n this.getPath('create', mapper, props, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _createMany (mapper, props, opts) {\n return this.POST(\n this.getPath('createMany', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroy (mapper, id, opts) {\n return this.DEL(\n this.getPath('destroy', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroyAll (mapper, query, opts) {\n return this.DEL(\n this.getPath('destroyAll', mapper, null, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n return this.GET(\n this.getPath('find', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _findAll (mapper, query, opts) {\n return this.GET(\n this.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _sum (mapper, field, query, opts) {\n return this.GET(\n this.getPath('sum', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _update (mapper, id, props, opts) {\n return this.PUT(\n this.getPath('update', mapper, id, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateAll (mapper, props, query, opts) {\n return this.PUT(\n this.getPath('updateAll', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateMany (mapper, records, opts) {\n return this.PUT(\n this.getPath('updateMany', mapper, null, opts),\n this.serialize(mapper, records, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params.count = true\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.count.call(this, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {object} mapper The mapper.\n * @param {object} props Properties to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.create.call(this, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {object} mapper The mapper.\n * @param {array} props Array of property objects to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.createMany.call(this, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'DEL'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {object} mapper The mapper used for the operation.\n * @param {object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {object} opts Configuration options.\n * @return {(object|array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroy.call(this, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroyAll.call(this, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {object} config Request configuration.\n * @param {object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {object} config.headers Headers for the request.\n * @param {object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n */\n fetch (config) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers || {})\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(buildUrl(config.url, config.params), requestConfig)\n .then((response) => {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json()\n .then((data) => {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.find.call(this, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.findAll.call(this, mapper, query, opts)\n },\n\n /**\n * Make a GET request.\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'GET'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {object} mapper The Mapper.\n * @param {*} id The primary key, if any.\n * @param {boolean} opts Configuration options.\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach((def) => {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, (value, key) => {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method The method being executed.\n * @param {object} mapper The Mapper.\n * @param {(string|number)?} id The primary key, if any.\n * @param {object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n opts || (opts = {})\n const args = [\n opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath,\n this.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (opts.params === undefined) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (opts.suffix === undefined) {\n if (mapper.suffix === undefined) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, this.httpConfig)\n config.data = payload\n config.cache = cache\n if (timeout !== undefined) {\n config.timeout = timeout\n }\n if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || this.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n const logResponse = (data) => {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (this.log) {\n this.dbg(str, data)\n }\n return data\n } else {\n if (this.error) {\n this.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!this.http) {\n if ((this.useFetch || opts.useFetch)) {\n if (!hasFetch) {\n throw new Error('Attempting to use window.fetch, but it is not available!')\n }\n } else {\n throw new Error('You have not configured this adapter with an http library!')\n }\n }\n\n return utils.resolve(this.beforeHTTP(config, opts))\n .then((_config) => {\n config = _config || config\n if (hasFetch && (this.useFetch || opts.useFetch || !this.http)) {\n return this.fetch(config, opts).then(logResponse, logResponse)\n }\n const httpConfig = utils.plainCopy(config)\n delete httpConfig.adapter\n return this.http(httpConfig).then(logResponse, logResponse)\n .catch((err) => this.responseError(err, config, opts))\n })\n .then((response) => {\n return utils.resolve(this.afterHTTP(config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a POST request.\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'POST'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a PUT request.\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'PUT'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the querystring object before it is serialized. This doesn't do\n * anything by default.\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {*} params The querystring object.\n * @param {*} opts Configuration options\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * Serialize request data. This doesn't do anything by default.\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {object} data The request payload.\n * @param {*} opts Configuration options.\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n query || (query = {})\n opts || (opts = {})\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = this.getParams(opts)\n opts.params.sum = field\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.sum.call(this, mapper, field, query, opts)\n },\n\n /**\n * Perform an update. Makes a PUT request by default.\n *\n * @name HttpAdapter#update\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {*} id The primary key of the record being updated.\n * @param {*} props The update payload.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.update.call(this, mapper, id, props, opts)\n },\n\n /**\n * Perform an update against records that match the selection query. Makes a\n * PUT request by default.\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {object} props The update payload.\n * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateAll.call(this, mapper, props, query, opts)\n },\n\n /**\n * Update multiple individual records in a batch.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {array} records Array of property objects to send as the payload.\n * Each must contain the primary key of the record to be updated.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateMany.call(this, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addAction = JSDataHttp.addAction;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * endpoint: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {object} [opts] Action configuration\n * @param {string} [opts.adapter=\"http\"] The name of the adapter to use.\n * @param {string} [opts.pathname] Set the action's pathname.\n * @param {function} [opts.request] Specify a request handler to be executed\n * before the request is made.\n * @param {function} [opts.response] Specify a response handler to be executed\n * after the response is received.\n * @param {function} [opts.responseError] Specify an error handler to be\n * executed on error.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addAction (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n _opts = _opts || {}\n if (utils.isObject(id)) {\n _opts = id\n }\n utils.fillIn(_opts, opts)\n let adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http')\n const config = {}\n config.mapper = this.name\n utils.deepMixIn(config, _opts)\n config.method = config.method || 'GET'\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(this, _opts)\n } else {\n let args = [\n _opts.basePath || this.basePath || adapter.basePath,\n adapter.getEndpoint(this, id, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n return utils.resolve(config)\n .then(_opts.request)\n .then((config) => adapter.HTTP(config))\n .then((data) => {\n if (data && data.config) {\n data.config.mapper = this.name\n }\n return data\n })\n .then(_opts.response, _opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addActions = JSDataHttp.addActions;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * addActions({\n * // GET /reports/schools/:school_id/teachers\n * getTeacherReports: {\n * basePath: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * }\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addActions\n * @method\n * @param {object.} opts Object where the key is an action name\n * and the value is the configuration for the action.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name module:js-data-http.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http`\n * that works on Node.js is registered in NPM as `js-data-http-node`. The build\n * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower\n * as `js-data-fetch`.\n *\n * @example Script tag\n * var HttpAdapter = window.JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example ES2015 Modules\n * import { HttpAdapter } from 'js-data-Http';\n * const httpAdapter = new HttpAdapter();\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * // ...\n * });\n *\n * @module js-data-http\n */\n\n/**\n * Create a subclass of this HttpAdapter:\n * @example HttpAdapter.extend\n * // Normally you would do: import { HttpAdapter } from 'js-data-http';\n * // or: import { HttpAdapter } from 'js-data-http-node';\n * const JSDataHttp = require('js-data-http-node');\n * const { HttpAdapter } = JSDataHttp;\n * console.log('Using JSDataHttp v' + JSDataHttp.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomHttpAdapterClass extends HttpAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customHttpAdapter = new CustomHttpAdapterClass();\n * console.log(customHttpAdapter.foo());\n * console.log(CustomHttpAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherHttpAdapterClass = HttpAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const otherHttpAdapter = new OtherHttpAdapterClass();\n * console.log(otherHttpAdapter.foo());\n * console.log(OtherHttpAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherHttpAdapterClass () {\n * HttpAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * HttpAdapter.extend({\n * constructor: AnotherHttpAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const anotherHttpAdapter = new AnotherHttpAdapterClass();\n * console.log(anotherHttpAdapter.created_at);\n * console.log(anotherHttpAdapter.foo());\n * console.log(AnotherHttpAdapterClass.beep());\n *\n * @method HttpAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this HttpAdapter class.\n * @since 3.0.0\n */\n"],"names":["this","utils","noop","args","opts","length","dbg","op","resolve","noop2","unique","array","seen","final","forEach","item","push","withoutRelations","mapper","props","with","relationFields","toStrip","filter","value","indexOf","omit","Response","data","meta","fillIn","DEFAULTS","Adapter","classCallCheck","call","Component","extend","query","then","_count","results","result","response","respond","_response","undefined","_props","_create","created","map","record","_createMany","id","_destroy","_destroyAll","def","records","__opts","relationDef","getRelation","isObject","isArray","find","makeBelongsToForeignKey","relatedItem","setLocalField","keys","key","findAll","idAttribute","relatedItems","foreignKey","_find","loadRelationsFor","found","activeWith","_activeWith","activeQuery","replace","deepFillIn","_findAll","tasks","forEachRelation","task","type","loadHasOne","loadHasMany","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadBelongsTo","Promise","all","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","where","attached","get","relatedMapper","makeHasManyLocalKeys","concat","x","itemKeys","Object","makeHasManyForeignKeys","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","field","isString","Error","_sum","getOpt","_update","updated","_updateAll","_records","_updateMany","hasFetch","window","fetch","e","isValidString","join","items","separator","makePath","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","v","toString","toISOString","toJson","axios","HttpAdapter","GET","getPath","_end","POST","serialize","DEL","deserialize","PUT","getParams","count","suffix","getSuffix","deepMixIn","queryTransform","prototype","create","createMany","config","method","_config","HTTP","isFunction","hasOwnProperty","destroy","destroyAll","console","error","requestConfig","Headers","headers","body","json","isUndefined","relationList","endpoint","name","parent","parentKey","parentDef","parentId","_opts","_","getEndpoint","basePath","isNumber","apply","copy","start","Date","payload","cache","timeout","httpConfig","forceTrailingSlash","toUpperCase","substr","logResponse","str","toUTCString","status","getTime","log","reject","http","useFetch","beforeHTTP","adapter","catch","err","responseError","afterHTTP","sum","update","updateAll","updateMany","addAction","TypeError","request","getAdapter","defaultAdapter","isSorN","pathname","addActions","version"],"mappings":";;;;;;;;;;;;;;;;;;AACA,CAAC,SAAS,gCAAgC,CAAC,IAAI,EAAE,OAAO,EAAE;CACzD,AACC,cAAc,GAAG,OAAO,EAAE,CAAC,AAMD;CAC3B,EAAEA,cAAI,EAAE,WAAW;AACpB,gBAAgB,CAAC,SAAS,OAAO,EAAE;;UAEzB,IAAI,gBAAgB,GAAG,EAAE,CAAC;;;UAG1B,SAAS,mBAAmB,CAAC,QAAQ,EAAE;;;WAGtC,GAAG,gBAAgB,CAAC,QAAQ,CAAC;YAC5B,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;;;WAG3C,IAAI,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG;YACzC,OAAO,EAAE,EAAE;YACX,EAAE,EAAE,QAAQ;YACZ,MAAM,EA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,QAAQA,KAAKyI,MAAjB,EAAyB;eAClBA,MAAL,CAAYnJ,MAAZ,GAAqB,QAAKqK,IAA1B;;eAEK3J,IAAP;OAPG,EASJU,IATI,CASCsJ,MAAMlJ,QATP,EASiBkJ,MAAM6B,aATvB,CAAP;KAxBF;WAmCOvM,MAAP;GA1CF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFF,AAAO,SAASoN,UAAT,CAAqBlO,IAArB,EAA2B;WACvBA,OAAO,EAAhB;SACO,UAAUc,MAAV,EAAkB;iBACjB2H,MAAN,CAAazI,IAAb,EAAmB,UAAUoB,KAAV,EAAiB2C,GAAjB,EAAsB;gBAC7BA,GAAV,EAAe3C,KAAf,EAAsBN,MAAtB;KADF;WAGOA,MAAP;GAJF;;;;;;;;;;;;;;;;;AAsBF,AAAO,IAAMqN,UAAU,gBAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/js-data-http.min.js b/dist/js-data-http.min.js new file mode 100644 index 0000000..c506c23 --- /dev/null +++ b/dist/js-data-http.min.js @@ -0,0 +1,10 @@ +/*! +* js-data-http +* @version 3.0.0 - Homepage +* @copyright (c) 2014-2016 js-data-http project authors +* @license MIT +* +* @overview HTTP (XHR) adapter for js-data in the browser. +*/ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-http",["exports","js-data"],t):t(e.JSDataHttp=e.JSDataHttp||{},e.JSData)}(this,function(e,t){"use strict";function Response(e,n,r){n||(n={}),this.data=e,t.utils.fillIn(this,n),this.op=r}function Adapter(e){t.utils.classCallCheck(this,Adapter),t.Component.call(this,e),e||(e={}),t.utils.fillIn(e,l),t.utils.fillIn(this,e)}function isValidString(e){return null!=e&&""!==e}function join(e,t){return t||(t=""),e.filter(isValidString).join(t)}function makePath(){for(var e=arguments.length,t=Array(e),n=0;n0&&(e+=(-1===e.indexOf("?")?"?":"&")+r.join("&")),e}function HttpAdapter(e){t.utils.classCallCheck(this,HttpAdapter),e||(e={}),t.utils.fillIn(e,d),Adapter.call(this,e)}function addAction(e,n){if(!e||!t.utils.isString(e))throw new TypeError("action(name[, opts]): Expected: string, Found: "+(void 0===e?"undefined":r(e)));return function(r){if(r[e])throw new Error("action(name[, opts]): "+e+" already exists on target!");return n.request=n.request||function(e){return e},n.response=n.response||function(e){return e},n.responseError=n.responseError||function(e){return t.utils.reject(e)},r[e]=function(r,o){var i=this;o=o||{},t.utils.isObject(r)&&(o=r),t.utils.fillIn(o,n);var a=this.getAdapter(o.adapter||this.defaultAdapter||"http"),s={};if(s.mapper=this.name,t.utils.deepMixIn(s,o),s.method=s.method||"GET","function"==typeof o.getEndpoint)s.url=o.getEndpoint(this,o);else{var u=[o.basePath||this.basePath||a.basePath,a.getEndpoint(this,r,o)];t.utils.isSorN(r)&&u.push(r),u.push(n.pathname||e),s.url=makePath.apply(null,u)}return t.utils.resolve(s).then(o.request).then(function(e){return a.HTTP(e)}).then(function(e){return e&&e.config&&(e.config.mapper=i.name),e}).then(o.response,o.responseError)},r}}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var n=function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}(function(e,t){!function webpackUniversalModuleDefinition(t,n){e.exports=n()}(0,function(){return function(e){function __webpack_require__(n){if(t[n])return t[n].exports;var r=t[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,__webpack_require__),r.loaded=!0,r.exports}var t={};return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.p="",__webpack_require__(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){function createInstance(e){var t=new i(e),n=o(i.prototype.request,t);return r.extend(n,i.prototype,t),r.extend(n,t),n}var r=n(2),o=n(3),i=n(5),a=n(6),s=createInstance(a);s.Axios=i,s.create=function create(e){return createInstance(r.merge(a,e))},s.Cancel=n(23),s.CancelToken=n(24),s.isCancel=n(20),s.all=function all(e){return Promise.all(e)},s.spread=n(25),e.exports=s,e.exports.default=s},function(e,t,n){function isArray(e){return"[object Array]"===i.call(e)}function isObject(e){return null!==e&&"object"==typeof e}function isFunction(e){return"[object Function]"===i.call(e)}function forEach(e,t){if(null!==e&&void 0!==e)if("object"==typeof e||isArray(e)||(e=[e]),isArray(e))for(var n=0,r=e.length;n=200&&e<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}},r.forEach(["delete","get","head"],function forEachMethodNoData(e){a.headers[e]={}}),r.forEach(["post","put","patch"],function forEachMethodWithData(e){a.headers[e]=r.merge(i)}),e.exports=a},function(e,t,n){var r=n(2);e.exports=function normalizeHeaderName(e,t){r.forEach(e,function processHeader(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){var r=n(2),o=n(9),i=n(12),a=n(13),s=n(14),u=n(10),f="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(15);e.exports=function xhrAdapter(e){return new Promise(function dispatchXhrRequest(t,l){var c=e.data,d=e.headers;r.isFormData(c)&&delete d["Content-Type"];var p=new XMLHttpRequest,h="onreadystatechange",y=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in p||s(e.url)||(p=new window.XDomainRequest,h="onload",y=!0,p.onprogress=function handleProgress(){},p.ontimeout=function handleTimeout(){}),e.auth){var m=e.auth.username||"",v=e.auth.password||"";d.Authorization="Basic "+f(m+":"+v)}if(p.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,p[h]=function handleLoad(){if(p&&(4===p.readyState||y)&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in p?a(p.getAllResponseHeaders()):null,r={data:e.responseType&&"text"!==e.responseType?p.response:p.responseText,status:1223===p.status?204:p.status,statusText:1223===p.status?"No Content":p.statusText,headers:n,config:e,request:p};o(t,l,r),p=null}},p.onerror=function handleError(){l(u("Network Error",e,null,p)),p=null},p.ontimeout=function handleTimeout(){l(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",p)),p=null},r.isStandardBrowserEnv()){var g=n(16),b=(e.withCredentials||s(e.url))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;b&&(d[e.xsrfHeaderName]=b)}if("setRequestHeader"in p&&r.forEach(d,function setRequestHeader(e,t){void 0===c&&"content-type"===t.toLowerCase()?delete d[t]:p.setRequestHeader(t,e)}),e.withCredentials&&(p.withCredentials=!0),e.responseType)try{p.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function onCanceled(e){p&&(p.abort(),l(e),p=null)}),void 0===c&&(c=null),p.send(c)})}},function(e,t,n){var r=n(10);e.exports=function settle(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){var r=n(11);e.exports=function createError(e,t,n,o,i){var a=new Error(e);return r(a,t,n,o,i)}},function(e,t){e.exports=function enhanceError(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e}},function(e,t,n){function encode(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var r=n(2);e.exports=function buildURL(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(r.isURLSearchParams(t))o=t.toString();else{var i=[];r.forEach(t,function serialize(e,t){null!==e&&void 0!==e&&(r.isArray(e)&&(t+="[]"),r.isArray(e)||(e=[e]),r.forEach(e,function parseValue(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),i.push(encode(t)+"="+encode(e))}))}),o=i.join("&")}return o&&(e+=(-1===e.indexOf("?")?"?":"&")+o),e}},function(e,t,n){var r=n(2);e.exports=function parseHeaders(e){var t,n,o,i={};return e?(r.forEach(e.split("\n"),function parser(e){o=e.indexOf(":"),t=r.trim(e.substr(0,o)).toLowerCase(),n=r.trim(e.substr(o+1)),t&&(i[t]=i[t]?i[t]+", "+n:n)}),i):i}},function(e,t,n){var r=n(2);e.exports=r.isStandardBrowserEnv()?function standardBrowserEnv(){function resolveURL(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");return e=resolveURL(window.location.href),function isURLSameOrigin(t){var n=r.isString(t)?resolveURL(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function nonStandardBrowserEnv(){return function isURLSameOrigin(){return!0}}()},function(e,t){function E(){this.message="String contains an invalid character"}var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";E.prototype=new Error,E.prototype.code=5,E.prototype.name="InvalidCharacterError",e.exports=function btoa(e){for(var t,r,o=String(e),i="",a=0,s=n;o.charAt(0|a)||(s="=",a%1);i+=s.charAt(63&t>>8-a%1*8)){if((r=o.charCodeAt(a+=.75))>255)throw new E;t=t<<8|r}return i}},function(e,t,n){var r=n(2);e.exports=r.isStandardBrowserEnv()?function standardBrowserEnv(){return{write:function write(e,t,n,o,i,a){var s=[];s.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),r.isString(o)&&s.push("path="+o),r.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function read(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function remove(e){this.write(e,"",Date.now()-864e5)}}}():function nonStandardBrowserEnv(){return{write:function write(){},read:function read(){return null},remove:function remove(){}}}()},function(e,t,n){function InterceptorManager(){this.handlers=[]}var r=n(2);InterceptorManager.prototype.use=function use(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},InterceptorManager.prototype.eject=function eject(e){this.handlers[e]&&(this.handlers[e]=null)},InterceptorManager.prototype.forEach=function forEach(e){r.forEach(this.handlers,function forEachHandler(t){null!==t&&e(t)})},e.exports=InterceptorManager},function(e,t,n){function throwIfCancellationRequested(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var r=n(2),o=n(19),i=n(20),a=n(6);e.exports=function dispatchRequest(e){return throwIfCancellationRequested(e),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),r.forEach(["delete","get","head","post","put","patch","common"],function cleanHeaderConfig(t){delete e.headers[t]}),(e.adapter||a.adapter)(e).then(function onAdapterResolution(t){return throwIfCancellationRequested(e),t.data=o(t.data,t.headers,e.transformResponse),t},function onAdapterRejection(t){return i(t)||(throwIfCancellationRequested(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){var r=n(2);e.exports=function transformData(e,t,n){return r.forEach(n,function transform(n){e=n(e,t)}),e}},function(e,t){e.exports=function isCancel(e){return!(!e||!e.__CANCEL__)}},function(e,t){e.exports=function isAbsoluteURL(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){e.exports=function combineURLs(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t){function Cancel(e){this.message=e}Cancel.prototype.toString=function toString(){return"Cancel"+(this.message?": "+this.message:"")},Cancel.prototype.__CANCEL__=!0,e.exports=Cancel},function(e,t,n){function CancelToken(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function promiseExecutor(e){t=e});var n=this;e(function cancel(e){n.reason||(n.reason=new r(e),t(n.reason))})}var r=n(23);CancelToken.prototype.throwIfRequested=function throwIfRequested(){if(this.reason)throw this.reason},CancelToken.source=function source(){var e;return{token:new CancelToken(function executor(t){e=t}),cancel:e}},e.exports=CancelToken},function(e,t){e.exports=function spread(e){return function wrap(t){return e.apply(null,t)}}}])})}),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},i=function(){function sliceIterator(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return sliceIterator(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),a=function noop(){for(var e=arguments.length,n=Array(e),r=0;r=200&&n.status<300?(r.log&&r.dbg(i,n),n):(r.error&&r.error("'FAILED: "+i,n),t.utils.reject(n))};if(!this.http){if(!this.useFetch&&!n.useFetch)throw new Error("You have not configured this adapter with an http library!");if(!c)throw new Error("Attempting to use window.fetch, but it is not available!")}return t.utils.resolve(this.beforeHTTP(e,n)).then(function(o){if(e=o||e,c&&(r.useFetch||n.useFetch||!r.http))return r.fetch(e,n).then(f,f);var i=t.utils.plainCopy(e);return delete i.adapter,r.http(i).then(f,f).catch(function(t){return r.responseError(t,e,n)})}).then(function(o){return t.utils.resolve(r.afterHTTP(e,n,o)).then(function(e){return void 0===e?o:e})})},POST:function POST(e,n,r,o){var i=this,a=void 0;return r||(r={}),o||(o={}),r.url=e||r.url,r.data=n||r.data,r.method=r.method||"post",a=o.op="beforePOST",t.utils.resolve(this[a](e,n,r,o)).then(function(t){return r=void 0===t?r:t,a=o.op="POST",i.dbg(a,e,n,r,o),i.HTTP(r,o)}).then(function(s){return a=o.op="afterPOST",t.utils.resolve(i[a](e,n,r,o,s)).then(function(e){return void 0===e?s:e})})},PUT:function PUT(e,n,r,o){var i=this,a=void 0;return r||(r={}),o||(o={}),r.url=e||r.url,r.data=n||r.data,r.method=r.method||"put",a=o.op="beforePUT",t.utils.resolve(this[a](e,n,r,o)).then(function(t){return r=void 0===t?r:t,a=o.op="PUT",i.dbg(a,e,n,r,o),i.HTTP(r,o)}).then(function(s){return a=o.op="afterPUT",t.utils.resolve(i[a](e,n,r,o,s)).then(function(e){return void 0===e?s:e})})},queryTransform:function queryTransform(e,n,r){return r||(r={}),t.utils.isFunction(r.queryTransform)?r.queryTransform(e,n,r):t.utils.isFunction(e.queryTransform)?e.queryTransform(e,n,r):n},responseError:function responseError(e,n,r){return t.utils.reject(e)},serialize:function serialize(e,n,r){return r||(r={}),t.utils.isFunction(r.serialize)?r.serialize(e,n,r):t.utils.isFunction(e.serialize)?e.serialize(e,n,r):n},sum:function sum(e,n,r,o){if(r||(r={}),o||(o={}),!t.utils.isString(n))throw new Error("field must be a string!");return o.params=this.getParams(o),o.params.sum=n,o.suffix=this.getSuffix(e,o),t.utils.deepMixIn(o.params,r),o.params=this.queryTransform(e,o.params,o),Adapter.prototype.sum.call(this,e,n,r,o)},update:function update(e,t,n,r){return r||(r={}),r.params=this.getParams(r),r.params=this.queryTransform(e,r.params,r),r.suffix=this.getSuffix(e,r),Adapter.prototype.update.call(this,e,t,n,r)},updateAll:function updateAll(e,n,r,o){return r||(r={}),o||(o={}),o.params=this.getParams(o),t.utils.deepMixIn(o.params,r),o.params=this.queryTransform(e,o.params,o),o.suffix=this.getSuffix(e,o),Adapter.prototype.updateAll.call(this,e,n,r,o)},updateMany:function updateMany(e,t,n){return n||(n={}),n.params=this.getParams(n),n.params=this.queryTransform(e,n.params,n),n.suffix=this.getSuffix(e,n),Adapter.prototype.updateMany.call(this,e,t,n)}});var p={full:"3.0.0",major:3,minor:0,patch:0};e.HttpAdapter=HttpAdapter,e.addAction=addAction,e.addActions=function addActions(e){return e||(e={}),function(n){return t.utils.forOwn(e,function(e,t){addAction(t,e)(n)}),n}},e.version=p,Object.defineProperty(e,"__esModule",{value:!0})}); +//# sourceMappingURL=js-data-http.min.map \ No newline at end of file diff --git a/dist/js-data-http.min.js.map b/dist/js-data-http.min.js.map new file mode 100644 index 0000000..769f32f --- /dev/null +++ b/dist/js-data-http.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["dist/js-data-http.js"],"names":["global","factory","exports","module","require","define","amd","JSDataHttp","JSData","this","jsData","Response","data","meta","op","utils","fillIn","Adapter","opts","classCallCheck","Component","call","DEFAULTS$1","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","isArray","forEach","v","toString","toISOString","isObject","toJson","push","indexOf","HttpAdapter","DEFAULTS","addAction","name","isString","TypeError","_typeof","mapper","Error","request","config","response","responseError","err","reject","id","_opts","_this18","adapter","getAdapter","defaultAdapter","deepMixIn","method","getEndpoint","basePath","isSorN","pathname","apply","resolve","then","HTTP","window","self","axios","createCommonjsModule","fn","webpackUniversalModuleDefinition","root","commonjsGlobal","modules","__webpack_require__","moduleId","installedModules","loaded","m","c","p","createInstance","defaultConfig","context","Axios","instance","bind","prototype","utils$$1","extend","defaults","create","instanceConfig","merge","Cancel","CancelToken","isCancel","all","promises","Promise","spread","default","isFunction","obj","i","l","Object","hasOwnProperty","result","assignValue","isBuffer","isArrayBuffer","isFormData","FormData","isArrayBufferView","ArrayBuffer","isView","buffer","isNumber","isUndefined","isDate","isFile","isBlob","isStream","pipe","isURLSearchParams","URLSearchParams","isStandardBrowserEnv","navigator","product","document","a","b","thisArg","trim","str","wrap","constructor","isSlowBuffer","readFloatLE","slice","_isBuffer","interceptors","InterceptorManager","dispatchRequest","isAbsoluteURL","combineURLs","toLowerCase","baseURL","chain","undefined","promise","unshiftRequestInterceptors","interceptor","unshift","fulfilled","rejected","pushResponseInterceptors","shift","forEachMethodNoData","forEachMethodWithData","setContentTypeIfUnset","headers","normalizeHeaderName","DEFAULT_CONTENT_TYPE","Content-Type","getDefaultAdapter","XMLHttpRequest","process","transformRequest","JSON","stringify","transformResponse","parse","e","timeout","xsrfCookieName","xsrfHeaderName","maxContentLength","validateStatus","status","common","Accept","normalizedName","processHeader","toUpperCase","settle","buildURL","parseHeaders","isURLSameOrigin","createError","btoa","xhrAdapter","dispatchXhrRequest","requestData","requestHeaders","loadEvent","xDomain","XDomainRequest","onprogress","handleProgress","ontimeout","handleTimeout","auth","username","password","Authorization","open","paramsSerializer","handleLoad","readyState","responseURL","responseHeaders","getAllResponseHeaders","responseType","responseText","statusText","onerror","handleError","cookies","xsrfValue","withCredentials","read","setRequestHeader","onDownloadProgress","addEventListener","onUploadProgress","upload","cancelToken","onCanceled","cancel","abort","send","enhanceError","message","code","error","serializedParams","serialize","parseValue","parsed","split","parser","line","substr","standardBrowserEnv","resolveURL","href","msie","urlParsingNode","setAttribute","protocol","host","search","hash","hostname","port","charAt","originURL","test","userAgent","createElement","location","requestURL","nonStandardBrowserEnv","E","chars","input","block","charCode","String","output","idx","map","charCodeAt","write","expires","path","domain","secure","cookie","Date","toGMTString","match","RegExp","decodeURIComponent","remove","now","handlers","use","eject","forEachHandler","h","throwIfCancellationRequested","throwIfRequested","transformData","cleanHeaderConfig","onAdapterResolution","onAdapterRejection","reason","fns","transform","__CANCEL__","relativeURL","executor","resolvePromise","promiseExecutor","token","source","callback","arr","Symbol","iterator","defineProperty","enumerable","configurable","writable","slicedToArray","sliceIterator","_arr","_n","_d","_e","_s","_i","next","done","noop","dbg","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","props","with","toStrip","relationFields","omit","debug","raw","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","count","query","_this","_count","results","_results","respond","_response","_this2","_props","_create","_results2","created","createMany","_this3","record","_createMany","_results3","destroy","_this4","_destroy","_results4","destroyAll","_this5","_destroyAll","_results5","loadBelongsTo","def","records","__opts","_this6","relationDef","getRelation","find","makeBelongsToForeignKey","relatedItem","setLocalField","keys","findAll","where","idAttribute","in","relatedItems","foreignKey","_this7","_find","loadRelationsFor","_ref","_ref2","found","_this8","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_ref3","_ref4","_this9","tasks","forEachRelation","task","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","getOpt","opt","plainCopy","_this10","singular","IDs","makeHasManyForeignKey","criteria","attached","get","_this11","relatedMapper","makeHasManyLocalKeys","x","itemKeys","_this12","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","sum","field","_this13","_sum","_results7","update","_this14","_update","_results8","updated","updateAll","_this15","_updateAll","_results9","updateMany","_this16","_records","_updateMany","_results10","hasFetch","fetch","forceTrailingSlash","http","httpConfig","suffix","useFetch","afterDEL","afterGET","afterHTTP","afterPOST","afterPUT","beforeDEL","beforeGET","beforeHTTP","beforePOST","beforePUT","GET","getPath","_end","POST","DEL","deserialize","PUT","getParams","getSuffix","queryTransform","_config","console","_console","_fetch","_x","requestConfig","Headers","body","json","relationList","endpoint","parent","parentKey","parentDef","parentId","_","copy","start","payload","cache","logResponse","toUTCString","getTime","log","catch","_this17","version","full","major","minor","patch","addActions"],"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Z,KAAMqD,EAAQmW,EAAS/Y,MAwKpE,IAAIwhB,GACFC,KAAM,QACNC,MAAO,EACPC,MAAO,EACPC,MAAO,GAsFT5iB,EAAQqD,YAAcA,YACtBrD,EAAQuD,UAAYA,UACpBvD,EAAQ6iB,WApHR,SAASA,WAAW7hB,GAElB,OADAA,IAASA,MACF,SAAU4C,GAIf,OAHApD,EAAOK,MAAM6B,OAAO1B,EAAM,SAAUM,EAAOqB,GACzCY,UAAUZ,EAAKrB,GAAOsC,KAEjBA,IA+GX5D,EAAQwiB,QAAUA,EAElB3a,OAAO+M,eAAe5U,EAAS,cAAgBsB,OAAO"} \ No newline at end of file diff --git a/dist/js-data-http.min.map b/dist/js-data-http.min.map new file mode 100644 index 0000000..f0f3816 --- /dev/null +++ b/dist/js-data-http.min.map @@ -0,0 +1 @@ +{"version":3,"sources":["dist/js-data-http.js"],"names":["global","factory","exports","module","require","define","amd","JSDataHttp","JSData","this","jsData","interopDefault","ex","createCommonjsModule","fn","Response","data","meta","op","utils","fillIn","Adapter","opts","classCallCheck","Component","call","DEFAULTS$1","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","isArray","forEach","v","toString","toISOString","isObject","toJson","push","indexOf","HttpAdapter","DEFAULTS","addAction","name","isString","TypeError","_typeof","mapper","Error","request","config","response","responseError","err","reject","id","_opts","_this18","adapter","getAdapter","defaultAdapter","deepMixIn","method","getEndpoint","basePath","isSorN","pathname","apply","resolve","then","HTTP","addActions","commonjsGlobal","window","self","axios","root","modules","__webpack_require__","moduleId","installedModules","loaded","m","c","p","createInstance","defaultConfig","context","Axios","instance","bind","prototype","extend","create","all","promises","Promise","spread","isArrayBuffer","isFormData","FormData","isArrayBufferView","ArrayBuffer","isView","buffer","isNumber","isUndefined","isDate","isFile","isBlob","isFunction","isStream","pipe","isURLSearchParams","URLSearchParams","trim","str","isStandardBrowserEnv","document","createElement","obj","i","l","hasOwnProperty","merge","assignValue","a","b","thisArg","Object","defaults","interceptors","InterceptorManager","dispatchRequest","isAbsoluteURL","combineURLs","baseURL","chain","undefined","promise","interceptor","unshift","fulfilled","rejected","shift","setContentTypeIfUnset","headers","normalizeHeaderName","PROTECTION_PREFIX","DEFAULT_CONTENT_TYPE","Content-Type","transformRequest","JSON","stringify","transformResponse","parse","e","common","Accept","patch","post","put","timeout","xsrfCookieName","xsrfHeaderName","maxContentLength","validateStatus","status","normalizedName","toUpperCase","handlers","use","eject","h","transformData","XMLHttpRequest","process","error","fns","settle","buildURL","parseHeaders","isURLSameOrigin","createError","btoa","requestData","requestHeaders","loadEvent","xDomain","XDomainRequest","onprogress","ontimeout","auth","username","password","Authorization","open","paramsSerializer","readyState","responseHeaders","getAllResponseHeaders","responseData","responseType","responseText","statusText","onerror","cookies","xsrfValue","withCredentials","read","toLowerCase","setRequestHeader","progress","upload","addEventListener","send","enhanceError","message","code","serializedParams","parsed","split","line","substr","resolveURL","href","msie","urlParsingNode","setAttribute","protocol","host","search","hash","hostname","port","charAt","originURL","test","navigator","userAgent","location","requestURL","E","input","block","charCode","String","output","idx","map","chars","charCodeAt","write","expires","path","domain","secure","cookie","Date","toGMTString","match","RegExp","decodeURIComponent","remove","now","relativeURL","callback","arr","axios$1","Symbol","iterator","constructor","defineProperty","enumerable","configurable","writable","slicedToArray","sliceIterator","_arr","_n","_d","_e","_s","_i","next","done","noop","dbg","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","props","with","relationFields","toStrip","omit","debug","raw","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","count","query","_this","_count","results","_results","respond","_response","_this2","_props","_create","_results2","created","createMany","_this3","record","_createMany","_results3","destroy","_this4","_destroy","_results4","destroyAll","_this5","_destroyAll","_results5","loadBelongsTo","def","records","__opts","_this6","relationDef","getRelation","keys","makeBelongsToForeignKey","findAll","where","idAttribute","in","relatedItems","relatedItem","foreignKey","setLocalField","_ret","find","_this7","_find","_results6","_record","_meta","tasks","forEachRelation","task","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","found","_this8","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_results7","_records","getOpt","opt","plainCopy","_this9","singular","IDs","makeHasManyForeignKey","criteria","attached","get","_this10","relatedMapper","makeHasManyLocalKeys","_ret2","x","itemKeys","_this11","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","sum","field","_this12","_sum","_results8","update","_this13","_update","_results9","updated","updateAll","_this14","_updateAll","_results10","updateMany","_this15","_updateMany","_results11","hasFetch","fetch","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","console","_console","_fetch","_x","requestConfig","Headers","body","json","relationList","endpoint","parent","parentKey","parentDef","parentId","_","copy","start","payload","cache","logResponse","toUTCString","getTime","log","catch","_this16","_this17","version","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,YAInC,SAASC,GAAeC,GACvB,MAAOA,IAAoB,gBAAPA,IAAmB,WAAaA,GAAKA,EAAY,QAAIA,EAG1E,QAASC,GAAqBC,EAAIX,GACjC,MAAOA,IAAWD,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EAAK0b,OAASvc,KAAK4d,UAAUla,EAAQ7C,GAC9BD,EAAQ0F,UAAUoV,UAAU1a,KAAKhB,KAAM0D,EAAQ2P,EAAO8B,EAAOtU,IAiBtEib,WAAY,SAAoBpY,EAAQoT,EAASjW,GAK/C,MAJAA,KAASA,MACTA,EAAKyB,OAAStC,KAAK2d,UAAU9c,GAC7BA,EAAKyB,OAAStC,KAAK6d,eAAena,EAAQ7C,EAAKyB,OAAQzB,GACvDA,EAAK0b,OAASvc,KAAK4d,UAAUla,EAAQ7C,GAC9BD,EAAQ0F,UAAUwV,WAAW9a,KAAKhB,KAAM0D,EAAQoT,EAASjW,KAwKpE,IAAI4e,IACHC,KAAM,aACNC,MAAO,EACPC,MAAO,EACPlV,MAAO,EAGRjL,GAAQ0D,YAAcA,EACtB1D,EAAQ4D,UAAYA,EACpB5D,EAAQyF,WAAaA,EACrBzF,EAAQggB,QAAUA,EAElB7W,OAAO+I,eAAelS,EAAS,cAAgB0B,OAAO","file":"dist/js-data-http.min.js"} \ No newline at end of file diff --git a/fetch/.gitignore b/fetch/.gitignore index 597ca41..e02e481 100644 --- a/fetch/.gitignore +++ b/fetch/.gitignore @@ -1,4 +1,2 @@ -dist/*.js -dist/*.map node_modules/ junit/ \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.js b/fetch/dist/js-data-fetch.js new file mode 100644 index 0000000..fdf8541 --- /dev/null +++ b/fetch/dist/js-data-fetch.js @@ -0,0 +1,2981 @@ +/*! +* js-data-fetch +* @version 3.0.0 - Homepage +* @copyright (c) 2014-2016 js-data-http project authors +* @license MIT +* +* @overview HTTP adapter for js-data that uses the fetch API. +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-data')) : + typeof define === 'function' && define.amd ? define('js-data-fetch', ['exports', 'js-data'], factory) : + (factory((global.JSDataHttp = global.JSDataHttp || {}),global.JSData)); +}(this, (function (exports,jsData) { 'use strict'; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; + + + + + + + + + + + + + + + + + + + +var defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +}; + + + + + + + + + + + + + + + + + + + + + +var slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; +}(); + +var noop = function noop() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + this.dbg.apply(this, [opts.op].concat(args)); + return jsData.utils.resolve(); +}; + +var noop2 = function noop2() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + this.dbg.apply(this, [opts.op].concat(args)); + return jsData.utils.resolve(); +}; + +var unique = function unique(array) { + var seen = {}; + var final = []; + array.forEach(function (item) { + if (item in seen) { + return; + } + final.push(item); + seen[item] = 0; + }); + return final; +}; + +var withoutRelations = function withoutRelations(mapper, props, opts) { + opts || (opts = {}); + opts.with || (opts.with = []); + var relationFields = mapper.relationFields || []; + var toStrip = relationFields.filter(function (value) { + return opts.with.indexOf(value) === -1; + }); + return jsData.utils.omit(props, toStrip); +}; + + + +/** + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @class Response + */ +function Response(data, meta, op) { + meta || (meta = {}); + + /** + * Response data. + * + * @name Response#data + * @type {*} + */ + this.data = data; + + jsData.utils.fillIn(this, meta); + + /** + * The operation for which the response was created. + * + * @name Response#op + * @type {string} + */ + this.op = op; +} + +var DEFAULTS$1 = { + /** + * Whether to log debugging information. + * + * @name Adapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * Whether to return a more detailed response object. + * + * @name Adapter#raw + * @type {boolean} + * @default false + */ + raw: false + + /** + * Abstract class meant to be extended by adapters. + * + * @class Adapter + * @abstract + * @extends Component + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.debug=false] Whether to log debugging information. + * @param {boolean} [opts.raw=false] Whether to return a more detailed response + * object. + */ +};function Adapter(opts) { + jsData.utils.classCallCheck(this, Adapter); + jsData.Component.call(this, opts); + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS$1); + jsData.utils.fillIn(this, opts); +} + +jsData.Component.extend({ + constructor: Adapter, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#afterCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} props The `props` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `afterCount` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterCount: noop2, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `afterCreate` + * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreate: noop2, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `afterCreateMany` + * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreateMany: noop2, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#afterDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `afterDestroy` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroy: noop2, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#afterDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `afterDestroyAll` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroyAll: noop2, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#afterFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `afterFind` + * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`. + */ + afterFind: noop2, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#afterFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `afterFindAll` + * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`. + */ + afterFindAll: noop2, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#afterSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {string} field The `field` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `afterSum` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterSum: noop2, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#afterUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `afterUpdate` + * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdate: noop2, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#afterUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `afterUpdateAll` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateAll: noop2, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#afterUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} records The `records` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `afterUpdateMany` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateMany: noop2, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#beforeCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} query The `query` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `beforeCount` + */ + beforeCount: noop, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#beforeCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `beforeCreate` + */ + beforeCreate: noop, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#beforeCreateMany + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `beforeCreateMany` + */ + beforeCreateMany: noop, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#beforeDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `beforeDestroy` + */ + beforeDestroy: noop, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#beforeDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `beforeDestroyAll` + */ + beforeDestroyAll: noop, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#beforeFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `beforeFind` + */ + beforeFind: noop, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#beforeFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `beforeFindAll` + */ + beforeFindAll: noop, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#beforeSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `beforeSum` + */ + beforeSum: noop, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#beforeUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `beforeUpdate` + */ + beforeUpdate: noop, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#beforeUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `beforeUpdateAll` + */ + beforeUpdateAll: noop, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#beforeUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} props The `props` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `beforeUpdateMany` + */ + beforeUpdateMany: noop, + + /** + * Retrieve the number of records that match the selection query. Called by + * `Mapper#count`. + * + * @name Adapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var _this = this; + + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + _this.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this._count(mapper, query, opts)); + }).then(function (results) { + var _results = slicedToArray(results, 2), + data = _results[0], + result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = _this.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(_this[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Create a new record. Called by `Mapper#create`. + * + * @name Adapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var _this2 = this; + + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'create'; + _this2.dbg(op, mapper, props, opts); + return jsData.utils.resolve(_this2._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = slicedToArray(results, 2), + data = _results2[0], + result = _results2[1]; + + result || (result = {}); + var response = new Response(data, result, 'create'); + response.created = data ? 1 : 0; + response = _this2.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(_this2[op](mapper, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Create multiple records in a single batch. Called by `Mapper#createMany`. + * + * @name Adapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var _this3 = this; + + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(this[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record, opts); + }); + op = opts.op = 'createMany'; + _this3.dbg(op, mapper, props, opts); + return jsData.utils.resolve(_this3._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = slicedToArray(results, 2), + data = _results3[0], + result = _results3[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'createMany'); + response.created = data.length; + response = _this3.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(_this3[op](mapper, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Destroy the record with the given primary key. Called by + * `Mapper#destroy`. + * + * @name Adapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var _this4 = this; + + var op = void 0; + opts || (opts = {}); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + _this4.dbg(op, mapper, id, opts); + return jsData.utils.resolve(_this4._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = slicedToArray(results, 2), + data = _results4[0], + result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = _this4.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(_this4[op](mapper, id, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Destroy the records that match the selection query. Called by + * `Mapper#destroyAll`. + * + * @name Adapter#destroyAll + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var _this5 = this; + + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + _this5.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this5._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = slicedToArray(results, 2), + data = _results5[0], + result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = _this5.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(_this5[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo + * @method + * @return {Promise} + */ + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { + var _this6 = this; + + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var record = records; + return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }); + } else { + var keys = records.map(function (record) { + return _this6.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return this.findAll(relationDef, { + where: defineProperty({}, relationDef.idAttribute, { + 'in': keys + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (record) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { + def.setLocalField(record, relatedItem); + } + }); + }); + }); + } + }, + + + /** + * Retrieve the record with the given primary key. Called by `Mapper#find`. + * + * @name Adapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var _this7 = this; + + var op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(this[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + _this7.dbg(op, mapper, id, opts); + return jsData.utils.resolve(_this7._find(mapper, id, opts)); + }).then(function (results) { + return _this7.loadRelationsFor(mapper, results, opts); + }).then(function (_ref) { + var _ref2 = slicedToArray(_ref, 2), + record = _ref2[0], + meta = _ref2[1]; + + var response = new Response(record, meta, 'find'); + response.found = record ? 1 : 0; + response = _this7.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(_this7[op](mapper, id, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Retrieve the records that match the selection query. + * + * @name Adapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var _this8 = this; + + var op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + var activeWith = opts._activeWith; + + if (jsData.utils.isObject(activeWith)) { + var activeQuery = activeWith.query || {}; + if (activeWith.replace) { + query = activeQuery; + } else { + jsData.utils.deepFillIn(query, activeQuery); + } + } + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return jsData.utils.resolve(this[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + _this8.dbg(op, mapper, query, opts); + return jsData.utils.resolve(_this8._findAll(mapper, query, opts)); + }).then(function (results) { + return _this8.loadRelationsFor(mapper, results, opts); + }).then(function (_ref3) { + var _ref4 = slicedToArray(_ref3, 2), + records = _ref4[0], + meta = _ref4[1]; + + var response = new Response(records, meta, 'findAll'); + response.found = records.length; + response = _this8.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(_this8[op](mapper, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + loadRelationsFor: function loadRelationsFor(mapper, results, opts) { + var _this9 = this; + + var _results6 = slicedToArray(results, 1), + records = _results6[0]; + + var tasks = []; + + if (records) { + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasOne') { + task = _this9.loadHasOne(mapper, def, records, __opts); + } else { + task = _this9.loadHasMany(mapper, def, records, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = _this9.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = _this9.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = _this9.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } + }); + } + + return jsData.utils.Promise.all(tasks).then(function () { + return results; + }); + }, + + + /** + * Resolve the value of the specified option based on the given options and + * this adapter's settings. Override with care. + * + * @name Adapter#getOpt + * @method + * @param {string} opt The name of the option. + * @param {Object} [opts] Configuration options. + * @return {*} The value of the specified option. + */ + getOpt: function getOpt(opt, opts) { + opts || (opts = {}); + return opts[opt] === undefined ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); + }, + + + /** + * Load a hasMany relationship. + * + * Override with care. + * + * @name Adapter#loadHasMany + * @method + * @return {Promise} + */ + loadHasMany: function loadHasMany(mapper, def, records, __opts) { + var _this10 = this; + + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return _this10.makeHasManyForeignKey(mapper, def, record); + }); + var query = { + where: {} + }; + var criteria = query.where[def.foreignKey] = {}; + if (singular) { + // more efficient query when we only have one record + criteria['=='] = IDs[0]; + } else { + criteria['in'] = IDs.filter(function (id) { + return id; + }); + } + return this.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { + records.forEach(function (record) { + var attached = []; + // avoid unneccesary iteration when we only have one record + if (singular) { + attached = relatedItems; + } else { + relatedItems.forEach(function (relatedItem) { + if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { + attached.push(relatedItem); + } + }); + } + def.setLocalField(record, attached); + }); + }); + }, + loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { + var _this11 = this; + + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return this.findAll(relatedMapper, { + where: defineProperty({}, relatedMapper.idAttribute, { + 'in': this.makeHasManyLocalKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + var localKeys = []; + records.forEach(function (record) { + localKeys = localKeys.concat(_this11.makeHasManyLocalKeys(mapper, def, record)); + }); + return this.findAll(relatedMapper, { + where: defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + var itemKeys = jsData.utils.get(item, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem); + } + }); + def.setLocalField(item, attached); + }); + return relatedItems; + }); + } + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var _this12 = this; + + var relatedMapper = def.getRelation(); + var idAttribute = mapper.idAttribute; + var record = void 0; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return this.findAll(def.getRelation(), { + where: defineProperty({}, def.foreignKeys, { + 'contains': this.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return this.findAll(relatedMapper, { + where: defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return _this12.makeHasManyForeignKeys(mapper, def, record); + }) + }) + }, __opts).then(function (relatedItems) { + var foreignKeysField = def.foreignKeys; + records.forEach(function (record) { + var _relatedItems = []; + var id = jsData.utils.get(record, idAttribute); + relatedItems.forEach(function (relatedItem) { + var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; + if (foreignKeys.indexOf(id) !== -1) { + _relatedItems.push(relatedItem); + } + }); + def.setLocalField(record, _relatedItems); + }); + }); + } + }, + + + /** + * Load a hasOne relationship. + * + * Override with care. + * + * @name Adapter#loadHasOne + * @method + * @return {Promise} + */ + loadHasOne: function loadHasOne(mapper, def, records, __opts) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + records = [records]; + } + return this.loadHasMany(mapper, def, records, __opts).then(function () { + records.forEach(function (record) { + var relatedData = def.getLocalField(record); + if (jsData.utils.isArray(relatedData) && relatedData.length) { + def.setLocalField(record, relatedData[0]); + } + }); + }); + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * There may be reasons why you may want to override this method, like when + * the id of the parent doesn't exactly match up to the key on the child. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKey + * @method + * @return {*} + */ + makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Return the localKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyLocalKeys + * @method + * @return {*} + */ + makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) { + var localKeys = []; + var itemKeys = jsData.utils.get(record, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + localKeys = localKeys.concat(itemKeys); + return unique(localKeys).filter(function (x) { + return x; + }); + }, + + + /** + * Return the foreignKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKeys + * @method + * @return {*} + */ + makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) { + return jsData.utils.get(record, mapper.idAttribute); + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeBelongsToForeignKey + * @method + * @return {*} + */ + makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Retrieve sum of the specified field of the records that match the selection + * query. Called by `Mapper#sum`. + * + * @name Adapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field By to sum. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var _this13 = this; + + var op = void 0; + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + query || (query = {}); + opts || (opts = {}); + + // beforeSum lifecycle hook + op = opts.op = 'beforeSum'; + return jsData.utils.resolve(this[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + _this13.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(_this13._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results7 = slicedToArray(results, 2), + data = _results7[0], + result = _results7[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = _this13.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(_this13[op](mapper, field, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * @name Adapter#respond + * @method + * @param {Object} response Response object. + * @param {Object} opts Configuration options. + * return {Object} If `opts.raw == true` then return `response`, else return + * `response.data`. + */ + respond: function respond(response, opts) { + return this.getOpt('raw', opts) ? response : response.data; + }, + + + /** + * Apply the given update to the record with the specified primary key. Called + * by `Mapper#update`. + * + * @name Adapter#update + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id The primary key of the record to be updated. + * @param {Object} props The update to apply to the record. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var _this14 = this; + + props || (props = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(this[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'update'; + _this14.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(_this14._update(mapper, id, props, opts)); + }).then(function (results) { + var _results8 = slicedToArray(results, 2), + data = _results8[0], + result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, 'update'); + response.updated = data ? 1 : 0; + response = _this14.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(_this14[op](mapper, id, props, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Apply the given update to all records that match the selection query. + * Called by `Mapper#updateAll`. + * + * @name Adapter#updateAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var _this15 = this; + + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(this[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = _props === undefined ? props : _props; + props = withoutRelations(mapper, props, opts); + op = opts.op = 'updateAll'; + _this15.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(_this15._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results9 = slicedToArray(results, 2), + data = _results9[0], + result = _results9[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateAll'); + response.updated = data.length; + response = _this15.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(_this15[op](mapper, props, query, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Update the given records in a single batch. Called by `Mapper#updateMany`. + * + * @name Adapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var _this16 = this; + + records || (records = []); + opts || (opts = {}); + var op = void 0; + var idAttribute = mapper.idAttribute; + + records = records.filter(function (record) { + return jsData.utils.get(record, idAttribute); + }); + + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return jsData.utils.resolve(this[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = _records === undefined ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record, opts); + }); + op = opts.op = 'updateMany'; + _this16.dbg(op, mapper, records, opts); + return jsData.utils.resolve(_this16._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results10 = slicedToArray(results, 2), + data = _results10[0], + result = _results10[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateMany'); + response.updated = data.length; + response = _this16.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(_this16[op](mapper, records, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + } +}); + +/** + * Create a subclass of this Adapter: + * + * @example Adapter.extend + * // Normally you would do: import {Adapter} from 'js-data' + * const JSData = require('js-data@3.0.0-beta.10') + * const {Adapter} = JSData + * console.log('Using JSData v' + JSData.version.full) + * + * // Extend the class using ES2015 class syntax. + * class CustomAdapterClass extends Adapter { + * foo () { return 'bar' } + * static beep () { return 'boop' } + * } + * const customAdapter = new CustomAdapterClass() + * console.log(customAdapter.foo()) + * console.log(CustomAdapterClass.beep()) + * + * // Extend the class using alternate method. + * const OtherAdapterClass = Adapter.extend({ + * foo () { return 'bar' } + * }, { + * beep () { return 'boop' } + * }) + * const otherAdapter = new OtherAdapterClass() + * console.log(otherAdapter.foo()) + * console.log(OtherAdapterClass.beep()) + * + * // Extend the class, providing a custom constructor. + * function AnotherAdapterClass () { + * Adapter.call(this) + * this.created_at = new Date().getTime() + * } + * Adapter.extend({ + * constructor: AnotherAdapterClass, + * foo () { return 'bar' } + * }, { + * beep () { return 'boop' } + * }) + * const anotherAdapter = new AnotherAdapterClass() + * console.log(anotherAdapter.created_at) + * console.log(anotherAdapter.foo()) + * console.log(AnotherAdapterClass.beep()) + * + * @method Adapter.extend + * @param {Object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {Object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {Object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this Adapter class. + */ + +var axios = undefined; +var hasFetch = false; + +try { + hasFetch = window && window.fetch; +} catch (e) {} + +function isValidString(value) { + return value != null && value !== ''; +} +function join(items, separator) { + separator || (separator = ''); + return items.filter(isValidString).join(separator); +} +function makePath() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var result = join(args, '/'); + return result.replace(/([^:/]|^)\/{2,}/g, '$1/'); +} + +function encode(val) { + return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); +} + +function buildUrl(url, params) { + if (!params) { + return url; + } + + var parts = []; + + jsData.utils.forOwn(params, function (val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + if (!jsData.utils.isArray(val)) { + val = [val]; + } + + val.forEach(function (v) { + if (toString.call(v) === '[object Date]') { + v = v.toISOString(); + } else if (jsData.utils.isObject(v)) { + v = jsData.utils.toJson(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; +} + +var DEFAULTS = { + /** + * Set a base path in order to use absolute URLs instead of relative URLs. + * + * @example + * const httpAdapter = new HttpAdapter({ + * basePath: 'https://mydomain.com' + * }); + * + * @name HttpAdapter#basePath + * @type {string} + * @since 3.0.0 + */ + basePath: '', + + /** + * Ensure that the request url has a trailing forward slash. + * + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + * @since 3.0.0 + */ + forceTrailingSlash: false, + + hasFetch: hasFetch, + + /** + * The HTTP function that actually makes the HTTP request. By default this is + * `axios`. + * + * @name HttpAdapter#http + * @type {function} + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library + */ + http: axios, + + /** + * Default configuration options to be mixed into the `config` argument passed + * to {@link HttpAdapter#http}. + * + * @name HttpAdapter#httpConfig + * @type {object} + * @since 3.0.0 + */ + httpConfig: {}, + + /** + * Add a suffix to the request url, e.g. ".json". + * + * @name HttpAdapter#suffix + * @type {string} + * @since 3.0.0 + */ + suffix: '', + + /** + * Use `window.fetch` if available. + * + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-windowfetch + */ + useFetch: false + + /** + * HttpAdapter class. + * + * @example + * import { DataStore } from 'js-data'; + * import { HttpAdapter } from 'js-data-http'; + * + * const httpAdapter = new HttpAdapter(); + * const store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * + * store.defineMapper('school'); + * store.defineMapper('student'); + * + * // GET /school/1 + * store.find('school', 1).then((school) => { + * console.log('school'); + * }); + * + * @class HttpAdapter + * @extends Adapter + * @param {object} [opts] Configuration options. + * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}. + * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}. + * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}. + * @param {object} [opts.http=axios] See {@link HttpAdapter#http}. + * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}. + * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}. + * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}. + * @see http://www.js-data.io/docs/js-data-http + */ +};function HttpAdapter(opts) { + jsData.utils.classCallCheck(this, HttpAdapter); + + opts || (opts = {}); + // Fill in any missing options with the defaults + jsData.utils.fillIn(opts, DEFAULTS); + Adapter.call(this, opts); +} + +/** + * @name module:js-data-http.HttpAdapter + * @see HttpAdapter + */ + +Adapter.extend({ + constructor: HttpAdapter, + + /** + * @name HttpAdapter#afterDEL + * @method + * @param {string} url + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterDEL: noop2, + + /** + * @name HttpAdapter#afterGET + * @method + * @param {string} url + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterGET: noop2, + + /** + * @name HttpAdapter#afterHTTP + * @method + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterHTTP: noop2, + + /** + * @name HttpAdapter#afterPOST + * @method + * @param {string} url + * @param {object} data + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterPOST: noop2, + + /** + * @name HttpAdapter#afterPUT + * @method + * @param {string} url + * @param {object} data + * @param {object} config + * @param {object} opts + * @param {object} response + */ + afterPUT: noop2, + + /** + * @name HttpAdapter#beforeDEL + * @method + * @param {object} url + * @param {object} config + * @param {object} opts + */ + beforeDEL: noop, + + /** + * @name HttpAdapter#beforeGET + * @method + * @param {object} url + * @param {object} config + * @param {object} opts + */ + beforeGET: noop, + + /** + * @name HttpAdapter#beforeHTTP + * @method + * @param {object} config + * @param {object} opts + */ + beforeHTTP: noop, + + /** + * @name HttpAdapter#beforePOST + * @method + * @param {object} url + * @param {object} data + * @param {object} config + * @param {object} opts + */ + beforePOST: noop, + + /** + * @name HttpAdapter#beforePUT + * @method + * @param {object} url + * @param {object} data + * @param {object} config + * @param {object} opts + */ + beforePUT: noop, + + _count: function _count(mapper, query, opts) { + var _this = this; + + return this.GET(this.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return _this._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var _this2 = this; + + return this.POST(this.getPath('create', mapper, props, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this2._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var _this3 = this; + + return this.POST(this.getPath('createMany', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this3._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var _this4 = this; + + return this.DEL(this.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return _this4._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var _this5 = this; + + return this.DEL(this.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return _this5._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var _this6 = this; + + return this.GET(this.getPath('find', mapper, id, opts), opts).then(function (response) { + return _this6._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var _this7 = this; + + return this.GET(this.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return _this7._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var _this8 = this; + + return this.GET(this.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return _this8._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var _this9 = this; + + return this.PUT(this.getPath('update', mapper, id, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this9._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var _this10 = this; + + return this.PUT(this.getPath('updateAll', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this10._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var _this11 = this; + + return this.PUT(this.getPath('updateMany', mapper, null, opts), this.serialize(mapper, records, opts), opts).then(function (response) { + return _this11._end(mapper, opts, response); + }); + }, + + + /** + * Retrieve the number of records that match the selection `query`. + * + * @name HttpAdapter#count + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params.count = true; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.count.call(this, mapper, query, opts); + }, + + + /** + * Create a new the record from the provided `props`. + * + * @name HttpAdapter#create + * @method + * @param {object} mapper The mapper. + * @param {object} props Properties to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.create.call(this, mapper, props, opts); + }, + + + /** + * Create multiple new records in batch. + * + * @name HttpAdapter#createMany + * @method + * @param {object} mapper The mapper. + * @param {array} props Array of property objects to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.createMany.call(this, mapper, props, opts); + }, + + + /** + * Make an Http request to `url` according to the configuration in `config`. + * + * @name HttpAdapter#DEL + * @method + * @param {string} url Url for the request. + * @param {object} [config] Http configuration that will be passed to + * {@link HttpAdapter#HTTP}. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + DEL: function DEL(url, config, opts) { + var _this12 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'delete'; + + // beforeDEL lifecycle hook + op = opts.op = 'beforeDEL'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'DEL'; + _this12.dbg(op, url, config, opts); + return _this12.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return jsData.utils.resolve(_this12[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the server response object into the payload that will be returned + * to JSData. + * + * @name HttpAdapter#deserialize + * @method + * @param {object} mapper The mapper used for the operation. + * @param {object} response Response object from {@link HttpAdapter#HTTP}. + * @param {object} opts Configuration options. + * @return {(object|array)} Deserialized data. + */ + deserialize: function deserialize(mapper, response, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.deserialize)) { + return opts.deserialize(mapper, response, opts); + } + if (jsData.utils.isFunction(mapper.deserialize)) { + return mapper.deserialize(mapper, response, opts); + } + if (response && response.hasOwnProperty('data')) { + return response.data; + } + return response; + }, + + + /** + * Destroy the record with the given primary key. + * + * @name HttpAdapter#destroy + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.destroy.call(this, mapper, id, opts); + }, + + + /** + * Destroy the records that match the selection `query`. + * + * @name HttpAdapter#destroyAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.destroyAll.call(this, mapper, query, opts); + }, + + + /** + * Log an error. + * + * @name HttpAdapter#error + * @method + * @param {...*} [args] Arguments to log. + */ + error: function error() { + if (console) { + var _console; + + (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); + } + }, + + + /** + * Make an Http request using `window.fetch`. + * + * @name HttpAdapter#fetch + * @method + * @param {object} config Request configuration. + * @param {object} config.data Payload for the request. + * @param {string} config.method Http method for the request. + * @param {object} config.headers Headers for the request. + * @param {object} config.params Querystring for the request. + * @param {string} config.url Url for the request. + */ + fetch: function (_fetch) { + function fetch(_x) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config) { + var requestConfig = { + method: config.method, + // turn the plain headers object into the Fetch Headers object + headers: new Headers(config.headers || {}) + }; + + if (config.data) { + requestConfig.body = jsData.utils.toJson(config.data); + } + + return fetch(buildUrl(config.url, config.params), requestConfig).then(function (response) { + response.config = { + method: config.method, + url: config.url + }; + return response.json().then(function (data) { + response.data = data; + return response; + }); + }); + }), + + + /** + * Retrieve the record with the given primary key. + * + * @name HttpAdapter#find + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.find.call(this, mapper, id, opts); + }, + + + /** + * Retrieve the records that match the selection `query`. + * + * @name HttpAdapter#findAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.findAll.call(this, mapper, query, opts); + }, + + + /** + * Make a GET request. + * + * @name HttpAdapter#GET + * @method + * @param {string} url The url for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + GET: function GET(url, config, opts) { + var _this13 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'get'; + + // beforeGET lifecycle hook + op = opts.op = 'beforeGET'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'GET'; + _this13.dbg(op, url, config, opts); + return _this13.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return jsData.utils.resolve(_this13[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {object} mapper The Mapper. + * @param {*} id The primary key, if any. + * @param {boolean} opts Configuration options. + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var _this14 = this; + + opts || (opts = {}); + opts.params = jsData.utils.isUndefined(opts.params) ? {} : opts.params; + var relationList = mapper.relationList || []; + var endpoint = jsData.utils.isUndefined(opts.endpoint) ? jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; + + relationList.forEach(function (def) { + if (def.type !== 'belongsTo' || !def.parent) { + return; + } + var item = void 0; + var parentKey = def.foreignKey; + var parentDef = def.getRelation(); + var parentId = opts.params[parentKey]; + + if (parentId === false || !parentKey || !parentDef) { + if (parentId === false) { + delete opts.params[parentKey]; + } + return false; + } else { + delete opts.params[parentKey]; + + if (jsData.utils.isObject(id)) { + item = id; + } + + if (item) { + parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); + } + + if (parentId) { + delete opts.endpoint; + var _opts = {}; + jsData.utils.forOwn(opts, function (value, key) { + _opts[key] = value; + }); + jsData.utils._(_opts, parentDef); + endpoint = makePath(_this14.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return false; + } + } + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method The method being executed. + * @param {object} mapper The Mapper. + * @param {(string|number)?} id The primary key, if any. + * @param {object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + opts || (opts = {}); + var args = [opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, this.getEndpoint(mapper, jsData.utils.isString(id) || jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; + if (method === 'find' || method === 'update' || method === 'destroy') { + args.push(id); + } + return makePath.apply(jsData.utils, args); + }, + getParams: function getParams(opts) { + opts || (opts = {}); + if (opts.params === undefined) { + return {}; + } + return jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (opts.suffix === undefined) { + if (mapper.suffix === undefined) { + return this.suffix; + } + return mapper.suffix; + } + return opts.suffix; + }, + + + /** + * Make an Http request. + * + * @name HttpAdapter#HTTP + * @method + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + HTTP: function HTTP(config, opts) { + var _this15 = this; + + var start = new Date(); + opts || (opts = {}); + var payload = config.data; + var cache = config.cache; + var timeout = config.timeout; + config = jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); + config = jsData.utils.deepMixIn(config, this.httpConfig); + config.data = payload; + config.cache = cache; + if (timeout !== undefined) { + config.timeout = timeout; + } + if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || this.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + var logResponse = function logResponse(data) { + var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; + if (data.status >= 200 && data.status < 300) { + if (_this15.log) { + _this15.dbg(str, data); + } + return data; + } else { + if (_this15.error) { + _this15.error('\'FAILED: ' + str, data); + } + return jsData.utils.reject(data); + } + }; + + if (!this.http) { + if (this.useFetch || opts.useFetch) { + if (!hasFetch) { + throw new Error('Attempting to use window.fetch, but it is not available!'); + } + } else { + throw new Error('You have not configured this adapter with an http library!'); + } + } + + return jsData.utils.resolve(this.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (_this15.useFetch || opts.useFetch || !_this15.http)) { + return _this15.fetch(config, opts).then(logResponse, logResponse); + } + var httpConfig = jsData.utils.plainCopy(config); + delete httpConfig.adapter; + return _this15.http(httpConfig).then(logResponse, logResponse).catch(function (err) { + return _this15.responseError(err, config, opts); + }); + }).then(function (response) { + return jsData.utils.resolve(_this15.afterHTTP(config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Make a POST request. + * + * @name HttpAdapter#POST + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var _this16 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'post'; + + // beforePOST lifecycle hook + op = opts.op = 'beforePOST'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'POST'; + _this16.dbg(op, url, data, config, opts); + return _this16.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return jsData.utils.resolve(_this16[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Make a PUT request. + * + * @name HttpAdapter#PUT + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var _this17 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'put'; + + // beforePUT lifecycle hook + op = opts.op = 'beforePUT'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'PUT'; + _this17.dbg(op, url, data, config, opts); + return _this17.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return jsData.utils.resolve(_this17[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the querystring object before it is serialized. This doesn't do + * anything by default. + * + * @name HttpAdapter#queryTransform + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {*} params The querystring object. + * @param {*} opts Configuration options + * @return {*} Transformed params. + */ + queryTransform: function queryTransform(mapper, params, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts); + } + if (jsData.utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts); + } + return params; + }, + + + /** + * Error handler invoked when the promise returned by {@link HttpAdapter#http} + * is rejected. Default implementation is to just return the error wrapped in + * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is + * called by {@link HttpAdapter#HTTP}. + * + * @name HttpAdapter#responseError + * @method + * @param {*} err The error that {@link HttpAdapter#http} rejected with. + * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. + * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. + * @return {Promise} + */ + responseError: function responseError(err, config, opts) { + return jsData.utils.reject(err); + }, + + + /** + * Serialize request data. This doesn't do anything by default. + * + * @name HttpAdapter#serialize + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {object} data The request payload. + * @param {*} opts Configuration options. + * @return {*} Serialized data. + */ + serialize: function serialize(mapper, data, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts); + } + if (jsData.utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts); + } + return data; + }, + + + /** + * Retrieve the sum of the field of the records that match the selection query. + * + * @name HttpAdapter#sum + * @method + * @param {object} mapper The mapper. + * @param {string} field The field to sum. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + query || (query = {}); + opts || (opts = {}); + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = this.getParams(opts); + opts.params.sum = field; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return Adapter.prototype.sum.call(this, mapper, field, query, opts); + }, + + + /** + * Perform an update. Makes a PUT request by default. + * + * @name HttpAdapter#update + * @method + * @param {object} mapper The Mapper for the request. + * @param {*} id The primary key of the record being updated. + * @param {*} props The update payload. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.update.call(this, mapper, id, props, opts); + }, + + + /** + * Perform an update against records that match the selection query. Makes a + * PUT request by default. + * + * @name HttpAdapter#updateAll + * @method + * @param {object} mapper The Mapper for the request. + * @param {object} props The update payload. + * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.updateAll.call(this, mapper, props, query, opts); + }, + + + /** + * Update multiple individual records in a batch. + * + * @name HttpAdapter#updateMany + * @method + * @param {object} mapper The Mapper for the request. + * @param {array} records Array of property objects to send as the payload. + * Each must contain the primary key of the record to be updated. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return Adapter.prototype.updateMany.call(this, mapper, records, opts); + } +}); + +/** + * Add an Http actions to a mapper. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addAction = JSDataHttp.addAction; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * // GET /reports/schools/:school_id/teachers + * addAction('getTeacherReports', { + * endpoint: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addAction + * @method + * @param {string} name Name of the new action. + * @param {object} [opts] Action configuration + * @param {string} [opts.adapter="http"] The name of the adapter to use. + * @param {string} [opts.pathname] Set the action's pathname. + * @param {function} [opts.request] Specify a request handler to be executed + * before the request is made. + * @param {function} [opts.response] Specify a response handler to be executed + * after the response is received. + * @param {function} [opts.responseError] Specify an error handler to be + * executed on error. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addAction(name, opts) { + if (!name || !jsData.utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + } + return function (mapper) { + if (mapper[name]) { + throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); + } + opts.request = opts.request || function (config) { + return config; + }; + opts.response = opts.response || function (response) { + return response; + }; + opts.responseError = opts.responseError || function (err) { + return jsData.utils.reject(err); + }; + mapper[name] = function (id, _opts) { + var _this18 = this; + + _opts = _opts || {}; + if (jsData.utils.isObject(id)) { + _opts = id; + } + jsData.utils.fillIn(_opts, opts); + var adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http'); + var config = {}; + config.mapper = this.name; + jsData.utils.deepMixIn(config, _opts); + config.method = config.method || 'GET'; + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(this, _opts); + } else { + var args = [_opts.basePath || this.basePath || adapter.basePath, adapter.getEndpoint(this, id, _opts)]; + if (jsData.utils.isSorN(id)) { + args.push(id); + } + args.push(opts.pathname || name); + config.url = makePath.apply(null, args); + } + return jsData.utils.resolve(config).then(_opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = _this18.name; + } + return data; + }).then(_opts.response, _opts.responseError); + }; + return mapper; + }; +} + +/** + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addActions = JSDataHttp.addActions; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * addActions({ + * // GET /reports/schools/:school_id/teachers + * getTeacherReports: { + * basePath: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * } + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addActions + * @method + * @param {object.} opts Object where the key is an action name + * and the value is the configuration for the action. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addActions(opts) { + opts || (opts = {}); + return function (mapper) { + jsData.utils.forOwn(opts, function (value, key) { + addAction(key, value)(mapper); + }); + return mapper; + }; +} + +/** + * Details of the current version of the `js-data-http` module. + * + * @name module:js-data-http.version + * @type {object} + * @property {string} version.full The full semver value. + * @property {number} version.major The major version number. + * @property {number} version.minor The minor version number. + * @property {number} version.patch The patch version number. + * @property {(string|boolean)} version.alpha The alpha version value, + * otherwise `false` if the current version is not alpha. + * @property {(string|boolean)} version.beta The beta version value, + * otherwise `false` if the current version is not beta. + */ +var version = { + full: '3.0.0', + major: 3, + minor: 0, + patch: 0 +}; + +/** + * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http` + * that works on Node.js is registered in NPM as `js-data-http-node`. The build + * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower + * as `js-data-fetch`. + * + * @example Script tag + * var HttpAdapter = window.JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example CommonJS + * var HttpAdapter = require('js-data-Http').HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example ES2015 Modules + * import { HttpAdapter } from 'js-data-Http'; + * const httpAdapter = new HttpAdapter(); + * + * @example AMD + * define('myApp', ['js-data-Http'], function (JSDataHttp) { + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * // ... + * }); + * + * @module js-data-http + */ + +/** + * Create a subclass of this HttpAdapter: + * @example HttpAdapter.extend + * // Normally you would do: import { HttpAdapter } from 'js-data-http'; + * // or: import { HttpAdapter } from 'js-data-http-node'; + * const JSDataHttp = require('js-data-http-node'); + * const { HttpAdapter } = JSDataHttp; + * console.log('Using JSDataHttp v' + JSDataHttp.version.full); + * + * // Extend the class using ES2015 class syntax. + * class CustomHttpAdapterClass extends HttpAdapter { + * foo () { return 'bar'; } + * static beep () { return 'boop'; } + * } + * const customHttpAdapter = new CustomHttpAdapterClass(); + * console.log(customHttpAdapter.foo()); + * console.log(CustomHttpAdapterClass.beep()); + * + * // Extend the class using alternate method. + * const OtherHttpAdapterClass = HttpAdapter.extend({ + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const otherHttpAdapter = new OtherHttpAdapterClass(); + * console.log(otherHttpAdapter.foo()); + * console.log(OtherHttpAdapterClass.beep()); + * + * // Extend the class, providing a custom constructor. + * function AnotherHttpAdapterClass () { + * HttpAdapter.call(this); + * this.created_at = new Date().getTime(); + * } + * HttpAdapter.extend({ + * constructor: AnotherHttpAdapterClass, + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const anotherHttpAdapter = new AnotherHttpAdapterClass(); + * console.log(anotherHttpAdapter.created_at); + * console.log(anotherHttpAdapter.foo()); + * console.log(AnotherHttpAdapterClass.beep()); + * + * @method HttpAdapter.extend + * @param {object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this HttpAdapter class. + * @since 3.0.0 + */ + +exports.HttpAdapter = HttpAdapter; +exports.addAction = addAction; +exports.addActions = addActions; +exports.version = version; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=js-data-fetch.js.map diff --git a/fetch/dist/js-data-fetch.js.map b/fetch/dist/js-data-fetch.js.map new file mode 100644 index 0000000..2286e14 --- /dev/null +++ b/fetch/dist/js-data-fetch.js.map @@ -0,0 +1 @@ +{"version":3,"file":"js-data-fetch.js","sources":["../../node_modules/js-data-adapter/src/index.js","../../src/index.js"],"sourcesContent":["import { Component, utils } from 'js-data'\n\nexport const noop = function (...args) {\n const opts = args[args.length - 1]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const opts = args[args.length - 2]\n this.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const unique = function (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\n\nexport const withoutRelations = function (mapper, props, opts) {\n opts || (opts = {})\n opts.with || (opts.with = [])\n const relationFields = mapper.relationFields || []\n const toStrip = relationFields.filter((value) => opts.with.indexOf(value) === -1)\n return utils.omit(props, toStrip)\n}\n\nexport const reserved = [\n 'orderBy',\n 'sort',\n 'limit',\n 'offset',\n 'skip',\n 'where'\n]\n\n/**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\nexport function Response (data, meta, op) {\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n this.data = data\n\n utils.fillIn(this, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n this.op = op\n}\n\nconst DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @extends Component\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\nexport function Adapter (opts) {\n utils.classCallCheck(this, Adapter)\n Component.call(this, opts)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(this, opts)\n}\n\nComponent.extend({\n constructor: Adapter,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {string} field The `field` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._count(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'create'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._create(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'create')\n response.created = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(this[op](mapper, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = props.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'createMany'\n this.dbg(op, mapper, props, opts)\n return utils.resolve(this._createMany(mapper, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'createMany')\n response.created = data.length\n response = this.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(this[op](mapper, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'destroy'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._destroy(mapper, id, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = this.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'destroyAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._destroyAll(mapper, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = this.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo (mapper, def, records, __opts) {\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return this.find(relationDef, this.makeBelongsToForeignKey(mapper, def, record), __opts)\n .then((relatedItem) => {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records\n .map((record) => this.makeBelongsToForeignKey(mapper, def, record))\n .filter((key) => key)\n return this.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((record) => {\n relatedItems.forEach((relatedItem) => {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem)\n }\n })\n })\n })\n }\n },\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(this[op](mapper, id, opts))\n .then(() => {\n op = opts.op = 'find'\n this.dbg(op, mapper, id, opts)\n return utils.resolve(this._find(mapper, id, opts))\n })\n .then((results) => this.loadRelationsFor(mapper, results, opts))\n .then(([record, meta]) => {\n let response = new Response(record, meta, 'find')\n response.found = record ? 1 : 0\n response = this.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(this[op](mapper, id, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n const activeWith = opts._activeWith\n\n if (utils.isObject(activeWith)) {\n const activeQuery = activeWith.query || {}\n if (activeWith.replace) {\n query = activeQuery\n } else {\n utils.deepFillIn(query, activeQuery)\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return utils.resolve(this[op](mapper, query, opts))\n .then(() => {\n op = opts.op = 'findAll'\n this.dbg(op, mapper, query, opts)\n return utils.resolve(this._findAll(mapper, query, opts))\n })\n .then((results) => this.loadRelationsFor(mapper, results, opts))\n .then(([records, meta]) => {\n let response = new Response(records, meta, 'findAll')\n response.found = records.length\n response = this.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(this[op](mapper, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n loadRelationsFor (mapper, results, opts) {\n const [records] = results\n const tasks = []\n\n if (records) {\n utils.forEachRelation(mapper, opts, (def, __opts) => {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = this.loadHasOne(mapper, def, records, __opts)\n } else {\n task = this.loadHasMany(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = this.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = this.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = this.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n }\n\n return utils.Promise.all(tasks)\n .then(() => results)\n },\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt (opt, opts) {\n opts || (opts = {})\n return opts[opt] === undefined ? utils.plainCopy(this[opt]) : utils.plainCopy(opts[opt])\n },\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany (mapper, def, records, __opts) {\n let singular = false\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n const IDs = records.map((record) => this.makeHasManyForeignKey(mapper, def, record))\n const query = {\n where: {}\n }\n const criteria = query.where[def.foreignKey] = {}\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0]\n } else {\n criteria['in'] = IDs.filter((id) => id)\n }\n return this.findAll(def.getRelation(), query, __opts).then((relatedItems) => {\n records.forEach((record) => {\n let attached = []\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems\n } else {\n relatedItems.forEach((relatedItem) => {\n if (utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem)\n }\n })\n }\n def.setLocalField(record, attached)\n })\n })\n },\n\n loadHasManyLocalKeys (mapper, def, records, __opts) {\n let record\n const relatedMapper = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': this.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach((record) => {\n localKeys = localKeys.concat(this.makeHasManyLocalKeys(mapper, def, record))\n })\n return this.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter((x) => x)\n }\n }\n }, __opts).then((relatedItems) => {\n records.forEach((item) => {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach((relatedItem) => {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem)\n }\n })\n def.setLocalField(item, attached)\n })\n return relatedItems\n })\n }\n },\n\n loadHasManyForeignKeys (mapper, def, records, __opts) {\n const relatedMapper = def.getRelation()\n const idAttribute = mapper.idAttribute\n let record\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return this.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': this.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then((relatedItems) => {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return this.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map((record) => this.makeHasManyForeignKeys(mapper, def, record))\n }\n }\n }, __opts).then((relatedItems) => {\n const foreignKeysField = def.foreignKeys\n records.forEach((record) => {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach((relatedItem) => {\n const foreignKeys = utils.get(relatedItems, foreignKeysField) || []\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem)\n }\n })\n def.setLocalField(record, _relatedItems)\n })\n })\n }\n },\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne (mapper, def, records, __opts) {\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n }\n return this.loadHasMany(mapper, def, records, __opts).then(() => {\n records.forEach((record) => {\n const relatedData = def.getLocalField(record)\n if (utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0])\n }\n })\n })\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n let localKeys = []\n let itemKeys = utils.get(record, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n return unique(localKeys).filter((x) => x)\n },\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys (mapper, def, record) {\n return utils.get(record, mapper.idAttribute)\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n let op\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n query || (query = {})\n opts || (opts = {})\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum'\n return utils.resolve(this[op](mapper, field, query, opts))\n .then(() => {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n this.dbg(op, mapper, field, query, opts)\n return utils.resolve(this._sum(mapper, field, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = this.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(this[op](mapper, field, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond (response, opts) {\n return this.getOpt('raw', opts) ? response : response.data\n },\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(this[op](mapper, id, props, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'update'\n this.dbg(op, mapper, id, props, opts)\n return utils.resolve(this._update(mapper, id, props, opts))\n })\n .then((results) => {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'update')\n response.updated = data ? 1 : 0\n response = this.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(this[op](mapper, id, props, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let op\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts))\n .then((_props) => {\n // Allow for re-assignment from lifecycle hook\n props = _props === undefined ? props : _props\n props = withoutRelations(mapper, props, opts)\n op = opts.op = 'updateAll'\n this.dbg(op, mapper, props, query, opts)\n return utils.resolve(this._updateAll(mapper, props, query, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateAll')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(this[op](mapper, props, query, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter((record) => utils.get(record, idAttribute))\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(this[op](mapper, records, opts))\n .then((_records) => {\n // Allow for re-assignment from lifecycle hook\n records = _records === undefined ? records : _records\n records = records.map((record) => withoutRelations(mapper, record, opts))\n op = opts.op = 'updateMany'\n this.dbg(op, mapper, records, opts)\n return utils.resolve(this._updateMany(mapper, records, opts))\n })\n .then((results) => {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateMany')\n response.updated = data.length\n response = this.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(this[op](mapper, records, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n }\n})\n\n/**\n * Create a subclass of this Adapter:\n *\n * @example Adapter.extend\n * // Normally you would do: import {Adapter} from 'js-data'\n * const JSData = require('js-data@3.0.0-beta.10')\n * const {Adapter} = JSData\n * console.log('Using JSData v' + JSData.version.full)\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomAdapterClass extends Adapter {\n * foo () { return 'bar' }\n * static beep () { return 'boop' }\n * }\n * const customAdapter = new CustomAdapterClass()\n * console.log(customAdapter.foo())\n * console.log(CustomAdapterClass.beep())\n *\n * // Extend the class using alternate method.\n * const OtherAdapterClass = Adapter.extend({\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const otherAdapter = new OtherAdapterClass()\n * console.log(otherAdapter.foo())\n * console.log(OtherAdapterClass.beep())\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherAdapterClass () {\n * Adapter.call(this)\n * this.created_at = new Date().getTime()\n * }\n * Adapter.extend({\n * constructor: AnotherAdapterClass,\n * foo () { return 'bar' }\n * }, {\n * beep () { return 'boop' }\n * })\n * const anotherAdapter = new AnotherAdapterClass()\n * console.log(anotherAdapter.created_at)\n * console.log(anotherAdapter.foo())\n * console.log(AnotherAdapterClass.beep())\n *\n * @method Adapter.extend\n * @param {Object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {Object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {Object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this Adapter class.\n */\n","import { utils } from 'js-data'\nimport axios from '../node_modules/axios/dist/axios'\nimport {\n Adapter,\n noop,\n noop2\n} from '../node_modules/js-data-adapter/src/index'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst DEFAULTS = {\n /**\n * Set a base path in order to use absolute URLs instead of relative URLs.\n *\n * @example\n * const httpAdapter = new HttpAdapter({\n * basePath: 'https://mydomain.com'\n * });\n *\n * @name HttpAdapter#basePath\n * @type {string}\n * @since 3.0.0\n */\n basePath: '',\n\n /**\n * Ensure that the request url has a trailing forward slash.\n *\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n forceTrailingSlash: false,\n\n hasFetch: hasFetch,\n\n /**\n * The HTTP function that actually makes the HTTP request. By default this is\n * `axios`.\n *\n * @name HttpAdapter#http\n * @type {function}\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library\n */\n http: axios,\n\n /**\n * Default configuration options to be mixed into the `config` argument passed\n * to {@link HttpAdapter#http}.\n *\n * @name HttpAdapter#httpConfig\n * @type {object}\n * @since 3.0.0\n */\n httpConfig: {},\n\n /**\n * Add a suffix to the request url, e.g. \".json\".\n *\n * @name HttpAdapter#suffix\n * @type {string}\n * @since 3.0.0\n */\n suffix: '',\n\n /**\n * Use `window.fetch` if available.\n *\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-windowfetch\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @example\n * import { DataStore } from 'js-data';\n * import { HttpAdapter } from 'js-data-http';\n *\n * const httpAdapter = new HttpAdapter();\n * const store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n *\n * store.defineMapper('school');\n * store.defineMapper('student');\n *\n * // GET /school/1\n * store.find('school', 1).then((school) => {\n * console.log('school');\n * });\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}.\n * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}.\n * @param {object} [opts.http=axios] See {@link HttpAdapter#http}.\n * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}.\n * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}.\n * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}.\n * @see http://www.js-data.io/docs/js-data-http\n */\nexport function HttpAdapter (opts) {\n utils.classCallCheck(this, HttpAdapter)\n\n opts || (opts = {})\n // Fill in any missing options with the defaults\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(this, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\nAdapter.extend({\n constructor: HttpAdapter,\n\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n return this.GET(\n this.getPath('count', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _create (mapper, props, opts) {\n return this.POST(\n this.getPath('create', mapper, props, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _createMany (mapper, props, opts) {\n return this.POST(\n this.getPath('createMany', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroy (mapper, id, opts) {\n return this.DEL(\n this.getPath('destroy', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroyAll (mapper, query, opts) {\n return this.DEL(\n this.getPath('destroyAll', mapper, null, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n return this.GET(\n this.getPath('find', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _findAll (mapper, query, opts) {\n return this.GET(\n this.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _sum (mapper, field, query, opts) {\n return this.GET(\n this.getPath('sum', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _update (mapper, id, props, opts) {\n return this.PUT(\n this.getPath('update', mapper, id, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateAll (mapper, props, query, opts) {\n return this.PUT(\n this.getPath('updateAll', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateMany (mapper, records, opts) {\n return this.PUT(\n this.getPath('updateMany', mapper, null, opts),\n this.serialize(mapper, records, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params.count = true\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.count.call(this, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {object} mapper The mapper.\n * @param {object} props Properties to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.create.call(this, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {object} mapper The mapper.\n * @param {array} props Array of property objects to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.createMany.call(this, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'DEL'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {object} mapper The mapper used for the operation.\n * @param {object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {object} opts Configuration options.\n * @return {(object|array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroy.call(this, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroyAll.call(this, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {object} config Request configuration.\n * @param {object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {object} config.headers Headers for the request.\n * @param {object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n */\n fetch (config) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers || {})\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(buildUrl(config.url, config.params), requestConfig)\n .then((response) => {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json()\n .then((data) => {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.find.call(this, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.findAll.call(this, mapper, query, opts)\n },\n\n /**\n * Make a GET request.\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'GET'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {object} mapper The Mapper.\n * @param {*} id The primary key, if any.\n * @param {boolean} opts Configuration options.\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach((def) => {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, (value, key) => {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method The method being executed.\n * @param {object} mapper The Mapper.\n * @param {(string|number)?} id The primary key, if any.\n * @param {object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n opts || (opts = {})\n const args = [\n opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath,\n this.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (opts.params === undefined) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (opts.suffix === undefined) {\n if (mapper.suffix === undefined) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, this.httpConfig)\n config.data = payload\n config.cache = cache\n if (timeout !== undefined) {\n config.timeout = timeout\n }\n if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || this.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n const logResponse = (data) => {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (this.log) {\n this.dbg(str, data)\n }\n return data\n } else {\n if (this.error) {\n this.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!this.http) {\n if ((this.useFetch || opts.useFetch)) {\n if (!hasFetch) {\n throw new Error('Attempting to use window.fetch, but it is not available!')\n }\n } else {\n throw new Error('You have not configured this adapter with an http library!')\n }\n }\n\n return utils.resolve(this.beforeHTTP(config, opts))\n .then((_config) => {\n config = _config || config\n if (hasFetch && (this.useFetch || opts.useFetch || !this.http)) {\n return this.fetch(config, opts).then(logResponse, logResponse)\n }\n const httpConfig = utils.plainCopy(config)\n delete httpConfig.adapter\n return this.http(httpConfig).then(logResponse, logResponse)\n .catch((err) => this.responseError(err, config, opts))\n })\n .then((response) => {\n return utils.resolve(this.afterHTTP(config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a POST request.\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'POST'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a PUT request.\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'PUT'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the querystring object before it is serialized. This doesn't do\n * anything by default.\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {*} params The querystring object.\n * @param {*} opts Configuration options\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * Serialize request data. This doesn't do anything by default.\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {object} data The request payload.\n * @param {*} opts Configuration options.\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n query || (query = {})\n opts || (opts = {})\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = this.getParams(opts)\n opts.params.sum = field\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.sum.call(this, mapper, field, query, opts)\n },\n\n /**\n * Perform an update. Makes a PUT request by default.\n *\n * @name HttpAdapter#update\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {*} id The primary key of the record being updated.\n * @param {*} props The update payload.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.update.call(this, mapper, id, props, opts)\n },\n\n /**\n * Perform an update against records that match the selection query. Makes a\n * PUT request by default.\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {object} props The update payload.\n * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateAll.call(this, mapper, props, query, opts)\n },\n\n /**\n * Update multiple individual records in a batch.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {array} records Array of property objects to send as the payload.\n * Each must contain the primary key of the record to be updated.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateMany.call(this, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addAction = JSDataHttp.addAction;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * endpoint: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {object} [opts] Action configuration\n * @param {string} [opts.adapter=\"http\"] The name of the adapter to use.\n * @param {string} [opts.pathname] Set the action's pathname.\n * @param {function} [opts.request] Specify a request handler to be executed\n * before the request is made.\n * @param {function} [opts.response] Specify a response handler to be executed\n * after the response is received.\n * @param {function} [opts.responseError] Specify an error handler to be\n * executed on error.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addAction (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n _opts = _opts || {}\n if (utils.isObject(id)) {\n _opts = id\n }\n utils.fillIn(_opts, opts)\n let adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http')\n const config = {}\n config.mapper = this.name\n utils.deepMixIn(config, _opts)\n config.method = config.method || 'GET'\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(this, _opts)\n } else {\n let args = [\n _opts.basePath || this.basePath || adapter.basePath,\n adapter.getEndpoint(this, id, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n return utils.resolve(config)\n .then(_opts.request)\n .then((config) => adapter.HTTP(config))\n .then((data) => {\n if (data && data.config) {\n data.config.mapper = this.name\n }\n return data\n })\n .then(_opts.response, _opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addActions = JSDataHttp.addActions;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * addActions({\n * // GET /reports/schools/:school_id/teachers\n * getTeacherReports: {\n * basePath: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * }\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addActions\n * @method\n * @param {object.} opts Object where the key is an action name\n * and the value is the configuration for the action.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name module:js-data-http.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http`\n * that works on Node.js is registered in NPM as `js-data-http-node`. The build\n * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower\n * as `js-data-fetch`.\n *\n * @example Script tag\n * var HttpAdapter = window.JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example ES2015 Modules\n * import { HttpAdapter } from 'js-data-Http';\n * const httpAdapter = new HttpAdapter();\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * // ...\n * });\n *\n * @module js-data-http\n */\n\n/**\n * Create a subclass of this HttpAdapter:\n * @example HttpAdapter.extend\n * // Normally you would do: import { HttpAdapter } from 'js-data-http';\n * // or: import { HttpAdapter } from 'js-data-http-node';\n * const JSDataHttp = require('js-data-http-node');\n * const { HttpAdapter } = JSDataHttp;\n * console.log('Using JSDataHttp v' + JSDataHttp.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomHttpAdapterClass extends HttpAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customHttpAdapter = new CustomHttpAdapterClass();\n * console.log(customHttpAdapter.foo());\n * console.log(CustomHttpAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherHttpAdapterClass = HttpAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const otherHttpAdapter = new OtherHttpAdapterClass();\n * console.log(otherHttpAdapter.foo());\n * console.log(OtherHttpAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherHttpAdapterClass () {\n * HttpAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * HttpAdapter.extend({\n * constructor: AnotherHttpAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const anotherHttpAdapter = new AnotherHttpAdapterClass();\n * console.log(anotherHttpAdapter.created_at);\n * console.log(anotherHttpAdapter.foo());\n * console.log(AnotherHttpAdapterClass.beep());\n *\n * @method HttpAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this HttpAdapter class.\n * @since 3.0.0\n */\n"],"names":["noop","args","opts","length","dbg","op","utils","resolve","noop2","unique","array","seen","final","forEach","item","push","withoutRelations","mapper","props","with","relationFields","toStrip","filter","value","indexOf","omit","Response","data","meta","fillIn","DEFAULTS","Adapter","classCallCheck","call","Component","extend","query","then","_count","results","result","response","respond","_response","undefined","_props","_create","created","map","record","_createMany","id","_destroy","_destroyAll","def","records","__opts","relationDef","getRelation","isObject","isArray","find","makeBelongsToForeignKey","relatedItem","setLocalField","keys","key","findAll","idAttribute","relatedItems","foreignKey","_find","loadRelationsFor","found","activeWith","_activeWith","activeQuery","replace","deepFillIn","_findAll","tasks","forEachRelation","task","type","loadHasOne","loadHasMany","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadBelongsTo","Promise","all","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","where","attached","get","relatedMapper","makeHasManyLocalKeys","concat","x","itemKeys","Object","makeHasManyForeignKeys","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","field","isString","Error","_sum","getOpt","_update","updated","_updateAll","_records","_updateMany","hasFetch","window","fetch","e","isValidString","join","items","separator","makePath","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","v","toString","toISOString","toJson","axios","HttpAdapter","GET","getPath","_end","POST","serialize","DEL","deserialize","PUT","getParams","count","suffix","getSuffix","deepMixIn","queryTransform","prototype","create","createMany","config","method","_config","HTTP","isFunction","hasOwnProperty","destroy","destroyAll","console","error","requestConfig","Headers","headers","body","json","isUndefined","relationList","endpoint","name","parent","parentKey","parentDef","parentId","_opts","_","getEndpoint","basePath","isNumber","apply","copy","start","Date","payload","cache","timeout","httpConfig","forceTrailingSlash","toUpperCase","substr","logResponse","str","toUTCString","status","getTime","log","reject","http","useFetch","beforeHTTP","adapter","catch","err","responseError","afterHTTP","sum","update","updateAll","updateMany","addAction","TypeError","request","getAdapter","defaultAdapter","isSorN","pathname","addActions","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,OAAO,SAAPA,IAAO,GAAmB;oCAANC,IAAM;QAAA;;;MAC/BC,OAAOD,KAAKA,KAAKE,MAAL,GAAc,CAAnB,CAAb;OACKC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.min.js b/fetch/dist/js-data-fetch.min.js new file mode 100644 index 0000000..59ad8db --- /dev/null +++ b/fetch/dist/js-data-fetch.min.js @@ -0,0 +1,10 @@ +/*! +* js-data-fetch +* @version 3.0.0 - Homepage +* @copyright (c) 2014-2016 js-data-http project authors +* @license MIT +* +* @overview HTTP adapter for js-data that uses the fetch API. +*/ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-fetch",["exports","js-data"],e):e(t.JSDataHttp=t.JSDataHttp||{},t.JSData)}(this,function(t,e){"use strict";function Response(t,n,r){n||(n={}),this.data=t,e.utils.fillIn(this,n),this.op=r}function Adapter(t){e.utils.classCallCheck(this,Adapter),e.Component.call(this,t),t||(t={}),e.utils.fillIn(t,l),e.utils.fillIn(this,t)}function isValidString(t){return null!=t&&""!==t}function join(t,e){return e||(e=""),t.filter(isValidString).join(e)}function makePath(){for(var t=arguments.length,e=Array(t),n=0;n0&&(t+=(-1===t.indexOf("?")?"?":"&")+r.join("&")),t}function HttpAdapter(t){e.utils.classCallCheck(this,HttpAdapter),t||(t={}),e.utils.fillIn(t,d),Adapter.call(this,t)}function addAction(t,r){if(!t||!e.utils.isString(t))throw new TypeError("action(name[, opts]): Expected: string, Found: "+(void 0===t?"undefined":n(t)));return function(n){if(n[t])throw new Error("action(name[, opts]): "+t+" already exists on target!");return r.request=r.request||function(t){return t},r.response=r.response||function(t){return t},r.responseError=r.responseError||function(t){return e.utils.reject(t)},n[t]=function(n,i){var o=this;i=i||{},e.utils.isObject(n)&&(i=n),e.utils.fillIn(i,r);var a=this.getAdapter(i.adapter||this.defaultAdapter||"http"),s={};if(s.mapper=this.name,e.utils.deepMixIn(s,i),s.method=s.method||"GET","function"==typeof i.getEndpoint)s.url=i.getEndpoint(this,i);else{var u=[i.basePath||this.basePath||a.basePath,a.getEndpoint(this,n,i)];e.utils.isSorN(n)&&u.push(n),u.push(r.pathname||t),s.url=makePath.apply(null,u)}return e.utils.resolve(s).then(i.request).then(function(t){return a.HTTP(t)}).then(function(t){return t&&t.config&&(t.config.mapper=o.name),t}).then(i.response,i.responseError)},n}}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},i=function(){function sliceIterator(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return sliceIterator(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function noop(){for(var t=arguments.length,n=Array(t),r=0;r=200&&n.status<300?(r.log&&r.dbg(o,n),n):(r.error&&r.error("'FAILED: "+o,n),e.utils.reject(n))};if(!this.http){if(!this.useFetch&&!n.useFetch)throw new Error("You have not configured this adapter with an http library!");if(!f)throw new Error("Attempting to use window.fetch, but it is not available!")}return e.utils.resolve(this.beforeHTTP(t,n)).then(function(i){if(t=i||t,f&&(r.useFetch||n.useFetch||!r.http))return r.fetch(t,n).then(l,l);var o=e.utils.plainCopy(t);return delete o.adapter,r.http(o).then(l,l).catch(function(e){return r.responseError(e,t,n)})}).then(function(i){return e.utils.resolve(r.afterHTTP(t,n,i)).then(function(t){return void 0===t?i:t})})},POST:function POST(t,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=t||r.url,r.data=n||r.data,r.method=r.method||"post",a=i.op="beforePOST",e.utils.resolve(this[a](t,n,r,i)).then(function(e){return r=void 0===e?r:e,a=i.op="POST",o.dbg(a,t,n,r,i),o.HTTP(r,i)}).then(function(s){return a=i.op="afterPOST",e.utils.resolve(o[a](t,n,r,i,s)).then(function(t){return void 0===t?s:t})})},PUT:function PUT(t,n,r,i){var o=this,a=void 0;return r||(r={}),i||(i={}),r.url=t||r.url,r.data=n||r.data,r.method=r.method||"put",a=i.op="beforePUT",e.utils.resolve(this[a](t,n,r,i)).then(function(e){return r=void 0===e?r:e,a=i.op="PUT",o.dbg(a,t,n,r,i),o.HTTP(r,i)}).then(function(s){return a=i.op="afterPUT",e.utils.resolve(o[a](t,n,r,i,s)).then(function(t){return void 0===t?s:t})})},queryTransform:function queryTransform(t,n,r){return r||(r={}),e.utils.isFunction(r.queryTransform)?r.queryTransform(t,n,r):e.utils.isFunction(t.queryTransform)?t.queryTransform(t,n,r):n},responseError:function responseError(t,n,r){return e.utils.reject(t)},serialize:function serialize(t,n,r){return r||(r={}),e.utils.isFunction(r.serialize)?r.serialize(t,n,r):e.utils.isFunction(t.serialize)?t.serialize(t,n,r):n},sum:function sum(t,n,r,i){if(r||(r={}),i||(i={}),!e.utils.isString(n))throw new Error("field must be a string!");return i.params=this.getParams(i),i.params.sum=n,i.suffix=this.getSuffix(t,i),e.utils.deepMixIn(i.params,r),i.params=this.queryTransform(t,i.params,i),Adapter.prototype.sum.call(this,t,n,r,i)},update:function update(t,e,n,r){return r||(r={}),r.params=this.getParams(r),r.params=this.queryTransform(t,r.params,r),r.suffix=this.getSuffix(t,r),Adapter.prototype.update.call(this,t,e,n,r)},updateAll:function updateAll(t,n,r,i){return r||(r={}),i||(i={}),i.params=this.getParams(i),e.utils.deepMixIn(i.params,r),i.params=this.queryTransform(t,i.params,i),i.suffix=this.getSuffix(t,i),Adapter.prototype.updateAll.call(this,t,n,r,i)},updateMany:function updateMany(t,e,n){return n||(n={}),n.params=this.getParams(n),n.params=this.queryTransform(t,n.params,n),n.suffix=this.getSuffix(t,n),Adapter.prototype.updateMany.call(this,t,e,n)}});var c={full:"3.0.0",major:3,minor:0,patch:0};t.HttpAdapter=HttpAdapter,t.addAction=addAction,t.addActions=function addActions(t){return t||(t={}),function(n){return e.utils.forOwn(t,function(t,e){addAction(e,t)(n)}),n}},t.version=c,Object.defineProperty(t,"__esModule",{value:!0})}); +//# sourceMappingURL=js-data-fetch.min.map \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.min.js.map b/fetch/dist/js-data-fetch.min.js.map new file mode 100644 index 0000000..d641212 --- /dev/null +++ b/fetch/dist/js-data-fetch.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["fetch/dist/js-data-fetch.js"],"names":["global","factory","exports","module","require","define","amd","JSDataHttp","JSData","this","jsData","Response","data","meta","op","utils","fillIn","Adapter","opts","classCallCheck","Component","call","DEFAULTS$1","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","isArray","forEach","v","toString","toISOString","isObject","toJson","push","indexOf","HttpAdapter","DEFAULTS","addAction","name","isString","TypeError","_typeof","mapper","Error","request","config","response","responseError","err","reject","id","_opts","_this18","adapter","getAdapter","defaultAdapter","deepMixIn","method","getEndpoint","basePath","isSorN","pathname","apply","resolve","then","HTTP","Symbol","iterator","obj","constructor","prototype","defineProperty","Object","enumerable","configurable","writable","slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","next","done","noop","dbg","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","props","with","toStrip","relationFields","omit","debug","raw","extend","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","count","query","_this","_count","results","_results","result","respond","_response","create","_this2","_props","_create","_results2","created","createMany","_this3","map","record","_createMany","_results3","destroy","_this4","_destroy","_results4","destroyAll","_this5","_destroyAll","_results5","loadBelongsTo","def","records","__opts","_this6","relationDef","getRelation","find","makeBelongsToForeignKey","relatedItem","setLocalField","keys","findAll","where","idAttribute","in","relatedItems","foreignKey","_this7","_find","loadRelationsFor","_ref","_ref2","found","_this8","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_ref3","_ref4","_this9","tasks","forEachRelation","task","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","Promise","all","getOpt","opt","plainCopy","_this10","singular","IDs","makeHasManyForeignKey","criteria","attached","get","_this11","relatedMapper","makeHasManyLocalKeys","x","itemKeys","_this12","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","sum","field","_this13","_sum","_results7","update","_this14","_update","_results8","updated","updateAll","_this15","_updateAll","_results9","updateMany","_this16","_records","_updateMany","_results10","hasFetch","window","fetch","e","forceTrailingSlash","http","httpConfig","suffix","useFetch","afterDEL","afterGET","afterHTTP","afterPOST","afterPUT","beforeDEL","beforeGET","beforeHTTP","beforePOST","beforePUT","GET","getPath","_end","POST","serialize","DEL","deserialize","PUT","getParams","getSuffix","queryTransform","_config","isFunction","hasOwnProperty","error","console","_console","_fetch","_x","requestConfig","headers","Headers","body","json","isUndefined","relationList","endpoint","parent","parentKey","parentDef","parentId","_","isNumber","copy","start","Date","payload","cache","timeout","toUpperCase","substr","logResponse","str","toUTCString","status","getTime","log","catch","_this17","version","full","major","minor","patch","addActions"],"mappings":"CAAC,SAAUA,EAAQC,GACC,iBAAZC,SAA0C,oBAAXC,OAAyBF,EAAQC,QAASE,QAAQ,YACtE,mBAAXC,QAAyBA,OAAOC,IAAMD,OAAO,iBAAkB,UAAW,WAAYJ,GAC5FA,EAASD,EAAOO,WAAaP,EAAOO,eAAkBP,EAAOQ,SAC7DC,KAAM,SAAWP,EAAQQ,GAAU,aAsJrC,SAASC,SAASC,EAAMC,EAAMC,GAC5BD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B,OAAO"} \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.min.map b/fetch/dist/js-data-fetch.min.map new file mode 100644 index 0000000..ad3e108 --- /dev/null +++ b/fetch/dist/js-data-fetch.min.map @@ -0,0 +1 @@ +{"version":3,"sources":["fetch/dist/js-data-fetch.js"],"names":["global","factory","exports","module","require","define","amd","JSDataHttp","JSData","this","jsData","Response","data","meta","op","utils","fillIn","Adapter","opts","classCallCheck","Component","call","DEFAULTS$1","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","isArray","forEach","v","toString","toISOString","isObject","toJson","push","indexOf","HttpAdapter","DEFAULTS","addAction","name","isString","TypeError","_typeof","mapper","Error","request","config","response","responseError","err","reject","id","_opts","_this18","adapter","getAdapter","defaultAdapter","deepMixIn","method","getEndpoint","basePath","isSorN","pathname","apply","resolve","then","HTTP","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","with","relationFields","toStrip","omit","debug","raw","extend","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","count","query","_this","_count","results","_results","respond","_response","create","_this2","_props","_create","_results2","created","createMany","_this3","map","record","_createMany","_results3","destroy","_this4","_destroy","_results4","destroyAll","_this5","_destroyAll","_results5","loadBelongsTo","def","records","__opts","_this6","relationDef","getRelation","keys","makeBelongsToForeignKey","findAll","where","idAttribute","in","relatedItems","relatedItem","foreignKey","setLocalField","_ret","find","_this7","_find","_results6","_record","_meta","tasks","forEachRelation","task","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","Promise","all","found","_this8","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_results7","_records","getOpt","opt","plainCopy","_this9","singular","IDs","makeHasManyForeignKey","criteria","attached","get","_this10","relatedMapper","makeHasManyLocalKeys","_ret2","x","itemKeys","_this11","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","getForeignKey","sum","field","_this12","_sum","_results8","update","_this13","_update","_results9","updated","updateAll","_this14","_updateAll","_results10","updateMany","_this15","_updateMany","_results11","axios","hasFetch","window","fetch","e","forceTrailingSlash","http","httpConfig","suffix","useFetch","afterDEL","afterGET","afterHTTP","afterPOST","afterPUT","beforeDEL","beforeGET","beforeHTTP","beforePOST","beforePUT","GET","getPath","_end","POST","serialize","DEL","deserialize","PUT","getParams","getSuffix","queryTransform","prototype","_config","isFunction","hasOwnProperty","error","console","_console","_fetch","_x","requestConfig","headers","Headers","body","json","isUndefined","relationList","endpoint","parent","parentKey","parentDef","parentId","_","isNumber","copy","start","Date","payload","cache","timeout","toUpperCase","substr","logResponse","str","toUTCString","status","getTime","log","catch","_this16","_this17","version","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,YA8GlC,SAASC,GAASC,EAAMC,EAAMC,GAC5BD,IAASA,MAQTJ,KAAKG,KAAOA,EAEZF,EAAOK,MAAMC,OAAOP,KAAMI,GAQ1BJ,KAAKK,GAAKA,EAkCZ,QAASG,GAAQC,GACfR,EAAOK,MAAMI,eAAeV,KAAMQ,GAClCP,EAAOU,UAAUC,KAAKZ,KAAMS,GAC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AMsD,EAAQuH,EAASpK,KAwKpE,IAAIiU,IACJC,KAAM,aACNC,MAAO,EACPC,MAAO,EACPC,MAAO,EAGPrV,GAAQsD,YAAcA,EACtBtD,EAAQwD,UAAYA,EACpBxD,EAAQqF,WAAaA,EACrBrF,EAAQiV,QAAUA,EAElBtP,OAAOD,eAAe1F,EAAS,cAAgBsB,OAAO","file":"fetch/dist/js-data-fetch.min.js"} \ No newline at end of file diff --git a/node/.gitignore b/node/.gitignore index 5d5e8fc..e69de29 100644 --- a/node/.gitignore +++ b/node/.gitignore @@ -1,2 +0,0 @@ -dist/*.js -dist/*.map \ No newline at end of file diff --git a/node/dist/js-data-http-node.js b/node/dist/js-data-http-node.js new file mode 100644 index 0000000..7301352 --- /dev/null +++ b/node/dist/js-data-http-node.js @@ -0,0 +1,1347 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var jsData = require('js-data'); +var jsDataAdapter = require('js-data-adapter'); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; + +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 (toString.call(v) === '[object Date]') { + v = v.toISOString(); + } else if (jsData.utils.isObject(v)) { + v = jsData.utils.toJson(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; +} + +var DEFAULTS = { + /** + * Set a base path in order to use absolute URLs instead of relative URLs. + * + * @example + * const httpAdapter = new HttpAdapter({ + * basePath: 'https://mydomain.com' + * }); + * + * @name HttpAdapter#basePath + * @type {string} + * @since 3.0.0 + */ + basePath: '', + + /** + * Ensure that the request url has a trailing forward slash. + * + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + * @since 3.0.0 + */ + forceTrailingSlash: false, + + hasFetch: hasFetch, + + /** + * The HTTP function that actually makes the HTTP request. By default this is + * `axios`. + * + * @name HttpAdapter#http + * @type {function} + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library + */ + http: axios, + + /** + * Default configuration options to be mixed into the `config` argument passed + * to {@link HttpAdapter#http}. + * + * @name HttpAdapter#httpConfig + * @type {object} + * @since 3.0.0 + */ + httpConfig: {}, + + /** + * Add a suffix to the request url, e.g. ".json". + * + * @name HttpAdapter#suffix + * @type {string} + * @since 3.0.0 + */ + suffix: '', + + /** + * Use `window.fetch` if available. + * + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + * @since 3.0.0 + * @see http://www.js-data.io/docs/js-data-http#using-windowfetch + */ + useFetch: false + + /** + * HttpAdapter class. + * + * @example + * import { DataStore } from 'js-data'; + * import { HttpAdapter } from 'js-data-http'; + * + * const httpAdapter = new HttpAdapter(); + * const store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * + * store.defineMapper('school'); + * store.defineMapper('student'); + * + * // GET /school/1 + * store.find('school', 1).then((school) => { + * console.log('school'); + * }); + * + * @class HttpAdapter + * @extends Adapter + * @param {object} [opts] Configuration options. + * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}. + * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}. + * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}. + * @param {object} [opts.http=axios] See {@link HttpAdapter#http}. + * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}. + * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}. + * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}. + * @see http://www.js-data.io/docs/js-data-http + */ +};function HttpAdapter(opts) { + jsData.utils.classCallCheck(this, HttpAdapter); + + opts || (opts = {}); + // Fill in any missing options with the defaults + jsData.utils.fillIn(opts, DEFAULTS); + jsDataAdapter.Adapter.call(this, opts); +} + +/** + * @name module:js-data-http.HttpAdapter + * @see HttpAdapter + */ + +jsDataAdapter.Adapter.extend({ + constructor: HttpAdapter, + + /** + * @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 _this = this; + + return this.GET(this.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return _this._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var _this2 = this; + + return this.POST(this.getPath('create', mapper, props, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this2._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var _this3 = this; + + return this.POST(this.getPath('createMany', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this3._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var _this4 = this; + + return this.DEL(this.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return _this4._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var _this5 = this; + + return this.DEL(this.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return _this5._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var _this6 = this; + + return this.GET(this.getPath('find', mapper, id, opts), opts).then(function (response) { + return _this6._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var _this7 = this; + + return this.GET(this.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return _this7._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var _this8 = this; + + return this.GET(this.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return _this8._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var _this9 = this; + + return this.PUT(this.getPath('update', mapper, id, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this9._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var _this10 = this; + + return this.PUT(this.getPath('updateAll', mapper, null, opts), this.serialize(mapper, props, opts), opts).then(function (response) { + return _this10._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var _this11 = this; + + return this.PUT(this.getPath('updateMany', mapper, null, opts), this.serialize(mapper, records, opts), opts).then(function (response) { + return _this11._end(mapper, opts, response); + }); + }, + + + /** + * Retrieve the number of records that match the selection `query`. + * + * @name HttpAdapter#count + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params.count = true; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return jsDataAdapter.Adapter.prototype.count.call(this, mapper, query, opts); + }, + + + /** + * Create a new the record from the provided `props`. + * + * @name HttpAdapter#create + * @method + * @param {object} mapper The mapper. + * @param {object} props Properties to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return jsDataAdapter.Adapter.prototype.create.call(this, mapper, props, opts); + }, + + + /** + * Create multiple new records in batch. + * + * @name HttpAdapter#createMany + * @method + * @param {object} mapper The mapper. + * @param {array} props Array of property objects to send as the payload. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return jsDataAdapter.Adapter.prototype.createMany.call(this, mapper, props, opts); + }, + + + /** + * Make an Http request to `url` according to the configuration in `config`. + * + * @name HttpAdapter#DEL + * @method + * @param {string} url Url for the request. + * @param {object} [config] Http configuration that will be passed to + * {@link HttpAdapter#HTTP}. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + DEL: function DEL(url, config, opts) { + var _this12 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'delete'; + + // beforeDEL lifecycle hook + op = opts.op = 'beforeDEL'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'DEL'; + _this12.dbg(op, url, config, opts); + return _this12.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return jsData.utils.resolve(_this12[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the server response object into the payload that will be returned + * to JSData. + * + * @name HttpAdapter#deserialize + * @method + * @param {object} mapper The mapper used for the operation. + * @param {object} response Response object from {@link HttpAdapter#HTTP}. + * @param {object} opts Configuration options. + * @return {(object|array)} Deserialized data. + */ + deserialize: function deserialize(mapper, response, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.deserialize)) { + return opts.deserialize(mapper, response, opts); + } + if (jsData.utils.isFunction(mapper.deserialize)) { + return mapper.deserialize(mapper, response, opts); + } + if (response && response.hasOwnProperty('data')) { + return response.data; + } + return response; + }, + + + /** + * Destroy the record with the given primary key. + * + * @name HttpAdapter#destroy + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return jsDataAdapter.Adapter.prototype.destroy.call(this, mapper, id, opts); + }, + + + /** + * Destroy the records that match the selection `query`. + * + * @name HttpAdapter#destroyAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return jsDataAdapter.Adapter.prototype.destroyAll.call(this, mapper, query, opts); + }, + + + /** + * Log an error. + * + * @name HttpAdapter#error + * @method + * @param {...*} [args] Arguments to log. + */ + error: function error() { + if (console) { + var _console; + + (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); + } + }, + + + /** + * Make an Http request using `window.fetch`. + * + * @name HttpAdapter#fetch + * @method + * @param {object} config Request configuration. + * @param {object} config.data Payload for the request. + * @param {string} config.method Http method for the request. + * @param {object} config.headers Headers for the request. + * @param {object} config.params Querystring for the request. + * @param {string} config.url Url for the request. + */ + fetch: function (_fetch) { + function fetch(_x) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config) { + var requestConfig = { + method: config.method, + // turn the plain headers object into the Fetch Headers object + headers: new Headers(config.headers || {}) + }; + + if (config.data) { + requestConfig.body = jsData.utils.toJson(config.data); + } + + return fetch(buildUrl(config.url, config.params), requestConfig).then(function (response) { + response.config = { + method: config.method, + url: config.url + }; + return response.json().then(function (data) { + response.data = data; + return response; + }); + }); + }), + + + /** + * Retrieve the record with the given primary key. + * + * @name HttpAdapter#find + * @method + * @param {object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return jsDataAdapter.Adapter.prototype.find.call(this, mapper, id, opts); + }, + + + /** + * Retrieve the records that match the selection `query`. + * + * @name HttpAdapter#findAll + * @method + * @param {object} mapper The mapper. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return jsDataAdapter.Adapter.prototype.findAll.call(this, mapper, query, opts); + }, + + + /** + * Make a GET request. + * + * @name HttpAdapter#GET + * @method + * @param {string} url The url for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + GET: function GET(url, config, opts) { + var _this13 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'get'; + + // beforeGET lifecycle hook + op = opts.op = 'beforeGET'; + return jsData.utils.resolve(this[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'GET'; + _this13.dbg(op, url, config, opts); + return _this13.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return jsData.utils.resolve(_this13[op](url, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {object} mapper The Mapper. + * @param {*} id The primary key, if any. + * @param {boolean} opts Configuration options. + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var _this14 = this; + + opts || (opts = {}); + opts.params = jsData.utils.isUndefined(opts.params) ? {} : opts.params; + var relationList = mapper.relationList || []; + var endpoint = jsData.utils.isUndefined(opts.endpoint) ? jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; + + relationList.forEach(function (def) { + if (def.type !== 'belongsTo' || !def.parent) { + return; + } + var item = void 0; + var parentKey = def.foreignKey; + var parentDef = def.getRelation(); + var parentId = opts.params[parentKey]; + + if (parentId === false || !parentKey || !parentDef) { + if (parentId === false) { + delete opts.params[parentKey]; + } + return false; + } else { + delete opts.params[parentKey]; + + if (jsData.utils.isObject(id)) { + item = id; + } + + if (item) { + parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); + } + + if (parentId) { + delete opts.endpoint; + var _opts = {}; + jsData.utils.forOwn(opts, function (value, key) { + _opts[key] = value; + }); + jsData.utils._(_opts, parentDef); + endpoint = makePath(_this14.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return false; + } + } + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method The method being executed. + * @param {object} mapper The Mapper. + * @param {(string|number)?} id The primary key, if any. + * @param {object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + opts || (opts = {}); + var args = [opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, this.getEndpoint(mapper, jsData.utils.isString(id) || jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; + if (method === 'find' || method === 'update' || method === 'destroy') { + args.push(id); + } + return makePath.apply(jsData.utils, args); + }, + getParams: function getParams(opts) { + opts || (opts = {}); + if (opts.params === undefined) { + return {}; + } + return jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (opts.suffix === undefined) { + if (mapper.suffix === undefined) { + return this.suffix; + } + return mapper.suffix; + } + return opts.suffix; + }, + + + /** + * Make an Http request. + * + * @name HttpAdapter#HTTP + * @method + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + HTTP: function HTTP(config, opts) { + var _this15 = this; + + var start = new Date(); + opts || (opts = {}); + var payload = config.data; + var cache = config.cache; + var timeout = config.timeout; + config = jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); + config = jsData.utils.deepMixIn(config, this.httpConfig); + config.data = payload; + config.cache = cache; + if (timeout !== undefined) { + config.timeout = timeout; + } + if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || this.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + var logResponse = function logResponse(data) { + var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; + if (data.status >= 200 && data.status < 300) { + if (_this15.log) { + _this15.dbg(str, data); + } + return data; + } else { + if (_this15.error) { + _this15.error('\'FAILED: ' + str, data); + } + return jsData.utils.reject(data); + } + }; + + if (!this.http) { + if (this.useFetch || opts.useFetch) { + if (!hasFetch) { + throw new Error('Attempting to use window.fetch, but it is not available!'); + } + } else { + throw new Error('You have not configured this adapter with an http library!'); + } + } + + return jsData.utils.resolve(this.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (_this15.useFetch || opts.useFetch || !_this15.http)) { + return _this15.fetch(config, opts).then(logResponse, logResponse); + } + var httpConfig = jsData.utils.plainCopy(config); + delete httpConfig.adapter; + return _this15.http(httpConfig).then(logResponse, logResponse).catch(function (err) { + return _this15.responseError(err, config, opts); + }); + }).then(function (response) { + return jsData.utils.resolve(_this15.afterHTTP(config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Make a POST request. + * + * @name HttpAdapter#POST + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var _this16 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'post'; + + // beforePOST lifecycle hook + op = opts.op = 'beforePOST'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'POST'; + _this16.dbg(op, url, data, config, opts); + return _this16.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return jsData.utils.resolve(_this16[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Make a PUT request. + * + * @name HttpAdapter#PUT + * @method + * @param {*} url The url for the request. + * @param {object} data Payload for the request. + * @param {object} config Request configuration options. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var _this17 = this; + + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'put'; + + // beforePUT lifecycle hook + op = opts.op = 'beforePUT'; + return jsData.utils.resolve(this[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _config === undefined ? config : _config; + op = opts.op = 'PUT'; + _this17.dbg(op, url, data, config, opts); + return _this17.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return jsData.utils.resolve(_this17[op](url, data, config, opts, response)).then(function (_response) { + return _response === undefined ? response : _response; + }); + }); + }, + + + /** + * Transform the querystring object before it is serialized. This doesn't do + * anything by default. + * + * @name HttpAdapter#queryTransform + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {*} params The querystring object. + * @param {*} opts Configuration options + * @return {*} Transformed params. + */ + queryTransform: function queryTransform(mapper, params, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts); + } + if (jsData.utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts); + } + return params; + }, + + + /** + * Error handler invoked when the promise returned by {@link HttpAdapter#http} + * is rejected. Default implementation is to just return the error wrapped in + * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is + * called by {@link HttpAdapter#HTTP}. + * + * @name HttpAdapter#responseError + * @method + * @param {*} err The error that {@link HttpAdapter#http} rejected with. + * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. + * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. + * @return {Promise} + */ + responseError: function responseError(err, config, opts) { + return jsData.utils.reject(err); + }, + + + /** + * Serialize request data. This doesn't do anything by default. + * + * @name HttpAdapter#serialize + * @method + * @param {object} mapper The Mapper that triggered the request. + * @param {object} data The request payload. + * @param {*} opts Configuration options. + * @return {*} Serialized data. + */ + serialize: function serialize(mapper, data, opts) { + opts || (opts = {}); + if (jsData.utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts); + } + if (jsData.utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts); + } + return data; + }, + + + /** + * Retrieve the sum of the field of the records that match the selection query. + * + * @name HttpAdapter#sum + * @method + * @param {object} mapper The mapper. + * @param {string} field The field to sum. + * @param {object} query Selection query. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + query || (query = {}); + opts || (opts = {}); + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = this.getParams(opts); + opts.params.sum = field; + opts.suffix = this.getSuffix(mapper, opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + return jsDataAdapter.Adapter.prototype.sum.call(this, mapper, field, query, opts); + }, + + + /** + * Perform an update. Makes a PUT request by default. + * + * @name HttpAdapter#update + * @method + * @param {object} mapper The Mapper for the request. + * @param {*} id The primary key of the record being updated. + * @param {*} props The update payload. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return jsDataAdapter.Adapter.prototype.update.call(this, mapper, id, props, opts); + }, + + + /** + * Perform an update against records that match the selection query. Makes a + * PUT request by default. + * + * @name HttpAdapter#updateAll + * @method + * @param {object} mapper The Mapper for the request. + * @param {object} props The update payload. + * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}. + * @param {object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + query || (query = {}); + opts || (opts = {}); + opts.params = this.getParams(opts); + jsData.utils.deepMixIn(opts.params, query); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return jsDataAdapter.Adapter.prototype.updateAll.call(this, mapper, props, query, opts); + }, + + + /** + * Update multiple individual records in a batch. + * + * @name HttpAdapter#updateMany + * @method + * @param {object} mapper The Mapper for the request. + * @param {array} records Array of property objects to send as the payload. + * Each must contain the primary key of the record to be updated. + * @param {object} [opts] Configuration options. + * @param {string} [opts.params] Querystring parameters. + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + opts || (opts = {}); + opts.params = this.getParams(opts); + opts.params = this.queryTransform(mapper, opts.params, opts); + opts.suffix = this.getSuffix(mapper, opts); + return jsDataAdapter.Adapter.prototype.updateMany.call(this, mapper, records, opts); + } +}); + +/** + * Add an Http actions to a mapper. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addAction = JSDataHttp.addAction; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * // GET /reports/schools/:school_id/teachers + * addAction('getTeacherReports', { + * endpoint: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addAction + * @method + * @param {string} name Name of the new action. + * @param {object} [opts] Action configuration + * @param {string} [opts.adapter="http"] The name of the adapter to use. + * @param {string} [opts.pathname] Set the action's pathname. + * @param {function} [opts.request] Specify a request handler to be executed + * before the request is made. + * @param {function} [opts.response] Specify a response handler to be executed + * after the response is received. + * @param {function} [opts.responseError] Specify an error handler to be + * executed on error. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addAction(name, opts) { + if (!name || !jsData.utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + } + return function (mapper) { + if (mapper[name]) { + throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); + } + opts.request = opts.request || function (config) { + return config; + }; + opts.response = opts.response || function (response) { + return response; + }; + opts.responseError = opts.responseError || function (err) { + return jsData.utils.reject(err); + }; + mapper[name] = function (id, _opts) { + var _this18 = this; + + _opts = _opts || {}; + if (jsData.utils.isObject(id)) { + _opts = id; + } + jsData.utils.fillIn(_opts, opts); + var adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http'); + var config = {}; + config.mapper = this.name; + jsData.utils.deepMixIn(config, _opts); + config.method = config.method || 'GET'; + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(this, _opts); + } else { + var args = [_opts.basePath || this.basePath || adapter.basePath, adapter.getEndpoint(this, id, _opts)]; + if (jsData.utils.isSorN(id)) { + args.push(id); + } + args.push(opts.pathname || name); + config.url = makePath.apply(null, args); + } + return jsData.utils.resolve(config).then(_opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = _this18.name; + } + return data; + }).then(_opts.response, _opts.responseError); + }; + return mapper; + }; +} + +/** + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. + * + * @example + * // CommonJS + * var JSData = require('js-data'); + * // It is recommended to use DataStore in the browser + * var DataStore = JSData.DataStore; + * + * var JSDataHttp = require('js-data-http'); + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var addActions = JSDataHttp.addActions; + * + * var httpAdapter = new HttpAdapter(); + * var store = new DataStore(); + * + * store.registerAdapter('http', httpAdapter, { 'default': true }); + * store.defineMapper('school'); + * + * addActions({ + * // GET /reports/schools/:school_id/teachers + * getTeacherReports: { + * basePath: 'reports/schools', + * pathname: 'teachers', + * method: 'GET' + * } + * })(store.getMapper('school')); + * + * // /reports/schools/1234/teachers + * store.getMapper('school').getTeacherReports(1234).then((response) => { + * // ... + * }); + * + * @name module:js-data-http.addActions + * @method + * @param {object.} opts Object where the key is an action name + * and the value is the configuration for the action. + * @return {function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +function addActions(opts) { + opts || (opts = {}); + return function (mapper) { + jsData.utils.forOwn(opts, function (value, key) { + addAction(key, value)(mapper); + }); + return mapper; + }; +} + +/** + * Details of the current version of the `js-data-http` module. + * + * @name module:js-data-http.version + * @type {object} + * @property {string} version.full The full semver value. + * @property {number} version.major The major version number. + * @property {number} version.minor The minor version number. + * @property {number} version.patch The patch version number. + * @property {(string|boolean)} version.alpha The alpha version value, + * otherwise `false` if the current version is not alpha. + * @property {(string|boolean)} version.beta The beta version value, + * otherwise `false` if the current version is not beta. + */ +var version = { + full: '3.0.0', + major: 3, + minor: 0, + patch: 0 +}; + +/** + * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http` + * that works on Node.js is registered in NPM as `js-data-http-node`. The build + * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower + * as `js-data-fetch`. + * + * @example Script tag + * var HttpAdapter = window.JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example CommonJS + * var HttpAdapter = require('js-data-Http').HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * @example ES2015 Modules + * import { HttpAdapter } from 'js-data-Http'; + * const httpAdapter = new HttpAdapter(); + * + * @example AMD + * define('myApp', ['js-data-Http'], function (JSDataHttp) { + * var HttpAdapter = JSDataHttp.HttpAdapter; + * var httpAdapter = new HttpAdapter(); + * + * // ... + * }); + * + * @module js-data-http + */ + +/** + * Create a subclass of this HttpAdapter: + * @example HttpAdapter.extend + * // Normally you would do: import { HttpAdapter } from 'js-data-http'; + * // or: import { HttpAdapter } from 'js-data-http-node'; + * const JSDataHttp = require('js-data-http-node'); + * const { HttpAdapter } = JSDataHttp; + * console.log('Using JSDataHttp v' + JSDataHttp.version.full); + * + * // Extend the class using ES2015 class syntax. + * class CustomHttpAdapterClass extends HttpAdapter { + * foo () { return 'bar'; } + * static beep () { return 'boop'; } + * } + * const customHttpAdapter = new CustomHttpAdapterClass(); + * console.log(customHttpAdapter.foo()); + * console.log(CustomHttpAdapterClass.beep()); + * + * // Extend the class using alternate method. + * const OtherHttpAdapterClass = HttpAdapter.extend({ + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const otherHttpAdapter = new OtherHttpAdapterClass(); + * console.log(otherHttpAdapter.foo()); + * console.log(OtherHttpAdapterClass.beep()); + * + * // Extend the class, providing a custom constructor. + * function AnotherHttpAdapterClass () { + * HttpAdapter.call(this); + * this.created_at = new Date().getTime(); + * } + * HttpAdapter.extend({ + * constructor: AnotherHttpAdapterClass, + * foo () { return 'bar'; } + * }, { + * beep () { return 'boop'; } + * }) + * const anotherHttpAdapter = new AnotherHttpAdapterClass(); + * console.log(anotherHttpAdapter.created_at); + * console.log(anotherHttpAdapter.foo()); + * console.log(AnotherHttpAdapterClass.beep()); + * + * @method HttpAdapter.extend + * @param {object} [props={}] Properties to add to the prototype of the + * subclass. + * @param {object} [props.constructor] Provide a custom constructor function + * to be used as the subclass itself. + * @param {object} [classProps={}] Static properties to add to the subclass. + * @returns {Constructor} Subclass of this HttpAdapter class. + * @since 3.0.0 + */ + +exports.HttpAdapter = HttpAdapter; +exports.addAction = addAction; +exports.addActions = addActions; +exports.version = version; +//# sourceMappingURL=js-data-http-node.js.map diff --git a/node/dist/js-data-http-node.js.map b/node/dist/js-data-http-node.js.map new file mode 100644 index 0000000..c35dc19 --- /dev/null +++ b/node/dist/js-data-http-node.js.map @@ -0,0 +1 @@ +{"version":3,"file":"js-data-http-node.js","sources":["../../src/index.js"],"sourcesContent":["import { utils } from 'js-data'\nimport axios from '../node_modules/axios/dist/axios'\nimport {\n Adapter,\n noop,\n noop2\n} from '../node_modules/js-data-adapter/src/index'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst DEFAULTS = {\n /**\n * Set a base path in order to use absolute URLs instead of relative URLs.\n *\n * @example\n * const httpAdapter = new HttpAdapter({\n * basePath: 'https://mydomain.com'\n * });\n *\n * @name HttpAdapter#basePath\n * @type {string}\n * @since 3.0.0\n */\n basePath: '',\n\n /**\n * Ensure that the request url has a trailing forward slash.\n *\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n forceTrailingSlash: false,\n\n hasFetch: hasFetch,\n\n /**\n * The HTTP function that actually makes the HTTP request. By default this is\n * `axios`.\n *\n * @name HttpAdapter#http\n * @type {function}\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-a-custom-http-library\n */\n http: axios,\n\n /**\n * Default configuration options to be mixed into the `config` argument passed\n * to {@link HttpAdapter#http}.\n *\n * @name HttpAdapter#httpConfig\n * @type {object}\n * @since 3.0.0\n */\n httpConfig: {},\n\n /**\n * Add a suffix to the request url, e.g. \".json\".\n *\n * @name HttpAdapter#suffix\n * @type {string}\n * @since 3.0.0\n */\n suffix: '',\n\n /**\n * Use `window.fetch` if available.\n *\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n * @since 3.0.0\n * @see http://www.js-data.io/docs/js-data-http#using-windowfetch\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @example\n * import { DataStore } from 'js-data';\n * import { HttpAdapter } from 'js-data-http';\n *\n * const httpAdapter = new HttpAdapter();\n * const store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n *\n * store.defineMapper('school');\n * store.defineMapper('student');\n *\n * // GET /school/1\n * store.find('school', 1).then((school) => {\n * console.log('school');\n * });\n *\n * @class HttpAdapter\n * @extends Adapter\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link HttpAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link HttpAdapter#debug}.\n * @param {boolean} [opts.forceTrailingSlash=false] See {@link HttpAdapter#forceTrailingSlash}.\n * @param {object} [opts.http=axios] See {@link HttpAdapter#http}.\n * @param {object} [opts.httpConfig={}] See {@link HttpAdapter#httpConfig}.\n * @param {string} [opts.suffix=''] See {@link HttpAdapter#suffix}.\n * @param {boolean} [opts.useFetch=false] See {@link HttpAdapter#useFetch}.\n * @see http://www.js-data.io/docs/js-data-http\n */\nexport function HttpAdapter (opts) {\n utils.classCallCheck(this, HttpAdapter)\n\n opts || (opts = {})\n // Fill in any missing options with the defaults\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(this, opts)\n}\n\n/**\n * @name module:js-data-http.HttpAdapter\n * @see HttpAdapter\n */\n\nAdapter.extend({\n constructor: HttpAdapter,\n\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n * @param {object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {object} url\n * @param {object} config\n * @param {object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {object} config\n * @param {object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {object} url\n * @param {object} data\n * @param {object} config\n * @param {object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n return this.GET(\n this.getPath('count', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _create (mapper, props, opts) {\n return this.POST(\n this.getPath('create', mapper, props, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _createMany (mapper, props, opts) {\n return this.POST(\n this.getPath('createMany', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroy (mapper, id, opts) {\n return this.DEL(\n this.getPath('destroy', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _destroyAll (mapper, query, opts) {\n return this.DEL(\n this.getPath('destroyAll', mapper, null, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n return this.GET(\n this.getPath('find', mapper, id, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _findAll (mapper, query, opts) {\n return this.GET(\n this.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _sum (mapper, field, query, opts) {\n return this.GET(\n this.getPath('sum', mapper, opts.params, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _update (mapper, id, props, opts) {\n return this.PUT(\n this.getPath('update', mapper, id, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateAll (mapper, props, query, opts) {\n return this.PUT(\n this.getPath('updateAll', mapper, null, opts),\n this.serialize(mapper, props, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n _updateMany (mapper, records, opts) {\n return this.PUT(\n this.getPath('updateMany', mapper, null, opts),\n this.serialize(mapper, records, opts),\n opts\n ).then((response) => this._end(mapper, opts, response))\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params.count = true\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.count.call(this, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {object} mapper The mapper.\n * @param {object} props Properties to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.create.call(this, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {object} mapper The mapper.\n * @param {array} props Array of property objects to send as the payload.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.createMany.call(this, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'DEL'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {object} mapper The mapper used for the operation.\n * @param {object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {object} opts Configuration options.\n * @return {(object|array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroy.call(this, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.destroyAll.call(this, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {object} config Request configuration.\n * @param {object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {object} config.headers Headers for the request.\n * @param {object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n */\n fetch (config) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers || {})\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(buildUrl(config.url, config.params), requestConfig)\n .then((response) => {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json()\n .then((data) => {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.find.call(this, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {object} mapper The mapper.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.findAll.call(this, mapper, query, opts)\n },\n\n /**\n * Make a GET request.\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(this[op](url, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'GET'\n this.dbg(op, url, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(this[op](url, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {object} mapper The Mapper.\n * @param {*} id The primary key, if any.\n * @param {boolean} opts Configuration options.\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach((def) => {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, (value, key) => {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(this.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method The method being executed.\n * @param {object} mapper The Mapper.\n * @param {(string|number)?} id The primary key, if any.\n * @param {object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n opts || (opts = {})\n const args = [\n opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath,\n this.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (opts.params === undefined) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (opts.suffix === undefined) {\n if (mapper.suffix === undefined) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, this.httpConfig)\n config.data = payload\n config.cache = cache\n if (timeout !== undefined) {\n config.timeout = timeout\n }\n if (this.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || this.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n const logResponse = (data) => {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (this.log) {\n this.dbg(str, data)\n }\n return data\n } else {\n if (this.error) {\n this.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!this.http) {\n if ((this.useFetch || opts.useFetch)) {\n if (!hasFetch) {\n throw new Error('Attempting to use window.fetch, but it is not available!')\n }\n } else {\n throw new Error('You have not configured this adapter with an http library!')\n }\n }\n\n return utils.resolve(this.beforeHTTP(config, opts))\n .then((_config) => {\n config = _config || config\n if (hasFetch && (this.useFetch || opts.useFetch || !this.http)) {\n return this.fetch(config, opts).then(logResponse, logResponse)\n }\n const httpConfig = utils.plainCopy(config)\n delete httpConfig.adapter\n return this.http(httpConfig).then(logResponse, logResponse)\n .catch((err) => this.responseError(err, config, opts))\n })\n .then((response) => {\n return utils.resolve(this.afterHTTP(config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a POST request.\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'POST'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Make a PUT request.\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url The url for the request.\n * @param {object} data Payload for the request.\n * @param {object} config Request configuration options.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(this[op](url, data, config, opts))\n .then((_config) => {\n // Allow re-assignment from lifecycle hook\n config = _config === undefined ? config : _config\n op = opts.op = 'PUT'\n this.dbg(op, url, data, config, opts)\n return this.HTTP(config, opts)\n })\n .then((response) => {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(this[op](url, data, config, opts, response))\n .then((_response) => _response === undefined ? response : _response)\n })\n },\n\n /**\n * Transform the querystring object before it is serialized. This doesn't do\n * anything by default.\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {*} params The querystring object.\n * @param {*} opts Configuration options\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * Serialize request data. This doesn't do anything by default.\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {object} mapper The Mapper that triggered the request.\n * @param {object} data The request payload.\n * @param {*} opts Configuration options.\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {object} query Selection query.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n query || (query = {})\n opts || (opts = {})\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = this.getParams(opts)\n opts.params.sum = field\n opts.suffix = this.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n return Adapter.prototype.sum.call(this, mapper, field, query, opts)\n },\n\n /**\n * Perform an update. Makes a PUT request by default.\n *\n * @name HttpAdapter#update\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {*} id The primary key of the record being updated.\n * @param {*} props The update payload.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.update.call(this, mapper, id, props, opts)\n },\n\n /**\n * Perform an update against records that match the selection query. Makes a\n * PUT request by default.\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {object} props The update payload.\n * @param {object} query The selection query. See {@link http://www.js-data.io/docs/query-syntax}.\n * @param {object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n query || (query = {})\n opts || (opts = {})\n opts.params = this.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateAll.call(this, mapper, props, query, opts)\n },\n\n /**\n * Update multiple individual records in a batch.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {object} mapper The Mapper for the request.\n * @param {array} records Array of property objects to send as the payload.\n * Each must contain the primary key of the record to be updated.\n * @param {object} [opts] Configuration options.\n * @param {string} [opts.params] Querystring parameters.\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] See {@link HttpAdapter#suffix}.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n opts || (opts = {})\n opts.params = this.getParams(opts)\n opts.params = this.queryTransform(mapper, opts.params, opts)\n opts.suffix = this.getSuffix(mapper, opts)\n return Adapter.prototype.updateMany.call(this, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addAction = JSDataHttp.addAction;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * // GET /reports/schools/:school_id/teachers\n * addAction('getTeacherReports', {\n * endpoint: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {object} [opts] Action configuration\n * @param {string} [opts.adapter=\"http\"] The name of the adapter to use.\n * @param {string} [opts.pathname] Set the action's pathname.\n * @param {function} [opts.request] Specify a request handler to be executed\n * before the request is made.\n * @param {function} [opts.response] Specify a response handler to be executed\n * after the response is received.\n * @param {function} [opts.responseError] Specify an error handler to be\n * executed on error.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addAction (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n _opts = _opts || {}\n if (utils.isObject(id)) {\n _opts = id\n }\n utils.fillIn(_opts, opts)\n let adapter = this.getAdapter(_opts.adapter || this.defaultAdapter || 'http')\n const config = {}\n config.mapper = this.name\n utils.deepMixIn(config, _opts)\n config.method = config.method || 'GET'\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(this, _opts)\n } else {\n let args = [\n _opts.basePath || this.basePath || adapter.basePath,\n adapter.getEndpoint(this, id, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n return utils.resolve(config)\n .then(_opts.request)\n .then((config) => adapter.HTTP(config))\n .then((data) => {\n if (data && data.config) {\n data.config.mapper = this.name\n }\n return data\n })\n .then(_opts.response, _opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @example\n * // CommonJS\n * var JSData = require('js-data');\n * // It is recommended to use DataStore in the browser\n * var DataStore = JSData.DataStore;\n *\n * var JSDataHttp = require('js-data-http');\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var addActions = JSDataHttp.addActions;\n *\n * var httpAdapter = new HttpAdapter();\n * var store = new DataStore();\n *\n * store.registerAdapter('http', httpAdapter, { 'default': true });\n * store.defineMapper('school');\n *\n * addActions({\n * // GET /reports/schools/:school_id/teachers\n * getTeacherReports: {\n * basePath: 'reports/schools',\n * pathname: 'teachers',\n * method: 'GET'\n * }\n * })(store.getMapper('school'));\n *\n * // /reports/schools/1234/teachers\n * store.getMapper('school').getTeacherReports(1234).then((response) => {\n * // ...\n * });\n *\n * @name module:js-data-http.addActions\n * @method\n * @param {object.} opts Object where the key is an action name\n * and the value is the configuration for the action.\n * @return {function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nexport function addActions (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(opts, function (value, key) {\n addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name module:js-data-http.version\n * @type {object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http`\n * that works on Node.js is registered in NPM as `js-data-http-node`. The build\n * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower\n * as `js-data-fetch`.\n *\n * @example Script tag\n * var HttpAdapter = window.JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example CommonJS\n * var HttpAdapter = require('js-data-Http').HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * @example ES2015 Modules\n * import { HttpAdapter } from 'js-data-Http';\n * const httpAdapter = new HttpAdapter();\n *\n * @example AMD\n * define('myApp', ['js-data-Http'], function (JSDataHttp) {\n * var HttpAdapter = JSDataHttp.HttpAdapter;\n * var httpAdapter = new HttpAdapter();\n *\n * // ...\n * });\n *\n * @module js-data-http\n */\n\n/**\n * Create a subclass of this HttpAdapter:\n * @example HttpAdapter.extend\n * // Normally you would do: import { HttpAdapter } from 'js-data-http';\n * // or: import { HttpAdapter } from 'js-data-http-node';\n * const JSDataHttp = require('js-data-http-node');\n * const { HttpAdapter } = JSDataHttp;\n * console.log('Using JSDataHttp v' + JSDataHttp.version.full);\n *\n * // Extend the class using ES2015 class syntax.\n * class CustomHttpAdapterClass extends HttpAdapter {\n * foo () { return 'bar'; }\n * static beep () { return 'boop'; }\n * }\n * const customHttpAdapter = new CustomHttpAdapterClass();\n * console.log(customHttpAdapter.foo());\n * console.log(CustomHttpAdapterClass.beep());\n *\n * // Extend the class using alternate method.\n * const OtherHttpAdapterClass = HttpAdapter.extend({\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const otherHttpAdapter = new OtherHttpAdapterClass();\n * console.log(otherHttpAdapter.foo());\n * console.log(OtherHttpAdapterClass.beep());\n *\n * // Extend the class, providing a custom constructor.\n * function AnotherHttpAdapterClass () {\n * HttpAdapter.call(this);\n * this.created_at = new Date().getTime();\n * }\n * HttpAdapter.extend({\n * constructor: AnotherHttpAdapterClass,\n * foo () { return 'bar'; }\n * }, {\n * beep () { return 'boop'; }\n * })\n * const anotherHttpAdapter = new AnotherHttpAdapterClass();\n * console.log(anotherHttpAdapter.created_at);\n * console.log(anotherHttpAdapter.foo());\n * console.log(AnotherHttpAdapterClass.beep());\n *\n * @method HttpAdapter.extend\n * @param {object} [props={}] Properties to add to the prototype of the\n * subclass.\n * @param {object} [props.constructor] Provide a custom constructor function\n * to be used as the subclass itself.\n * @param {object} [classProps={}] Static properties to add to the subclass.\n * @returns {Constructor} Subclass of this HttpAdapter class.\n * @since 3.0.0\n */\n"],"names":["hasFetch","window","fetch","e","isValidString","value","join","items","separator","filter","makePath","args","result","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","forOwn","key","utils","isArray","forEach","v","toString","call","toISOString","isObject","toJson","push","length","indexOf","DEFAULTS","axios","HttpAdapter","opts","classCallCheck","fillIn","Adapter","extend","noop2","noop","mapper","query","GET","getPath","then","response","_end","props","POST","serialize","id","DEL","deserialize","field","PUT","records","getParams","count","suffix","getSuffix","deepMixIn","queryTransform","prototype","create","createMany","config","op","method","resolve","_config","undefined","dbg","HTTP","_response","isFunction","hasOwnProperty","data","destroy","destroyAll","console","error","requestConfig","Headers","headers","body","json","find","findAll","isUndefined","relationList","endpoint","name","def","type","parent","item","parentKey","foreignKey","parentDef","getRelation","parentId","getForeignKey","getLocalField","get","idAttribute","_opts","_","getEndpoint","basePath","isString","isNumber","apply","copy","start","Date","payload","cache","timeout","httpConfig","forceTrailingSlash","toUpperCase","substr","logResponse","str","toUTCString","status","getTime","log","reject","http","useFetch","Error","beforeHTTP","plainCopy","adapter","catch","err","responseError","afterHTTP","sum","update","updateAll","updateMany","addAction","TypeError","request","getAdapter","defaultAdapter","isSorN","pathname","addActions","version"],"mappings":";;;;;;;;;;;;;AACA,4BAAA;AACA,AAMA,IAAIA,WAAW,KAAf;;AAEA,IAAI;aACSC,UAAUA,OAAOC,KAA5B;CADF,CAEE,OAAOC,CAAP,EAAU;;AAEZ,SAASC,aAAT,CAAwBC,KAAxB,EAA+B;SACrBA,SAAS,IAAT,IAAiBA,UAAU,EAAnC;;AAEF,SAASC,IAAT,CAAeC,KAAf,EAAsBC,SAAtB,EAAiC;gBACjBA,YAAY,EAA1B;SACOD,MAAME,MAAN,CAAaL,aAAb,EAA4BE,IAA5B,CAAiCE,SAAjC,CAAP;;AAEF,SAASE,QAAT,GAA4B;oCAANC,IAAM;QAAA;;;MACtBC,SAASN,KAAKK,IAAL,EAAW,GAAX,CAAb;SACOC,OAAOC,OAAP,CAAe,kBAAf,EAAmC,KAAnC,CAAP;;;AAGF,SAASC,MAAT,CAAiBC,GAAjB,EAAsB;SACbC,mBAAmBD,GAAnB,EACJF,OADI,CACI,OADJ,EACa,GADb,EAEJA,OAFI,CAEI,OAFJ,EAEa,GAFb,EAGJA,OAHI,CAGI,MAHJ,EAGY,GAHZ,EAIJA,OAJI,CAII,OAJJ,EAIa,GAJb,EAKJA,OALI,CAKI,MALJ,EAKY,GALZ,EAMJA,OANI,CAMI,OANJ,EAMa,GANb,EAOJA,OAPI,CAOI,OAPJ,EAOa,GAPb,CAAP;;;AAUF,SAASI,QAAT,CAAmBC,GAAnB,EAAwBC,MAAxB,EAAgC;MAC1B,CAACA,MAAL,EAAa;WACJD,GAAP;;;MAGIE,QAAQ,EAAd;;eAEMC,MAAN,CAAaF,MAAb,EAAqB,UAAUJ,GAAV,EAAeO,GAAf,EAAoB;QACnCP,QAAQ,IAAR,IAAgB,OAAOA,GAAP,KAAe,WAAnC,EAAgD;;;QAG5C,CAACQ,a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