diff --git a/.bowerrc b/.bowerrc deleted file mode 100644 index baa91a3..0000000 --- a/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "bower_components" -} \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 2ce62e8..56d48b8 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,7 +1,7 @@ -(delete this line) GitHub Issues are NOT for support questions. -(delete this line) GitHub Issues ARE for bug reports, feature requests, and other issues. +(delete this line) GitHub Issues are not for support questions. +(delete this line) GitHub Issues are for bug reports, feature requests, and other issues. (delete this line) Find out how to Get Support here: http://js-data.io/docs/support. - + Thanks! diff --git a/.gitignore b/.gitignore index 94442af..33745c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -node_modules/ bower_components/ .idea/ @@ -6,4 +5,8 @@ bower_components/ *.iml coverage/ -junit/ \ No newline at end of file +junit/ +doc/ +node_modules/ +*.log +typings \ No newline at end of file diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 8d96fc1..0000000 --- a/.npmignore +++ /dev/null @@ -1,36 +0,0 @@ -lib-cov -*.seed -*.log -*.csv -*.dat -*.out -*.pid -*.gz - -pids -logs -results - -npm-debug.log -node_modules - -junit/ -coverage/ -doc/ -bower_components/ - -*.iml -.idea/ - -*.png -CONTRIBUTING.md -favicon.ico -circle.yml -bower.json -.bowerrc -Gruntfile.js -*.start.js -karma.conf.js -test/ -lib/ -src/ diff --git a/AUTHORS b/AUTHORS index 9fe6289..050e11f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,10 +1,10 @@ # This is the official list of js-data-http project authors. # -# This file is controlled by scripts/authors.js -# # Names are formatted as: -# # commits Name or Organization +# Name or Organization +# # The email address is not required for organizations. +# InternalFX Ivan Voznyakovsky Jason Dobry diff --git a/CHANGELOG.md b/CHANGELOG.md index db442b3..4c07f8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,41 @@ +##### 3.0.0-beta.3 - 28 April 2016 + +###### Breaking changes +- js-data-http.js no longer exports a default module, you must now do: + - `import {HttpAdapter} from 'js-data-http' + - `var HttpAdapter = require('js-data-http').HttpAdapter + - `var adapter = new window.JSDataHttp.HttpAdapter()` + - `define(['js-data-http'], function (JSDataHttp) { var adapter = new window.JSDataHttp.HttpAdapter(); }) + +###### Backwards compatible changes +- Added `typings` field to `package.json` +- Added `typings.json` +- Added `dist/js-data-http.d.ts` + +##### 3.0.0-beta.2 - 17 April 2016 + +Official v3 beta release + +###### Other +- Upgraded some devDependencies + +##### 3.0.0-alpha.10 - 02 April 2016 + +###### Backwards compatible bug fixes +- Fixed double deserialization of data in some cases + +##### 3.0.0-alpha.9 - 18 March 2016 + +###### Backwards compatible API changes +- Added sum and count methods + +###### Other +- Cleaned up some things + +##### 3.0.0-alpha.8 - 17 March 2016 + +- Rebased master + ##### 2.2.1 - 17 March 2016 ###### Backwards compatible bug fixes @@ -6,6 +44,20 @@ - #46 - Sending large payloads takes huge amount of time - thanks @ivanvoznyakovsky - #47 - perf(http): speed up preparation of http config with large payload - thanks @ivanvoznyakovsky +##### 3.0.0-alpha.7 - 10 March 2016 + +###### Other +- Now using js-data-repo-tools +- Now using js-data-adapter + +##### 3.0.0-alpha.6 - 23 February 2016 + +- getEndpoint now works with multiple parents + +##### 3.0.0-alpha.5 - 23 February 2016 + +- Rebased master + ##### 2.2.0 - 23 February 2016 ###### Backwards compatible API changes @@ -16,8 +68,48 @@ - Added AUTHORS and CONTRIBUTORS files - Updated Readme +##### 3.0.0-alpha.4 - 12 February 2016 + +###### Backwards compatible API changes +- Better debugging/logging +- Updates for the newest js-data alpha + +##### 3.0.0-alpha.3 - 10 January 2016 + +###### Backwards compatible API changes +- Added updateMany, createMany, and responseError methods. + +##### 3.0.0-alpha.2 - 09 January 2016 + +###### Breaking API changes +- All options that could be found at `DSHttpAdapter#defaults` will now be on +the actual instances of `DSHttpAdapter`. e.g. `DSHttpAdapter#defaults.deserialize` +is now at `DSHttpAdapter#deserialize`. This makes it easier to extend the +`DSHttpAdapter` class and override its methods. + +###### Backwards compatible API changes +- Added lifecycle methods: beforeFind, afterPOST, etc. +- Added support for the `raw` option + +##### 3.0.0-alpha.1 - 12 December 2015 + +###### Breaking API changes +- Actions are now part of js-data-http, rather than js-data +- Now requires js-data 3.x or greater + +###### Backwards compatible API changes +- Added option to support use of `window.fetch` +- Added option to supply custom http implementation + +###### Other +- Published the js-data-http-node package, a build of js-data-http that works in Node.js + ##### 2.1.2 - 28 October 2015 +###### Backwards compatible API changes +- Added option to support use of `window.fetch` +- Added option to supply custom http implementation + ###### Other - Dropped Grunt - Now reporting code coverage properly diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9cf3079..61f3803 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,12 +1,11 @@ -# People who have contributed to the js-data-http project. +# This is the official list of js-data-http project contributors. # -# This file is controlled by scripts/authors.js +# Names are formatted as: +# Name # -# Names should be added to this file as: -# [commit count] Name - 1 InternalFX - 1 Ivan Voznyakovsky - 56 Jason Dobry - 1 Josh Drake - 1 RobertHerhold - 3 Tomás Fox +InternalFX +Ivan Voznyakovsky +Jason Dobry +Josh Drake +RobertHerhold +Tomás Fox diff --git a/README.md b/README.md index 5e061d0..f877c90 100644 --- a/README.md +++ b/README.md @@ -9,53 +9,28 @@ [![Coverage Status][cov_b]][cov_l] [![Codacy][cod_b]][cod_l] -HTTP adapter for [js-data](http://www.js-data.io/). +This repo contains HTTP adapters for [js-data](http://www.js-data.io/): -To get started, visit __[http://js-data.io](http://www.js-data.io)__. +- js-data-http - HTTP (XHR, includes [axios][axios]) adapter for js-data in the +browser. Capable of using `window.fetch` instead of axios. +- js-data-fetch - Same as js-data-http but doesn't include axios and will use +`window.fetch` if available and if you don't provide your own http library. +- js-data-http-node - Same as js-data-http but runs on Node.js. Depends on axios +and will use axios unless you provide a different http library. -## Table of contents +Tested on IE9, Chrome 46, Firefox 41 & Safari 7.1 using +bs logo -* [Quick start](#quick-start) -* [Guides and Tutorials](#guides-and-tutorials) -* [API Reference Docs](#api-reference-docs) -* [Community](#community) -* [Support](#support) -* [Contributing](#contributing) -* [License](#license) +To get started, visit the main website at __[http://js-data.io](http://www.js-data.io/v3.0/docs/js-data-http)__. -## Quick Start -`npm install --save js-data js-data-http` or `bower install --save js-data js-data-http`. +## Links -Load `js-data-http.js` after `js-data.js`. - -```js -var adapter = new DSHttpAdapter(); - -var store = new JSData.DS(); -store.registerAdapter('http', adapter, { default: true }); - -// "store" will now use the http adapter for all async operations -``` - -## Guides and Tutorials - -[Get started at http://js-data.io](http://js-data.io) - -## API Reference Docs - -[Visit http://api.js-data.io](http://api.js-data.io). - -## Community - -[Explore the Community](http://js-data.io/docs/community). - -## Support - -[Find out how to Get Support](http://js-data.io/docs/support). - -## Contributing - -[Read the Contributing Guide](http://js-data.io/docs/contributing). +* [Quick start](http://www.js-data.io/v3.0/docs/js-data-http) +* [Guides and Tutorials](http://www.js-data.io/v3.0/docs/home) +* [API Reference Docs](http://api.js-data.io/js-data-http) +* [Community](http://js-data.io/docs/community) +* [Support](http://js-data.io/docs/support) +* [Contributing](http://js-data.io/docs/contributing) ## License @@ -69,13 +44,14 @@ Copyright (c) 2014-2016 js-data-http project authors [sl_b]: http://slack.js-data.io/badge.svg [sl_l]: http://slack.js-data.io +[so]: http://stackoverflow.com/questions/tagged/jsdata [npm_b]: https://img.shields.io/npm/v/js-data-http.svg?style=flat [npm_l]: https://www.npmjs.org/package/js-data-http [circle_b]: https://img.shields.io/circleci/project/js-data/js-data-http/master.svg?style=flat [circle_l]: https://circleci.com/gh/js-data/js-data-http/tree/master [dn_b]: https://img.shields.io/npm/dm/js-data-http.svg?style=flat [dn_l]: https://www.npmjs.org/package/js-data-http -[cov_b]: https://img.shields.io/coveralls/js-data/js-data-http/master.svg?style=flat -[cov_l]: https://coveralls.io/github/js-data/js-data-http?branch=master +[cov_b]: https://img.shields.io/codecov/c/github/js-data/js-data-http/3.0.svg?style=flat +[cov_l]: https://codecov.io/github/js-data/js-data-http [cod_b]: https://img.shields.io/codacy/3931bbd8d838463297f70640aa78251b.svg [cod_l]: https://www.codacy.com/app/jasondobry/js-data-http/dashboard \ No newline at end of file diff --git a/bower.json b/bower.json index 312c532..9f596f0 100644 --- a/bower.json +++ b/bower.json @@ -1,34 +1,33 @@ { "name": "js-data-http", - "description": "HTTP adapter for js-data.", - "homepage": "http://www.js-data.io/docs/dshttpadapter", + "description": "HTTP (XHR) adapter for js-data in the browser.", + "homepage": "https://github.com/js-data/js-data-http", "repository": { "type": "git", "url": "https://github.com/js-data/js-data-http.git" }, - "author": { - "name": "Jason Dobry", - "url": "http://www.pseudobry.com", - "email": "jason.dobry@gmail.com" - }, + "author": "js-data-http project authors", "main": "./dist/js-data-http.js", "ignore": [ ".idea/", ".*", "*.iml", "src/", - "lib/", "doc/", - "guide/", + "build_examples/", "coverage/", - "Gruntfile.js", + "scripts/", + "junit/", "node_modules/", + "fetch/", + "node/", "test/", "package.json", "karma.conf.js", - "karma.start.js" + "karma.start.js", + "webpack.config.js" ], "dependencies": { - "js-data": ">=2.0.0" + "js-data": ">=3.0.0-alpha.26" } } diff --git a/build_examples/browserify/README.md b/build_examples/browserify/README.md new file mode 100644 index 0000000..bac593a --- /dev/null +++ b/build_examples/browserify/README.md @@ -0,0 +1,3 @@ +Running `browserify -x axios app.js > bundle.js` in this directory will produce `bundle.js` + +Note the external dependency "axios" that is excluded from the build (it's not needed when using js-data-angular). diff --git a/build_examples/browserify/app.js b/build_examples/browserify/app.js new file mode 100644 index 0000000..1be0455 --- /dev/null +++ b/build_examples/browserify/app.js @@ -0,0 +1,14 @@ +var JSData = require('js-data') +// normally this would be "var HttpAdapter = require('js-data-http')" +var HttpAdapter = require('../../') + +document.getElementById('main').innerHTML = HttpAdapter.version.full + +var adapter = new HttpAdapter() +var store = new JSData.DataStore() +store.registerAdapter('http', adapter, { default: true }) +store.defineMapper('user') + +store.find('user', 1).catch(function (err) { + console.log(err) +}) diff --git a/build_examples/browserify/index.html b/build_examples/browserify/index.html new file mode 100644 index 0000000..090fb5d --- /dev/null +++ b/build_examples/browserify/index.html @@ -0,0 +1,11 @@ + + + + My App + + +

+ + + + diff --git a/build_examples/node/app.js b/build_examples/node/app.js new file mode 100644 index 0000000..60f6296 --- /dev/null +++ b/build_examples/node/app.js @@ -0,0 +1,12 @@ +var JSData = require('js-data') +// normally this would be "var HttpAdapter = require('js-data-http-node')" +var HttpAdapter = require('../../') + +var adapter = new HttpAdapter() +var store = new JSData.Container() +store.registerAdapter('http', adapter, { default: true }) +store.defineMapper('user') + +store.find('user', 1).catch(function (err) { + console.log(err) +}) diff --git a/build_examples/r.js/README.md b/build_examples/r.js/README.md new file mode 100644 index 0000000..0632f37 --- /dev/null +++ b/build_examples/r.js/README.md @@ -0,0 +1,3 @@ +Running `r.js -o require.config.js` in this directory will produce `bundle.js` + +In `index.html` switch `script/main` between `main` (load scripts dynamically) and `bundle` (load bundled scripts) diff --git a/build_examples/r.js/app.js b/build_examples/r.js/app.js new file mode 100644 index 0000000..2a30365 --- /dev/null +++ b/build_examples/r.js/app.js @@ -0,0 +1,15 @@ +define('app', [ + 'js-data', + 'js-data-http' +], function (JSData, HttpAdapter) { + document.getElementById('main').innerHTML = HttpAdapter.version.full + + var adapter = new HttpAdapter() + var store = new DataStore() + store.registerAdapter('http', adapter, { default: true }) + store.defineMapper('user') + + store.find('user', 1).catch(function (err) { + console.log(err) + }) +}) diff --git a/build_examples/r.js/index.html b/build_examples/r.js/index.html new file mode 100644 index 0000000..ca909b0 --- /dev/null +++ b/build_examples/r.js/index.html @@ -0,0 +1,14 @@ + + + + My App + + +

+ + + + + + + diff --git a/build_examples/r.js/main.js b/build_examples/r.js/main.js new file mode 100644 index 0000000..66e0774 --- /dev/null +++ b/build_examples/r.js/main.js @@ -0,0 +1,17 @@ +require.config({ + paths: { + // customize these as needed + 'js-data-http': '../../node/dist/js-data-http', + 'js-data': '../../node_modules/js-data/dist/js-data', + } +}); + +require([ + 'app' + ], function (User) { + + User.find(1).catch(function (err) { + console.log(err); + }); + } +); diff --git a/build_examples/r.js/require.config.js b/build_examples/r.js/require.config.js new file mode 100644 index 0000000..a89ae0f --- /dev/null +++ b/build_examples/r.js/require.config.js @@ -0,0 +1,6 @@ +({ + name: 'main', + mainConfigFile: 'main.js', + out: 'bundle.js', + optimize: 'none' +}) diff --git a/build_examples/webpack/README.md b/build_examples/webpack/README.md new file mode 100644 index 0000000..14fa7b9 --- /dev/null +++ b/build_examples/webpack/README.md @@ -0,0 +1,3 @@ +Running `webpack` in this directory will produce `bundle.js` + +Note the external dependency "axios" that is excluded from the build (it's not needed when using js-data-angular). diff --git a/build_examples/webpack/app.js b/build_examples/webpack/app.js new file mode 100644 index 0000000..1be0455 --- /dev/null +++ b/build_examples/webpack/app.js @@ -0,0 +1,14 @@ +var JSData = require('js-data') +// normally this would be "var HttpAdapter = require('js-data-http')" +var HttpAdapter = require('../../') + +document.getElementById('main').innerHTML = HttpAdapter.version.full + +var adapter = new HttpAdapter() +var store = new JSData.DataStore() +store.registerAdapter('http', adapter, { default: true }) +store.defineMapper('user') + +store.find('user', 1).catch(function (err) { + console.log(err) +}) diff --git a/build_examples/webpack/index.html b/build_examples/webpack/index.html new file mode 100644 index 0000000..090fb5d --- /dev/null +++ b/build_examples/webpack/index.html @@ -0,0 +1,11 @@ + + + + My App + + +

+ + + + diff --git a/build_examples/webpack/webpack.config.js b/build_examples/webpack/webpack.config.js new file mode 100644 index 0000000..8e3c289 --- /dev/null +++ b/build_examples/webpack/webpack.config.js @@ -0,0 +1,12 @@ +module.exports = { + entry: './app.js', + output: { + filename: 'bundle.js' + }, + // only necessary for this demo + resolve: { + alias: { + 'js-data-http': '../../dist/js-data-http.js' + } + } +}; diff --git a/build_examples/webpack_es6/README.md b/build_examples/webpack_es6/README.md new file mode 100644 index 0000000..14fa7b9 --- /dev/null +++ b/build_examples/webpack_es6/README.md @@ -0,0 +1,3 @@ +Running `webpack` in this directory will produce `bundle.js` + +Note the external dependency "axios" that is excluded from the build (it's not needed when using js-data-angular). diff --git a/build_examples/webpack_es6/app.js b/build_examples/webpack_es6/app.js new file mode 100644 index 0000000..d12c6e2 --- /dev/null +++ b/build_examples/webpack_es6/app.js @@ -0,0 +1,14 @@ +import {DataStore} from 'js-data' +// normally this would be "import DSHttpAdatper from 'js-data-http'" +import HttpAdapter from '../../'; + +document.getElementById('main').innerHTML = HttpAdapter.version.full; + +var adapter = new HttpAdapter() +var store = new DataStore() +store.registerAdapter('http', adapter, { default: true }) +store.defineMapper('user') + +store.find('user', 1).catch(function (err) { + console.log(err) +}) \ No newline at end of file diff --git a/build_examples/webpack_es6/index.html b/build_examples/webpack_es6/index.html new file mode 100644 index 0000000..090fb5d --- /dev/null +++ b/build_examples/webpack_es6/index.html @@ -0,0 +1,11 @@ + + + + My App + + +

+ + + + diff --git a/build_examples/webpack_es6/webpack.config.js b/build_examples/webpack_es6/webpack.config.js new file mode 100644 index 0000000..be68a98 --- /dev/null +++ b/build_examples/webpack_es6/webpack.config.js @@ -0,0 +1,21 @@ +var path = require('path'); +module.exports = { + entry: './app.js', + output: { + filename: 'bundle.js' + }, + // only necessary for this demo + resolve: { + alias: { + 'js-data-http': '../../dist/js-data-http.js' + } + }, + module: { + loaders: [ + {test: /(.+)\.js$/, loader: 'babel-loader?blacklist=useStrict'} + ] + }, + resolveLoader: { + root: path.join(__dirname, '../../node_modules') + } +}; diff --git a/circle.yml b/circle.yml index 21adefe..f3696f9 100644 --- a/circle.yml +++ b/circle.yml @@ -1,12 +1,11 @@ -dependencies: - pre: - - bower install - cache_directories: - - "bower_components" +machine: + node: + version: 4.1.0 test: override: - npm run ci general: artifacts: - "dist" + - "fetch/dist" - "coverage" diff --git a/conf.json b/conf.json new file mode 100644 index 0000000..e6aed45 --- /dev/null +++ b/conf.json @@ -0,0 +1,27 @@ + { + "source": { + "includePattern": ".*js$" + }, + "plugins": ["plugins/markdown"], + "opts": { + "template": "./node_modules/ink-docstrap/template", + "destination": "./doc/", + "recurse": true, + "verbose": true, + "readme": "./README.md", + "package": "./package.json" + }, + "templates": { + "theme": "lumen", + "systemName": "js-data-http", + "copyright": "js-data-http Copyright © 2014-2016 js-data-http project authors", + "outputSourceFiles": true, + "syntaxTheme": "dark", + "linenums": true, + "footer": "
Back to js-data.io
", + "analytics": { + "ua": "UA-55528236-2", + "domain": "api.js-data.io" + } + } +} \ No newline at end of file diff --git a/dist/js-data-http.d.ts b/dist/js-data-http.d.ts new file mode 100644 index 0000000..36186ca --- /dev/null +++ b/dist/js-data-http.d.ts @@ -0,0 +1,38 @@ +import {Adapter} from 'js-data-adapter' + +interface IDict { + [key: string]: any; +} +interface IActionOpts { + adapter?: string, + pathname?: string, + request?: Function, + response?: Function, + responseError?: Function +} +interface IBaseAdapter extends IDict { + debug?: boolean, + raw?: boolean +} +interface IBaseHttpAdapter extends IBaseAdapter { + basePath?: string + forceTrailingSlash?: boolean + http?: any + httpConfig?: IDict + suffix?: string + useFetch?: boolean +} +export function addAction(name: string, opts: IActionOpts): Function +export function addActions(opts ?: { [key:string]: IActionOpts }): Function +export class HttpAdapter extends Adapter { + static version: { + full?: string + minor?: string + major?: string + patch?: string + alpha?: string | boolean + beta?: string | boolean + } + static extend(instanceProps?: IDict, classProps?: IDict): typeof HttpAdapter + constructor(opts?: IBaseHttpAdapter) +} diff --git a/dist/js-data-http.js b/dist/js-data-http.js index 959d21c..4b8835f 100644 --- a/dist/js-data-http.js +++ b/dist/js-data-http.js @@ -1,11 +1,10 @@ /*! * js-data-http -* @version 2.2.1 - Homepage -* @author Jason Dobry -* @copyright (c) 2014-2015 Jason Dobry +* @version 3.0.0-beta.2 - Homepage +* @copyright (c) 2014-2016 js-data-http project authors * @license MIT * -* @overview HTTP adapter for js-data. +* @overview HTTP (XHR) adapter for js-data in the browser. */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') @@ -13,9 +12,9 @@ else if(typeof define === 'function' && define.amd) define(["js-data"], factory); else if(typeof exports === 'object') - exports["DSHttpAdapter"] = factory(require("js-data")); + exports["HttpAdapter"] = factory(require("js-data")); else - root["DSHttpAdapter"] = factory(root["JSData"]); + root["HttpAdapter"] = factory(root["JSData"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_1__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache @@ -67,401 +66,2935 @@ return /******/ (function(modules) { // webpackBootstrap var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + var _jsData = __webpack_require__(1); - function _defineProperty(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 _jsDataAdapter = __webpack_require__(2); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + var _jsDataAdapter2 = _interopRequireDefault(_jsDataAdapter); - var JSData = __webpack_require__(1); - var axios = null; + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + /* global fetch:true Headers:true Request:true */ + var axios = __webpack_require__(3); + + + var hasFetch = false; try { - axios = __webpack_require__(2); + hasFetch = window && window.fetch; } catch (e) {} - var DSUtils = JSData.DSUtils; - var deepMixIn = DSUtils.deepMixIn; - var removeCircular = DSUtils.removeCircular; - var copy = DSUtils.copy; - var makePath = DSUtils.makePath; - var isString = DSUtils.isString; - var isNumber = DSUtils.isNumber; - - var Defaults = function () { - function Defaults() { - _classCallCheck(this, Defaults); - } + var noop = function noop() { + var self = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return _jsData.utils.resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + self.dbg.apply(self, [opts.op].concat(args)); + return _jsData.utils.resolve(); + }; + + function isValidString(value) { + return value != null && value !== ''; + } + function join(items, separator) { + separator || (separator = ''); + return items.filter(isValidString).join(separator); + } + function makePath() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + var result = join(args, '/'); + return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); + } + + function encode(val) { + return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); + } + + function buildUrl(url, params) { + if (!params) { + return url; + } + + var parts = []; + + _jsData.utils.forOwn(params, function (val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + if (!_jsData.utils.isArray(val)) { + val = [val]; + } + + val.forEach(function (v) { + if (window.toString.call(v) === '[object Date]') { + v = v.toISOString(); + } else if (_jsData.utils.isObject(v)) { + v = _jsData.utils.toJson(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; + } + + var __super__ = _jsDataAdapter2.default.prototype; + + var DEFAULTS = { + // Default and user-defined settings + /** + * @name HttpAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + */ + forceTrailingSlash: false, + + /** + * @name HttpAdapter#http + * @type {Function} + */ + http: axios, + + /** + * @name HttpAdapter#httpConfig + * @type {Object} + */ + httpConfig: {}, + + /** + * @name HttpAdapter#suffix + * @type {string} + */ + suffix: '', + + /** + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + */ + useFetch: false + }; + + /** + * HttpAdapter class. + * + * @class HttpAdapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.basePath=''] TODO + * @param {boolean} [opts.debug=false] TODO + * @param {boolean} [opts.forceTrailingSlash=false] TODO + * @param {Object} [opts.http=axios] TODO + * @param {Object} [opts.httpConfig={}] TODO + * @param {string} [opts.suffix=''] TODO + * @param {boolean} [opts.useFetch=false] TODO + */ + function HttpAdapter(opts) { + var self = this; + opts || (opts = {}); + _jsData.utils.fillIn(opts, DEFAULTS); + _jsDataAdapter2.default.call(self, opts); + } + + // Setup prototype inheritance from Adapter + HttpAdapter.prototype = Object.create(_jsDataAdapter2.default.prototype, { + constructor: { + value: HttpAdapter, + enumerable: false, + writable: true, + configurable: true + } + }); + + Object.defineProperty(HttpAdapter, '__super__', { + configurable: true, + value: _jsDataAdapter2.default + }); + + _jsData.utils.addHiddenPropsToTarget(HttpAdapter.prototype, { + /** + * @name HttpAdapter#afterDEL + * @method + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterDEL: noop2, + + /** + * @name HttpAdapter#afterGET + * @method + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterGET: noop2, + + /** + * @name HttpAdapter#afterHTTP + * @method + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterHTTP: noop2, + + /** + * @name HttpAdapter#afterPOST + * @method + * @param {string} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterPOST: noop2, + + /** + * @name HttpAdapter#afterPUT + * @method + * @param {string} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterPUT: noop2, + + /** + * @name HttpAdapter#beforeDEL + * @method + * @param {Object} url + * @param {Object} config + * @param {Object} opts + */ + beforeDEL: noop, + + /** + * @name HttpAdapter#beforeGET + * @method + * @param {Object} url + * @param {Object} config + * @param {Object} opts + */ + beforeGET: noop, + + /** + * @name HttpAdapter#beforeHTTP + * @method + * @param {Object} config + * @param {Object} opts + */ + beforeHTTP: noop, + + /** + * @name HttpAdapter#beforePOST + * @method + * @param {Object} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + */ + beforePOST: noop, + + /** + * @name HttpAdapter#beforePUT + * @method + * @param {Object} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + */ + beforePUT: noop, + + _count: function _count(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('create', mapper, props, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('createMany', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var self = this; + return self.DEL(self.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var self = this; + return self.DEL(self.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var self = this; + return self.GET(self.getPath('find', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var self = this; + return self.GET(self.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var self = this; + return self.PUT(self.getPath('update', mapper, id, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var self = this; + return self.PUT(self.getPath('updateAll', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var self = this; + return self.PUT(self.getPath('updateMany', mapper, null, opts), self.serialize(mapper, records, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + + + /** + * Retrieve the number of records that match the selection `query`. + * + * @name HttpAdapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params.count = true; + opts.suffix = self.getSuffix(mapper, opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.count.call(self, mapper, query, opts); + }, + + + /** + * Create a new the record from the provided `props`. + * + * @name HttpAdapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props Properties to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.create.call(self, mapper, props, opts); + }, + + + /** + * Create multiple new records in batch. + * + * @name HttpAdapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} props Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.createMany.call(self, mapper, props, opts); + }, + + + /** + * Make an Http request to `url` according to the configuration in `config`. + * + * @name HttpAdapter#DEL + * @method + * @param {string} url Url for the request. + * @param {Object} [config] Http configuration that will be passed to + * {@link HttpAdapter#HTTP}. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + DEL: function DEL(url, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'delete'; + + // beforeDEL lifecycle hook + op = opts.op = 'beforeDEL'; + return _jsData.utils.resolve(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'DEL'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Transform the server response object into the payload that will be returned + * to JSData. + * + * @name HttpAdapter#deserialize + * @method + * @param {Object} mapper The mapper used for the operation. + * @param {Object} response Response object from {@link HttpAdapter#HTTP}. + * @param {Object} opts Configuration options. + * @return {(Object|Array)} Deserialized data. + */ + deserialize: function deserialize(mapper, response, opts) { + opts || (opts = {}); + if (_jsData.utils.isFunction(opts.deserialize)) { + return opts.deserialize(mapper, response, opts); + } + if (_jsData.utils.isFunction(mapper.deserialize)) { + return mapper.deserialize(mapper, response, opts); + } + if (response && response.hasOwnProperty('data')) { + return response.data; + } + return response; + }, + + + /** + * Destroy the record with the given primary key. + * + * @name HttpAdapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroy.call(self, mapper, id, opts); + }, + + + /** + * Destroy the records that match the selection `query`. + * + * @name HttpAdapter#destroyAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroyAll.call(self, mapper, query, opts); + }, + + + /** + * Log an error. + * + * @name HttpAdapter#error + * @method + * @param {...*} [args] Arguments to log. + */ + error: function error() { + if (console) { + var _console; + + (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); + } + }, + + + /** + * Make an Http request using `window.fetch`. + * + * @name HttpAdapter#fetch + * @method + * @param {Object} config Request configuration. + * @param {Object} config.data Payload for the request. + * @param {string} config.method Http method for the request. + * @param {Object} config.headers Headers for the request. + * @param {Object} config.params Querystring for the request. + * @param {string} config.url Url for the request. + * @param {Object} [opts] Configuration options. + */ + fetch: function (_fetch) { + function fetch(_x, _x2) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config, opts) { + var requestConfig = { + method: config.method, + // turn the plain headers object into the Fetch Headers object + headers: new Headers(config.headers) + }; + + if (config.data) { + requestConfig.body = _jsData.utils.toJson(config.data); + } + + return fetch(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) { + response.config = { + method: config.method, + url: config.url + }; + return response.json().then(function (data) { + response.data = data; + return response; + }); + }); + }), + + + /** + * Retrieve the record with the given primary key. + * + * @name HttpAdapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.find.call(self, mapper, id, opts); + }, + + + /** + * Retrieve the records that match the selection `query`. + * + * @name HttpAdapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.suffix = self.getSuffix(mapper, opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.findAll.call(self, mapper, query, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#GET + * @method + * @param {string} url The url for the request. + * @param {Object} config Request configuration options. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + GET: function GET(url, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'get'; + + // beforeGET lifecycle hook + op = opts.op = 'beforeGET'; + return _jsData.utils.resolve(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'GET'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {boolean} opts TODO + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = _jsData.utils.isUndefined(opts.params) ? {} : opts.params; + var relationList = mapper.relationList || []; + var endpoint = _jsData.utils.isUndefined(opts.endpoint) ? _jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; + + relationList.forEach(function (def) { + if (def.type !== 'belongsTo' || !def.parent) { + return; + } + var item = void 0; + var parentKey = def.foreignKey; + var parentDef = def.getRelation(); + var parentId = opts.params[parentKey]; + + if (parentId === false || !parentKey || !parentDef) { + if (parentId === false) { + delete opts.params[parentKey]; + } + return false; + } else { + delete opts.params[parentKey]; + + if (_jsData.utils.isObject(id)) { + item = id; + } + + if (item) { + parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? _jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); + } + + if (parentId) { + var _ret = function () { + delete opts.endpoint; + var _opts = {}; + _jsData.utils.forOwn(opts, function (value, key) { + _opts[key] = value; + }); + _jsData.utils._(_opts, parentDef); + endpoint = makePath(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return { + v: false + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + } + } + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method TODO + * @param {Object} mapper TODO + * @param {(string|number)?} id TODO + * @param {Object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + var self = this; + opts || (opts = {}); + var args = [_jsData.utils.isUndefined(opts.basePath) ? _jsData.utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath : opts.basePath, self.getEndpoint(mapper, _jsData.utils.isString(id) || _jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; + if (method === 'find' || method === 'update' || method === 'destroy') { + args.push(id); + } + return makePath.apply(_jsData.utils, args); + }, + getParams: function getParams(opts) { + opts || (opts = {}); + if (_jsData.utils.isUndefined(opts.params)) { + return {}; + } + return _jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (_jsData.utils.isUndefined(opts.suffix)) { + if (_jsData.utils.isUndefined(mapper.suffix)) { + return this.suffix; + } + return mapper.suffix; + } + return opts.suffix; + }, + + + /** + * Make an Http request. + * + * @name HttpAdapter#HTTP + * @method + * @param {Object} config Request configuration options. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + HTTP: function HTTP(config, opts) { + var self = this; + var start = new Date(); + opts || (opts = {}); + var payload = config.data; + var cache = config.cache; + var timeout = config.timeout; + config = _jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); + config = _jsData.utils.deepMixIn(config, self.httpConfig); + config.data = payload; + config.cache = cache; + config.timeout = timeout; + if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || self.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + function logResponse(data) { + var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; + if (data.status >= 200 && data.status < 300) { + if (self.log) { + self.dbg('debug', str, data); + } + return data; + } else { + if (self.error) { + self.error('\'FAILED: ' + str, data); + } + return _jsData.utils.reject(data); + } + } + + if (!self.http) { + throw new Error('You have not configured this adapter with an http library!'); + } + + return _jsData.utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { + return self.fetch(config, opts).then(logResponse, logResponse); + } + return self.http(config).then(logResponse, logResponse).catch(function (err) { + return self.responseError(err, config, opts); + }); + }).then(function (response) { + return _jsData.utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { + return _response || response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#POST + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'post'; + + // beforePOST lifecycle hook + op = opts.op = 'beforePOST'; + return _jsData.utils.resolve(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'POST'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#PUT + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'put'; + + // beforePUT lifecycle hook + op = opts.op = 'beforePUT'; + return _jsData.utils.resolve(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'PUT'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#queryTransform + * @method + * @param {Object} mapper TODO + * @param {*} params TODO + * @param {*} opts TODO + * @return {*} Transformed params. + */ + queryTransform: function queryTransform(mapper, params, opts) { + opts || (opts = {}); + if (_jsData.utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts); + } + if (_jsData.utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts); + } + return params; + }, + + + /** + * Error handler invoked when the promise returned by {@link HttpAdapter#http} + * is rejected. Default implementation is to just return the error wrapped in + * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is + * called by {@link HttpAdapter#HTTP}. + * + * @name HttpAdapter#responseError + * @method + * @param {*} err The error that {@link HttpAdapter#http} rejected with. + * @param {Object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. + * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. + * @return {Promise} + */ + responseError: function responseError(err, config, opts) { + return _jsData.utils.reject(err); + }, + + + /** + * TODO + * + * @name HttpAdapter#serialize + * @method + * @param {Object} mapper TODO + * @param {Object} data TODO + * @param {*} opts TODO + * @return {*} Serialized data. + */ + serialize: function serialize(mapper, data, opts) { + opts || (opts = {}); + if (_jsData.utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts); + } + if (_jsData.utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts); + } + return data; + }, + + + /** + * Retrieve the sum of the field of the records that match the selection query. + * + * @name HttpAdapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field The field to sum. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + if (!_jsData.utils.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = self.getParams(opts); + opts.params.sum = field; + opts.suffix = self.getSuffix(mapper, opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.sum.call(self, mapper, field, query, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#update + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {*} props TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.update.call(self, mapper, id, props, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#updateAll + * @method + * @param {Object} mapper TODO + * @param {Object} props TODO + * @param {Object} query TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateAll.call(self, mapper, props, query, opts); + }, + + + /** + * Update multiple records in batch. + * + * {@link HttpAdapter#beforeUpdateMany} will be called before calling + * {@link HttpAdapter#PUT}. + * {@link HttpAdapter#afterUpdateMany} will be called after calling + * {@link HttpAdapter#PUT}. + * + * @name HttpAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} records Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateMany.call(self, mapper, records, opts); + } + }); + + /** + * Add an Http actions to a mapper. + * + * @name HttpAdapter.addAction + * @method + * @param {string} name Name of the new action. + * @param {Object} [opts] Action configuration + * @param {string} [opts.adapter] + * @param {string} [opts.pathname] + * @param {Function} [opts.request] + * @param {Function} [opts.response] + * @param {Function} [opts.responseError] + * @return {Function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ + HttpAdapter.addAction = function (name, opts) { + if (!name || !_jsData.utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + } + return function (mapper) { + if (mapper[name]) { + throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); + } + opts.request = opts.request || function (config) { + return config; + }; + opts.response = opts.response || function (response) { + return response; + }; + opts.responseError = opts.responseError || function (err) { + return _jsData.utils.reject(err); + }; + mapper[name] = function (id, _opts) { + var self = this; + if (_jsData.utils.isObject(id)) { + _opts = id; + } + _opts = _opts || {}; + var adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http'); + var config = {}; + _jsData.utils.fillIn(config, opts); + if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { + _opts.endpoint = config.endpoint; + } + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(self, _opts); + } else { + var _args = [_opts.basePath || self.basePath || adapter.basePath, adapter.getEndpoint(self, _jsData.utils.isSorN(id) ? id : null, _opts)]; + if (_jsData.utils.isSorN(id)) { + _args.push(id); + } + _args.push(opts.pathname || name); + config.url = makePath.apply(null, _args); + } + config.method = config.method || 'GET'; + config.mapper = self.name; + _jsData.utils.deepMixIn(config)(_opts); + return _jsData.utils.resolve(config).then(_opts.request || opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = self.name; + } + return data; + }).then(_opts.response || opts.response, _opts.responseError || opts.responseError); + }; + return mapper; + }; + }; + + /** + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. + * + * @name HttpAdapter.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. + */ + HttpAdapter.addActions = function (opts) { + opts || (opts = {}); + return function (mapper) { + _jsData.utils.forOwn(mapper, function (value, key) { + HttpAdapter.addAction(key, value)(mapper); + }); + return mapper; + }; + }; + + /** + * Alternative to ES6 class syntax for extending `HttpAdapter`. + * + * __ES6__: + * ```javascript + * class MyHttpAdapter extends HttpAdapter { + * deserialize (Model, data, opts) { + * const data = super.deserialize(Model, data, opts) + * data.foo = 'bar' + * return data + * } + * } + * ``` + * + * __ES5__: + * ```javascript + * var instanceProps = { + * // override deserialize + * deserialize: function (Model, data, opts) { + * var Ctor = this.constructor + * var superDeserialize = (Ctor.__super__ || Object.getPrototypeOf(Ctor)).deserialize + * // call the super deserialize + * var data = superDeserialize(Model, data, opts) + * data.foo = 'bar' + * return data + * }, + * say: function () { return 'hi' } + * } + * var classProps = { + * yell: function () { return 'HI' } + * } + * + * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) + * var adapter = new MyHttpAdapter() + * adapter.say() // "hi" + * MyHttpAdapter.yell() // "HI" + * ``` + * + * @name HttpAdapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `HttpAdapter`. + */ + HttpAdapter.extend = _jsData.utils.extend; + + /** + * Details of the current version of the `js-data-http` module. + * + * @name HttpAdapter.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. + */ + HttpAdapter.version = { + beta: 2, + full: '3.0.0-beta.2', + 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`. + * + * __Script tag__: + * ```javascript + * window.HttpAdapter + * ``` + * __CommonJS__: + * ```javascript + * var HttpAdapter = require('js-data-http') + * ``` + * __ES6 Modules__: + * ```javascript + * import HttpAdapter from 'js-data-http' + * ``` + * __AMD__: + * ```javascript + * define('myApp', ['js-data-http'], function (HttpAdapter) { ... }) + * ``` + * + * @module js-data-http + */ + + module.exports = HttpAdapter; + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_1__; + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + (function (global, factory) { + true ? factory(__webpack_require__(1)) : + typeof define === 'function' && define.amd ? define('js-data-adapter', ['js-data'], factory) : + (factory(global.JSData)); + }(this, function (jsData) { 'use strict'; + + var babelHelpers = {}; + babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; + }; + + babelHelpers.defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + }; + + babelHelpers.slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + }(); + + babelHelpers; + + var noop = function noop() { + var self = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var unique = function unique(array) { + var seen = {}; + var final = []; + array.forEach(function (item) { + if (item in seen) { + return; + } + final.push(item); + seen[item] = 0; + }); + return final; + }; + + var withoutRelations = function withoutRelations(mapper, props) { + return jsData.utils.omit(props, mapper.relationFields || []); + }; + + var DEFAULTS = { + /** + * Whether to log debugging information. + * + * @name Adapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * Whether to return a more detailed response object. + * + * @name Adapter#raw + * @type {boolean} + * @default false + */ + raw: false + }; + + /** + * Abstract class meant to be extended by adapters. + * + * @class Adapter + * @abstract + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.debug=false] Whether to log debugging information. + * @param {boolean} [opts.raw=false] Whether to return a more detailed response + * object. + */ + function Adapter(opts) { + var self = this; + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS); + jsData.utils.fillIn(self, opts); + } + + Adapter.reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where']; + + /** + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @typedef {Object} Response + * @property {Object} data Response data. + * @property {string} op The operation for which the response was created. + */ + function Response(data, meta, op) { + var self = this; + meta || (meta = {}); + self.data = data; + jsData.utils.fillIn(self, meta); + self.op = op; + } + + Adapter.Response = Response; + + /** + * Alternative to ES6 class syntax for extending `Adapter`. + * + * @name Adapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `Adapter`. + */ + Adapter.extend = jsData.utils.extend; + + jsData.utils.addHiddenPropsToTarget(Adapter.prototype, { + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#afterCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} props The `props` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `afterCount` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterCount: noop2, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `afterCreate` + * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreate: noop2, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `afterCreateMany` + * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreateMany: noop2, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#afterDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `afterDestroy` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroy: noop2, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#afterDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `afterDestroyAll` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroyAll: noop2, - _createClass(Defaults, [{ - key: 'queryTransform', - value: function queryTransform(resourceConfig, params) { - return params; - } - }, { - key: 'deserialize', - value: function deserialize(resourceConfig, data) { - return data ? 'data' in data ? data.data : data : data; - } - }, { - key: 'serialize', - value: function serialize(resourceConfig, data) { - return data; - } - }, { - key: 'log', - value: function log() {} - }, { - key: 'error', - value: function error() {} - }]); + /** + * 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, - return Defaults; - }(); + /** + * 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, - var defaultsPrototype = Defaults.prototype; + /** + * 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 {Object} props The `props` 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, - defaultsPrototype.basePath = ''; + /** + * 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, - defaultsPrototype.forceTrailingSlash = ''; + /** + * 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, - defaultsPrototype.httpConfig = {}; + /** + * 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, - defaultsPrototype.verbsUseBasePath = false; + /** + * 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, - var DSHttpAdapter = function () { - function DSHttpAdapter(options) { - _classCallCheck(this, DSHttpAdapter); + /** + * 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, - options = options || {}; - this.defaults = new Defaults(); - if (console) { - this.defaults.log = function (a, b) { - return console[typeof console.info === 'function' ? 'info' : 'log'](a, b); - }; - } - if (console) { - this.defaults.error = function (a, b) { - return console[typeof console.error === 'function' ? 'error' : 'log'](a, b); - }; - } - deepMixIn(this.defaults, options); - this.http = options.http || axios; - } + /** + * 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, - _createClass(DSHttpAdapter, [{ - key: 'getEndpoint', - value: function getEndpoint(resourceConfig, id, options) { - options = options || {}; - options.params = options.params || {}; - - var endpoint = options.hasOwnProperty('endpoint') ? options.endpoint : resourceConfig.endpoint; - var parents = resourceConfig.parents || (resourceConfig.parent ? _defineProperty({}, resourceConfig.parent, { - key: resourceConfig.parentKey, - field: resourceConfig.parentField - }) : {}); - - DSUtils.forOwn(parents, function (parent, parentName) { - var _this2 = this; - - var item = void 0; - var parentKey = parent.key; - var parentField = parent.field; - var parentDef = resourceConfig.getResource(parentName); - var parentId = options.params[parentKey]; - - if (parentId === false || !parentKey || !parentDef) { - if (parentId === false) { - delete options.params[parentKey]; - } - } else { - delete options.params[parentKey]; + /** + * 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, - if (DSUtils._sn(id)) { - item = resourceConfig.get(id); - } else if (DSUtils._o(id)) { - item = id; - } - console.log('item', item); + /** + * 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, - if (item) { - parentId = parentId || item[parentKey] || (item[parentField] ? item[parentField][parentDef.idAttribute] : null); - } + /** + * 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, - if (parentId) { - (function () { - delete options.endpoint; - var _options = {}; - DSUtils.forOwn(options, function (value, key) { - _options[key] = value; - }); - endpoint = DSUtils.makePath(_this2.getEndpoint(parentDef, parentId, DSUtils._(parentDef, _options)), parentId, endpoint); - })(); - } - } - }, this); + /** + * 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, - return endpoint; - } - }, { - key: 'getPath', - value: function getPath(method, resourceConfig, id, options) { - var _this = this; - options = options || {}; - if (isString(options.urlPath)) { - return makePath.apply(DSUtils, [options.basePath || _this.defaults.basePath || resourceConfig.basePath, options.urlPath]); + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#beforeSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `beforeSum` + */ + beforeSum: noop, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#beforeUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `beforeUpdate` + */ + beforeUpdate: noop, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#beforeUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `beforeUpdateAll` + */ + beforeUpdateAll: noop, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#beforeUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} props The `props` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `beforeUpdateMany` + */ + beforeUpdateMany: noop, + + /** + * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`. + * + * @name Adapter#dbg + * @method + */ + dbg: function dbg() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + this.log.apply(this, ['debug'].concat(args)); + }, + + + /** + * Retrieve the number of records that match the selection query. Called by + * `Mapper#count`. + * + * @name Adapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._count(mapper, query, opts)); + }).then(function (results) { + var _results = babelHelpers.slicedToArray(results, 2); + + var data = _results[0]; + var result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Create a new record. Called by `Mapper#create`. + * + * @name Adapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'create'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = babelHelpers.slicedToArray(results, 2); + + var data = _results2[0]; + var result = _results2[1]; + + result || (result = {}); + var response = new Response(data, result, 'create'); + response.created = data ? 1 : 0; + response = self.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Create multiple records in a single batch. Called by `Mapper#createMany`. + * + * @name Adapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'createMany'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = babelHelpers.slicedToArray(results, 2); + + var data = _results3[0]; + var result = _results3[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'createMany'); + response.created = data.length; + response = self.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Destroy the record with the given primary key. Called by + * `Mapper#destroy`. + * + * @name Adapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + var op = void 0; + opts || (opts = {}); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = babelHelpers.slicedToArray(results, 2); + + var data = _results4[0]; + var result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = self.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Destroy the records that match the selection query. Called by + * `Mapper#destroyAll`. + * + * @name Adapter#destroyAll + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = babelHelpers.slicedToArray(results, 2); + + var data = _results5[0]; + var result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = self.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * 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); + }, + + + /** + * Load a hasMany relationship. + * + * Override with care. + * + * @name Adapter#loadHasMany + * @method + * @return {Promise} + */ + loadHasMany: function loadHasMany(mapper, def, records, __opts) { + var self = this; + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return self.makeHasManyForeignKey(mapper, def, record); + }); + var query = { + where: {} + }; + var criteria = query.where[def.foreignKey] = {}; + if (singular) { + // more efficient query when we only have one record + criteria['=='] = IDs[0]; } else { - var args = [options.basePath || _this.defaults.basePath || resourceConfig.basePath, this.getEndpoint(resourceConfig, isString(id) || isNumber(id) || method === 'create' ? id : null, options)]; - if (method === 'find' || method === 'update' || method === 'destroy') { - args.push(id); - } - return makePath.apply(DSUtils, args); + criteria['in'] = IDs.filter(function (id) { + return id; + }); } - } - }, { - key: 'HTTP', - value: function HTTP(config) { - var _this = this; - var start = new Date(); - - // blacklist `data` as it can be large and will take a lot of time to copy - var payload = config.data; - var cache = config.cache; - var timeout = config.timeout; - config = copy(config, null, null, null, ['data', 'cache', 'timeout']); - config = deepMixIn(config, _this.defaults.httpConfig); - config.data = payload; - config.cache = cache; - config.timeout = timeout; - if (!('verbsUseBasePath' in config)) { - config.verbsUseBasePath = _this.defaults.verbsUseBasePath; + return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { + records.forEach(function (record) { + var attached = []; + // avoid unneccesary iteration when we only have one record + if (singular) { + attached = relatedItems; + } else { + relatedItems.forEach(function (relatedItem) { + if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { + attached.push(relatedItem); + } + }); + } + def.setLocalField(record, attached); + }); + }); + }, + loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { + var self = this; + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; } - if (!config.urlOverride && config.verbsUseBasePath) { - config.url = makePath(config.basePath || _this.defaults.basePath, config.url); + + if (record) { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': self.makeHasManyLocalKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + var _ret = function () { + var localKeys = []; + records.forEach(function (record) { + localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record)); + }); + return { + v: self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + var itemKeys = jsData.utils.get(item, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem); + } + }); + def.setLocalField(item, attached); + }); + return relatedItems; + }) + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; } - if (_this.defaults.forceTrailingSlash && config.url[config.url.length - 1] !== '/' && !config.urlOverride) { - config.url += '/'; + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var self = this; + var relatedMapper = def.getRelation(); + var idAttribute = mapper.idAttribute; + var record = void 0; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; } - if (_typeof(config.data) === 'object') { - config.data = removeCircular(config.data); + + if (record) { + return self.findAll(def.getRelation(), { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'contains': self.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return self.makeHasManyForeignKeys(mapper, def, record); + }) + }) + }, __opts).then(function (relatedItems) { + var foreignKeysField = def.foreignKeys; + records.forEach(function (record) { + var _relatedItems = []; + var id = jsData.utils.get(record, idAttribute); + relatedItems.forEach(function (relatedItem) { + var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; + if (foreignKeys.indexOf(id) !== -1) { + _relatedItems.push(relatedItem); + } + }); + def.setLocalField(record, _relatedItems); + }); + }); } - config.method = config.method.toUpperCase(); - var suffix = config.suffix || _this.defaults.suffix; - if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix && !config.urlOverride) { - config.url += suffix; + }, + + + /** + * 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]); + } + }); + }); + }, - // logs the HTTP response - function logResponse(data, isRejection) { - data = data || {}; - // examine the data object - if (data instanceof Error) { - // log the Error object - _this.defaults.error('FAILED: ' + (data.message || 'Unknown Error'), data); - return DSUtils.Promise.reject(data); - } else if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object') { - var str = start.toUTCString() + ' - ' + config.method + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; - - if (data.status >= 200 && data.status < 300 && !isRejection) { - if (_this.defaults.log) { - _this.defaults.log(str, data); - } - return data; - } else { - if (_this.defaults.error) { - _this.defaults.error('FAILED: ' + str, data); + + /** + * 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); + }, + + + /** + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo + * @method + * @return {Promise} + */ + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { + var self = this; + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var _ret2 = function () { + var record = records; + return { + v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }) + }; + }(); + + if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v; + } else { + var keys = records.map(function (record) { + return self.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return self.findAll(relationDef, { + where: babelHelpers.defineProperty({}, relationDef.idAttribute, { + 'in': keys + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (record) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { + def.setLocalField(record, relatedItem); + } + }); + }); + }); + } + }, + + + /** + * Retrieve the record with the given primary key. Called by `Mapper#find`. + * + * @name Adapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + var record = void 0, + op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._find(mapper, id, opts)); + }).then(function (results) { + var _results6 = babelHelpers.slicedToArray(results, 1); + + var _record = _results6[0]; + + if (!_record) { + return; + } + record = _record; + var tasks = []; + + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasOne') { + task = self.loadHasOne(mapper, def, record, __opts); + } else { + task = self.loadHasMany(mapper, def, record, __opts); } - return DSUtils.Promise.reject(data); + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, record, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, record, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, record, __opts); } + if (task) { + tasks.push(task); + } + }); + + return Promise.all(tasks); + }).then(function () { + var response = new Response(record, {}, 'find'); + response.found = record ? 1 : 0; + response = self.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Retrieve the records that match the selection query. + * + * @name Adapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + opts || (opts = {}); + opts.with || (opts.with = []); + + var records = []; + var op = void 0; + var activeWith = opts._activeWith; + + if (jsData.utils.isObject(activeWith)) { + var activeQuery = activeWith.query || {}; + if (activeWith.replace) { + query = activeQuery; } else { - // unknown type for 'data' that is not an Object or Error - _this.defaults.error('FAILED', data); - return DSUtils.Promise.reject(data); + jsData.utils.deepFillIn(query, activeQuery); } } - if (!this.http) { - throw new Error('You have not configured this adapter with an http library!'); + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._findAll(mapper, query, opts)); + }).then(function (results) { + var _results7 = babelHelpers.slicedToArray(results, 1); + + var _records = _results7[0]; + + _records || (_records = []); + records = _records; + var tasks = []; + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasMany') { + task = self.loadHasMany(mapper, def, records, __opts); + } else { + task = self.loadHasOne(mapper, def, records, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } + }); + return Promise.all(tasks); + }).then(function () { + var response = new Response(records, {}, 'findAll'); + response.found = records.length; + response = self.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Resolve the value of the specified option based on the given options and + * this adapter's settings. Override with care. + * + * @name Adapter#getOpt + * @method + * @param {string} opt The name of the option. + * @param {Object} [opts] Configuration options. + * @return {*} The value of the specified option. + */ + getOpt: function getOpt(opt, opts) { + opts || (opts = {}); + return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); + }, + + + /** + * Logging utility method. Override this method if you want to send log + * messages to something other than the console. + * + * @name Adapter#log + * @method + * @param {string} level Log level. + * @param {...*} values Values to log. + */ + log: function log(level) { + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + if (level && !args.length) { + args.push(level); + level = 'debug'; + } + if (level === 'debug' && !this.debug) { + return; } + var prefix = level.toUpperCase() + ': (Adapter)'; + if (console[level]) { + var _console; - return this.http(config).then(logResponse, function (data) { - return logResponse(data, true); - }); - } - }, { - key: 'GET', - value: function GET(url, config) { - config = config || {}; - config.method = config.method || 'get'; - config.urlOverride = !!config.url; - config.url = config.url || url; - return this.HTTP(config); - } - }, { - key: 'POST', - value: function POST(url, attrs, config) { - config = config || {}; - config.method = config.method || 'post'; - config.urlOverride = !!config.url; - config.url = config.url || url; - config.data = config.data || attrs; - return this.HTTP(config); - } - }, { - key: 'PUT', - value: function PUT(url, attrs, config) { - config = config || {}; - config.method = config.method || 'put'; - config.urlOverride = !!config.url; - config.url = config.url || url; - config.data = config.data || attrs; - return this.HTTP(config); - } - }, { - key: 'DEL', - value: function DEL(url, config) { - config = config || {}; - config.method = config.method || 'delete'; - config.urlOverride = !!config.url; - config.url = config.url || url; - return this.HTTP(config); - } - }, { - key: 'find', - value: function find(resourceConfig, id, options) { - var _this = this; - options = options ? copy(options) : {}; - options.suffix = options.suffix || resourceConfig.suffix; - options.params = options.params || {}; - options.params = _this.defaults.queryTransform(resourceConfig, options.params); - return _this.GET(_this.getPath('find', resourceConfig, id, options), options).then(function (data) { - var item = (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data); - return !item ? DSUtils.Promise.reject(new Error('Not Found!')) : item; - }); - } - }, { - key: 'findAll', - value: function findAll(resourceConfig, params, options) { - var _this = this; - options = options ? copy(options) : {}; - options.suffix = options.suffix || resourceConfig.suffix; - options.params = options.params || {}; - if (params) { - params = _this.defaults.queryTransform(resourceConfig, params); - deepMixIn(options.params, params); + (_console = console)[level].apply(_console, [prefix].concat(args)); + } else { + var _console2; + + (_console2 = console).log.apply(_console2, [prefix].concat(args)); } - return _this.GET(_this.getPath('findAll', resourceConfig, params, options), options).then(function (data) { - return (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data); - }); - } - }, { - key: 'create', - value: function create(resourceConfig, attrs, options) { - var _this = this; - options = options ? copy(options) : {}; - options.suffix = options.suffix || resourceConfig.suffix; - options.params = options.params || {}; - options.params = _this.defaults.queryTransform(resourceConfig, options.params); - return _this.POST(_this.getPath('create', resourceConfig, attrs, options), options.serialize ? options.serialize(resourceConfig, attrs) : _this.defaults.serialize(resourceConfig, attrs), options).then(function (data) { - return (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data); + }, + + + /** + * Retrieve sum of the specified field of the records that match the selection + * query. Called by `Mapper#sum`. + * + * @name Adapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field By to sum. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + var op = void 0; + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + query || (query = {}); + opts || (opts = {}); + + // beforeSum lifecycle hook + op = opts.op = 'beforeSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + self.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(self._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results8 = babelHelpers.slicedToArray(results, 2); + + var data = _results8[0]; + var result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); }); - } - }, { - key: 'update', - value: function update(resourceConfig, id, attrs, options) { - var _this = this; - options = options ? copy(options) : {}; - options.suffix = options.suffix || resourceConfig.suffix; - options.params = options.params || {}; - options.params = _this.defaults.queryTransform(resourceConfig, options.params); - return _this.PUT(_this.getPath('update', resourceConfig, id, options), options.serialize ? options.serialize(resourceConfig, attrs) : _this.defaults.serialize(resourceConfig, attrs), options).then(function (data) { - return (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data); + }, + + + /** + * @name Adapter#respond + * @method + * @param {Object} response Response object. + * @param {Object} opts Configuration options. + * return {Object} If `opts.raw == true` then return `response`, else return + * `response.data`. + */ + respond: function respond(response, opts) { + return this.getOpt('raw', opts) ? response : response.data; + }, + + + /** + * Apply the given update to the record with the specified primary key. Called + * by `Mapper#update`. + * + * @name Adapter#update + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id The primary key of the record to be updated. + * @param {Object} props The update to apply to the record. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + op = opts.op = 'update'; + self.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(self._update(mapper, id, props, opts)); + }).then(function (results) { + var _results9 = babelHelpers.slicedToArray(results, 2); + + var data = _results9[0]; + var result = _results9[1]; + + result || (result = {}); + var response = new Response(data, result, 'update'); + response.updated = data ? 1 : 0; + response = self.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); }); - } - }, { - key: 'updateAll', - value: function updateAll(resourceConfig, attrs, params, options) { - var _this = this; - options = options ? copy(options) : {}; - options.suffix = options.suffix || resourceConfig.suffix; - options.params = options.params || {}; - if (params) { - params = _this.defaults.queryTransform(resourceConfig, params); - deepMixIn(options.params, params); - } - return this.PUT(_this.getPath('updateAll', resourceConfig, attrs, options), options.serialize ? options.serialize(resourceConfig, attrs) : _this.defaults.serialize(resourceConfig, attrs), options).then(function (data) { - return (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data); + }, + + + /** + * Apply the given update to all records that match the selection query. + * Called by `Mapper#updateAll`. + * + * @name Adapter#updateAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + op = opts.op = 'updateAll'; + self.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results10 = babelHelpers.slicedToArray(results, 2); + + var data = _results10[0]; + var result = _results10[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateAll'); + response.updated = data.length; + response = self.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); }); - } - }, { - key: 'destroy', - value: function destroy(resourceConfig, id, options) { - var _this = this; - options = options ? copy(options) : {}; - options.suffix = options.suffix || resourceConfig.suffix; - options.params = options.params || {}; - options.params = _this.defaults.queryTransform(resourceConfig, options.params); - return _this.DEL(_this.getPath('destroy', resourceConfig, id, options), options).then(function (data) { - return (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data); + }, + + + /** + * Update the given records in a single batch. Called by `Mapper#updateMany`. + * + * @name Adapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + records || (records = []); + opts || (opts = {}); + var op = void 0; + var idAttribute = mapper.idAttribute; + + records = records.filter(function (record) { + return jsData.utils.get(record, idAttribute); }); - } - }, { - key: 'destroyAll', - value: function destroyAll(resourceConfig, params, options) { - var _this = this; - options = options ? copy(options) : {}; - options.suffix = options.suffix || resourceConfig.suffix; - options.params = options.params || {}; - if (params) { - params = _this.defaults.queryTransform(resourceConfig, params); - deepMixIn(options.params, params); - } - return this.DEL(_this.getPath('destroyAll', resourceConfig, params, options), options).then(function (data) { - return (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data); + + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = jsData.utils.isUndefined(_records) ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'updateMany'; + self.dbg(op, mapper, records, opts); + return jsData.utils.resolve(self._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results11 = babelHelpers.slicedToArray(results, 2); + + var data = _results11[0]; + var result = _results11[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateMany'); + response.updated = data.length; + response = self.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); }); } - }]); - - return DSHttpAdapter; - }(); - - DSHttpAdapter.version = { - full: '2.2.1', - major: parseInt('2', 10), - minor: parseInt('2', 10), - patch: parseInt('1', 10), - alpha: true ? 'false' : false, - beta: true ? 'false' : false - }; + }); - module.exports = DSHttpAdapter; - -/***/ }, -/* 1 */ -/***/ function(module, exports) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_1__; + module.exports = Adapter; + + })); + //# sourceMappingURL=js-data-adapter.js.map /***/ }, -/* 2 */ +/* 3 */ /***/ function(module, exports, __webpack_require__) { - module.exports = __webpack_require__(3); + module.exports = __webpack_require__(4); /***/ }, -/* 3 */ +/* 4 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var defaults = __webpack_require__(4); - var utils = __webpack_require__(5); - var dispatchRequest = __webpack_require__(6); - var InterceptorManager = __webpack_require__(15); - var isAbsoluteURL = __webpack_require__(16); - var combineURLs = __webpack_require__(17); - var bind = __webpack_require__(18); - var transformData = __webpack_require__(11); + var defaults = __webpack_require__(5); + var utils = __webpack_require__(6); + var dispatchRequest = __webpack_require__(7); + var InterceptorManager = __webpack_require__(16); + var isAbsoluteURL = __webpack_require__(17); + var combineURLs = __webpack_require__(18); + var bind = __webpack_require__(19); + var transformData = __webpack_require__(12); function Axios(defaultConfig) { this.defaults = utils.merge({}, defaultConfig); @@ -544,7 +3077,7 @@ return /******/ (function(modules) { // webpackBootstrap axios.all = function all(promises) { return Promise.all(promises); }; - axios.spread = __webpack_require__(19); + axios.spread = __webpack_require__(20); // Expose interceptors axios.interceptors = defaultInstance.interceptors; @@ -575,12 +3108,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 4 */ +/* 5 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var utils = __webpack_require__(5); + var utils = __webpack_require__(6); var PROTECTION_PREFIX = /^\)\]\}',?\n/; var DEFAULT_CONTENT_TYPE = { @@ -644,7 +3177,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 5 */ +/* 6 */ /***/ function(module, exports) { 'use strict'; @@ -894,7 +3427,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 6 */ +/* 7 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; @@ -916,10 +3449,10 @@ return /******/ (function(modules) { // webpackBootstrap adapter = config.adapter; } else if (typeof XMLHttpRequest !== 'undefined') { // For browsers use XHR adapter - adapter = __webpack_require__(8); + adapter = __webpack_require__(9); } else if (typeof process !== 'undefined') { // For node use HTTP adapter - adapter = __webpack_require__(8); + adapter = __webpack_require__(9); } if (typeof adapter === 'function') { @@ -932,10 +3465,10 @@ return /******/ (function(modules) { // webpackBootstrap }; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) /***/ }, -/* 7 */ +/* 8 */ /***/ function(module, exports) { // shim for using process in browser @@ -1032,17 +3565,17 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 8 */ +/* 9 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var utils = __webpack_require__(5); - var buildURL = __webpack_require__(9); - var parseHeaders = __webpack_require__(10); - var transformData = __webpack_require__(11); - var isURLSameOrigin = __webpack_require__(12); - var btoa = window.btoa || __webpack_require__(13); + var utils = __webpack_require__(6); + var buildURL = __webpack_require__(10); + var parseHeaders = __webpack_require__(11); + var transformData = __webpack_require__(12); + var isURLSameOrigin = __webpack_require__(13); + var btoa = window.btoa || __webpack_require__(14); module.exports = function xhrAdapter(resolve, reject, config) { var requestData = config.data; @@ -1117,7 +3650,7 @@ return /******/ (function(modules) { // webpackBootstrap // This is only done if running in a standard browser environment. // Specifically not if we're in a web worker, or react-native. if (utils.isStandardBrowserEnv()) { - var cookies = __webpack_require__(14); + var cookies = __webpack_require__(15); // Add xsrf header var xsrfValue = config.withCredentials || isURLSameOrigin(config.url) ? @@ -1168,12 +3701,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 9 */ +/* 10 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var utils = __webpack_require__(5); + var utils = __webpack_require__(6); function encode(val) { return encodeURIComponent(val). @@ -1241,12 +3774,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 10 */ +/* 11 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var utils = __webpack_require__(5); + var utils = __webpack_require__(6); /** * Parse headers into an object @@ -1284,12 +3817,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 11 */ +/* 12 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var utils = __webpack_require__(5); + var utils = __webpack_require__(6); /** * Transform the data for a request or a response @@ -1310,12 +3843,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 12 */ +/* 13 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var utils = __webpack_require__(5); + var utils = __webpack_require__(6); module.exports = ( utils.isStandardBrowserEnv() ? @@ -1384,7 +3917,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 13 */ +/* 14 */ /***/ function(module, exports) { 'use strict'; @@ -1426,12 +3959,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 14 */ +/* 15 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var utils = __webpack_require__(5); + var utils = __webpack_require__(6); module.exports = ( utils.isStandardBrowserEnv() ? @@ -1485,12 +4018,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 15 */ +/* 16 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var utils = __webpack_require__(5); + var utils = __webpack_require__(6); function InterceptorManager() { this.handlers = []; @@ -1543,7 +4076,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 16 */ +/* 17 */ /***/ function(module, exports) { 'use strict'; @@ -1563,7 +4096,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 17 */ +/* 18 */ /***/ function(module, exports) { 'use strict'; @@ -1581,7 +4114,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 18 */ +/* 19 */ /***/ function(module, exports) { 'use strict'; @@ -1598,7 +4131,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 19 */ +/* 20 */ /***/ function(module, exports) { 'use strict'; diff --git a/dist/js-data-http.js.map b/dist/js-data-http.js.map index 8871656..50a602c 100644 --- a/dist/js-data-http.js.map +++ b/dist/js-data-http.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 8edc9ba2dfe64e8eafd0","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/axios/index.js","webpack:///./~/axios/lib/axios.js","webpack:///./~/axios/lib/defaults.js","webpack:///./~/axios/lib/utils.js","webpack:///./~/axios/lib/core/dispatchRequest.js","webpack:///./~/process/browser.js","webpack:///./~/axios/lib/adapters/xhr.js","webpack:///./~/axios/lib/helpers/buildURL.js","webpack:///./~/axios/lib/helpers/parseHeaders.js","webpack:///./~/axios/lib/helpers/transformData.js","webpack:///./~/axios/lib/helpers/isURLSameOrigin.js","webpack:///./~/axios/lib/helpers/btoa.js","webpack:///./~/axios/lib/helpers/cookies.js","webpack:///./~/axios/lib/core/InterceptorManager.js","webpack:///./~/axios/lib/helpers/isAbsoluteURL.js","webpack:///./~/axios/lib/helpers/combineURLs.js","webpack:///./~/axios/lib/helpers/bind.js","webpack:///./~/axios/lib/help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AAP;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,QAA6B,cAA7B,GAA8C,KAA9C;AACP,SAAM,QAA4B,aAA5B,GAA4C,KAA5C;EANR;;AASA,QAAO,OAAP,GAAiB,aAAjB,C;;;;;;AC5UA,gD;;;;;;ACAA,yC;;;;;;ACAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iCAAgC;AAChC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;;AAEA,kDAAiD,gBAAgB;;AAEjE;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gCAA+B;AAC/B,wCAAuC;AACvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA,MAAK;AACL;AACA;AACA,EAAC;;AAED;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,EAAC;;;;;;;ACvHD;;AAEA;;AAEA,iCAAgC;AAChC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA,uDAAsD;AACtD;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,QAAO,YAAY;AACnB;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA,IAAG;;AAEH;;AAEA;AACA;AACA;;;;;;;AC9DA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,aAAa;AACxB,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oCAAmC,OAAO;AAC1C;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAuB,SAAS,GAAG,SAAS;AAC5C,4BAA2B;AAC3B;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;;AAEA,wCAAuC,OAAO;AAC9C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACnPA;;AAEA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,QAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,IAAG;AACH;;;;;;;;;AChCA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,wBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,4BAA2B;AAC3B;AACA;AACA;AACA,6BAA4B,UAAU;;;;;;;AC1FtC;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,2CAA0C;AAC1C;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA,MAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;ACjIA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP,MAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;;;;;;;ACjEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAiB,eAAe;;AAEhC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACpCA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,cAAc;AACzB,YAAW,MAAM;AACjB,YAAW,eAAe;AAC1B,cAAa,EAAE;AACf;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACnBA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;;;;;;ACnEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACnCA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,yCAAwC;AACxC,QAAO;;AAEP;AACA,2DAA0D,wBAAwB;AAClF;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,iCAAgC;AAChC,8BAA6B,aAAa,EAAE;AAC5C;AACA;AACA,IAAG;AACH;;;;;;;ACpDA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,SAAS;AACpB,YAAW,SAAS;AACpB;AACA,aAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;AAEA;;;;;;;ACnDA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACbA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;;;;;;;ACXA;;AAEA;AACA;AACA;AACA,oBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;;;;;;;ACVA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAA+B;AAC/B;AACA;AACA,YAAW,SAAS;AACpB,cAAa;AACb;AACA;AACA;AACA;AACA;AACA","file":"./dist/js-data-http.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"js-data\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"js-data\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"DSHttpAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"DSHttpAdapter\"] = factory(root[\"JSData\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 8edc9ba2dfe64e8eafd0\n **/","let JSData = require('js-data')\nlet axios = null\n\ntry {\n axios = require('axios')\n} catch (e) {}\n\nlet { DSUtils } = JSData\nlet { deepMixIn, removeCircular, copy, makePath, isString, isNumber } = DSUtils\n\nclass Defaults {\n queryTransform (resourceConfig, params) {\n return params\n }\n\n deserialize (resourceConfig, data) {\n return data ? ('data' in data ? data.data : data) : data\n }\n\n serialize (resourceConfig, data) {\n return data\n }\n\n log () {}\n\n error () {}\n}\n\nlet defaultsPrototype = Defaults.prototype\n\ndefaultsPrototype.basePath = ''\n\ndefaultsPrototype.forceTrailingSlash = ''\n\ndefaultsPrototype.httpConfig = {}\n\ndefaultsPrototype.verbsUseBasePath = false\n\nclass DSHttpAdapter {\n constructor (options) {\n options = options || {}\n this.defaults = new Defaults()\n if (console) {\n this.defaults.log = (a, b) => console[typeof console.info === 'function' ? 'info' : 'log'](a, b)\n }\n if (console) {\n this.defaults.error = (a, b) => console[typeof console.error === 'function' ? 'error' : 'log'](a, b)\n }\n deepMixIn(this.defaults, options)\n this.http = options.http || axios\n }\n\n getEndpoint (resourceConfig, id, options) {\n options = options || {}\n options.params = options.params || {}\n\n let endpoint = options.hasOwnProperty('endpoint') ? options.endpoint : resourceConfig.endpoint\n let parents = resourceConfig.parents || (resourceConfig.parent ? {\n [resourceConfig.parent]: {\n key: resourceConfig.parentKey,\n field: resourceConfig.parentField\n }\n } : {})\n\n DSUtils.forOwn(parents, function (parent, parentName) {\n let item\n let parentKey = parent.key\n let parentField = parent.field\n let parentDef = resourceConfig.getResource(parentName)\n let parentId = options.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete options.params[parentKey]\n }\n } else {\n delete options.params[parentKey]\n\n if (DSUtils._sn(id)) {\n item = resourceConfig.get(id)\n } else if (DSUtils._o(id)) {\n item = id\n }\n console.log('item', item)\n\n if (item) {\n parentId = parentId || item[parentKey] || (item[parentField] ? item[parentField][parentDef.idAttribute] : null)\n }\n\n if (parentId) {\n delete options.endpoint\n let _options = {}\n DSUtils.forOwn(options, (value, key) => {\n _options[key] = value\n })\n endpoint = DSUtils.makePath(this.getEndpoint(parentDef, parentId, DSUtils._(parentDef, _options)), parentId, endpoint)\n }\n }\n }, this)\n\n return endpoint\n }\n\n getPath (method, resourceConfig, id, options) {\n let _this = this\n options = options || {}\n if (isString(options.urlPath)) {\n return makePath.apply(DSUtils, [options.basePath || _this.defaults.basePath || resourceConfig.basePath, options.urlPath])\n } else {\n let args = [\n options.basePath || _this.defaults.basePath || resourceConfig.basePath,\n this.getEndpoint(resourceConfig, (isString(id) || isNumber(id) || method === 'create') ? id : null, options)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(DSUtils, args)\n }\n }\n\n HTTP (config) {\n let _this = this\n let start = new Date()\n\n // blacklist `data` as it can be large and will take a lot of time to copy\n let payload = config.data\n let cache = config.cache\n let timeout = config.timeout\n config = copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = deepMixIn(config, _this.defaults.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (!('verbsUseBasePath' in config)) {\n config.verbsUseBasePath = _this.defaults.verbsUseBasePath\n }\n if (!config.urlOverride && config.verbsUseBasePath) {\n config.url = makePath(config.basePath || _this.defaults.basePath, config.url)\n }\n if (_this.defaults.forceTrailingSlash && config.url[config.url.length - 1] !== '/' && !config.urlOverride) {\n config.url += '/'\n }\n if (typeof config.data === 'object') {\n config.data = removeCircular(config.data)\n }\n config.method = config.method.toUpperCase()\n let suffix = config.suffix || _this.defaults.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix && !config.urlOverride) {\n config.url += suffix\n }\n\n // logs the HTTP response\n function logResponse (data, isRejection) {\n data = data || {}\n // examine the data object\n if (data instanceof Error) {\n // log the Error object\n _this.defaults.error(`FAILED: ${data.message || 'Unknown Error'}`, data)\n return DSUtils.Promise.reject(data)\n } else if (typeof data === 'object') {\n let str = `${start.toUTCString()} - ${config.method} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n\n if (data.status >= 200 && data.status < 300 && !isRejection) {\n if (_this.defaults.log) {\n _this.defaults.log(str, data)\n }\n return data\n } else {\n if (_this.defaults.error) {\n _this.defaults.error(`FAILED: ${str}`, data)\n }\n return DSUtils.Promise.reject(data)\n }\n } else {\n // unknown type for 'data' that is not an Object or Error\n _this.defaults.error('FAILED', data)\n return DSUtils.Promise.reject(data)\n }\n }\n\n if (!this.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return this.http(config).then(logResponse, function (data) {\n return logResponse(data, true)\n })\n }\n\n GET (url, config) {\n config = config || {}\n config.method = config.method || 'get'\n config.urlOverride = !!config.url\n config.url = config.url || url\n return this.HTTP(config)\n }\n\n POST (url, attrs, config) {\n config = config || {}\n config.method = config.method || 'post'\n config.urlOverride = !!config.url\n config.url = config.url || url\n config.data = config.data || attrs\n return this.HTTP(config)\n }\n\n PUT (url, attrs, config) {\n config = config || {}\n config.method = config.method || 'put'\n config.urlOverride = !!config.url\n config.url = config.url || url\n config.data = config.data || attrs\n return this.HTTP(config)\n }\n\n DEL (url, config) {\n config = config || {}\n config.method = config.method || 'delete'\n config.urlOverride = !!config.url\n config.url = config.url || url\n return this.HTTP(config)\n }\n\n find (resourceConfig, id, options) {\n let _this = this\n options = options ? copy(options) : {}\n options.suffix = options.suffix || resourceConfig.suffix\n options.params = options.params || {}\n options.params = _this.defaults.queryTransform(resourceConfig, options.params)\n return _this.GET(\n _this.getPath('find', resourceConfig, id, options),\n options\n ).then((data) => {\n let item = (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data)\n return !item ? DSUtils.Promise.reject(new Error('Not Found!')) : item\n })\n }\n\n findAll (resourceConfig, params, options) {\n let _this = this\n options = options ? copy(options) : {}\n options.suffix = options.suffix || resourceConfig.suffix\n options.params = options.params || {}\n if (params) {\n params = _this.defaults.queryTransform(resourceConfig, params)\n deepMixIn(options.params, params)\n }\n return _this.GET(\n _this.getPath('findAll', resourceConfig, params, options),\n options\n ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data))\n }\n\n create (resourceConfig, attrs, options) {\n let _this = this\n options = options ? copy(options) : {}\n options.suffix = options.suffix || resourceConfig.suffix\n options.params = options.params || {}\n options.params = _this.defaults.queryTransform(resourceConfig, options.params)\n return _this.POST(\n _this.getPath('create', resourceConfig, attrs, options),\n options.serialize ? options.serialize(resourceConfig, attrs) : _this.defaults.serialize(resourceConfig, attrs),\n options\n ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data))\n }\n\n update (resourceConfig, id, attrs, options) {\n let _this = this\n options = options ? copy(options) : {}\n options.suffix = options.suffix || resourceConfig.suffix\n options.params = options.params || {}\n options.params = _this.defaults.queryTransform(resourceConfig, options.params)\n return _this.PUT(\n _this.getPath('update', resourceConfig, id, options),\n options.serialize ? options.serialize(resourceConfig, attrs) : _this.defaults.serialize(resourceConfig, attrs),\n options\n ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data))\n }\n\n updateAll (resourceConfig, attrs, params, options) {\n let _this = this\n options = options ? copy(options) : {}\n options.suffix = options.suffix || resourceConfig.suffix\n options.params = options.params || {}\n if (params) {\n params = _this.defaults.queryTransform(resourceConfig, params)\n deepMixIn(options.params, params)\n }\n return this.PUT(\n _this.getPath('updateAll', resourceConfig, attrs, options),\n options.serialize ? options.serialize(resourceConfig, attrs) : _this.defaults.serialize(resourceConfig, attrs),\n options\n ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data))\n }\n\n destroy (resourceConfig, id, options) {\n let _this = this\n options = options ? copy(options) : {}\n options.suffix = options.suffix || resourceConfig.suffix\n options.params = options.params || {}\n options.params = _this.defaults.queryTransform(resourceConfig, options.params)\n return _this.DEL(\n _this.getPath('destroy', resourceConfig, id, options),\n options\n ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data))\n }\n\n destroyAll (resourceConfig, params, options) {\n let _this = this\n options = options ? copy(options) : {}\n options.suffix = options.suffix || resourceConfig.suffix\n options.params = options.params || {}\n if (params) {\n params = _this.defaults.queryTransform(resourceConfig, params)\n deepMixIn(options.params, params)\n }\n return this.DEL(\n _this.getPath('destroyAll', resourceConfig, params, options),\n options\n ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data))\n }\n}\n\nDSHttpAdapter.version = {\n full: '<%= pkg.version %>',\n major: parseInt('<%= major %>', 10),\n minor: parseInt('<%= minor %>', 10),\n patch: parseInt('<%= patch %>', 10),\n alpha: '<%= alpha %>' !== 'false' ? '<%= alpha %>' : false,\n beta: '<%= beta %>' !== 'false' ? '<%= beta %>' : false\n}\n\nmodule.exports = DSHttpAdapter\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}\n ** module id = 1\n ** module chunks = 0\n **/","module.exports = require('./lib/axios');\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/index.js\n ** module id = 2\n ** module chunks = 0\n **/","'use strict';\n\nvar defaults = require('./defaults');\nvar utils = require('./utils');\nvar dispatchRequest = require('./core/dispatchRequest');\nvar InterceptorManager = require('./core/InterceptorManager');\nvar isAbsoluteURL = require('./helpers/isAbsoluteURL');\nvar combineURLs = require('./helpers/combineURLs');\nvar bind = require('./helpers/bind');\nvar transformData = require('./helpers/transformData');\n\nfunction Axios(defaultConfig) {\n this.defaults = utils.merge({}, defaultConfig);\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = utils.merge({\n url: arguments[0]\n }, arguments[1]);\n }\n\n config = utils.merge(defaults, this.defaults, { method: 'get' }, config);\n\n // Support baseURL config\n if (config.baseURL && !isAbsoluteURL(config.url)) {\n config.url = combineURLs(config.baseURL, config.url);\n }\n\n // Don't allow overriding defaults.withCredentials\n config.withCredentials = config.withCredentials || this.defaults.withCredentials;\n\n // Transform request data\n config.data = transformData(\n config.data,\n config.headers,\n config.transformRequest\n );\n\n // Flatten headers\n config.headers = utils.merge(\n config.headers.common || {},\n config.headers[config.method] || {},\n config.headers || {}\n );\n\n utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n function cleanHeaderConfig(method) {\n delete config.headers[method];\n }\n );\n\n // Hook up interceptors middleware\n var chain = [dispatchRequest, undefined];\n var promise = Promise.resolve(config);\n\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n chain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n chain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n};\n\nvar defaultInstance = new Axios(defaults);\nvar axios = module.exports = bind(Axios.prototype.request, defaultInstance);\n\naxios.create = function create(defaultConfig) {\n return new Axios(defaultConfig);\n};\n\n// Expose defaults\naxios.defaults = defaultInstance.defaults;\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\n// Expose interceptors\naxios.interceptors = defaultInstance.interceptors;\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url\n }));\n };\n axios[method] = bind(Axios.prototype[method], defaultInstance);\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n axios[method] = bind(Axios.prototype[method], defaultInstance);\n});\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/axios.js\n ** module id = 3\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./utils');\n\nvar PROTECTION_PREFIX = /^\\)\\]\\}',?\\n/;\nvar DEFAULT_CONTENT_TYPE = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nmodule.exports = {\n transformRequest: [function transformResponseJSON(data, headers) {\n if (utils.isFormData(data)) {\n return data;\n }\n if (utils.isArrayBuffer(data)) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) {\n // Set application/json if no Content-Type has been specified\n if (!utils.isUndefined(headers)) {\n utils.forEach(headers, function processContentTypeHeader(val, key) {\n if (key.toLowerCase() === 'content-type') {\n headers['Content-Type'] = val;\n }\n });\n\n if (utils.isUndefined(headers['Content-Type'])) {\n headers['Content-Type'] = 'application/json;charset=utf-8';\n }\n }\n return JSON.stringify(data);\n }\n return data;\n }],\n\n transformResponse: [function transformResponseJSON(data) {\n /*eslint no-param-reassign:0*/\n if (typeof data === 'string') {\n data = data.replace(PROTECTION_PREFIX, '');\n try {\n data = JSON.parse(data);\n } catch (e) { /* Ignore */ }\n }\n return data;\n }],\n\n headers: {\n common: {\n 'Accept': 'application/json, text/plain, */*'\n },\n patch: utils.merge(DEFAULT_CONTENT_TYPE),\n post: utils.merge(DEFAULT_CONTENT_TYPE),\n put: utils.merge(DEFAULT_CONTENT_TYPE)\n },\n\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN'\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/defaults.js\n ** module id = 4\n ** module chunks = 0\n **/","'use strict';\n\n/*global toString:true*/\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return toString.call(val) === '[object FormData]';\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * typeof document.createElement -> undefined\n */\nfunction isStandardBrowserEnv() {\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined' &&\n typeof document.createElement === 'function'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object' && !isArray(obj)) {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (obj.hasOwnProperty(key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (typeof result[key] === 'object' && typeof val === 'object') {\n result[key] = merge(result[key], val);\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n trim: trim\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/utils.js\n ** module id = 5\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Dispatch a request to the server using whichever adapter\n * is supported by the current environment.\n *\n * @param {object} config The config that is to be used for the request\n * @returns {Promise} The Promise to be fulfilled\n */\nmodule.exports = function dispatchRequest(config) {\n return new Promise(function executor(resolve, reject) {\n try {\n var adapter;\n\n if (typeof config.adapter === 'function') {\n // For custom adapter support\n adapter = config.adapter;\n } else if (typeof XMLHttpRequest !== 'undefined') {\n // For browsers use XHR adapter\n adapter = require('../adapters/xhr');\n } else if (typeof process !== 'undefined') {\n // For node use HTTP adapter\n adapter = require('../adapters/http');\n }\n\n if (typeof adapter === 'function') {\n adapter(resolve, reject, config);\n }\n } catch (e) {\n reject(e);\n }\n });\n};\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/core/dispatchRequest.js\n ** module id = 6\n ** module chunks = 0\n **/","// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/process/browser.js\n ** module id = 7\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\nvar buildURL = require('./../helpers/buildURL');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar transformData = require('./../helpers/transformData');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar btoa = window.btoa || require('./../helpers/btoa');\n\nmodule.exports = function xhrAdapter(resolve, reject, config) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n\n // For IE 8/9 CORS support\n // Only supports POST and GET calls and doesn't returns the response headers.\n if (window.XDomainRequest && !('withCredentials' in request) && !isURLSameOrigin(config.url)) {\n request = new window.XDomainRequest();\n }\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password || '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n // Listen for ready state\n request.onload = function handleLoad() {\n if (!request) {\n return;\n }\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = ['text', ''].indexOf(config.responseType || '') !== -1 ? request.responseText : request.response;\n var response = {\n data: transformData(\n responseData,\n responseHeaders,\n config.transformResponse\n ),\n // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)\n status: request.status === 1223 ? 204 : request.status,\n statusText: request.status === 1223 ? 'No Content' : request.statusText,\n headers: responseHeaders,\n config: config\n };\n\n // Resolve or reject the Promise based on the status\n ((response.status >= 200 && response.status < 300) ||\n (!('status' in request) && response.responseText) ?\n resolve :\n reject)(response);\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(new Error('Network Error'));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n var cookies = require('./../helpers/cookies');\n\n // Add xsrf header\n var xsrfValue = config.withCredentials || isURLSameOrigin(config.url) ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (config.withCredentials) {\n request.withCredentials = true;\n }\n\n // Add responseType to request if needed\n if (config.responseType) {\n try {\n request.responseType = config.responseType;\n } catch (e) {\n if (request.responseType !== 'json') {\n throw e;\n }\n }\n }\n\n if (utils.isArrayBuffer(requestData)) {\n requestData = new DataView(requestData);\n }\n\n // Send the request\n request.send(requestData);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/adapters/xhr.js\n ** module id = 8\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nfunction encode(val) {\n return encodeURIComponent(val).\n replace(/%40/gi, '@').\n replace(/%3A/gi, ':').\n replace(/%24/g, '$').\n replace(/%2C/gi, ',').\n replace(/%20/g, '+').\n replace(/%5B/gi, '[').\n replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @returns {string} The formatted url\n */\nmodule.exports = function buildURL(url, params, paramsSerializer) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n\n var serializedParams;\n if (paramsSerializer) {\n serializedParams = paramsSerializer(params);\n } else {\n var parts = [];\n\n utils.forEach(params, function serialize(val, key) {\n if (val === null || typeof val === 'undefined') {\n return;\n }\n\n if (utils.isArray(val)) {\n key = key + '[]';\n }\n\n if (!utils.isArray(val)) {\n val = [val];\n }\n\n utils.forEach(val, function parseValue(v) {\n if (utils.isDate(v)) {\n v = v.toISOString();\n } else if (utils.isObject(v)) {\n v = JSON.stringify(v);\n }\n parts.push(encode(key) + '=' + encode(v));\n });\n });\n\n serializedParams = parts.join('&');\n }\n\n if (serializedParams) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n};\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/buildURL.js\n ** module id = 9\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n });\n\n return parsed;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/parseHeaders.js\n ** module id = 10\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Object|String} data The data to be transformed\n * @param {Array} headers The headers for the request or response\n * @param {Array|Function} fns A single function or Array of functions\n * @returns {*} The resulting transformed data\n */\nmodule.exports = function transformData(data, headers, fns) {\n /*eslint no-param-reassign:0*/\n utils.forEach(fns, function transform(fn) {\n data = fn(data, headers);\n });\n\n return data;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/transformData.js\n ** module id = 11\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/isURLSameOrigin.js\n ** module id = 12\n ** module chunks = 0\n **/","'use strict';\n\n// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js\n\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\nfunction InvalidCharacterError(message) {\n this.message = message;\n}\nInvalidCharacterError.prototype = new Error;\nInvalidCharacterError.prototype.code = 5;\nInvalidCharacterError.prototype.name = 'InvalidCharacterError';\n\nfunction btoa(input) {\n var str = String(input);\n var output = '';\n for (\n // initialize result and counter\n var block, charCode, idx = 0, map = chars;\n // if the next str index does not exist:\n // change the mapping table to \"=\"\n // check if d has no fractional digits\n str.charAt(idx | 0) || (map = '=', idx % 1);\n // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n ) {\n charCode = str.charCodeAt(idx += 3 / 4);\n if (charCode > 0xFF) {\n throw new InvalidCharacterError('INVALID_CHARACTER_ERR: DOM Exception 5');\n }\n block = block << 8 | charCode;\n }\n return output;\n}\n\nmodule.exports = btoa;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/btoa.js\n ** module id = 13\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs support document.cookie\n (function standardBrowserEnv() {\n return {\n write: function write(name, value, expires, path, domain, secure) {\n var cookie = [];\n cookie.push(name + '=' + encodeURIComponent(value));\n\n if (utils.isNumber(expires)) {\n cookie.push('expires=' + new Date(expires).toGMTString());\n }\n\n if (utils.isString(path)) {\n cookie.push('path=' + path);\n }\n\n if (utils.isString(domain)) {\n cookie.push('domain=' + domain);\n }\n\n if (secure === true) {\n cookie.push('secure');\n }\n\n document.cookie = cookie.join('; ');\n },\n\n read: function read(name) {\n var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove: function remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n };\n })() :\n\n // Non standard browser env (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return {\n write: function write() {},\n read: function read() { return null; },\n remove: function remove() {}\n };\n })()\n);\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/cookies.js\n ** module id = 14\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/core/InterceptorManager.js\n ** module id = 15\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nmodule.exports = function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/isAbsoluteURL.js\n ** module id = 16\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n * @returns {string} The combined URL\n */\nmodule.exports = function combineURLs(baseURL, relativeURL) {\n return baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '');\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/combineURLs.js\n ** module id = 17\n ** module chunks = 0\n **/","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/bind.js\n ** module id = 18\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n * @returns {Function}\n */\nmodule.exports = function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/spread.js\n ** module id = 19\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 878550722cb11aefdcf8","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/js-data-adapter/dist/js-data-adapter.js","webpack:///./~/axios/index.js","webpack:///./~/axios/lib/axios.js","webpack:///./~/axios/lib/defaults.js","webpack:///./~/axios/lib/utils.js","webpack:///./~/axios/lib/core/dispatchRequest.js","webpack:///./~/process/browser.js","webpack:///./~/axios/lib/adapters/xhr.js","webpack:///./~/axios/lib/helpers/buildURL.js","webpack:///./~/axios/lib/helpers/parseHeaders.js","webpack:///./~/axios/lib/helpers/transformData.js","webpack:///./~/axios/lib/helpers/isURLSameOrigin.js","webpack:///./~/axios/lib/helpers/btoa.js","webpack:///./~/axios/lib/helpers/cookies.js","webpack:///./~/axios/lib/core/InterceptorManager.js","webpack:///./~/axios/lib/helpers/isAbsoluteURL.js","webpack:///./~/axios/lib/helpers/combineURLs.js","webpack:///./~/axios/lib/helpers/bind.js","webpack:///./~/axios/lib/helpers/spread.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;ACpCA;;AACA;;;;;;;AAFA,KAAM,QAAQ,oBAAQ,CAAR,CAAR;;;AAIN,KAAI,WAAW,KAAX;;AAEJ,KAAI;AACF,cAAW,UAAU,OAAO,KAAP,CADnB;EAAJ,CAEE,OAAO,CAAP,EAAU,EAAV;;AAEF,KAAM,OAAO,SAAP,IAAO,GAAmB;AAC9B,OAAM,OAAO,IAAP,CADwB;;qCAAN;;IAAM;;AAE9B,OAAM,OAAO,KAAK,KAAK,MAAL,GAAc,CAAd,CAAZ,CAFwB;AAG9B,QAAK,GAAL,cAAS,KAAK,EAAL,SAAY,KAArB,EAH8B;AAI9B,UAAO,cAAM,OAAN,EAAP,CAJ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KAA3B,EAAkC,MAAlC,EADyC;MAAtB,CAArB,CADuB;AAIvB,YAAO,MAAP,CAJuB;IAAlB,CAFgC;EAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDzB,aAAY,MAAZ,GAAqB,cAAM,MAAN;;;;;;;;;;;;;;;;AAgBrB,aAAY,OAAZ,GAAsB,gBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,QAAO,OAAP,GAAiB,WAAjB,C;;;;;;AC3uCA,gD;;;;;;ACAA;AACA;AACA;AACA;AACA,EAAC,0BAA0B;;AAE3B;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;AACL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kDAAiD,+BAA+B;AAChF;;AAEA;AACA;AACA,QAAO;AACP;AACA;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA,QAAO;AACP;AACA;AACA;AACA,IAAG;;AAEH;;AAEA;AACA;;AAEA,oEAAmE,aAAa;AAChF;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,uEAAsE,eAAe;AACrF;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB,cAAa,QAAQ;AACrB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,uBAAsB;AACtB;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,iBAAgB,OAAO;AACvB,iBAAgB,OAAO;AACvB;AACA;AACA;AACA,uBAAsB;AACtB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB;AACA,cAAa,OAAO;AACpB;AACA,eAAc,OAAO;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,6BAA6B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,8BAA8B,eAAe;AAC9E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,+BAA+B,eAAe;AAC7E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,gCAAgC,eAAe;AAChF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,iCAAiC,eAAe;AAC/E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAwE,eAAe;AACvF;AACA;;AAEA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA,oDAAmD;AACnD;AACA;AACA,kBAAiB;AACjB,gBAAe;AACf,cAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA,gBAAe;AACf;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA,gDAA+C;AAC/C;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA,QAAO;AACP,+CAA8C;AAC9C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,QAAO;AACP,gDAA+C;AAC/C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,iBAAgB,EAAE;AAClB;AACA;AACA,yBAAwB;AACxB;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,KAAK;AACpB;AACA;AACA,6FAA4F,eAAe;AAC3G;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,QAAO;AACP;;AAEA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;AACxB;AACA;;AAEA;AACA;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP;AACA,IAAG;;AAEH;;AAEA,EAAC;AACD,4C;;;;;;AC3lDA,yC;;;;;;ACAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iCAAgC;AAChC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;;AAEA,kDAAiD,gBAAgB;;AAEjE;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gCAA+B;AAC/B,wCAAuC;AACvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA,MAAK;AACL;AACA;AACA,EAAC;;AAED;AACA;AACA;AACA,iDAAgD;AAChD;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,EAAC;;;;;;;ACvHD;;AAEA;;AAEA,iCAAgC;AAChC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA,uDAAsD;AACtD;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,QAAO,YAAY;AACnB;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA,IAAG;;AAEH;;AAEA;AACA;AACA;;;;;;;AC9DA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,aAAa;AACxB,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oCAAmC,OAAO;AAC1C;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAuB,SAAS,GAAG,SAAS;AAC5C,4BAA2B;AAC3B;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;;AAEA,wCAAuC,OAAO;AAC9C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACnPA;;AAEA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,QAAO;AACP;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,IAAG;AACH;;;;;;;;;AChCA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,wBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,4BAA2B;AAC3B;AACA;AACA;AACA,6BAA4B,UAAU;;;;;;;AC1FtC;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,2CAA0C;AAC1C;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA,MAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;ACjIA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP,MAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;;;;;;;ACjEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAiB,eAAe;;AAEhC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACpCA;;AAEA;;AAEA;AACA;AACA;AACA,YAAW,cAAc;AACzB,YAAW,MAAM;AACjB,YAAW,eAAe;AAC1B,cAAa,EAAE;AACf;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;;;;;;;ACnBA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,iBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;;;;;;ACnEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;ACnCA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,yCAAwC;AACxC,QAAO;;AAEP;AACA,2DAA0D,wBAAwB;AAClF;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,iCAAgC;AAChC,8BAA6B,aAAa,EAAE;AAC5C;AACA;AACA,IAAG;AACH;;;;;;;ACpDA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAW,SAAS;AACpB,YAAW,SAAS;AACpB;AACA,aAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW,SAAS;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;;AAEA;;;;;;;ACnDA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACbA;;AAEA;AACA;AACA;AACA,YAAW,OAAO;AAClB,YAAW,OAAO;AAClB,cAAa,OAAO;AACpB;AACA;AACA;AACA;;;;;;;ACXA;;AAEA;AACA;AACA;AACA,oBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;;;;;;;ACVA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAA+B;AAC/B;AACA;AACA,YAAW,SAAS;AACpB,cAAa;AACb;AACA;AACA;AACA;AACA;AACA","file":"./dist/js-data-http.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"js-data\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"js-data\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"HttpAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"HttpAdapter\"] = factory(root[\"JSData\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 878550722cb11aefdcf8\n **/","/* global fetch:true Headers:true Request:true */\nconst axios = require('axios')\nimport {utils} from 'js-data'\nimport Adapter from 'js-data-adapter'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nconst noop2 = function (...args) {\n const self = this\n const opts = args[args.length - 2]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:\\/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (window.toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n // Default and user-defined settings\n /**\n * @name HttpAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n */\n forceTrailingSlash: false,\n\n /**\n * @name HttpAdapter#http\n * @type {Function}\n */\n http: axios,\n\n /**\n * @name HttpAdapter#httpConfig\n * @type {Object}\n */\n httpConfig: {},\n\n /**\n * @name HttpAdapter#suffix\n * @type {string}\n */\n suffix: '',\n\n /**\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @class HttpAdapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {boolean} [opts.forceTrailingSlash=false] TODO\n * @param {Object} [opts.http=axios] TODO\n * @param {Object} [opts.httpConfig={}] TODO\n * @param {string} [opts.suffix=''] TODO\n * @param {boolean} [opts.useFetch=false] TODO\n */\nfunction HttpAdapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nHttpAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: HttpAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(HttpAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\nutils.addHiddenPropsToTarget(HttpAdapter.prototype, {\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {Object} url\n * @param {Object} config\n * @param {Object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {Object} url\n * @param {Object} config\n * @param {Object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {Object} config\n * @param {Object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {Object} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {Object} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('count', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('create', mapper, props, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('createMany', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroy', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroyAll', mapper, null, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n const self = this\n return self.GET(\n self.getPath('find', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n return self.GET(\n self.getPath('sum', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n return self.PUT(\n self.getPath('update', mapper, id, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateAll', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateMany', mapper, null, opts),\n self.serialize(mapper, records, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params.count = true\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.count.call(self, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props Properties to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.create.call(self, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.createMany.call(self, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {Object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'DEL'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {Object} mapper The mapper used for the operation.\n * @param {Object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {Object} opts Configuration options.\n * @return {(Object|Array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroy.call(self, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroyAll.call(self, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {Object} config Request configuration.\n * @param {Object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {Object} config.headers Headers for the request.\n * @param {Object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n * @param {Object} [opts] Configuration options.\n */\n fetch (config, opts) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers)\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json().then(function (data) {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.find.call(self, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.findAll.call(self, mapper, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {Object} config Request configuration options.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'GET'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {boolean} opts TODO\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach(function (def) {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, function (value, key) {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method TODO\n * @param {Object} mapper TODO\n * @param {(string|number)?} id TODO\n * @param {Object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const args = [\n utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath,\n self.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.params)) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.suffix)) {\n if (utils.isUndefined(mapper.suffix)) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {Object} config Request configuration options.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const self = this\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, self.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || self.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n function logResponse (data) {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (self.log) {\n self.dbg('debug', str, data)\n }\n return data\n } else {\n if (self.error) {\n self.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!self.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) {\n config = _config || config\n if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) {\n return self.fetch(config, opts).then(logResponse, logResponse)\n }\n return self.http(config).then(logResponse, logResponse).catch(function (err) {\n return self.responseError(err, config, opts)\n })\n }).then(function (response) {\n return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) {\n return _response || response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'POST'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'PUT'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {Object} mapper TODO\n * @param {*} params TODO\n * @param {*} opts TODO\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {Object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {Object} mapper TODO\n * @param {Object} data TODO\n * @param {*} opts TODO\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n if (!utils.utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = self.getParams(opts)\n opts.params.sum = field\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.sum.call(self, mapper, field, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#update\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {*} props TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.update.call(self, mapper, id, props, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {Object} mapper TODO\n * @param {Object} props TODO\n * @param {Object} query TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateAll.call(self, mapper, props, query, opts)\n },\n\n /**\n * Update multiple records in batch.\n *\n * {@link HttpAdapter#beforeUpdateMany} will be called before calling\n * {@link HttpAdapter#PUT}.\n * {@link HttpAdapter#afterUpdateMany} will be called after calling\n * {@link HttpAdapter#PUT}.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} records Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateMany.call(self, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @name HttpAdapter.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {Object} [opts] Action configuration\n * @param {string} [opts.adapter]\n * @param {string} [opts.pathname]\n * @param {Function} [opts.request]\n * @param {Function} [opts.response]\n * @param {Function} [opts.responseError]\n * @return {Function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nHttpAdapter.addAction = function (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n const self = this\n if (utils.isObject(id)) {\n _opts = id\n }\n _opts = _opts || {}\n let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http')\n let config = {}\n utils.fillIn(config, opts)\n if (!_opts.hasOwnProperty('endpoint') && config.endpoint) {\n _opts.endpoint = config.endpoint\n }\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(self, _opts)\n } else {\n let args = [\n _opts.basePath || self.basePath || adapter.basePath,\n adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n config.method = config.method || 'GET'\n config.mapper = self.name\n utils.deepMixIn(config)(_opts)\n return utils.resolve(config)\n .then(_opts.request || opts.request)\n .then(function (config) { return adapter.HTTP(config) })\n .then(function (data) {\n if (data && data.config) {\n data.config.mapper = self.name\n }\n return data\n })\n .then(_opts.response || opts.response, _opts.responseError || opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @name HttpAdapter.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 */\nHttpAdapter.addActions = function (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(mapper, function (value, key) {\n HttpAdapter.addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Alternative to ES6 class syntax for extending `HttpAdapter`.\n *\n * __ES6__:\n * ```javascript\n * class MyHttpAdapter extends HttpAdapter {\n * deserialize (Model, data, opts) {\n * const data = super.deserialize(Model, data, opts)\n * data.foo = 'bar'\n * return data\n * }\n * }\n * ```\n *\n * __ES5__:\n * ```javascript\n * var instanceProps = {\n * // override deserialize\n * deserialize: function (Model, data, opts) {\n * var Ctor = this.constructor\n * var superDeserialize = (Ctor.__super__ || Object.getPrototypeOf(Ctor)).deserialize\n * // call the super deserialize\n * var data = superDeserialize(Model, data, opts)\n * data.foo = 'bar'\n * return data\n * },\n * say: function () { return 'hi' }\n * }\n * var classProps = {\n * yell: function () { return 'HI' }\n * }\n *\n * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps)\n * var adapter = new MyHttpAdapter()\n * adapter.say() // \"hi\"\n * MyHttpAdapter.yell() // \"HI\"\n * ```\n *\n * @name HttpAdapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `HttpAdapter`.\n */\nHttpAdapter.extend = utils.extend\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name HttpAdapter.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 */\nHttpAdapter.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 * __Script tag__:\n * ```javascript\n * window.HttpAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var HttpAdapter = require('js-data-http')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import HttpAdapter from 'js-data-http'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-http'], function (HttpAdapter) { ... })\n * ```\n *\n * @module js-data-http\n */\n\nmodule.exports = HttpAdapter\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}\n ** module id = 1\n ** module chunks = 0\n **/","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('js-data')) :\n typeof define === 'function' && define.amd ? define('js-data-adapter', ['js-data'], factory) :\n (factory(global.JSData));\n}(this, function (jsData) { 'use strict';\n\n var babelHelpers = {};\n babelHelpers.typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n };\n\n babelHelpers.defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n };\n\n babelHelpers.slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n }();\n\n babelHelpers;\n\n var noop = function noop() {\n var self = this;\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var opts = args[args.length - 1];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var noop2 = function noop2() {\n var self = this;\n\n for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n var opts = args[args.length - 2];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var unique = function unique(array) {\n var seen = {};\n var final = [];\n array.forEach(function (item) {\n if (item in seen) {\n return;\n }\n final.push(item);\n seen[item] = 0;\n });\n return final;\n };\n\n var withoutRelations = function withoutRelations(mapper, props) {\n return jsData.utils.omit(props, mapper.relationFields || []);\n };\n\n var DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n };\n\n /**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\n function Adapter(opts) {\n var self = this;\n opts || (opts = {});\n jsData.utils.fillIn(opts, DEFAULTS);\n jsData.utils.fillIn(self, opts);\n }\n\n Adapter.reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where'];\n\n /**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @typedef {Object} Response\n * @property {Object} data Response data.\n * @property {string} op The operation for which the response was created.\n */\n function Response(data, meta, op) {\n var self = this;\n meta || (meta = {});\n self.data = data;\n jsData.utils.fillIn(self, meta);\n self.op = op;\n }\n\n Adapter.Response = Response;\n\n /**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\n Adapter.extend = jsData.utils.extend;\n\n jsData.utils.addHiddenPropsToTarget(Adapter.prototype, {\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} props The `props` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg: function dbg() {\n for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n\n this.log.apply(this, ['debug'].concat(args));\n },\n\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count: function count(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._count(mapper, query, opts));\n }).then(function (results) {\n var _results = babelHelpers.slicedToArray(results, 2);\n\n var data = _results[0];\n var result = _results[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create: function create(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'create';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._create(mapper, props, opts));\n }).then(function (results) {\n var _results2 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results2[0];\n var result = _results2[1];\n\n result || (result = {});\n var response = new Response(data, result, 'create');\n response.created = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany: function createMany(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = props.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'createMany';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._createMany(mapper, props, opts));\n }).then(function (results) {\n var _results3 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results3[0];\n var result = _results3[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'createMany');\n response.created = data.length;\n response = self.respond(response, opts);\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy: function destroy(mapper, id, opts) {\n var self = this;\n var op = void 0;\n opts || (opts = {});\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._destroy(mapper, id, opts));\n }).then(function (results) {\n var _results4 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results4[0];\n var result = _results4[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroy');\n response = self.respond(response, opts);\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll: function destroyAll(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._destroyAll(mapper, query, opts));\n }).then(function (results) {\n var _results5 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results5[0];\n var result = _results5[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroyAll');\n response = self.respond(response, opts);\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\n\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) {\n var localKeys = [];\n var itemKeys = jsData.utils.get(record, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n localKeys = localKeys.concat(itemKeys);\n return unique(localKeys).filter(function (x) {\n return x;\n });\n },\n\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) {\n return jsData.utils.get(record, mapper.idAttribute);\n },\n\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany: function loadHasMany(mapper, def, records, __opts) {\n var self = this;\n var singular = false;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n singular = true;\n records = [records];\n }\n var IDs = records.map(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record);\n });\n var query = {\n where: {}\n };\n var criteria = query.where[def.foreignKey] = {};\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0];\n } else {\n criteria['in'] = IDs.filter(function (id) {\n return id;\n });\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n var attached = [];\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems;\n } else {\n relatedItems.forEach(function (relatedItem) {\n if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem);\n }\n });\n }\n def.setLocalField(record, attached);\n });\n });\n },\n loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) {\n var self = this;\n var record = void 0;\n var relatedMapper = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n var _ret = function () {\n var localKeys = [];\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record));\n });\n return {\n v: self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': unique(localKeys).filter(function (x) {\n return x;\n })\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n var attached = [];\n var itemKeys = jsData.utils.get(item, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n relatedItems.forEach(function (relatedItem) {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem);\n }\n });\n def.setLocalField(item, attached);\n });\n return relatedItems;\n })\n };\n }();\n\n if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === \"object\") return _ret.v;\n }\n },\n loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) {\n var self = this;\n var relatedMapper = def.getRelation();\n var idAttribute = mapper.idAttribute;\n var record = void 0;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(def.getRelation(), {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record);\n })\n })\n }, __opts).then(function (relatedItems) {\n var foreignKeysField = def.foreignKeys;\n records.forEach(function (record) {\n var _relatedItems = [];\n var id = jsData.utils.get(record, idAttribute);\n relatedItems.forEach(function (relatedItem) {\n var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || [];\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem);\n }\n });\n def.setLocalField(record, _relatedItems);\n });\n });\n }\n },\n\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne: function loadHasOne(mapper, def, records, __opts) {\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n records = [records];\n }\n return this.loadHasMany(mapper, def, records, __opts).then(function () {\n records.forEach(function (record) {\n var relatedData = def.getLocalField(record);\n if (jsData.utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0]);\n }\n });\n });\n },\n\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\n\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) {\n var self = this;\n var relationDef = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n var _ret2 = function () {\n var record = records;\n return {\n v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem);\n })\n };\n }();\n\n if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === \"object\") return _ret2.v;\n } else {\n var keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record);\n }).filter(function (key) {\n return key;\n });\n return self.findAll(relationDef, {\n where: babelHelpers.defineProperty({}, relationDef.idAttribute, {\n 'in': keys\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem);\n }\n });\n });\n });\n }\n },\n\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find: function find(mapper, id, opts) {\n var self = this;\n var record = void 0,\n op = void 0;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._find(mapper, id, opts));\n }).then(function (results) {\n var _results6 = babelHelpers.slicedToArray(results, 1);\n\n var _record = _results6[0];\n\n if (!_record) {\n return;\n }\n record = _record;\n var tasks = [];\n\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts);\n } else {\n task = self.loadHasMany(mapper, def, record, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(record, {}, 'find');\n response.found = record ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll: function findAll(mapper, query, opts) {\n var self = this;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n var records = [];\n var op = void 0;\n var activeWith = opts._activeWith;\n\n if (jsData.utils.isObject(activeWith)) {\n var activeQuery = activeWith.query || {};\n if (activeWith.replace) {\n query = activeQuery;\n } else {\n jsData.utils.deepFillIn(query, activeQuery);\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._findAll(mapper, query, opts));\n }).then(function (results) {\n var _results7 = babelHelpers.slicedToArray(results, 1);\n\n var _records = _results7[0];\n\n _records || (_records = []);\n records = _records;\n var tasks = [];\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts);\n } else {\n task = self.loadHasOne(mapper, def, records, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(records, {}, 'findAll');\n response.found = records.length;\n response = self.respond(response, opts);\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt: function getOpt(opt, opts) {\n opts || (opts = {});\n return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]);\n },\n\n\n /**\n * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log: function log(level) {\n for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n args[_key4 - 1] = arguments[_key4];\n }\n\n if (level && !args.length) {\n args.push(level);\n level = 'debug';\n }\n if (level === 'debug' && !this.debug) {\n return;\n }\n var prefix = level.toUpperCase() + ': (Adapter)';\n if (console[level]) {\n var _console;\n\n (_console = console)[level].apply(_console, [prefix].concat(args));\n } else {\n var _console2;\n\n (_console2 = console).log.apply(_console2, [prefix].concat(args));\n }\n },\n\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum: function sum(mapper, field, query, opts) {\n var self = this;\n var op = void 0;\n if (!jsData.utils.isString(field)) {\n throw new Error('field must be a string!');\n }\n query || (query = {});\n opts || (opts = {});\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum';\n return jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum';\n self.dbg(op, mapper, field, query, opts);\n return jsData.utils.resolve(self._sum(mapper, field, query, opts));\n }).then(function (results) {\n var _results8 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results8[0];\n var result = _results8[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum';\n return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond: function respond(response, opts) {\n return this.getOpt('raw', opts) ? response : response.data;\n },\n\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update: function update(mapper, id, props, opts) {\n var self = this;\n props || (props = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n op = opts.op = 'update';\n self.dbg(op, mapper, id, props, opts);\n return jsData.utils.resolve(self._update(mapper, id, props, opts));\n }).then(function (results) {\n var _results9 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results9[0];\n var result = _results9[1];\n\n result || (result = {});\n var response = new Response(data, result, 'update');\n response.updated = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll: function updateAll(mapper, props, query, opts) {\n var self = this;\n props || (props = {});\n query || (query = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n op = opts.op = 'updateAll';\n self.dbg(op, mapper, props, query, opts);\n return jsData.utils.resolve(self._updateAll(mapper, props, query, opts));\n }).then(function (results) {\n var _results10 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results10[0];\n var result = _results10[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateAll');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany: function updateMany(mapper, records, opts) {\n var self = this;\n records || (records = []);\n opts || (opts = {});\n var op = void 0;\n var idAttribute = mapper.idAttribute;\n\n records = records.filter(function (record) {\n return jsData.utils.get(record, idAttribute);\n });\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = jsData.utils.isUndefined(_records) ? records : _records;\n records = records.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'updateMany';\n self.dbg(op, mapper, records, opts);\n return jsData.utils.resolve(self._updateMany(mapper, records, opts));\n }).then(function (results) {\n var _results11 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results11[0];\n var result = _results11[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateMany');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n }\n });\n\n module.exports = Adapter;\n\n}));\n//# sourceMappingURL=js-data-adapter.js.map\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/js-data-adapter/dist/js-data-adapter.js\n ** module id = 2\n ** module chunks = 0\n **/","module.exports = require('./lib/axios');\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/index.js\n ** module id = 3\n ** module chunks = 0\n **/","'use strict';\n\nvar defaults = require('./defaults');\nvar utils = require('./utils');\nvar dispatchRequest = require('./core/dispatchRequest');\nvar InterceptorManager = require('./core/InterceptorManager');\nvar isAbsoluteURL = require('./helpers/isAbsoluteURL');\nvar combineURLs = require('./helpers/combineURLs');\nvar bind = require('./helpers/bind');\nvar transformData = require('./helpers/transformData');\n\nfunction Axios(defaultConfig) {\n this.defaults = utils.merge({}, defaultConfig);\n this.interceptors = {\n request: new InterceptorManager(),\n response: new InterceptorManager()\n };\n}\n\nAxios.prototype.request = function request(config) {\n /*eslint no-param-reassign:0*/\n // Allow for axios('example/url'[, config]) a la fetch API\n if (typeof config === 'string') {\n config = utils.merge({\n url: arguments[0]\n }, arguments[1]);\n }\n\n config = utils.merge(defaults, this.defaults, { method: 'get' }, config);\n\n // Support baseURL config\n if (config.baseURL && !isAbsoluteURL(config.url)) {\n config.url = combineURLs(config.baseURL, config.url);\n }\n\n // Don't allow overriding defaults.withCredentials\n config.withCredentials = config.withCredentials || this.defaults.withCredentials;\n\n // Transform request data\n config.data = transformData(\n config.data,\n config.headers,\n config.transformRequest\n );\n\n // Flatten headers\n config.headers = utils.merge(\n config.headers.common || {},\n config.headers[config.method] || {},\n config.headers || {}\n );\n\n utils.forEach(\n ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n function cleanHeaderConfig(method) {\n delete config.headers[method];\n }\n );\n\n // Hook up interceptors middleware\n var chain = [dispatchRequest, undefined];\n var promise = Promise.resolve(config);\n\n this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n chain.unshift(interceptor.fulfilled, interceptor.rejected);\n });\n\n this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n chain.push(interceptor.fulfilled, interceptor.rejected);\n });\n\n while (chain.length) {\n promise = promise.then(chain.shift(), chain.shift());\n }\n\n return promise;\n};\n\nvar defaultInstance = new Axios(defaults);\nvar axios = module.exports = bind(Axios.prototype.request, defaultInstance);\n\naxios.create = function create(defaultConfig) {\n return new Axios(defaultConfig);\n};\n\n// Expose defaults\naxios.defaults = defaultInstance.defaults;\n\n// Expose all/spread\naxios.all = function all(promises) {\n return Promise.all(promises);\n};\naxios.spread = require('./helpers/spread');\n\n// Expose interceptors\naxios.interceptors = defaultInstance.interceptors;\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url\n }));\n };\n axios[method] = bind(Axios.prototype[method], defaultInstance);\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n /*eslint func-names:0*/\n Axios.prototype[method] = function(url, data, config) {\n return this.request(utils.merge(config || {}, {\n method: method,\n url: url,\n data: data\n }));\n };\n axios[method] = bind(Axios.prototype[method], defaultInstance);\n});\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/axios.js\n ** module id = 4\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./utils');\n\nvar PROTECTION_PREFIX = /^\\)\\]\\}',?\\n/;\nvar DEFAULT_CONTENT_TYPE = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n};\n\nmodule.exports = {\n transformRequest: [function transformResponseJSON(data, headers) {\n if (utils.isFormData(data)) {\n return data;\n }\n if (utils.isArrayBuffer(data)) {\n return data;\n }\n if (utils.isArrayBufferView(data)) {\n return data.buffer;\n }\n if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) {\n // Set application/json if no Content-Type has been specified\n if (!utils.isUndefined(headers)) {\n utils.forEach(headers, function processContentTypeHeader(val, key) {\n if (key.toLowerCase() === 'content-type') {\n headers['Content-Type'] = val;\n }\n });\n\n if (utils.isUndefined(headers['Content-Type'])) {\n headers['Content-Type'] = 'application/json;charset=utf-8';\n }\n }\n return JSON.stringify(data);\n }\n return data;\n }],\n\n transformResponse: [function transformResponseJSON(data) {\n /*eslint no-param-reassign:0*/\n if (typeof data === 'string') {\n data = data.replace(PROTECTION_PREFIX, '');\n try {\n data = JSON.parse(data);\n } catch (e) { /* Ignore */ }\n }\n return data;\n }],\n\n headers: {\n common: {\n 'Accept': 'application/json, text/plain, */*'\n },\n patch: utils.merge(DEFAULT_CONTENT_TYPE),\n post: utils.merge(DEFAULT_CONTENT_TYPE),\n put: utils.merge(DEFAULT_CONTENT_TYPE)\n },\n\n timeout: 0,\n\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN'\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/defaults.js\n ** module id = 5\n ** module chunks = 0\n **/","'use strict';\n\n/*global toString:true*/\n\n// utils is a library of generic helper functions non-specific to axios\n\nvar toString = Object.prototype.toString;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Array, otherwise false\n */\nfunction isArray(val) {\n return toString.call(val) === '[object Array]';\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nfunction isArrayBuffer(val) {\n return toString.call(val) === '[object ArrayBuffer]';\n}\n\n/**\n * Determine if a value is a FormData\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nfunction isFormData(val) {\n return toString.call(val) === '[object FormData]';\n}\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n var result;\n if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n result = ArrayBuffer.isView(val);\n } else {\n result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);\n }\n return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a String, otherwise false\n */\nfunction isString(val) {\n return typeof val === 'string';\n}\n\n/**\n * Determine if a value is a Number\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Number, otherwise false\n */\nfunction isNumber(val) {\n return typeof val === 'number';\n}\n\n/**\n * Determine if a value is undefined\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nfunction isUndefined(val) {\n return typeof val === 'undefined';\n}\n\n/**\n * Determine if a value is an Object\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is an Object, otherwise false\n */\nfunction isObject(val) {\n return val !== null && typeof val === 'object';\n}\n\n/**\n * Determine if a value is a Date\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Date, otherwise false\n */\nfunction isDate(val) {\n return toString.call(val) === '[object Date]';\n}\n\n/**\n * Determine if a value is a File\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a File, otherwise false\n */\nfunction isFile(val) {\n return toString.call(val) === '[object File]';\n}\n\n/**\n * Determine if a value is a Blob\n *\n * @param {Object} val The value to test\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nfunction isBlob(val) {\n return toString.call(val) === '[object Blob]';\n}\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n * @returns {String} The String freed of excess whitespace\n */\nfunction trim(str) {\n return str.replace(/^\\s*/, '').replace(/\\s*$/, '');\n}\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n * typeof window -> undefined\n * typeof document -> undefined\n *\n * react-native:\n * typeof document.createElement -> undefined\n */\nfunction isStandardBrowserEnv() {\n return (\n typeof window !== 'undefined' &&\n typeof document !== 'undefined' &&\n typeof document.createElement === 'function'\n );\n}\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n */\nfunction forEach(obj, fn) {\n // Don't bother if no value provided\n if (obj === null || typeof obj === 'undefined') {\n return;\n }\n\n // Force an array if not already something iterable\n if (typeof obj !== 'object' && !isArray(obj)) {\n /*eslint no-param-reassign:0*/\n obj = [obj];\n }\n\n if (isArray(obj)) {\n // Iterate over array values\n for (var i = 0, l = obj.length; i < l; i++) {\n fn.call(null, obj[i], i, obj);\n }\n } else {\n // Iterate over object keys\n for (var key in obj) {\n if (obj.hasOwnProperty(key)) {\n fn.call(null, obj[key], key, obj);\n }\n }\n }\n}\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n var result = {};\n function assignValue(val, key) {\n if (typeof result[key] === 'object' && typeof val === 'object') {\n result[key] = merge(result[key], val);\n } else {\n result[key] = val;\n }\n }\n\n for (var i = 0, l = arguments.length; i < l; i++) {\n forEach(arguments[i], assignValue);\n }\n return result;\n}\n\nmodule.exports = {\n isArray: isArray,\n isArrayBuffer: isArrayBuffer,\n isFormData: isFormData,\n isArrayBufferView: isArrayBufferView,\n isString: isString,\n isNumber: isNumber,\n isObject: isObject,\n isUndefined: isUndefined,\n isDate: isDate,\n isFile: isFile,\n isBlob: isBlob,\n isStandardBrowserEnv: isStandardBrowserEnv,\n forEach: forEach,\n merge: merge,\n trim: trim\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/utils.js\n ** module id = 6\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Dispatch a request to the server using whichever adapter\n * is supported by the current environment.\n *\n * @param {object} config The config that is to be used for the request\n * @returns {Promise} The Promise to be fulfilled\n */\nmodule.exports = function dispatchRequest(config) {\n return new Promise(function executor(resolve, reject) {\n try {\n var adapter;\n\n if (typeof config.adapter === 'function') {\n // For custom adapter support\n adapter = config.adapter;\n } else if (typeof XMLHttpRequest !== 'undefined') {\n // For browsers use XHR adapter\n adapter = require('../adapters/xhr');\n } else if (typeof process !== 'undefined') {\n // For node use HTTP adapter\n adapter = require('../adapters/http');\n }\n\n if (typeof adapter === 'function') {\n adapter(resolve, reject, config);\n }\n } catch (e) {\n reject(e);\n }\n });\n};\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/core/dispatchRequest.js\n ** module id = 7\n ** module chunks = 0\n **/","// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/process/browser.js\n ** module id = 8\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\nvar buildURL = require('./../helpers/buildURL');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar transformData = require('./../helpers/transformData');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar btoa = window.btoa || require('./../helpers/btoa');\n\nmodule.exports = function xhrAdapter(resolve, reject, config) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n\n // For IE 8/9 CORS support\n // Only supports POST and GET calls and doesn't returns the response headers.\n if (window.XDomainRequest && !('withCredentials' in request) && !isURLSameOrigin(config.url)) {\n request = new window.XDomainRequest();\n }\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password || '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n // Listen for ready state\n request.onload = function handleLoad() {\n if (!request) {\n return;\n }\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = ['text', ''].indexOf(config.responseType || '') !== -1 ? request.responseText : request.response;\n var response = {\n data: transformData(\n responseData,\n responseHeaders,\n config.transformResponse\n ),\n // IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)\n status: request.status === 1223 ? 204 : request.status,\n statusText: request.status === 1223 ? 'No Content' : request.statusText,\n headers: responseHeaders,\n config: config\n };\n\n // Resolve or reject the Promise based on the status\n ((response.status >= 200 && response.status < 300) ||\n (!('status' in request) && response.responseText) ?\n resolve :\n reject)(response);\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(new Error('Network Error'));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n var cookies = require('./../helpers/cookies');\n\n // Add xsrf header\n var xsrfValue = config.withCredentials || isURLSameOrigin(config.url) ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (config.withCredentials) {\n request.withCredentials = true;\n }\n\n // Add responseType to request if needed\n if (config.responseType) {\n try {\n request.responseType = config.responseType;\n } catch (e) {\n if (request.responseType !== 'json') {\n throw e;\n }\n }\n }\n\n if (utils.isArrayBuffer(requestData)) {\n requestData = new DataView(requestData);\n }\n\n // Send the request\n request.send(requestData);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/adapters/xhr.js\n ** module id = 9\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nfunction encode(val) {\n return encodeURIComponent(val).\n replace(/%40/gi, '@').\n replace(/%3A/gi, ':').\n replace(/%24/g, '$').\n replace(/%2C/gi, ',').\n replace(/%20/g, '+').\n replace(/%5B/gi, '[').\n replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @returns {string} The formatted url\n */\nmodule.exports = function buildURL(url, params, paramsSerializer) {\n /*eslint no-param-reassign:0*/\n if (!params) {\n return url;\n }\n\n var serializedParams;\n if (paramsSerializer) {\n serializedParams = paramsSerializer(params);\n } else {\n var parts = [];\n\n utils.forEach(params, function serialize(val, key) {\n if (val === null || typeof val === 'undefined') {\n return;\n }\n\n if (utils.isArray(val)) {\n key = key + '[]';\n }\n\n if (!utils.isArray(val)) {\n val = [val];\n }\n\n utils.forEach(val, function parseValue(v) {\n if (utils.isDate(v)) {\n v = v.toISOString();\n } else if (utils.isObject(v)) {\n v = JSON.stringify(v);\n }\n parts.push(encode(key) + '=' + encode(v));\n });\n });\n\n serializedParams = parts.join('&');\n }\n\n if (serializedParams) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n }\n\n return url;\n};\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/buildURL.js\n ** module id = 10\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} headers Headers needing to be parsed\n * @returns {Object} Headers parsed into an object\n */\nmodule.exports = function parseHeaders(headers) {\n var parsed = {};\n var key;\n var val;\n var i;\n\n if (!headers) { return parsed; }\n\n utils.forEach(headers.split('\\n'), function parser(line) {\n i = line.indexOf(':');\n key = utils.trim(line.substr(0, i)).toLowerCase();\n val = utils.trim(line.substr(i + 1));\n\n if (key) {\n parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n }\n });\n\n return parsed;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/parseHeaders.js\n ** module id = 11\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Object|String} data The data to be transformed\n * @param {Array} headers The headers for the request or response\n * @param {Array|Function} fns A single function or Array of functions\n * @returns {*} The resulting transformed data\n */\nmodule.exports = function transformData(data, headers, fns) {\n /*eslint no-param-reassign:0*/\n utils.forEach(fns, function transform(fn) {\n data = fn(data, headers);\n });\n\n return data;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/transformData.js\n ** module id = 12\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs have full support of the APIs needed to test\n // whether the request URL is of the same origin as current location.\n (function standardBrowserEnv() {\n var msie = /(msie|trident)/i.test(navigator.userAgent);\n var urlParsingNode = document.createElement('a');\n var originURL;\n\n /**\n * Parse a URL to discover it's components\n *\n * @param {String} url The URL to be parsed\n * @returns {Object}\n */\n function resolveURL(url) {\n var href = url;\n\n if (msie) {\n // IE needs attribute set twice to normalize properties\n urlParsingNode.setAttribute('href', href);\n href = urlParsingNode.href;\n }\n\n urlParsingNode.setAttribute('href', href);\n\n // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n return {\n href: urlParsingNode.href,\n protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n host: urlParsingNode.host,\n search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n hostname: urlParsingNode.hostname,\n port: urlParsingNode.port,\n pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n urlParsingNode.pathname :\n '/' + urlParsingNode.pathname\n };\n }\n\n originURL = resolveURL(window.location.href);\n\n /**\n * Determine if a URL shares the same origin as the current location\n *\n * @param {String} requestURL The URL to test\n * @returns {boolean} True if URL shares the same origin, otherwise false\n */\n return function isURLSameOrigin(requestURL) {\n var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n return (parsed.protocol === originURL.protocol &&\n parsed.host === originURL.host);\n };\n })() :\n\n // Non standard browser envs (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return function isURLSameOrigin() {\n return true;\n };\n })()\n);\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/isURLSameOrigin.js\n ** module id = 13\n ** module chunks = 0\n **/","'use strict';\n\n// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js\n\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n\nfunction InvalidCharacterError(message) {\n this.message = message;\n}\nInvalidCharacterError.prototype = new Error;\nInvalidCharacterError.prototype.code = 5;\nInvalidCharacterError.prototype.name = 'InvalidCharacterError';\n\nfunction btoa(input) {\n var str = String(input);\n var output = '';\n for (\n // initialize result and counter\n var block, charCode, idx = 0, map = chars;\n // if the next str index does not exist:\n // change the mapping table to \"=\"\n // check if d has no fractional digits\n str.charAt(idx | 0) || (map = '=', idx % 1);\n // \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8\n output += map.charAt(63 & block >> 8 - idx % 1 * 8)\n ) {\n charCode = str.charCodeAt(idx += 3 / 4);\n if (charCode > 0xFF) {\n throw new InvalidCharacterError('INVALID_CHARACTER_ERR: DOM Exception 5');\n }\n block = block << 8 | charCode;\n }\n return output;\n}\n\nmodule.exports = btoa;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/btoa.js\n ** module id = 14\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nmodule.exports = (\n utils.isStandardBrowserEnv() ?\n\n // Standard browser envs support document.cookie\n (function standardBrowserEnv() {\n return {\n write: function write(name, value, expires, path, domain, secure) {\n var cookie = [];\n cookie.push(name + '=' + encodeURIComponent(value));\n\n if (utils.isNumber(expires)) {\n cookie.push('expires=' + new Date(expires).toGMTString());\n }\n\n if (utils.isString(path)) {\n cookie.push('path=' + path);\n }\n\n if (utils.isString(domain)) {\n cookie.push('domain=' + domain);\n }\n\n if (secure === true) {\n cookie.push('secure');\n }\n\n document.cookie = cookie.join('; ');\n },\n\n read: function read(name) {\n var match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove: function remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n };\n })() :\n\n // Non standard browser env (web workers, react-native) lack needed support.\n (function nonStandardBrowserEnv() {\n return {\n write: function write() {},\n read: function read() { return null; },\n remove: function remove() {}\n };\n })()\n);\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/cookies.js\n ** module id = 15\n ** module chunks = 0\n **/","'use strict';\n\nvar utils = require('./../utils');\n\nfunction InterceptorManager() {\n this.handlers = [];\n}\n\n/**\n * Add a new interceptor to the stack\n *\n * @param {Function} fulfilled The function to handle `then` for a `Promise`\n * @param {Function} rejected The function to handle `reject` for a `Promise`\n *\n * @return {Number} An ID used to remove interceptor later\n */\nInterceptorManager.prototype.use = function use(fulfilled, rejected) {\n this.handlers.push({\n fulfilled: fulfilled,\n rejected: rejected\n });\n return this.handlers.length - 1;\n};\n\n/**\n * Remove an interceptor from the stack\n *\n * @param {Number} id The ID that was returned by `use`\n */\nInterceptorManager.prototype.eject = function eject(id) {\n if (this.handlers[id]) {\n this.handlers[id] = null;\n }\n};\n\n/**\n * Iterate over all the registered interceptors\n *\n * This method is particularly useful for skipping over any\n * interceptors that may have become `null` calling `eject`.\n *\n * @param {Function} fn The function to call for each interceptor\n */\nInterceptorManager.prototype.forEach = function forEach(fn) {\n utils.forEach(this.handlers, function forEachHandler(h) {\n if (h !== null) {\n fn(h);\n }\n });\n};\n\nmodule.exports = InterceptorManager;\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/core/InterceptorManager.js\n ** module id = 16\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nmodule.exports = function isAbsoluteURL(url) {\n // A URL is considered absolute if it begins with \"://\" or \"//\" (protocol-relative URL).\n // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n // by any combination of letters, digits, plus, period, or hyphen.\n return /^([a-z][a-z\\d\\+\\-\\.]*:)?\\/\\//i.test(url);\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/isAbsoluteURL.js\n ** module id = 17\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n * @returns {string} The combined URL\n */\nmodule.exports = function combineURLs(baseURL, relativeURL) {\n return baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '');\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/combineURLs.js\n ** module id = 18\n ** module chunks = 0\n **/","'use strict';\n\nmodule.exports = function bind(fn, thisArg) {\n return function wrap() {\n var args = new Array(arguments.length);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i];\n }\n return fn.apply(thisArg, args);\n };\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/bind.js\n ** module id = 19\n ** module chunks = 0\n **/","'use strict';\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n * ```js\n * function f(x, y, z) {}\n * var args = [1, 2, 3];\n * f.apply(null, args);\n * ```\n *\n * With `spread` this example can be re-written.\n *\n * ```js\n * spread(function(x, y, z) {})([1, 2, 3]);\n * ```\n *\n * @param {Function} callback\n * @returns {Function}\n */\nmodule.exports = function spread(callback) {\n return function wrap(arr) {\n return callback.apply(null, arr);\n };\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/axios/lib/helpers/spread.js\n ** module id = 20\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-http.min.js b/dist/js-data-http.min.js index dd0f07b..da1a509 100644 --- a/dist/js-data-http.min.js +++ b/dist/js-data-http.min.js @@ -1,11 +1,11 @@ /*! * js-data-http -* @version 2.2.1 - Homepage -* @author Jason Dobry -* @copyright (c) 2014-2015 Jason Dobry +* @version 3.0.0-beta.2 - Homepage +* @copyright (c) 2014-2016 js-data-http project authors * @license MIT * -* @overview HTTP adapter for js-data. +* @overview HTTP (XHR) adapter for js-data in the browser. */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],t):"object"==typeof exports?exports.DSHttpAdapter=t(require("js-data")):e.DSHttpAdapter=t(e.JSData)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i=function(){function e(e,t){for(var r=0;r=200&&t.status<300&&!o?(r.defaults.log&&r.defaults.log(i,t),t):(r.defaults.error&&r.defaults.error("FAILED: "+i,t),f.Promise.reject(t))}return r.defaults.error("FAILED",t),f.Promise.reject(t)}var r=this,n=new Date,o=e.data,i=e.cache,s=e.timeout;e=p(e,null,null,null,["data","cache","timeout"]),e=l(e,r.defaults.httpConfig),e.data=o,e.cache=i,e.timeout=s,"verbsUseBasePath"in e||(e.verbsUseBasePath=r.defaults.verbsUseBasePath),!e.urlOverride&&e.verbsUseBasePath&&(e.url=d(e.basePath||r.defaults.basePath,e.url)),r.defaults.forceTrailingSlash&&"/"!==e.url[e.url.length-1]&&!e.urlOverride&&(e.url+="/"),"object"===a(e.data)&&(e.data=c(e.data)),e.method=e.method.toUpperCase();var u=e.suffix||r.defaults.suffix;if(u&&e.url.substr(e.url.length-u.length)!==u&&!e.urlOverride&&(e.url+=u),!this.http)throw new Error("You have not configured this adapter with an http library!");return this.http(e).then(t,function(e){return t(e,!0)})}},{key:"GET",value:function(e,t){return t=t||{},t.method=t.method||"get",t.urlOverride=!!t.url,t.url=t.url||e,this.HTTP(t)}},{key:"POST",value:function(e,t,r){return r=r||{},r.method=r.method||"post",r.urlOverride=!!r.url,r.url=r.url||e,r.data=r.data||t,this.HTTP(r)}},{key:"PUT",value:function(e,t,r){return r=r||{},r.method=r.method||"put",r.urlOverride=!!r.url,r.url=r.url||e,r.data=r.data||t,this.HTTP(r)}},{key:"DEL",value:function(e,t){return t=t||{},t.method=t.method||"delete",t.urlOverride=!!t.url,t.url=t.url||e,this.HTTP(t)}},{key:"find",value:function(e,t,r){var n=this;return r=r?p(r):{},r.suffix=r.suffix||e.suffix,r.params=r.params||{},r.params=n.defaults.queryTransform(e,r.params),n.GET(n.getPath("find",e,t,r),r).then(function(t){var o=(r.deserialize?r.deserialize:n.defaults.deserialize)(e,t);return o?o:f.Promise.reject(new Error("Not Found!"))})}},{key:"findAll",value:function(e,t,r){var n=this;return r=r?p(r):{},r.suffix=r.suffix||e.suffix,r.params=r.params||{},t&&(t=n.defaults.queryTransform(e,t),l(r.params,t)),n.GET(n.getPath("findAll",e,t,r),r).then(function(t){return(r.deserialize?r.deserialize:n.defaults.deserialize)(e,t)})}},{key:"create",value:function(e,t,r){var n=this;return r=r?p(r):{},r.suffix=r.suffix||e.suffix,r.params=r.params||{},r.params=n.defaults.queryTransform(e,r.params),n.POST(n.getPath("create",e,t,r),r.serialize?r.serialize(e,t):n.defaults.serialize(e,t),r).then(function(t){return(r.deserialize?r.deserialize:n.defaults.deserialize)(e,t)})}},{key:"update",value:function(e,t,r,n){var o=this;return n=n?p(n):{},n.suffix=n.suffix||e.suffix,n.params=n.params||{},n.params=o.defaults.queryTransform(e,n.params),o.PUT(o.getPath("update",e,t,n),n.serialize?n.serialize(e,r):o.defaults.serialize(e,r),n).then(function(t){return(n.deserialize?n.deserialize:o.defaults.deserialize)(e,t)})}},{key:"updateAll",value:function(e,t,r,n){var o=this;return n=n?p(n):{},n.suffix=n.suffix||e.suffix,n.params=n.params||{},r&&(r=o.defaults.queryTransform(e,r),l(n.params,r)),this.PUT(o.getPath("updateAll",e,t,n),n.serialize?n.serialize(e,t):o.defaults.serialize(e,t),n).then(function(t){return(n.deserialize?n.deserialize:o.defaults.deserialize)(e,t)})}},{key:"destroy",value:function(e,t,r){var n=this;return r=r?p(r):{},r.suffix=r.suffix||e.suffix,r.params=r.params||{},r.params=n.defaults.queryTransform(e,r.params),n.DEL(n.getPath("destroy",e,t,r),r).then(function(t){return(r.deserialize?r.deserialize:n.defaults.deserialize)(e,t)})}},{key:"destroyAll",value:function(e,t,r){var n=this;return r=r?p(r):{},r.suffix=r.suffix||e.suffix,r.params=r.params||{},t&&(t=n.defaults.queryTransform(e,t),l(r.params,t)),this.DEL(n.getPath("destroyAll",e,t,r),r).then(function(t){return(r.deserialize?r.deserialize:n.defaults.deserialize)(e,t)})}}]),e}();g.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},e.exports=g},function(t,r){t.exports=e},function(e,t,r){e.exports=r(3)},function(e,t,r){"use strict";function n(e){this.defaults=a.merge({},e),this.interceptors={request:new s,response:new s}}var o=r(4),a=r(5),i=r(6),s=r(15),u=r(16),f=r(17),l=r(18),c=r(11);n.prototype.request=function(e){"string"==typeof e&&(e=a.merge({url:arguments[0]},arguments[1])),e=a.merge(o,this.defaults,{method:"get"},e),e.baseURL&&!u(e.url)&&(e.url=f(e.baseURL,e.url)),e.withCredentials=e.withCredentials||this.defaults.withCredentials,e.data=c(e.data,e.headers,e.transformRequest),e.headers=a.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),a.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=[i,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)r=r.then(t.shift(),t.shift());return r};var p=new n(o),d=e.exports=l(n.prototype.request,p);d.create=function(e){return new n(e)},d.defaults=p.defaults,d.all=function(e){return Promise.all(e)},d.spread=r(19),d.interceptors=p.interceptors,a.forEach(["delete","get","head"],function(e){n.prototype[e]=function(t,r){return this.request(a.merge(r||{},{method:e,url:t}))},d[e]=l(n.prototype[e],p)}),a.forEach(["post","put","patch"],function(e){n.prototype[e]=function(t,r,n){return this.request(a.merge(n||{},{method:e,url:t,data:r}))},d[e]=l(n.prototype[e],p)})},function(e,t,r){"use strict";var n=r(5),o=/^\)\]\}',?\n/,a={"Content-Type":"application/x-www-form-urlencoded"};e.exports={transformRequest:[function(e,t){return n.isFormData(e)?e:n.isArrayBuffer(e)?e:n.isArrayBufferView(e)?e.buffer:!n.isObject(e)||n.isFile(e)||n.isBlob(e)?e:(n.isUndefined(t)||(n.forEach(t,function(e,r){"content-type"===r.toLowerCase()&&(t["Content-Type"]=e)}),n.isUndefined(t["Content-Type"])&&(t["Content-Type"]="application/json;charset=utf-8")),JSON.stringify(e))}],transformResponse:[function(e){if("string"==typeof e){e=e.replace(o,"");try{e=JSON.parse(e)}catch(e){}}return e}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:n.merge(a),post:n.merge(a),put:n.merge(a)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"}},function(e,t){"use strict";function r(e){return"[object Array]"===v.call(e)}function n(e){return"[object ArrayBuffer]"===v.call(e)}function o(e){return"[object FormData]"===v.call(e)}function a(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function i(e){return"string"==typeof e}function s(e){return"number"==typeof e}function u(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function l(e){return"[object Date]"===v.call(e)}function c(e){return"[object File]"===v.call(e)}function p(e){return"[object Blob]"===v.call(e)}function d(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function h(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function m(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||r(e)||(e=[e]),r(e))for(var n=0,o=e.length;o>n;n++)t.call(null,e[n],n,e);else for(var a in e)e.hasOwnProperty(a)&&t.call(null,e[a],a,e)}function y(){function e(e,r){"object"==typeof t[r]&&"object"==typeof e?t[r]=y(t[r],e):t[r]=e}for(var t={},r=0,n=arguments.length;n>r;r++)m(arguments[r],e);return t}var v=Object.prototype.toString;e.exports={isArray:r,isArrayBuffer:n,isFormData:o,isArrayBufferView:a,isString:i,isNumber:s,isObject:f,isUndefined:u,isDate:l,isFile:c,isBlob:p,isStandardBrowserEnv:h,forEach:m,merge:y,trim:d}},function(e,t,r){(function(t){"use strict";e.exports=function(e){return new Promise(function(n,o){try{var a;"function"==typeof e.adapter?a=e.adapter:"undefined"!=typeof XMLHttpRequest?a=r(8):"undefined"!=typeof t&&(a=r(8)),"function"==typeof a&&a(n,o,e)}catch(e){o(e)}})}}).call(t,r(7))},function(e,t){function r(){f=!1,i.length?u=i.concat(u):l=-1,u.length&&n()}function n(){if(!f){var e=setTimeout(r);f=!0;for(var t=u.length;t;){for(i=u,u=[];++l1)for(var r=1;r=200&&o.status<300||!("status"in p)&&o.responseText?e:t)(o),p=null}},p.onerror=function(){t(new Error("Network Error")),p=null},n.isStandardBrowserEnv()){var m=r(14),y=f.withCredentials||s(f.url)?m.read(f.xsrfCookieName):void 0;y&&(c[f.xsrfHeaderName]=y)}if("setRequestHeader"in p&&n.forEach(c,function(e,t){"undefined"==typeof l&&"content-type"===t.toLowerCase()?delete c[t]:p.setRequestHeader(t,e)}),f.withCredentials&&(p.withCredentials=!0),f.responseType)try{p.responseType=f.responseType}catch(e){if("json"!==p.responseType)throw e}n.isArrayBuffer(l)&&(l=new DataView(l)),p.send(l)}},function(e,t,r){"use strict";function n(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 o=r(5);e.exports=function(e,t,r){if(!t)return e;var a;if(r)a=r(t);else{var i=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)&&(t+="[]"),o.isArray(e)||(e=[e]),o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),i.push(n(t)+"="+n(e))}))}),a=i.join("&")}return a&&(e+=(-1===e.indexOf("?")?"?":"&")+a),e}},function(e,t,r){"use strict";var n=r(5);e.exports=function(e){var t,r,o,a={};return e?(n.forEach(e.split("\n"),function(e){o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t&&(a[t]=a[t]?a[t]+", "+r:r)}),a):a}},function(e,t,r){"use strict";var n=r(5);e.exports=function(e,t,r){return n.forEach(r,function(r){e=r(e,t)}),e}},function(e,t,r){"use strict";var n=r(5);e.exports=n.isStandardBrowserEnv()?function(){function e(e){var t=e;return r&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,r=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(r){var o=n.isString(r)?e(r):r;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function r(e){this.message=e}function n(e){for(var t,n,a=String(e),i="",s=0,u=o;a.charAt(0|s)||(u="=",s%1);i+=u.charAt(63&t>>8-s%1*8)){if(n=a.charCodeAt(s+=.75),n>255)throw new r("INVALID_CHARACTER_ERR: DOM Exception 5");t=t<<8|n}return i}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.prototype=new Error,r.prototype.code=5,r.prototype.name="InvalidCharacterError",e.exports=n},function(e,t,r){"use strict";var n=r(5);e.exports=n.isStandardBrowserEnv()?function(){return{write:function(e,t,r,o,a,i){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(o)&&s.push("path="+o),n.isString(a)&&s.push("domain="+a),i===!0&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,r){"use strict";function n(){this.handlers=[]}var o=r(5);n.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},n.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},n.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=n},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,"")}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;nn;n++)t[n]=arguments[n];var r=o(t,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function a(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function s(e,t){if(!t)return e;var n=[];return c.utils.forOwn(t,function(e,t){null!==e&&"undefined"!=typeof e&&(c.utils.isArray(e)||(e=[e]),e.forEach(function(e){"[object Date]"===window.toString.call(e)?e=e.toISOString():c.utils.isObject(e)&&(e=c.utils.toJson(e)),n.push(a(t)+"="+a(e))}))}),n.length>0&&(e+=(-1===e.indexOf("?")?"?":"&")+n.join("&")),e}function f(e){var t=this;e||(e={}),c.utils.fillIn(e,b),p.default.call(t,e)}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},c=n(1),d=n(2),p=r(d),h=n(3),y=!1;try{y=window&&window.fetch}catch(e){}var v=function(){for(var e=this,t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var i=n[n.length-1];return e.dbg.apply(e,[i.op].concat(n)),c.utils.resolve()},m=function(){for(var e=this,t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var i=n[n.length-2];return e.dbg.apply(e,[i.op].concat(n)),c.utils.resolve()},g=p.default.prototype,b={basePath:"",forceTrailingSlash:!1,http:h,httpConfig:{},suffix:"",useFetch:!1};f.prototype=Object.create(p.default.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(f,"__super__",{configurable:!0,value:p.default}),c.utils.addHiddenPropsToTarget(f.prototype,{afterDEL:m,afterGET:m,afterHTTP:m,afterPOST:m,afterPUT:m,beforeDEL:v,beforeGET:v,beforeHTTP:v,beforePOST:v,beforePUT:v,_count:function(e,t,n){var r=this;return r.GET(r.getPath("count",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_create:function(e,t,n){var r=this;return r.POST(r.getPath("create",e,t,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_createMany:function(e,t,n){var r=this;return r.POST(r.getPath("createMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroy:function(e,t,n){var r=this;return r.DEL(r.getPath("destroy",e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroyAll:function(e,t,n){var r=this;return r.DEL(r.getPath("destroyAll",e,null,n),n).then(function(t){return r._end(e,n,t)})},_end:function(e,t,n){return[this.deserialize(e,n,t),n]},_find:function(e,t,n){var r=this;return r.GET(r.getPath("find",e,t,n),n).then(function(t){return r._end(e,n,t)})},_findAll:function(e,t,n){var r=this;return r.GET(r.getPath("findAll",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_sum:function(e,t,n,r){var i=this;return i.GET(i.getPath("sum",e,r.params,r),r).then(function(t){return i._end(e,r,t)})},_update:function(e,t,n,r){var i=this;return i.PUT(i.getPath("update",e,t,r),i.serialize(e,n,r),r).then(function(t){return i._end(e,r,t)})},_updateAll:function(e,t,n,r){var i=this;return i.PUT(i.getPath("updateAll",e,null,r),i.serialize(e,t,r),r).then(function(t){return i._end(e,r,t)})},_updateMany:function(e,t,n){var r=this;return r.PUT(r.getPath("updateMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},count:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),n.params.count=!0,n.suffix=r.getSuffix(e,n),c.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),g.count.call(r,e,t,n)},create:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),g.create.call(r,e,t,n)},createMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),g.createMany.call(r,e,t,n)},DEL:function(e,t,n){var r=this,i=void 0;return t||(t={}),n||(n={}),t.url=e||t.url,t.method=t.method||"delete",i=n.op="beforeDEL",c.utils.resolve(r[i](e,t,n)).then(function(o){return t=c.utils.isUndefined(o)?t:o,i=n.op="DEL",r.dbg(i,e,t,n),r.HTTP(t,n)}).then(function(o){return i=n.op="afterDEL",c.utils.resolve(r[i](e,t,n,o)).then(function(e){return c.utils.isUndefined(e)?o:e})})},deserialize:function(e,t,n){return n||(n={}),c.utils.isFunction(n.deserialize)?n.deserialize(e,t,n):c.utils.isFunction(e.deserialize)?e.deserialize(e,t,n):t&&t.hasOwnProperty("data")?t.data:t},destroy:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),g.destroy.call(r,e,t,n)},destroyAll:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),c.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),g.destroyAll.call(r,e,t,n)},error:function(){if(console){var e;(e=console)["function"==typeof console.error?"error":"log"].apply(e,arguments)}},fetch:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,t){var n={method:e.method,headers:new Headers(e.headers)};return e.data&&(n.body=c.utils.toJson(e.data)),fetch(new Request(s(e.url,e.params),n)).then(function(t){return t.config={method:e.method,url:e.url},t.json().then(function(e){return t.data=e,t})})}),find:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),g.find.call(r,e,t,n)},findAll:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),n.suffix=r.getSuffix(e,n),c.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),g.findAll.call(r,e,t,n)},GET:function(e,t,n){var r=this,i=void 0;return t||(t={}),n||(n={}),t.url=e||t.url,t.method=t.method||"get",i=n.op="beforeGET",c.utils.resolve(r[i](e,t,n)).then(function(o){return t=c.utils.isUndefined(o)?t:o,i=n.op="GET",r.dbg(i,e,t,n),r.HTTP(t,n)}).then(function(o){return i=n.op="afterGET",c.utils.resolve(r[i](e,t,n,o)).then(function(e){return c.utils.isUndefined(e)?o:e})})},getEndpoint:function(e,t,n){var r=this;n||(n={}),n.params=c.utils.isUndefined(n.params)?{}:n.params;var i=e.relationList||[],o=c.utils.isUndefined(n.endpoint)?c.utils.isUndefined(e.endpoint)?e.name:e.endpoint:n.endpoint;return i.forEach(function(e){if("belongsTo"===e.type&&e.parent){var i=void 0,a=e.foreignKey,s=e.getRelation(),f=n.params[a];if(f===!1||!a||!s)return f===!1&&delete n.params[a],!1;if(delete n.params[a],c.utils.isObject(t)&&(i=t),i&&(f=f||e.getForeignKey(i)||(e.getLocalField(i)?c.utils.get(e.getLocalField(i),s.idAttribute):null)),f){var d=function(){delete n.endpoint;var e={};return c.utils.forOwn(n,function(t,n){e[n]=t}),c.utils._(e,s),o=u(r.getEndpoint(s,f,e),f,o),{v:!1}}();if("object"===("undefined"==typeof d?"undefined":l(d)))return d.v}}}),o},getPath:function(e,t,n,r){var i=this;r||(r={});var o=[c.utils.isUndefined(r.basePath)?c.utils.isUndefined(t.basePath)?i.basePath:t.basePath:r.basePath,i.getEndpoint(t,c.utils.isString(n)||c.utils.isNumber(n)||"create"===e?n:null,r)];return"find"!==e&&"update"!==e&&"destroy"!==e||o.push(n),u.apply(c.utils,o)},getParams:function(e){return e||(e={}),c.utils.isUndefined(e.params)?{}:c.utils.copy(e.params)},getSuffix:function(e,t){return t||(t={}),c.utils.isUndefined(t.suffix)?c.utils.isUndefined(e.suffix)?this.suffix:e.suffix:t.suffix},HTTP:function(e,t){function n(t){var n=i.toUTCString()+" - "+e.method.toUpperCase()+" "+e.url+" - "+t.status+" "+((new Date).getTime()-i.getTime())+"ms";return t.status>=200&&t.status<300?(r.log&&r.dbg("debug",n,t),t):(r.error&&r.error("'FAILED: "+n,t),c.utils.reject(t))}var r=this,i=new Date;t||(t={});var o=e.data,u=e.cache,a=e.timeout;e=c.utils.copy(e,null,null,null,["data","cache","timeout"]),e=c.utils.deepMixIn(e,r.httpConfig),e.data=o,e.cache=u,e.timeout=a,r.forceTrailingSlash&&"/"!==e.url[e.url.length-1]&&(e.url+="/"),e.method=e.method.toUpperCase();var s=e.suffix||t.suffix||r.suffix;if(s&&e.url.substr(e.url.length-s.length)!==s&&(e.url+=s),!r.http)throw new Error("You have not configured this adapter with an http library!");return c.utils.resolve(r.beforeHTTP(e,t)).then(function(i){return e=i||e,y&&(r.useFetch||t.useFetch||!r.http)?r.fetch(e,t).then(n,n):r.http(e).then(n,n).catch(function(n){return r.responseError(n,e,t)})}).then(function(n){return c.utils.resolve(r.afterHTTP(e,t,n)).then(function(e){return e||n})})},POST:function(e,t,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.data=t||n.data,n.method=n.method||"post",o=r.op="beforePOST",c.utils.resolve(i[o](e,t,n,r)).then(function(u){return n=c.utils.isUndefined(u)?n:u,o=r.op="POST",i.dbg(o,e,t,n,r),i.HTTP(n,r)}).then(function(u){return o=r.op="afterPOST",c.utils.resolve(i[o](e,t,n,r,u)).then(function(e){return c.utils.isUndefined(e)?u:e})})},PUT:function(e,t,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.data=t||n.data,n.method=n.method||"put",o=r.op="beforePUT",c.utils.resolve(i[o](e,t,n,r)).then(function(u){return n=c.utils.isUndefined(u)?n:u,o=r.op="PUT",i.dbg(o,e,t,n,r),i.HTTP(n,r)}).then(function(u){return o=r.op="afterPUT",c.utils.resolve(i[o](e,t,n,r,u)).then(function(e){return c.utils.isUndefined(e)?u:e})})},queryTransform:function(e,t,n){return n||(n={}),c.utils.isFunction(n.queryTransform)?n.queryTransform(e,t,n):c.utils.isFunction(e.queryTransform)?e.queryTransform(e,t,n):t},responseError:function(e,t,n){return c.utils.reject(e)},serialize:function(e,t,n){return n||(n={}),c.utils.isFunction(n.serialize)?n.serialize(e,t,n):c.utils.isFunction(e.serialize)?e.serialize(e,t,n):t},sum:function(e,t,n,r){var i=this;if(n||(n={}),r||(r={}),!c.utils.utils.isString(t))throw new Error("field must be a string!");return r.params=i.getParams(r),r.params.sum=t,r.suffix=i.getSuffix(e,r),c.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),g.sum.call(i,e,t,n,r)},update:function(e,t,n,r){var i=this;return r||(r={}),r.params=i.getParams(r),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),g.update.call(i,e,t,n,r)},updateAll:function(e,t,n,r){var i=this;return n||(n={}),r||(r={}),r.params=i.getParams(r),c.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),g.updateAll.call(i,e,t,n,r)},updateMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),g.updateMany.call(r,e,t,n)}}),f.addAction=function(e,t){if(!e||!c.utils.isString(e))throw new TypeError("action(name[, opts]): Expected: string, Found: "+("undefined"==typeof e?"undefined":l(e)));return function(n){if(n[e])throw new Error("action(name[, opts]): "+e+" already exists on target!");return t.request=t.request||function(e){return e},t.response=t.response||function(e){return e},t.responseError=t.responseError||function(e){return c.utils.reject(e)},n[e]=function(n,r){var i=this;c.utils.isObject(n)&&(r=n),r=r||{};var o=i.getAdapter(t.adapter||i.defaultAdapter||"http"),a={};if(c.utils.fillIn(a,t),!r.hasOwnProperty("endpoint")&&a.endpoint&&(r.endpoint=a.endpoint),"function"==typeof r.getEndpoint)a.url=r.getEndpoint(i,r);else{var s=[r.basePath||i.basePath||o.basePath,o.getEndpoint(i,c.utils.isSorN(n)?n:null,r)];c.utils.isSorN(n)&&s.push(n),s.push(t.pathname||e),a.url=u.apply(null,s)}return a.method=a.method||"GET",a.mapper=i.name,c.utils.deepMixIn(a)(r),c.utils.resolve(a).then(r.request||t.request).then(function(e){return o.HTTP(e)}).then(function(e){return e&&e.config&&(e.config.mapper=i.name),e}).then(r.response||t.response,r.responseError||t.responseError)},n}},f.addActions=function(e){return e||(e={}),function(e){return c.utils.forOwn(e,function(t,n){f.addAction(n,t)(e)}),e}},f.extend=c.utils.extend,f.version={beta:2,full:"3.0.0-beta.2",major:3,minor:0,patch:0},e.exports=f},function(t,n){t.exports=e},function(e,t,n){!function(e,t){t(n(1))}(this,function(t){"use strict";function n(e){var n=this;e||(e={}),t.utils.fillIn(e,f),t.utils.fillIn(n,e)}function r(e,n,r){var i=this;n||(n={}),i.data=e,t.utils.fillIn(i,n),i.op=r}var i={};i.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},i.slicedToArray=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var o=function(){for(var e=this,n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r[r.length-1];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},u=function(){for(var e=this,n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r[r.length-2];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},a=function(e){var t={},n=[];return e.forEach(function(e){e in t||(n.push(e),t[e]=0)}),n},s=function(e,n){return t.utils.omit(n,e.relationFields||[])},f={debug:!1,raw:!1};n.reserved=["orderBy","sort","limit","offset","skip","where"],n.Response=r,n.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(n.prototype,{afterCount:u,afterCreate:u,afterCreateMany:u,afterDestroy:u,afterDestroyAll:u,afterFind:u,afterFindAll:u,afterSum:u,afterUpdate:u,afterUpdateAll:u,afterUpdateMany:u,beforeCount:o,beforeCreate:o,beforeCreateMany:o,beforeDestroy:o,beforeDestroyAll:o,beforeFind:o,beforeFindAll:o,beforeSum:o,beforeUpdate:o,beforeUpdateAll:o,beforeUpdateMany:o,dbg:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},count:function(e,n,o){var u=this,a=void 0;return n||(n={}),o||(o={}),a=o.op="beforeCount",t.utils.resolve(u[a](e,n,o)).then(function(){return a=o.op="count",u.dbg(a,e,n,o),t.utils.resolve(u._count(e,n,o))}).then(function(s){var f=i.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new r(l,c,a);return d=u.respond(d,o),a=o.op="afterCount",t.utils.resolve(u[a](e,n,o,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},create:function(e,n,o){var u=this,a=void 0;return n||(n={}),o||(o={}),a=o.op="beforeCreate",t.utils.resolve(u[a](e,n,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=s(e,n),a=o.op="create",u.dbg(a,e,n,o),t.utils.resolve(u._create(e,n,o))}).then(function(s){var f=i.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new r(l,c,"create");return d.created=l?1:0,d=u.respond(d,o),a=o.op="afterCreate",t.utils.resolve(u[a](e,n,o,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},createMany:function(e,n,o){var u=this,a=void 0;return n||(n={}),o||(o={}),a=o.op="beforeCreateMany",t.utils.resolve(u[a](e,n,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),a=o.op="createMany",u.dbg(a,e,n,o),t.utils.resolve(u._createMany(e,n,o))}).then(function(s){var f=i.slicedToArray(s,2),l=f[0],c=f[1];l||(l=[]),c||(c={});var d=new r(l,c,"createMany");return d.created=l.length,d=u.respond(d,o),a=o.op="afterCreateMany",t.utils.resolve(u[a](e,n,o,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroy:function(e,n,o){var u=this,a=void 0;return o||(o={}),a=o.op="beforeDestroy",t.utils.resolve(u[a](e,n,o)).then(function(){return a=o.op="destroy",u.dbg(a,e,n,o),t.utils.resolve(u._destroy(e,n,o))}).then(function(s){var f=i.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new r(l,c,"destroy");return d=u.respond(d,o),a=o.op="afterDestroy",t.utils.resolve(u[a](e,n,o,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroyAll:function(e,n,o){var u=this,a=void 0;return n||(n={}),o||(o={}),a=o.op="beforeDestroyAll",t.utils.resolve(u[a](e,n,o)).then(function(){return a=o.op="destroyAll",u.dbg(a,e,n,o),t.utils.resolve(u._destroyAll(e,n,o))}).then(function(s){var f=i.slicedToArray(s,2),l=f[0],c=f[1];c||(c={});var d=new r(l,c,"destroyAll");return d=u.respond(d,o),a=o.op="afterDestroyAll",t.utils.resolve(u[a](e,n,o,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},makeHasManyForeignKey:function(e,t,n){return t.getForeignKey(n)},makeHasManyLocalKeys:function(e,n,r){var i=[],o=t.utils.get(r,n.localKeys)||[];return o=t.utils.isArray(o)?o:Object.keys(o),i=i.concat(o),a(i).filter(function(e){return e})},makeHasManyForeignKeys:function(e,n,r){return t.utils.get(r,e.idAttribute)},loadHasMany:function(e,n,r,i){var o=this,u=!1;t.utils.isObject(r)&&!t.utils.isArray(r)&&(u=!0,r=[r]);var a=r.map(function(t){return o.makeHasManyForeignKey(e,n,t)}),s={where:{}},f=s.where[n.foreignKey]={};return u?f["=="]=a[0]:f.in=a.filter(function(e){return e}),o.findAll(n.getRelation(),s,i).then(function(i){r.forEach(function(r){var o=[];u?o=i:i.forEach(function(i){t.utils.get(i,n.foreignKey)===r[e.idAttribute]&&o.push(i)}),n.setLocalField(r,o)})})},loadHasManyLocalKeys:function(e,n,r,o){var u=this,s=void 0,f=n.getRelation();if(t.utils.isObject(r)&&!t.utils.isArray(r)&&(s=r),s)return u.findAll(f,{where:i.defineProperty({},f.idAttribute,{in:u.makeHasManyLocalKeys(e,n,s)})},o).then(function(e){n.setLocalField(s,e)});var l=function(){var s=[];return r.forEach(function(t){s=s.concat(u.self.makeHasManyLocalKeys(e,n,t))}),{v:u.findAll(f,{where:i.defineProperty({},f.idAttribute,{in:a(s).filter(function(e){return e})})},o).then(function(e){return r.forEach(function(r){var i=[],o=t.utils.get(r,n.localKeys)||[];o=t.utils.isArray(o)?o:Object.keys(o),e.forEach(function(e){o&&-1!==o.indexOf(e[f.idAttribute])&&i.push(e)}),n.setLocalField(r,i)}),e})}}();return"object"===("undefined"==typeof l?"undefined":i.typeof(l))?l.v:void 0},loadHasManyForeignKeys:function(e,n,r,o){var u=this,a=n.getRelation(),s=e.idAttribute,f=void 0;return t.utils.isObject(r)&&!t.utils.isArray(r)&&(f=r),f?u.findAll(n.getRelation(),{where:i.defineProperty({},n.foreignKeys,{contains:u.makeHasManyForeignKeys(e,n,f)})},o).then(function(e){n.setLocalField(f,e)}):u.findAll(a,{where:i.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(t){return u.makeHasManyForeignKeys(e,n,t)})})},o).then(function(e){var i=n.foreignKeys;r.forEach(function(r){var o=[],u=t.utils.get(r,s);e.forEach(function(n){var r=t.utils.get(e,i)||[];-1!==r.indexOf(u)&&o.push(n)}),n.setLocalField(r,o)})})},loadHasOne:function(e,n,r,i){return t.utils.isObject(r)&&!t.utils.isArray(r)&&(r=[r]),this.loadHasMany(e,n,r,i).then(function(){r.forEach(function(e){var r=n.getLocalField(e);t.utils.isArray(r)&&r.length&&n.setLocalField(e,r[0])})})},makeBelongsToForeignKey:function(e,t,n){return t.getForeignKey(n)},loadBelongsTo:function(e,n,r,o){var u=this,a=n.getRelation();if(!t.utils.isObject(r)||t.utils.isArray(r)){var s=r.map(function(t){return u.makeBelongsToForeignKey(e,n,t)}).filter(function(e){return e});return u.findAll(a,{where:i.defineProperty({},a.idAttribute,{in:s})},o).then(function(e){r.forEach(function(t){e.forEach(function(e){e[a.idAttribute]===t[n.foreignKey]&&n.setLocalField(t,e)})})})}var f=function(){var t=r;return{v:u.find(a,u.makeBelongsToForeignKey(e,n,t),o).then(function(e){n.setLocalField(t,e)})}}();return"object"===("undefined"==typeof f?"undefined":i.typeof(f))?f.v:void 0},find:function(e,n,o){var u=this,a=void 0,s=void 0;return o||(o={}),o.with||(o.with=[]),s=o.op="beforeFind",t.utils.resolve(u[s](e,n,o)).then(function(){return s=o.op="find",u.dbg(s,e,n,o),t.utils.resolve(u._find(e,n,o))}).then(function(n){var r=i.slicedToArray(n,1),s=r[0];if(s){a=s;var f=[];return t.utils.forEachRelation(e,o,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=u.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=u.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=u.loadBelongsTo(e,t,a,n)):r="hasOne"===t.type?u.loadHasOne(e,t,a,n):u.loadHasMany(e,t,a,n),r&&f.push(r)}),Promise.all(f)}}).then(function(){var i=new r(a,{},"find");return i.found=a?1:0,i=u.respond(i,o),s=o.op="afterFind",t.utils.resolve(u[s](e,n,o,i)).then(function(e){return t.utils.isUndefined(e)?i:e})})},findAll:function(e,n,o){var u=this;o||(o={}),o.with||(o.with=[]);var a=[],s=void 0,f=o._activeWith;if(t.utils.isObject(f)){var l=f.query||{};f.replace?n=l:t.utils.deepFillIn(n,l)}return s=o.op="beforeFindAll",t.utils.resolve(u[s](e,n,o)).then(function(){return s=o.op="findAll",u.dbg(s,e,n,o),t.utils.resolve(u._findAll(e,n,o))}).then(function(n){var r=i.slicedToArray(n,1),s=r[0];s||(s=[]),a=s;var f=[];return t.utils.forEachRelation(e,o,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=u.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=u.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=u.loadBelongsTo(e,t,a,n)):r="hasMany"===t.type?u.loadHasMany(e,t,a,n):u.loadHasOne(e,t,a,n),r&&f.push(r)}),Promise.all(f)}).then(function(){var i=new r(a,{},"findAll");return i.found=a.length,i=u.respond(i,o),s=o.op="afterFindAll",t.utils.resolve(u[s](e,n,o,i)).then(function(e){return t.utils.isUndefined(e)?i:e})})},getOpt:function(e,n){return n||(n={}),t.utils.isUndefined(n[e])?t.utils.plainCopy(this[e]):t.utils.plainCopy(n[e])},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var i=e.toUpperCase()+": (Adapter)";if(console[e]){var o;(o=console)[e].apply(o,[i].concat(n))}else{var u;(u=console).log.apply(u,[i].concat(n))}}},sum:function(e,n,o,u){var a=this,s=void 0;if(!t.utils.isString(n))throw new Error("field must be a string!");return o||(o={}),u||(u={}),s=u.op="beforeSum",t.utils.resolve(a[s](e,n,o,u)).then(function(){return s=u.op="sum",a.dbg(s,e,n,o,u),t.utils.resolve(a._sum(e,n,o,u))}).then(function(f){var l=i.slicedToArray(f,2),c=l[0],d=l[1];d||(d={});var p=new r(c,d,s);return p=a.respond(p,u),s=u.op="afterSum",t.utils.resolve(a[s](e,n,o,u,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},respond:function(e,t){return this.getOpt("raw",t)?e:e.data},update:function(e,n,o,u){var a=this;o||(o={}),u||(u={});var s=void 0;return s=u.op="beforeUpdate",t.utils.resolve(a[s](e,n,o,u)).then(function(r){return o=t.utils.isUndefined(r)?o:r,s=u.op="update",a.dbg(s,e,n,o,u),t.utils.resolve(a._update(e,n,o,u))}).then(function(f){var l=i.slicedToArray(f,2),c=l[0],d=l[1];d||(d={});var p=new r(c,d,"update");return p.updated=c?1:0,p=a.respond(p,u),s=u.op="afterUpdate",t.utils.resolve(a[s](e,n,o,u,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateAll:function(e,n,o,u){var a=this;n||(n={}),o||(o={}),u||(u={});var s=void 0;return s=u.op="beforeUpdateAll",t.utils.resolve(a[s](e,n,o,u)).then(function(r){return n=t.utils.isUndefined(r)?n:r,s=u.op="updateAll",a.dbg(s,e,n,o,u),t.utils.resolve(a._updateAll(e,n,o,u))}).then(function(f){var l=i.slicedToArray(f,2),c=l[0],d=l[1];c||(c=[]),d||(d={});var p=new r(c,d,"updateAll");return p.updated=c.length,p=a.respond(p,u),s=u.op="afterUpdateAll",t.utils.resolve(a[s](e,n,o,u,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateMany:function(e,n,o){var u=this;n||(n=[]),o||(o={});var a=void 0,f=e.idAttribute;return n=n.filter(function(e){return t.utils.get(e,f)}),a=o.op="beforeUpdateMany",t.utils.resolve(u[a](e,n,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),a=o.op="updateMany",u.dbg(a,e,n,o),t.utils.resolve(u._updateMany(e,n,o))}).then(function(s){var f=i.slicedToArray(s,2),l=f[0],c=f[1];l||(l=[]),c||(c={});var d=new r(l,c,"updateMany");return d.updated=l.length,d=u.respond(d,o),a=o.op="afterUpdateMany",t.utils.resolve(u[a](e,n,o,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})}}),e.exports=n})},function(e,t,n){e.exports=n(4)},function(e,t,n){"use strict";function r(e){this.defaults=o.merge({},e),this.interceptors={request:new a,response:new a}}var i=n(5),o=n(6),u=n(7),a=n(16),s=n(17),f=n(18),l=n(19),c=n(12);r.prototype.request=function(e){"string"==typeof e&&(e=o.merge({url:arguments[0]},arguments[1])),e=o.merge(i,this.defaults,{method:"get"},e),e.baseURL&&!s(e.url)&&(e.url=f(e.baseURL,e.url)),e.withCredentials=e.withCredentials||this.defaults.withCredentials,e.data=c(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=[u,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n};var d=new r(i),p=e.exports=l(r.prototype.request,d);p.create=function(e){return new r(e)},p.defaults=d.defaults,p.all=function(e){return Promise.all(e)},p.spread=n(20),p.interceptors=d.interceptors,o.forEach(["delete","get","head"],function(e){r.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))},p[e]=l(r.prototype[e],d)}),o.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))},p[e]=l(r.prototype[e],d)})},function(e,t,n){"use strict";var r=n(6),i=/^\)\]\}',?\n/,o={"Content-Type":"application/x-www-form-urlencoded"};e.exports={transformRequest:[function(e,t){return r.isFormData(e)?e:r.isArrayBuffer(e)?e:r.isArrayBufferView(e)?e.buffer:!r.isObject(e)||r.isFile(e)||r.isBlob(e)?e:(r.isUndefined(t)||(r.forEach(t,function(e,n){"content-type"===n.toLowerCase()&&(t["Content-Type"]=e)}),r.isUndefined(t["Content-Type"])&&(t["Content-Type"]="application/json;charset=utf-8")),JSON.stringify(e))}],transformResponse:[function(e){if("string"==typeof e){e=e.replace(i,"");try{e=JSON.parse(e)}catch(e){}}return e}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:r.merge(o),post:r.merge(o),put:r.merge(o)},timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"}},function(e,t){"use strict";function n(e){return"[object Array]"===m.call(e)}function r(e){return"[object ArrayBuffer]"===m.call(e)}function i(e){return"[object FormData]"===m.call(e)}function o(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function u(e){return"string"==typeof e}function a(e){return"number"==typeof e}function s(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function l(e){return"[object Date]"===m.call(e)}function c(e){return"[object File]"===m.call(e)}function d(e){return"[object Blob]"===m.call(e)}function p(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function h(){return"undefined"!=typeof window&&"undefined"!=typeof document&&"function"==typeof document.createElement}function y(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||n(e)||(e=[e]),n(e))for(var r=0,i=e.length;i>r;r++)t.call(null,e[r],r,e);else for(var o in e)e.hasOwnProperty(o)&&t.call(null,e[o],o,e)}function v(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=v(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;r>n;n++)y(arguments[n],e);return t}var m=Object.prototype.toString;e.exports={isArray:n,isArrayBuffer:r,isFormData:i,isArrayBufferView:o,isString:u,isNumber:a,isObject:f,isUndefined:s,isDate:l,isFile:c,isBlob:d,isStandardBrowserEnv:h,forEach:y,merge:v,trim:p}},function(e,t,n){(function(t){"use strict";e.exports=function(e){return new Promise(function(r,i){try{var o;"function"==typeof e.adapter?o=e.adapter:"undefined"!=typeof XMLHttpRequest?o=n(9):"undefined"!=typeof t&&(o=n(9)),"function"==typeof o&&o(r,i,e)}catch(e){i(e)}})}}).call(t,n(8))},function(e,t){function n(){f=!1,u.length?s=u.concat(s):l=-1,s.length&&r()}function r(){if(!f){var e=setTimeout(n);f=!0;for(var t=s.length;t;){for(u=s,s=[];++l1)for(var n=1;n=200&&i.status<300||!("status"in d)&&i.responseText?e:t)(i),d=null}},d.onerror=function(){t(new Error("Network Error")),d=null},r.isStandardBrowserEnv()){var y=n(15),v=f.withCredentials||a(f.url)?y.read(f.xsrfCookieName):void 0;v&&(c[f.xsrfHeaderName]=v)}if("setRequestHeader"in d&&r.forEach(c,function(e,t){"undefined"==typeof l&&"content-type"===t.toLowerCase()?delete c[t]:d.setRequestHeader(t,e)}),f.withCredentials&&(d.withCredentials=!0),f.responseType)try{d.responseType=f.responseType}catch(e){if("json"!==d.responseType)throw e}r.isArrayBuffer(l)&&(l=new DataView(l)),d.send(l)}},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var i=n(6);e.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else{var u=[];i.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(i.isArray(e)&&(t+="[]"),i.isArray(e)||(e=[e]),i.forEach(e,function(e){i.isDate(e)?e=e.toISOString():i.isObject(e)&&(e=JSON.stringify(e)),u.push(r(t)+"="+r(e))}))}),o=u.join("&")}return o&&(e+=(-1===e.indexOf("?")?"?":"&")+o),e}},function(e,t,n){"use strict";var r=n(6);e.exports=function(e){var t,n,i,o={};return e?(r.forEach(e.split("\n"),function(e){i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t&&(o[t]=o[t]?o[t]+", "+n:n)}),o):o}},function(e,t,n){"use strict";var r=n(6);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){"use strict";var r=n(6);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(i.setAttribute("href",t),t=i.href),i.setAttribute("href",t), +{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");return t=e(window.location.href),function(n){var i=r.isString(n)?e(n):n;return i.protocol===t.protocol&&i.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function n(e){this.message=e}function r(e){for(var t,r,o=String(e),u="",a=0,s=i;o.charAt(0|a)||(s="=",a%1);u+=s.charAt(63&t>>8-a%1*8)){if(r=o.charCodeAt(a+=.75),r>255)throw new n("INVALID_CHARACTER_ERR: DOM Exception 5");t=t<<8|r}return u}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t,n){"use strict";var r=n(6);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,i,o,u){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),u===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";function r(){this.handlers=[]}var i=n(6);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){i.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,"")}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r +* @copyright (c) 2014-2016 js-data-http project authors +* @license MIT +* +* @overview HTTP adapter for js-data that uses the fetch API. +*/ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("js-data"), require("undefined")); + else if(typeof define === 'function' && define.amd) + define(["js-data", "undefined"], factory); + else if(typeof exports === 'object') + exports["HttpAdapter"] = factory(require("js-data"), require("undefined")); + else + root["HttpAdapter"] = factory(root["JSData"], root["undefined"]); +})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_3__) { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + + var _jsData = __webpack_require__(1); + + var _jsDataAdapter = __webpack_require__(2); + + var _jsDataAdapter2 = _interopRequireDefault(_jsDataAdapter); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + /* global fetch:true Headers:true Request:true */ + var axios = __webpack_require__(3); + + + var hasFetch = false; + + try { + hasFetch = window && window.fetch; + } catch (e) {} + + var noop = function noop() { + var self = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return _jsData.utils.resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + self.dbg.apply(self, [opts.op].concat(args)); + return _jsData.utils.resolve(); + }; + + function isValidString(value) { + return value != null && value !== ''; + } + function join(items, separator) { + separator || (separator = ''); + return items.filter(isValidString).join(separator); + } + function makePath() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + var result = join(args, '/'); + return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); + } + + function encode(val) { + return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); + } + + function buildUrl(url, params) { + if (!params) { + return url; + } + + var parts = []; + + _jsData.utils.forOwn(params, function (val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + if (!_jsData.utils.isArray(val)) { + val = [val]; + } + + val.forEach(function (v) { + if (window.toString.call(v) === '[object Date]') { + v = v.toISOString(); + } else if (_jsData.utils.isObject(v)) { + v = _jsData.utils.toJson(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; + } + + var __super__ = _jsDataAdapter2.default.prototype; + + var DEFAULTS = { + // Default and user-defined settings + /** + * @name HttpAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + */ + forceTrailingSlash: false, + + /** + * @name HttpAdapter#http + * @type {Function} + */ + http: axios, + + /** + * @name HttpAdapter#httpConfig + * @type {Object} + */ + httpConfig: {}, + + /** + * @name HttpAdapter#suffix + * @type {string} + */ + suffix: '', + + /** + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + */ + useFetch: false + }; + + /** + * HttpAdapter class. + * + * @class HttpAdapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.basePath=''] TODO + * @param {boolean} [opts.debug=false] TODO + * @param {boolean} [opts.forceTrailingSlash=false] TODO + * @param {Object} [opts.http=axios] TODO + * @param {Object} [opts.httpConfig={}] TODO + * @param {string} [opts.suffix=''] TODO + * @param {boolean} [opts.useFetch=false] TODO + */ + function HttpAdapter(opts) { + var self = this; + opts || (opts = {}); + _jsData.utils.fillIn(opts, DEFAULTS); + _jsDataAdapter2.default.call(self, opts); + } + + // Setup prototype inheritance from Adapter + HttpAdapter.prototype = Object.create(_jsDataAdapter2.default.prototype, { + constructor: { + value: HttpAdapter, + enumerable: false, + writable: true, + configurable: true + } + }); + + Object.defineProperty(HttpAdapter, '__super__', { + configurable: true, + value: _jsDataAdapter2.default + }); + + _jsData.utils.addHiddenPropsToTarget(HttpAdapter.prototype, { + /** + * @name HttpAdapter#afterDEL + * @method + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterDEL: noop2, + + /** + * @name HttpAdapter#afterGET + * @method + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterGET: noop2, + + /** + * @name HttpAdapter#afterHTTP + * @method + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterHTTP: noop2, + + /** + * @name HttpAdapter#afterPOST + * @method + * @param {string} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterPOST: noop2, + + /** + * @name HttpAdapter#afterPUT + * @method + * @param {string} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterPUT: noop2, + + /** + * @name HttpAdapter#beforeDEL + * @method + * @param {Object} url + * @param {Object} config + * @param {Object} opts + */ + beforeDEL: noop, + + /** + * @name HttpAdapter#beforeGET + * @method + * @param {Object} url + * @param {Object} config + * @param {Object} opts + */ + beforeGET: noop, + + /** + * @name HttpAdapter#beforeHTTP + * @method + * @param {Object} config + * @param {Object} opts + */ + beforeHTTP: noop, + + /** + * @name HttpAdapter#beforePOST + * @method + * @param {Object} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + */ + beforePOST: noop, + + /** + * @name HttpAdapter#beforePUT + * @method + * @param {Object} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + */ + beforePUT: noop, + + _count: function _count(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('create', mapper, props, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('createMany', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var self = this; + return self.DEL(self.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var self = this; + return self.DEL(self.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var self = this; + return self.GET(self.getPath('find', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var self = this; + return self.GET(self.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var self = this; + return self.PUT(self.getPath('update', mapper, id, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var self = this; + return self.PUT(self.getPath('updateAll', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var self = this; + return self.PUT(self.getPath('updateMany', mapper, null, opts), self.serialize(mapper, records, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + + + /** + * Retrieve the number of records that match the selection `query`. + * + * @name HttpAdapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params.count = true; + opts.suffix = self.getSuffix(mapper, opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.count.call(self, mapper, query, opts); + }, + + + /** + * Create a new the record from the provided `props`. + * + * @name HttpAdapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props Properties to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.create.call(self, mapper, props, opts); + }, + + + /** + * Create multiple new records in batch. + * + * @name HttpAdapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} props Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.createMany.call(self, mapper, props, opts); + }, + + + /** + * Make an Http request to `url` according to the configuration in `config`. + * + * @name HttpAdapter#DEL + * @method + * @param {string} url Url for the request. + * @param {Object} [config] Http configuration that will be passed to + * {@link HttpAdapter#HTTP}. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + DEL: function DEL(url, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'delete'; + + // beforeDEL lifecycle hook + op = opts.op = 'beforeDEL'; + return _jsData.utils.resolve(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'DEL'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Transform the server response object into the payload that will be returned + * to JSData. + * + * @name HttpAdapter#deserialize + * @method + * @param {Object} mapper The mapper used for the operation. + * @param {Object} response Response object from {@link HttpAdapter#HTTP}. + * @param {Object} opts Configuration options. + * @return {(Object|Array)} Deserialized data. + */ + deserialize: function deserialize(mapper, response, opts) { + opts || (opts = {}); + if (_jsData.utils.isFunction(opts.deserialize)) { + return opts.deserialize(mapper, response, opts); + } + if (_jsData.utils.isFunction(mapper.deserialize)) { + return mapper.deserialize(mapper, response, opts); + } + if (response && response.hasOwnProperty('data')) { + return response.data; + } + return response; + }, + + + /** + * Destroy the record with the given primary key. + * + * @name HttpAdapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroy.call(self, mapper, id, opts); + }, + + + /** + * Destroy the records that match the selection `query`. + * + * @name HttpAdapter#destroyAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroyAll.call(self, mapper, query, opts); + }, + + + /** + * Log an error. + * + * @name HttpAdapter#error + * @method + * @param {...*} [args] Arguments to log. + */ + error: function error() { + if (console) { + var _console; + + (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); + } + }, + + + /** + * Make an Http request using `window.fetch`. + * + * @name HttpAdapter#fetch + * @method + * @param {Object} config Request configuration. + * @param {Object} config.data Payload for the request. + * @param {string} config.method Http method for the request. + * @param {Object} config.headers Headers for the request. + * @param {Object} config.params Querystring for the request. + * @param {string} config.url Url for the request. + * @param {Object} [opts] Configuration options. + */ + fetch: function (_fetch) { + function fetch(_x, _x2) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config, opts) { + var requestConfig = { + method: config.method, + // turn the plain headers object into the Fetch Headers object + headers: new Headers(config.headers) + }; + + if (config.data) { + requestConfig.body = _jsData.utils.toJson(config.data); + } + + return fetch(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) { + response.config = { + method: config.method, + url: config.url + }; + return response.json().then(function (data) { + response.data = data; + return response; + }); + }); + }), + + + /** + * Retrieve the record with the given primary key. + * + * @name HttpAdapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.find.call(self, mapper, id, opts); + }, + + + /** + * Retrieve the records that match the selection `query`. + * + * @name HttpAdapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.suffix = self.getSuffix(mapper, opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.findAll.call(self, mapper, query, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#GET + * @method + * @param {string} url The url for the request. + * @param {Object} config Request configuration options. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + GET: function GET(url, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'get'; + + // beforeGET lifecycle hook + op = opts.op = 'beforeGET'; + return _jsData.utils.resolve(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'GET'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {boolean} opts TODO + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = _jsData.utils.isUndefined(opts.params) ? {} : opts.params; + var relationList = mapper.relationList || []; + var endpoint = _jsData.utils.isUndefined(opts.endpoint) ? _jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; + + relationList.forEach(function (def) { + if (def.type !== 'belongsTo' || !def.parent) { + return; + } + var item = void 0; + var parentKey = def.foreignKey; + var parentDef = def.getRelation(); + var parentId = opts.params[parentKey]; + + if (parentId === false || !parentKey || !parentDef) { + if (parentId === false) { + delete opts.params[parentKey]; + } + return false; + } else { + delete opts.params[parentKey]; + + if (_jsData.utils.isObject(id)) { + item = id; + } + + if (item) { + parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? _jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); + } + + if (parentId) { + var _ret = function () { + delete opts.endpoint; + var _opts = {}; + _jsData.utils.forOwn(opts, function (value, key) { + _opts[key] = value; + }); + _jsData.utils._(_opts, parentDef); + endpoint = makePath(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return { + v: false + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + } + } + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method TODO + * @param {Object} mapper TODO + * @param {(string|number)?} id TODO + * @param {Object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + var self = this; + opts || (opts = {}); + var args = [_jsData.utils.isUndefined(opts.basePath) ? _jsData.utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath : opts.basePath, self.getEndpoint(mapper, _jsData.utils.isString(id) || _jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; + if (method === 'find' || method === 'update' || method === 'destroy') { + args.push(id); + } + return makePath.apply(_jsData.utils, args); + }, + getParams: function getParams(opts) { + opts || (opts = {}); + if (_jsData.utils.isUndefined(opts.params)) { + return {}; + } + return _jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (_jsData.utils.isUndefined(opts.suffix)) { + if (_jsData.utils.isUndefined(mapper.suffix)) { + return this.suffix; + } + return mapper.suffix; + } + return opts.suffix; + }, + + + /** + * Make an Http request. + * + * @name HttpAdapter#HTTP + * @method + * @param {Object} config Request configuration options. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + HTTP: function HTTP(config, opts) { + var self = this; + var start = new Date(); + opts || (opts = {}); + var payload = config.data; + var cache = config.cache; + var timeout = config.timeout; + config = _jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); + config = _jsData.utils.deepMixIn(config, self.httpConfig); + config.data = payload; + config.cache = cache; + config.timeout = timeout; + if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || self.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + function logResponse(data) { + var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; + if (data.status >= 200 && data.status < 300) { + if (self.log) { + self.dbg('debug', str, data); + } + return data; + } else { + if (self.error) { + self.error('\'FAILED: ' + str, data); + } + return _jsData.utils.reject(data); + } + } + + if (!self.http) { + throw new Error('You have not configured this adapter with an http library!'); + } + + return _jsData.utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { + return self.fetch(config, opts).then(logResponse, logResponse); + } + return self.http(config).then(logResponse, logResponse).catch(function (err) { + return self.responseError(err, config, opts); + }); + }).then(function (response) { + return _jsData.utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { + return _response || response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#POST + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'post'; + + // beforePOST lifecycle hook + op = opts.op = 'beforePOST'; + return _jsData.utils.resolve(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'POST'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#PUT + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'put'; + + // beforePUT lifecycle hook + op = opts.op = 'beforePUT'; + return _jsData.utils.resolve(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'PUT'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#queryTransform + * @method + * @param {Object} mapper TODO + * @param {*} params TODO + * @param {*} opts TODO + * @return {*} Transformed params. + */ + queryTransform: function queryTransform(mapper, params, opts) { + opts || (opts = {}); + if (_jsData.utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts); + } + if (_jsData.utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts); + } + return params; + }, + + + /** + * Error handler invoked when the promise returned by {@link HttpAdapter#http} + * is rejected. Default implementation is to just return the error wrapped in + * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is + * called by {@link HttpAdapter#HTTP}. + * + * @name HttpAdapter#responseError + * @method + * @param {*} err The error that {@link HttpAdapter#http} rejected with. + * @param {Object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. + * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. + * @return {Promise} + */ + responseError: function responseError(err, config, opts) { + return _jsData.utils.reject(err); + }, + + + /** + * TODO + * + * @name HttpAdapter#serialize + * @method + * @param {Object} mapper TODO + * @param {Object} data TODO + * @param {*} opts TODO + * @return {*} Serialized data. + */ + serialize: function serialize(mapper, data, opts) { + opts || (opts = {}); + if (_jsData.utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts); + } + if (_jsData.utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts); + } + return data; + }, + + + /** + * Retrieve the sum of the field of the records that match the selection query. + * + * @name HttpAdapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field The field to sum. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + if (!_jsData.utils.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = self.getParams(opts); + opts.params.sum = field; + opts.suffix = self.getSuffix(mapper, opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.sum.call(self, mapper, field, query, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#update + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {*} props TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.update.call(self, mapper, id, props, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#updateAll + * @method + * @param {Object} mapper TODO + * @param {Object} props TODO + * @param {Object} query TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateAll.call(self, mapper, props, query, opts); + }, + + + /** + * Update multiple records in batch. + * + * {@link HttpAdapter#beforeUpdateMany} will be called before calling + * {@link HttpAdapter#PUT}. + * {@link HttpAdapter#afterUpdateMany} will be called after calling + * {@link HttpAdapter#PUT}. + * + * @name HttpAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} records Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateMany.call(self, mapper, records, opts); + } + }); + + /** + * Add an Http actions to a mapper. + * + * @name HttpAdapter.addAction + * @method + * @param {string} name Name of the new action. + * @param {Object} [opts] Action configuration + * @param {string} [opts.adapter] + * @param {string} [opts.pathname] + * @param {Function} [opts.request] + * @param {Function} [opts.response] + * @param {Function} [opts.responseError] + * @return {Function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ + HttpAdapter.addAction = function (name, opts) { + if (!name || !_jsData.utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + } + return function (mapper) { + if (mapper[name]) { + throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); + } + opts.request = opts.request || function (config) { + return config; + }; + opts.response = opts.response || function (response) { + return response; + }; + opts.responseError = opts.responseError || function (err) { + return _jsData.utils.reject(err); + }; + mapper[name] = function (id, _opts) { + var self = this; + if (_jsData.utils.isObject(id)) { + _opts = id; + } + _opts = _opts || {}; + var adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http'); + var config = {}; + _jsData.utils.fillIn(config, opts); + if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { + _opts.endpoint = config.endpoint; + } + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(self, _opts); + } else { + var _args = [_opts.basePath || self.basePath || adapter.basePath, adapter.getEndpoint(self, _jsData.utils.isSorN(id) ? id : null, _opts)]; + if (_jsData.utils.isSorN(id)) { + _args.push(id); + } + _args.push(opts.pathname || name); + config.url = makePath.apply(null, _args); + } + config.method = config.method || 'GET'; + config.mapper = self.name; + _jsData.utils.deepMixIn(config)(_opts); + return _jsData.utils.resolve(config).then(_opts.request || opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = self.name; + } + return data; + }).then(_opts.response || opts.response, _opts.responseError || opts.responseError); + }; + return mapper; + }; + }; + + /** + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. + * + * @name HttpAdapter.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. + */ + HttpAdapter.addActions = function (opts) { + opts || (opts = {}); + return function (mapper) { + _jsData.utils.forOwn(mapper, function (value, key) { + HttpAdapter.addAction(key, value)(mapper); + }); + return mapper; + }; + }; + + /** + * Alternative to ES6 class syntax for extending `HttpAdapter`. + * + * __ES6__: + * ```javascript + * class MyHttpAdapter extends HttpAdapter { + * deserialize (Model, data, opts) { + * const data = super.deserialize(Model, data, opts) + * data.foo = 'bar' + * return data + * } + * } + * ``` + * + * __ES5__: + * ```javascript + * var instanceProps = { + * // override deserialize + * deserialize: function (Model, data, opts) { + * var Ctor = this.constructor + * var superDeserialize = (Ctor.__super__ || Object.getPrototypeOf(Ctor)).deserialize + * // call the super deserialize + * var data = superDeserialize(Model, data, opts) + * data.foo = 'bar' + * return data + * }, + * say: function () { return 'hi' } + * } + * var classProps = { + * yell: function () { return 'HI' } + * } + * + * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) + * var adapter = new MyHttpAdapter() + * adapter.say() // "hi" + * MyHttpAdapter.yell() // "HI" + * ``` + * + * @name HttpAdapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `HttpAdapter`. + */ + HttpAdapter.extend = _jsData.utils.extend; + + /** + * Details of the current version of the `js-data-http` module. + * + * @name HttpAdapter.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. + */ + HttpAdapter.version = { + beta: 2, + full: '3.0.0-beta.2', + 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`. + * + * __Script tag__: + * ```javascript + * window.HttpAdapter + * ``` + * __CommonJS__: + * ```javascript + * var HttpAdapter = require('js-data-http') + * ``` + * __ES6 Modules__: + * ```javascript + * import HttpAdapter from 'js-data-http' + * ``` + * __AMD__: + * ```javascript + * define('myApp', ['js-data-http'], function (HttpAdapter) { ... }) + * ``` + * + * @module js-data-http + */ + + module.exports = HttpAdapter; + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_1__; + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + (function (global, factory) { + true ? factory(__webpack_require__(1)) : + typeof define === 'function' && define.amd ? define('js-data-adapter', ['js-data'], factory) : + (factory(global.JSData)); + }(this, function (jsData) { 'use strict'; + + var babelHelpers = {}; + babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; + }; + + babelHelpers.defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + }; + + babelHelpers.slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + }(); + + babelHelpers; + + var noop = function noop() { + var self = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var unique = function unique(array) { + var seen = {}; + var final = []; + array.forEach(function (item) { + if (item in seen) { + return; + } + final.push(item); + seen[item] = 0; + }); + return final; + }; + + var withoutRelations = function withoutRelations(mapper, props) { + return jsData.utils.omit(props, mapper.relationFields || []); + }; + + var DEFAULTS = { + /** + * Whether to log debugging information. + * + * @name Adapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * Whether to return a more detailed response object. + * + * @name Adapter#raw + * @type {boolean} + * @default false + */ + raw: false + }; + + /** + * Abstract class meant to be extended by adapters. + * + * @class Adapter + * @abstract + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.debug=false] Whether to log debugging information. + * @param {boolean} [opts.raw=false] Whether to return a more detailed response + * object. + */ + function Adapter(opts) { + var self = this; + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS); + jsData.utils.fillIn(self, opts); + } + + Adapter.reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where']; + + /** + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @typedef {Object} Response + * @property {Object} data Response data. + * @property {string} op The operation for which the response was created. + */ + function Response(data, meta, op) { + var self = this; + meta || (meta = {}); + self.data = data; + jsData.utils.fillIn(self, meta); + self.op = op; + } + + Adapter.Response = Response; + + /** + * Alternative to ES6 class syntax for extending `Adapter`. + * + * @name Adapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `Adapter`. + */ + Adapter.extend = jsData.utils.extend; + + jsData.utils.addHiddenPropsToTarget(Adapter.prototype, { + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#afterCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} props The `props` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `afterCount` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterCount: noop2, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `afterCreate` + * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreate: noop2, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `afterCreateMany` + * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreateMany: noop2, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#afterDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `afterDestroy` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroy: noop2, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#afterDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `afterDestroyAll` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroyAll: noop2, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#afterFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `afterFind` + * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`. + */ + afterFind: noop2, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#afterFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `afterFindAll` + * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`. + */ + afterFindAll: noop2, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#afterSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} props The `props` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `afterSum` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterSum: noop2, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#afterUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `afterUpdate` + * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdate: noop2, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#afterUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `afterUpdateAll` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateAll: noop2, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#afterUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} records The `records` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `afterUpdateMany` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateMany: noop2, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#beforeCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} query The `query` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `beforeCount` + */ + beforeCount: noop, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#beforeCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `beforeCreate` + */ + beforeCreate: noop, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#beforeCreateMany + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `beforeCreateMany` + */ + beforeCreateMany: noop, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#beforeDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `beforeDestroy` + */ + beforeDestroy: noop, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#beforeDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `beforeDestroyAll` + */ + beforeDestroyAll: noop, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#beforeFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `beforeFind` + */ + beforeFind: noop, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#beforeFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `beforeFindAll` + */ + beforeFindAll: noop, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#beforeSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `beforeSum` + */ + beforeSum: noop, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#beforeUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `beforeUpdate` + */ + beforeUpdate: noop, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#beforeUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `beforeUpdateAll` + */ + beforeUpdateAll: noop, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#beforeUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} props The `props` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `beforeUpdateMany` + */ + beforeUpdateMany: noop, + + /** + * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`. + * + * @name Adapter#dbg + * @method + */ + dbg: function dbg() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + this.log.apply(this, ['debug'].concat(args)); + }, + + + /** + * Retrieve the number of records that match the selection query. Called by + * `Mapper#count`. + * + * @name Adapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._count(mapper, query, opts)); + }).then(function (results) { + var _results = babelHelpers.slicedToArray(results, 2); + + var data = _results[0]; + var result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Create a new record. Called by `Mapper#create`. + * + * @name Adapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'create'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = babelHelpers.slicedToArray(results, 2); + + var data = _results2[0]; + var result = _results2[1]; + + result || (result = {}); + var response = new Response(data, result, 'create'); + response.created = data ? 1 : 0; + response = self.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Create multiple records in a single batch. Called by `Mapper#createMany`. + * + * @name Adapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'createMany'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = babelHelpers.slicedToArray(results, 2); + + var data = _results3[0]; + var result = _results3[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'createMany'); + response.created = data.length; + response = self.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Destroy the record with the given primary key. Called by + * `Mapper#destroy`. + * + * @name Adapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + var op = void 0; + opts || (opts = {}); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = babelHelpers.slicedToArray(results, 2); + + var data = _results4[0]; + var result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = self.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Destroy the records that match the selection query. Called by + * `Mapper#destroyAll`. + * + * @name Adapter#destroyAll + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = babelHelpers.slicedToArray(results, 2); + + var data = _results5[0]; + var result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = self.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * 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); + }, + + + /** + * Load a hasMany relationship. + * + * Override with care. + * + * @name Adapter#loadHasMany + * @method + * @return {Promise} + */ + loadHasMany: function loadHasMany(mapper, def, records, __opts) { + var self = this; + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return self.makeHasManyForeignKey(mapper, def, record); + }); + var query = { + where: {} + }; + var criteria = query.where[def.foreignKey] = {}; + if (singular) { + // more efficient query when we only have one record + criteria['=='] = IDs[0]; + } else { + criteria['in'] = IDs.filter(function (id) { + return id; + }); + } + return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { + records.forEach(function (record) { + var attached = []; + // avoid unneccesary iteration when we only have one record + if (singular) { + attached = relatedItems; + } else { + relatedItems.forEach(function (relatedItem) { + if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { + attached.push(relatedItem); + } + }); + } + def.setLocalField(record, attached); + }); + }); + }, + loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { + var self = this; + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': self.makeHasManyLocalKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + var _ret = function () { + var localKeys = []; + records.forEach(function (record) { + localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record)); + }); + return { + v: self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + var itemKeys = jsData.utils.get(item, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem); + } + }); + def.setLocalField(item, attached); + }); + return relatedItems; + }) + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; + } + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var self = this; + var relatedMapper = def.getRelation(); + var idAttribute = mapper.idAttribute; + var record = void 0; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return self.findAll(def.getRelation(), { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'contains': self.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return self.makeHasManyForeignKeys(mapper, def, record); + }) + }) + }, __opts).then(function (relatedItems) { + var foreignKeysField = def.foreignKeys; + records.forEach(function (record) { + var _relatedItems = []; + var id = jsData.utils.get(record, idAttribute); + relatedItems.forEach(function (relatedItem) { + var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; + if (foreignKeys.indexOf(id) !== -1) { + _relatedItems.push(relatedItem); + } + }); + def.setLocalField(record, _relatedItems); + }); + }); + } + }, + + + /** + * Load a hasOne relationship. + * + * Override with care. + * + * @name Adapter#loadHasOne + * @method + * @return {Promise} + */ + loadHasOne: function loadHasOne(mapper, def, records, __opts) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + records = [records]; + } + return this.loadHasMany(mapper, def, records, __opts).then(function () { + records.forEach(function (record) { + var relatedData = def.getLocalField(record); + if (jsData.utils.isArray(relatedData) && relatedData.length) { + def.setLocalField(record, relatedData[0]); + } + }); + }); + }, + + + /** + * 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); + }, + + + /** + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo + * @method + * @return {Promise} + */ + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { + var self = this; + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var _ret2 = function () { + var record = records; + return { + v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }) + }; + }(); + + if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v; + } else { + var keys = records.map(function (record) { + return self.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return self.findAll(relationDef, { + where: babelHelpers.defineProperty({}, relationDef.idAttribute, { + 'in': keys + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (record) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { + def.setLocalField(record, relatedItem); + } + }); + }); + }); + } + }, + + + /** + * Retrieve the record with the given primary key. Called by `Mapper#find`. + * + * @name Adapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + var record = void 0, + op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._find(mapper, id, opts)); + }).then(function (results) { + var _results6 = babelHelpers.slicedToArray(results, 1); + + var _record = _results6[0]; + + if (!_record) { + return; + } + record = _record; + var tasks = []; + + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasOne') { + task = self.loadHasOne(mapper, def, record, __opts); + } else { + task = self.loadHasMany(mapper, def, record, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, record, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, record, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, record, __opts); + } + if (task) { + tasks.push(task); + } + }); + + return Promise.all(tasks); + }).then(function () { + var response = new Response(record, {}, 'find'); + response.found = record ? 1 : 0; + response = self.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Retrieve the records that match the selection query. + * + * @name Adapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + opts || (opts = {}); + opts.with || (opts.with = []); + + var records = []; + var op = void 0; + var activeWith = opts._activeWith; + + if (jsData.utils.isObject(activeWith)) { + var activeQuery = activeWith.query || {}; + if (activeWith.replace) { + query = activeQuery; + } else { + jsData.utils.deepFillIn(query, activeQuery); + } + } + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._findAll(mapper, query, opts)); + }).then(function (results) { + var _results7 = babelHelpers.slicedToArray(results, 1); + + var _records = _results7[0]; + + _records || (_records = []); + records = _records; + var tasks = []; + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasMany') { + task = self.loadHasMany(mapper, def, records, __opts); + } else { + task = self.loadHasOne(mapper, def, records, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } + }); + return Promise.all(tasks); + }).then(function () { + var response = new Response(records, {}, 'findAll'); + response.found = records.length; + response = self.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Resolve the value of the specified option based on the given options and + * this adapter's settings. Override with care. + * + * @name Adapter#getOpt + * @method + * @param {string} opt The name of the option. + * @param {Object} [opts] Configuration options. + * @return {*} The value of the specified option. + */ + getOpt: function getOpt(opt, opts) { + opts || (opts = {}); + return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); + }, + + + /** + * Logging utility method. Override this method if you want to send log + * messages to something other than the console. + * + * @name Adapter#log + * @method + * @param {string} level Log level. + * @param {...*} values Values to log. + */ + log: function log(level) { + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + if (level && !args.length) { + args.push(level); + level = 'debug'; + } + if (level === 'debug' && !this.debug) { + return; + } + var prefix = level.toUpperCase() + ': (Adapter)'; + if (console[level]) { + var _console; + + (_console = console)[level].apply(_console, [prefix].concat(args)); + } else { + var _console2; + + (_console2 = console).log.apply(_console2, [prefix].concat(args)); + } + }, + + + /** + * Retrieve sum of the specified field of the records that match the selection + * query. Called by `Mapper#sum`. + * + * @name Adapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field By to sum. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + var op = void 0; + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + query || (query = {}); + opts || (opts = {}); + + // beforeSum lifecycle hook + op = opts.op = 'beforeSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + self.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(self._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results8 = babelHelpers.slicedToArray(results, 2); + + var data = _results8[0]; + var result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * @name Adapter#respond + * @method + * @param {Object} response Response object. + * @param {Object} opts Configuration options. + * return {Object} If `opts.raw == true` then return `response`, else return + * `response.data`. + */ + respond: function respond(response, opts) { + return this.getOpt('raw', opts) ? response : response.data; + }, + + + /** + * Apply the given update to the record with the specified primary key. Called + * by `Mapper#update`. + * + * @name Adapter#update + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id The primary key of the record to be updated. + * @param {Object} props The update to apply to the record. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + op = opts.op = 'update'; + self.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(self._update(mapper, id, props, opts)); + }).then(function (results) { + var _results9 = babelHelpers.slicedToArray(results, 2); + + var data = _results9[0]; + var result = _results9[1]; + + result || (result = {}); + var response = new Response(data, result, 'update'); + response.updated = data ? 1 : 0; + response = self.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Apply the given update to all records that match the selection query. + * Called by `Mapper#updateAll`. + * + * @name Adapter#updateAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + op = opts.op = 'updateAll'; + self.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results10 = babelHelpers.slicedToArray(results, 2); + + var data = _results10[0]; + var result = _results10[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateAll'); + response.updated = data.length; + response = self.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Update the given records in a single batch. Called by `Mapper#updateMany`. + * + * @name Adapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + records || (records = []); + opts || (opts = {}); + var op = void 0; + var idAttribute = mapper.idAttribute; + + records = records.filter(function (record) { + return jsData.utils.get(record, idAttribute); + }); + + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = jsData.utils.isUndefined(_records) ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'updateMany'; + self.dbg(op, mapper, records, opts); + return jsData.utils.resolve(self._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results11 = babelHelpers.slicedToArray(results, 2); + + var data = _results11[0]; + var result = _results11[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateMany'); + response.updated = data.length; + response = self.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + } + }); + + module.exports = Adapter; + + })); + //# sourceMappingURL=js-data-adapter.js.map + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + module.exports = undefined; + +/***/ } +/******/ ]) +}); +; +//# sourceMappingURL=js-data-fetch.js.map \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.js.map b/fetch/dist/js-data-fetch.js.map new file mode 100644 index 0000000..6710742 --- /dev/null +++ b/fetch/dist/js-data-fetch.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 27f47e9c2e60000cdeca","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/js-data-adapter/dist/js-data-adapter.js","webpack:///external \"undefined\""],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;ACpCA;;AACA;;;;;;;AAFA,KAAM,QAAQ,oBAAQ,CAAR,CAAR;;;AAIN,KAAI,WAAW,KAAX;;AAEJ,KAAI;AACF,cAAW,UAAU,OAAO,KAAP,CADnB;EAAJ,CAEE,OAAO,CAAP,EAAU,EAAV;;AAEF,KAAM,OAAO,SAAP,IAAO,GAAmB;AAC9B,OAAM,OAAO,IAAP,CADwB;;qCAAN;;IAAM;;AAE9B,OAAM,OAAO,KAAK,KAAK,MAAL,GAAc,CAAd,CAAZ,CAFwB;AAG9B,QAAK,GAAL,cAAS,KAAK,EAAL,SAAY,KAArB,EAH8B;AAI9B,UAAO,cAAM,OAAN,EAAP,CAJ8B;EAAnB;;AAOb,KAAM,QAAQ,SAAR,KAAQ,GAAmB;AAC/B,OAAM,OAAO,IAAP,CADyB;;sCAAN;;IAAM;;AAE/B,OAAM,OAAO,KAAK,KAAK,MAAL,GAAc,CAAd,CAAZ,CAFyB;AAG/B,QAAK,GAAL,cAAS,KAAK,EAAL,SAAY,KAArB,EAH+B;AAI/B,UAAO,cAAM,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gBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,QAAO,OAAP,GAAiB,WAAjB,C;;;;;;AC3uCA,gD;;;;;;ACAA;AACA;AACA;AACA;AACA,EAAC,0BAA0B;;AAE3B;AACA;AACA;AACA,IAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;AACL;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kDAAiD,+BAA+B;AAChF;;AAEA;AACA;AACA,QAAO;AACP;AACA;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA,QAAO;AACP;AACA;AACA;AACA,IAAG;;AAEH;;AAEA;AACA;;AAEA,oEAAmE,aAAa;AAChF;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,uEAAsE,eAAe;AACrF;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB,cAAa,QAAQ;AACrB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,uBAAsB;AACtB;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,iBAAgB,OAAO;AACvB,iBAAgB,OAAO;AACvB;AACA;AACA;AACA,uBAAsB;AACtB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB;AACA,cAAa,OAAO;AACpB;AACA,eAAc,OAAO;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,6BAA6B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,8BAA8B,eAAe;AAC9E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,+BAA+B,eAAe;AAC7E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,gCAAgC,eAAe;AAChF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,iCAAiC,eAAe;AAC/E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAwE,eAAe;AACvF;AACA;;AAEA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA,oDAAmD;AACnD;AACA;AACA,kBAAiB;AACjB,gBAAe;AACf,cAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA,gBAAe;AACf;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA,gDAA+C;AAC/C;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA,QAAO;AACP,+CAA8C;AAC9C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,QAAO;AACP,gDAA+C;AAC/C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,iBAAgB,EAAE;AAClB;AACA;AACA,yBAAwB;AACxB;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,KAAK;AACpB;AACA;AACA,6FAA4F,eAAe;AAC3G;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,QAAO;AACP;;AAEA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB;AACA;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;AACxB;AACA;;AAEA;AACA;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP;AACA,IAAG;;AAEH;;AAEA,EAAC;AACD,4C;;;;;;AC3lDA,4B","file":"./fetch/dist/js-data-fetch.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"js-data\"), require(\"undefined\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"js-data\", \"undefined\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"HttpAdapter\"] = factory(require(\"js-data\"), require(\"undefined\"));\n\telse\n\t\troot[\"HttpAdapter\"] = factory(root[\"JSData\"], root[\"undefined\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_3__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 27f47e9c2e60000cdeca\n **/","/* global fetch:true Headers:true Request:true */\nconst axios = require('axios')\nimport {utils} from 'js-data'\nimport Adapter from 'js-data-adapter'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nconst noop2 = function (...args) {\n const self = this\n const opts = args[args.length - 2]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:\\/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (window.toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n // Default and user-defined settings\n /**\n * @name HttpAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n */\n forceTrailingSlash: false,\n\n /**\n * @name HttpAdapter#http\n * @type {Function}\n */\n http: axios,\n\n /**\n * @name HttpAdapter#httpConfig\n * @type {Object}\n */\n httpConfig: {},\n\n /**\n * @name HttpAdapter#suffix\n * @type {string}\n */\n suffix: '',\n\n /**\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @class HttpAdapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {boolean} [opts.forceTrailingSlash=false] TODO\n * @param {Object} [opts.http=axios] TODO\n * @param {Object} [opts.httpConfig={}] TODO\n * @param {string} [opts.suffix=''] TODO\n * @param {boolean} [opts.useFetch=false] TODO\n */\nfunction HttpAdapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nHttpAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: HttpAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(HttpAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\nutils.addHiddenPropsToTarget(HttpAdapter.prototype, {\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {Object} url\n * @param {Object} config\n * @param {Object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {Object} url\n * @param {Object} config\n * @param {Object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {Object} config\n * @param {Object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {Object} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {Object} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('count', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('create', mapper, props, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('createMany', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroy', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroyAll', mapper, null, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n const self = this\n return self.GET(\n self.getPath('find', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n return self.GET(\n self.getPath('sum', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n return self.PUT(\n self.getPath('update', mapper, id, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateAll', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateMany', mapper, null, opts),\n self.serialize(mapper, records, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params.count = true\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.count.call(self, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props Properties to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.create.call(self, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.createMany.call(self, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {Object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'DEL'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {Object} mapper The mapper used for the operation.\n * @param {Object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {Object} opts Configuration options.\n * @return {(Object|Array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroy.call(self, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroyAll.call(self, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {Object} config Request configuration.\n * @param {Object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {Object} config.headers Headers for the request.\n * @param {Object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n * @param {Object} [opts] Configuration options.\n */\n fetch (config, opts) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers)\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json().then(function (data) {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.find.call(self, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.findAll.call(self, mapper, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {Object} config Request configuration options.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'GET'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {boolean} opts TODO\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach(function (def) {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, function (value, key) {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method TODO\n * @param {Object} mapper TODO\n * @param {(string|number)?} id TODO\n * @param {Object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const args = [\n utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath,\n self.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.params)) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.suffix)) {\n if (utils.isUndefined(mapper.suffix)) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {Object} config Request configuration options.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const self = this\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, self.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || self.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n function logResponse (data) {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (self.log) {\n self.dbg('debug', str, data)\n }\n return data\n } else {\n if (self.error) {\n self.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!self.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) {\n config = _config || config\n if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) {\n return self.fetch(config, opts).then(logResponse, logResponse)\n }\n return self.http(config).then(logResponse, logResponse).catch(function (err) {\n return self.responseError(err, config, opts)\n })\n }).then(function (response) {\n return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) {\n return _response || response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'POST'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'PUT'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {Object} mapper TODO\n * @param {*} params TODO\n * @param {*} opts TODO\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {Object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {Object} mapper TODO\n * @param {Object} data TODO\n * @param {*} opts TODO\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n if (!utils.utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = self.getParams(opts)\n opts.params.sum = field\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.sum.call(self, mapper, field, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#update\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {*} props TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.update.call(self, mapper, id, props, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {Object} mapper TODO\n * @param {Object} props TODO\n * @param {Object} query TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateAll.call(self, mapper, props, query, opts)\n },\n\n /**\n * Update multiple records in batch.\n *\n * {@link HttpAdapter#beforeUpdateMany} will be called before calling\n * {@link HttpAdapter#PUT}.\n * {@link HttpAdapter#afterUpdateMany} will be called after calling\n * {@link HttpAdapter#PUT}.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} records Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateMany.call(self, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @name HttpAdapter.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {Object} [opts] Action configuration\n * @param {string} [opts.adapter]\n * @param {string} [opts.pathname]\n * @param {Function} [opts.request]\n * @param {Function} [opts.response]\n * @param {Function} [opts.responseError]\n * @return {Function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nHttpAdapter.addAction = function (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n const self = this\n if (utils.isObject(id)) {\n _opts = id\n }\n _opts = _opts || {}\n let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http')\n let config = {}\n utils.fillIn(config, opts)\n if (!_opts.hasOwnProperty('endpoint') && config.endpoint) {\n _opts.endpoint = config.endpoint\n }\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(self, _opts)\n } else {\n let args = [\n _opts.basePath || self.basePath || adapter.basePath,\n adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n config.method = config.method || 'GET'\n config.mapper = self.name\n utils.deepMixIn(config)(_opts)\n return utils.resolve(config)\n .then(_opts.request || opts.request)\n .then(function (config) { return adapter.HTTP(config) })\n .then(function (data) {\n if (data && data.config) {\n data.config.mapper = self.name\n }\n return data\n })\n .then(_opts.response || opts.response, _opts.responseError || opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @name HttpAdapter.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 */\nHttpAdapter.addActions = function (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(mapper, function (value, key) {\n HttpAdapter.addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Alternative to ES6 class syntax for extending `HttpAdapter`.\n *\n * __ES6__:\n * ```javascript\n * class MyHttpAdapter extends HttpAdapter {\n * deserialize (Model, data, opts) {\n * const data = super.deserialize(Model, data, opts)\n * data.foo = 'bar'\n * return data\n * }\n * }\n * ```\n *\n * __ES5__:\n * ```javascript\n * var instanceProps = {\n * // override deserialize\n * deserialize: function (Model, data, opts) {\n * var Ctor = this.constructor\n * var superDeserialize = (Ctor.__super__ || Object.getPrototypeOf(Ctor)).deserialize\n * // call the super deserialize\n * var data = superDeserialize(Model, data, opts)\n * data.foo = 'bar'\n * return data\n * },\n * say: function () { return 'hi' }\n * }\n * var classProps = {\n * yell: function () { return 'HI' }\n * }\n *\n * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps)\n * var adapter = new MyHttpAdapter()\n * adapter.say() // \"hi\"\n * MyHttpAdapter.yell() // \"HI\"\n * ```\n *\n * @name HttpAdapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `HttpAdapter`.\n */\nHttpAdapter.extend = utils.extend\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name HttpAdapter.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 */\nHttpAdapter.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 * __Script tag__:\n * ```javascript\n * window.HttpAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var HttpAdapter = require('js-data-http')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import HttpAdapter from 'js-data-http'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-http'], function (HttpAdapter) { ... })\n * ```\n *\n * @module js-data-http\n */\n\nmodule.exports = HttpAdapter\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}\n ** module id = 1\n ** module chunks = 0\n **/","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('js-data')) :\n typeof define === 'function' && define.amd ? define('js-data-adapter', ['js-data'], factory) :\n (factory(global.JSData));\n}(this, function (jsData) { 'use strict';\n\n var babelHelpers = {};\n babelHelpers.typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n };\n\n babelHelpers.defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n };\n\n babelHelpers.slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n }();\n\n babelHelpers;\n\n var noop = function noop() {\n var self = this;\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var opts = args[args.length - 1];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var noop2 = function noop2() {\n var self = this;\n\n for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n var opts = args[args.length - 2];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var unique = function unique(array) {\n var seen = {};\n var final = [];\n array.forEach(function (item) {\n if (item in seen) {\n return;\n }\n final.push(item);\n seen[item] = 0;\n });\n return final;\n };\n\n var withoutRelations = function withoutRelations(mapper, props) {\n return jsData.utils.omit(props, mapper.relationFields || []);\n };\n\n var DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n };\n\n /**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\n function Adapter(opts) {\n var self = this;\n opts || (opts = {});\n jsData.utils.fillIn(opts, DEFAULTS);\n jsData.utils.fillIn(self, opts);\n }\n\n Adapter.reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where'];\n\n /**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @typedef {Object} Response\n * @property {Object} data Response data.\n * @property {string} op The operation for which the response was created.\n */\n function Response(data, meta, op) {\n var self = this;\n meta || (meta = {});\n self.data = data;\n jsData.utils.fillIn(self, meta);\n self.op = op;\n }\n\n Adapter.Response = Response;\n\n /**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\n Adapter.extend = jsData.utils.extend;\n\n jsData.utils.addHiddenPropsToTarget(Adapter.prototype, {\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} props The `props` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg: function dbg() {\n for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n\n this.log.apply(this, ['debug'].concat(args));\n },\n\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count: function count(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._count(mapper, query, opts));\n }).then(function (results) {\n var _results = babelHelpers.slicedToArray(results, 2);\n\n var data = _results[0];\n var result = _results[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create: function create(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'create';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._create(mapper, props, opts));\n }).then(function (results) {\n var _results2 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results2[0];\n var result = _results2[1];\n\n result || (result = {});\n var response = new Response(data, result, 'create');\n response.created = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany: function createMany(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = props.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'createMany';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._createMany(mapper, props, opts));\n }).then(function (results) {\n var _results3 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results3[0];\n var result = _results3[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'createMany');\n response.created = data.length;\n response = self.respond(response, opts);\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy: function destroy(mapper, id, opts) {\n var self = this;\n var op = void 0;\n opts || (opts = {});\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._destroy(mapper, id, opts));\n }).then(function (results) {\n var _results4 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results4[0];\n var result = _results4[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroy');\n response = self.respond(response, opts);\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll: function destroyAll(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._destroyAll(mapper, query, opts));\n }).then(function (results) {\n var _results5 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results5[0];\n var result = _results5[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroyAll');\n response = self.respond(response, opts);\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\n\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) {\n var localKeys = [];\n var itemKeys = jsData.utils.get(record, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n localKeys = localKeys.concat(itemKeys);\n return unique(localKeys).filter(function (x) {\n return x;\n });\n },\n\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) {\n return jsData.utils.get(record, mapper.idAttribute);\n },\n\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany: function loadHasMany(mapper, def, records, __opts) {\n var self = this;\n var singular = false;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n singular = true;\n records = [records];\n }\n var IDs = records.map(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record);\n });\n var query = {\n where: {}\n };\n var criteria = query.where[def.foreignKey] = {};\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0];\n } else {\n criteria['in'] = IDs.filter(function (id) {\n return id;\n });\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n var attached = [];\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems;\n } else {\n relatedItems.forEach(function (relatedItem) {\n if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem);\n }\n });\n }\n def.setLocalField(record, attached);\n });\n });\n },\n loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) {\n var self = this;\n var record = void 0;\n var relatedMapper = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n var _ret = function () {\n var localKeys = [];\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record));\n });\n return {\n v: self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': unique(localKeys).filter(function (x) {\n return x;\n })\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n var attached = [];\n var itemKeys = jsData.utils.get(item, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n relatedItems.forEach(function (relatedItem) {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem);\n }\n });\n def.setLocalField(item, attached);\n });\n return relatedItems;\n })\n };\n }();\n\n if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === \"object\") return _ret.v;\n }\n },\n loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) {\n var self = this;\n var relatedMapper = def.getRelation();\n var idAttribute = mapper.idAttribute;\n var record = void 0;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(def.getRelation(), {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record);\n })\n })\n }, __opts).then(function (relatedItems) {\n var foreignKeysField = def.foreignKeys;\n records.forEach(function (record) {\n var _relatedItems = [];\n var id = jsData.utils.get(record, idAttribute);\n relatedItems.forEach(function (relatedItem) {\n var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || [];\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem);\n }\n });\n def.setLocalField(record, _relatedItems);\n });\n });\n }\n },\n\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne: function loadHasOne(mapper, def, records, __opts) {\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n records = [records];\n }\n return this.loadHasMany(mapper, def, records, __opts).then(function () {\n records.forEach(function (record) {\n var relatedData = def.getLocalField(record);\n if (jsData.utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0]);\n }\n });\n });\n },\n\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\n\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) {\n var self = this;\n var relationDef = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n var _ret2 = function () {\n var record = records;\n return {\n v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem);\n })\n };\n }();\n\n if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === \"object\") return _ret2.v;\n } else {\n var keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record);\n }).filter(function (key) {\n return key;\n });\n return self.findAll(relationDef, {\n where: babelHelpers.defineProperty({}, relationDef.idAttribute, {\n 'in': keys\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem);\n }\n });\n });\n });\n }\n },\n\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find: function find(mapper, id, opts) {\n var self = this;\n var record = void 0,\n op = void 0;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._find(mapper, id, opts));\n }).then(function (results) {\n var _results6 = babelHelpers.slicedToArray(results, 1);\n\n var _record = _results6[0];\n\n if (!_record) {\n return;\n }\n record = _record;\n var tasks = [];\n\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts);\n } else {\n task = self.loadHasMany(mapper, def, record, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(record, {}, 'find');\n response.found = record ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll: function findAll(mapper, query, opts) {\n var self = this;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n var records = [];\n var op = void 0;\n var activeWith = opts._activeWith;\n\n if (jsData.utils.isObject(activeWith)) {\n var activeQuery = activeWith.query || {};\n if (activeWith.replace) {\n query = activeQuery;\n } else {\n jsData.utils.deepFillIn(query, activeQuery);\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._findAll(mapper, query, opts));\n }).then(function (results) {\n var _results7 = babelHelpers.slicedToArray(results, 1);\n\n var _records = _results7[0];\n\n _records || (_records = []);\n records = _records;\n var tasks = [];\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts);\n } else {\n task = self.loadHasOne(mapper, def, records, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(records, {}, 'findAll');\n response.found = records.length;\n response = self.respond(response, opts);\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt: function getOpt(opt, opts) {\n opts || (opts = {});\n return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]);\n },\n\n\n /**\n * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log: function log(level) {\n for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n args[_key4 - 1] = arguments[_key4];\n }\n\n if (level && !args.length) {\n args.push(level);\n level = 'debug';\n }\n if (level === 'debug' && !this.debug) {\n return;\n }\n var prefix = level.toUpperCase() + ': (Adapter)';\n if (console[level]) {\n var _console;\n\n (_console = console)[level].apply(_console, [prefix].concat(args));\n } else {\n var _console2;\n\n (_console2 = console).log.apply(_console2, [prefix].concat(args));\n }\n },\n\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum: function sum(mapper, field, query, opts) {\n var self = this;\n var op = void 0;\n if (!jsData.utils.isString(field)) {\n throw new Error('field must be a string!');\n }\n query || (query = {});\n opts || (opts = {});\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum';\n return jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum';\n self.dbg(op, mapper, field, query, opts);\n return jsData.utils.resolve(self._sum(mapper, field, query, opts));\n }).then(function (results) {\n var _results8 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results8[0];\n var result = _results8[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum';\n return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond: function respond(response, opts) {\n return this.getOpt('raw', opts) ? response : response.data;\n },\n\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update: function update(mapper, id, props, opts) {\n var self = this;\n props || (props = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n op = opts.op = 'update';\n self.dbg(op, mapper, id, props, opts);\n return jsData.utils.resolve(self._update(mapper, id, props, opts));\n }).then(function (results) {\n var _results9 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results9[0];\n var result = _results9[1];\n\n result || (result = {});\n var response = new Response(data, result, 'update');\n response.updated = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll: function updateAll(mapper, props, query, opts) {\n var self = this;\n props || (props = {});\n query || (query = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n op = opts.op = 'updateAll';\n self.dbg(op, mapper, props, query, opts);\n return jsData.utils.resolve(self._updateAll(mapper, props, query, opts));\n }).then(function (results) {\n var _results10 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results10[0];\n var result = _results10[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateAll');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany: function updateMany(mapper, records, opts) {\n var self = this;\n records || (records = []);\n opts || (opts = {});\n var op = void 0;\n var idAttribute = mapper.idAttribute;\n\n records = records.filter(function (record) {\n return jsData.utils.get(record, idAttribute);\n });\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = jsData.utils.isUndefined(_records) ? records : _records;\n records = records.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'updateMany';\n self.dbg(op, mapper, records, opts);\n return jsData.utils.resolve(self._updateMany(mapper, records, opts));\n }).then(function (results) {\n var _results11 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results11[0];\n var result = _results11[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateMany');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n }\n });\n\n module.exports = Adapter;\n\n}));\n//# sourceMappingURL=js-data-adapter.js.map\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/js-data-adapter/dist/js-data-adapter.js\n ** module id = 2\n ** module chunks = 0\n **/","module.exports = undefined;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"undefined\"\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.min.js b/fetch/dist/js-data-fetch.min.js new file mode 100644 index 0000000..35f0608 --- /dev/null +++ b/fetch/dist/js-data-fetch.min.js @@ -0,0 +1,10 @@ +/*! +* js-data-fetch +* @version 3.0.0-beta.2 - Homepage +* @copyright (c) 2014-2016 js-data-http project authors +* @license MIT +* +* @overview HTTP adapter for js-data that uses the fetch API. +*/ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("js-data"),require("undefined")):"function"==typeof define&&define.amd?define(["js-data","undefined"],t):"object"==typeof exports?exports.HttpAdapter=t(require("js-data"),require("undefined")):e.HttpAdapter=t(e.JSData,e.undefined)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e){return null!=e&&""!==e}function o(e,t){return t||(t=""),e.filter(i).join(t)}function u(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var r=o(t,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function a(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function s(e,t){if(!t)return e;var n=[];return d.utils.forOwn(t,function(e,t){null!==e&&"undefined"!=typeof e&&(d.utils.isArray(e)||(e=[e]),e.forEach(function(e){"[object Date]"===window.toString.call(e)?e=e.toISOString():d.utils.isObject(e)&&(e=d.utils.toJson(e)),n.push(a(t)+"="+a(e))}))}),n.length>0&&(e+=(-1===e.indexOf("?")?"?":"&")+n.join("&")),e}function l(e){var t=this;e||(e={}),d.utils.fillIn(e,b),p.default.call(t,e)}var f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},d=n(1),c=n(2),p=r(c),h=n(3),y=!1;try{y=window&&window.fetch}catch(e){}var v=function(){for(var e=this,t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var i=n[n.length-1];return e.dbg.apply(e,[i.op].concat(n)),d.utils.resolve()},g=function(){for(var e=this,t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var i=n[n.length-2];return e.dbg.apply(e,[i.op].concat(n)),d.utils.resolve()},m=p.default.prototype,b={basePath:"",forceTrailingSlash:!1,http:h,httpConfig:{},suffix:"",useFetch:!1};l.prototype=Object.create(p.default.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(l,"__super__",{configurable:!0,value:p.default}),d.utils.addHiddenPropsToTarget(l.prototype,{afterDEL:g,afterGET:g,afterHTTP:g,afterPOST:g,afterPUT:g,beforeDEL:v,beforeGET:v,beforeHTTP:v,beforePOST:v,beforePUT:v,_count:function(e,t,n){var r=this;return r.GET(r.getPath("count",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_create:function(e,t,n){var r=this;return r.POST(r.getPath("create",e,t,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_createMany:function(e,t,n){var r=this;return r.POST(r.getPath("createMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroy:function(e,t,n){var r=this;return r.DEL(r.getPath("destroy",e,t,n),n).then(function(t){return r._end(e,n,t)})},_destroyAll:function(e,t,n){var r=this;return r.DEL(r.getPath("destroyAll",e,null,n),n).then(function(t){return r._end(e,n,t)})},_end:function(e,t,n){return[this.deserialize(e,n,t),n]},_find:function(e,t,n){var r=this;return r.GET(r.getPath("find",e,t,n),n).then(function(t){return r._end(e,n,t)})},_findAll:function(e,t,n){var r=this;return r.GET(r.getPath("findAll",e,n.params,n),n).then(function(t){return r._end(e,n,t)})},_sum:function(e,t,n,r){var i=this;return i.GET(i.getPath("sum",e,r.params,r),r).then(function(t){return i._end(e,r,t)})},_update:function(e,t,n,r){var i=this;return i.PUT(i.getPath("update",e,t,r),i.serialize(e,n,r),r).then(function(t){return i._end(e,r,t)})},_updateAll:function(e,t,n,r){var i=this;return i.PUT(i.getPath("updateAll",e,null,r),i.serialize(e,t,r),r).then(function(t){return i._end(e,r,t)})},_updateMany:function(e,t,n){var r=this;return r.PUT(r.getPath("updateMany",e,null,n),r.serialize(e,t,n),n).then(function(t){return r._end(e,n,t)})},count:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),n.params.count=!0,n.suffix=r.getSuffix(e,n),d.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),m.count.call(r,e,t,n)},create:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),m.create.call(r,e,t,n)},createMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),m.createMany.call(r,e,t,n)},DEL:function(e,t,n){var r=this,i=void 0;return t||(t={}),n||(n={}),t.url=e||t.url,t.method=t.method||"delete",i=n.op="beforeDEL",d.utils.resolve(r[i](e,t,n)).then(function(o){return t=d.utils.isUndefined(o)?t:o,i=n.op="DEL",r.dbg(i,e,t,n),r.HTTP(t,n)}).then(function(o){return i=n.op="afterDEL",d.utils.resolve(r[i](e,t,n,o)).then(function(e){return d.utils.isUndefined(e)?o:e})})},deserialize:function(e,t,n){return n||(n={}),d.utils.isFunction(n.deserialize)?n.deserialize(e,t,n):d.utils.isFunction(e.deserialize)?e.deserialize(e,t,n):t&&t.hasOwnProperty("data")?t.data:t},destroy:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),m.destroy.call(r,e,t,n)},destroyAll:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),d.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),m.destroyAll.call(r,e,t,n)},error:function(){if(console){var e;(e=console)["function"==typeof console.error?"error":"log"].apply(e,arguments)}},fetch:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,t){var n={method:e.method,headers:new Headers(e.headers)};return e.data&&(n.body=d.utils.toJson(e.data)),fetch(new Request(s(e.url,e.params),n)).then(function(t){return t.config={method:e.method,url:e.url},t.json().then(function(e){return t.data=e,t})})}),find:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),m.find.call(r,e,t,n)},findAll:function(e,t,n){var r=this;return t||(t={}),n||(n={}),n.params=r.getParams(n),n.suffix=r.getSuffix(e,n),d.utils.deepMixIn(n.params,t),n.params=r.queryTransform(e,n.params,n),m.findAll.call(r,e,t,n)},GET:function(e,t,n){var r=this,i=void 0;return t||(t={}),n||(n={}),t.url=e||t.url,t.method=t.method||"get",i=n.op="beforeGET",d.utils.resolve(r[i](e,t,n)).then(function(o){return t=d.utils.isUndefined(o)?t:o,i=n.op="GET",r.dbg(i,e,t,n),r.HTTP(t,n)}).then(function(o){return i=n.op="afterGET",d.utils.resolve(r[i](e,t,n,o)).then(function(e){return d.utils.isUndefined(e)?o:e})})},getEndpoint:function(e,t,n){var r=this;n||(n={}),n.params=d.utils.isUndefined(n.params)?{}:n.params;var i=e.relationList||[],o=d.utils.isUndefined(n.endpoint)?d.utils.isUndefined(e.endpoint)?e.name:e.endpoint:n.endpoint;return i.forEach(function(e){if("belongsTo"===e.type&&e.parent){var i=void 0,a=e.foreignKey,s=e.getRelation(),l=n.params[a];if(l===!1||!a||!s)return l===!1&&delete n.params[a],!1;if(delete n.params[a],d.utils.isObject(t)&&(i=t),i&&(l=l||e.getForeignKey(i)||(e.getLocalField(i)?d.utils.get(e.getLocalField(i),s.idAttribute):null)),l){var c=function(){delete n.endpoint;var e={};return d.utils.forOwn(n,function(t,n){e[n]=t}),d.utils._(e,s),o=u(r.getEndpoint(s,l,e),l,o),{v:!1}}();if("object"===("undefined"==typeof c?"undefined":f(c)))return c.v}}}),o},getPath:function(e,t,n,r){var i=this;r||(r={});var o=[d.utils.isUndefined(r.basePath)?d.utils.isUndefined(t.basePath)?i.basePath:t.basePath:r.basePath,i.getEndpoint(t,d.utils.isString(n)||d.utils.isNumber(n)||"create"===e?n:null,r)];return"find"!==e&&"update"!==e&&"destroy"!==e||o.push(n),u.apply(d.utils,o)},getParams:function(e){return e||(e={}),d.utils.isUndefined(e.params)?{}:d.utils.copy(e.params)},getSuffix:function(e,t){return t||(t={}),d.utils.isUndefined(t.suffix)?d.utils.isUndefined(e.suffix)?this.suffix:e.suffix:t.suffix},HTTP:function(e,t){function n(t){var n=i.toUTCString()+" - "+e.method.toUpperCase()+" "+e.url+" - "+t.status+" "+((new Date).getTime()-i.getTime())+"ms";return t.status>=200&&t.status<300?(r.log&&r.dbg("debug",n,t),t):(r.error&&r.error("'FAILED: "+n,t),d.utils.reject(t))}var r=this,i=new Date;t||(t={});var o=e.data,u=e.cache,a=e.timeout;e=d.utils.copy(e,null,null,null,["data","cache","timeout"]),e=d.utils.deepMixIn(e,r.httpConfig),e.data=o,e.cache=u,e.timeout=a,r.forceTrailingSlash&&"/"!==e.url[e.url.length-1]&&(e.url+="/"),e.method=e.method.toUpperCase();var s=e.suffix||t.suffix||r.suffix;if(s&&e.url.substr(e.url.length-s.length)!==s&&(e.url+=s),!r.http)throw new Error("You have not configured this adapter with an http library!");return d.utils.resolve(r.beforeHTTP(e,t)).then(function(i){return e=i||e,y&&(r.useFetch||t.useFetch||!r.http)?r.fetch(e,t).then(n,n):r.http(e).then(n,n).catch(function(n){return r.responseError(n,e,t)})}).then(function(n){return d.utils.resolve(r.afterHTTP(e,t,n)).then(function(e){return e||n})})},POST:function(e,t,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.data=t||n.data,n.method=n.method||"post",o=r.op="beforePOST",d.utils.resolve(i[o](e,t,n,r)).then(function(u){return n=d.utils.isUndefined(u)?n:u,o=r.op="POST",i.dbg(o,e,t,n,r),i.HTTP(n,r)}).then(function(u){return o=r.op="afterPOST",d.utils.resolve(i[o](e,t,n,r,u)).then(function(e){return d.utils.isUndefined(e)?u:e})})},PUT:function(e,t,n,r){var i=this,o=void 0;return n||(n={}),r||(r={}),n.url=e||n.url,n.data=t||n.data,n.method=n.method||"put",o=r.op="beforePUT",d.utils.resolve(i[o](e,t,n,r)).then(function(u){return n=d.utils.isUndefined(u)?n:u,o=r.op="PUT",i.dbg(o,e,t,n,r),i.HTTP(n,r)}).then(function(u){return o=r.op="afterPUT",d.utils.resolve(i[o](e,t,n,r,u)).then(function(e){return d.utils.isUndefined(e)?u:e})})},queryTransform:function(e,t,n){return n||(n={}),d.utils.isFunction(n.queryTransform)?n.queryTransform(e,t,n):d.utils.isFunction(e.queryTransform)?e.queryTransform(e,t,n):t},responseError:function(e,t,n){return d.utils.reject(e)},serialize:function(e,t,n){return n||(n={}),d.utils.isFunction(n.serialize)?n.serialize(e,t,n):d.utils.isFunction(e.serialize)?e.serialize(e,t,n):t},sum:function(e,t,n,r){var i=this;if(n||(n={}),r||(r={}),!d.utils.utils.isString(t))throw new Error("field must be a string!");return r.params=i.getParams(r),r.params.sum=t,r.suffix=i.getSuffix(e,r),d.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),m.sum.call(i,e,t,n,r)},update:function(e,t,n,r){var i=this;return r||(r={}),r.params=i.getParams(r),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),m.update.call(i,e,t,n,r)},updateAll:function(e,t,n,r){var i=this;return n||(n={}),r||(r={}),r.params=i.getParams(r),d.utils.deepMixIn(r.params,n),r.params=i.queryTransform(e,r.params,r),r.suffix=i.getSuffix(e,r),m.updateAll.call(i,e,t,n,r)},updateMany:function(e,t,n){var r=this;return n||(n={}),n.params=r.getParams(n),n.params=r.queryTransform(e,n.params,n),n.suffix=r.getSuffix(e,n),m.updateMany.call(r,e,t,n)}}),l.addAction=function(e,t){if(!e||!d.utils.isString(e))throw new TypeError("action(name[, opts]): Expected: string, Found: "+("undefined"==typeof e?"undefined":f(e)));return function(n){if(n[e])throw new Error("action(name[, opts]): "+e+" already exists on target!");return t.request=t.request||function(e){return e},t.response=t.response||function(e){return e},t.responseError=t.responseError||function(e){return d.utils.reject(e)},n[e]=function(n,r){var i=this;d.utils.isObject(n)&&(r=n),r=r||{};var o=i.getAdapter(t.adapter||i.defaultAdapter||"http"),a={};if(d.utils.fillIn(a,t),!r.hasOwnProperty("endpoint")&&a.endpoint&&(r.endpoint=a.endpoint),"function"==typeof r.getEndpoint)a.url=r.getEndpoint(i,r);else{var s=[r.basePath||i.basePath||o.basePath,o.getEndpoint(i,d.utils.isSorN(n)?n:null,r)];d.utils.isSorN(n)&&s.push(n),s.push(t.pathname||e),a.url=u.apply(null,s)}return a.method=a.method||"GET",a.mapper=i.name,d.utils.deepMixIn(a)(r),d.utils.resolve(a).then(r.request||t.request).then(function(e){return o.HTTP(e)}).then(function(e){return e&&e.config&&(e.config.mapper=i.name),e}).then(r.response||t.response,r.responseError||t.responseError)},n}},l.addActions=function(e){return e||(e={}),function(e){return d.utils.forOwn(e,function(t,n){l.addAction(n,t)(e)}),e}},l.extend=d.utils.extend,l.version={beta:2,full:"3.0.0-beta.2",major:3,minor:0,patch:0},e.exports=l},function(t,n){t.exports=e},function(e,t,n){!function(e,t){t(n(1))}(this,function(t){"use strict";function n(e){var n=this;e||(e={}),t.utils.fillIn(e,l),t.utils.fillIn(n,e)}function r(e,n,r){var i=this;n||(n={}),i.data=e,t.utils.fillIn(i,n),i.op=r}var i={};i.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},i.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},i.slicedToArray=function(){function e(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(i)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var o=function(){for(var e=this,n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r[r.length-1];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},u=function(){for(var e=this,n=arguments.length,r=Array(n),i=0;n>i;i++)r[i]=arguments[i];var o=r[r.length-2];return e.dbg.apply(e,[o.op].concat(r)),t.utils.resolve()},a=function(e){var t={},n=[];return e.forEach(function(e){e in t||(n.push(e),t[e]=0)}),n},s=function(e,n){return t.utils.omit(n,e.relationFields||[])},l={debug:!1,raw:!1};n.reserved=["orderBy","sort","limit","offset","skip","where"],n.Response=r,n.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(n.prototype,{afterCount:u,afterCreate:u,afterCreateMany:u,afterDestroy:u,afterDestroyAll:u,afterFind:u,afterFindAll:u,afterSum:u,afterUpdate:u,afterUpdateAll:u,afterUpdateMany:u,beforeCount:o,beforeCreate:o,beforeCreateMany:o,beforeDestroy:o,beforeDestroyAll:o,beforeFind:o,beforeFindAll:o,beforeSum:o,beforeUpdate:o,beforeUpdateAll:o,beforeUpdateMany:o,dbg:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},count:function(e,n,o){var u=this,a=void 0;return n||(n={}),o||(o={}),a=o.op="beforeCount",t.utils.resolve(u[a](e,n,o)).then(function(){return a=o.op="count",u.dbg(a,e,n,o),t.utils.resolve(u._count(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var c=new r(f,d,a);return c=u.respond(c,o),a=o.op="afterCount",t.utils.resolve(u[a](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},create:function(e,n,o){var u=this,a=void 0;return n||(n={}),o||(o={}),a=o.op="beforeCreate",t.utils.resolve(u[a](e,n,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=s(e,n),a=o.op="create",u.dbg(a,e,n,o),t.utils.resolve(u._create(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var c=new r(f,d,"create");return c.created=f?1:0,c=u.respond(c,o),a=o.op="afterCreate",t.utils.resolve(u[a](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},createMany:function(e,n,o){var u=this,a=void 0;return n||(n={}),o||(o={}),a=o.op="beforeCreateMany",t.utils.resolve(u[a](e,n,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),a=o.op="createMany",u.dbg(a,e,n,o),t.utils.resolve(u._createMany(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];f||(f=[]),d||(d={});var c=new r(f,d,"createMany");return c.created=f.length,c=u.respond(c,o),a=o.op="afterCreateMany",t.utils.resolve(u[a](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},destroy:function(e,n,o){var u=this,a=void 0;return o||(o={}),a=o.op="beforeDestroy",t.utils.resolve(u[a](e,n,o)).then(function(){return a=o.op="destroy",u.dbg(a,e,n,o),t.utils.resolve(u._destroy(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var c=new r(f,d,"destroy");return c=u.respond(c,o),a=o.op="afterDestroy",t.utils.resolve(u[a](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},destroyAll:function(e,n,o){var u=this,a=void 0;return n||(n={}),o||(o={}),a=o.op="beforeDestroyAll",t.utils.resolve(u[a](e,n,o)).then(function(){return a=o.op="destroyAll",u.dbg(a,e,n,o),t.utils.resolve(u._destroyAll(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];d||(d={});var c=new r(f,d,"destroyAll");return c=u.respond(c,o),a=o.op="afterDestroyAll",t.utils.resolve(u[a](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})},makeHasManyForeignKey:function(e,t,n){return t.getForeignKey(n)},makeHasManyLocalKeys:function(e,n,r){var i=[],o=t.utils.get(r,n.localKeys)||[];return o=t.utils.isArray(o)?o:Object.keys(o),i=i.concat(o),a(i).filter(function(e){return e})},makeHasManyForeignKeys:function(e,n,r){return t.utils.get(r,e.idAttribute)},loadHasMany:function(e,n,r,i){var o=this,u=!1;t.utils.isObject(r)&&!t.utils.isArray(r)&&(u=!0,r=[r]);var a=r.map(function(t){return o.makeHasManyForeignKey(e,n,t)}),s={where:{}},l=s.where[n.foreignKey]={};return u?l["=="]=a[0]:l.in=a.filter(function(e){return e}),o.findAll(n.getRelation(),s,i).then(function(i){r.forEach(function(r){var o=[];u?o=i:i.forEach(function(i){t.utils.get(i,n.foreignKey)===r[e.idAttribute]&&o.push(i)}),n.setLocalField(r,o)})})},loadHasManyLocalKeys:function(e,n,r,o){var u=this,s=void 0,l=n.getRelation();if(t.utils.isObject(r)&&!t.utils.isArray(r)&&(s=r),s)return u.findAll(l,{where:i.defineProperty({},l.idAttribute,{in:u.makeHasManyLocalKeys(e,n,s)})},o).then(function(e){n.setLocalField(s,e)});var f=function(){var s=[];return r.forEach(function(t){s=s.concat(u.self.makeHasManyLocalKeys(e,n,t))}),{v:u.findAll(l,{where:i.defineProperty({},l.idAttribute,{in:a(s).filter(function(e){return e})})},o).then(function(e){return r.forEach(function(r){var i=[],o=t.utils.get(r,n.localKeys)||[];o=t.utils.isArray(o)?o:Object.keys(o),e.forEach(function(e){o&&-1!==o.indexOf(e[l.idAttribute])&&i.push(e)}),n.setLocalField(r,i)}),e})}}();return"object"===("undefined"==typeof f?"undefined":i.typeof(f))?f.v:void 0},loadHasManyForeignKeys:function(e,n,r,o){var u=this,a=n.getRelation(),s=e.idAttribute,l=void 0;return t.utils.isObject(r)&&!t.utils.isArray(r)&&(l=r),l?u.findAll(n.getRelation(),{where:i.defineProperty({},n.foreignKeys,{contains:u.makeHasManyForeignKeys(e,n,l)})},o).then(function(e){n.setLocalField(l,e)}):u.findAll(a,{where:i.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(t){return u.makeHasManyForeignKeys(e,n,t)})})},o).then(function(e){var i=n.foreignKeys;r.forEach(function(r){var o=[],u=t.utils.get(r,s);e.forEach(function(n){var r=t.utils.get(e,i)||[];-1!==r.indexOf(u)&&o.push(n)}),n.setLocalField(r,o)})})},loadHasOne:function(e,n,r,i){return t.utils.isObject(r)&&!t.utils.isArray(r)&&(r=[r]),this.loadHasMany(e,n,r,i).then(function(){r.forEach(function(e){var r=n.getLocalField(e);t.utils.isArray(r)&&r.length&&n.setLocalField(e,r[0])})})},makeBelongsToForeignKey:function(e,t,n){return t.getForeignKey(n)},loadBelongsTo:function(e,n,r,o){var u=this,a=n.getRelation();if(!t.utils.isObject(r)||t.utils.isArray(r)){var s=r.map(function(t){return u.makeBelongsToForeignKey(e,n,t)}).filter(function(e){return e});return u.findAll(a,{where:i.defineProperty({},a.idAttribute,{in:s})},o).then(function(e){r.forEach(function(t){e.forEach(function(e){e[a.idAttribute]===t[n.foreignKey]&&n.setLocalField(t,e)})})})}var l=function(){var t=r;return{v:u.find(a,u.makeBelongsToForeignKey(e,n,t),o).then(function(e){n.setLocalField(t,e)})}}();return"object"===("undefined"==typeof l?"undefined":i.typeof(l))?l.v:void 0},find:function(e,n,o){var u=this,a=void 0,s=void 0;return o||(o={}),o.with||(o.with=[]),s=o.op="beforeFind",t.utils.resolve(u[s](e,n,o)).then(function(){return s=o.op="find",u.dbg(s,e,n,o),t.utils.resolve(u._find(e,n,o))}).then(function(n){var r=i.slicedToArray(n,1),s=r[0];if(s){a=s;var l=[];return t.utils.forEachRelation(e,o,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=u.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=u.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=u.loadBelongsTo(e,t,a,n)):r="hasOne"===t.type?u.loadHasOne(e,t,a,n):u.loadHasMany(e,t,a,n),r&&l.push(r)}),Promise.all(l)}}).then(function(){var i=new r(a,{},"find");return i.found=a?1:0,i=u.respond(i,o),s=o.op="afterFind",t.utils.resolve(u[s](e,n,o,i)).then(function(e){return t.utils.isUndefined(e)?i:e})})},findAll:function(e,n,o){var u=this;o||(o={}),o.with||(o.with=[]);var a=[],s=void 0,l=o._activeWith;if(t.utils.isObject(l)){var f=l.query||{};l.replace?n=f:t.utils.deepFillIn(n,f)}return s=o.op="beforeFindAll",t.utils.resolve(u[s](e,n,o)).then(function(){return s=o.op="findAll",u.dbg(s,e,n,o),t.utils.resolve(u._findAll(e,n,o))}).then(function(n){var r=i.slicedToArray(n,1),s=r[0];s||(s=[]),a=s;var l=[];return t.utils.forEachRelation(e,o,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=u.loadHasManyLocalKeys(e,t,a,n):"hasMany"===t.type&&t.foreignKeys?r=u.loadHasManyForeignKeys(e,t,a,n):"belongsTo"===t.type&&(r=u.loadBelongsTo(e,t,a,n)):r="hasMany"===t.type?u.loadHasMany(e,t,a,n):u.loadHasOne(e,t,a,n),r&&l.push(r)}),Promise.all(l)}).then(function(){var i=new r(a,{},"findAll");return i.found=a.length,i=u.respond(i,o),s=o.op="afterFindAll",t.utils.resolve(u[s](e,n,o,i)).then(function(e){return t.utils.isUndefined(e)?i:e})})},getOpt:function(e,n){return n||(n={}),t.utils.isUndefined(n[e])?t.utils.plainCopy(this[e]):t.utils.plainCopy(n[e])},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var i=e.toUpperCase()+": (Adapter)";if(console[e]){var o;(o=console)[e].apply(o,[i].concat(n))}else{var u;(u=console).log.apply(u,[i].concat(n))}}},sum:function(e,n,o,u){var a=this,s=void 0;if(!t.utils.isString(n))throw new Error("field must be a string!");return o||(o={}),u||(u={}),s=u.op="beforeSum",t.utils.resolve(a[s](e,n,o,u)).then(function(){return s=u.op="sum",a.dbg(s,e,n,o,u),t.utils.resolve(a._sum(e,n,o,u))}).then(function(l){var f=i.slicedToArray(l,2),d=f[0],c=f[1];c||(c={});var p=new r(d,c,s);return p=a.respond(p,u),s=u.op="afterSum",t.utils.resolve(a[s](e,n,o,u,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},respond:function(e,t){return this.getOpt("raw",t)?e:e.data},update:function(e,n,o,u){var a=this;o||(o={}),u||(u={});var s=void 0;return s=u.op="beforeUpdate",t.utils.resolve(a[s](e,n,o,u)).then(function(r){return o=t.utils.isUndefined(r)?o:r,s=u.op="update",a.dbg(s,e,n,o,u),t.utils.resolve(a._update(e,n,o,u))}).then(function(l){var f=i.slicedToArray(l,2),d=f[0],c=f[1];c||(c={});var p=new r(d,c,"update");return p.updated=d?1:0,p=a.respond(p,u),s=u.op="afterUpdate",t.utils.resolve(a[s](e,n,o,u,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateAll:function(e,n,o,u){var a=this;n||(n={}),o||(o={}),u||(u={});var s=void 0;return s=u.op="beforeUpdateAll",t.utils.resolve(a[s](e,n,o,u)).then(function(r){return n=t.utils.isUndefined(r)?n:r,s=u.op="updateAll",a.dbg(s,e,n,o,u),t.utils.resolve(a._updateAll(e,n,o,u))}).then(function(l){var f=i.slicedToArray(l,2),d=f[0],c=f[1];d||(d=[]),c||(c={});var p=new r(d,c,"updateAll");return p.updated=d.length,p=a.respond(p,u),s=u.op="afterUpdateAll",t.utils.resolve(a[s](e,n,o,u,p)).then(function(e){return t.utils.isUndefined(e)?p:e})})},updateMany:function(e,n,o){var u=this;n||(n=[]),o||(o={});var a=void 0,l=e.idAttribute;return n=n.filter(function(e){return t.utils.get(e,l)}),a=o.op="beforeUpdateMany",t.utils.resolve(u[a](e,n,o)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),a=o.op="updateMany",u.dbg(a,e,n,o),t.utils.resolve(u._updateMany(e,n,o))}).then(function(s){var l=i.slicedToArray(s,2),f=l[0],d=l[1];f||(f=[]),d||(d={});var c=new r(f,d,"updateMany");return c.updated=f.length,c=u.respond(c,o),a=o.op="afterUpdateMany",t.utils.resolve(u[a](e,n,o,c)).then(function(e){return t.utils.isUndefined(e)?c:e})})}}),e.exports=n})},function(e,t){e.exports=void 0}])}); +//# sourceMappingURL=js-data-fetch.min.map \ No newline at end of file diff --git a/fetch/dist/js-data-fetch.min.map b/fetch/dist/js-data-fetch.min.map new file mode 100644 index 0000000..516db84 --- /dev/null +++ b/fetch/dist/js-data-fetch.min.map @@ -0,0 +1 @@ +{"version":3,"sources":["fetch/dist/js-data-fetch.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","__WEBPACK_EXTERNAL_MODULE_3__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_interopRequireDefault","obj","__esModule","default","isValidString","value","join","items","separator","filter","makePath","_len3","arguments","length","args","Array","_key3","result","replace","encode","val","encodeURIComponent","buildUrl","url","params","parts","_jsData","utils","forOwn","key","isArray","forEach","v","window","toString","toISOString","isObject","toJson","push","indexOf","HttpAdapter","opts","self","fillIn","DEFAULTS","_jsDataAdapter2","_typeof","Symbol","iterator","constructor","_jsDataAdapter","axios","hasFetch","fetch","e","noop","_len","_key","dbg","apply","op","concat","resolve","noop2","_len2","_key2","__super__","prototype","basePath","forceTrailingSlash","http","httpConfig","suffix","useFetch","Object","create","enumerable","writable","configurable","defineProperty","addHiddenPropsToTarget","afterDEL","afterGET","afterHTTP","afterPOST","afterPUT","beforeDEL","beforeGET","beforeHTTP","beforePOST","beforePUT","_count","mapper","query","GET","getPath","then","response","_end","_create","props","POST","serialize","_createMany","_destroy","DEL","_destroyAll","deserialize","_find","_findAll","_sum","field","_update","PUT","_updateAll","_updateMany","records","count","getParams","getSuffix","deepMixIn","queryTransform","createMany","config","method","_config","isUndefined","HTTP","_response","isFunction","hasOwnProperty","data","destroy","destroyAll","error","console","_console","_fetch","_x","_x2","requestConfig","headers","Headers","body","Request","json","find","findAll","getEndpoint","relationList","endpoint","name","def","type","parent","item","parentKey","foreignKey","parentDef","getRelation","parentId","getForeignKey","getLocalField","get","idAttribute","_ret","_opts","_","isString","isNumber","copy","logResponse","str","start","toUTCString","toUpperCase","status","Date","getTime","log","reject","payload","cache","timeout","substr","Error","catch","err","responseError","sum","update","updateAll","updateMany","addAction","TypeError","request","adapter","getAdapter","defaultAdapter","_args","isSorN","pathname","addActions","extend","version","beta","full","major","minor","patch","global","jsData","Adapter","Response","meta","babelHelpers","typeof","slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","next","done","unique","array","seen","final","withoutRelations","omit","relationFields","debug","raw","reserved","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","results","_results","respond","_props","_results2","created","map","record","_results3","_results4","_results5","makeHasManyForeignKey","makeHasManyLocalKeys","localKeys","itemKeys","keys","x","makeHasManyForeignKeys","loadHasMany","__opts","singular","IDs","where","criteria","relatedItems","attached","relatedItem","setLocalField","loadHasManyLocalKeys","relatedMapper","in","loadHasManyForeignKeys","foreignKeys","contains","isectNotEmpty","foreignKeysField","_relatedItems","loadHasOne","relatedData","makeBelongsToForeignKey","loadBelongsTo","relationDef","_ret2","with","_results6","_record","tasks","forEachRelation","task","Promise","all","found","activeWith","_activeWith","activeQuery","deepFillIn","_results7","_records","getOpt","opt","plainCopy","level","_len4","_key4","prefix","_console2","_results8","_results9","updated","_results10","_results11"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,WAAYA,QAAQ,cAC5B,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,UAAW,aAAcJ,GACP,gBAAZC,SACdA,QAAqB,YAAID,EAAQG,QAAQ,WAAYA,QAAQ,cAE7DJ,EAAkB,YAAIC,EAAQD,EAAa,OAAGA,EAAgB,YAC7DO,KAAM,SAASC,EAA+BC,GACjD,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUV,OAGnC,IAAIC,GAASU,EAAiBD,IAC7BV,WACAY,GAAIF,EACJG,QAAQ,E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1E,MANA3M,GAAU+F,EAAOxL,MAAMmG,YAAYiM,GAAY3M,EAAU2M,EACzD3M,EAAUA,EAAQwJ,IAAI,SAAUC,GAC9B,MAAOnC,GAAiB9I,EAAQiL,KAElCjN,EAAKnB,EAAKmB,GAAK,aACflB,EAAKgB,IAAIE,EAAIgC,EAAQwB,EAAS3E,GACvB0K,EAAOxL,MAAMmC,QAAQpB,EAAKyE,YAAYvB,EAAQwB,EAAS3E,MAC7DuD,KAAK,SAAUsK,GAChB,GAAIsE,GAAarH,EAAaE,cAAc6C,EAAS,GAEjDnI,EAAOyM,EAAW,GAClB3T,EAAS2T,EAAW,EAExBzM,KAASA,MACTlH,IAAWA,KACX,IAAIgF,GAAW,GAAIoH,GAASlF,EAAMlH,EAAQ,aAM1C,OALAgF,GAASyO,QAAUvM,EAAKtH,OACxBoF,EAAWvD,EAAK8N,QAAQvK,EAAUxD,GAGlCmB,EAAKnB,EAAKmB,GAAK,kBACRuJ,EAAOxL,MAAMmC,QAAQpB,EAAKkB,GAAIgC,EAAQwB,EAAS3E,EAAMwD,IAAWD,KAAK,SAAUgC,GAEpF,MAAOmF,GAAOxL,MAAMmG,YAAYE,GAAa/B,EAAW+B,SAMhEjJ,EAAOD,QAAUsO,KAOd,SAASrO,EAAQD,GAEtBC,EAAOD,QAAUmP","file":"fetch/dist/js-data-fetch.min.js"} \ No newline at end of file diff --git a/fetch/karma.conf.js b/fetch/karma.conf.js new file mode 100644 index 0000000..866b314 --- /dev/null +++ b/fetch/karma.conf.js @@ -0,0 +1,80 @@ +var customLaunchers = { + bs_ie9_windows7: { + base: 'BrowserStack', + browser: 'ie', + browser_version: '9.0', + os: 'Windows', + os_version: '7' + }, + bs_safari7_osxmavericks: { + base: 'BrowserStack', + browser: 'safari', + browser_version: '7.1', + os: 'OS X', + os_version: 'Mavericks' + }, + bs_firefox41_windows7: { + base: 'BrowserStack', + browser: 'firefox', + browser_version: '41.0', + os: 'Windows', + os_version: '7' + }, + bs_chrome46_windows7: { + base: 'BrowserStack', + browser: 'chrome', + browser_version: '46.0', + os: 'Windows', + os_version: '7' + } +} + +var browsers = ['PhantomJS'] +if ( + process.env.BROWSERSTACK_USERNAME && + process.env.BROWSERSTACK_ACCESS_KEY +) { + browsers = browsers.concat(Object.keys(customLaunchers)) +} + +module.exports = function (config) { + config.set({ + basePath: '../', + frameworks: ['sinon', 'chai', 'mocha'], + plugins: [ + 'karma-sinon', + 'karma-mocha', + 'karma-chai', + 'karma-phantomjs-launcher', + 'karma-browserstack-launcher' + ], + autoWatch: false, + browsers: browsers, + files: [ + 'node_modules/babel-polyfill/dist/polyfill.js', + 'node_modules/js-data/dist/js-data.js', + 'fetch/dist/js-data-fetch.js', + 'fetch/karma.start.js', + 'test/*.test.js' + ], + browserStack: { + username: process.env.BROWSERSTACK_USERNAME, + accessKey: process.env.BROWSERSTACK_ACCESS_KEY + }, + customLaunchers: customLaunchers, + reporters: ['dots'], + junitReporter: { + outputDir: process.env.CIRCLE_TEST_REPORTS || 'junit', + outputFile: undefined, + suite: 'js-data-http', + userBrowserName: false + }, + port: 9876, + runnerPort: 9100, + colors: true, + logLevel: config.LOG_INFO, + browserNoActivityTimeout: 90000, + captureTimeout: 90000, + singleRun: true + }) +} diff --git a/fetch/karma.start.js b/fetch/karma.start.js new file mode 100644 index 0000000..acaa197 --- /dev/null +++ b/fetch/karma.start.js @@ -0,0 +1,80 @@ +/* global JSData:true, JSDataHttp:true, sinon:true, chai:true */ +before(function () { + var Test = this + Test.fail = function (msg) { + if (msg instanceof Error) { + console.log(msg.stack) + } else { + Test.assert.equal('should not reach this!: ' + msg, 'failure') + } + } + Test.assert = chai.assert + Test.assert.objectsEqual = function (a, b, m) { + Test.assert.deepEqual(JSON.parse(JSON.stringify(a)), JSON.parse(JSON.stringify(b)), m || (JSON.stringify(a) + ' should be equal to ' + JSON.stringify(b))) + } + Test.sinon = sinon + Test.JSData = JSData + Test.HttpAdapter = JSDataHttp.HttpAdapter + Test.User = new JSData.Mapper({ + name: 'user' + }) + Test.Post = new JSData.Mapper({ + name: 'post', + endpoint: 'posts', + basePath: 'api' + }) + + console.log('Testing against js-data ' + JSData.version.full) +}) + +beforeEach(function () { + var Test = this + Test.adapter = new Test.HttpAdapter() + Test.User.registerAdapter('http', Test.adapter, { default: true }) + Test.Post.registerAdapter('http', Test.adapter, { default: true }) + + Test.p1 = { author: 'John', age: 30, id: 5 } + Test.p2 = { author: 'Sally', age: 31, id: 6 } + Test.p3 = { author: 'Mike', age: 32, id: 7 } + Test.p4 = { author: 'Adam', age: 33, id: 8 } + Test.p5 = { author: 'Adam', age: 33, id: 9 } + + Test.requests = [] + + Test.adapter.http = function (config) { + config.headers || (config.headers = {}) + config.headers.Accept = 'application/json, text/plain, */*' + var params = [] + for (var key in config.params) { + config.params[key] = Test.JSData.utils.isObject(config.params[key]) ? JSON.stringify(config.params[key]) : config.params[key] + params.push([key, config.params[key]]) + } + return new Promise(function (resolve) { + var url = config.url + if (params.length) { + url += '?' + params.forEach(function (param) { + url += param[0] + url += '=' + url += encodeURIComponent(param[1]) + }) + } + var request = { + url: url, + method: config.method, + requestBody: JSON.stringify(config.data), + requestHeaders: config.headers, + respond: function (statusCode, headers, body) { + resolve({ + url: config.url, + method: config.method, + status: statusCode, + headers: headers, + data: body && statusCode >= 200 && statusCode < 300 ? JSON.parse(body) : '' + }) + } + } + Test.requests.push(request) + }) + } +}) diff --git a/fetch/package.json b/fetch/package.json new file mode 100644 index 0000000..1634988 --- /dev/null +++ b/fetch/package.json @@ -0,0 +1,27 @@ +{ + "name": "js-data-fetch", + "description": "HTTP adapter for js-data that uses the fetch API.", + "version": "3.0.0-beta.3", + "homepage": "https://github.com/js-data/js-data-http", + "repository": { + "type": "git", + "url": "https://github.com/js-data/js-data-http.git" + }, + "author": "js-data-http project authors", + "license": "MIT", + "main": "./dist/js-data-fetch.js", + "files": [ + "dist/" + ], + "keywords": [ + "ajax", + "axios", + "rest", + "adapter", + "http", + "fetch" + ], + "peerDependencies": { + "js-data": "^3.0.0-beta.2" + } +} diff --git a/fetch/typings.json b/fetch/typings.json new file mode 100644 index 0000000..4ebc46e --- /dev/null +++ b/fetch/typings.json @@ -0,0 +1,10 @@ +{ + "name": "js-data-fetch", + "version": false, + "main": "./dist/js-data-fetch.d.ts", + "ambientDependencies": { + "js-data": "npm:js-data", + "js-data-adapter": "npm:js-data-adapter", + "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654" + } +} diff --git a/fetch/webpack.config.js b/fetch/webpack.config.js new file mode 100644 index 0000000..e87bc60 --- /dev/null +++ b/fetch/webpack.config.js @@ -0,0 +1,45 @@ +var path = require('path') + +module.exports = { + devtool: 'source-map', + entry: { + './fetch/dist/js-data-fetch.js': './src/index.js' + }, + output: { + filename: '[name]', + libraryTarget: 'umd', + library: 'JSDataHttp' + }, + externals: [ + { + 'js-data': { + amd: 'js-data', + commonjs: 'js-data', + commonjs2: 'js-data', + root: 'JSData' + } + }, + { + 'axios': 'var undefined' + }, + { + 'chai': { + amd: 'chai', + commonjs: 'chai', + commonjs2: 'chai', + root: 'chai' + } + } + ], + module: { + loaders: [ + { + loader: 'babel-loader', + include: [ + path.resolve(__dirname, '../src') + ], + test: /\.js$/ + } + ] + } +} diff --git a/karma.conf.js b/karma.conf.js index 5d944d6..bd3db1e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,88 +1,80 @@ var customLaunchers = { - bs_ie9_windows7: { - base: 'BrowserStack', - browser: 'ie', - browser_version: '9.0', - os: 'Windows', - os_version: '7' - } -}; + bs_ie9_windows7: { + base: 'BrowserStack', + browser: 'ie', + browser_version: '9.0', + os: 'Windows', + os_version: '7' + }, + bs_safari7_osxmavericks: { + base: 'BrowserStack', + browser: 'safari', + browser_version: '7.1', + os: 'OS X', + os_version: 'Mavericks' + }, + bs_firefox41_windows7: { + base: 'BrowserStack', + browser: 'firefox', + browser_version: '41.0', + os: 'Windows', + os_version: '7' + }, + bs_chrome46_windows7: { + base: 'BrowserStack', + browser: 'chrome', + browser_version: '46.0', + os: 'Windows', + os_version: '7' + } +} -var browsers = ['PhantomJS']; +var browsers = ['PhantomJS'] if ( - process.env.BROWSERSTACK_USERNAME && - process.env.BROWSERSTACK_ACCESS_KEY + process.env.BROWSERSTACK_USERNAME && + process.env.BROWSERSTACK_ACCESS_KEY ) { - browsers = browsers.concat(Object.keys(customLaunchers)); + browsers = browsers.concat(Object.keys(customLaunchers)) } module.exports = function (config) { - config.set({ - // base path, that will be used to resolve files and exclude - basePath: './', - frameworks: ['sinon', 'chai', 'mocha'], - plugins: [ - // these plugins will be require() by Karma - 'karma-sinon', - 'karma-mocha', - 'karma-chai', - 'karma-chrome-launcher', - 'karma-phantomjs-launcher', - 'karma-firefox-launcher', - 'karma-coverage', - 'karma-browserstack-launcher' - ], - autoWatch: false, - autoWatchBatchDelay: 4000, - browsers: browsers, - - // list of files / patterns to load in the browser - files: [ - 'node_modules/es6-promise/dist/es6-promise.js', - 'node_modules/js-data/dist/js-data.js', - 'dist/js-data-http.js', - 'karma.start.js', - 'test/**/*.js' - ], - - reporters: ['dots', 'coverage'], - - preprocessors: { - 'dist/js-data-http.js': ['coverage'] - }, - - // optionally, configure the reporter - coverageReporter: { - type: 'lcov', - dir: 'coverage/' - }, - - browserStack: { - username: process.env.BROWSERSTACK_USERNAME, - accessKey: process.env.BROWSERSTACK_ACCESS_KEY - }, - - customLaunchers: customLaunchers, - - browserNoActivityTimeout: 30000, - - // web server port - port: 9876, - - // cli runner port - runnerPort: 9100, - - // enable / disable colors in the output (reporters and logs) - colors: true, - - // level of logging - logLevel: config.LOG_INFO, - - // If browser does not capture in given timeout [ms], kill it - captureTimeout: 30000, - - // Continuous Integration mode - // if true, it capture browsers, run tests and exit - singleRun: true - }); -}; + config.set({ + basePath: './', + frameworks: ['sinon', 'chai', 'mocha'], + plugins: [ + 'karma-sinon', + 'karma-mocha', + 'karma-chai', + 'karma-phantomjs-launcher', + 'karma-browserstack-launcher' + ], + autoWatch: false, + browsers: browsers, + files: [ + 'node_modules/babel-polyfill/dist/polyfill.js', + 'node_modules/js-data/dist/js-data.js', + 'dist/js-data-http.js', + 'karma.start.js', + 'test/*.test.js' + ], + browserStack: { + username: process.env.BROWSERSTACK_USERNAME, + accessKey: process.env.BROWSERSTACK_ACCESS_KEY + }, + customLaunchers: customLaunchers, + reporters: ['dots'], + junitReporter: { + outputDir: process.env.CIRCLE_TEST_REPORTS || 'junit', + outputFile: undefined, + suite: 'js-data-http', + userBrowserName: false + }, + port: 9876, + runnerPort: 9100, + colors: true, + logLevel: config.LOG_INFO, + browserNoActivityTimeout: 90000, + captureTimeout: 90000, + singleRun: true + }) +} diff --git a/karma.start.js b/karma.start.js index 857082a..464dc71 100644 --- a/karma.start.js +++ b/karma.start.js @@ -1,89 +1,63 @@ -// Setup global test variables -var dsHttpAdapter, User, Post, datastore, DSUtils, queryTransform, p1, p2, p3, p4, p5; - -// Helper globals -var fail = function (msg) { - if (msg instanceof Error) { - console.log(msg.stack); - } else { - assert.equal('should not reach this!: ' + msg, 'failure'); +/* global JSData:true, JSDataHttp:true, sinon:true, chai:true */ +before(function () { + var Test = this + Test.fail = function (msg) { + if (msg instanceof Error) { + console.log(msg.stack) + } else { + Test.assert.equal('should not reach this!: ' + msg, 'failure') + } } -}; -var TYPES_EXCEPT_STRING = [123, 123.123, null, undefined, {}, [], true, false, function () { -}]; -var TYPES_EXCEPT_STRING_OR_ARRAY = [123, 123.123, null, undefined, {}, true, false, function () { -}]; -var TYPES_EXCEPT_STRING_OR_OBJECT = [123, 123.123, null, undefined, [], true, false, function () { -}]; -var TYPES_EXCEPT_STRING_OR_NUMBER_OBJECT = [null, undefined, [], true, false, function () { -}]; -var TYPES_EXCEPT_ARRAY = ['string', 123, 123.123, null, undefined, {}, true, false, function () { -}]; -var TYPES_EXCEPT_STRING_OR_NUMBER = [null, undefined, {}, [], true, false, function () { -}]; -var TYPES_EXCEPT_STRING_OR_ARRAY_OR_NUMBER = [null, undefined, {}, true, false, function () { -}]; -var TYPES_EXCEPT_NUMBER = ['string', null, undefined, {}, [], true, false, function () { -}]; -var TYPES_EXCEPT_OBJECT = ['string', 123, 123.123, null, undefined, true, false, function () { -}]; -var TYPES_EXCEPT_BOOLEAN = ['string', 123, 123.123, null, undefined, {}, [], function () { -}]; -var TYPES_EXCEPT_FUNCTION = ['string', 123, 123.123, null, undefined, {}, [], true, false]; - -// Setup before each test -beforeEach(function () { - var JSData; - if (!window && typeof module !== 'undefined' && module.exports) { - JSData = require('js-data'); - } else { - JSData = window.JSData; + Test.assert = chai.assert + Test.assert.objectsEqual = function (a, b, m) { + Test.assert.deepEqual(JSON.parse(JSON.stringify(a)), JSON.parse(JSON.stringify(b)), m || (JSON.stringify(a) + ' should be equal to ' + JSON.stringify(b))) } - - queryTransform = function (resourceName, query) { - queryTransform.callCount += 1; - return query; - }; - - DSUtils = JSData.DSUtils; - datastore = new JSData.DS(); - - User = datastore.defineResource('user'); - Post = datastore.defineResource({ - name: 'posts', + Test.sinon = sinon + Test.JSData = JSData + Test.HttpAdapter = JSDataHttp.HttpAdapter + Test.User = new JSData.Mapper({ + name: 'user' + }) + Test.Post = new JSData.Mapper({ + name: 'post', + endpoint: 'posts', basePath: 'api' - }); - dsHttpAdapter = new DSHttpAdapter({ - queryTransform: queryTransform - }); - datastore.registerAdapter('http', dsHttpAdapter, { default: true }); + }) - queryTransform.callCount = 0; + console.log('Testing against js-data ' + JSData.version.full) +}) + +beforeEach(function () { + var Test = this + Test.adapter = new Test.HttpAdapter() + Test.User.registerAdapter('http', Test.adapter, { default: true }) + Test.Post.registerAdapter('http', Test.adapter, { default: true }) - p1 = { author: 'John', age: 30, id: 5 }; - p2 = { author: 'Sally', age: 31, id: 6 }; - p3 = { author: 'Mike', age: 32, id: 7 }; - p4 = { author: 'Adam', age: 33, id: 8 }; - p5 = { author: 'Adam', age: 33, id: 9 }; + Test.p1 = { author: 'John', age: 30, id: 5 } + Test.p2 = { author: 'Sally', age: 31, id: 6 } + Test.p3 = { author: 'Mike', age: 32, id: 7 } + Test.p4 = { author: 'Adam', age: 33, id: 8 } + Test.p5 = { author: 'Adam', age: 33, id: 9 } try { - this.xhr = sinon.useFakeXMLHttpRequest(); + Test.xhr = Test.sinon.useFakeXMLHttpRequest() // Create an array to store requests - var requests = this.requests = []; + Test.requests = [] // Keep references to created requests - this.xhr.onCreate = function (xhr) { - requests.push(xhr); - }; + Test.xhr.onCreate = function (xhr) { + Test.requests.push(xhr) + } } catch (err) { - console.error(err); + console.error(err) } -}); +}) afterEach(function () { + var Test = this // Restore the global timer functions to their native implementations try { - this.xhr.restore(); + Test.xhr.restore() } catch (err) { - console.error(err); + console.error(err) } -}); +}) diff --git a/node/.gitignore b/node/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/node/LICENSE b/node/LICENSE new file mode 100644 index 0000000..7ff3781 --- /dev/null +++ b/node/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014-2016 js-data-http project authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node/dist/js-data-http-node.d.ts b/node/dist/js-data-http-node.d.ts new file mode 100644 index 0000000..9da417e --- /dev/null +++ b/node/dist/js-data-http-node.d.ts @@ -0,0 +1,38 @@ +import {Adapter} from 'js-data-adapter' + +interface IDict { + [key: string]: any; +} +interface IActionOpts { + adapter?: string, + pathname?: string, + request?: Function, + response?: Function, + responseError?: Function +} +interface IBaseAdapter extends IDict { + debug?: boolean, + raw?: boolean +} +interface IBaseHttpAdapter extends IBaseAdapter { + basePath?: string + forceTrailingSlash?: boolean + http?: any + httpConfig?: IDict + suffix?: string + useFetch?: boolean +} +export function addAction(name: string, opts: IActionOpts): Function +export function addActions(opts?: { [key: string]: IActionOpts }): Function +export class HttpAdapter extends Adapter { + static version: { + full?: string + minor?: string + major?: string + patch?: string + alpha?: string | boolean + beta?: string | boolean + } + static extend(instanceProps?: IDict, classProps?: IDict): typeof HttpAdapter + constructor(opts?: IBaseHttpAdapter) +} diff --git a/node/dist/js-data-http-node.js b/node/dist/js-data-http-node.js new file mode 100644 index 0000000..bdf5871 --- /dev/null +++ b/node/dist/js-data-http-node.js @@ -0,0 +1,2980 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("js-data"), require("axios")); + else if(typeof define === 'function' && define.amd) + define(["js-data", "axios"], factory); + else { + var a = typeof exports === 'object' ? factory(require("js-data"), require("axios")) : factory(root["js-data"], root["axios"]); + for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; + } +})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_3__) { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + + var _jsData = __webpack_require__(1); + + var _jsDataAdapter = __webpack_require__(2); + + var _jsDataAdapter2 = _interopRequireDefault(_jsDataAdapter); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + /* global fetch:true Headers:true Request:true */ + var axios = __webpack_require__(3); + + + var hasFetch = false; + + try { + hasFetch = window && window.fetch; + } catch (e) {} + + var noop = function noop() { + var self = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return _jsData.utils.resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + self.dbg.apply(self, [opts.op].concat(args)); + return _jsData.utils.resolve(); + }; + + function isValidString(value) { + return value != null && value !== ''; + } + function join(items, separator) { + separator || (separator = ''); + return items.filter(isValidString).join(separator); + } + function makePath() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + var result = join(args, '/'); + return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); + } + + function encode(val) { + return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']'); + } + + function buildUrl(url, params) { + if (!params) { + return url; + } + + var parts = []; + + _jsData.utils.forOwn(params, function (val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + if (!_jsData.utils.isArray(val)) { + val = [val]; + } + + val.forEach(function (v) { + if (window.toString.call(v) === '[object Date]') { + v = v.toISOString(); + } else if (_jsData.utils.isObject(v)) { + v = _jsData.utils.toJson(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); + } + + return url; + } + + var __super__ = _jsDataAdapter2.default.prototype; + + var DEFAULTS = { + // Default and user-defined settings + /** + * @name HttpAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + */ + forceTrailingSlash: false, + + /** + * @name HttpAdapter#http + * @type {Function} + */ + http: axios, + + /** + * @name HttpAdapter#httpConfig + * @type {Object} + */ + httpConfig: {}, + + /** + * @name HttpAdapter#suffix + * @type {string} + */ + suffix: '', + + /** + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + */ + useFetch: false + }; + + /** + * HttpAdapter class. + * + * @class HttpAdapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.basePath=''] TODO + * @param {boolean} [opts.debug=false] TODO + * @param {boolean} [opts.forceTrailingSlash=false] TODO + * @param {Object} [opts.http=axios] TODO + * @param {Object} [opts.httpConfig={}] TODO + * @param {string} [opts.suffix=''] TODO + * @param {boolean} [opts.useFetch=false] TODO + */ + function HttpAdapter(opts) { + var self = this; + opts || (opts = {}); + _jsData.utils.fillIn(opts, DEFAULTS); + _jsDataAdapter2.default.call(self, opts); + } + + // Setup prototype inheritance from Adapter + HttpAdapter.prototype = Object.create(_jsDataAdapter2.default.prototype, { + constructor: { + value: HttpAdapter, + enumerable: false, + writable: true, + configurable: true + } + }); + + Object.defineProperty(HttpAdapter, '__super__', { + configurable: true, + value: _jsDataAdapter2.default + }); + + _jsData.utils.addHiddenPropsToTarget(HttpAdapter.prototype, { + /** + * @name HttpAdapter#afterDEL + * @method + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterDEL: noop2, + + /** + * @name HttpAdapter#afterGET + * @method + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterGET: noop2, + + /** + * @name HttpAdapter#afterHTTP + * @method + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterHTTP: noop2, + + /** + * @name HttpAdapter#afterPOST + * @method + * @param {string} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterPOST: noop2, + + /** + * @name HttpAdapter#afterPUT + * @method + * @param {string} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterPUT: noop2, + + /** + * @name HttpAdapter#beforeDEL + * @method + * @param {Object} url + * @param {Object} config + * @param {Object} opts + */ + beforeDEL: noop, + + /** + * @name HttpAdapter#beforeGET + * @method + * @param {Object} url + * @param {Object} config + * @param {Object} opts + */ + beforeGET: noop, + + /** + * @name HttpAdapter#beforeHTTP + * @method + * @param {Object} config + * @param {Object} opts + */ + beforeHTTP: noop, + + /** + * @name HttpAdapter#beforePOST + * @method + * @param {Object} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + */ + beforePOST: noop, + + /** + * @name HttpAdapter#beforePUT + * @method + * @param {Object} url + * @param {Object} data + * @param {Object} config + * @param {Object} opts + */ + beforePUT: noop, + + _count: function _count(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('count', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _create: function _create(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('create', mapper, props, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _createMany: function _createMany(mapper, props, opts) { + var self = this; + return self.POST(self.getPath('createMany', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroy: function _destroy(mapper, id, opts) { + var self = this; + return self.DEL(self.getPath('destroy', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _destroyAll: function _destroyAll(mapper, query, opts) { + var self = this; + return self.DEL(self.getPath('destroyAll', mapper, null, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _end: function _end(mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response]; + }, + _find: function _find(mapper, id, opts) { + var self = this; + return self.GET(self.getPath('find', mapper, id, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _findAll: function _findAll(mapper, query, opts) { + var self = this; + return self.GET(self.getPath('findAll', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _sum: function _sum(mapper, field, query, opts) { + var self = this; + return self.GET(self.getPath('sum', mapper, opts.params, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _update: function _update(mapper, id, props, opts) { + var self = this; + return self.PUT(self.getPath('update', mapper, id, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateAll: function _updateAll(mapper, props, query, opts) { + var self = this; + return self.PUT(self.getPath('updateAll', mapper, null, opts), self.serialize(mapper, props, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + _updateMany: function _updateMany(mapper, records, opts) { + var self = this; + return self.PUT(self.getPath('updateMany', mapper, null, opts), self.serialize(mapper, records, opts), opts).then(function (response) { + return self._end(mapper, opts, response); + }); + }, + + + /** + * Retrieve the number of records that match the selection `query`. + * + * @name HttpAdapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params.count = true; + opts.suffix = self.getSuffix(mapper, opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.count.call(self, mapper, query, opts); + }, + + + /** + * Create a new the record from the provided `props`. + * + * @name HttpAdapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props Properties to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.create.call(self, mapper, props, opts); + }, + + + /** + * Create multiple new records in batch. + * + * @name HttpAdapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} props Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.createMany.call(self, mapper, props, opts); + }, + + + /** + * Make an Http request to `url` according to the configuration in `config`. + * + * @name HttpAdapter#DEL + * @method + * @param {string} url Url for the request. + * @param {Object} [config] Http configuration that will be passed to + * {@link HttpAdapter#HTTP}. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + DEL: function DEL(url, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'delete'; + + // beforeDEL lifecycle hook + op = opts.op = 'beforeDEL'; + return _jsData.utils.resolve(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'DEL'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL'; + return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Transform the server response object into the payload that will be returned + * to JSData. + * + * @name HttpAdapter#deserialize + * @method + * @param {Object} mapper The mapper used for the operation. + * @param {Object} response Response object from {@link HttpAdapter#HTTP}. + * @param {Object} opts Configuration options. + * @return {(Object|Array)} Deserialized data. + */ + deserialize: function deserialize(mapper, response, opts) { + opts || (opts = {}); + if (_jsData.utils.isFunction(opts.deserialize)) { + return opts.deserialize(mapper, response, opts); + } + if (_jsData.utils.isFunction(mapper.deserialize)) { + return mapper.deserialize(mapper, response, opts); + } + if (response && response.hasOwnProperty('data')) { + return response.data; + } + return response; + }, + + + /** + * Destroy the record with the given primary key. + * + * @name HttpAdapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroy.call(self, mapper, id, opts); + }, + + + /** + * Destroy the records that match the selection `query`. + * + * @name HttpAdapter#destroyAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.destroyAll.call(self, mapper, query, opts); + }, + + + /** + * Log an error. + * + * @name HttpAdapter#error + * @method + * @param {...*} [args] Arguments to log. + */ + error: function error() { + if (console) { + var _console; + + (_console = console)[typeof console.error === 'function' ? 'error' : 'log'].apply(_console, arguments); + } + }, + + + /** + * Make an Http request using `window.fetch`. + * + * @name HttpAdapter#fetch + * @method + * @param {Object} config Request configuration. + * @param {Object} config.data Payload for the request. + * @param {string} config.method Http method for the request. + * @param {Object} config.headers Headers for the request. + * @param {Object} config.params Querystring for the request. + * @param {string} config.url Url for the request. + * @param {Object} [opts] Configuration options. + */ + fetch: function (_fetch) { + function fetch(_x, _x2) { + return _fetch.apply(this, arguments); + } + + fetch.toString = function () { + return _fetch.toString(); + }; + + return fetch; + }(function (config, opts) { + var requestConfig = { + method: config.method, + // turn the plain headers object into the Fetch Headers object + headers: new Headers(config.headers) + }; + + if (config.data) { + requestConfig.body = _jsData.utils.toJson(config.data); + } + + return fetch(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) { + response.config = { + method: config.method, + url: config.url + }; + return response.json().then(function (data) { + response.data = data; + return response; + }); + }); + }), + + + /** + * Retrieve the record with the given primary key. + * + * @name HttpAdapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.find.call(self, mapper, id, opts); + }, + + + /** + * Retrieve the records that match the selection `query`. + * + * @name HttpAdapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.suffix = self.getSuffix(mapper, opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.findAll.call(self, mapper, query, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#GET + * @method + * @param {string} url The url for the request. + * @param {Object} config Request configuration options. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + GET: function GET(url, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.method = config.method || 'get'; + + // beforeGET lifecycle hook + op = opts.op = 'beforeGET'; + return _jsData.utils.resolve(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'GET'; + self.dbg(op, url, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET'; + return _jsData.utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {boolean} opts TODO + * @return {string} Full path. + */ + getEndpoint: function getEndpoint(mapper, id, opts) { + var self = this; + opts || (opts = {}); + opts.params = _jsData.utils.isUndefined(opts.params) ? {} : opts.params; + var relationList = mapper.relationList || []; + var endpoint = _jsData.utils.isUndefined(opts.endpoint) ? _jsData.utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint : opts.endpoint; + + relationList.forEach(function (def) { + if (def.type !== 'belongsTo' || !def.parent) { + return; + } + var item = void 0; + var parentKey = def.foreignKey; + var parentDef = def.getRelation(); + var parentId = opts.params[parentKey]; + + if (parentId === false || !parentKey || !parentDef) { + if (parentId === false) { + delete opts.params[parentKey]; + } + return false; + } else { + delete opts.params[parentKey]; + + if (_jsData.utils.isObject(id)) { + item = id; + } + + if (item) { + parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? _jsData.utils.get(def.getLocalField(item), parentDef.idAttribute) : null); + } + + if (parentId) { + var _ret = function () { + delete opts.endpoint; + var _opts = {}; + _jsData.utils.forOwn(opts, function (value, key) { + _opts[key] = value; + }); + _jsData.utils._(_opts, parentDef); + endpoint = makePath(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint); + return { + v: false + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + } + } + }); + + return endpoint; + }, + + + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method TODO + * @param {Object} mapper TODO + * @param {(string|number)?} id TODO + * @param {Object} opts Configuration options. + */ + getPath: function getPath(method, mapper, id, opts) { + var self = this; + opts || (opts = {}); + var args = [_jsData.utils.isUndefined(opts.basePath) ? _jsData.utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath : opts.basePath, self.getEndpoint(mapper, _jsData.utils.isString(id) || _jsData.utils.isNumber(id) || method === 'create' ? id : null, opts)]; + if (method === 'find' || method === 'update' || method === 'destroy') { + args.push(id); + } + return makePath.apply(_jsData.utils, args); + }, + getParams: function getParams(opts) { + opts || (opts = {}); + if (_jsData.utils.isUndefined(opts.params)) { + return {}; + } + return _jsData.utils.copy(opts.params); + }, + getSuffix: function getSuffix(mapper, opts) { + opts || (opts = {}); + if (_jsData.utils.isUndefined(opts.suffix)) { + if (_jsData.utils.isUndefined(mapper.suffix)) { + return this.suffix; + } + return mapper.suffix; + } + return opts.suffix; + }, + + + /** + * Make an Http request. + * + * @name HttpAdapter#HTTP + * @method + * @param {Object} config Request configuration options. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + HTTP: function HTTP(config, opts) { + var self = this; + var start = new Date(); + opts || (opts = {}); + var payload = config.data; + var cache = config.cache; + var timeout = config.timeout; + config = _jsData.utils.copy(config, null, null, null, ['data', 'cache', 'timeout']); + config = _jsData.utils.deepMixIn(config, self.httpConfig); + config.data = payload; + config.cache = cache; + config.timeout = timeout; + if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { + config.url += '/'; + } + config.method = config.method.toUpperCase(); + var suffix = config.suffix || opts.suffix || self.suffix; + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { + config.url += suffix; + } + + function logResponse(data) { + var str = start.toUTCString() + ' - ' + config.method.toUpperCase() + ' ' + config.url + ' - ' + data.status + ' ' + (new Date().getTime() - start.getTime()) + 'ms'; + if (data.status >= 200 && data.status < 300) { + if (self.log) { + self.dbg('debug', str, data); + } + return data; + } else { + if (self.error) { + self.error('\'FAILED: ' + str, data); + } + return _jsData.utils.reject(data); + } + } + + if (!self.http) { + throw new Error('You have not configured this adapter with an http library!'); + } + + return _jsData.utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config; + if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { + return self.fetch(config, opts).then(logResponse, logResponse); + } + return self.http(config).then(logResponse, logResponse).catch(function (err) { + return self.responseError(err, config, opts); + }); + }).then(function (response) { + return _jsData.utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { + return _response || response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#POST + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + POST: function POST(url, data, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'post'; + + // beforePOST lifecycle hook + op = opts.op = 'beforePOST'; + return _jsData.utils.resolve(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'POST'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST'; + return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#PUT + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + PUT: function PUT(url, data, config, opts) { + var self = this; + var op = void 0; + config || (config = {}); + opts || (opts = {}); + config.url = url || config.url; + config.data = data || config.data; + config.method = config.method || 'put'; + + // beforePUT lifecycle hook + op = opts.op = 'beforePUT'; + return _jsData.utils.resolve(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = _jsData.utils.isUndefined(_config) ? config : _config; + op = opts.op = 'PUT'; + self.dbg(op, url, data, config, opts); + return self.HTTP(config, opts); + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT'; + return _jsData.utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return _jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * TODO + * + * @name HttpAdapter#queryTransform + * @method + * @param {Object} mapper TODO + * @param {*} params TODO + * @param {*} opts TODO + * @return {*} Transformed params. + */ + queryTransform: function queryTransform(mapper, params, opts) { + opts || (opts = {}); + if (_jsData.utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts); + } + if (_jsData.utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts); + } + return params; + }, + + + /** + * Error handler invoked when the promise returned by {@link HttpAdapter#http} + * is rejected. Default implementation is to just return the error wrapped in + * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is + * called by {@link HttpAdapter#HTTP}. + * + * @name HttpAdapter#responseError + * @method + * @param {*} err The error that {@link HttpAdapter#http} rejected with. + * @param {Object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}. + * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}. + * @return {Promise} + */ + responseError: function responseError(err, config, opts) { + return _jsData.utils.reject(err); + }, + + + /** + * TODO + * + * @name HttpAdapter#serialize + * @method + * @param {Object} mapper TODO + * @param {Object} data TODO + * @param {*} opts TODO + * @return {*} Serialized data. + */ + serialize: function serialize(mapper, data, opts) { + opts || (opts = {}); + if (_jsData.utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts); + } + if (_jsData.utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts); + } + return data; + }, + + + /** + * Retrieve the sum of the field of the records that match the selection query. + * + * @name HttpAdapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field The field to sum. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + if (!_jsData.utils.utils.isString(field)) { + throw new Error('field must be a string!'); + } + opts.params = self.getParams(opts); + opts.params.sum = field; + opts.suffix = self.getSuffix(mapper, opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + + return __super__.sum.call(self, mapper, field, query, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#update + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {*} props TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.update.call(self, mapper, id, props, opts); + }, + + + /** + * TODO + * + * @name HttpAdapter#updateAll + * @method + * @param {Object} mapper TODO + * @param {Object} props TODO + * @param {Object} query TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + opts.params = self.getParams(opts); + _jsData.utils.deepMixIn(opts.params, query); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateAll.call(self, mapper, props, query, opts); + }, + + + /** + * Update multiple records in batch. + * + * {@link HttpAdapter#beforeUpdateMany} will be called before calling + * {@link HttpAdapter#PUT}. + * {@link HttpAdapter#afterUpdateMany} will be called after calling + * {@link HttpAdapter#PUT}. + * + * @name HttpAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} records Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + opts || (opts = {}); + opts.params = self.getParams(opts); + opts.params = self.queryTransform(mapper, opts.params, opts); + opts.suffix = self.getSuffix(mapper, opts); + + return __super__.updateMany.call(self, mapper, records, opts); + } + }); + + /** + * Add an Http actions to a mapper. + * + * @name HttpAdapter.addAction + * @method + * @param {string} name Name of the new action. + * @param {Object} [opts] Action configuration + * @param {string} [opts.adapter] + * @param {string} [opts.pathname] + * @param {Function} [opts.request] + * @param {Function} [opts.response] + * @param {Function} [opts.responseError] + * @return {Function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ + HttpAdapter.addAction = function (name, opts) { + if (!name || !_jsData.utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + (typeof name === 'undefined' ? 'undefined' : _typeof(name))); + } + return function (mapper) { + if (mapper[name]) { + throw new Error('action(name[, opts]): ' + name + ' already exists on target!'); + } + opts.request = opts.request || function (config) { + return config; + }; + opts.response = opts.response || function (response) { + return response; + }; + opts.responseError = opts.responseError || function (err) { + return _jsData.utils.reject(err); + }; + mapper[name] = function (id, _opts) { + var self = this; + if (_jsData.utils.isObject(id)) { + _opts = id; + } + _opts = _opts || {}; + var adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http'); + var config = {}; + _jsData.utils.fillIn(config, opts); + if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { + _opts.endpoint = config.endpoint; + } + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(self, _opts); + } else { + var _args = [_opts.basePath || self.basePath || adapter.basePath, adapter.getEndpoint(self, _jsData.utils.isSorN(id) ? id : null, _opts)]; + if (_jsData.utils.isSorN(id)) { + _args.push(id); + } + _args.push(opts.pathname || name); + config.url = makePath.apply(null, _args); + } + config.method = config.method || 'GET'; + config.mapper = self.name; + _jsData.utils.deepMixIn(config)(_opts); + return _jsData.utils.resolve(config).then(_opts.request || opts.request).then(function (config) { + return adapter.HTTP(config); + }).then(function (data) { + if (data && data.config) { + data.config.mapper = self.name; + } + return data; + }).then(_opts.response || opts.response, _opts.responseError || opts.responseError); + }; + return mapper; + }; + }; + + /** + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. + * + * @name HttpAdapter.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. + */ + HttpAdapter.addActions = function (opts) { + opts || (opts = {}); + return function (mapper) { + _jsData.utils.forOwn(mapper, function (value, key) { + HttpAdapter.addAction(key, value)(mapper); + }); + return mapper; + }; + }; + + /** + * Alternative to ES6 class syntax for extending `HttpAdapter`. + * + * __ES6__: + * ```javascript + * class MyHttpAdapter extends HttpAdapter { + * deserialize (Model, data, opts) { + * const data = super.deserialize(Model, data, opts) + * data.foo = 'bar' + * return data + * } + * } + * ``` + * + * __ES5__: + * ```javascript + * var instanceProps = { + * // override deserialize + * deserialize: function (Model, data, opts) { + * var Ctor = this.constructor + * var superDeserialize = (Ctor.__super__ || Object.getPrototypeOf(Ctor)).deserialize + * // call the super deserialize + * var data = superDeserialize(Model, data, opts) + * data.foo = 'bar' + * return data + * }, + * say: function () { return 'hi' } + * } + * var classProps = { + * yell: function () { return 'HI' } + * } + * + * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) + * var adapter = new MyHttpAdapter() + * adapter.say() // "hi" + * MyHttpAdapter.yell() // "HI" + * ``` + * + * @name HttpAdapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `HttpAdapter`. + */ + HttpAdapter.extend = _jsData.utils.extend; + + /** + * Details of the current version of the `js-data-http` module. + * + * @name HttpAdapter.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. + */ + HttpAdapter.version = { + beta: 2, + full: '3.0.0-beta.2', + 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`. + * + * __Script tag__: + * ```javascript + * window.HttpAdapter + * ``` + * __CommonJS__: + * ```javascript + * var HttpAdapter = require('js-data-http') + * ``` + * __ES6 Modules__: + * ```javascript + * import HttpAdapter from 'js-data-http' + * ``` + * __AMD__: + * ```javascript + * define('myApp', ['js-data-http'], function (HttpAdapter) { ... }) + * ``` + * + * @module js-data-http + */ + + module.exports = HttpAdapter; + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_1__; + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + (function (global, factory) { + true ? factory(__webpack_require__(1)) : + typeof define === 'function' && define.amd ? define('js-data-adapter', ['js-data'], factory) : + (factory(global.JSData)); + }(this, function (jsData) { 'use strict'; + + var babelHelpers = {}; + babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; + }; + + babelHelpers.defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + }; + + babelHelpers.slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + }(); + + babelHelpers; + + var noop = function noop() { + var self = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var unique = function unique(array) { + var seen = {}; + var final = []; + array.forEach(function (item) { + if (item in seen) { + return; + } + final.push(item); + seen[item] = 0; + }); + return final; + }; + + var withoutRelations = function withoutRelations(mapper, props) { + return jsData.utils.omit(props, mapper.relationFields || []); + }; + + var DEFAULTS = { + /** + * Whether to log debugging information. + * + * @name Adapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * Whether to return a more detailed response object. + * + * @name Adapter#raw + * @type {boolean} + * @default false + */ + raw: false + }; + + /** + * Abstract class meant to be extended by adapters. + * + * @class Adapter + * @abstract + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.debug=false] Whether to log debugging information. + * @param {boolean} [opts.raw=false] Whether to return a more detailed response + * object. + */ + function Adapter(opts) { + var self = this; + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS); + jsData.utils.fillIn(self, opts); + } + + Adapter.reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where']; + + /** + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @typedef {Object} Response + * @property {Object} data Response data. + * @property {string} op The operation for which the response was created. + */ + function Response(data, meta, op) { + var self = this; + meta || (meta = {}); + self.data = data; + jsData.utils.fillIn(self, meta); + self.op = op; + } + + Adapter.Response = Response; + + /** + * Alternative to ES6 class syntax for extending `Adapter`. + * + * @name Adapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `Adapter`. + */ + Adapter.extend = jsData.utils.extend; + + jsData.utils.addHiddenPropsToTarget(Adapter.prototype, { + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#afterCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} props The `props` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `afterCount` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterCount: noop2, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `afterCreate` + * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreate: noop2, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `afterCreateMany` + * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreateMany: noop2, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#afterDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `afterDestroy` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroy: noop2, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#afterDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `afterDestroyAll` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroyAll: noop2, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#afterFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `afterFind` + * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`. + */ + afterFind: noop2, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#afterFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `afterFindAll` + * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`. + */ + afterFindAll: noop2, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#afterSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} props The `props` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `afterSum` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterSum: noop2, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#afterUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `afterUpdate` + * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdate: noop2, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#afterUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `afterUpdateAll` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateAll: noop2, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#afterUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} records The `records` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `afterUpdateMany` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateMany: noop2, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#beforeCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} query The `query` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `beforeCount` + */ + beforeCount: noop, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#beforeCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `beforeCreate` + */ + beforeCreate: noop, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#beforeCreateMany + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `beforeCreateMany` + */ + beforeCreateMany: noop, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#beforeDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `beforeDestroy` + */ + beforeDestroy: noop, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#beforeDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `beforeDestroyAll` + */ + beforeDestroyAll: noop, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#beforeFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `beforeFind` + */ + beforeFind: noop, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#beforeFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `beforeFindAll` + */ + beforeFindAll: noop, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#beforeSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `beforeSum` + */ + beforeSum: noop, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#beforeUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `beforeUpdate` + */ + beforeUpdate: noop, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#beforeUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `beforeUpdateAll` + */ + beforeUpdateAll: noop, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#beforeUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} props The `props` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `beforeUpdateMany` + */ + beforeUpdateMany: noop, + + /** + * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`. + * + * @name Adapter#dbg + * @method + */ + dbg: function dbg() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + this.log.apply(this, ['debug'].concat(args)); + }, + + + /** + * Retrieve the number of records that match the selection query. Called by + * `Mapper#count`. + * + * @name Adapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._count(mapper, query, opts)); + }).then(function (results) { + var _results = babelHelpers.slicedToArray(results, 2); + + var data = _results[0]; + var result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Create a new record. Called by `Mapper#create`. + * + * @name Adapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'create'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = babelHelpers.slicedToArray(results, 2); + + var data = _results2[0]; + var result = _results2[1]; + + result || (result = {}); + var response = new Response(data, result, 'create'); + response.created = data ? 1 : 0; + response = self.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Create multiple records in a single batch. Called by `Mapper#createMany`. + * + * @name Adapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'createMany'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = babelHelpers.slicedToArray(results, 2); + + var data = _results3[0]; + var result = _results3[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'createMany'); + response.created = data.length; + response = self.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Destroy the record with the given primary key. Called by + * `Mapper#destroy`. + * + * @name Adapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + var op = void 0; + opts || (opts = {}); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = babelHelpers.slicedToArray(results, 2); + + var data = _results4[0]; + var result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = self.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Destroy the records that match the selection query. Called by + * `Mapper#destroyAll`. + * + * @name Adapter#destroyAll + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = babelHelpers.slicedToArray(results, 2); + + var data = _results5[0]; + var result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = self.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * 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); + }, + + + /** + * Load a hasMany relationship. + * + * Override with care. + * + * @name Adapter#loadHasMany + * @method + * @return {Promise} + */ + loadHasMany: function loadHasMany(mapper, def, records, __opts) { + var self = this; + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return self.makeHasManyForeignKey(mapper, def, record); + }); + var query = { + where: {} + }; + var criteria = query.where[def.foreignKey] = {}; + if (singular) { + // more efficient query when we only have one record + criteria['=='] = IDs[0]; + } else { + criteria['in'] = IDs.filter(function (id) { + return id; + }); + } + return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { + records.forEach(function (record) { + var attached = []; + // avoid unneccesary iteration when we only have one record + if (singular) { + attached = relatedItems; + } else { + relatedItems.forEach(function (relatedItem) { + if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { + attached.push(relatedItem); + } + }); + } + def.setLocalField(record, attached); + }); + }); + }, + loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { + var self = this; + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': self.makeHasManyLocalKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + var _ret = function () { + var localKeys = []; + records.forEach(function (record) { + localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record)); + }); + return { + v: self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + var itemKeys = jsData.utils.get(item, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem); + } + }); + def.setLocalField(item, attached); + }); + return relatedItems; + }) + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; + } + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var self = this; + var relatedMapper = def.getRelation(); + var idAttribute = mapper.idAttribute; + var record = void 0; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return self.findAll(def.getRelation(), { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'contains': self.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return self.makeHasManyForeignKeys(mapper, def, record); + }) + }) + }, __opts).then(function (relatedItems) { + var foreignKeysField = def.foreignKeys; + records.forEach(function (record) { + var _relatedItems = []; + var id = jsData.utils.get(record, idAttribute); + relatedItems.forEach(function (relatedItem) { + var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; + if (foreignKeys.indexOf(id) !== -1) { + _relatedItems.push(relatedItem); + } + }); + def.setLocalField(record, _relatedItems); + }); + }); + } + }, + + + /** + * Load a hasOne relationship. + * + * Override with care. + * + * @name Adapter#loadHasOne + * @method + * @return {Promise} + */ + loadHasOne: function loadHasOne(mapper, def, records, __opts) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + records = [records]; + } + return this.loadHasMany(mapper, def, records, __opts).then(function () { + records.forEach(function (record) { + var relatedData = def.getLocalField(record); + if (jsData.utils.isArray(relatedData) && relatedData.length) { + def.setLocalField(record, relatedData[0]); + } + }); + }); + }, + + + /** + * 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); + }, + + + /** + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo + * @method + * @return {Promise} + */ + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { + var self = this; + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var _ret2 = function () { + var record = records; + return { + v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }) + }; + }(); + + if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v; + } else { + var keys = records.map(function (record) { + return self.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return self.findAll(relationDef, { + where: babelHelpers.defineProperty({}, relationDef.idAttribute, { + 'in': keys + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (record) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { + def.setLocalField(record, relatedItem); + } + }); + }); + }); + } + }, + + + /** + * Retrieve the record with the given primary key. Called by `Mapper#find`. + * + * @name Adapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + var record = void 0, + op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._find(mapper, id, opts)); + }).then(function (results) { + var _results6 = babelHelpers.slicedToArray(results, 1); + + var _record = _results6[0]; + + if (!_record) { + return; + } + record = _record; + var tasks = []; + + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasOne') { + task = self.loadHasOne(mapper, def, record, __opts); + } else { + task = self.loadHasMany(mapper, def, record, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, record, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, record, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, record, __opts); + } + if (task) { + tasks.push(task); + } + }); + + return Promise.all(tasks); + }).then(function () { + var response = new Response(record, {}, 'find'); + response.found = record ? 1 : 0; + response = self.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Retrieve the records that match the selection query. + * + * @name Adapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + opts || (opts = {}); + opts.with || (opts.with = []); + + var records = []; + var op = void 0; + var activeWith = opts._activeWith; + + if (jsData.utils.isObject(activeWith)) { + var activeQuery = activeWith.query || {}; + if (activeWith.replace) { + query = activeQuery; + } else { + jsData.utils.deepFillIn(query, activeQuery); + } + } + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._findAll(mapper, query, opts)); + }).then(function (results) { + var _results7 = babelHelpers.slicedToArray(results, 1); + + var _records = _results7[0]; + + _records || (_records = []); + records = _records; + var tasks = []; + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasMany') { + task = self.loadHasMany(mapper, def, records, __opts); + } else { + task = self.loadHasOne(mapper, def, records, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } + }); + return Promise.all(tasks); + }).then(function () { + var response = new Response(records, {}, 'findAll'); + response.found = records.length; + response = self.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Resolve the value of the specified option based on the given options and + * this adapter's settings. Override with care. + * + * @name Adapter#getOpt + * @method + * @param {string} opt The name of the option. + * @param {Object} [opts] Configuration options. + * @return {*} The value of the specified option. + */ + getOpt: function getOpt(opt, opts) { + opts || (opts = {}); + return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); + }, + + + /** + * Logging utility method. Override this method if you want to send log + * messages to something other than the console. + * + * @name Adapter#log + * @method + * @param {string} level Log level. + * @param {...*} values Values to log. + */ + log: function log(level) { + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + if (level && !args.length) { + args.push(level); + level = 'debug'; + } + if (level === 'debug' && !this.debug) { + return; + } + var prefix = level.toUpperCase() + ': (Adapter)'; + if (console[level]) { + var _console; + + (_console = console)[level].apply(_console, [prefix].concat(args)); + } else { + var _console2; + + (_console2 = console).log.apply(_console2, [prefix].concat(args)); + } + }, + + + /** + * Retrieve sum of the specified field of the records that match the selection + * query. Called by `Mapper#sum`. + * + * @name Adapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field By to sum. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + var op = void 0; + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + query || (query = {}); + opts || (opts = {}); + + // beforeSum lifecycle hook + op = opts.op = 'beforeSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + self.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(self._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results8 = babelHelpers.slicedToArray(results, 2); + + var data = _results8[0]; + var result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * @name Adapter#respond + * @method + * @param {Object} response Response object. + * @param {Object} opts Configuration options. + * return {Object} If `opts.raw == true` then return `response`, else return + * `response.data`. + */ + respond: function respond(response, opts) { + return this.getOpt('raw', opts) ? response : response.data; + }, + + + /** + * Apply the given update to the record with the specified primary key. Called + * by `Mapper#update`. + * + * @name Adapter#update + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id The primary key of the record to be updated. + * @param {Object} props The update to apply to the record. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + op = opts.op = 'update'; + self.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(self._update(mapper, id, props, opts)); + }).then(function (results) { + var _results9 = babelHelpers.slicedToArray(results, 2); + + var data = _results9[0]; + var result = _results9[1]; + + result || (result = {}); + var response = new Response(data, result, 'update'); + response.updated = data ? 1 : 0; + response = self.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Apply the given update to all records that match the selection query. + * Called by `Mapper#updateAll`. + * + * @name Adapter#updateAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + op = opts.op = 'updateAll'; + self.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results10 = babelHelpers.slicedToArray(results, 2); + + var data = _results10[0]; + var result = _results10[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateAll'); + response.updated = data.length; + response = self.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Update the given records in a single batch. Called by `Mapper#updateMany`. + * + * @name Adapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + records || (records = []); + opts || (opts = {}); + var op = void 0; + var idAttribute = mapper.idAttribute; + + records = records.filter(function (record) { + return jsData.utils.get(record, idAttribute); + }); + + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = jsData.utils.isUndefined(_records) ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'updateMany'; + self.dbg(op, mapper, records, opts); + return jsData.utils.resolve(self._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results11 = babelHelpers.slicedToArray(results, 2); + + var data = _results11[0]; + var result = _results11[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateMany'); + response.updated = data.length; + response = self.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + } + }); + + module.exports = Adapter; + + })); + //# sourceMappingURL=js-data-adapter.js.map + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_3__; + +/***/ } +/******/ ]) +}); +; +//# sourceMappingURL=js-data-http-node.js.map \ No newline at end of file diff --git a/node/dist/js-data-http-node.js.map b/node/dist/js-data-http-node.js.map new file mode 100644 index 0000000..2e944d4 --- /dev/null +++ b/node/dist/js-data-http-node.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 66471f2167b1b4c3962f","webpack:///./src/index.js","webpack:///external \"js-data\"","webpack:///./~/js-data-adapter/dist/js-data-adapter.js","webpack:///external \"axios\""],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O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ACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA,QAAO;AACP;AACA;AACA;AACA,IAAG;;AAEH;;AAEA;AACA;;AAEA,oEAAmE,aAAa;AAChF;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,uEAAsE,eAAe;AACrF;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB,cAAa,QAAQ;AACrB,cAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,uBAAsB;AACtB;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,iBAAgB,OAAO;AACvB,iBAAgB,OAAO;AACvB;AACA;AACA;AACA,uBAAsB;AACtB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa,OAAO;AACpB;AACA,cAAa,OAAO;AACpB;AACA,eAAc,OAAO;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,6BAA6B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,8BAA8B,eAAe;AAC9E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,mBAAmB,0BAA0B,eAAe;AAC3E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,+BAA+B,eAAe;AAC7E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,gCAAgC,eAAe;AAChF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,oBAAoB,eAAe;AAClE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,gBAAgB,iCAAiC,eAAe;AAC/E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB,gBAAe,kBAAkB,kCAAkC,eAAe;AAClF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,mBAAkB,OAAO;AACzB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAwE,eAAe;AACvF;AACA;;AAEA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,2BAA0B;AAC1B,yBAAwB;;AAExB;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA,+BAA8B;AAC9B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA;AACA;AACA;AACA,YAAW;AACX;AACA;AACA,oDAAmD;AACnD;AACA;AACA,kBAAiB;AACjB,gBAAe;AACf,cAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA,gBAAe;AACf;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA,UAAS;AACT,QAAO;AACP;AACA,gDAA+C;AAC/C;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA,UAAS;;AAET;AACA,QAAO;AACP;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA,gDAA+C;AAC/C;AACA,YAAW;AACX,UAAS;AACT;AACA;AACA;AACA;AACA;AACA,cAAa;AACb,YAAW;AACX,UAAS;AACT;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,gBAAgB;AAC/B,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA,QAAO;AACP,+CAA8C;AAC9C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,aAAa;AAC5B,gBAAe,aAAa;AAC5B,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,gBAAe,SAAS;AACxB,iBAAgB;AAChB;AACA;AACA;AACA,yBAAwB;AACxB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA,YAAW;AACX;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,QAAO;AACP,gDAA+C;AAC/C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,OAAO;AACtB,iBAAgB,EAAE;AAClB;AACA;AACA,yBAAwB;AACxB;AACA,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,KAAK;AACpB;AACA;AACA,6FAA4F,eAAe;AAC3G;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,QA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AACA,iBAAgB;AAChB;AACA;AACA;AACA,2BAA0B;AAC1B,2BAA0B;AAC1B,yBAAwB;AACxB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP,MAAK;;;AAGL;AACA;AACA;AACA;AACA;AACA,gBAAe,OAAO;AACtB,gBAAe,SAAS;AACxB,gBAAe,OAAO;AACtB,gBAAe,QAAQ;AACvB;AACA,iBAAgB;AAChB;AACA;AACA;AACA;AACA,yBAAwB;AACxB;AACA;;AAEA;AACA;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA,QAAO;AACP;;AAEA;AACA;;AAEA;AACA,+BAA8B;AAC9B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,QAAO;AACP;AACA,IAAG;;AAEH;;AAEA,EAAC;AACD,4C;;;;;;AC3lDA,gD","file":"./node/dist/js-data-http-node.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"js-data\"), require(\"axios\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"js-data\", \"axios\"], factory);\n\telse {\n\t\tvar a = typeof exports === 'object' ? factory(require(\"js-data\"), require(\"axios\")) : factory(root[\"js-data\"], root[\"axios\"]);\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_3__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 66471f2167b1b4c3962f\n **/","/* global fetch:true Headers:true Request:true */\nconst axios = require('axios')\nimport {utils} from 'js-data'\nimport Adapter from 'js-data-adapter'\n\nlet hasFetch = false\n\ntry {\n hasFetch = window && window.fetch\n} catch (e) {}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nconst noop2 = function (...args) {\n const self = this\n const opts = args[args.length - 2]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nfunction isValidString (value) {\n return (value != null && value !== '')\n}\nfunction join (items, separator) {\n separator || (separator = '')\n return items.filter(isValidString).join(separator)\n}\nfunction makePath (...args) {\n let result = join(args, '/')\n return result.replace(/([^:\\/]|^)\\/{2,}/g, '$1/')\n}\n\nfunction encode (val) {\n return encodeURIComponent(val)\n .replace(/%40/gi, '@')\n .replace(/%3A/gi, ':')\n .replace(/%24/g, '$')\n .replace(/%2C/gi, ',')\n .replace(/%20/g, '+')\n .replace(/%5B/gi, '[')\n .replace(/%5D/gi, ']')\n}\n\nfunction buildUrl (url, params) {\n if (!params) {\n return url\n }\n\n const parts = []\n\n utils.forOwn(params, function (val, key) {\n if (val === null || typeof val === 'undefined') {\n return\n }\n if (!utils.isArray(val)) {\n val = [val]\n }\n\n val.forEach(function (v) {\n if (window.toString.call(v) === '[object Date]') {\n v = v.toISOString()\n } else if (utils.isObject(v)) {\n v = utils.toJson(v)\n }\n parts.push(`${encode(key)}=${encode(v)}`)\n })\n })\n\n if (parts.length > 0) {\n url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&')\n }\n\n return url\n}\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n // Default and user-defined settings\n /**\n * @name HttpAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * @name HttpAdapter#forceTrailingSlash\n * @type {boolean}\n * @default false\n */\n forceTrailingSlash: false,\n\n /**\n * @name HttpAdapter#http\n * @type {Function}\n */\n http: axios,\n\n /**\n * @name HttpAdapter#httpConfig\n * @type {Object}\n */\n httpConfig: {},\n\n /**\n * @name HttpAdapter#suffix\n * @type {string}\n */\n suffix: '',\n\n /**\n * @name HttpAdapter#useFetch\n * @type {boolean}\n * @default false\n */\n useFetch: false\n}\n\n/**\n * HttpAdapter class.\n *\n * @class HttpAdapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {boolean} [opts.forceTrailingSlash=false] TODO\n * @param {Object} [opts.http=axios] TODO\n * @param {Object} [opts.httpConfig={}] TODO\n * @param {string} [opts.suffix=''] TODO\n * @param {boolean} [opts.useFetch=false] TODO\n */\nfunction HttpAdapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nHttpAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: HttpAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(HttpAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\nutils.addHiddenPropsToTarget(HttpAdapter.prototype, {\n /**\n * @name HttpAdapter#afterDEL\n * @method\n * @param {string} url\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterDEL: noop2,\n\n /**\n * @name HttpAdapter#afterGET\n * @method\n * @param {string} url\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterGET: noop2,\n\n /**\n * @name HttpAdapter#afterHTTP\n * @method\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterHTTP: noop2,\n\n /**\n * @name HttpAdapter#afterPOST\n * @method\n * @param {string} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterPOST: noop2,\n\n /**\n * @name HttpAdapter#afterPUT\n * @method\n * @param {string} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n * @param {Object} response\n */\n afterPUT: noop2,\n\n /**\n * @name HttpAdapter#beforeDEL\n * @method\n * @param {Object} url\n * @param {Object} config\n * @param {Object} opts\n */\n beforeDEL: noop,\n\n /**\n * @name HttpAdapter#beforeGET\n * @method\n * @param {Object} url\n * @param {Object} config\n * @param {Object} opts\n */\n beforeGET: noop,\n\n /**\n * @name HttpAdapter#beforeHTTP\n * @method\n * @param {Object} config\n * @param {Object} opts\n */\n beforeHTTP: noop,\n\n /**\n * @name HttpAdapter#beforePOST\n * @method\n * @param {Object} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n */\n beforePOST: noop,\n\n /**\n * @name HttpAdapter#beforePUT\n * @method\n * @param {Object} url\n * @param {Object} data\n * @param {Object} config\n * @param {Object} opts\n */\n beforePUT: noop,\n\n _count (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('count', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _create (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('create', mapper, props, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _createMany (mapper, props, opts) {\n const self = this\n return self.POST(\n self.getPath('createMany', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroy (mapper, id, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroy', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _destroyAll (mapper, query, opts) {\n const self = this\n return self.DEL(\n self.getPath('destroyAll', mapper, null, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _end (mapper, opts, response) {\n return [this.deserialize(mapper, response, opts), response]\n },\n\n _find (mapper, id, opts) {\n const self = this\n return self.GET(\n self.getPath('find', mapper, id, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _findAll (mapper, query, opts) {\n const self = this\n return self.GET(\n self.getPath('findAll', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _sum (mapper, field, query, opts) {\n const self = this\n return self.GET(\n self.getPath('sum', mapper, opts.params, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _update (mapper, id, props, opts) {\n const self = this\n return self.PUT(\n self.getPath('update', mapper, id, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateAll (mapper, props, query, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateAll', mapper, null, opts),\n self.serialize(mapper, props, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n _updateMany (mapper, records, opts) {\n const self = this\n return self.PUT(\n self.getPath('updateMany', mapper, null, opts),\n self.serialize(mapper, records, opts),\n opts\n ).then(function (response) {\n return self._end(mapper, opts, response)\n })\n },\n\n /**\n * Retrieve the number of records that match the selection `query`.\n *\n * @name HttpAdapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params.count = true\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.count.call(self, mapper, query, opts)\n },\n\n /**\n * Create a new the record from the provided `props`.\n *\n * @name HttpAdapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props Properties to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.create.call(self, mapper, props, opts)\n },\n\n /**\n * Create multiple new records in batch.\n *\n * @name HttpAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.createMany.call(self, mapper, props, opts)\n },\n\n /**\n * Make an Http request to `url` according to the configuration in `config`.\n *\n * @name HttpAdapter#DEL\n * @method\n * @param {string} url Url for the request.\n * @param {Object} [config] Http configuration that will be passed to\n * {@link HttpAdapter#HTTP}.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n DEL (url, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'delete'\n\n // beforeDEL lifecycle hook\n op = opts.op = 'beforeDEL'\n return utils.resolve(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'DEL'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterDEL lifecycle hook\n op = opts.op = 'afterDEL'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Transform the server response object into the payload that will be returned\n * to JSData.\n *\n * @name HttpAdapter#deserialize\n * @method\n * @param {Object} mapper The mapper used for the operation.\n * @param {Object} response Response object from {@link HttpAdapter#HTTP}.\n * @param {Object} opts Configuration options.\n * @return {(Object|Array)} Deserialized data.\n */\n deserialize (mapper, response, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.deserialize)) {\n return opts.deserialize(mapper, response, opts)\n }\n if (utils.isFunction(mapper.deserialize)) {\n return mapper.deserialize(mapper, response, opts)\n }\n if (response && response.hasOwnProperty('data')) {\n return response.data\n }\n return response\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name HttpAdapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroy.call(self, mapper, id, opts)\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name HttpAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.destroyAll.call(self, mapper, query, opts)\n },\n\n /**\n * Log an error.\n *\n * @name HttpAdapter#error\n * @method\n * @param {...*} [args] Arguments to log.\n */\n error (...args) {\n if (console) {\n console[typeof console.error === 'function' ? 'error' : 'log'](...args)\n }\n },\n\n /**\n * Make an Http request using `window.fetch`.\n *\n * @name HttpAdapter#fetch\n * @method\n * @param {Object} config Request configuration.\n * @param {Object} config.data Payload for the request.\n * @param {string} config.method Http method for the request.\n * @param {Object} config.headers Headers for the request.\n * @param {Object} config.params Querystring for the request.\n * @param {string} config.url Url for the request.\n * @param {Object} [opts] Configuration options.\n */\n fetch (config, opts) {\n const requestConfig = {\n method: config.method,\n // turn the plain headers object into the Fetch Headers object\n headers: new Headers(config.headers)\n }\n\n if (config.data) {\n requestConfig.body = utils.toJson(config.data)\n }\n\n return fetch(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) {\n response.config = {\n method: config.method,\n url: config.url\n }\n return response.json().then(function (data) {\n response.data = data\n return response\n })\n })\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name HttpAdapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.find.call(self, mapper, id, opts)\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name HttpAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.findAll.call(self, mapper, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#GET\n * @method\n * @param {string} url The url for the request.\n * @param {Object} config Request configuration options.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n GET (url, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.method = config.method || 'get'\n\n // beforeGET lifecycle hook\n op = opts.op = 'beforeGET'\n return utils.resolve(self[op](url, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'GET'\n self.dbg(op, url, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterGET lifecycle hook\n op = opts.op = 'afterGET'\n return utils.resolve(self[op](url, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name HttpAdapter#getEndpoint\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {boolean} opts TODO\n * @return {string} Full path.\n */\n getEndpoint (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n opts.params = utils.isUndefined(opts.params) ? {} : opts.params\n const relationList = mapper.relationList || []\n let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint\n\n relationList.forEach(function (def) {\n if (def.type !== 'belongsTo' || !def.parent) {\n return\n }\n let item\n const parentKey = def.foreignKey\n const parentDef = def.getRelation()\n let parentId = opts.params[parentKey]\n\n if (parentId === false || !parentKey || !parentDef) {\n if (parentId === false) {\n delete opts.params[parentKey]\n }\n return false\n } else {\n delete opts.params[parentKey]\n\n if (utils.isObject(id)) {\n item = id\n }\n\n if (item) {\n parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null)\n }\n\n if (parentId) {\n delete opts.endpoint\n const _opts = {}\n utils.forOwn(opts, function (value, key) {\n _opts[key] = value\n })\n utils._(_opts, parentDef)\n endpoint = makePath(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint)\n return false\n }\n }\n })\n\n return endpoint\n },\n\n /**\n * @name HttpAdapter#getPath\n * @method\n * @param {string} method TODO\n * @param {Object} mapper TODO\n * @param {(string|number)?} id TODO\n * @param {Object} opts Configuration options.\n */\n getPath (method, mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const args = [\n utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath,\n self.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts)\n ]\n if (method === 'find' || method === 'update' || method === 'destroy') {\n args.push(id)\n }\n return makePath.apply(utils, args)\n },\n\n getParams (opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.params)) {\n return {}\n }\n return utils.copy(opts.params)\n },\n\n getSuffix (mapper, opts) {\n opts || (opts = {})\n if (utils.isUndefined(opts.suffix)) {\n if (utils.isUndefined(mapper.suffix)) {\n return this.suffix\n }\n return mapper.suffix\n }\n return opts.suffix\n },\n\n /**\n * Make an Http request.\n *\n * @name HttpAdapter#HTTP\n * @method\n * @param {Object} config Request configuration options.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n HTTP (config, opts) {\n const self = this\n const start = new Date()\n opts || (opts = {})\n const payload = config.data\n const cache = config.cache\n const timeout = config.timeout\n config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout'])\n config = utils.deepMixIn(config, self.httpConfig)\n config.data = payload\n config.cache = cache\n config.timeout = timeout\n if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') {\n config.url += '/'\n }\n config.method = config.method.toUpperCase()\n const suffix = config.suffix || opts.suffix || self.suffix\n if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) {\n config.url += suffix\n }\n\n function logResponse (data) {\n const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms`\n if (data.status >= 200 && data.status < 300) {\n if (self.log) {\n self.dbg('debug', str, data)\n }\n return data\n } else {\n if (self.error) {\n self.error(`'FAILED: ${str}`, data)\n }\n return utils.reject(data)\n }\n }\n\n if (!self.http) {\n throw new Error('You have not configured this adapter with an http library!')\n }\n\n return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) {\n config = _config || config\n if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) {\n return self.fetch(config, opts).then(logResponse, logResponse)\n }\n return self.http(config).then(logResponse, logResponse).catch(function (err) {\n return self.responseError(err, config, opts)\n })\n }).then(function (response) {\n return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) {\n return _response || response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#POST\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n POST (url, data, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'post'\n\n // beforePOST lifecycle hook\n op = opts.op = 'beforePOST'\n return utils.resolve(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'POST'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPOST lifecycle hook\n op = opts.op = 'afterPOST'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#PUT\n * @method\n * @param {*} url TODO\n * @param {Object} data TODO\n * @param {Object} config TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n PUT (url, data, config, opts) {\n const self = this\n let op\n config || (config = {})\n opts || (opts = {})\n config.url = url || config.url\n config.data = data || config.data\n config.method = config.method || 'put'\n\n // beforePUT lifecycle hook\n op = opts.op = 'beforePUT'\n return utils.resolve(self[op](url, data, config, opts)).then(function (_config) {\n // Allow re-assignment from lifecycle hook\n config = utils.isUndefined(_config) ? config : _config\n op = opts.op = 'PUT'\n self.dbg(op, url, data, config, opts)\n return self.HTTP(config, opts)\n }).then(function (response) {\n // afterPUT lifecycle hook\n op = opts.op = 'afterPUT'\n return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) {\n // Allow re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#queryTransform\n * @method\n * @param {Object} mapper TODO\n * @param {*} params TODO\n * @param {*} opts TODO\n * @return {*} Transformed params.\n */\n queryTransform (mapper, params, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.queryTransform)) {\n return opts.queryTransform(mapper, params, opts)\n }\n if (utils.isFunction(mapper.queryTransform)) {\n return mapper.queryTransform(mapper, params, opts)\n }\n return params\n },\n\n /**\n * Error handler invoked when the promise returned by {@link HttpAdapter#http}\n * is rejected. Default implementation is to just return the error wrapped in\n * a rejected Promise, aka rethrow the error. {@link HttpAdapter#http} is\n * called by {@link HttpAdapter#HTTP}.\n *\n * @name HttpAdapter#responseError\n * @method\n * @param {*} err The error that {@link HttpAdapter#http} rejected with.\n * @param {Object} config The `config` argument that was passed to {@link HttpAdapter#HTTP}.\n * @param {*} opts The `opts` argument that was passed to {@link HttpAdapter#HTTP}.\n * @return {Promise}\n */\n responseError (err, config, opts) {\n return utils.reject(err)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#serialize\n * @method\n * @param {Object} mapper TODO\n * @param {Object} data TODO\n * @param {*} opts TODO\n * @return {*} Serialized data.\n */\n serialize (mapper, data, opts) {\n opts || (opts = {})\n if (utils.isFunction(opts.serialize)) {\n return opts.serialize(mapper, data, opts)\n }\n if (utils.isFunction(mapper.serialize)) {\n return mapper.serialize(mapper, data, opts)\n }\n return data\n },\n\n /**\n * Retrieve the sum of the field of the records that match the selection query.\n *\n * @name HttpAdapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field The field to sum.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n if (!utils.utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n opts.params = self.getParams(opts)\n opts.params.sum = field\n opts.suffix = self.getSuffix(mapper, opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n\n return __super__.sum.call(self, mapper, field, query, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#update\n * @method\n * @param {Object} mapper TODO\n * @param {*} id TODO\n * @param {*} props TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.update.call(self, mapper, id, props, opts)\n },\n\n /**\n * TODO\n *\n * @name HttpAdapter#updateAll\n * @method\n * @param {Object} mapper TODO\n * @param {Object} props TODO\n * @param {Object} query TODO\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n opts.params = self.getParams(opts)\n utils.deepMixIn(opts.params, query)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateAll.call(self, mapper, props, query, opts)\n },\n\n /**\n * Update multiple records in batch.\n *\n * {@link HttpAdapter#beforeUpdateMany} will be called before calling\n * {@link HttpAdapter#PUT}.\n * {@link HttpAdapter#afterUpdateMany} will be called after calling\n * {@link HttpAdapter#PUT}.\n *\n * @name HttpAdapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} records Array of property objects to send as the payload.\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.params] TODO\n * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n opts || (opts = {})\n opts.params = self.getParams(opts)\n opts.params = self.queryTransform(mapper, opts.params, opts)\n opts.suffix = self.getSuffix(mapper, opts)\n\n return __super__.updateMany.call(self, mapper, records, opts)\n }\n})\n\n/**\n * Add an Http actions to a mapper.\n *\n * @name HttpAdapter.addAction\n * @method\n * @param {string} name Name of the new action.\n * @param {Object} [opts] Action configuration\n * @param {string} [opts.adapter]\n * @param {string} [opts.pathname]\n * @param {Function} [opts.request]\n * @param {Function} [opts.response]\n * @param {Function} [opts.responseError]\n * @return {Function} Decoration function, which should be passed the mapper to\n * decorate when invoked.\n */\nHttpAdapter.addAction = function (name, opts) {\n if (!name || !utils.isString(name)) {\n throw new TypeError('action(name[, opts]): Expected: string, Found: ' + typeof name)\n }\n return function (mapper) {\n if (mapper[name]) {\n throw new Error('action(name[, opts]): ' + name + ' already exists on target!')\n }\n opts.request = opts.request || function (config) { return config }\n opts.response = opts.response || function (response) { return response }\n opts.responseError = opts.responseError || function (err) { return utils.reject(err) }\n mapper[name] = function (id, _opts) {\n const self = this\n if (utils.isObject(id)) {\n _opts = id\n }\n _opts = _opts || {}\n let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http')\n let config = {}\n utils.fillIn(config, opts)\n if (!_opts.hasOwnProperty('endpoint') && config.endpoint) {\n _opts.endpoint = config.endpoint\n }\n if (typeof _opts.getEndpoint === 'function') {\n config.url = _opts.getEndpoint(self, _opts)\n } else {\n let args = [\n _opts.basePath || self.basePath || adapter.basePath,\n adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _opts)\n ]\n if (utils.isSorN(id)) {\n args.push(id)\n }\n args.push(opts.pathname || name)\n config.url = makePath.apply(null, args)\n }\n config.method = config.method || 'GET'\n config.mapper = self.name\n utils.deepMixIn(config)(_opts)\n return utils.resolve(config)\n .then(_opts.request || opts.request)\n .then(function (config) { return adapter.HTTP(config) })\n .then(function (data) {\n if (data && data.config) {\n data.config.mapper = self.name\n }\n return data\n })\n .then(_opts.response || opts.response, _opts.responseError || opts.responseError)\n }\n return mapper\n }\n}\n\n/**\n * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for\n * action configuration options.\n *\n * @name HttpAdapter.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 */\nHttpAdapter.addActions = function (opts) {\n opts || (opts = {})\n return function (mapper) {\n utils.forOwn(mapper, function (value, key) {\n HttpAdapter.addAction(key, value)(mapper)\n })\n return mapper\n }\n}\n\n/**\n * Alternative to ES6 class syntax for extending `HttpAdapter`.\n *\n * __ES6__:\n * ```javascript\n * class MyHttpAdapter extends HttpAdapter {\n * deserialize (Model, data, opts) {\n * const data = super.deserialize(Model, data, opts)\n * data.foo = 'bar'\n * return data\n * }\n * }\n * ```\n *\n * __ES5__:\n * ```javascript\n * var instanceProps = {\n * // override deserialize\n * deserialize: function (Model, data, opts) {\n * var Ctor = this.constructor\n * var superDeserialize = (Ctor.__super__ || Object.getPrototypeOf(Ctor)).deserialize\n * // call the super deserialize\n * var data = superDeserialize(Model, data, opts)\n * data.foo = 'bar'\n * return data\n * },\n * say: function () { return 'hi' }\n * }\n * var classProps = {\n * yell: function () { return 'HI' }\n * }\n *\n * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps)\n * var adapter = new MyHttpAdapter()\n * adapter.say() // \"hi\"\n * MyHttpAdapter.yell() // \"HI\"\n * ```\n *\n * @name HttpAdapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `HttpAdapter`.\n */\nHttpAdapter.extend = utils.extend\n\n/**\n * Details of the current version of the `js-data-http` module.\n *\n * @name HttpAdapter.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 */\nHttpAdapter.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 * __Script tag__:\n * ```javascript\n * window.HttpAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var HttpAdapter = require('js-data-http')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import HttpAdapter from 'js-data-http'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-http'], function (HttpAdapter) { ... })\n * ```\n *\n * @module js-data-http\n */\n\nmodule.exports = HttpAdapter\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"js-data\"\n ** module id = 1\n ** module chunks = 0\n **/","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('js-data')) :\n typeof define === 'function' && define.amd ? define('js-data-adapter', ['js-data'], factory) :\n (factory(global.JSData));\n}(this, function (jsData) { 'use strict';\n\n var babelHelpers = {};\n babelHelpers.typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n };\n\n babelHelpers.defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n };\n\n babelHelpers.slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n }();\n\n babelHelpers;\n\n var noop = function noop() {\n var self = this;\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n var opts = args[args.length - 1];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var noop2 = function noop2() {\n var self = this;\n\n for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n var opts = args[args.length - 2];\n self.dbg.apply(self, [opts.op].concat(args));\n return jsData.utils.resolve();\n };\n\n var unique = function unique(array) {\n var seen = {};\n var final = [];\n array.forEach(function (item) {\n if (item in seen) {\n return;\n }\n final.push(item);\n seen[item] = 0;\n });\n return final;\n };\n\n var withoutRelations = function withoutRelations(mapper, props) {\n return jsData.utils.omit(props, mapper.relationFields || []);\n };\n\n var DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n };\n\n /**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\n function Adapter(opts) {\n var self = this;\n opts || (opts = {});\n jsData.utils.fillIn(opts, DEFAULTS);\n jsData.utils.fillIn(self, opts);\n }\n\n Adapter.reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where'];\n\n /**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @typedef {Object} Response\n * @property {Object} data Response data.\n * @property {string} op The operation for which the response was created.\n */\n function Response(data, meta, op) {\n var self = this;\n meta || (meta = {});\n self.data = data;\n jsData.utils.fillIn(self, meta);\n self.op = op;\n }\n\n Adapter.Response = Response;\n\n /**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\n Adapter.extend = jsData.utils.extend;\n\n jsData.utils.addHiddenPropsToTarget(Adapter.prototype, {\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} props The `props` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg: function dbg() {\n for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n\n this.log.apply(this, ['debug'].concat(args));\n },\n\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count: function count(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._count(mapper, query, opts));\n }).then(function (results) {\n var _results = babelHelpers.slicedToArray(results, 2);\n\n var data = _results[0];\n var result = _results[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create: function create(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'create';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._create(mapper, props, opts));\n }).then(function (results) {\n var _results2 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results2[0];\n var result = _results2[1];\n\n result || (result = {});\n var response = new Response(data, result, 'create');\n response.created = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany: function createMany(mapper, props, opts) {\n var self = this;\n var op = void 0;\n props || (props = {});\n opts || (opts = {});\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n props = props.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'createMany';\n self.dbg(op, mapper, props, opts);\n return jsData.utils.resolve(self._createMany(mapper, props, opts));\n }).then(function (results) {\n var _results3 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results3[0];\n var result = _results3[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'createMany');\n response.created = data.length;\n response = self.respond(response, opts);\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany';\n return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy: function destroy(mapper, id, opts) {\n var self = this;\n var op = void 0;\n opts || (opts = {});\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._destroy(mapper, id, opts));\n }).then(function (results) {\n var _results4 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results4[0];\n var result = _results4[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroy');\n response = self.respond(response, opts);\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll: function destroyAll(mapper, query, opts) {\n var self = this;\n var op = void 0;\n query || (query = {});\n opts || (opts = {});\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._destroyAll(mapper, query, opts));\n }).then(function (results) {\n var _results5 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results5[0];\n var result = _results5[1];\n\n result || (result = {});\n var response = new Response(data, result, 'destroyAll');\n response = self.respond(response, opts);\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\n\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) {\n var localKeys = [];\n var itemKeys = jsData.utils.get(record, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n localKeys = localKeys.concat(itemKeys);\n return unique(localKeys).filter(function (x) {\n return x;\n });\n },\n\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) {\n return jsData.utils.get(record, mapper.idAttribute);\n },\n\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany: function loadHasMany(mapper, def, records, __opts) {\n var self = this;\n var singular = false;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n singular = true;\n records = [records];\n }\n var IDs = records.map(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record);\n });\n var query = {\n where: {}\n };\n var criteria = query.where[def.foreignKey] = {};\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0];\n } else {\n criteria['in'] = IDs.filter(function (id) {\n return id;\n });\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n var attached = [];\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems;\n } else {\n relatedItems.forEach(function (relatedItem) {\n if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem);\n }\n });\n }\n def.setLocalField(record, attached);\n });\n });\n },\n loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) {\n var self = this;\n var record = void 0;\n var relatedMapper = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n var _ret = function () {\n var localKeys = [];\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record));\n });\n return {\n v: self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {\n 'in': unique(localKeys).filter(function (x) {\n return x;\n })\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n var attached = [];\n var itemKeys = jsData.utils.get(item, def.localKeys) || [];\n itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);\n relatedItems.forEach(function (relatedItem) {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem);\n }\n });\n def.setLocalField(item, attached);\n });\n return relatedItems;\n })\n };\n }();\n\n if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === \"object\") return _ret.v;\n }\n },\n loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) {\n var self = this;\n var relatedMapper = def.getRelation();\n var idAttribute = mapper.idAttribute;\n var record = void 0;\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n record = records;\n }\n\n if (record) {\n return self.findAll(def.getRelation(), {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n })\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems);\n });\n } else {\n return self.findAll(relatedMapper, {\n where: babelHelpers.defineProperty({}, def.foreignKeys, {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record);\n })\n })\n }, __opts).then(function (relatedItems) {\n var foreignKeysField = def.foreignKeys;\n records.forEach(function (record) {\n var _relatedItems = [];\n var id = jsData.utils.get(record, idAttribute);\n relatedItems.forEach(function (relatedItem) {\n var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || [];\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem);\n }\n });\n def.setLocalField(record, _relatedItems);\n });\n });\n }\n },\n\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne: function loadHasOne(mapper, def, records, __opts) {\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n records = [records];\n }\n return this.loadHasMany(mapper, def, records, __opts).then(function () {\n records.forEach(function (record) {\n var relatedData = def.getLocalField(record);\n if (jsData.utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0]);\n }\n });\n });\n },\n\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) {\n return def.getForeignKey(record);\n },\n\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) {\n var self = this;\n var relationDef = def.getRelation();\n\n if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {\n var _ret2 = function () {\n var record = records;\n return {\n v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem);\n })\n };\n }();\n\n if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === \"object\") return _ret2.v;\n } else {\n var keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record);\n }).filter(function (key) {\n return key;\n });\n return self.findAll(relationDef, {\n where: babelHelpers.defineProperty({}, relationDef.idAttribute, {\n 'in': keys\n })\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem);\n }\n });\n });\n });\n }\n },\n\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find: function find(mapper, id, opts) {\n var self = this;\n var record = void 0,\n op = void 0;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind';\n return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find';\n self.dbg(op, mapper, id, opts);\n return jsData.utils.resolve(self._find(mapper, id, opts));\n }).then(function (results) {\n var _results6 = babelHelpers.slicedToArray(results, 1);\n\n var _record = _results6[0];\n\n if (!_record) {\n return;\n }\n record = _record;\n var tasks = [];\n\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts);\n } else {\n task = self.loadHasMany(mapper, def, record, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(record, {}, 'find');\n response.found = record ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind';\n return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll: function findAll(mapper, query, opts) {\n var self = this;\n opts || (opts = {});\n opts.with || (opts.with = []);\n\n var records = [];\n var op = void 0;\n var activeWith = opts._activeWith;\n\n if (jsData.utils.isObject(activeWith)) {\n var activeQuery = activeWith.query || {};\n if (activeWith.replace) {\n query = activeQuery;\n } else {\n jsData.utils.deepFillIn(query, activeQuery);\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll';\n self.dbg(op, mapper, query, opts);\n return jsData.utils.resolve(self._findAll(mapper, query, opts));\n }).then(function (results) {\n var _results7 = babelHelpers.slicedToArray(results, 1);\n\n var _records = _results7[0];\n\n _records || (_records = []);\n records = _records;\n var tasks = [];\n jsData.utils.forEachRelation(mapper, opts, function (def, __opts) {\n var task = void 0;\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts);\n } else {\n task = self.loadHasOne(mapper, def, records, __opts);\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts);\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts);\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts);\n }\n if (task) {\n tasks.push(task);\n }\n });\n return Promise.all(tasks);\n }).then(function () {\n var response = new Response(records, {}, 'findAll');\n response.found = records.length;\n response = self.respond(response, opts);\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll';\n return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt: function getOpt(opt, opts) {\n opts || (opts = {});\n return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]);\n },\n\n\n /**\n * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log: function log(level) {\n for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {\n args[_key4 - 1] = arguments[_key4];\n }\n\n if (level && !args.length) {\n args.push(level);\n level = 'debug';\n }\n if (level === 'debug' && !this.debug) {\n return;\n }\n var prefix = level.toUpperCase() + ': (Adapter)';\n if (console[level]) {\n var _console;\n\n (_console = console)[level].apply(_console, [prefix].concat(args));\n } else {\n var _console2;\n\n (_console2 = console).log.apply(_console2, [prefix].concat(args));\n }\n },\n\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum: function sum(mapper, field, query, opts) {\n var self = this;\n var op = void 0;\n if (!jsData.utils.isString(field)) {\n throw new Error('field must be a string!');\n }\n query || (query = {});\n opts || (opts = {});\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum';\n return jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum';\n self.dbg(op, mapper, field, query, opts);\n return jsData.utils.resolve(self._sum(mapper, field, query, opts));\n }).then(function (results) {\n var _results8 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results8[0];\n var result = _results8[1];\n\n result || (result = {});\n var response = new Response(data, result, op);\n response = self.respond(response, opts);\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum';\n return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond: function respond(response, opts) {\n return this.getOpt('raw', opts) ? response : response.data;\n },\n\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update: function update(mapper, id, props, opts) {\n var self = this;\n props || (props = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n op = opts.op = 'update';\n self.dbg(op, mapper, id, props, opts);\n return jsData.utils.resolve(self._update(mapper, id, props, opts));\n }).then(function (results) {\n var _results9 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results9[0];\n var result = _results9[1];\n\n result || (result = {});\n var response = new Response(data, result, 'update');\n response.updated = data ? 1 : 0;\n response = self.respond(response, opts);\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate';\n return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll: function updateAll(mapper, props, query, opts) {\n var self = this;\n props || (props = {});\n query || (query = {});\n opts || (opts = {});\n var op = void 0;\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = jsData.utils.isUndefined(_props) ? props : _props;\n op = opts.op = 'updateAll';\n self.dbg(op, mapper, props, query, opts);\n return jsData.utils.resolve(self._updateAll(mapper, props, query, opts));\n }).then(function (results) {\n var _results10 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results10[0];\n var result = _results10[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateAll');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll';\n return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n },\n\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany: function updateMany(mapper, records, opts) {\n var self = this;\n records || (records = []);\n opts || (opts = {});\n var op = void 0;\n var idAttribute = mapper.idAttribute;\n\n records = records.filter(function (record) {\n return jsData.utils.get(record, idAttribute);\n });\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = jsData.utils.isUndefined(_records) ? records : _records;\n records = records.map(function (record) {\n return withoutRelations(mapper, record);\n });\n op = opts.op = 'updateMany';\n self.dbg(op, mapper, records, opts);\n return jsData.utils.resolve(self._updateMany(mapper, records, opts));\n }).then(function (results) {\n var _results11 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results11[0];\n var result = _results11[1];\n\n data || (data = []);\n result || (result = {});\n var response = new Response(data, result, 'updateMany');\n response.updated = data.length;\n response = self.respond(response, opts);\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany';\n return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return jsData.utils.isUndefined(_response) ? response : _response;\n });\n });\n }\n });\n\n module.exports = Adapter;\n\n}));\n//# sourceMappingURL=js-data-adapter.js.map\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/js-data-adapter/dist/js-data-adapter.js\n ** module id = 2\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_3__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"axios\"\n ** module id = 3\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/node/mocha.start.js b/node/mocha.start.js new file mode 100644 index 0000000..afc2cf7 --- /dev/null +++ b/node/mocha.start.js @@ -0,0 +1,79 @@ +'use strict' + +var querystring = require('querystring') + +before(function () { + var Test = this + Test.fail = function (msg) { + if (msg instanceof Error) { + console.log(msg.stack) + } else { + Test.assert.equal('should not reach this!: ' + msg, 'failure') + } + } + Test.assert = require('chai').assert + Test.assert.objectsEqual = function (a, b, m) { + Test.assert.deepEqual(JSON.parse(JSON.stringify(a)), JSON.parse(JSON.stringify(b)), m || (JSON.stringify(a) + ' should be equal to ' + JSON.stringify(b))) + } + Test.sinon = require('sinon') + Test.JSData = require('js-data') + Test.HttpAdapter = require('./dist/js-data-http-node').HttpAdapter + Test.User = new Test.JSData.Mapper({ + name: 'user' + }) + Test.Post = new Test.JSData.Mapper({ + name: 'post', + endpoint: 'posts', + basePath: 'api' + }) + + console.log('Testing against js-data ' + Test.JSData.version.full) +}) + +beforeEach(function () { + var Test = this + Test.adapter = new Test.HttpAdapter() + Test.User.registerAdapter('http', Test.adapter, { default: true }) + Test.Post.registerAdapter('http', Test.adapter, { default: true }) + + Test.p1 = { author: 'John', age: 30, id: 5 } + Test.p2 = { author: 'Sally', age: 31, id: 6 } + Test.p3 = { author: 'Mike', age: 32, id: 7 } + Test.p4 = { author: 'Adam', age: 33, id: 8 } + Test.p5 = { author: 'Adam', age: 33, id: 9 } + + Test.requests = [] + + Test.adapter.http = function (config) { + config.headers || (config.headers = {}) + config.headers.Accept = 'application/json, text/plain, */*' + var params = 0 + for (var key in config.params) { + config.params[key] = Test.JSData.utils.isObject(config.params[key]) ? JSON.stringify(config.params[key]) : config.params[key] + params++ + } + return new Promise(function (resolve) { + var url = config.url + if (params) { + url += '?' + url += querystring.stringify(config.params) + } + var request = { + url: url, + method: config.method, + requestBody: JSON.stringify(config.data), + requestHeaders: config.headers, + respond: function (statusCode, headers, body) { + resolve({ + url: config.url, + method: config.method, + status: statusCode, + headers: headers, + data: body && statusCode >= 200 && statusCode < 300 ? JSON.parse(body) : '' + }) + } + } + Test.requests.push(request) + }) + } +}) diff --git a/node/package.json b/node/package.json new file mode 100644 index 0000000..7126302 --- /dev/null +++ b/node/package.json @@ -0,0 +1,31 @@ +{ + "name": "js-data-http-node", + "description": "Node.js HTTP adapter for js-data.", + "version": "3.0.0-beta.3", + "homepage": "https://github.com/js-data/js-data-http", + "repository": { + "type": "git", + "url": "https://github.com/js-data/js-data-http.git" + }, + "author": "js-data-http project authors", + "license": "MIT", + "main": "./dist/js-data-http-node.js", + "files": [ + "dist/" + ], + "keywords": [ + "ajax", + "axios", + "rest", + "adapter", + "http", + "node.js" + ], + "dependencies": { + "js-data-adapter": "~0.3.0" + }, + "peerDependencies": { + "axios": "^0.11.0", + "js-data": "^3.0.0-beta.2" + } +} diff --git a/node/typings.json b/node/typings.json new file mode 100644 index 0000000..a4970e8 --- /dev/null +++ b/node/typings.json @@ -0,0 +1,10 @@ +{ + "name": "js-data-http-node", + "version": false, + "main": "./dist/js-data-http-node.d.ts", + "ambientDependencies": { + "js-data": "npm:js-data", + "js-data-adapter": "npm:js-data-adapter", + "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654" + } +} diff --git a/node/webpack.config.js b/node/webpack.config.js new file mode 100644 index 0000000..9ba2482 --- /dev/null +++ b/node/webpack.config.js @@ -0,0 +1,28 @@ +var path= require('path') + +module.exports = { + devtool: 'source-map', + entry: { + './node/dist/js-data-http-node.js': './src/index.js', + }, + output: { + filename: '[name]', + libraryTarget: 'umd' + }, + externals: [ + 'js-data', + 'axios', + 'chai' + ], + module: { + loaders: [ + { + loader: 'babel-loader', + include: [ + path.resolve(__dirname, '../src') + ], + test: /\.js$/ + } + ] + } +} diff --git a/package.json b/package.json index ef6d050..b60e33a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-http", - "description": "HTTP adapter for js-data.", - "version": "2.2.1", + "description": "HTTP (XHR) adapter for js-data in the browser.", + "version": "3.0.0-beta.3", "homepage": "https://github.com/js-data/js-data-http", "repository": { "type": "git", @@ -10,56 +10,90 @@ "author": "js-data-http project authors", "license": "MIT", "main": "./dist/js-data-http.js", + "typings": "./dist/js-data-http.d.ts", + "files": [ + "dist/", + "src/", + "AUTHORS", + "CONTRIBUTORS", + "typings.json" + ], "keywords": [ "ajax", "axios", "rest", "adapter", - "http" + "http", + "browser", + "xhr" ], "standard": { - "parser": "babel-eslint" + "parser": "babel-eslint", + "globals": [ + "Headers", + "fetch", + "Request", + "action", + "describe", + "it", + "sinon", + "before", + "after", + "beforeEach", + "afterEach" + ] }, "scripts": { - "lint": "standard src/**/*.js", - "bundle": "webpack --config webpack.config.js --colors", + "lint": "repo-tools lint karma.start.js karma.conf.js src/**/*.js test/*.test.js fetch/karma.*.js node/mocha.start.js scripts/*.js", + "doc": "jsdoc -c conf.json src node_modules/js-data-adapter/src && node scripts/cleanup.js", + "version": "repo-tools write-version dist/js-data-http.js fetch/dist/js-data-fetch.js node/dist/js-data-http-node.js", + "webpack": "webpack --config webpack.config.js && webpack --config node/webpack.config.js && webpack --config fetch/webpack.config.js && npm run version", "min": "uglifyjs dist/js-data-http.js -o dist/js-data-http.min.js --source-map dist/js-data-http.min.map --source-map-url js-data-http.min.map -v -m -c --screw-ie8", - "version": "node scripts/version.js", + "min_fetch": "uglifyjs fetch/dist/js-data-fetch.js -o fetch/dist/js-data-fetch.min.js --source-map fetch/dist/js-data-fetch.min.map --source-map-url js-data-fetch.min.map -v -m -c --screw-ie8", "banner": "node scripts/banner.js", - "gzip": "echo gzipped size: $(cat dist/js-data-http.min.js | gzip -f9 | wc -c)kb", - "build": "npm run lint && npm run bundle && npm run min && npm run version && npm run banner", + "gzip": "echo js-data-http gzipped size: $(cat dist/js-data-http.min.js | gzip -f9 | wc -c)kb", + "gzip_fetch": "echo js-data-fetch gzipped size: $(cat fetch/dist/js-data-fetch.min.js | gzip -f9 | wc -c)kb", + "build": "npm run lint && npm run webpack && npm run min && npm run min_fetch && npm run banner", "karma": "karma start", - "test": "npm run build && npm run karma", - "release": "npm test && node scripts/authors.js", - "ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | coveralls || true" + "karma_fetch": "karma start fetch/karma.conf.js", + "mocha": "mocha -t 20000 -R dot -r source-map-support/register node/mocha.start.js test/*.test.js", + "cover": "istanbul cover -x node/dist/js-data-http-node-tests.js --hook-run-in-context node_modules/mocha/bin/_mocha -- -t 20000 -R dot -r source-map-support/register node/mocha.start.js test/*.test.js", + "test": "npm run build && npm run karma && npm run karma_fetch && npm run cover", + "repo-tools": "repo-tools updates && repo-tools changelog && repo-tools authors", + "release": "npm test && npm run doc && npm run repo-tools", + "ci": "npm test && cat ./coverage/lcov.info | codecov" + }, + "dependencies": { + "js-data-adapter": "0.5.0" + }, + "peerDependencies": { + "js-data": "^3.0.0-beta.3" }, "devDependencies": { - "axios": "0.9.1", - "babel-core": "6.7.2", - "babel-eslint": "5.0.0", + "axios": "0.11.0", + "babel-core": "6.7.7", "babel-loader": "6.2.4", + "babel-plugin-syntax-async-functions": "6.5.0", + "babel-plugin-transform-regenerator": "6.6.5", + "babel-polyfill": "6.7.4", "babel-preset-es2015": "6.6.0", + "babel-preset-stage-0": "6.5.0", "chai": "3.5.0", - "coveralls": "2.11.8", - "es6-promise": "3.1.2", + "codecov": "1.0.1", + "istanbul": "0.4.3", + "js-data-repo-tools": "0.3.0", + "jsdoc": "3.4.0", "karma": "0.13.22", - "karma-browserstack-launcher": "0.1.10", + "karma-browserstack-launcher": "0.1.11", "karma-chai": "0.1.0", - "karma-chrome-launcher": "0.2.2", - "karma-coverage": "0.5.3", - "karma-firefox-launcher": "0.1.7", "karma-mocha": "0.2.2", "karma-phantomjs-launcher": "1.0.0", "karma-sinon": "1.0.4", "mocha": "2.4.5", - "mout": "0.12.0", - "phantomjs-prebuilt": "2.1.5", + "phantomjs-prebuilt": "2.1.7", "sinon": "1.17.3", - "standard": "6.0.8", + "source-map-support": "0.4.0", "uglify-js": "2.6.2", - "webpack": "1.12.14" - }, - "dependencies": { - "js-data": ">=2.0.0 <3" + "webpack": "1.13.0" } } diff --git a/scripts/AUTHORS b/scripts/AUTHORS deleted file mode 100644 index fa2423d..0000000 --- a/scripts/AUTHORS +++ /dev/null @@ -1,7 +0,0 @@ -# This is the official list of js-data-http project authors. -# -# This file is controlled by scripts/authors.js -# -# Names are formatted as: -# # commits Name or Organization -# The email address is not required for organizations. diff --git a/scripts/CONTRIBUTORS b/scripts/CONTRIBUTORS deleted file mode 100644 index 429081a..0000000 --- a/scripts/CONTRIBUTORS +++ /dev/null @@ -1,6 +0,0 @@ -# People who have contributed to the js-data-http project. -# -# This file is controlled by scripts/authors.js -# -# Names should be added to this file as: -# [commit count] Name diff --git a/scripts/authors.js b/scripts/authors.js deleted file mode 100644 index 82a856d..0000000 --- a/scripts/authors.js +++ /dev/null @@ -1,45 +0,0 @@ -var fs = require('fs') -var exec = require('child_process').exec - -console.log('Writing AUTHORS file...') - -var authorsFile = fs.readFileSync(__dirname + '/AUTHORS', { - encoding: 'utf-8' -}) -var contributorsFile = fs.readFileSync(__dirname + '/CONTRIBUTORS', { - encoding: 'utf-8' -}) - -var tty = process.platform === 'win32' ? 'CON' : '/dev/tty'; - -exec('git shortlog -s -e < ' + tty, function (err, stdout, stderr) { - if (err) { - console.error(err) - process.exit(-1) - } else { - var lines = stdout.split('\n') - var countsAndNames = lines.map(function (line) { - return line.split('\t') - }) - var names = countsAndNames.map(function (pair) { - return pair[1] - }) - - // Add to or otherwise modify "names" if necessary - - fs.writeFileSync(__dirname + '/../AUTHORS', authorsFile + names.join('\n'), { - encoding: 'utf-8' - }) - console.log('Done!') - console.log('Writing CONTRIBUTORS file...') - - names = lines - - // Add to or otherwise modify "names" if necessary - - fs.writeFileSync(__dirname + '/../CONTRIBUTORS', contributorsFile + names.join('\n'), { - encoding: 'utf-8' - }) - console.log('Done!') - } -}) diff --git a/scripts/banner.js b/scripts/banner.js index a932aca..f2f761b 100644 --- a/scripts/banner.js +++ b/scripts/banner.js @@ -1,30 +1,41 @@ -var fs = require('fs'); -var pkg = require('../package.json'); +var fs = require('fs') +var pkg = require('../package.json') var banner = '/*!\n' + '* js-data-http\n' + - '* @version ' + pkg.version + ' - Homepage \n' + - '* @author Jason Dobry \n' + - '* @copyright (c) 2014-2015 Jason Dobry\n' + + '* @version ' + pkg.version + ' - Homepage \n' + + '* @copyright (c) 2014-2016 js-data-http project authors\n' + '* @license MIT \n' + '*\n' + - '* @overview HTTP adapter for js-data.\n' + - '*/\n'; + '* @overview HTTP (XHR) adapter for js-data in the browser.\n' + + '*/\n' -console.log('Adding banner to dist/ files...'); +console.log('Adding banner to dist/ files...') -function addBanner(filepath) { +function addBanner (filepath) { var contents = fs.readFileSync(filepath, { encoding: 'utf-8' - }); + }) if (contents.substr(0, 3) !== '/*!') { fs.writeFileSync(filepath, banner + contents, { encoding: 'utf-8' - }); + }) } } -addBanner('dist/js-data-http.js'); -addBanner('dist/js-data-http.min.js'); +addBanner('dist/js-data-http.js') +addBanner('dist/js-data-http.min.js') -console.log('Done!'); +banner = '/*!\n' + + '* js-data-fetch\n' + + '* @version ' + pkg.version + ' - Homepage \n' + + '* @copyright (c) 2014-2016 js-data-http project authors\n' + + '* @license MIT \n' + + '*\n' + + '* @overview HTTP adapter for js-data that uses the fetch API.\n' + + '*/\n' + +addBanner('fetch/dist/js-data-fetch.js') +addBanner('fetch/dist/js-data-fetch.min.js') + +console.log('Done!') diff --git a/scripts/cleanup.js b/scripts/cleanup.js new file mode 100644 index 0000000..692ec4e --- /dev/null +++ b/scripts/cleanup.js @@ -0,0 +1,25 @@ +var fs = require('fs') + +var pkg = require('../package.json') + +var path = './doc/js-data-http/' + pkg.version + '/styles/' + +var files = fs.readdirSync(path) +files.forEach(function (file) { + if (file.indexOf('site') === 0) { + if (file.indexOf('lumen') === -1 && file.indexOf('dibs') === -1) { + fs.unlinkSync(path + file) + } + } +}) + +path = './doc/js-data-http/' + pkg.version + +files = fs.readdirSync(path) +files.forEach(function (file) { + if (file.indexOf('.html') === file.length - 5) { + var content = fs.readFileSync(path + '/' + file, { encoding: 'utf8' }) + content = content.replace(/\/home\/ubuntu\/workspace\//gi, '') + fs.writeFileSync(path + '/' + file, content, { encoding: 'utf8' }) + } +}) diff --git a/scripts/version.js b/scripts/version.js deleted file mode 100644 index 8e11b36..0000000 --- a/scripts/version.js +++ /dev/null @@ -1,41 +0,0 @@ -var fs = require('fs'); -var pkg = require('../package.json'); - -console.log('Adding version to dist/ files...'); - -function version(filepath) { - var file = fs.readFileSync(filepath, { - encoding: 'utf-8' - }); - - file = file.replace(/<%= pkg\.version %>/gi, pkg.version); - - var parts = pkg.version.split('-'); - var numbers = parts[0].split('.'); - - file = file.replace(/<%= major %>/gi, numbers[0]); - file = file.replace(/<%= minor %>/gi, numbers[1]); - file = file.replace(/<%= patch %>/gi, numbers[2]); - - if (pkg.version.indexOf('alpha') !== -1) { - file = file.replace(/<%= alpha %>/gi, parts[1].replace('alpha.', '') + (parts.length > 2 ? '-' + parts[2] : '')); - } - else { - file = file.replace(/<%= alpha %>/gi, false); - } - - if (pkg.version.indexOf('beta') !== -1) { - file = file.replace(/<%= beta %>/gi, parts[1].replace('beta.', '') + (parts.length > 2 ? '-' + parts[2] : '')); - } - else { - file = file.replace(/<%= beta %>/gi, false); - } - - fs.writeFileSync(filepath, file, { - encoding: 'utf-8' - }); -} - -version('dist/js-data-http.js'); - -console.log('Done!'); diff --git a/src/index.js b/src/index.js index bacc63d..1950856 100644 --- a/src/index.js +++ b/src/index.js @@ -1,333 +1,1256 @@ -let JSData = require('js-data') -let axios = null +/* global fetch:true Headers:true Request:true */ + +/** + * Registered as `js-data-http` in NPM and Bower. The build of `js-data-http` + * that works on Node.js is registered in NPM as `js-data-http-node`. The build + * of `js-data-http` that does not bundle `axios` is registered in NPM and Bower + * as `js-data-fetch`. + * + * __Script tag__: + * ```javascript + * window.HttpAdapter + * ``` + * __CommonJS__: + * ```javascript + * var HttpAdapter = require('js-data-http') + * ``` + * __ES6 Modules__: + * ```javascript + * import HttpAdapter from 'js-data-http' + * ``` + * __AMD__: + * ```javascript + * define('myApp', ['js-data-http'], function (HttpAdapter) { ... }) + * ``` + * + * @module js-data-http + */ + +const axios = require('axios') +import {utils} from 'js-data' +import { + Adapter, + noop, + noop2 +} from 'js-data-adapter' + +let hasFetch = false try { - axios = require('axios') + hasFetch = window && window.fetch } catch (e) {} -let { DSUtils } = JSData -let { deepMixIn, removeCircular, copy, makePath, isString, isNumber } = DSUtils +function isValidString (value) { + return (value != null && value !== '') +} +function join (items, separator) { + separator || (separator = '') + return items.filter(isValidString).join(separator) +} +function makePath (...args) { + let result = join(args, '/') + return result.replace(/([^:\/]|^)\/{2,}/g, '$1/') +} -class Defaults { - queryTransform (resourceConfig, params) { - return params - } +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, ']') +} - deserialize (resourceConfig, data) { - return data ? ('data' in data ? data.data : data) : data +function buildUrl (url, params) { + if (!params) { + return url } - serialize (resourceConfig, data) { - return data + const parts = [] + + utils.forOwn(params, function (val, key) { + if (val === null || typeof val === 'undefined') { + return + } + if (!utils.isArray(val)) { + val = [val] + } + + val.forEach(function (v) { + if (window.toString.call(v) === '[object Date]') { + v = v.toISOString() + } else if (utils.isObject(v)) { + v = utils.toJson(v) + } + parts.push(`${encode(key)}=${encode(v)}`) + }) + }) + + if (parts.length > 0) { + url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&') } - log () {} + return url +} + +const __super__ = Adapter.prototype - error () {} +const DEFAULTS = { + // Default and user-defined settings + /** + * @name HttpAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * @name HttpAdapter#forceTrailingSlash + * @type {boolean} + * @default false + */ + forceTrailingSlash: false, + + /** + * @name HttpAdapter#http + * @type {Function} + */ + http: axios, + + /** + * @name HttpAdapter#httpConfig + * @type {Object} + */ + httpConfig: {}, + + /** + * @name HttpAdapter#suffix + * @type {string} + */ + suffix: '', + + /** + * @name HttpAdapter#useFetch + * @type {boolean} + * @default false + */ + useFetch: false } -let defaultsPrototype = Defaults.prototype +/** + * HttpAdapter class. + * + * @class HttpAdapter + * @extends Adapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.basePath=''] TODO + * @param {boolean} [opts.debug=false] TODO + * @param {boolean} [opts.forceTrailingSlash=false] TODO + * @param {Object} [opts.http=axios] TODO + * @param {Object} [opts.httpConfig={}] TODO + * @param {string} [opts.suffix=''] TODO + * @param {boolean} [opts.useFetch=false] TODO + */ +function HttpAdapter (opts) { + const self = this + opts || (opts = {}) + utils.fillIn(opts, DEFAULTS) + Adapter.call(self, opts) +} + +/** + * @name module:js-data-http.HttpAdapter + * @see HttpAdapter + */ +exports.HttpAdapter = HttpAdapter -defaultsPrototype.basePath = '' +// Setup prototype inheritance from Adapter +HttpAdapter.prototype = Object.create(Adapter.prototype, { + constructor: { + value: HttpAdapter, + enumerable: false, + writable: true, + configurable: true + } +}) -defaultsPrototype.forceTrailingSlash = '' +Object.defineProperty(HttpAdapter, '__super__', { + configurable: true, + value: Adapter +}) -defaultsPrototype.httpConfig = {} +/** + * Alternative to ES6 class syntax for extending `HttpAdapter`. + * + * __ES6__: + * ```javascript + * class MyHttpAdapter extends HttpAdapter { + * deserialize (Model, data, opts) { + * const data = super.deserialize(Model, data, opts) + * data.foo = 'bar' + * return data + * } + * } + * ``` + * + * __ES5__: + * ```javascript + * var instanceProps = { + * // override deserialize + * deserialize: function (Model, data, opts) { + * var Ctor = this.constructor + * var superDeserialize = (Ctor.__super__ || Object.getPrototypeOf(Ctor)).deserialize + * // call the super deserialize + * var data = superDeserialize(Model, data, opts) + * data.foo = 'bar' + * return data + * }, + * say: function () { return 'hi' } + * } + * var classProps = { + * yell: function () { return 'HI' } + * } + * + * var MyHttpAdapter = HttpAdapter.extend(instanceProps, classProps) + * var adapter = new MyHttpAdapter() + * adapter.say() // "hi" + * MyHttpAdapter.yell() // "HI" + * ``` + * + * @name HttpAdapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `HttpAdapter`. + */ +HttpAdapter.extend = utils.extend -defaultsPrototype.verbsUseBasePath = false +utils.addHiddenPropsToTarget(HttpAdapter.prototype, { + /** + * @name HttpAdapter#afterDEL + * @method + * @param {string} url + * @param {Object} config + * @param {Object} opts + * @param {Object} response + */ + afterDEL: noop2, -class DSHttpAdapter { - constructor (options) { - options = options || {} - this.defaults = new Defaults() - if (console) { - this.defaults.log = (a, b) => console[typeof console.info === 'function' ? 'info' : 'log'](a, b) + /** + * @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 (mapper, query, opts) { + const self = this + return self.GET( + self.getPath('count', mapper, opts.params, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _create (mapper, props, opts) { + const self = this + return self.POST( + self.getPath('create', mapper, props, opts), + self.serialize(mapper, props, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _createMany (mapper, props, opts) { + const self = this + return self.POST( + self.getPath('createMany', mapper, null, opts), + self.serialize(mapper, props, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _destroy (mapper, id, opts) { + const self = this + return self.DEL( + self.getPath('destroy', mapper, id, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _destroyAll (mapper, query, opts) { + const self = this + return self.DEL( + self.getPath('destroyAll', mapper, null, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _end (mapper, opts, response) { + return [this.deserialize(mapper, response, opts), response] + }, + + _find (mapper, id, opts) { + const self = this + return self.GET( + self.getPath('find', mapper, id, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _findAll (mapper, query, opts) { + const self = this + return self.GET( + self.getPath('findAll', mapper, opts.params, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _sum (mapper, field, query, opts) { + const self = this + return self.GET( + self.getPath('sum', mapper, opts.params, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _update (mapper, id, props, opts) { + const self = this + return self.PUT( + self.getPath('update', mapper, id, opts), + self.serialize(mapper, props, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _updateAll (mapper, props, query, opts) { + const self = this + return self.PUT( + self.getPath('updateAll', mapper, null, opts), + self.serialize(mapper, props, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + _updateMany (mapper, records, opts) { + const self = this + return self.PUT( + self.getPath('updateMany', mapper, null, opts), + self.serialize(mapper, records, opts), + opts + ).then(function (response) { + return self._end(mapper, opts, response) + }) + }, + + /** + * Retrieve the number of records that match the selection `query`. + * + * @name HttpAdapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + count (mapper, query, opts) { + const self = this + query || (query = {}) + opts || (opts = {}) + opts.params = self.getParams(opts) + opts.params.count = true + opts.suffix = self.getSuffix(mapper, opts) + utils.deepMixIn(opts.params, query) + opts.params = self.queryTransform(mapper, opts.params, opts) + + return __super__.count.call(self, mapper, query, opts) + }, + + /** + * Create a new the record from the provided `props`. + * + * @name HttpAdapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props Properties to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + create (mapper, props, opts) { + const self = this + opts || (opts = {}) + opts.params = self.getParams(opts) + opts.params = self.queryTransform(mapper, opts.params, opts) + opts.suffix = self.getSuffix(mapper, opts) + + return __super__.create.call(self, mapper, props, opts) + }, + + /** + * Create multiple new records in batch. + * + * @name HttpAdapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} props Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + createMany (mapper, props, opts) { + const self = this + opts || (opts = {}) + opts.params = self.getParams(opts) + opts.params = self.queryTransform(mapper, opts.params, opts) + opts.suffix = self.getSuffix(mapper, opts) + + return __super__.createMany.call(self, mapper, props, opts) + }, + + /** + * Make an Http request to `url` according to the configuration in `config`. + * + * @name HttpAdapter#DEL + * @method + * @param {string} url Url for the request. + * @param {Object} [config] Http configuration that will be passed to + * {@link HttpAdapter#HTTP}. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + DEL (url, config, opts) { + const self = this + let op + config || (config = {}) + opts || (opts = {}) + config.url = url || config.url + config.method = config.method || 'delete' + + // beforeDEL lifecycle hook + op = opts.op = 'beforeDEL' + return utils.resolve(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = utils.isUndefined(_config) ? config : _config + op = opts.op = 'DEL' + self.dbg(op, url, config, opts) + return self.HTTP(config, opts) + }).then(function (response) { + // afterDEL lifecycle hook + op = opts.op = 'afterDEL' + return utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return utils.isUndefined(_response) ? response : _response + }) + }) + }, + + /** + * Transform the server response object into the payload that will be returned + * to JSData. + * + * @name HttpAdapter#deserialize + * @method + * @param {Object} mapper The mapper used for the operation. + * @param {Object} response Response object from {@link HttpAdapter#HTTP}. + * @param {Object} opts Configuration options. + * @return {(Object|Array)} Deserialized data. + */ + deserialize (mapper, response, opts) { + opts || (opts = {}) + if (utils.isFunction(opts.deserialize)) { + return opts.deserialize(mapper, response, opts) + } + if (utils.isFunction(mapper.deserialize)) { + return mapper.deserialize(mapper, response, opts) } + if (response && response.hasOwnProperty('data')) { + return response.data + } + return response + }, + + /** + * Destroy the record with the given primary key. + * + * @name HttpAdapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroy (mapper, id, opts) { + const self = this + opts || (opts = {}) + opts.params = self.getParams(opts) + opts.params = self.queryTransform(mapper, opts.params, opts) + opts.suffix = self.getSuffix(mapper, opts) + + return __super__.destroy.call(self, mapper, id, opts) + }, + + /** + * Destroy the records that match the selection `query`. + * + * @name HttpAdapter#destroyAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + destroyAll (mapper, query, opts) { + const self = this + query || (query = {}) + opts || (opts = {}) + opts.params = self.getParams(opts) + utils.deepMixIn(opts.params, query) + opts.params = self.queryTransform(mapper, opts.params, opts) + opts.suffix = self.getSuffix(mapper, opts) + + return __super__.destroyAll.call(self, mapper, query, opts) + }, + + /** + * Log an error. + * + * @name HttpAdapter#error + * @method + * @param {...*} [args] Arguments to log. + */ + error (...args) { if (console) { - this.defaults.error = (a, b) => console[typeof console.error === 'function' ? 'error' : 'log'](a, b) + console[typeof console.error === 'function' ? 'error' : 'log'](...args) } - deepMixIn(this.defaults, options) - this.http = options.http || axios - } + }, - getEndpoint (resourceConfig, id, options) { - options = options || {} - options.params = options.params || {} + /** + * Make an Http request using `window.fetch`. + * + * @name HttpAdapter#fetch + * @method + * @param {Object} config Request configuration. + * @param {Object} config.data Payload for the request. + * @param {string} config.method Http method for the request. + * @param {Object} config.headers Headers for the request. + * @param {Object} config.params Querystring for the request. + * @param {string} config.url Url for the request. + * @param {Object} [opts] Configuration options. + */ + fetch (config, opts) { + const requestConfig = { + method: config.method, + // turn the plain headers object into the Fetch Headers object + headers: new Headers(config.headers) + } + + if (config.data) { + requestConfig.body = utils.toJson(config.data) + } - let endpoint = options.hasOwnProperty('endpoint') ? options.endpoint : resourceConfig.endpoint - let parents = resourceConfig.parents || (resourceConfig.parent ? { - [resourceConfig.parent]: { - key: resourceConfig.parentKey, - field: resourceConfig.parentField + return fetch(new Request(buildUrl(config.url, config.params), requestConfig)).then(function (response) { + response.config = { + method: config.method, + url: config.url } - } : {}) + return response.json().then(function (data) { + response.data = data + return response + }) + }) + }, + + /** + * Retrieve the record with the given primary key. + * + * @name HttpAdapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + find (mapper, id, opts) { + const self = this + opts || (opts = {}) + opts.params = self.getParams(opts) + opts.params = self.queryTransform(mapper, opts.params, opts) + opts.suffix = self.getSuffix(mapper, opts) - DSUtils.forOwn(parents, function (parent, parentName) { + return __super__.find.call(self, mapper, id, opts) + }, + + /** + * Retrieve the records that match the selection `query`. + * + * @name HttpAdapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + findAll (mapper, query, opts) { + const self = this + query || (query = {}) + opts || (opts = {}) + opts.params = self.getParams(opts) + opts.suffix = self.getSuffix(mapper, opts) + utils.deepMixIn(opts.params, query) + opts.params = self.queryTransform(mapper, opts.params, opts) + + return __super__.findAll.call(self, mapper, query, opts) + }, + + /** + * TODO + * + * @name HttpAdapter#GET + * @method + * @param {string} url The url for the request. + * @param {Object} config Request configuration options. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + GET (url, config, opts) { + const self = this + let op + config || (config = {}) + opts || (opts = {}) + config.url = url || config.url + config.method = config.method || 'get' + + // beforeGET lifecycle hook + op = opts.op = 'beforeGET' + return utils.resolve(self[op](url, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = utils.isUndefined(_config) ? config : _config + op = opts.op = 'GET' + self.dbg(op, url, config, opts) + return self.HTTP(config, opts) + }).then(function (response) { + // afterGET lifecycle hook + op = opts.op = 'afterGET' + return utils.resolve(self[op](url, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return utils.isUndefined(_response) ? response : _response + }) + }) + }, + + /** + * @name HttpAdapter#getEndpoint + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {boolean} opts TODO + * @return {string} Full path. + */ + getEndpoint (mapper, id, opts) { + const self = this + opts || (opts = {}) + opts.params = utils.isUndefined(opts.params) ? {} : opts.params + const relationList = mapper.relationList || [] + let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint + + relationList.forEach(function (def) { + if (def.type !== 'belongsTo' || !def.parent) { + return + } let item - let parentKey = parent.key - let parentField = parent.field - let parentDef = resourceConfig.getResource(parentName) - let parentId = options.params[parentKey] + const parentKey = def.foreignKey + const parentDef = def.getRelation() + let parentId = opts.params[parentKey] if (parentId === false || !parentKey || !parentDef) { if (parentId === false) { - delete options.params[parentKey] + delete opts.params[parentKey] } + return false } else { - delete options.params[parentKey] + delete opts.params[parentKey] - if (DSUtils._sn(id)) { - item = resourceConfig.get(id) - } else if (DSUtils._o(id)) { + if (utils.isObject(id)) { item = id } - console.log('item', item) if (item) { - parentId = parentId || item[parentKey] || (item[parentField] ? item[parentField][parentDef.idAttribute] : null) + parentId = parentId || def.getForeignKey(item) || (def.getLocalField(item) ? utils.get(def.getLocalField(item), parentDef.idAttribute) : null) } if (parentId) { - delete options.endpoint - let _options = {} - DSUtils.forOwn(options, (value, key) => { - _options[key] = value + delete opts.endpoint + const _opts = {} + utils.forOwn(opts, function (value, key) { + _opts[key] = value }) - endpoint = DSUtils.makePath(this.getEndpoint(parentDef, parentId, DSUtils._(parentDef, _options)), parentId, endpoint) + utils._(_opts, parentDef) + endpoint = makePath(self.getEndpoint(parentDef, parentId, _opts), parentId, endpoint) + return false } } - }, this) + }) return endpoint - } + }, - getPath (method, resourceConfig, id, options) { - let _this = this - options = options || {} - if (isString(options.urlPath)) { - return makePath.apply(DSUtils, [options.basePath || _this.defaults.basePath || resourceConfig.basePath, options.urlPath]) - } else { - let args = [ - options.basePath || _this.defaults.basePath || resourceConfig.basePath, - this.getEndpoint(resourceConfig, (isString(id) || isNumber(id) || method === 'create') ? id : null, options) - ] - if (method === 'find' || method === 'update' || method === 'destroy') { - args.push(id) - } - return makePath.apply(DSUtils, args) + /** + * @name HttpAdapter#getPath + * @method + * @param {string} method TODO + * @param {Object} mapper TODO + * @param {(string|number)?} id TODO + * @param {Object} opts Configuration options. + */ + getPath (method, mapper, id, opts) { + const self = this + opts || (opts = {}) + const args = [ + utils.isUndefined(opts.basePath) ? (utils.isUndefined(mapper.basePath) ? self.basePath : mapper.basePath) : opts.basePath, + self.getEndpoint(mapper, (utils.isString(id) || utils.isNumber(id) || method === 'create') ? id : null, opts) + ] + if (method === 'find' || method === 'update' || method === 'destroy') { + args.push(id) } - } + return makePath.apply(utils, args) + }, - HTTP (config) { - let _this = this - let start = new Date() + getParams (opts) { + opts || (opts = {}) + if (utils.isUndefined(opts.params)) { + return {} + } + return utils.copy(opts.params) + }, - // blacklist `data` as it can be large and will take a lot of time to copy - let payload = config.data - let cache = config.cache - let timeout = config.timeout - config = copy(config, null, null, null, ['data', 'cache', 'timeout']) - config = deepMixIn(config, _this.defaults.httpConfig) + getSuffix (mapper, opts) { + opts || (opts = {}) + if (utils.isUndefined(opts.suffix)) { + if (utils.isUndefined(mapper.suffix)) { + return this.suffix + } + return mapper.suffix + } + return opts.suffix + }, + + /** + * Make an Http request. + * + * @name HttpAdapter#HTTP + * @method + * @param {Object} config Request configuration options. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + HTTP (config, opts) { + const self = this + const start = new Date() + opts || (opts = {}) + const payload = config.data + const cache = config.cache + const timeout = config.timeout + config = utils.copy(config, null, null, null, ['data', 'cache', 'timeout']) + config = utils.deepMixIn(config, self.httpConfig) config.data = payload config.cache = cache config.timeout = timeout - if (!('verbsUseBasePath' in config)) { - config.verbsUseBasePath = _this.defaults.verbsUseBasePath - } - if (!config.urlOverride && config.verbsUseBasePath) { - config.url = makePath(config.basePath || _this.defaults.basePath, config.url) - } - if (_this.defaults.forceTrailingSlash && config.url[config.url.length - 1] !== '/' && !config.urlOverride) { + if (self.forceTrailingSlash && config.url[config.url.length - 1] !== '/') { config.url += '/' } - if (typeof config.data === 'object') { - config.data = removeCircular(config.data) - } config.method = config.method.toUpperCase() - let suffix = config.suffix || _this.defaults.suffix - if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix && !config.urlOverride) { + const suffix = config.suffix || opts.suffix || self.suffix + if (suffix && config.url.substr(config.url.length - suffix.length) !== suffix) { config.url += suffix } - // logs the HTTP response - function logResponse (data, isRejection) { - data = data || {} - // examine the data object - if (data instanceof Error) { - // log the Error object - _this.defaults.error(`FAILED: ${data.message || 'Unknown Error'}`, data) - return DSUtils.Promise.reject(data) - } else if (typeof data === 'object') { - let str = `${start.toUTCString()} - ${config.method} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms` - - if (data.status >= 200 && data.status < 300 && !isRejection) { - if (_this.defaults.log) { - _this.defaults.log(str, data) - } - return data - } else { - if (_this.defaults.error) { - _this.defaults.error(`FAILED: ${str}`, data) - } - return DSUtils.Promise.reject(data) + function logResponse (data) { + const str = `${start.toUTCString()} - ${config.method.toUpperCase()} ${config.url} - ${data.status} ${(new Date().getTime() - start.getTime())}ms` + if (data.status >= 200 && data.status < 300) { + if (self.log) { + self.dbg('debug', str, data) } + return data } else { - // unknown type for 'data' that is not an Object or Error - _this.defaults.error('FAILED', data) - return DSUtils.Promise.reject(data) + if (self.error) { + self.error(`'FAILED: ${str}`, data) + } + return utils.reject(data) } } - if (!this.http) { + if (!self.http) { throw new Error('You have not configured this adapter with an http library!') } - return this.http(config).then(logResponse, function (data) { - return logResponse(data, true) + return utils.resolve(self.beforeHTTP(config, opts)).then(function (_config) { + config = _config || config + if (hasFetch && (self.useFetch || opts.useFetch || !self.http)) { + return self.fetch(config, opts).then(logResponse, logResponse) + } + return self.http(config).then(logResponse, logResponse).catch(function (err) { + return self.responseError(err, config, opts) + }) + }).then(function (response) { + return utils.resolve(self.afterHTTP(config, opts, response)).then(function (_response) { + return _response || response + }) }) - } + }, - GET (url, config) { - config = config || {} - config.method = config.method || 'get' - config.urlOverride = !!config.url - config.url = config.url || url - return this.HTTP(config) - } - - POST (url, attrs, config) { - config = config || {} + /** + * TODO + * + * @name HttpAdapter#POST + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + POST (url, data, config, opts) { + const self = this + let op + config || (config = {}) + opts || (opts = {}) + config.url = url || config.url + config.data = data || config.data config.method = config.method || 'post' - config.urlOverride = !!config.url - config.url = config.url || url - config.data = config.data || attrs - return this.HTTP(config) - } - PUT (url, attrs, config) { - config = config || {} - config.method = config.method || 'put' - config.urlOverride = !!config.url - config.url = config.url || url - config.data = config.data || attrs - return this.HTTP(config) - } + // beforePOST lifecycle hook + op = opts.op = 'beforePOST' + return utils.resolve(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = utils.isUndefined(_config) ? config : _config + op = opts.op = 'POST' + self.dbg(op, url, data, config, opts) + return self.HTTP(config, opts) + }).then(function (response) { + // afterPOST lifecycle hook + op = opts.op = 'afterPOST' + return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return utils.isUndefined(_response) ? response : _response + }) + }) + }, - DEL (url, config) { - config = config || {} - config.method = config.method || 'delete' - config.urlOverride = !!config.url - config.url = config.url || url - return this.HTTP(config) - } + /** + * TODO + * + * @name HttpAdapter#PUT + * @method + * @param {*} url TODO + * @param {Object} data TODO + * @param {Object} config TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + PUT (url, data, config, opts) { + const self = this + let op + config || (config = {}) + opts || (opts = {}) + config.url = url || config.url + config.data = data || config.data + config.method = config.method || 'put' - find (resourceConfig, id, options) { - let _this = this - options = options ? copy(options) : {} - options.suffix = options.suffix || resourceConfig.suffix - options.params = options.params || {} - options.params = _this.defaults.queryTransform(resourceConfig, options.params) - return _this.GET( - _this.getPath('find', resourceConfig, id, options), - options - ).then((data) => { - let item = (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data) - return !item ? DSUtils.Promise.reject(new Error('Not Found!')) : item + // beforePUT lifecycle hook + op = opts.op = 'beforePUT' + return utils.resolve(self[op](url, data, config, opts)).then(function (_config) { + // Allow re-assignment from lifecycle hook + config = utils.isUndefined(_config) ? config : _config + op = opts.op = 'PUT' + self.dbg(op, url, data, config, opts) + return self.HTTP(config, opts) + }).then(function (response) { + // afterPUT lifecycle hook + op = opts.op = 'afterPUT' + return utils.resolve(self[op](url, data, config, opts, response)).then(function (_response) { + // Allow re-assignment from lifecycle hook + return utils.isUndefined(_response) ? response : _response + }) }) - } + }, - findAll (resourceConfig, params, options) { - let _this = this - options = options ? copy(options) : {} - options.suffix = options.suffix || resourceConfig.suffix - options.params = options.params || {} - if (params) { - params = _this.defaults.queryTransform(resourceConfig, params) - deepMixIn(options.params, params) + /** + * TODO + * + * @name HttpAdapter#queryTransform + * @method + * @param {Object} mapper TODO + * @param {*} params TODO + * @param {*} opts TODO + * @return {*} Transformed params. + */ + queryTransform (mapper, params, opts) { + opts || (opts = {}) + if (utils.isFunction(opts.queryTransform)) { + return opts.queryTransform(mapper, params, opts) } - return _this.GET( - _this.getPath('findAll', resourceConfig, params, options), - options - ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data)) - } + if (utils.isFunction(mapper.queryTransform)) { + return mapper.queryTransform(mapper, params, opts) + } + return params + }, - create (resourceConfig, attrs, options) { - let _this = this - options = options ? copy(options) : {} - options.suffix = options.suffix || resourceConfig.suffix - options.params = options.params || {} - options.params = _this.defaults.queryTransform(resourceConfig, options.params) - return _this.POST( - _this.getPath('create', resourceConfig, attrs, options), - options.serialize ? options.serialize(resourceConfig, attrs) : _this.defaults.serialize(resourceConfig, attrs), - options - ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data)) - } + /** + * 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 (err, config, opts) { + return utils.reject(err) + }, - update (resourceConfig, id, attrs, options) { - let _this = this - options = options ? copy(options) : {} - options.suffix = options.suffix || resourceConfig.suffix - options.params = options.params || {} - options.params = _this.defaults.queryTransform(resourceConfig, options.params) - return _this.PUT( - _this.getPath('update', resourceConfig, id, options), - options.serialize ? options.serialize(resourceConfig, attrs) : _this.defaults.serialize(resourceConfig, attrs), - options - ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data)) - } + /** + * TODO + * + * @name HttpAdapter#serialize + * @method + * @param {Object} mapper TODO + * @param {Object} data TODO + * @param {*} opts TODO + * @return {*} Serialized data. + */ + serialize (mapper, data, opts) { + opts || (opts = {}) + if (utils.isFunction(opts.serialize)) { + return opts.serialize(mapper, data, opts) + } + if (utils.isFunction(mapper.serialize)) { + return mapper.serialize(mapper, data, opts) + } + return data + }, - updateAll (resourceConfig, attrs, params, options) { - let _this = this - options = options ? copy(options) : {} - options.suffix = options.suffix || resourceConfig.suffix - options.params = options.params || {} - if (params) { - params = _this.defaults.queryTransform(resourceConfig, params) - deepMixIn(options.params, params) + /** + * Retrieve the sum of the field of the records that match the selection query. + * + * @name HttpAdapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field The field to sum. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + sum (mapper, field, query, opts) { + const self = this + query || (query = {}) + opts || (opts = {}) + if (!utils.utils.isString(field)) { + throw new Error('field must be a string!') } - return this.PUT( - _this.getPath('updateAll', resourceConfig, attrs, options), - options.serialize ? options.serialize(resourceConfig, attrs) : _this.defaults.serialize(resourceConfig, attrs), - options - ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data)) - } + opts.params = self.getParams(opts) + opts.params.sum = field + opts.suffix = self.getSuffix(mapper, opts) + utils.deepMixIn(opts.params, query) + opts.params = self.queryTransform(mapper, opts.params, opts) + + return __super__.sum.call(self, mapper, field, query, opts) + }, + + /** + * TODO + * + * @name HttpAdapter#update + * @method + * @param {Object} mapper TODO + * @param {*} id TODO + * @param {*} props TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + update (mapper, id, props, opts) { + const self = this + opts || (opts = {}) + opts.params = self.getParams(opts) + opts.params = self.queryTransform(mapper, opts.params, opts) + opts.suffix = self.getSuffix(mapper, opts) + + return __super__.update.call(self, mapper, id, props, opts) + }, + + /** + * TODO + * + * @name HttpAdapter#updateAll + * @method + * @param {Object} mapper TODO + * @param {Object} props TODO + * @param {Object} query TODO + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + updateAll (mapper, props, query, opts) { + const self = this + query || (query = {}) + opts || (opts = {}) + opts.params = self.getParams(opts) + utils.deepMixIn(opts.params, query) + opts.params = self.queryTransform(mapper, opts.params, opts) + opts.suffix = self.getSuffix(mapper, opts) - destroy (resourceConfig, id, options) { - let _this = this - options = options ? copy(options) : {} - options.suffix = options.suffix || resourceConfig.suffix - options.params = options.params || {} - options.params = _this.defaults.queryTransform(resourceConfig, options.params) - return _this.DEL( - _this.getPath('destroy', resourceConfig, id, options), - options - ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data)) + return __super__.updateAll.call(self, mapper, props, query, opts) + }, + + /** + * Update multiple records in batch. + * + * {@link HttpAdapter#beforeUpdateMany} will be called before calling + * {@link HttpAdapter#PUT}. + * {@link HttpAdapter#afterUpdateMany} will be called after calling + * {@link HttpAdapter#PUT}. + * + * @name HttpAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} records Array of property objects to send as the payload. + * @param {Object} [opts] Configuration options. + * @param {string} [opts.params] TODO + * @param {string} [opts.suffix={@link HttpAdapter#suffix}] TODO + * @return {Promise} + */ + updateMany (mapper, records, opts) { + const self = this + opts || (opts = {}) + opts.params = self.getParams(opts) + opts.params = self.queryTransform(mapper, opts.params, opts) + opts.suffix = self.getSuffix(mapper, opts) + + return __super__.updateMany.call(self, mapper, records, opts) } +}) - destroyAll (resourceConfig, params, options) { - let _this = this - options = options ? copy(options) : {} - options.suffix = options.suffix || resourceConfig.suffix - options.params = options.params || {} - if (params) { - params = _this.defaults.queryTransform(resourceConfig, params) - deepMixIn(options.params, params) +/** + * Add an Http actions to a mapper. + * + * @name module:js-data-http.addAction + * @method + * @param {string} name Name of the new action. + * @param {Object} [opts] Action configuration + * @param {string} [opts.adapter] + * @param {string} [opts.pathname] + * @param {Function} [opts.request] + * @param {Function} [opts.response] + * @param {Function} [opts.responseError] + * @return {Function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +exports.addAction = function addAction (name, opts) { + if (!name || !utils.isString(name)) { + throw new TypeError('action(name[, opts]): Expected: string, Found: ' + 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 utils.reject(err) } + mapper[name] = function (id, _opts) { + const self = this + if (utils.isObject(id)) { + _opts = id + } + _opts = _opts || {} + let adapter = self.getAdapter(opts.adapter || self.defaultAdapter || 'http') + let config = {} + utils.fillIn(config, opts) + if (!_opts.hasOwnProperty('endpoint') && config.endpoint) { + _opts.endpoint = config.endpoint + } + if (typeof _opts.getEndpoint === 'function') { + config.url = _opts.getEndpoint(self, _opts) + } else { + let args = [ + _opts.basePath || self.basePath || adapter.basePath, + adapter.getEndpoint(self, utils.isSorN(id) ? id : null, _opts) + ] + if (utils.isSorN(id)) { + args.push(id) + } + args.push(opts.pathname || name) + config.url = makePath.apply(null, args) + } + config.method = config.method || 'GET' + config.mapper = self.name + utils.deepMixIn(config)(_opts) + return utils.resolve(config) + .then(_opts.request || opts.request) + .then(function (config) { return adapter.HTTP(config) }) + .then(function (data) { + if (data && data.config) { + data.config.mapper = self.name + } + return data + }) + .then(_opts.response || opts.response, _opts.responseError || opts.responseError) } - return this.DEL( - _this.getPath('destroyAll', resourceConfig, params, options), - options - ).then((data) => (options.deserialize ? options.deserialize : _this.defaults.deserialize)(resourceConfig, data)) + return mapper } } -DSHttpAdapter.version = { - full: '<%= pkg.version %>', - major: parseInt('<%= major %>', 10), - minor: parseInt('<%= minor %>', 10), - patch: parseInt('<%= patch %>', 10), - alpha: '<%= alpha %>' !== 'false' ? '<%= alpha %>' : false, - beta: '<%= beta %>' !== 'false' ? '<%= beta %>' : false +/** + * Add multiple Http actions to a mapper. See {@link HttpAdapter.addAction} for + * action configuration options. + * + * @name module:js-data-http.addActions + * @method + * @param {Object.} opts Object where the key is an action name + * and the value is the configuration for the action. + * @return {Function} Decoration function, which should be passed the mapper to + * decorate when invoked. + */ +exports.addActions = function addActions (opts) { + opts || (opts = {}) + return function (mapper) { + utils.forOwn(mapper, function (value, key) { + exports.addAction(key, value)(mapper) + }) + return mapper + } } -module.exports = DSHttpAdapter +/** + * Details of the current version of the `js-data-http` module. + * + * @name module:js-data-http.version + * @type {Object} + * @property {string} version.full The full semver value. + * @property {number} version.major The major version number. + * @property {number} version.minor The minor version number. + * @property {number} version.patch The patch version number. + * @property {(string|boolean)} version.alpha The alpha version value, + * otherwise `false` if the current version is not alpha. + * @property {(string|boolean)} version.beta The beta version value, + * otherwise `false` if the current version is not beta. + */ +exports.version = '<%= version %>' diff --git a/test/DEL.test.js b/test/DEL.test.js new file mode 100644 index 0000000..047dcd6 --- /dev/null +++ b/test/DEL.test.js @@ -0,0 +1,3 @@ +describe('DEL', function () { + it('should DEL') +}) diff --git a/test/GET.test.js b/test/GET.test.js new file mode 100644 index 0000000..adf478e --- /dev/null +++ b/test/GET.test.js @@ -0,0 +1,3 @@ +describe('GET', function () { + it('should GET') +}) diff --git a/test/HTTP.test.js b/test/HTTP.test.js new file mode 100644 index 0000000..199bf95 --- /dev/null +++ b/test/HTTP.test.js @@ -0,0 +1,3 @@ +describe('HTTP', function () { + it('should HTTP') +}) diff --git a/test/POST.test.js b/test/POST.test.js new file mode 100644 index 0000000..3170500 --- /dev/null +++ b/test/POST.test.js @@ -0,0 +1,3 @@ +describe('POST', function () { + it('should POST') +}) diff --git a/test/PUT.test.js b/test/PUT.test.js new file mode 100644 index 0000000..e62a1a3 --- /dev/null +++ b/test/PUT.test.js @@ -0,0 +1,3 @@ +describe('PUT', function () { + it('should PUT') +}) diff --git a/test/create.spec.js b/test/create.spec.js deleted file mode 100644 index 992d09f..0000000 --- a/test/create.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('DSHttpAdapter.create(resourceConfig, attrs, options)', function () { - - it('should make a POST request', function () { - var _this = this; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/posts'); - assert.equal(_this.requests[0].method, 'POST'); - assert.equal(_this.requests[0].requestBody, DSUtils.toJson({ author: 'John', age: 30 })); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, DSUtils.toJson(p1)); - }, 30); - - return dsHttpAdapter.create(Post, { author: 'John', age: 30 }).then(function (data) { - assert.deepEqual(data, p1, 'post should have been created'); - - setTimeout(function () { - assert.equal(2, _this.requests.length); - assert.equal(_this.requests[1].url, 'api2/posts'); - assert.equal(_this.requests[1].requestBody, DSUtils.toJson({ author: 'John', age: 30 })); - _this.requests[1].respond(200, { 'Content-Type': 'application/json' }, DSUtils.toJson(p1)); - }, 30); - - return dsHttpAdapter.create(Post, { author: 'John', age: 30 }, { basePath: 'api2' }); - }).then(function (data) { - assert.deepEqual(data, p1, 'post should have been created'); - - assert.equal(queryTransform.callCount, 2, 'queryTransform should have been called twice'); - }); - }); -}); diff --git a/test/create.test.js b/test/create.test.js new file mode 100644 index 0000000..8da03d1 --- /dev/null +++ b/test/create.test.js @@ -0,0 +1,34 @@ +describe('create', function () { + it('should create', function () { + var Test = this + var post = { + author: 'John', + age: 30 + } + + setTimeout(function () { + Test.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(Test.p1)) + }, 30) + + return Test.adapter.create(Test.Post, post) + .then(function (data) { + Test.assert.equal(Test.requests[0].url, 'api/posts') + Test.assert.equal(Test.requests[0].method, 'POST') + Test.assert.equal(Test.requests[0].requestBody, JSON.stringify(post)) + Test.assert.deepEqual(data, Test.p1, 'post should have been created') + + setTimeout(function () { + Test.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(Test.p1)) + }, 30) + + return Test.adapter.create(Test.Post, post, { + basePath: 'api2' + }) + }) + .then(function (data) { + Test.assert.equal(Test.requests[1].url, 'api2/posts') + Test.assert.equal(Test.requests[1].requestBody, JSON.stringify(post)) + Test.assert.deepEqual(data, Test.p1, 'post should have been created') + }) + }) +}) diff --git a/test/createMany.test.js b/test/createMany.test.js new file mode 100644 index 0000000..1066bc7 --- /dev/null +++ b/test/createMany.test.js @@ -0,0 +1,3 @@ +describe('createMany', function () { + it('should createMany') +}) diff --git a/test/deserialize.test.js b/test/deserialize.test.js new file mode 100644 index 0000000..eeb4559 --- /dev/null +++ b/test/deserialize.test.js @@ -0,0 +1,3 @@ +describe('deserialize', function () { + it('should deserialize') +}) diff --git a/test/destroy.spec.js b/test/destroy.spec.js deleted file mode 100644 index bfebf00..0000000 --- a/test/destroy.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -describe('DSHttpAdapter.destroy(resourceConfig, id, options)', function () { - - it('should make a DELETE request', function () { - var _this = this; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/posts/1'); - assert.equal(_this.requests[0].method, 'DELETE'); - _this.requests[0].respond(200, { 'Content-Type': 'text/plain' }, '1'); - }, 30); - - return dsHttpAdapter.destroy(Post, 1).then(function (data) { - assert.deepEqual(data, 1, 'post should have been deleted'); - - setTimeout(function () { - assert.equal(2, _this.requests.length); - assert.equal(_this.requests[1].url, 'api2/posts/1'); - assert.equal(_this.requests[1].method, 'DELETE'); - _this.requests[1].respond(200, { 'Content-Type': 'text/plain' }, '1'); - }, 30); - - return dsHttpAdapter.destroy(Post, 1, { basePath: 'api2' }); - }).then(function (data) { - assert.deepEqual(data, 1, 'post should have been deleted'); - assert.equal(queryTransform.callCount, 2, 'queryTransform should have been called twice'); - }); - }); -}); diff --git a/test/destroy.test.js b/test/destroy.test.js new file mode 100644 index 0000000..13ed79d --- /dev/null +++ b/test/destroy.test.js @@ -0,0 +1,29 @@ +describe('destroy', function () { + it('should destroy', function () { + var Test = this + + setTimeout(function () { + Test.requests[0].respond(200, { 'Content-Type': 'text/plain' }, '1') + }, 30) + + return Test.adapter.destroy(Test.Post, 1) + .then(function (data) { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'api/posts/1') + Test.assert.equal(Test.requests[0].method, 'DELETE') + Test.assert.deepEqual(data, 1, 'post should have been deleted') + + setTimeout(function () { + Test.requests[1].respond(200, { 'Content-Type': 'text/plain' }, '1') + }, 30) + + return Test.adapter.destroy(Test.Post, 1, { basePath: 'api2' }) + }) + .then(function (data) { + Test.assert.equal(2, Test.requests.length) + Test.assert.equal(Test.requests[1].url, 'api2/posts/1') + Test.assert.equal(Test.requests[1].method, 'DELETE') + Test.assert.deepEqual(data, 1, 'post should have been deleted') + }) + }) +}) diff --git a/test/destroyAll.spec.js b/test/destroyAll.spec.js deleted file mode 100644 index d070c58..0000000 --- a/test/destroyAll.spec.js +++ /dev/null @@ -1,35 +0,0 @@ -describe('DSHttpAdapter.destroyAll(resourceConfig, params, options)', function () { - - it('should make a DELETE request', function () { - var _this = this; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/posts'); - assert.equal(_this.requests[0].method, 'DELETE'); - _this.requests[0].respond(204); - }, 30); - - return dsHttpAdapter.destroyAll(Post, {}).then(function (data) { - assert.equal('', data, 'posts should have been found'); - - setTimeout(function () { - assert.equal(2, _this.requests.length); - assert.equal(_this.requests[1].url, 'api2/posts?where=%7B%22author%22:%7B%22%3D%3D%22:%22John%22%7D%7D'); - assert.equal(_this.requests[1].method, 'DELETE'); - _this.requests[1].respond(204); - }, 30); - - return dsHttpAdapter.destroyAll(Post, { - where: { - author: { - '==': 'John' - } - } - }, { basePath: 'api2' }); - }).then(function (data) { - assert.equal('', data, 'posts should have been destroyed'); - assert.equal(queryTransform.callCount, 2, 'queryTransform should have been called'); - }); - }); -}); diff --git a/test/destroyAll.test.js b/test/destroyAll.test.js new file mode 100644 index 0000000..d73879d --- /dev/null +++ b/test/destroyAll.test.js @@ -0,0 +1,35 @@ +describe('destroyAll', function () { + it('should destroyAll', function () { + var Test = this + + setTimeout(function () { + Test.requests[0].respond(204) + }, 30) + + return Test.adapter.destroyAll(Test.Post, {}) + .then(function (data) { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'api/posts') + Test.assert.equal(Test.requests[0].method, 'DELETE') + Test.assert.equal('', data, 'posts should have been found') + + setTimeout(function () { + Test.requests[1].respond(204) + }, 30) + + return Test.adapter.destroyAll(Test.Post, { + where: { + author: { + '==': 'John' + } + } + }, { basePath: 'api2' }) + }) + .then(function (data) { + Test.assert.equal(2, Test.requests.length) + Test.assert.equal(Test.requests[1].url.indexOf('api2/posts?where='), 0) + Test.assert.equal(Test.requests[1].method, 'DELETE') + Test.assert.equal('', data, 'posts should have been destroyed') + }) + }) +}) diff --git a/test/fetch.test.js b/test/fetch.test.js new file mode 100644 index 0000000..d86e69f --- /dev/null +++ b/test/fetch.test.js @@ -0,0 +1,3 @@ +describe('fetch', function () { + it('should fetch') +}) diff --git a/test/find.spec.js b/test/find.spec.js deleted file mode 100644 index c6e3ec1..0000000 --- a/test/find.spec.js +++ /dev/null @@ -1,156 +0,0 @@ -describe('DSHttpAdapter.find(resourceConfig, id, options)', function () { - - it('should make a GET request', function () { - var _this = this; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/posts/1'); - assert.equal(_this.requests[0].method, 'GET'); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(p1)); - }, 30); - - return dsHttpAdapter.find(Post, 1).then(function (data) { - assert.deepEqual(data, p1, 'post should have been found'); - - setTimeout(function () { - assert.equal(2, _this.requests.length); - assert.equal(_this.requests[1].url, 'api2/posts/1'); - assert.equal(_this.requests[1].method, 'GET'); - _this.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(p1)); - }, 30); - - return dsHttpAdapter.find(Post, 1, { basePath: 'api2' }); - }).then(function (data) { - assert.deepEqual(data, p1, 'post should have been found'); - assert.equal(queryTransform.callCount, 2, 'queryTransform should have been called twice'); - }); - }); - - it('should allow overriding urlPath', function () { - var _this = this; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/foo/bar/beep/boop/1'); - assert.equal(_this.requests[0].method, 'GET'); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(p1)); - }, 30); - - return Post.find(1, { urlPath: '/foo/bar/beep/boop/1' }).then(function (data) { - assert.equal(data.id, p1.id, 'post should have been found'); - assert.equal(queryTransform.callCount, 1, 'queryTransform should have been called twice'); - }); - }); - - it('should use default configs', function () { - var _this = this; - - dsHttpAdapter.defaults.httpConfig.params = { test: 'test' }; - dsHttpAdapter.defaults.httpConfig.headers = { Authorization: 'test' }; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/posts/1?test=test'); - assert.equal(_this.requests[0].method, 'GET'); - assert.deepEqual({ - Authorization: 'test', - Accept: 'application/json, text/plain, */*' - }, _this.requests[0].requestHeaders); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(p1)); - }, 30); - - return dsHttpAdapter.find(Post, 1).then(function (data) { - assert.deepEqual(data, p1, 'post should have been found'); - - delete dsHttpAdapter.defaults.httpConfig.params; - delete dsHttpAdapter.defaults.httpConfig.headers; - }); - }); - - it('should log errors', function () { - var _this = this; - var loggedError; - - dsHttpAdapter.defaults.error = function (err) { - loggedError = err; - }; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/posts/1'); - assert.equal(_this.requests[0].method, 'GET'); - _this.requests[0].respond(404, { 'Content-Type': 'text/plain' }, 'Not Found'); - }, 30); - - return dsHttpAdapter.find(Post, 1).then(function () { - throw new Error('Should not have succeeded!'); - }, function () { - console.log(loggedError); - assert.isString(loggedError); - assert.isTrue(loggedError.indexOf('api/posts/1') !== -1, loggedError); - }); - }); - - it('should use suffixes', function () { - var _this = this; - - var Thing = datastore.defineResource({ - name: 'thing', - endpoint: 'things', - suffix: '.xml' - }); - - var otherAdapter = new DSHttpAdapter({ - suffix: '.json' - }); - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'things/1.xml'); - assert.equal(_this.requests[0].method, 'GET'); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ id: 1 })); - }, 30); - - return dsHttpAdapter.find(Thing, 1).then(function () { - - setTimeout(function () { - assert.equal(2, _this.requests.length); - assert.equal(_this.requests[1].url, 'api/posts/1.json'); - assert.equal(_this.requests[1].method, 'GET'); - _this.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ id: 1 })); - }, 30); - - return otherAdapter.find(Post, 1); - }); - }); - - it('should use parent', function () { - var _this = this; - - var Thing = datastore.defineResource({ - name: 'thing', - endpoint: 'things', - relations: { - belongsTo: { - user: { - localKey: 'userId', - localField: 'user', - parent: true - } - } - } - }); - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'user/2/things/1'); - assert.equal(_this.requests[0].method, 'GET'); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ id: 1 })); - }, 30); - - return dsHttpAdapter.find(Thing, 1, { params: { userId: 2 } }).then(function (data) { - assert.deepEqual(data, { id: 1 }, 'thing should have been found'); - }); - }); -}); diff --git a/test/find.test.js b/test/find.test.js new file mode 100644 index 0000000..f37990d --- /dev/null +++ b/test/find.test.js @@ -0,0 +1,225 @@ +describe('find', function () { + it('should find', function () { + var Test = this + + setTimeout(function () { + Test.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(Test.p1)) + }, 30) + + return Test.adapter.find(Test.Post, 1) + .then(function (data) { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'api/posts/1') + Test.assert.equal(Test.requests[0].method, 'GET') + Test.assert.deepEqual(data, Test.p1, 'post should have been found') + + setTimeout(function () { + Test.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(Test.p1)) + }, 30) + + return Test.adapter.find(Test.Post, 1, { basePath: 'api2' }) + }) + .then(function (data) { + Test.assert.equal(2, Test.requests.length) + Test.assert.equal(Test.requests[1].url, 'api2/posts/1') + Test.assert.equal(Test.requests[1].method, 'GET') + Test.assert.deepEqual(data, Test.p1, 'post should have been found') + }) + }) + + it('should use default configs', function () { + var Test = this + + Test.adapter.httpConfig.params = { test: 'test' } + Test.adapter.httpConfig.headers = { Authorization: 'test' } + + setTimeout(function () { + Test.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(Test.p1)) + }, 30) + + return Test.adapter.find(Test.Post, 1) + .then(function (data) { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'api/posts/1?test=test') + Test.assert.equal(Test.requests[0].method, 'GET') + Test.assert.deepEqual({ + Authorization: 'test', + Accept: 'application/json, text/plain, */*' + }, Test.requests[0].requestHeaders) + Test.assert.deepEqual(data, Test.p1, 'post should have been found') + + delete Test.adapter.httpConfig.params + delete Test.adapter.httpConfig.headers + }) + }) + + it('should log errors', function () { + var Test = this + var loggedError + + Test.adapter.error = function (err) { + loggedError = err + } + + setTimeout(function () { + Test.requests[0].respond(404, { 'Content-Type': 'text/plain' }, 'Not Found') + }, 30) + + return Test.adapter.find(Test.Post, 1) + .then(function () { + throw new Error('Should not have succeeded!') + }, function () { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'api/posts/1') + Test.assert.equal(Test.requests[0].method, 'GET') + Test.assert.isString(loggedError) + Test.assert.isTrue(loggedError.indexOf('api/posts/1') !== -1) + }) + }) + + it('should use suffixes', function () { + var Test = this + + var Thing = new Test.JSData.Mapper({ + name: 'thing', + endpoint: 'things', + suffix: '.xml' + }) + + var otherAdapter = new Test.HttpAdapter({ + suffix: '.json' + }) + otherAdapter.http = Test.adapter.http + + setTimeout(function () { + Test.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ id: 1 })) + }, 30) + + return Test.adapter.find(Thing, 1) + .then(function () { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'things/1.xml') + Test.assert.equal(Test.requests[0].method, 'GET') + + setTimeout(function () { + Test.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ id: 1 })) + }, 30) + + return otherAdapter.find(Test.Post, 1) + }).then(function () { + Test.assert.equal(2, Test.requests.length) + Test.assert.equal(Test.requests[1].url, 'api/posts/1.json') + Test.assert.equal(Test.requests[1].method, 'GET') + }) + }) + + it('should work with multiple parents', function () { + var Test = this + var store = new Test.JSData.DataStore({ + mapperDefaults: { + basePath: 'api' + } + }) + store.registerAdapter('http', Test.adapter, { default: true }) + store.defineMapper('user', { + relations: { + hasMany: { + post: { + foreignKey: 'userId', + localField: 'posts' + }, + comment: { + foreignKey: 'userId', + localField: 'comments' + } + } + } + }) + store.defineMapper('post', { + endpoint: 'posts', + relations: { + belongsTo: { + user: { + parent: true, + foreignKey: 'userId', + localField: 'user' + } + }, + hasMany: { + comment: { + localField: 'comments', + foreignKey: 'postId' + } + } + } + }) + store.defineMapper('comment', { + relations: { + belongsTo: { + post: { + parent: true, + foreignKey: 'postId', + localField: 'post' + }, + user: { + parent: true, + foreignKey: 'userId', + localField: 'user' + } + } + } + }) + + var post = { + id: 1, + userId: 10 + } + + var comment = { + id: 3, + postId: 1, + userId: 13 + } + + var comment2 = { + id: 4, + userId: 7 + } + + setTimeout(function () { + Test.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(post)) + }, 30) + + return store.find('post', 1, { params: { userId: 10 } }) + .then(function (data) { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'api/user/10/posts/1') + Test.assert.equal(Test.requests[0].method, 'GET') + Test.assert.objectsEqual(data, post, 'post should have been found') + + setTimeout(function () { + Test.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(comment)) + }, 30) + + return store.find('comment', 3, { params: { postId: 1, userId: 13 } }) + }) + .then(function (data) { + Test.assert.equal(2, Test.requests.length) + Test.assert.equal(Test.requests[1].url, 'api/user/13/posts/1/comment/3') + Test.assert.equal(Test.requests[1].method, 'GET') + Test.assert.objectsEqual(data, comment, 'comment should have been found') + + setTimeout(function () { + Test.requests[2].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(comment2)) + }, 30) + + return store.find('comment', 4, { params: { userId: 7 } }) + }) + .then(function (data) { + Test.assert.equal(3, Test.requests.length) + Test.assert.equal(Test.requests[2].url, 'api/user/7/comment/4') + Test.assert.equal(Test.requests[2].method, 'GET') + Test.assert.objectsEqual(data, comment2, 'comment should have been found') + }) + }) +}) diff --git a/test/findAll.spec.js b/test/findAll.spec.js deleted file mode 100644 index 06f6165..0000000 --- a/test/findAll.spec.js +++ /dev/null @@ -1,93 +0,0 @@ -describe('dsHttpAdapter.findAll(resourceConfig, params, options)', function () { - - it('should make a GET request', function () { - var _this = this; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/posts'); - assert.equal(_this.requests[0].method, 'GET'); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([p1])); - }, 30); - - return dsHttpAdapter.findAll(Post, {}).then(function (data) { - assert.deepEqual(data, [p1], 'posts should have been found'); - - setTimeout(function () { - assert.equal(2, _this.requests.length); - assert.equal(_this.requests[1].url, 'api2/posts?where=%7B%22author%22:%7B%22%3D%3D%22:%22John%22%7D%7D'); - assert.equal(_this.requests[1].method, 'GET'); - _this.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([p1])); - }, 30); - - return dsHttpAdapter.findAll(Post, { - where: { - author: { - '==': 'John' - } - } - }, { basePath: 'api2' }); - }).then(function (data) { - assert.deepEqual(data, [p1], 'posts should have been found'); - assert.equal(queryTransform.callCount, 2, 'queryTransform should have been called'); - }); - }); - - it('should use one of many parents', function () { - var _this = this; - - var Thing = datastore.defineResource({ - name: 'thing', - endpoint: 'things', - relations: { - belongsTo: { - user: { - localKey: 'userId', - localField: 'user', - parent: true - }, - posts: { - localKey: 'postId', - localField: 'post', - parent: true - } - } - } - }); - - if (!Thing.parents) { - Thing.parents = { - user: { - key: 'userId', - field: 'user' - }, - posts: { - key: 'postId', - field: 'post' - } - } - } - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'user/1/things'); - assert.equal(_this.requests[0].method, 'GET'); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([{ id: 1 }])); - }, 30); - - return dsHttpAdapter.findAll(Thing, { userId: 1 }).then(function (data) { - assert.deepEqual(data, [{ id: 1 }], 'user thing should have been found'); - - setTimeout(function () { - assert.equal(2, _this.requests.length); - assert.equal(_this.requests[1].url, 'posts/2/things'); - assert.equal(_this.requests[1].method, 'GET'); - _this.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([{ id: 2 }])); - }, 30); - - return dsHttpAdapter.findAll(Thing, { postId: 2 }); - }).then(function(data) { - assert.deepEqual(data, [{ id: 2 }], 'post thing should have been found'); - }); - }); -}); diff --git a/test/findAll.test.js b/test/findAll.test.js new file mode 100644 index 0000000..b131ca4 --- /dev/null +++ b/test/findAll.test.js @@ -0,0 +1,35 @@ +describe('findAll', function () { + it('should findAll', function () { + var Test = this + + setTimeout(function () { + Test.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([Test.p1])) + }, 30) + + return Test.adapter.findAll(Test.Post, {}) + .then(function (data) { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'api/posts') + Test.assert.equal(Test.requests[0].method, 'GET') + Test.assert.deepEqual(data, [Test.p1], 'posts should have been found') + + setTimeout(function () { + Test.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([Test.p1])) + }, 30) + + return Test.adapter.findAll(Test.Post, { + where: { + author: { + '==': 'John' + } + } + }, { basePath: 'api2' }) + }) + .then(function (data) { + Test.assert.equal(2, Test.requests.length) + Test.assert.equal(Test.requests[1].url.indexOf('api2/posts?where='), 0) + Test.assert.equal(Test.requests[1].method, 'GET') + Test.assert.deepEqual(data, [Test.p1], 'posts should have been found') + }) + }) +}) diff --git a/test/getEndpoint.test.js b/test/getEndpoint.test.js new file mode 100644 index 0000000..3e88df6 --- /dev/null +++ b/test/getEndpoint.test.js @@ -0,0 +1,3 @@ +describe('getEndpoint', function () { + it('should getEndpoint') +}) diff --git a/test/getPath.test.js b/test/getPath.test.js new file mode 100644 index 0000000..93a65ce --- /dev/null +++ b/test/getPath.test.js @@ -0,0 +1,3 @@ +describe('getPath', function () { + it('should getPath') +}) diff --git a/test/queryTransform.test.js b/test/queryTransform.test.js new file mode 100644 index 0000000..bc819ae --- /dev/null +++ b/test/queryTransform.test.js @@ -0,0 +1,3 @@ +describe('queryTransform', function () { + it('should queryTransform') +}) diff --git a/test/responseError.test.js b/test/responseError.test.js new file mode 100644 index 0000000..fb0e67b --- /dev/null +++ b/test/responseError.test.js @@ -0,0 +1,3 @@ +describe('responseError', function () { + it('should responseError') +}) diff --git a/test/serialize.test.js b/test/serialize.test.js new file mode 100644 index 0000000..41c858b --- /dev/null +++ b/test/serialize.test.js @@ -0,0 +1,3 @@ +describe('serialize', function () { + it('should serialize') +}) diff --git a/test/static.addAction.test.js b/test/static.addAction.test.js new file mode 100644 index 0000000..a368b20 --- /dev/null +++ b/test/static.addAction.test.js @@ -0,0 +1,3 @@ +describe('static addAction', function () { + it('should addAction') +}) diff --git a/test/static.addActions.test.js b/test/static.addActions.test.js new file mode 100644 index 0000000..685c0cf --- /dev/null +++ b/test/static.addActions.test.js @@ -0,0 +1,3 @@ +describe('static addActions', function () { + it('should addActions') +}) diff --git a/test/update.spec.js b/test/update.spec.js deleted file mode 100644 index 6f7cf37..0000000 --- a/test/update.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('DSHttpAdapter.update(resourceConfig, id, attrs, options)', function () { - - it('should make a PUT request', function () { - var _this = this; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/posts/1'); - assert.equal(_this.requests[0].method, 'PUT'); - assert.equal(_this.requests[0].requestBody, JSON.stringify({ author: 'John', age: 30 })); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(p1)); - }, 30); - - return dsHttpAdapter.update(Post, 1, { author: 'John', age: 30 }).then(function (data) { - assert.deepEqual(data, p1, 'post 5 should have been updated'); - - setTimeout(function () { - assert.equal(2, _this.requests.length); - assert.equal(_this.requests[1].url, 'api2/posts/1'); - assert.equal(_this.requests[1].method, 'PUT'); - assert.equal(_this.requests[1].requestBody, JSON.stringify({ author: 'John', age: 30 })); - _this.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(p1)); - }, 30); - - return dsHttpAdapter.update(Post, 1, { author: 'John', age: 30 }, { basePath: 'api2' }); - }).then(function (data) { - assert.deepEqual(data, p1, 'post 5 should have been updated'); - assert.equal(queryTransform.callCount, 2, 'queryTransform should have been called twice'); - }); - }); -}); diff --git a/test/update.test.js b/test/update.test.js new file mode 100644 index 0000000..15427aa --- /dev/null +++ b/test/update.test.js @@ -0,0 +1,31 @@ +describe('update', function () { + it('should update', function () { + var Test = this + + setTimeout(function () { + Test.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(Test.p1)) + }, 30) + + return Test.adapter.update(Test.Post, 1, { author: 'John', age: 30 }) + .then(function (data) { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'api/posts/1') + Test.assert.equal(Test.requests[0].method, 'PUT') + Test.assert.equal(Test.requests[0].requestBody, JSON.stringify({ author: 'John', age: 30 })) + Test.assert.deepEqual(data, Test.p1, 'post 5 should have been updated') + + setTimeout(function () { + Test.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(Test.p1)) + }, 30) + + return Test.adapter.update(Test.Post, 1, { author: 'John', age: 30 }, { basePath: 'api2' }) + }) + .then(function (data) { + Test.assert.equal(2, Test.requests.length) + Test.assert.equal(Test.requests[1].url, 'api2/posts/1') + Test.assert.equal(Test.requests[1].method, 'PUT') + Test.assert.equal(Test.requests[1].requestBody, JSON.stringify({ author: 'John', age: 30 })) + Test.assert.deepEqual(data, Test.p1, 'post 5 should have been updated') + }) + }) +}) diff --git a/test/updateAll.spec.js b/test/updateAll.spec.js deleted file mode 100644 index f8179c1..0000000 --- a/test/updateAll.spec.js +++ /dev/null @@ -1,35 +0,0 @@ -describe('DSHttpAdapter.updateAll(resourceConfig, attrs, params, options)', function () { - - it('should make a PUT request', function () { - var _this = this; - - setTimeout(function () { - assert.equal(1, _this.requests.length); - assert.equal(_this.requests[0].url, 'api/posts'); - assert.equal(_this.requests[0].method, 'PUT'); - _this.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([p1])); - }, 30); - - return dsHttpAdapter.updateAll(Post, { author: 'John', age: 30 }).then(function (data) { - assert.deepEqual(data, [p1], 'posts should have been updated'); - - setTimeout(function () { - assert.equal(2, _this.requests.length); - assert.equal(_this.requests[1].url, 'api2/posts?where=%7B%22author%22:%7B%22%3D%3D%22:%22John%22%7D%7D'); - assert.equal(_this.requests[1].method, 'PUT'); - _this.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([p1])); - }, 30); - - return dsHttpAdapter.updateAll(Post, { author: 'John', age: 30 }, { - where: { - author: { - '==': 'John' - } - } - }, { basePath: 'api2' }); - }).then(function (data) { - assert.deepEqual(data, [p1], 'posts should have been updated'); - assert.equal(queryTransform.callCount, 1, 'queryTransform should have been called'); - }); - }); -}); diff --git a/test/updateAll.test.js b/test/updateAll.test.js new file mode 100644 index 0000000..a55573e --- /dev/null +++ b/test/updateAll.test.js @@ -0,0 +1,35 @@ +describe('updateAll', function () { + it('should updateAll', function () { + var Test = this + + setTimeout(function () { + Test.requests[0].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([Test.p1])) + }, 30) + + return Test.adapter.updateAll(Test.Post, { author: 'John', age: 30 }) + .then(function (data) { + Test.assert.equal(1, Test.requests.length) + Test.assert.equal(Test.requests[0].url, 'api/posts') + Test.assert.equal(Test.requests[0].method, 'PUT') + Test.assert.deepEqual(data, [Test.p1], 'posts should have been updated') + + setTimeout(function () { + Test.requests[1].respond(200, { 'Content-Type': 'application/json' }, JSON.stringify([Test.p1])) + }, 30) + + return Test.adapter.updateAll(Test.Post, { author: 'John', age: 30 }, { + where: { + author: { + '==': 'John' + } + } + }, { basePath: 'api2' }) + }) + .then(function (data) { + Test.assert.equal(2, Test.requests.length) + Test.assert.equal(Test.requests[1].url.indexOf('api2/posts?where='), 0) + Test.assert.equal(Test.requests[1].method, 'PUT') + Test.assert.deepEqual(data, [Test.p1], 'posts should have been updated') + }) + }) +}) diff --git a/test/updateMany.test.js b/test/updateMany.test.js new file mode 100644 index 0000000..c1137a6 --- /dev/null +++ b/test/updateMany.test.js @@ -0,0 +1,3 @@ +describe('updateMany', function () { + it('should updateMany') +}) diff --git a/typings.json b/typings.json new file mode 100644 index 0000000..2f71f35 --- /dev/null +++ b/typings.json @@ -0,0 +1,10 @@ +{ + "name": "js-data-http", + "version": false, + "main": "./dist/js-data-http.d.ts", + "ambientDependencies": { + "js-data": "npm:js-data", + "js-data-adapter": "npm:js-data-adapter", + "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654" + } +} diff --git a/webpack.config.js b/webpack.config.js index ac1f7e6..60458a6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,13 +2,21 @@ var path = require('path') module.exports = { devtool: 'source-map', - entry: './src/index.js', + entry: { + './dist/js-data-http.js': './src/index.js' + }, output: { - filename: './dist/js-data-http.js', + filename: '[name]', libraryTarget: 'umd', - library: 'DSHttpAdapter' + library: 'JSDataHttp' }, externals: { + 'chai': { + amd: 'chai', + commonjs: 'chai', + commonjs2: 'chai', + root: 'chai' + }, 'js-data': { amd: 'js-data', commonjs: 'js-data',