From 68856d791b594bceaff2093641ce1f74c287064b Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sat, 13 Feb 2016 22:32:24 +0000 Subject: [PATCH 01/15] Stable Version 3.0.0-alpha.1 --- .babelrc | 3 + .bowerrc | 3 - .gitignore | 3 +- .npmignore | 8 +- CONTRIBUTING.md | 42 +- LICENSE | 2 +- README.md | 99 +- bower.json | 8 +- conf.json | 23 + dist/js-data-localstorage.js | 2016 +++++++++++++++++------------ dist/js-data-localstorage.js.map | 1 + dist/js-data-localstorage.min.js | 6 +- dist/js-data-localstorage.min.map | 2 +- karma.conf.js | 5 +- karma.start.js | 30 +- package.json | 47 +- scripts/banner.js | 4 +- scripts/cleanup.js | 25 + src/index.js | 1373 +++++++++++++++----- webpack.config.js | 24 +- 20 files changed, 2411 insertions(+), 1313 deletions(-) create mode 100644 .babelrc delete mode 100644 .bowerrc create mode 100644 conf.json create mode 100644 dist/js-data-localstorage.js.map create mode 100644 scripts/cleanup.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..c13c5f6 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} 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/.gitignore b/.gitignore index 8f37b2a..64aa96d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ coverage/ npm-debug.log junit/ -dist/karma.start.js \ No newline at end of file +dist/karma.start.js +doc/ \ No newline at end of file diff --git a/.npmignore b/.npmignore index 94e80f9..57378b4 100644 --- a/.npmignore +++ b/.npmignore @@ -20,17 +20,15 @@ bower_components/ *.iml .idea/ - +bs.jpg *.png CONTRIBUTING.md favicon.ico circle.yml bower.json -.bowerrc -Gruntfile.js *.start.js karma.conf.js test/ -lib/ src/ -junit/ \ No newline at end of file +junit/ +doc/ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9df6145..81066a4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,24 +1,46 @@ # Contributing Guide -First, support is handled via the [Slack Channel](http://slack.js-data.io) and the [Mailing List](https://groups.io/org/groupsio/jsdata). Ask your questions there. +## Support -When submitting issues on GitHub, please include as much detail as possible to make debugging quick and easy. +Support questions are handled via [StackOverflow][so], [Slack][slack], and the +[Mailing List][ml]. Ask your questions there. -- good - Your versions of js-data, js-data-localstorage, etc., relevant console logs/error, code examples that revealed the issue -- better - A [plnkr](http://plnkr.co/), [fiddle](http://jsfiddle.net/), or [bin](http://jsbin.com/?html,output) that demonstrates the issue -- best - A Pull Request that fixes the issue, including test coverage for the issue and the fix +## Community +- [StackOverflow Channel][so] +- [Slack Chat][slack] [![Slack Status][sl_b]][slack] +- [Announcements](http://www.js-data.io/blog) +- [Mailing List](ml) +- [Issues Tracker](https://github.com/js-data/js-data/issues) +- [GitHub](https://github.com/js-data/js-data) +- [Contributing Guide](https://github.com/js-data/js-data/blob/master/CONTRIBUTING.md) -[Github Issues](https://github.com/js-data/js-data-localstorage/issues). +## Contributing -#### Submitting Pull Requests +When submitting bug reports or feature requests on GitHub, please include _as +much detail as possible_. -1. Contribute to the issue/discussion that is the reason you'll be developing in the first place -1. Fork js-data-localstorage +- good - Your versions of Angular, JSData, etc, relevant console logs, stack +traces, code examples that revealed the issue, etc. +- better - A [plnkr](http://plnkr.co/), [fiddle](http://jsfiddle.net/), or +[bin](http://jsbin.com/?html,output) that demonstrates the issue +- best - A Pull Request that fixes the issue, including test coverage for the +issue and the fix + +### Pull Requests + +1. Contribute to the issue/discussion that is the reason you'll be developing in +the first place +1. Fork js-data 1. `git clone git@github.com:/js-data-localstorage.git` 1. `cd js-data-localstorage; npm install;` 1. Write your code, including relevant documentation and tests 1. Run `npm test` (build and test) 1. Your code will be linted and checked for formatting, the tests will be run -1. The `dist/` folder & files will be generated, do NOT commit `dist/*`! They will be committed when a release is cut. +1. The `dist/` folder & files will be generated, do NOT commit `dist/*`! They +will be committed when a release is cut. 1. Submit your PR and we'll review! 1. Thanks! + +[slack]: http://slack.js-data.io +[ml]: https://groups.io/org/groupsio/jsdata +[so]: http://stackoverflow.com/questions/tagged/jsdata diff --git a/LICENSE b/LICENSE index d74449a..73d2777 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2015 Jason Dobry +Copyright (c) 2014-2016 Jason Dobry Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index f3e004d..00b5a69 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,43 @@ -js-data logo +js-data logo -## js-data-localstorage [![Slack Status][sl_b]][sl_l] [![npm version][npm_b]][npm_l] [![Circle CI][circle_b]][circle_l] [![npm downloads][dn_b]][dn_l] [![Coverage Status][cov_b]][cov_l] [![Codacy][cod_b]][cod_l] +# js-data-localstorage + +[![Slack Status][sl_b]][sl_l] +[![npm version][npm_b]][npm_l] +[![Circle CI][circle_b]][circle_l] +[![npm downloads][dn_b]][dn_l] +[![Coverage Status][cov_b]][cov_l] +[![Codacy][cod_b]][cod_l] localStorage adapter for [js-data](http://www.js-data.io/). Tested on IE9, Chrome 46, Firefox 41 & Safari 7.1 using bs logo -### API Documentation -[DSLocalStorageAdapter](http://www.js-data.io/docs/dslocalstorageadapter) +## Table of contents -### Demo -[https://js-data-localstorage.firebaseapp.com/](https://js-data-localstorage.firebaseapp.com/) +* [Quick start](#quick-start) +* [Documentation](#documentation) +* [API Reference](#api-reference) +* [Demo](#demo) +* [Support](#support) +* [Community](#community) +* [Contributing](#contributing) +* [License](#license) + +## Quick Start -### Quick Start `npm install --save js-data js-data-localstorage` or `bower install --save js-data js-data-localstorage`. Load `js-data-localstorage.js` after `js-data.js`. ```js -var adapter = new DSLocalStorageAdapter(); +var adapter = new LocalStorageAdapter(); -var store = new JSData.DS(); +var store = new JSData.DataStore(); store.registerAdapter('localstorage', adapter, { default: true }); -// "store" will now use the localstorage adapter for all async operations +// "store" will now use the localstorage adapter ``` You can also provide a custom storage medium (it just needs to implement the `localStorage` API): @@ -33,7 +46,7 @@ You can also provide a custom storage medium (it just needs to implement the `lo var memory = {}; // Turn js-data-localstorage into an in-memory adapter -var memoryAdapter = new DSLocalStorageAdapter({ +var memoryAdapter = new LocalStorageAdapter({ storage: { getItem: function (key) { return memory[key]; @@ -48,52 +61,69 @@ var memoryAdapter = new DSLocalStorageAdapter({ }); // Turn js-data-localstorage into a sessionStorage adapter -var sessionAdapter = new DSLocalStorageAdapter({ +var sessionAdapter = new LocalStorageAdapter({ storage: sessionStorage }); ``` -### Changelog -[CHANGELOG.md](https://github.com/js-data/js-data-localstorage/blob/master/CHANGELOG.md) +## Documentation +- [Getting Started with js-data](http://www.js-data.io/docs/home) +- [js-data-http](http://www.js-data.io/docs/js-data-localstorage) +- [CHANGELOG.md](https://github.com/js-data/js-data-localstorage/blob/master/CHANGELOG.md) -### Community -- [Slack Channel][sl_l] - Better than IRC! -- [Announcements](http://www.js-data.io/blog) -- [Mailing List](https://groups.io/org/groupsio/jsdata) - Ask your questions! -- [Issues](https://github.com/js-data/js-data-localstorage/issues) - Found a bug? Feature request? Submit an issue! -- [GitHub](https://github.com/js-data/js-data-localstorage) - View the source code for js-data. -- [Contributing Guide](https://github.com/js-data/js-data-localstorage/blob/master/CONTRIBUTING.md) +## API Reference +- [js-data](http://api.js-data.io/js-data/) +- [js-data-localstorage](http://api.js-data.io/js-data-localstorage/) -### Contributing +## Demo +[https://js-data-localstorage.firebaseapp.com/](https://js-data-localstorage.firebaseapp.com/) + +## Support -First, support is handled via the [Slack Channel][sl_l] and the [Mailing List](https://groups.io/org/groupsio/jsdata). Ask your questions there. +Support questions are handled via [StackOverflow][so], [Slack][slack], and the +[Mailing List][ml]. Ask your questions there. + +## Community +- [StackOverflow Channel][so] +- [Slack Chat][slack] [![Slack Status][sl_b]][slack] +- [Announcements](http://www.js-data.io/blog) +- [Mailing List](ml) +- [Issues Tracker](https://github.com/js-data/js-data/issues) +- [GitHub](https://github.com/js-data/js-data) +- [Contributing Guide](https://github.com/js-data/js-data/blob/master/CONTRIBUTING.md) -When submitting issues on GitHub, please include as much detail as possible to make debugging quick and easy. +## Contributing -- good - Your versions of js-data, js-data-localstorage, etc., relevant console logs/error, code examples that revealed the issue -- better - A [plnkr](http://plnkr.co/), [fiddle](http://jsfiddle.net/), or [bin](http://jsbin.com/?html,output) that demonstrates the issue -- best - A Pull Request that fixes the issue, including test coverage for the issue and the fix +When submitting bug reports or feature requests on GitHub, please include _as +much detail as possible_. -[Github Issues](https://github.com/js-data/js-data-localstorage/issues). +- good - Your versions of Angular, JSData, etc, relevant console logs, stack +traces, code examples that revealed the issue, etc. +- better - A [plnkr](http://plnkr.co/), [fiddle](http://jsfiddle.net/), or +[bin](http://jsbin.com/?html,output) that demonstrates the issue +- best - A Pull Request that fixes the issue, including test coverage for the +issue and the fix -#### Submitting Pull Requests +### Pull Requests -1. Contribute to the issue/discussion that is the reason you'll be developing in the first place -1. Fork js-data-localstorage +1. Contribute to the issue/discussion that is the reason you'll be developing in +the first place +1. Fork js-data 1. `git clone git@github.com:/js-data-localstorage.git` 1. `cd js-data-localstorage; npm install;` 1. Write your code, including relevant documentation and tests 1. Run `npm test` (build and test) 1. Your code will be linted and checked for formatting, the tests will be run -1. The `dist/` folder & files will be generated, do NOT commit `dist/*`! They will be committed when a release is cut. +1. The `dist/` folder & files will be generated, do NOT commit `dist/*`! They +will be committed when a release is cut. 1. Submit your PR and we'll review! 1. Thanks! -### License +## License The MIT License (MIT) -Copyright (c) 2014-2015 Jason Dobry +Copyright (c) 2014-2016 Jason Dobry Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -125,3 +155,4 @@ SOFTWARE. [cov_l]: https://coveralls.io/github/js-data/js-data-localstorage?branch=master [cod_b]: https://img.shields.io/codacy/b8e46008e6ad45159b7a6927dbfd66c3.svg [cod_l]: https://www.codacy.com/app/jasondobry/js-data-localstorage/dashboard +[so]: http://stackoverflow.com/questions/tagged/jsdata diff --git a/bower.json b/bower.json index 0124420..0a9c60c 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "homepage": "http://www.js-data.io/docs/dslocalstorageadapter", + "homepage": "http://www.js-data.io/docs/js-data-localstorage", "repository": { "type": "git", "url": "https://github.com/js-data/js-data-localstorage.git" @@ -17,11 +17,9 @@ ".*", "*.iml", "src/", - "lib/", "doc/", - "guide/", + "junit/", "coverage/", - "Gruntfile.js", "node_modules/", "test/", "package.json", @@ -29,6 +27,6 @@ "karma.start.js" ], "dependencies": { - "js-data": "~2.x" + "js-data": "~3.x" } } diff --git a/conf.json b/conf.json new file mode 100644 index 0000000..41b00bc --- /dev/null +++ b/conf.json @@ -0,0 +1,23 @@ + { + "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-localstorage", + "copyright": "js-data-localstorage Copyright © 2014-2016 Jason Dobry", + "outputSourceFiles": true, + "syntaxTheme": "dark", + "linenums": true, + "footer": "
Back to js-data.io
" + } +} \ No newline at end of file diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index ccdb36a..1c942d5 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1,8 +1,8 @@ /*! * js-data-localstorage -* @version 2.3.2 - Homepage +* @version 3.0.0-alpha.1 - Homepage * @author Jason Dobry -* @copyright (c) 2014-2015 Jason Dobry +* @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. @@ -13,48 +13,48 @@ else if(typeof define === 'function' && define.amd) define(["js-data"], factory); else if(typeof exports === 'object') - exports["DSLocalStorageAdapter"] = factory(require("js-data")); + exports["LocalStorageAdapter"] = factory(require("js-data")); else - root["DSLocalStorageAdapter"] = factory(root["JSData"]); + root["LocalStorageAdapter"] = factory(root["JSData"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_1__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; - +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { - +/******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; - +/******/ /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; - +/******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - +/******/ /******/ // Flag the module as loaded /******/ module.loaded = true; - +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } - - +/******/ +/******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; - +/******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; - +/******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; - +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) @@ -64,44 +64,72 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports, __webpack_require__) { 'use strict'; - - 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; }; })(); - + 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; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - + /* global: localStorage */ var JSData = __webpack_require__(1); var guid = __webpack_require__(2); - var unique = __webpack_require__(13); - var map = __webpack_require__(22); - - var emptyStore = new JSData.DS(); - var DSUtils = JSData.DSUtils; - - var filter = emptyStore.defaults.defaultFilter; - - var Defaults = function Defaults() { - _classCallCheck(this, Defaults); - }; - - Defaults.prototype.basePath = ''; - + + var Query = JSData.Query; + var utils = JSData.utils; + var addHiddenPropsToTarget = utils.addHiddenPropsToTarget; + var copy = utils.copy; + var deepMixIn = utils.deepMixIn; + var extend = utils.extend; + var fillIn = utils.fillIn; + var forOwn = utils.forOwn; + var fromJson = utils.fromJson; + var get = utils.get; + var isArray = utils.isArray; + var isUndefined = utils.isUndefined; + var resolve = utils.resolve; + var reject = utils.reject; + var set = utils.set; + var toJson = utils.toJson; + + + function isValidString(value) { + return value != null && value !== ''; + } + function join(items, separator) { + separator || (separator = ''); + return items.filter(isValidString).join(separator); + } + function makePath() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var result = join(args, '/'); + return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); + } + function unique(array) { + var seen = {}; + var final = []; + array.forEach(function (item) { + if (item in seen) { + return; + } + final.push(item); + seen[item] = 0; + }); + return final; + } var queue = []; var taskInProcess = false; - + function enqueue(task) { queue.push(task); } - + function dequeue() { if (queue.length && !taskInProcess) { taskInProcess = true; queue[0](); } } - + function queueTask(task) { if (!queue.length) { enqueue(task); @@ -110,9 +138,9 @@ return /******/ (function(modules) { // webpackBootstrap enqueue(task); } } - + function createTask(fn) { - return new DSUtils.Promise(fn).then(function (result) { + return new Promise(fn).then(function (result) { taskInProcess = false; queue.shift(); setTimeout(dequeue, 0); @@ -121,462 +149,1106 @@ return /******/ (function(modules) { // webpackBootstrap taskInProcess = false; queue.shift(); setTimeout(dequeue, 0); - return DSUtils.Promise.reject(err); + return reject(err); }); } - - var DSLocalStorageAdapter = (function () { - function DSLocalStorageAdapter(options) { - _classCallCheck(this, DSLocalStorageAdapter); - - options = options || {}; - this.defaults = new Defaults(); - this.storage = options.storage || localStorage; - DSUtils.deepMixIn(this.defaults, options); + + var noop = function noop() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; } - - _createClass(DSLocalStorageAdapter, [{ - key: 'getPath', - value: function getPath(resourceConfig, options) { - options = options || {}; - return DSUtils.makePath(options.basePath || this.defaults.basePath || resourceConfig.basePath, resourceConfig.name); - } - }, { - key: 'getIdPath', - value: function getIdPath(resourceConfig, options, id) { - options = options || {}; - return DSUtils.makePath(options.basePath || this.defaults.basePath || resourceConfig.basePath, resourceConfig.endpoint, id); + + var opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + var opts = args[args.length - 2]; + self.dbg.apply(self, [opts.op].concat(args)); + return resolve(); + }; + + var DEFAULTS = { + /** + * TODO + * + * @name LocalStorageAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * TODO + * + * @name LocalStorageAdapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * TODO + * + * @name LocalStorageAdapter#storage + * @type {Object} + * @default localStorage + */ + storage: localStorage + }; + + /** + * LocalStorageAdapter class. + * + * @example + * import {DataStore} from 'js-data' + * import LocalStorageAdapter from 'js-data-localstorage' + * const store = new DataStore() + * const adapter = new LocalStorageAdapter() + * store.registerAdapter('ls', adapter, { 'default': true }) + * + * @class LocalStorageAdapter + * @param {Object} [opts] Configuration opts. + * @param {string} [opts.basePath=''] TODO + * @param {boolean} [opts.debug=false] TODO + * @param {Object} [opts.storeage=localStorage] TODO + */ + function LocalStorageAdapter(opts) { + fillIn(this, opts || {}); + fillIn(this, DEFAULTS); + } + + /** + * Alternative to ES6 class syntax for extending `LocalStorageAdapter`. + * + * @name LocalStorageAdapter.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 `LocalStorageAdapter`. + */ + LocalStorageAdapter.extend = extend; + + addHiddenPropsToTarget(LocalStorageAdapter.prototype, { + /** + * @name LocalStorageAdapter#afterCreate + * @method + */ + afterCreate: noop2, + + /** + * @name LocalStorageAdapter#afterCreateMany + * @method + */ + afterCreateMany: noop2, + + /** + * @name LocalStorageAdapter#afterDEL + * @method + */ + afterDEL: noop2, + + /** + * @name LocalStorageAdapter#afterDestroy + * @method + */ + afterDestroy: noop2, + + /** + * @name LocalStorageAdapter#afterDestroyAll + * @method + */ + afterDestroyAll: noop2, + + /** + * @name LocalStorageAdapter#afterFind + * @method + */ + afterFind: noop2, + + /** + * @name LocalStorageAdapter#afterFindAll + * @method + */ + afterFindAll: noop2, + + /** + * @name LocalStorageAdapter#afterGET + * @method + */ + afterGET: noop2, + + /** + * @name LocalStorageAdapter#afterPUT + * @method + */ + afterPUT: noop2, + + /** + * @name LocalStorageAdapter#afterUpdate + * @method + */ + afterUpdate: noop2, + + /** + * @name LocalStorageAdapter#afterUpdateAll + * @method + */ + afterUpdateAll: noop2, + + /** + * @name LocalStorageAdapter#afterUpdateMany + * @method + */ + afterUpdateMany: noop2, + + /** + * @name LocalStorageAdapter#beforeCreate + * @method + */ + beforeCreate: noop, + + /** + * @name LocalStorageAdapter#beforeCreateMany + * @method + */ + beforeCreateMany: noop, + + /** + * @name LocalStorageAdapter#beforeDEL + * @method + */ + beforeDEL: noop, + + /** + * @name LocalStorageAdapter#beforeDestroy + * @method + */ + beforeDestroy: noop, + + /** + * @name LocalStorageAdapter#beforeDestroyAll + * @method + */ + beforeDestroyAll: noop, + + /** + * @name LocalStorageAdapter#beforeFind + * @method + */ + beforeFind: noop, + + /** + * @name LocalStorageAdapter#beforeFindAll + * @method + */ + beforeFindAll: noop, + + /** + * @name LocalStorageAdapter#beforeGET + * @method + */ + beforeGET: noop, + + /** + * @name LocalStorageAdapter#beforePUT + * @method + */ + beforePUT: noop, + + /** + * @name LocalStorageAdapter#beforeUpdate + * @method + */ + beforeUpdate: noop, + + /** + * @name LocalStorageAdapter#beforeUpdateAll + * @method + */ + beforeUpdateAll: noop, + + /** + * @name LocalStorageAdapter#beforeUpdateMany + * @method + */ + beforeUpdateMany: noop, + + /** + * Create a new record. + * + * @name LocalStorageAdapter#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] TODO + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + + return createTask(function (success, failure) { + queueTask(function () { + var op = undefined; + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + var record = isUndefined(_props) ? props : _props; + var id = get(record, mapper.idAttribute) || guid(); + set(record, mapper.idAttribute, id); + var key = self.getIdPath(mapper, opts, id); + + // Create the record + // TODO: Create related records when the "with" option is provided + self.storage.setItem(key, toJson(record)); + self.ensureId(id, mapper, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return self[op](mapper, props, opts, record).then(function (_record) { + // Allow for re-assignment from lifecycle hook + record = isUndefined(_record) ? record : _record; + return opts.raw ? { + data: record, + created: 1 + } : record; + }); + }).then(success, failure); + }); + }); + }, + + + /** + * Create multiple records in a single batch. + * + * @name LocalStorageAdapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} props Array of records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] TODO + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + + return createTask(function (success, failure) { + queueTask(function () { + var op = undefined; + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + var records = isUndefined(_props) ? props : _props; + var idAttribute = mapper.idAttribute; + + // Create the record + // TODO: Create related records when the "with" option is provided + records.forEach(function (record) { + var id = get(record, idAttribute) || guid(); + set(record, idAttribute, id); + var key = self.getIdPath(mapper, opts, id); + self.storage.setItem(key, toJson(record)); + self.ensureId(id, mapper, opts); + }); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return self[op](mapper, props, opts, records).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? records : _records; + return opts.raw ? { + data: records, + created: records.length + } : records; + }); + }).then(success, failure); + }); + }); + }, + + + /** + * @name LocalStorageAdapter#dbg + * @method + */ + dbg: function dbg() { + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; } - }, { - key: 'getIds', - value: function getIds(resourceConfig, options) { - var ids = undefined; - var idsPath = this.getPath(resourceConfig, options); - var idsJson = this.storage.getItem(idsPath); - if (idsJson) { - ids = DSUtils.fromJson(idsJson); - } else { - ids = {}; + + this.log.apply(this, ['debug'].concat(args)); + }, + + + /** + * Destroy the record with the given primary key. + * + * @name LocalStorageAdapter#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] TODO + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + opts || (opts = {}); + + return createTask(function (success, failure) { + queueTask(function () { + var op = undefined; + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + self.dbg(op, id, opts); + // Destroy the record + // TODO: Destroy related records when the "with" option is provided + self.storage.removeItem(self.getIdPath(mapper, opts, id)); + self.removeId(id, mapper, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return self[op](mapper, id, opts).then(function (_id) { + // Allow for re-assignment from lifecycle hook + id = isUndefined(_id) ? id : _id; + return opts.raw ? { + data: id, + deleted: 1 + } : id; + }); + }).then(success, failure); + }); + }); + }, + + + /** + * Destroy the records that match the selection `query`. + * + * @name LocalStorageAdapter#destroyAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.raw=false] TODO + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + query || (query = {}); + opts || (opts = {}); + + return createTask(function (success, failure) { + queueTask(function () { + var op = undefined; + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + self.dbg(op, query, opts); + // Find the records that are to be destroyed + return self.findAll(mapper, query, opts); + }).then(function (records) { + var idAttribute = mapper.idAttribute; + // Gather IDs of records to be destroyed + var ids = records.map(function (record) { + return get(record, idAttribute); + }); + // Destroy each record + // TODO: Destroy related records when the "with" option is provided + ids.forEach(function (id) { + self.storage.removeItem(self.getIdPath(mapper, opts, id)); + }); + self.removeId(ids, mapper, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return self[op](mapper, query, opts, ids).then(function (_ids) { + // Allow for re-assignment from lifecycle hook + ids = isUndefined(_ids) ? ids : _ids; + return opts.raw ? { + data: ids, + deleted: records.length + } : ids; + }); + }).then(success, failure); + }); + }); + }, + + + /** + * TODO + * + * @name LocalStorageAdapter#ensureId + * @method + */ + ensureId: function ensureId(id, mapper, opts) { + var ids = this.getIds(mapper, opts); + if (isArray(id)) { + if (!id.length) { + return; } - return ids; + id.forEach(function (_id) { + ids[_id] = 1; + }); + } else { + ids[id] = 1; } - }, { - key: 'saveKeys', - value: function saveKeys(ids, resourceConfig, options) { - var idsPath = this.getPath(resourceConfig, options); - if (!DSUtils.isEmpty(ids)) { - this.storage.setItem(idsPath, DSUtils.toJson(ids)); - } else { - this.storage.removeItem(idsPath); + this.saveKeys(ids, mapper, opts); + }, + + + /** + * Retrieve the record with the given primary key. + * + * @name LocalStorageAdapter#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] TODO + * @param {string[]} [opts.with=[]] TODO + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + var record = undefined, + op = undefined; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + self.dbg(op, id, opts); + var key = self.getIdPath(mapper, opts, id); + record = self.storage.getItem(key); + if (isUndefined(record)) { + record = undefined; + return; } - } - }, { - key: 'ensureId', - value: function ensureId(id, resourceConfig, options) { - var ids = this.getIds(resourceConfig, options); - if (DSUtils.isArray(id)) { - if (!id.length) { - return; + record = fromJson(record); + var tasks = []; + var relationList = mapper.relationList || []; + + relationList.forEach(function (def) { + var relationName = def.relation; + var relatedMapper = def.getRelation(); + var containedName = null; + if (opts.with.indexOf(relationName) !== -1) { + containedName = relationName; + } else if (opts.with.indexOf(def.localField) !== -1) { + containedName = def.localField; } - DSUtils.forEach(id, function (_id) { - ids[_id] = 1; - }); - } else { - ids[id] = 1; - } - this.saveKeys(ids, resourceConfig, options); - } - }, { - key: 'removeId', - value: function removeId(id, resourceConfig, options) { - var ids = this.getIds(resourceConfig, options); - if (DSUtils.isArray(id)) { - if (!id.length) { + if (!containedName) { return; } - DSUtils.forEach(id, function (_id) { - delete ids[_id]; + var __opts = copy(opts); + __opts.with = opts.with.slice(); + fillIn(__opts, relatedMapper); + var index = __opts.with.indexOf(containedName); + if (index >= 0) { + __opts.with.splice(index, 1); + } + __opts.with.forEach(function (relation, i) { + if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { + __opts.with[i] = relation.substr(containedName.length + 1); + } else { + __opts.with[i] = ''; + } }); - } else { - delete ids[id]; - } - this.saveKeys(ids, resourceConfig, options); - } - }, { - key: 'GET', - value: function GET(key) { - var _this = this; - - return new DSUtils.Promise(function (resolve) { - var item = _this.storage.getItem(key); - resolve(item ? DSUtils.fromJson(item) : undefined); + + var task = undefined; + + if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { + task = self.findAll(relatedMapper, _defineProperty({}, def.foreignKey, get(record, mapper.idAttribute)), __opts).then(function (relatedItems) { + if (def.type === 'hasOne' && relatedItems.length) { + set(record, def.localField, relatedItems[0]); + } else { + set(record, def.localField, relatedItems); + } + return relatedItems; + }); + } else if (def.type === 'hasMany' && def.localKeys) { + var localKeys = []; + var itemKeys = get(record, def.localKeys) || []; + itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + localKeys = localKeys.concat(itemKeys || []); + task = self.findAll(relatedMapper, { + where: _defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + set(record, def.localField, relatedItems); + return relatedItems; + }); + } else if (def.type === 'belongsTo') { + task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) { + set(record, def.localField, relatedItem); + return relatedItem; + }); + } + + if (task) { + tasks.push(task); + } }); - } - }, { - key: 'PUT', - value: function PUT(key, value) { - var _this2 = this; - - var DSLocalStorageAdapter = this; - return DSLocalStorageAdapter.GET(key).then(function (item) { - if (item) { - DSUtils.deepMixIn(item, DSUtils.removeCircular(value)); + + return Promise.all(tasks); + }).then(function () { + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return resolve(self[op](mapper, id, opts, record)).then(function (_record) { + // Allow for re-assignment from lifecycle hook + record = isUndefined(_record) ? record : _record; + return opts.raw ? { + data: record, + found: record ? 1 : 0 + } : record; + }); + }); + }, + + + /** + * Retrieve the records that match the selection `query`. + * + * @name LocalStorageAdapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] TODO + * @param {string[]} [opts.with=[]] TODO + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + var records = []; + var op = undefined; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + self.dbg(op, query, opts); + + // Load all records into memory... + var ids = self.getIds(mapper, opts); + forOwn(ids, function (value, id) { + var json = self.storage.getItem(self.getIdPath(mapper, opts, id)); + if (json) { + records.push(fromJson(json)); } - _this2.storage.setItem(key, DSUtils.toJson(item || value)); - return DSLocalStorageAdapter.GET(key); }); - } - }, { - key: 'DEL', - value: function DEL(key) { - var _this3 = this; - - return new DSUtils.Promise(function (resolve) { - _this3.storage.removeItem(key); - resolve(); + var idAttribute = mapper.idAttribute; + // TODO: Verify that this collection gets properly garbage collected + // TODO: Or, find a way to filter without using Collection + var _query = new Query({ + index: { + getAll: function getAll() { + return records; + } + } }); - } - }, { - key: 'find', - value: function find(resourceConfig, id, options) { - var _this4 = this; - - var instance = undefined; - options = options || {}; - options.with = options.with || []; - return new DSUtils.Promise(function (resolve, reject) { - _this4.GET(_this4.getIdPath(resourceConfig, options || {}, id)).then(function (item) { - return !item ? reject(new Error('Not Found!')) : item; - }).then(function (_instance) { - instance = _instance; - var tasks = []; - - DSUtils.forEach(resourceConfig.relationList, function (def) { - var relationName = def.relation; - var relationDef = resourceConfig.getResource(relationName); - var containedName = null; - if (DSUtils.contains(options.with, relationName)) { - containedName = relationName; - } else if (DSUtils.contains(options.with, def.localField)) { - containedName = def.localField; - } - if (containedName) { - (function () { - var __options = DSUtils.deepMixIn({}, options.orig ? options.orig() : options); - __options.with = options.with.slice(); - __options = DSUtils._(relationDef, __options); - DSUtils.remove(__options.with, containedName); - DSUtils.forEach(__options.with, function (relation, i) { - if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { - __options.with[i] = relation.substr(containedName.length + 1); - } else { - __options.with[i] = ''; - } - }); - - var task = undefined; - - if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { - task = _this4.findAll(resourceConfig.getResource(relationName), { - where: _defineProperty({}, def.foreignKey, { - '==': instance[resourceConfig.idAttribute] - }) - }, __options).then(function (relatedItems) { - if (def.type === 'hasOne' && relatedItems.length) { - DSUtils.set(instance, def.localField, relatedItems[0]); - } else { - DSUtils.set(instance, def.localField, relatedItems); - } - return relatedItems; - }); - } else if (def.type === 'hasMany' && def.localKeys) { - var localKeys = []; - var itemKeys = instance[def.localKeys] || []; - itemKeys = Array.isArray(itemKeys) ? itemKeys : DSUtils.keys(itemKeys); - localKeys = localKeys.concat(itemKeys || []); - task = _this4.findAll(resourceConfig.getResource(relationName), { - where: _defineProperty({}, relationDef.idAttribute, { - 'in': DSUtils.filter(unique(localKeys), function (x) { - return x; - }) - }) - }, __options).then(function (relatedItems) { - DSUtils.set(instance, def.localField, relatedItems); - return relatedItems; - }); - } else if (def.type === 'belongsTo' || def.type === 'hasOne' && def.localKey) { - task = _this4.find(resourceConfig.getResource(relationName), DSUtils.get(instance, def.localKey), __options).then(function (relatedItem) { - DSUtils.set(instance, def.localField, relatedItem); - return relatedItem; - }); - } - - if (task) { - tasks.push(task); + records = _query.filter(query).run(); + var tasks = []; + var relationList = mapper.relationList || []; + + relationList.forEach(function (def) { + var relationName = def.relation; + var relatedMapper = def.getRelation(); + var containedName = null; + if (opts.with.indexOf(relationName) !== -1) { + containedName = relationName; + } else if (opts.with.indexOf(def.localField) !== -1) { + containedName = def.localField; + } + if (!containedName) { + return; + } + var __opts = copy(opts); + __opts.with = opts.with.slice(); + fillIn(__opts, relatedMapper); + var index = __opts.with.indexOf(containedName); + if (index >= 0) { + __opts.with.splice(index, 1); + } + __opts.with.forEach(function (relation, i) { + if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { + __opts.with[i] = relation.substr(containedName.length + 1); + } else { + __opts.with[i] = ''; + } + }); + + var task = undefined; + + if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { + task = self.findAll(relatedMapper, { + where: _defineProperty({}, def.foreignKey, { + 'in': records.map(function (item) { + return get(item, idAttribute); + }).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + relatedItems.forEach(function (relatedItem) { + if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) { + attached.push(relatedItem); } - })(); - } + }); + if (def.type === 'hasOne' && attached.length) { + set(item, def.localField, attached[0]); + } else { + set(item, def.localField, attached); + } + }); + return relatedItems; }); - - return DSUtils.Promise.all(tasks); - }).then(function () { - return resolve(instance); - }).catch(reject); - }); - } - }, { - key: 'findAll', - value: function findAll(resourceConfig, params, options) { - var _this5 = this; - - var items = null; - options = options || {}; - options.with = options.with || []; - return new DSUtils.Promise(function (resolve, reject) { - try { + } else if (def.type === 'hasMany' && def.localKeys) { (function () { - options = options || {}; - if (!('allowSimpleWhere' in options)) { - options.allowSimpleWhere = true; - } - var items = []; - var ids = DSUtils.keys(_this5.getIds(resourceConfig, options)); - DSUtils.forEach(ids, function (id) { - var itemJson = _this5.storage.getItem(_this5.getIdPath(resourceConfig, options, id)); - if (itemJson) { - items.push(DSUtils.fromJson(itemJson)); - } + var localKeys = []; + records.forEach(function (item) { + var itemKeys = get(item, def.localKeys) || []; + itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + localKeys = localKeys.concat(itemKeys || []); + }); + task = self.findAll(relatedMapper, { + where: _defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + var itemKeys = get(item, def.localKeys) || []; + itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem); + } + }); + set(item, def.localField, attached); + }); + return relatedItems; }); - resolve(filter.call(emptyStore, items, resourceConfig.name, params, options)); })(); - } catch (err) { - reject(err); - } - }).then(function (_items) { - items = _items; - var tasks = []; - DSUtils.forEach(resourceConfig.relationList, function (def) { - var relationName = def.relation; - var relationDef = resourceConfig.getResource(relationName); - var containedName = null; - if (DSUtils.contains(options.with, relationName)) { - containedName = relationName; - } else if (DSUtils.contains(options.with, def.localField)) { - containedName = def.localField; - } - if (containedName) { - (function () { - var __options = DSUtils.deepMixIn({}, options.orig ? options.orig() : options); - __options.with = options.with.slice(); - __options = DSUtils._(relationDef, __options); - DSUtils.remove(__options.with, containedName); - DSUtils.forEach(__options.with, function (relation, i) { - if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { - __options.with[i] = relation.substr(containedName.length + 1); - } else { - __options.with[i] = ''; + } else if (def.type === 'belongsTo') { + task = self.findAll(relatedMapper, { + where: _defineProperty({}, relatedMapper.idAttribute, { + 'in': records.map(function (item) { + return get(item, def.foreignKey); + }).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) { + set(item, def.localField, relatedItem); } }); - - var task = undefined; - - if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { - task = _this5.findAll(resourceConfig.getResource(relationName), { - where: _defineProperty({}, def.foreignKey, { - 'in': DSUtils.filter(map(items, function (item) { - return DSUtils.get(item, resourceConfig.idAttribute); - }), function (x) { - return x; - }) - }) - }, __options).then(function (relatedItems) { - DSUtils.forEach(items, function (item) { - var attached = []; - DSUtils.forEach(relatedItems, function (relatedItem) { - if (DSUtils.get(relatedItem, def.foreignKey) === item[resourceConfig.idAttribute]) { - attached.push(relatedItem); - } - }); - if (def.type === 'hasOne' && attached.length) { - DSUtils.set(item, def.localField, attached[0]); - } else { - DSUtils.set(item, def.localField, attached); - } - }); - return relatedItems; - }); - } else if (def.type === 'hasMany' && def.localKeys) { - (function () { - var localKeys = []; - DSUtils.forEach(items, function (item) { - var itemKeys = item[def.localKeys] || []; - itemKeys = Array.isArray(itemKeys) ? itemKeys : DSUtils.keys(itemKeys); - localKeys = localKeys.concat(itemKeys || []); - }); - task = _this5.findAll(resourceConfig.getResource(relationName), { - where: _defineProperty({}, relationDef.idAttribute, { - 'in': DSUtils.filter(unique(localKeys), function (x) { - return x; - }) - }) - }, __options).then(function (relatedItems) { - DSUtils.forEach(items, function (item) { - var attached = []; - var itemKeys = item[def.localKeys] || []; - itemKeys = Array.isArray(itemKeys) ? itemKeys : DSUtils.keys(itemKeys); - DSUtils.forEach(relatedItems, function (relatedItem) { - if (itemKeys && DSUtils.contains(itemKeys, relatedItem[relationDef.idAttribute])) { - attached.push(relatedItem); - } - }); - DSUtils.set(item, def.localField, attached); - }); - return relatedItems; - }); - })(); - } else if (def.type === 'belongsTo' || def.type === 'hasOne' && def.localKey) { - task = _this5.findAll(resourceConfig.getResource(relationName), { - where: _defineProperty({}, relationDef.idAttribute, { - 'in': DSUtils.filter(map(items, function (item) { - return DSUtils.get(item, def.localKey); - }), function (x) { - return x; - }) - }) - }, __options).then(function (relatedItems) { - DSUtils.forEach(items, function (item) { - DSUtils.forEach(relatedItems, function (relatedItem) { - if (relatedItem[relationDef.idAttribute] === item[def.localKey]) { - DSUtils.set(item, def.localField, relatedItem); - } - }); - }); - return relatedItems; - }); - } - - if (task) { - tasks.push(task); - } - })(); - } - }); - return DSUtils.Promise.all(tasks); - }).then(function () { - return items; + }); + return relatedItems; + }); + } + + if (task) { + tasks.push(task); + } }); - } - }, { - key: 'create', - value: function create(resourceConfig, attrs, options) { - var _this6 = this; - - return createTask(function (resolve, reject) { - queueTask(function () { - attrs[resourceConfig.idAttribute] = attrs[resourceConfig.idAttribute] || guid(); - options = options || {}; - _this6.PUT(DSUtils.makePath(_this6.getIdPath(resourceConfig, options, attrs[resourceConfig.idAttribute])), DSUtils.omit(attrs, resourceConfig.relationFields || [])).then(function (item) { - _this6.ensureId(item[resourceConfig.idAttribute], resourceConfig, options); - resolve(item); - }).catch(reject); - }); + return Promise.all(tasks); + }).then(function () { + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return resolve(self[op](mapper, query, opts, records)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? records : _records; + return opts.raw ? { + data: records, + found: records.length + } : records; }); + }); + }, + + + /** + * TODO + * + * @name LocalStorageAdapter#getPath + * @method + */ + getPath: function getPath(mapper, opts) { + opts = opts || {}; + return makePath(opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, mapper.name); + }, + + + /** + * TODO + * + * @name LocalStorageAdapter#getIdPath + * @method + */ + getIdPath: function getIdPath(mapper, opts, id) { + opts = opts || {}; + return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id); + }, + + + /** + * TODO + * + * @name LocalStorageAdapter#getIds + * @method + */ + getIds: function getIds(mapper, opts) { + var ids = undefined; + var idsPath = this.getPath(mapper, opts); + var idsJson = this.storage.getItem(idsPath); + if (idsJson) { + ids = fromJson(idsJson); + } else { + ids = {}; } - }, { - key: 'createMany', - value: function createMany(resourceConfig, items, options) { - var _this7 = this; - - return createTask(function (resolve, reject) { - queueTask(function () { - var tasks = []; - var ids = []; - DSUtils.forEach(items, function (attrs) { - var id = attrs[resourceConfig.idAttribute] = attrs[resourceConfig.idAttribute] || guid(); - ids.push(id); - options = options || {}; - tasks.push(_this7.PUT(DSUtils.makePath(_this7.getIdPath(resourceConfig, options, id)), DSUtils.omit(attrs, resourceConfig.relationFields || []))); - }); - _this7.ensureId(ids, resourceConfig, options); - return DSUtils.Promise.all(tasks).then(resolve).catch(reject); - }); - }); + return ids; + }, + + + /** + * TODO + * + * @name LocalStorageAdapter#log + * @method + */ + log: function log(level) { + for (var _len5 = arguments.length, args = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { + args[_key5 - 1] = arguments[_key5]; } - }, { - key: 'update', - value: function update(resourceConfig, id, attrs, options) { - var _this8 = this; - - return createTask(function (resolve, reject) { - queueTask(function () { - options = options || {}; - _this8.PUT(_this8.getIdPath(resourceConfig, options, id), DSUtils.omit(attrs, resourceConfig.relationFields || [])).then(function (item) { - _this8.ensureId(item[resourceConfig.idAttribute], resourceConfig, options); - resolve(item); - }).catch(reject); - }); - }); + + if (level && !args.length) { + args.push(level); + level = 'debug'; } - }, { - key: 'updateAll', - value: function updateAll(resourceConfig, attrs, params, options) { - var _this9 = this; - - return this.findAll(resourceConfig, params, options).then(function (items) { - var tasks = []; - DSUtils.forEach(items, function (item) { - return tasks.push(_this9.update(resourceConfig, item[resourceConfig.idAttribute], DSUtils.omit(attrs, resourceConfig.relationFields || []), options)); - }); - return DSUtils.Promise.all(tasks); - }); + if (level === 'debug' && !this.debug) { + return; } - }, { - key: 'destroy', - value: function destroy(resourceConfig, id, options) { - var _this10 = this; - - return createTask(function (resolve, reject) { - queueTask(function () { - options = options || {}; - _this10.DEL(_this10.getIdPath(resourceConfig, options, id)).then(function () { - return _this10.removeId(id, resourceConfig, options); - }).then(function () { - return resolve(null); - }, reject); - }); + var prefix = level.toUpperCase() + ': (LocalStorageAdapter)'; + if (console[level]) { + var _console; + + (_console = console)[level].apply(_console, [prefix].concat(args)); + } else { + var _console2; + + (_console2 = console).log.apply(_console2, [prefix].concat(args)); + } + }, + + + /** + * TODO + * + * @name LocalStorageAdapter#removeId + * @method + */ + removeId: function removeId(id, mapper, opts) { + var ids = this.getIds(mapper, opts); + if (isArray(id)) { + if (!id.length) { + return; + } + id.forEach(function (_id) { + delete ids[_id]; }); + } else { + delete ids[id]; } - }, { - key: 'destroyAll', - value: function destroyAll(resourceConfig, params, options) { - var _this11 = this; - - return this.findAll(resourceConfig, params, options).then(function (items) { - var ids = []; - DSUtils.forEach(items, function (item) { - var id = item[resourceConfig.idAttribute]; - ids.push(id); - _this11.storage.removeItem(_this11.getIdPath(resourceConfig, options, id)); - }); - _this11.removeId(ids, resourceConfig, options); - return ids; + this.saveKeys(ids, mapper, opts); + }, + + + /** + * TODO + * + * @name LocalStorageAdapter#saveKeys + * @method + */ + saveKeys: function saveKeys(ids, mapper, opts) { + ids = ids || {}; + var idsPath = this.getPath(mapper, opts); + if (Object.keys(ids).length) { + this.storage.setItem(idsPath, toJson(ids)); + } else { + this.storage.removeItem(idsPath); + } + }, + + + /** + * Update the records that match the selection `query`. If a record with the + * specified primary key cannot be found then no update is performed and the + * promise is resolved with `undefined`. + * + * @name LocalStorageAdapter#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] TODO + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + + return createTask(function (success, failure) { + queueTask(function () { + var op = undefined; + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return resolve(self[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = isUndefined(_props) ? props : _props; + var key = self.getIdPath(mapper, opts, id); + var record = self.storage.getItem(key); + record = record ? fromJson(record) : undefined; + var updated = 0; + + // Update the record + // TODO: Update related records when the "with" option is provided + if (record) { + deepMixIn(record, props); + self.storage.setItem(key, toJson(record)); + updated++; + } + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return self[op](mapper, id, props, opts, record).then(function (_record) { + // Allow for re-assignment from lifecycle hook + record = isUndefined(_record) ? record : _record; + return opts.raw ? { + data: record, + updated: updated + } : record; + }); + }).then(success, failure); + }); + }); + }, + + + /** + * Update the records that match the selection `query`. + * + * @name LocalStorageAdapter#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} [opts] Configuration options. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + + return createTask(function (success, failure) { + queueTask(function () { + var op = undefined; + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return resolve(self[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = isUndefined(_props) ? props : _props; + op = opts.op = 'updateAll'; + self.dbg(op, query, opts); + + // Find the records that are to be updated + return self.findAll(mapper, query, opts); + }).then(function (records) { + var idAttribute = mapper.idAttribute; + var updated = 0; + + // Update each record + // TODO: Update related records when the "with" option is provided + records.forEach(function (record) { + record || (record = {}); + var id = get(record, idAttribute); + var key = self.getIdPath(mapper, opts, id); + deepMixIn(record, props); + self.storage.setItem(key, toJson(record)); + updated++; + }); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return self[op](mapper, props, query, opts, records).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? records : _records; + return opts.raw ? { + data: records, + updated: updated + } : records; + }); + }).then(success, failure); + }); + }); + }, + + + /** + * Update the given records in a single batch. + * + * @name LocalStorageAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] TODO + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + records || (records = []); + opts || (opts = {}); + + return createTask(function (success, failure) { + queueTask(function () { + var op = undefined; + var updatedRecords = []; + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return resolve(self[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? records : _records; + op = opts.op = 'updateMany'; + self.dbg(op, records, opts); + + var idAttribute = mapper.idAttribute; + + // Update each record + // TODO: Update related records when the "with" option is provided + records.forEach(function (record) { + if (!record) { + return; + } + var id = get(record, idAttribute); + if (isUndefined(id)) { + return; + } + var key = self.getIdPath(mapper, opts, id); + var json = self.storage.getItem(key); + var existingRecord = json ? fromJson(json) : undefined; + if (!existingRecord) { + return; + } + deepMixIn(existingRecord, record); + self.storage.setItem(key, toJson(existingRecord)); + updatedRecords.push(existingRecord); + }); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return self[op](mapper, records, opts, updatedRecords).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? updatedRecords : _records; + return opts.raw ? { + data: records, + updated: updatedRecords.length + } : records; + }); + }).then(success, failure); }); - } - }]); - - return DSLocalStorageAdapter; - })(); - - DSLocalStorageAdapter.version = { - full: '2.3.2', - major: parseInt('2', 10), - minor: parseInt('3', 10), - patch: parseInt('2', 10), - alpha: true ? 'false' : false, + }); + } + }); + + /** + * Details of the current version of the `js-data-localstorage` module. + * + * @name LocalStorageAdapter.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. + */ + LocalStorageAdapter.version = { + full: '3.0.0-alpha.1', + major: parseInt('3', 10), + minor: parseInt('0', 10), + patch: parseInt('0', 10), + alpha: true ? '1' : false, beta: true ? 'false' : false }; - - module.exports = DSLocalStorageAdapter; + + /** + * Registered as `js-data-localstorage` in NPM and Bower. + * + * __Script tag__: + * ```javascript + * window.LocalStorageAdapter + * ``` + * __CommonJS__: + * ```javascript + * var LocalStorageAdapter = require('js-data-localstorage') + * ``` + * __ES6 Modules__: + * ```javascript + * import LocalStorageAdapter from 'js-data-localstorage' + * ``` + * __AMD__: + * ```javascript + * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... }) + * ``` + * + * @module js-data-localstorage + */ + + module.exports = LocalStorageAdapter; /***/ }, /* 1 */ @@ -590,7 +1262,7 @@ return /******/ (function(modules) { // webpackBootstrap var randHex = __webpack_require__(3); var choice = __webpack_require__(4); - + /** * Returns pseudo-random guid (UUID v4) * IMPORTANT: it's not totally "safe" since randHex/choice uses Math.random @@ -611,7 +1283,7 @@ return /******/ (function(modules) { // webpackBootstrap ); } module.exports = guid; - + /***/ }, @@ -619,9 +1291,9 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports, __webpack_require__) { var choice = __webpack_require__(4); - + var _chars = '0123456789abcdef'.split(''); - + /** * Returns a random hexadecimal string */ @@ -633,10 +1305,10 @@ return /******/ (function(modules) { // webpackBootstrap } return str; } - + module.exports = randHex; - - + + /***/ }, @@ -645,7 +1317,7 @@ return /******/ (function(modules) { // webpackBootstrap var randInt = __webpack_require__(5); var isArray = __webpack_require__(10); - + /** * Returns a random element from the supplied arguments * or from the array (if single argument is an array). @@ -654,10 +1326,10 @@ return /******/ (function(modules) { // webpackBootstrap var target = (arguments.length === 1 && isArray(items))? items : arguments; return target[ randInt(0, target.length - 1) ]; } - + module.exports = choice; - - + + /***/ }, @@ -667,7 +1339,7 @@ return /******/ (function(modules) { // webpackBootstrap var MIN_INT = __webpack_require__(6); var MAX_INT = __webpack_require__(7); var rand = __webpack_require__(8); - + /** * Gets random integer inside range or snap to min/max values. */ @@ -679,9 +1351,9 @@ return /******/ (function(modules) { // webpackBootstrap // -0.5 and + 0.49 are required to avoid bias caused by rounding return Math.round( rand(min - 0.5, max + 0.499999999999) ); } - + module.exports = randInt; - + /***/ }, @@ -691,9 +1363,9 @@ return /******/ (function(modules) { // webpackBootstrap /** * @constant Minimum 32-bit signed integer value (-2^31). */ - + module.exports = -2147483648; - + /***/ }, @@ -703,9 +1375,9 @@ return /******/ (function(modules) { // webpackBootstrap /** * @constant Maximum 32-bit signed integer value. (2^31 - 1) */ - + module.exports = 2147483647; - + /***/ }, @@ -715,7 +1387,7 @@ return /******/ (function(modules) { // webpackBootstrap var random = __webpack_require__(9); var MIN_INT = __webpack_require__(6); var MAX_INT = __webpack_require__(7); - + /** * Returns random number inside range */ @@ -724,9 +1396,9 @@ return /******/ (function(modules) { // webpackBootstrap max = max == null? MAX_INT : max; return min + (max - min) * random(); } - + module.exports = rand; - + /***/ }, @@ -734,7 +1406,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports) { - + /** * Just a wrapper to Math.random. No methods inside mout/random should call * Math.random() directly so we can inject the pseudo-random number @@ -744,13 +1416,13 @@ return /******/ (function(modules) { // webpackBootstrap function random(){ return random.get(); } - + // we expose the method so it can be swapped if needed random.get = Math.random; - + module.exports = random; - - + + /***/ }, @@ -764,7 +1436,7 @@ return /******/ (function(modules) { // webpackBootstrap return isKind(val, 'Array'); }; module.exports = isArray; - + /***/ }, @@ -779,7 +1451,7 @@ return /******/ (function(modules) { // webpackBootstrap return kindOf(val) === kind; } module.exports = isKind; - + /***/ }, @@ -787,11 +1459,11 @@ return /******/ (function(modules) { // webpackBootstrap /***/ function(module, exports) { - + var _rKind = /^\[object (.*)\]$/, _toString = Object.prototype.toString, UNDEF; - + /** * Gets the "kind" of value. (e.g. "String", "Number", etc) */ @@ -805,365 +1477,11 @@ return /******/ (function(modules) { // webpackBootstrap } } module.exports = kindOf; - - - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - var filter = __webpack_require__(14); - - /** - * @return {array} Array of unique items - */ - function unique(arr, compare){ - compare = compare || isEqual; - return filter(arr, function(item, i, arr){ - var n = arr.length; - while (++i < n) { - if ( compare(item, arr[i]) ) { - return false; - } - } - return true; - }); - } - - function isEqual(a, b){ - return a === b; - } - - module.exports = unique; - - - - -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { - - var makeIterator = __webpack_require__(15); - - /** - * Array filter - */ - function filter(arr, callback, thisObj) { - callback = makeIterator(callback, thisObj); - var results = []; - if (arr == null) { - return results; - } - - var i = -1, len = arr.length, value; - while (++i < len) { - value = arr[i]; - if (callback(value, i, arr)) { - results.push(value); - } - } - - return results; - } - - module.exports = filter; - - - - -/***/ }, -/* 15 */ -/***/ function(module, exports, __webpack_require__) { - - var identity = __webpack_require__(16); - var prop = __webpack_require__(17); - var deepMatches = __webpack_require__(18); - - /** - * Converts argument into a valid iterator. - * Used internally on most array/object/collection methods that receives a - * callback/iterator providing a shortcut syntax. - */ - function makeIterator(src, thisObj){ - if (src == null) { - return identity; - } - switch(typeof src) { - case 'function': - // function is the first to improve perf (most common case) - // also avoid using `Function#call` if not needed, which boosts - // perf a lot in some cases - return (typeof thisObj !== 'undefined')? function(val, i, arr){ - return src.call(thisObj, val, i, arr); - } : src; - case 'object': - return function(val){ - return deepMatches(val, src); - }; - case 'string': - case 'number': - return prop(src); - } - } - - module.exports = makeIterator; - - - - -/***/ }, -/* 16 */ -/***/ function(module, exports) { - - - - /** - * Returns the first argument provided to it. - */ - function identity(val){ - return val; - } - - module.exports = identity; - - - - -/***/ }, -/* 17 */ -/***/ function(module, exports) { - - - - /** - * Returns a function that gets a property of the passed object - */ - function prop(name){ - return function(obj){ - return obj[name]; - }; - } - - module.exports = prop; - - - - -/***/ }, -/* 18 */ -/***/ function(module, exports, __webpack_require__) { - - var forOwn = __webpack_require__(19); - var isArray = __webpack_require__(10); - - function containsMatch(array, pattern) { - var i = -1, length = array.length; - while (++i < length) { - if (deepMatches(array[i], pattern)) { - return true; - } - } - - return false; - } - - function matchArray(target, pattern) { - var i = -1, patternLength = pattern.length; - while (++i < patternLength) { - if (!containsMatch(target, pattern[i])) { - return false; - } - } - - return true; - } - - function matchObject(target, pattern) { - var result = true; - forOwn(pattern, function(val, key) { - if (!deepMatches(target[key], val)) { - // Return false to break out of forOwn early - return (result = false); - } - }); - - return result; - } - - /** - * Recursively check if the objects match. - */ - function deepMatches(target, pattern){ - if (target && typeof target === 'object') { - if (isArray(target) && isArray(pattern)) { - return matchArray(target, pattern); - } else { - return matchObject(target, pattern); - } - } else { - return target === pattern; - } - } - - module.exports = deepMatches; - - - - -/***/ }, -/* 19 */ -/***/ function(module, exports, __webpack_require__) { - - var hasOwn = __webpack_require__(20); - var forIn = __webpack_require__(21); - - /** - * Similar to Array/forEach but works over object properties and fixes Don't - * Enum bug on IE. - * based on: http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation - */ - function forOwn(obj, fn, thisObj){ - forIn(obj, function(val, key){ - if (hasOwn(obj, key)) { - return fn.call(thisObj, obj[key], key, obj); - } - }); - } - - module.exports = forOwn; - - - - -/***/ }, -/* 20 */ -/***/ function(module, exports) { - - /** - * Safer Object.hasOwnProperty - */ - function hasOwn(obj, prop){ - return Object.prototype.hasOwnProperty.call(obj, prop); - } - - module.exports = hasOwn; - - - - -/***/ }, -/* 21 */ -/***/ function(module, exports, __webpack_require__) { - - var hasOwn = __webpack_require__(20); - - var _hasDontEnumBug, - _dontEnums; - - function checkDontEnum(){ - _dontEnums = [ - 'toString', - 'toLocaleString', - 'valueOf', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'constructor' - ]; - - _hasDontEnumBug = true; - - for (var key in {'toString': null}) { - _hasDontEnumBug = false; - } - } - - /** - * Similar to Array/forEach but works over object properties and fixes Don't - * Enum bug on IE. - * based on: http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation - */ - function forIn(obj, fn, thisObj){ - var key, i = 0; - // no need to check if argument is a real object that way we can use - // it for arrays, functions, date, etc. - - //post-pone check till needed - if (_hasDontEnumBug == null) checkDontEnum(); - - for (key in obj) { - if (exec(fn, obj, key, thisObj) === false) { - break; - } - } - - - if (_hasDontEnumBug) { - var ctor = obj.constructor, - isProto = !!ctor && obj === ctor.prototype; - - while (key = _dontEnums[i++]) { - // For constructor, if it is a prototype object the constructor - // is always non-enumerable unless defined otherwise (and - // enumerated above). For non-prototype objects, it will have - // to be defined on this object, since it cannot be defined on - // any prototype objects. - // - // For other [[DontEnum]] properties, check if the value is - // different than Object prototype value. - if ( - (key !== 'constructor' || - (!isProto && hasOwn(obj, key))) && - obj[key] !== Object.prototype[key] - ) { - if (exec(fn, obj, key, thisObj) === false) { - break; - } - } - } - } - } - - function exec(fn, obj, key, thisObj){ - return fn.call(thisObj, obj[key], key, obj); - } - - module.exports = forIn; - - - - -/***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { - - var makeIterator = __webpack_require__(15); - - /** - * Array map - */ - function map(arr, callback, thisObj) { - callback = makeIterator(callback, thisObj); - var results = []; - if (arr == null){ - return results; - } - - var i = -1, len = arr.length; - while (++i < len) { - results[i] = callback(arr[i], i, arr); - } - - return results; - } - - module.exports = map; - - /***/ } /******/ ]) }); -; \ No newline at end of file +; +//# sourceMappingURL=js-data-localstorage.js.map \ No newline at end of file diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map new file mode 100644 index 0000000..8176a51 --- /dev/null +++ b/dist/js-data-localstorage.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap fbe6266b96afe5f0f650","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;A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AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 fbe6266b96afe5f0f650\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n copy,\n deepMixIn,\n extend,\n fillIn,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDEL\n * @method\n */\n afterDEL: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterGET\n * @method\n */\n afterGET: noop2,\n\n /**\n * @name LocalStorageAdapter#afterPUT\n * @method\n */\n afterPUT: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDEL\n * @method\n */\n beforeDEL: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeGET\n * @method\n */\n beforeGET: noop,\n\n /**\n * @name LocalStorageAdapter#beforePUT\n * @method\n */\n beforePUT: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n const id = get(record, mapper.idAttribute) || guid()\n set(record, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(record))\n self.ensureId(id, mapper, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n const idAttribute = mapper.idAttribute\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n records.forEach(function (record) {\n const id = get(record, idAttribute) || guid()\n set(record, idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n self.storage.setItem(key, toJson(record))\n self.ensureId(id, mapper, opts)\n })\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return self[op](mapper, id, opts).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: id,\n deleted: 1\n } : id\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (isUndefined(record)) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n const relationList = mapper.relationList || []\n\n relationList.forEach(function (def) {\n const relationName = def.relation\n const relatedMapper = def.getRelation()\n let containedName = null\n if (opts.with.indexOf(relationName) !== -1) {\n containedName = relationName\n } else if (opts.with.indexOf(def.localField) !== -1) {\n containedName = def.localField\n }\n if (!containedName) {\n return\n }\n let __opts = copy(opts)\n __opts.with = opts.with.slice()\n fillIn(__opts, relatedMapper)\n const index = __opts.with.indexOf(containedName)\n if (index >= 0) {\n __opts.with.splice(index, 1)\n }\n __opts.with.forEach(function (relation, i) {\n if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {\n __opts.with[i] = relation.substr(containedName.length + 1)\n } else {\n __opts.with[i] = ''\n }\n })\n\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n const relationList = mapper.relationList || []\n\n relationList.forEach(function (def) {\n const relationName = def.relation\n const relatedMapper = def.getRelation()\n let containedName = null\n if (opts.with.indexOf(relationName) !== -1) {\n containedName = relationName\n } else if (opts.with.indexOf(def.localField) !== -1) {\n containedName = def.localField\n }\n if (!containedName) {\n return\n }\n let __opts = copy(opts)\n __opts.with = opts.with.slice()\n fillIn(__opts, relatedMapper)\n const index = __opts.with.indexOf(containedName)\n if (index >= 0) {\n __opts.with.splice(index, 1)\n }\n __opts.with.forEach(function (relation, i) {\n if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {\n __opts.with[i] = relation.substr(containedName.length + 1)\n } else {\n __opts.with[i] = ''\n }\n })\n\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return self[op](mapper, id, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index bed89ba..0675c90 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -1,11 +1,11 @@ /*! * js-data-localstorage -* @version 2.3.2 - Homepage +* @version 3.0.0-alpha.1 - Homepage * @author Jason Dobry -* @copyright (c) 2014-2015 Jason Dobry +* @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.DSLocalStorageAdapter=e(require("js-data")):t.DSLocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){m.push(t)}function u(){m.length&&!b&&(b=!0,m[0]())}function a(t){m.length?i(t):(i(t),u())}function c(t){return new p.Promise(t).then(function(t){return b=!1,m.shift(),setTimeout(u,0),t},function(t){return b=!1,m.shift(),setTimeout(u,0),p.Promise.reject(t)})}var f=function(){function t(t,e){for(var n=0;n=f.length&&"."===t[f.length]?l.with[e]=t.substr(f.length+1):l.with[e]=""});var s=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var d=[],v=i[e.localKeys]||[];v=Array.isArray(v)?v:p.keys(v),d=d.concat(v||[]),s=o.findAll(t.getResource(a),{where:r({},c.idAttribute,{in:p.filter(h(d),function(t){return t})})},l).then(function(t){return p.set(i,e.localField,t),t})}else("belongsTo"===e.type||"hasOne"===e.type&&e.localKey)&&(s=o.find(t.getResource(a),p.get(i,e.localKey),l).then(function(t){return p.set(i,e.localField,t),t}));else s=o.findAll(t.getResource(a),{where:r({},e.foreignKey,{"==":i[t.idAttribute]})},l).then(function(t){return"hasOne"===e.type&&t.length?p.set(i,e.localField,t[0]):p.set(i,e.localField,t),t});s&&u.push(s)}()}),p.Promise.all(u)}).then(function(){return u(i)}).catch(a)})}},{key:"findAll",value:function(t,e,n){var o=this,i=null;return n=n||{},n.with=n.with||[],new p.Promise(function(r,i){try{!function(){n=n||{},"allowSimpleWhere"in n||(n.allowSimpleWhere=!0);var i=[],u=p.keys(o.getIds(t,n));p.forEach(u,function(e){var r=o.storage.getItem(o.getIdPath(t,n,e));r&&i.push(p.fromJson(r))}),r(y.call(v,i,t.name,e,n))}()}catch(t){i(t)}}).then(function(e){i=e;var u=[];return p.forEach(t.relationList,function(e){var a=e.relation,c=t.getResource(a),f=null;p.contains(n.with,a)?f=a:p.contains(n.with,e.localField)&&(f=e.localField),f&&!function(){var l=p.deepMixIn({},n.orig?n.orig():n);l.with=n.with.slice(),l=p._(c,l),p.remove(l.with,f),p.forEach(l.with,function(t,e){t&&0===t.indexOf(f)&&t.length>=f.length&&"."===t[f.length]?l.with[e]=t.substr(f.length+1):l.with[e]=""});var s=void 0;"hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey?"hasMany"===e.type&&e.localKeys?!function(){var n=[];p.forEach(i,function(t){var r=t[e.localKeys]||[];r=Array.isArray(r)?r:p.keys(r),n=n.concat(r||[])}),s=o.findAll(t.getResource(a),{where:r({},c.idAttribute,{in:p.filter(h(n),function(t){return t})})},l).then(function(t){return p.forEach(i,function(n){var r=[],o=n[e.localKeys]||[];o=Array.isArray(o)?o:p.keys(o),p.forEach(t,function(t){o&&p.contains(o,t[c.idAttribute])&&r.push(t)}),p.set(n,e.localField,r)}),t})}():("belongsTo"===e.type||"hasOne"===e.type&&e.localKey)&&(s=o.findAll(t.getResource(a),{where:r({},c.idAttribute,{in:p.filter(d(i,function(t){return p.get(t,e.localKey)}),function(t){return t})})},l).then(function(t){return p.forEach(i,function(n){p.forEach(t,function(t){t[c.idAttribute]===n[e.localKey]&&p.set(n,e.localField,t)})}),t})):s=o.findAll(t.getResource(a),{where:r({},e.foreignKey,{in:p.filter(d(i,function(e){return p.get(e,t.idAttribute)}),function(t){return t})})},l).then(function(n){return p.forEach(i,function(r){var o=[];p.forEach(n,function(n){p.get(n,e.foreignKey)===r[t.idAttribute]&&o.push(n)}),"hasOne"===e.type&&o.length?p.set(r,e.localField,o[0]):p.set(r,e.localField,o)}),n}),s&&u.push(s)}()}),p.Promise.all(u)}).then(function(){return i})}},{key:"create",value:function(t,e,n){var r=this;return c(function(o,i){a(function(){e[t.idAttribute]=e[t.idAttribute]||s(),n=n||{},r.PUT(p.makePath(r.getIdPath(t,n,e[t.idAttribute])),p.omit(e,t.relationFields||[])).then(function(e){r.ensureId(e[t.idAttribute],t,n),o(e)}).catch(i)})})}},{key:"createMany",value:function(t,e,n){var r=this;return c(function(o,i){a(function(){var u=[],a=[];return p.forEach(e,function(e){var o=e[t.idAttribute]=e[t.idAttribute]||s();a.push(o),n=n||{},u.push(r.PUT(p.makePath(r.getIdPath(t,n,o)),p.omit(e,t.relationFields||[])))}),r.ensureId(a,t,n),p.Promise.all(u).then(o).catch(i)})})}},{key:"update",value:function(t,e,n,r){var o=this;return c(function(i,u){a(function(){r=r||{},o.PUT(o.getIdPath(t,r,e),p.omit(n,t.relationFields||[])).then(function(e){o.ensureId(e[t.idAttribute],t,r),i(e)}).catch(u)})})}},{key:"updateAll",value:function(t,e,n,r){var o=this;return this.findAll(t,n,r).then(function(n){var i=[];return p.forEach(n,function(n){return i.push(o.update(t,n[t.idAttribute],p.omit(e,t.relationFields||[]),r))}),p.Promise.all(i)})}},{key:"destroy",value:function(t,e,n){var r=this;return c(function(o,i){a(function(){n=n||{},r.DEL(r.getIdPath(t,n,e)).then(function(){return r.removeId(e,t,n)}).then(function(){return o(null)},i)})})}},{key:"destroyAll",value:function(t,e,n){var r=this;return this.findAll(t,e,n).then(function(e){var o=[];return p.forEach(e,function(e){var i=e[t.idAttribute];o.push(i),r.storage.removeItem(r.getIdPath(t,n,i))}),r.removeId(o,t,n),o})}}]),t}();w.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=w},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+i(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),i=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(i);return e}var o=n(4),i="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&i(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),i=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?i:~~e,Math.round(u(t-.5,e+.499999999999))}var o=n(6),i=n(7),u=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?i:t,e=null==e?u:e,t+(e-t)*o()}var o=n(9),i=n(6),u=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(i.call(t))[1]}var r,o=/^\[object (.*)\]$/,i=Object.prototype.toString;t.exports=n},function(t,e,n){function r(t,e){return e=e||o,i(t,function(t,n,r){for(var o=r.length;++nn;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){K.push(t)}function c(){K.length&&!D&&(D=!0,K[0]())}function l(t){K.length?f(t):(f(t),c())}function s(t){return new Promise(t).then(function(t){return D=!1,K.shift(),setTimeout(c,0),t},function(t){return D=!1,K.shift(),setTimeout(c,0),M(t)})}function d(t){w(this,t||{}),w(this,L)}var h=n(1),p=n(2),g=h.Query,v=h.utils,y=v.addHiddenPropsToTarget,b=v.copy,A=v.deepMixIn,m=v.extend,w=v.fillIn,I=v.forOwn,x=v.fromJson,P=v.get,E=v.isArray,F=v.isUndefined,O=v.resolve,M=v.reject,j=v.set,U=v.toJson,K=[],D=!1,T=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),O()},C=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),O()},L={basePath:"",debug:!1,storage:localStorage};d.extend=m,y(d.prototype,{afterCreate:C,afterCreateMany:C,afterDEL:C,afterDestroy:C,afterDestroyAll:C,afterFind:C,afterFindAll:C,afterGET:C,afterPUT:C,afterUpdate:C,afterUpdateAll:C,afterUpdateMany:C,beforeCreate:T,beforeCreateMany:T,beforeDEL:T,beforeDestroy:T,beforeDestroyAll:T,beforeFind:T,beforeFindAll:T,beforeGET:T,beforePUT:T,beforeUpdate:T,beforeUpdateAll:T,beforeUpdateMany:T,create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",O(r[i](t,e,n)).then(function(o){var a=F(o)?e:o,u=P(a,t.idAttribute)||p();j(a,t.idAttribute,u);var f=r.getIdPath(t,n,u);return r.storage.setItem(f,U(a)),r.ensureId(u,t,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=F(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",O(r[i](t,e,n)).then(function(o){var a=F(o)?e:o,u=t.idAttribute;return a.forEach(function(e){var o=P(e,u)||p();j(e,u,o);var a=r.getIdPath(t,n,o);r.storage.setItem(a,U(e)),r.ensureId(o,t,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=F(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroy",O(r[i](t,e,n)).then(function(){return i=n.op="destroy",r.dbg(i,e,n),r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),i=n.op="afterDestroy",r[i](t,e,n).then(function(t){return e=F(t)?e:t,n.raw?{data:e,deleted:1}:e})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroyAll",O(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return P(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=F(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",O(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),F(a))return void(a=void 0);a=x(a);var c=[],l=t.relationList||[];return l.forEach(function(e){var i=e.relation,f=e.getRelation(),l=null;if(-1!==n.with.indexOf(i)?l=i:-1!==n.with.indexOf(e.localField)&&(l=e.localField),l){var s=b(n);s.with=n.with.slice(),w(s,f);var d=s.with.indexOf(l);d>=0&&s.with.splice(d,1),s.with.forEach(function(t,e){t&&0===t.indexOf(l)&&t.length>=l.length&&"."===t[l.length]?s.with[e]=t.substr(l.length+1):s.with[e]=""});var h=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var p=[],g=P(a,e.localKeys)||[];g=Array.isArray(g)?g:Object.keys(g),p=p.concat(g||[]),h=o.findAll(f,{where:r({},f.idAttribute,{in:u(p).filter(function(t){return t})})},s).then(function(t){return j(a,e.localField,t),t})}else"belongsTo"===e.type&&(h=o.find(f,P(a,e.foreignKey),s).then(function(t){return j(a,e.localField,t),t}));else h=o.findAll(f,r({},e.foreignKey,P(a,t.idAttribute)),s).then(function(t){return"hasOne"===e.type&&t.length?j(a,e.localField,t[0]):j(a,e.localField,t),t});h&&c.push(h)}}),Promise.all(c)}).then(function(){return i=n.op="afterFind",O(o[i](t,e,n,a)).then(function(t){return a=F(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",O(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);I(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(x(i))});var c=t.idAttribute,l=new g({index:{getAll:function(){return a}}});a=l.filter(e).run();var s=[],d=t.relationList||[];return d.forEach(function(t){var e=t.relation,i=t.getRelation(),f=null;if(-1!==n.with.indexOf(e)?f=e:-1!==n.with.indexOf(t.localField)&&(f=t.localField),f){var l=b(n);l.with=n.with.slice(),w(l,i);var d=l.with.indexOf(f);d>=0&&l.with.splice(d,1),l.with.forEach(function(t,e){t&&0===t.indexOf(f)&&t.length>=f.length&&"."===t[f.length]?l.with[e]=t.substr(f.length+1):l.with[e]=""});var h=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var e=[];a.forEach(function(n){var r=P(n,t.localKeys)||[];r=Array.isArray(r)?r:Object.keys(r),e=e.concat(r||[])}),h=o.findAll(i,{where:r({},i.idAttribute,{in:u(e).filter(function(t){return t})})},l).then(function(e){return a.forEach(function(n){var r=[],o=P(n,t.localKeys)||[];o=Array.isArray(o)?o:Object.keys(o),e.forEach(function(t){o&&-1!==o.indexOf(t[i.idAttribute])&&r.push(t)}),j(n,t.localField,r)}),e})}():"belongsTo"===t.type&&(h=o.findAll(i,{where:r({},i.idAttribute,{in:a.map(function(e){return P(e,t.foreignKey)}).filter(function(t){return t})})},l).then(function(e){return a.forEach(function(n){e.forEach(function(e){e[i.idAttribute]===P(n,t.foreignKey)&&j(n,t.localField,e)})}),e})):h=o.findAll(i,{where:r({},t.foreignKey,{in:a.map(function(t){return P(t,c)}).filter(function(t){return t})})},l).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){P(e,t.foreignKey)===P(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?j(n,t.localField,r[0]):j(n,t.localField,r)}),e}),h&&s.push(h)}}),Promise.all(s)}).then(function(){return i=n.op="afterFindAll",O(o[i](t,e,n,a)).then(function(t){return a=F(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?x(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,U(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),s(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",O(o[u](t,e,n,r)).then(function(a){n=F(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?x(f):void 0;var c=0;return f&&(A(f,n),o.storage.setItem(i,U(f)),c++),u=r.op="afterUpdate",o[u](t,e,n,r,f).then(function(t){return f=F(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),s(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",O(o[u](t,e,n,r)).then(function(a){return e=F(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=P(n,i),u=o.getIdPath(t,r,a);A(n,e),o.storage.setItem(u,U(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=F(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),s(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",O(r[i](t,e,n)).then(function(o){e=F(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=P(e,a);if(!F(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?x(f):void 0;c&&(A(c,e),r.storage.setItem(i,U(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=F(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),d.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=d},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); //# sourceMappingURL=dist/js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index 4a799c3..dced51d 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","_classCallCheck","instance","Constructor","TypeError","enqueue","task","queue","push","dequeue","length","taskInProcess","queueTask","createTask","fn","DSUtils","Promise","then","result","shift","setTimeout","err","reject","_createClass","defineProperties","target","props","i","descriptor","protoProps","staticProps","prototype","JSData","guid","unique","map","emptyStore","DS","filter","defaults","defaultFilter","Defaults","basePath","DSLocalStorageAdapter","options","storage","localStorage","deepMixIn","resourceConfig","makePath","name","endpoint","ids","undefined","idsPath","getPath","idsJson","getItem","fromJson","isEmpty","removeItem","setItem","toJson","getIds","isArray","forEach","_id","saveKeys","_this","resolve","item","_this2","GET","removeCircular","_this3","_this4","with","getIdPath","Error","_instance","tasks","relationList","def","relationName","relation","relationDef","getResource","containedName","contains","localField","__options","orig","slice","_","remove","indexOf","substr","type","foreignKey","localKeys","itemKeys","Array","keys","concat","findAll","where","idAttribute","in","x","relatedItems","set","localKey","find","get","relatedItem","==","all","catch","params","_this5","items","allowSimpleWhere","itemJson","_items","attached","attrs","_this6","PUT","omit","relationFields","ensureId","_this7","_this8","_this9","update","_this10","DEL","removeId","_this11","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","arguments","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString","arr","compare","isEqual","n","a","b","callback","thisObj","makeIterator","results","len","src","identity","deepMatches","prop","containsMatch","array","pattern","matchArray","patternLength","matchObject","forOwn","forIn","hasOwn","hasOwnProperty","checkDontEnum","_dontEnums","_hasDontEnumBug","ctor","constructor","isProto"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA+B,sBAAID,EAAQG,QAAQ,YAEnDJ,EAA4B,sBAAIC,EAAQD,EAAa,SACpDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAIA,SAASS,GAAgBC,EAAKC,EAAKC,GAAiK,MAApJD,KAAOD,GAAOG,OAAOC,eAAeJ,EAAKC,GAAOC,MAAOA,EAAOG,YAAY,EAAMC,cAAc,EAAMC,UAAU,IAAkBP,EAAIC,GAAOC,EAAgBF,EAE3M,QAASQ,GAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,qCAsBhH,QAASC,GAAQC,GACfC,EAAMC,KAAKF,GAGb,QAASG,KACHF,EAAMG,SAAWC,IACnBA,GAAgB,EAChBJ,EAAM,MAIV,QAASK,GAAUN,GACZC,EAAMG,OAITL,EA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C,GACQ,WACA,iBACA,UACA,iBACA,gBACA,uBACA,eAGRC,GAAkB,CAElB,KAAK,GAAI7M,MAAQiL,SAAY,MACzB4B,GAAkB,EAS1B,QAASL,GAAMzM,EAAKqB,EAAIqK,GACpB,GAAIzL,GAAKiC,EAAI,CAKU,OAAnB4K,GAAyBF,GAE7B,KAAK3M,IAAOD,GACR,GAAIgL,EAAK3J,EAAIrB,EAAKC,EAAKyL,MAAa,EAChC,KAKR,IAAIoB,EAIA,IAHA,GAAIC,GAAO/M,EAAIgN,YACXC,IAAYF,GAAQ/M,IAAQ+M,EAAKzK,WAE9BrC,EAAM4M,EAAW3K,QAUP,gBAARjC,IACKgN,IAAWP,EAAO1M,EAAKC,KAC7BD,EAAIC,KAASE,OAAOmC,UAAUrC,IAE1B+K,EAAK3J,EAAIrB,EAAKC,EAAKyL,MAAa,MAQpD,QAASV,GAAK3J,EAAIrB,EAAKC,EAAKyL,GACxB,MAAOrK,GAAG1B,KAAK+L,EAAS1L,EAAIC,GAAMA,EAAKD,GAtE/C,GAEQ8M,GACAD,EAHJH,EAASpN,EAAoB,GAyE7BP,GAAOD,QAAU2N,GAOhB,SAAS1N,EAAQD,EAASQ,GAO3B,QAASoD,GAAIyI,EAAKM,EAAUC,GACxBD,EAAWE,EAAaF,EAAUC,EAClC,IAAIE,KACJ,IAAW,MAAPT,EACA,MAAOS,EAIX,KADA,GAAI1J,GAAI,GAAI2J,EAAMV,EAAIlK,SACbiB,EAAI2J,GACTD,EAAQ1J,GAAKuJ,EAASN,EAAIjJ,GAAIA,EAAGiJ,EAGrC,OAAOS,GAjBf,GAAID,GAAerM,EAAoB,GAoBlCP,GAAOD,QAAU4D","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","copy","deepMixIn","extend","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDEL","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterGET","afterPUT","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDEL","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeGET","beforePUT","beforeUpdate","beforeUpdateAll","beforeUpdateMany","create","mapper","props","success","failure","undefined","_props","record","idAttribute","getIdPath","setItem","ensureId","_record","raw","data","created","createMany","records","_records","_len4","_key4","log","destroy","removeItem","removeId","_id","deleted","destroyAll","query","findAll","ids","map","_ids","getIds","saveKeys","find","with","getItem","tasks","relationList","def","relationName","relation","relatedMapper","getRelation","containedName","indexOf","localField","__opts","slice","index","splice","i","substr","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","relatedItem","all","found","json","_query","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gB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,EAASQ,GAE/B,GAAImO,GAASnO,EAAoB,IAGzBoE,EAAUxC,MAAMwC,SAAW,SAAUgK,GACrC,MAAOD,GAAOC,EAAK,SAEvB3O,GAAOD,QAAU4E,GAMhB,SAAS3E,EAAQD,EAASQ,GAM3B,QAASmO,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAAStO,EAAoB,GAO7BP,GAAOD,QAAU2O,GAMhB,SAAS1O,EAAQD,GAWlB,QAAS8O,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAUrO,KAAK+N,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAY7N,OAAO2E,UAAUmJ,QAejClP,GAAOD,QAAU8O","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 46b635f..dde1087 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -72,7 +72,10 @@ module.exports = function (config) { // optionally, configure the reporter coverageReporter: { type: 'lcov', - dir: 'coverage/' + dir: 'coverage/', + instrumenterOptions: { + istanbul: { noCompact: true } + } }, // the default configuration diff --git a/karma.start.js b/karma.start.js index 364807c..cb49510 100644 --- a/karma.start.js +++ b/karma.start.js @@ -6,29 +6,9 @@ window.assert = TestRunner.assert; TestRunner.init({ features: [], - DS: JSData.DS, - Adapter: DSLocalStorageAdapter -}); - -// TODO: Move this into js-data-adapter-tests -describe('DSLocalStorageAdapter#createMany', function () { - it('should create many items at once', function () { - var adapter = this.$$adapter - var User = this.$$User - return adapter.createMany(User, [ - {name: 'John'}, - {name: 'Sally'} - ]).then(function (users) { - assert.equal(users[0].name, 'John'); - assert.isDefined(users[0].id); - assert.equal(users[1].name, 'Sally'); - assert.isDefined(users[1].id); - return adapter.findAll(User); - }).then(function (users) { - assert.equal(users[0].name, 'John'); - assert.isDefined(users[0].id); - assert.equal(users[1].name, 'Sally'); - assert.isDefined(users[1].id); - }); - }); + JSData: JSData, + Adapter: LocalStorageAdapter, + adapterConfig: { + debug: false + } }); diff --git a/package.json b/package.json index 553ec3d..3372ac4 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,13 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "version": "2.3.2", - "homepage": "http://www.js-data.io/docs/dslocalstorageadapter", + "version": "3.0.0-alpha.1", + "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", "url": "https://github.com/js-data/js-data-localstorage.git" }, - "author": { - "name": "Jason Dobry", - "url": "http://www.pseudobry.com", - "email": "jason.dobry@gmail.com" - }, + "author": "Jason Dobry (http://www.pseudobry.com)", "license": "MIT", "keywords": [ "data", @@ -29,40 +25,45 @@ ] }, "scripts": { - "lint": "standard src/**/*.js", "bundle": "webpack --config webpack.config.js --colors", + "doc": "jsdoc -c conf.json src && node scripts/cleanup.js", + "lint": "standard src/**/*.js", "min": "uglifyjs dist/js-data-localstorage.js -o dist/js-data-localstorage.min.js --source-map dist/js-data-localstorage.min.map -v -m -c --screw-ie8", "version": "node scripts/version.js", "banner": "node scripts/banner.js", "gzip": "echo gzipped size: $(cat dist/js-data-localstorage.min.js | gzip -f9 | wc -c)kb", - "build": "npm run lint && npm run bundle && npm run min && npm run version && npm run banner && npm run gzip", + "build": "npm run lint && npm run bundle && npm run min && npm run version && npm run banner", "karma": "karma start", "test": "npm run build && npm run karma", "ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | coveralls || true && cat ./coverage/PhantomJS*/lcov.info | codacy-coverage || true" }, - "peerDependencies": { - "js-data": "~2.x" + "dependencies": { + "js-data": "^3.0.0-alpha.13" }, "devDependencies": { - "babel-core": "6.3.17", - "babel-eslint": "4.1.6", - "babel-loader": "6.2.0", - "babel-preset-es2015": "6.3.13", + "babel-core": "6.5.2", + "babel-eslint": "4.1.8", + "babel-loader": "6.2.2", + "babel-polyfill": "6.5.0", + "babel-preset-es2015": "6.5.0", + "chai": "3.5.0", "codacy-coverage": "1.1.3", "coveralls": "2.11.6", "es6-promise": "3.0.2", - "js-data-adapter-tests": "~1.x", - "karma": "0.13.15", - "karma-browserstack-launcher": "0.1.7", + "ink-docstrap": "1.1.1", + "js-data-adapter-tests": "^2.0.0-alpha.1", + "jsdoc": "3.4.0", + "karma": "0.13.21", + "karma-browserstack-launcher": "0.1.10", "karma-coverage": "0.5.3", "karma-junit-reporter": "0.3.8", "karma-mocha": "0.2.1", - "karma-phantomjs-launcher": "0.2.1", - "mocha": "2.3.4", + "karma-phantomjs-launcher": "1.0.0", + "mocha": "2.4.5", "mout": "0.11.1", - "phantomjs": "1.9.19", - "standard": "5.4.1", + "phantomjs-prebuilt": "^2.1.4", + "standard": "6.0.5", "uglify-js": "2.6.1", - "webpack": "1.12.9" + "webpack": "1.12.13" } } diff --git a/scripts/banner.js b/scripts/banner.js index b0b9542..e370a02 100644 --- a/scripts/banner.js +++ b/scripts/banner.js @@ -3,9 +3,9 @@ var pkg = require('../package.json'); var banner = '/*!\n' + '* js-data-localstorage\n' + - '* @version ' + pkg.version + ' - Homepage \n' + + '* @version ' + pkg.version + ' - Homepage \n' + '* @author Jason Dobry \n' + - '* @copyright (c) 2014-2015 Jason Dobry\n' + + '* @copyright (c) 2014-2016 Jason Dobry\n' + '* @license MIT \n' + '*\n' + '* @overview localStorage adapter for js-data.\n' + diff --git a/scripts/cleanup.js b/scripts/cleanup.js new file mode 100644 index 0000000..aaa3689 --- /dev/null +++ b/scripts/cleanup.js @@ -0,0 +1,25 @@ +var fs = require('fs') + +var pkg = require('../package.json') + +var path = './doc/js-data-localstorage/' + 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-localstorage/' + 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/src/index.js b/src/index.js index 642064d..023aace 100644 --- a/src/index.js +++ b/src/index.js @@ -1,19 +1,52 @@ /* global: localStorage */ -let JSData = require('js-data') -let guid = require('mout/random/guid') -let unique = require('mout/array/unique') -let map = require('mout/array/map') +const JSData = require('js-data') +const guid = require('mout/random/guid') -let emptyStore = new JSData.DS() -let {DSUtils} = JSData -let filter = emptyStore.defaults.defaultFilter +const { + Query, + utils +} = JSData -class Defaults { +const { + addHiddenPropsToTarget, + copy, + deepMixIn, + extend, + fillIn, + forOwn, + fromJson, + get, + isArray, + isUndefined, + resolve, + reject, + set, + toJson +} = utils +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/') +} +function unique (array) { + const seen = {} + const final = [] + array.forEach(function (item) { + if (item in seen) { + return + } + final.push(item) + seen[item] = 0 + }) + return final } - -Defaults.prototype.basePath = '' - let queue = [] let taskInProcess = false @@ -38,407 +71,1044 @@ function queueTask (task) { } function createTask (fn) { - return new DSUtils.Promise(fn).then(result => { + return new Promise(fn).then(function (result) { taskInProcess = false queue.shift() setTimeout(dequeue, 0) return result - }, err => { + }, function (err) { taskInProcess = false queue.shift() setTimeout(dequeue, 0) - return DSUtils.Promise.reject(err) + return reject(err) }) } -class DSLocalStorageAdapter { - constructor (options) { - options = options || {} - this.defaults = new Defaults() - this.storage = options.storage || localStorage - DSUtils.deepMixIn(this.defaults, options) - } +const noop = function (...args) { + const self = this + const opts = args[args.length - 1] + self.dbg(opts.op, ...args) + return resolve() +} - getPath (resourceConfig, options) { - options = options || {} - return DSUtils.makePath(options.basePath || this.defaults.basePath || resourceConfig.basePath, resourceConfig.name) - } +const noop2 = function (...args) { + const self = this + const opts = args[args.length - 2] + self.dbg(opts.op, ...args) + return resolve() +} - getIdPath (resourceConfig, options, id) { - options = options || {} - return DSUtils.makePath(options.basePath || this.defaults.basePath || resourceConfig.basePath, resourceConfig.endpoint, id) - } +const DEFAULTS = { + /** + * TODO + * + * @name LocalStorageAdapter#basePath + * @type {string} + */ + basePath: '', - getIds (resourceConfig, options) { - let ids - const idsPath = this.getPath(resourceConfig, options) - const idsJson = this.storage.getItem(idsPath) - if (idsJson) { - ids = DSUtils.fromJson(idsJson) - } else { - ids = {} - } - return ids - } + /** + * TODO + * + * @name LocalStorageAdapter#debug + * @type {boolean} + * @default false + */ + debug: false, - saveKeys (ids, resourceConfig, options) { - const idsPath = this.getPath(resourceConfig, options) - if (!DSUtils.isEmpty(ids)) { - this.storage.setItem(idsPath, DSUtils.toJson(ids)) - } else { - this.storage.removeItem(idsPath) - } - } + /** + * TODO + * + * @name LocalStorageAdapter#storage + * @type {Object} + * @default localStorage + */ + storage: localStorage +} + +/** + * LocalStorageAdapter class. + * + * @example + * import {DataStore} from 'js-data' + * import LocalStorageAdapter from 'js-data-localstorage' + * const store = new DataStore() + * const adapter = new LocalStorageAdapter() + * store.registerAdapter('ls', adapter, { 'default': true }) + * + * @class LocalStorageAdapter + * @param {Object} [opts] Configuration opts. + * @param {string} [opts.basePath=''] TODO + * @param {boolean} [opts.debug=false] TODO + * @param {Object} [opts.storeage=localStorage] TODO + */ +function LocalStorageAdapter (opts) { + fillIn(this, opts || {}) + fillIn(this, DEFAULTS) +} + +/** + * Alternative to ES6 class syntax for extending `LocalStorageAdapter`. + * + * @name LocalStorageAdapter.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 `LocalStorageAdapter`. + */ +LocalStorageAdapter.extend = extend + +addHiddenPropsToTarget(LocalStorageAdapter.prototype, { + /** + * @name LocalStorageAdapter#afterCreate + * @method + */ + afterCreate: noop2, + + /** + * @name LocalStorageAdapter#afterCreateMany + * @method + */ + afterCreateMany: noop2, + + /** + * @name LocalStorageAdapter#afterDEL + * @method + */ + afterDEL: noop2, + + /** + * @name LocalStorageAdapter#afterDestroy + * @method + */ + afterDestroy: noop2, + + /** + * @name LocalStorageAdapter#afterDestroyAll + * @method + */ + afterDestroyAll: noop2, + + /** + * @name LocalStorageAdapter#afterFind + * @method + */ + afterFind: noop2, + + /** + * @name LocalStorageAdapter#afterFindAll + * @method + */ + afterFindAll: noop2, + + /** + * @name LocalStorageAdapter#afterGET + * @method + */ + afterGET: noop2, + + /** + * @name LocalStorageAdapter#afterPUT + * @method + */ + afterPUT: noop2, + + /** + * @name LocalStorageAdapter#afterUpdate + * @method + */ + afterUpdate: noop2, + + /** + * @name LocalStorageAdapter#afterUpdateAll + * @method + */ + afterUpdateAll: noop2, + + /** + * @name LocalStorageAdapter#afterUpdateMany + * @method + */ + afterUpdateMany: noop2, + + /** + * @name LocalStorageAdapter#beforeCreate + * @method + */ + beforeCreate: noop, + + /** + * @name LocalStorageAdapter#beforeCreateMany + * @method + */ + beforeCreateMany: noop, + + /** + * @name LocalStorageAdapter#beforeDEL + * @method + */ + beforeDEL: noop, + + /** + * @name LocalStorageAdapter#beforeDestroy + * @method + */ + beforeDestroy: noop, + + /** + * @name LocalStorageAdapter#beforeDestroyAll + * @method + */ + beforeDestroyAll: noop, + + /** + * @name LocalStorageAdapter#beforeFind + * @method + */ + beforeFind: noop, + + /** + * @name LocalStorageAdapter#beforeFindAll + * @method + */ + beforeFindAll: noop, + + /** + * @name LocalStorageAdapter#beforeGET + * @method + */ + beforeGET: noop, + + /** + * @name LocalStorageAdapter#beforePUT + * @method + */ + beforePUT: noop, + + /** + * @name LocalStorageAdapter#beforeUpdate + * @method + */ + beforeUpdate: noop, + + /** + * @name LocalStorageAdapter#beforeUpdateAll + * @method + */ + beforeUpdateAll: noop, + + /** + * @name LocalStorageAdapter#beforeUpdateMany + * @method + */ + beforeUpdateMany: noop, + + /** + * Create a new record. + * + * @name LocalStorageAdapter#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] TODO + * @return {Promise} + */ + create (mapper, props, opts) { + const self = this + props || (props = {}) + opts || (opts = {}) + + return createTask(function (success, failure) { + queueTask(function () { + let op + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate' + return resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + let record = isUndefined(_props) ? props : _props + const id = get(record, mapper.idAttribute) || guid() + set(record, mapper.idAttribute, id) + const key = self.getIdPath(mapper, opts, id) - ensureId (id, resourceConfig, options) { - const ids = this.getIds(resourceConfig, options) - if (DSUtils.isArray(id)) { + // Create the record + // TODO: Create related records when the "with" option is provided + self.storage.setItem(key, toJson(record)) + self.ensureId(id, mapper, opts) + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate' + return self[op](mapper, props, opts, record).then(function (_record) { + // Allow for re-assignment from lifecycle hook + record = isUndefined(_record) ? record : _record + return opts.raw ? { + data: record, + created: 1 + } : record + }) + }).then(success, failure) + }) + }) + }, + + /** + * Create multiple records in a single batch. + * + * @name LocalStorageAdapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Array} props Array of records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] TODO + * @return {Promise} + */ + createMany (mapper, props, opts) { + const self = this + props || (props = {}) + opts || (opts = {}) + + return createTask(function (success, failure) { + queueTask(function () { + let op + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany' + return resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + let records = isUndefined(_props) ? props : _props + const idAttribute = mapper.idAttribute + + // Create the record + // TODO: Create related records when the "with" option is provided + records.forEach(function (record) { + const id = get(record, idAttribute) || guid() + set(record, idAttribute, id) + const key = self.getIdPath(mapper, opts, id) + self.storage.setItem(key, toJson(record)) + self.ensureId(id, mapper, opts) + }) + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany' + return self[op](mapper, props, opts, records).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? records : _records + return opts.raw ? { + data: records, + created: records.length + } : records + }) + }).then(success, failure) + }) + }) + }, + + /** + * @name LocalStorageAdapter#dbg + * @method + */ + dbg (...args) { + this.log('debug', ...args) + }, + + /** + * Destroy the record with the given primary key. + * + * @name LocalStorageAdapter#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] TODO + * @return {Promise} + */ + destroy (mapper, id, opts) { + const self = this + opts || (opts = {}) + + return createTask(function (success, failure) { + queueTask(function () { + let op + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy' + return resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy' + self.dbg(op, id, opts) + // Destroy the record + // TODO: Destroy related records when the "with" option is provided + self.storage.removeItem(self.getIdPath(mapper, opts, id)) + self.removeId(id, mapper, opts) + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy' + return self[op](mapper, id, opts).then(function (_id) { + // Allow for re-assignment from lifecycle hook + id = isUndefined(_id) ? id : _id + return opts.raw ? { + data: id, + deleted: 1 + } : id + }) + }).then(success, failure) + }) + }) + }, + + /** + * Destroy the records that match the selection `query`. + * + * @name LocalStorageAdapter#destroyAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.raw=false] TODO + * @return {Promise} + */ + destroyAll (mapper, query, opts) { + const self = this + query || (query = {}) + opts || (opts = {}) + + return createTask(function (success, failure) { + queueTask(function () { + let op + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll' + return resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll' + self.dbg(op, query, opts) + // Find the records that are to be destroyed + return self.findAll(mapper, query, opts) + }).then(function (records) { + const idAttribute = mapper.idAttribute + // Gather IDs of records to be destroyed + let ids = records.map(function (record) { + return get(record, idAttribute) + }) + // Destroy each record + // TODO: Destroy related records when the "with" option is provided + ids.forEach(function (id) { + self.storage.removeItem(self.getIdPath(mapper, opts, id)) + }) + self.removeId(ids, mapper, opts) + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll' + return self[op](mapper, query, opts, ids).then(function (_ids) { + // Allow for re-assignment from lifecycle hook + ids = isUndefined(_ids) ? ids : _ids + return opts.raw ? { + data: ids, + deleted: records.length + } : ids + }) + }).then(success, failure) + }) + }) + }, + + /** + * TODO + * + * @name LocalStorageAdapter#ensureId + * @method + */ + ensureId (id, mapper, opts) { + const ids = this.getIds(mapper, opts) + if (isArray(id)) { if (!id.length) { return } - DSUtils.forEach(id, function (_id) { + id.forEach(function (_id) { ids[_id] = 1 }) } else { ids[id] = 1 } - this.saveKeys(ids, resourceConfig, options) - } + this.saveKeys(ids, mapper, opts) + }, - removeId (id, resourceConfig, options) { - const ids = this.getIds(resourceConfig, options) - if (DSUtils.isArray(id)) { - if (!id.length) { + /** + * Retrieve the record with the given primary key. + * + * @name LocalStorageAdapter#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] TODO + * @param {string[]} [opts.with=[]] TODO + * @return {Promise} + */ + find (mapper, id, opts) { + const self = this + let record, op + opts || (opts = {}) + opts.with || (opts.with = []) + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind' + return resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'find' + self.dbg(op, id, opts) + const key = self.getIdPath(mapper, opts, id) + record = self.storage.getItem(key) + if (isUndefined(record)) { + record = undefined return } - DSUtils.forEach(id, function (_id) { - delete ids[_id] - }) - } else { - delete ids[id] - } - this.saveKeys(ids, resourceConfig, options) - } - - GET (key) { - return new DSUtils.Promise(resolve => { - let item = this.storage.getItem(key) - resolve(item ? DSUtils.fromJson(item) : undefined) - }) - } + record = fromJson(record) + const tasks = [] + const relationList = mapper.relationList || [] - PUT (key, value) { - let DSLocalStorageAdapter = this - return DSLocalStorageAdapter.GET(key).then(item => { - if (item) { - DSUtils.deepMixIn(item, DSUtils.removeCircular(value)) - } - this.storage.setItem(key, DSUtils.toJson(item || value)) - return DSLocalStorageAdapter.GET(key) - }) - } + relationList.forEach(function (def) { + const relationName = def.relation + const relatedMapper = def.getRelation() + let containedName = null + if (opts.with.indexOf(relationName) !== -1) { + containedName = relationName + } else if (opts.with.indexOf(def.localField) !== -1) { + containedName = def.localField + } + if (!containedName) { + return + } + let __opts = copy(opts) + __opts.with = opts.with.slice() + fillIn(__opts, relatedMapper) + const index = __opts.with.indexOf(containedName) + if (index >= 0) { + __opts.with.splice(index, 1) + } + __opts.with.forEach(function (relation, i) { + if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { + __opts.with[i] = relation.substr(containedName.length + 1) + } else { + __opts.with[i] = '' + } + }) - DEL (key) { - return new DSUtils.Promise(resolve => { - this.storage.removeItem(key) - resolve() - }) - } + let task - find (resourceConfig, id, options) { - let instance - options = options || {} - options.with = options.with || [] - return new DSUtils.Promise((resolve, reject) => { - this.GET(this.getIdPath(resourceConfig, options || {}, id)) - .then(item => !item ? reject(new Error('Not Found!')) : item) - .then(_instance => { - instance = _instance - let tasks = [] - - DSUtils.forEach(resourceConfig.relationList, def => { - let relationName = def.relation - let relationDef = resourceConfig.getResource(relationName) - let containedName = null - if (DSUtils.contains(options.with, relationName)) { - containedName = relationName - } else if (DSUtils.contains(options.with, def.localField)) { - containedName = def.localField + if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { + task = self.findAll(relatedMapper, { + [def.foreignKey]: get(record, mapper.idAttribute) + }, __opts).then(function (relatedItems) { + if (def.type === 'hasOne' && relatedItems.length) { + set(record, def.localField, relatedItems[0]) + } else { + set(record, def.localField, relatedItems) } - if (containedName) { - let __options = DSUtils.deepMixIn({}, options.orig ? options.orig() : options) - __options.with = options.with.slice() - __options = DSUtils._(relationDef, __options) - DSUtils.remove(__options.with, containedName) - DSUtils.forEach(__options.with, (relation, i) => { - if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { - __options.with[i] = relation.substr(containedName.length + 1) - } else { - __options.with[i] = '' - } - }) - - let task - - if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { - task = this.findAll(resourceConfig.getResource(relationName), { - where: { - [def.foreignKey]: { - '==': instance[resourceConfig.idAttribute] - } - } - }, __options).then(relatedItems => { - if (def.type === 'hasOne' && relatedItems.length) { - DSUtils.set(instance, def.localField, relatedItems[0]) - } else { - DSUtils.set(instance, def.localField, relatedItems) - } - return relatedItems - }) - } else if (def.type === 'hasMany' && def.localKeys) { - let localKeys = [] - let itemKeys = instance[def.localKeys] || [] - itemKeys = Array.isArray(itemKeys) ? itemKeys : DSUtils.keys(itemKeys) - localKeys = localKeys.concat(itemKeys || []) - task = this.findAll(resourceConfig.getResource(relationName), { - where: { - [relationDef.idAttribute]: { - 'in': DSUtils.filter(unique(localKeys), x => x) - } - } - }, __options).then(relatedItems => { - DSUtils.set(instance, def.localField, relatedItems) - return relatedItems - }) - } else if (def.type === 'belongsTo' || (def.type === 'hasOne' && def.localKey)) { - task = this.find(resourceConfig.getResource(relationName), DSUtils.get(instance, def.localKey), __options).then(relatedItem => { - DSUtils.set(instance, def.localField, relatedItem) - return relatedItem - }) - } - - if (task) { - tasks.push(task) + return relatedItems + }) + } else if (def.type === 'hasMany' && def.localKeys) { + let localKeys = [] + let itemKeys = get(record, def.localKeys) || [] + itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) + localKeys = localKeys.concat(itemKeys || []) + task = self.findAll(relatedMapper, { + where: { + [relatedMapper.idAttribute]: { + 'in': unique(localKeys).filter(function (x) { return x }) } } + }, __opts).then(function (relatedItems) { + set(record, def.localField, relatedItems) + return relatedItems + }) + } else if (def.type === 'belongsTo') { + task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) { + set(record, def.localField, relatedItem) + return relatedItem }) + } - return DSUtils.Promise.all(tasks) - }) - .then(() => resolve(instance)) - .catch(reject) + if (task) { + tasks.push(task) + } + }) + + return Promise.all(tasks) + }).then(function () { + // afterFind lifecycle hook + op = opts.op = 'afterFind' + return resolve(self[op](mapper, id, opts, record)).then(function (_record) { + // Allow for re-assignment from lifecycle hook + record = isUndefined(_record) ? record : _record + return opts.raw ? { + data: record, + found: record ? 1 : 0 + } : record + }) }) - } + }, + + /** + * Retrieve the records that match the selection `query`. + * + * @name LocalStorageAdapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] TODO + * @param {string[]} [opts.with=[]] TODO + * @return {Promise} + */ + findAll (mapper, query, opts) { + const self = this + let records = [] + let op + opts || (opts = {}) + opts.with || (opts.with = []) + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll' + return resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll' + self.dbg(op, query, opts) - findAll (resourceConfig, params, options) { - let items = null - options = options || {} - options.with = options.with || [] - return new DSUtils.Promise((resolve, reject) => { - try { - options = options || {} - if (!('allowSimpleWhere' in options)) { - options.allowSimpleWhere = true + // Load all records into memory... + const ids = self.getIds(mapper, opts) + forOwn(ids, function (value, id) { + const json = self.storage.getItem(self.getIdPath(mapper, opts, id)) + if (json) { + records.push(fromJson(json)) } - let items = [] - let ids = DSUtils.keys(this.getIds(resourceConfig, options)) - DSUtils.forEach(ids, id => { - let itemJson = this.storage.getItem(this.getIdPath(resourceConfig, options, id)) - if (itemJson) { - items.push(DSUtils.fromJson(itemJson)) + }) + const idAttribute = mapper.idAttribute + // TODO: Verify that this collection gets properly garbage collected + // TODO: Or, find a way to filter without using Collection + const _query = new Query({ + index: { + getAll () { + return records } - }) - resolve(filter.call(emptyStore, items, resourceConfig.name, params, options)) - } catch (err) { - reject(err) - } - }).then(_items => { - items = _items - let tasks = [] - DSUtils.forEach(resourceConfig.relationList, def => { - let relationName = def.relation - let relationDef = resourceConfig.getResource(relationName) + } + }) + records = _query.filter(query).run() + const tasks = [] + const relationList = mapper.relationList || [] + + relationList.forEach(function (def) { + const relationName = def.relation + const relatedMapper = def.getRelation() let containedName = null - if (DSUtils.contains(options.with, relationName)) { + if (opts.with.indexOf(relationName) !== -1) { containedName = relationName - } else if (DSUtils.contains(options.with, def.localField)) { + } else if (opts.with.indexOf(def.localField) !== -1) { containedName = def.localField } - if (containedName) { - let __options = DSUtils.deepMixIn({}, options.orig ? options.orig() : options) - __options.with = options.with.slice() - __options = DSUtils._(relationDef, __options) - DSUtils.remove(__options.with, containedName) - DSUtils.forEach(__options.with, (relation, i) => { - if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { - __options.with[i] = relation.substr(containedName.length + 1) - } else { - __options.with[i] = '' - } - }) + if (!containedName) { + return + } + let __opts = copy(opts) + __opts.with = opts.with.slice() + fillIn(__opts, relatedMapper) + const index = __opts.with.indexOf(containedName) + if (index >= 0) { + __opts.with.splice(index, 1) + } + __opts.with.forEach(function (relation, i) { + if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { + __opts.with[i] = relation.substr(containedName.length + 1) + } else { + __opts.with[i] = '' + } + }) - let task + let task - if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { - task = this.findAll(resourceConfig.getResource(relationName), { - where: { - [def.foreignKey]: { - 'in': DSUtils.filter(map(items, item => DSUtils.get(item, resourceConfig.idAttribute)), x => x) - } + if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { + task = self.findAll(relatedMapper, { + where: { + [def.foreignKey]: { + 'in': records.map(function (item) { + return get(item, idAttribute) + }).filter(function (x) { return x }) } - }, __options).then(relatedItems => { - DSUtils.forEach(items, item => { - let attached = [] - DSUtils.forEach(relatedItems, relatedItem => { - if (DSUtils.get(relatedItem, def.foreignKey) === item[resourceConfig.idAttribute]) { - attached.push(relatedItem) - } - }) - if (def.type === 'hasOne' && attached.length) { - DSUtils.set(item, def.localField, attached[0]) - } else { - DSUtils.set(item, def.localField, attached) + } + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + const attached = [] + relatedItems.forEach(function (relatedItem) { + if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) { + attached.push(relatedItem) } }) - return relatedItems - }) - } else if (def.type === 'hasMany' && def.localKeys) { - let localKeys = [] - DSUtils.forEach(items, item => { - let itemKeys = item[def.localKeys] || [] - itemKeys = Array.isArray(itemKeys) ? itemKeys : DSUtils.keys(itemKeys) - localKeys = localKeys.concat(itemKeys || []) + if (def.type === 'hasOne' && attached.length) { + set(item, def.localField, attached[0]) + } else { + set(item, def.localField, attached) + } }) - task = this.findAll(resourceConfig.getResource(relationName), { - where: { - [relationDef.idAttribute]: { - 'in': DSUtils.filter(unique(localKeys), x => x) - } + return relatedItems + }) + } else if (def.type === 'hasMany' && def.localKeys) { + let localKeys = [] + records.forEach(function (item) { + let itemKeys = get(item, def.localKeys) || [] + itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) + localKeys = localKeys.concat(itemKeys || []) + }) + task = self.findAll(relatedMapper, { + where: { + [relatedMapper.idAttribute]: { + 'in': unique(localKeys).filter(function (x) { return x }) } - }, __options).then(relatedItems => { - DSUtils.forEach(items, item => { - let attached = [] - let itemKeys = item[def.localKeys] || [] - itemKeys = Array.isArray(itemKeys) ? itemKeys : DSUtils.keys(itemKeys) - DSUtils.forEach(relatedItems, relatedItem => { - if (itemKeys && DSUtils.contains(itemKeys, relatedItem[relationDef.idAttribute])) { - attached.push(relatedItem) - } - }) - DSUtils.set(item, def.localField, attached) + } + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + const attached = [] + let itemKeys = get(item, def.localKeys) || [] + itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem) + } }) - return relatedItems + set(item, def.localField, attached) }) - } else if (def.type === 'belongsTo' || (def.type === 'hasOne' && def.localKey)) { - task = this.findAll(resourceConfig.getResource(relationName), { - where: { - [relationDef.idAttribute]: { - 'in': DSUtils.filter(map(items, item => DSUtils.get(item, def.localKey)), x => x) - } + return relatedItems + }) + } else if (def.type === 'belongsTo') { + task = self.findAll(relatedMapper, { + where: { + [relatedMapper.idAttribute]: { + 'in': records.map(function (item) { + return get(item, def.foreignKey) + }).filter(function (x) { return x }) } - }, __options).then(relatedItems => { - DSUtils.forEach(items, item => { - DSUtils.forEach(relatedItems, relatedItem => { - if (relatedItem[relationDef.idAttribute] === item[def.localKey]) { - DSUtils.set(item, def.localField, relatedItem) - } - }) + } + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) { + set(item, def.localField, relatedItem) + } }) - return relatedItems }) - } + return relatedItems + }) + } - if (task) { - tasks.push(task) - } + if (task) { + tasks.push(task) } }) - return DSUtils.Promise.all(tasks) - }).then(() => items) - } - - create (resourceConfig, attrs, options) { - return createTask((resolve, reject) => { - queueTask(() => { - attrs[resourceConfig.idAttribute] = attrs[resourceConfig.idAttribute] || guid() - options = options || {} - this.PUT( - DSUtils.makePath(this.getIdPath(resourceConfig, options, attrs[resourceConfig.idAttribute])), - DSUtils.omit(attrs, resourceConfig.relationFields || []) - ).then(item => { - this.ensureId(item[resourceConfig.idAttribute], resourceConfig, options) - resolve(item) - }).catch(reject) + return Promise.all(tasks) + }).then(function () { + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll' + return resolve(self[op](mapper, query, opts, records)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? records : _records + return opts.raw ? { + data: records, + found: records.length + } : records }) }) - } + }, - createMany (resourceConfig, items, options) { - return createTask((resolve, reject) => { - queueTask(() => { - const tasks = [] - const ids = [] - DSUtils.forEach(items, attrs => { - const id = attrs[resourceConfig.idAttribute] = attrs[resourceConfig.idAttribute] || guid() - ids.push(id) - options = options || {} - tasks.push(this.PUT( - DSUtils.makePath(this.getIdPath(resourceConfig, options, id)), - DSUtils.omit(attrs, resourceConfig.relationFields || []) - )) - }) - this.ensureId(ids, resourceConfig, options) - return DSUtils.Promise.all(tasks).then(resolve).catch(reject) + /** + * TODO + * + * @name LocalStorageAdapter#getPath + * @method + */ + getPath (mapper, opts) { + opts = opts || {} + return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name) + }, + + /** + * TODO + * + * @name LocalStorageAdapter#getIdPath + * @method + */ + getIdPath (mapper, opts, id) { + opts = opts || {} + return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id) + }, + + /** + * TODO + * + * @name LocalStorageAdapter#getIds + * @method + */ + getIds (mapper, opts) { + let ids + const idsPath = this.getPath(mapper, opts) + const idsJson = this.storage.getItem(idsPath) + if (idsJson) { + ids = fromJson(idsJson) + } else { + ids = {} + } + return ids + }, + + /** + * TODO + * + * @name LocalStorageAdapter#log + * @method + */ + log (level, ...args) { + if (level && !args.length) { + args.push(level) + level = 'debug' + } + if (level === 'debug' && !this.debug) { + return + } + const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)` + if (console[level]) { + console[level](prefix, ...args) + } else { + console.log(prefix, ...args) + } + }, + + /** + * TODO + * + * @name LocalStorageAdapter#removeId + * @method + */ + removeId (id, mapper, opts) { + const ids = this.getIds(mapper, opts) + if (isArray(id)) { + if (!id.length) { + return + } + id.forEach(function (_id) { + delete ids[_id] }) - }) - } + } else { + delete ids[id] + } + this.saveKeys(ids, mapper, opts) + }, + + /** + * TODO + * + * @name LocalStorageAdapter#saveKeys + * @method + */ + saveKeys (ids, mapper, opts) { + ids = ids || {} + const idsPath = this.getPath(mapper, opts) + if (Object.keys(ids).length) { + this.storage.setItem(idsPath, toJson(ids)) + } else { + this.storage.removeItem(idsPath) + } + }, - update (resourceConfig, id, attrs, options) { - return createTask((resolve, reject) => { - queueTask(() => { - options = options || {} - this.PUT(this.getIdPath(resourceConfig, options, id), DSUtils.omit(attrs, resourceConfig.relationFields || [])).then(item => { - this.ensureId(item[resourceConfig.idAttribute], resourceConfig, options) - resolve(item) - }).catch(reject) + /** + * Update the records that match the selection `query`. If a record with the + * specified primary key cannot be found then no update is performed and the + * promise is resolved with `undefined`. + * + * @name LocalStorageAdapter#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] TODO + * @return {Promise} + */ + update (mapper, id, props, opts) { + const self = this + props || (props = {}) + opts || (opts = {}) + + return createTask(function (success, failure) { + queueTask(function () { + let op + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate' + return resolve(self[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = isUndefined(_props) ? props : _props + const key = self.getIdPath(mapper, opts, id) + let record = self.storage.getItem(key) + record = record ? fromJson(record) : undefined + let updated = 0 + + // Update the record + // TODO: Update related records when the "with" option is provided + if (record) { + deepMixIn(record, props) + self.storage.setItem(key, toJson(record)) + updated++ + } + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate' + return self[op](mapper, id, props, opts, record).then(function (_record) { + // Allow for re-assignment from lifecycle hook + record = isUndefined(_record) ? record : _record + return opts.raw ? { + data: record, + updated + } : record + }) + }).then(success, failure) }) }) - } + }, - updateAll (resourceConfig, attrs, params, options) { - return this.findAll(resourceConfig, params, options).then(items => { - const tasks = [] - DSUtils.forEach(items, item => tasks.push(this.update(resourceConfig, item[resourceConfig.idAttribute], DSUtils.omit(attrs, resourceConfig.relationFields || []), options))) - return DSUtils.Promise.all(tasks) - }) - } + /** + * Update the records that match the selection `query`. + * + * @name LocalStorageAdapter#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} [opts] Configuration options. + * @return {Promise} + */ + updateAll (mapper, props, query, opts) { + const self = this + props || (props = {}) + query || (query = {}) + opts || (opts = {}) + + return createTask(function (success, failure) { + queueTask(function () { + let op + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll' + return resolve(self[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = isUndefined(_props) ? props : _props + op = opts.op = 'updateAll' + self.dbg(op, query, opts) + + // Find the records that are to be updated + return self.findAll(mapper, query, opts) + }).then(function (records) { + const idAttribute = mapper.idAttribute + let updated = 0 + + // Update each record + // TODO: Update related records when the "with" option is provided + records.forEach(function (record) { + record || (record = {}) + const id = get(record, idAttribute) + const key = self.getIdPath(mapper, opts, id) + deepMixIn(record, props) + self.storage.setItem(key, toJson(record)) + updated++ + }) - destroy (resourceConfig, id, options) { - return createTask((resolve, reject) => { - queueTask(() => { - options = options || {} - this.DEL(this.getIdPath(resourceConfig, options, id)) - .then(() => this.removeId(id, resourceConfig, options)) - .then(() => resolve(null), reject) + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll' + return self[op](mapper, props, query, opts, records).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? records : _records + return opts.raw ? { + data: records, + updated + } : records + }) + }).then(success, failure) }) }) - } + }, + + /** + * Update the given records in a single batch. + * + * @name LocalStorageAdapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] TODO + * @return {Promise} + */ + updateMany (mapper, records, opts) { + const self = this + records || (records = []) + opts || (opts = {}) + + return createTask(function (success, failure) { + queueTask(function () { + let op + let updatedRecords = [] + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany' + return resolve(self[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? records : _records + op = opts.op = 'updateMany' + self.dbg(op, records, opts) - destroyAll (resourceConfig, params, options) { - return this.findAll(resourceConfig, params, options).then(items => { - const ids = [] - DSUtils.forEach(items, item => { - const id = item[resourceConfig.idAttribute] - ids.push(id) - this.storage.removeItem(this.getIdPath(resourceConfig, options, id)) + const idAttribute = mapper.idAttribute + + // Update each record + // TODO: Update related records when the "with" option is provided + records.forEach(function (record) { + if (!record) { + return + } + const id = get(record, idAttribute) + if (isUndefined(id)) { + return + } + const key = self.getIdPath(mapper, opts, id) + let json = self.storage.getItem(key) + const existingRecord = json ? fromJson(json) : undefined + if (!existingRecord) { + return + } + deepMixIn(existingRecord, record) + self.storage.setItem(key, toJson(existingRecord)) + updatedRecords.push(existingRecord) + }) + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany' + return self[op](mapper, records, opts, updatedRecords).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? updatedRecords : _records + return opts.raw ? { + data: records, + updated: updatedRecords.length + } : records + }) + }).then(success, failure) }) - this.removeId(ids, resourceConfig, options) - return ids }) } -} +}) -DSLocalStorageAdapter.version = { +/** + * Details of the current version of the `js-data-localstorage` module. + * + * @name LocalStorageAdapter.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. + */ +LocalStorageAdapter.version = { full: '<%= pkg.version %>', major: parseInt('<%= major %>', 10), minor: parseInt('<%= minor %>', 10), @@ -447,4 +1117,27 @@ DSLocalStorageAdapter.version = { beta: '<%= beta %>' !== 'false' ? '<%= beta %>' : false } -module.exports = DSLocalStorageAdapter +/** + * Registered as `js-data-localstorage` in NPM and Bower. + * + * __Script tag__: + * ```javascript + * window.LocalStorageAdapter + * ``` + * __CommonJS__: + * ```javascript + * var LocalStorageAdapter = require('js-data-localstorage') + * ``` + * __ES6 Modules__: + * ```javascript + * import LocalStorageAdapter from 'js-data-localstorage' + * ``` + * __AMD__: + * ```javascript + * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... }) + * ``` + * + * @module js-data-localstorage + */ + +module.exports = LocalStorageAdapter diff --git a/webpack.config.js b/webpack.config.js index 4dd9dcf..a35e29c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,9 +1,14 @@ +var path = require('path') + module.exports = { - entry: './src/index.js', + devtool: 'source-map', + entry: { + './dist/js-data-localstorage.js': './src/index.js' + }, output: { - filename: './dist/js-data-localstorage.js', + filename: '[name]', libraryTarget: 'umd', - library: 'DSLocalStorageAdapter' + library: 'LocalStorageAdapter' }, externals: { 'js-data': { @@ -16,13 +21,12 @@ module.exports = { module: { loaders: [ { - test: /(src)(.+)\.js$/, - exclude: /(node_modules|bower_components)/, - loader: 'babel', - query: { - presets: ['es2015'] - } + loader: 'babel-loader', + include: [ + path.resolve(__dirname, 'src') + ], + test: /\.js$/ } ] } -}; \ No newline at end of file +} From da34a476f8512b22d3f8986bdbc55d41ebb010b0 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sat, 13 Feb 2016 18:28:09 -0800 Subject: [PATCH 02/15] Stable Version 3.0.0-alpha.2 --- CHANGELOG.md | 9 +++++ dist/js-data-localstorage.js | 64 +++---------------------------- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 4 +- dist/js-data-localstorage.min.map | 2 +- package.json | 4 +- src/index.js | 58 ++-------------------------- 7 files changed, 24 insertions(+), 119 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 570ecd6..7c3601c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +##### 3.0.0-alpha.2 - 13 February 2016 + +- Now making use of JSData.utils.forEachRelation + +##### 3.0.0-alpha.1 - 13 February 2016 + +- Added support for `raw` option +- Added lifecycle hooks + ##### 2.3.2 - 12 December 2015 ###### Backwards compatible bug fixes diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index 1c942d5..b43da9f 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1,6 +1,6 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.1 - Homepage +* @version 3.0.0-alpha.2 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT @@ -74,10 +74,10 @@ return /******/ (function(modules) { // webpackBootstrap var Query = JSData.Query; var utils = JSData.utils; var addHiddenPropsToTarget = utils.addHiddenPropsToTarget; - var copy = utils.copy; var deepMixIn = utils.deepMixIn; var extend = utils.extend; var fillIn = utils.fillIn; + var forEachRelation = utils.forEachRelation; var forOwn = utils.forOwn; var fromJson = utils.fromJson; var get = utils.get; @@ -651,35 +651,9 @@ return /******/ (function(modules) { // webpackBootstrap } record = fromJson(record); var tasks = []; - var relationList = mapper.relationList || []; - relationList.forEach(function (def) { - var relationName = def.relation; + forEachRelation(mapper, opts, function (def, __opts) { var relatedMapper = def.getRelation(); - var containedName = null; - if (opts.with.indexOf(relationName) !== -1) { - containedName = relationName; - } else if (opts.with.indexOf(def.localField) !== -1) { - containedName = def.localField; - } - if (!containedName) { - return; - } - var __opts = copy(opts); - __opts.with = opts.with.slice(); - fillIn(__opts, relatedMapper); - var index = __opts.with.indexOf(containedName); - if (index >= 0) { - __opts.with.splice(index, 1); - } - __opts.with.forEach(function (relation, i) { - if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { - __opts.with[i] = relation.substr(containedName.length + 1); - } else { - __opts.with[i] = ''; - } - }); - var task = undefined; if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { @@ -779,35 +753,9 @@ return /******/ (function(modules) { // webpackBootstrap }); records = _query.filter(query).run(); var tasks = []; - var relationList = mapper.relationList || []; - relationList.forEach(function (def) { - var relationName = def.relation; + forEachRelation(mapper, opts, function (def, __opts) { var relatedMapper = def.getRelation(); - var containedName = null; - if (opts.with.indexOf(relationName) !== -1) { - containedName = relationName; - } else if (opts.with.indexOf(def.localField) !== -1) { - containedName = def.localField; - } - if (!containedName) { - return; - } - var __opts = copy(opts); - __opts.with = opts.with.slice(); - fillIn(__opts, relatedMapper); - var index = __opts.with.indexOf(containedName); - if (index >= 0) { - __opts.with.splice(index, 1); - } - __opts.with.forEach(function (relation, i) { - if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { - __opts.with[i] = relation.substr(containedName.length + 1); - } else { - __opts.with[i] = ''; - } - }); - var task = undefined; if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { @@ -1217,11 +1165,11 @@ return /******/ (function(modules) { // webpackBootstrap * otherwise `false` if the current version is not beta. */ LocalStorageAdapter.version = { - full: '3.0.0-alpha.1', + full: '3.0.0-alpha.2', major: parseInt('3', 10), minor: parseInt('0', 10), patch: parseInt('0', 10), - alpha: true ? '1' : false, + alpha: true ? '2' : false, beta: true ? 'false' : false }; diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index 8176a51..6656414 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap fbe6266b96afe5f0f650","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray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AAT,EAAyB,EAAzB,CAAP;AACA,UAAO,QAA6B,cAA7B,GAA8C,KAA9C;AACP,SAAM,QAA4B,aAA5B,GAA4C,KAA5C;EANR;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,QAAO,OAAP,GAAiB,mBAAjB,C;;;;;;ACtnCA,gD;;;;;;ACAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 fbe6266b96afe5f0f650\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n copy,\n deepMixIn,\n extend,\n fillIn,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDEL\n * @method\n */\n afterDEL: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterGET\n * @method\n */\n afterGET: noop2,\n\n /**\n * @name LocalStorageAdapter#afterPUT\n * @method\n */\n afterPUT: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDEL\n * @method\n */\n beforeDEL: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeGET\n * @method\n */\n beforeGET: noop,\n\n /**\n * @name LocalStorageAdapter#beforePUT\n * @method\n */\n beforePUT: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n const id = get(record, mapper.idAttribute) || guid()\n set(record, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(record))\n self.ensureId(id, mapper, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n const idAttribute = mapper.idAttribute\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n records.forEach(function (record) {\n const id = get(record, idAttribute) || guid()\n set(record, idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n self.storage.setItem(key, toJson(record))\n self.ensureId(id, mapper, opts)\n })\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return self[op](mapper, id, opts).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: id,\n deleted: 1\n } : id\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (isUndefined(record)) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n const relationList = mapper.relationList || []\n\n relationList.forEach(function (def) {\n const relationName = def.relation\n const relatedMapper = def.getRelation()\n let containedName = null\n if (opts.with.indexOf(relationName) !== -1) {\n containedName = relationName\n } else if (opts.with.indexOf(def.localField) !== -1) {\n containedName = def.localField\n }\n if (!containedName) {\n return\n }\n let __opts = copy(opts)\n __opts.with = opts.with.slice()\n fillIn(__opts, relatedMapper)\n const index = __opts.with.indexOf(containedName)\n if (index >= 0) {\n __opts.with.splice(index, 1)\n }\n __opts.with.forEach(function (relation, i) {\n if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {\n __opts.with[i] = relation.substr(containedName.length + 1)\n } else {\n __opts.with[i] = ''\n }\n })\n\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n const relationList = mapper.relationList || []\n\n relationList.forEach(function (def) {\n const relationName = def.relation\n const relatedMapper = def.getRelation()\n let containedName = null\n if (opts.with.indexOf(relationName) !== -1) {\n containedName = relationName\n } else if (opts.with.indexOf(def.localField) !== -1) {\n containedName = def.localField\n }\n if (!containedName) {\n return\n }\n let __opts = copy(opts)\n __opts.with = opts.with.slice()\n fillIn(__opts, relatedMapper)\n const index = __opts.with.indexOf(containedName)\n if (index >= 0) {\n __opts.with.splice(index, 1)\n }\n __opts.with.forEach(function (relation, i) {\n if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {\n __opts.with[i] = relation.substr(containedName.length + 1)\n } else {\n __opts.with[i] = ''\n }\n })\n\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return self[op](mapper, id, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 145c8d90430110fb7773","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;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QAA6B,cAA7B,GAA8C,KAA9C;AACP,SAAM,QAA4B,aAA5B,GAA4C,KAA5C;EANR;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,QAAO,OAAP,GAAiB,mBAAjB,C;;;;;;AClkCA,gD;;;;;;ACAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 145c8d90430110fb7773\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDEL\n * @method\n */\n afterDEL: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterGET\n * @method\n */\n afterGET: noop2,\n\n /**\n * @name LocalStorageAdapter#afterPUT\n * @method\n */\n afterPUT: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDEL\n * @method\n */\n beforeDEL: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeGET\n * @method\n */\n beforeGET: noop,\n\n /**\n * @name LocalStorageAdapter#beforePUT\n * @method\n */\n beforePUT: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n const id = get(record, mapper.idAttribute) || guid()\n set(record, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(record))\n self.ensureId(id, mapper, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n const idAttribute = mapper.idAttribute\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n records.forEach(function (record) {\n const id = get(record, idAttribute) || guid()\n set(record, idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n self.storage.setItem(key, toJson(record))\n self.ensureId(id, mapper, opts)\n })\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return self[op](mapper, id, opts).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: id,\n deleted: 1\n } : id\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (isUndefined(record)) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return self[op](mapper, id, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index 0675c90..aeacdaf 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -1,11 +1,11 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.1 - Homepage +* @version 3.0.0-alpha.2 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){K.push(t)}function c(){K.length&&!D&&(D=!0,K[0]())}function l(t){K.length?f(t):(f(t),c())}function s(t){return new Promise(t).then(function(t){return D=!1,K.shift(),setTimeout(c,0),t},function(t){return D=!1,K.shift(),setTimeout(c,0),M(t)})}function d(t){w(this,t||{}),w(this,L)}var h=n(1),p=n(2),g=h.Query,v=h.utils,y=v.addHiddenPropsToTarget,b=v.copy,A=v.deepMixIn,m=v.extend,w=v.fillIn,I=v.forOwn,x=v.fromJson,P=v.get,E=v.isArray,F=v.isUndefined,O=v.resolve,M=v.reject,j=v.set,U=v.toJson,K=[],D=!1,T=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),O()},C=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),O()},L={basePath:"",debug:!1,storage:localStorage};d.extend=m,y(d.prototype,{afterCreate:C,afterCreateMany:C,afterDEL:C,afterDestroy:C,afterDestroyAll:C,afterFind:C,afterFindAll:C,afterGET:C,afterPUT:C,afterUpdate:C,afterUpdateAll:C,afterUpdateMany:C,beforeCreate:T,beforeCreateMany:T,beforeDEL:T,beforeDestroy:T,beforeDestroyAll:T,beforeFind:T,beforeFindAll:T,beforeGET:T,beforePUT:T,beforeUpdate:T,beforeUpdateAll:T,beforeUpdateMany:T,create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",O(r[i](t,e,n)).then(function(o){var a=F(o)?e:o,u=P(a,t.idAttribute)||p();j(a,t.idAttribute,u);var f=r.getIdPath(t,n,u);return r.storage.setItem(f,U(a)),r.ensureId(u,t,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=F(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",O(r[i](t,e,n)).then(function(o){var a=F(o)?e:o,u=t.idAttribute;return a.forEach(function(e){var o=P(e,u)||p();j(e,u,o);var a=r.getIdPath(t,n,o);r.storage.setItem(a,U(e)),r.ensureId(o,t,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=F(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroy",O(r[i](t,e,n)).then(function(){return i=n.op="destroy",r.dbg(i,e,n),r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),i=n.op="afterDestroy",r[i](t,e,n).then(function(t){return e=F(t)?e:t,n.raw?{data:e,deleted:1}:e})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroyAll",O(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return P(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=F(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",O(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),F(a))return void(a=void 0);a=x(a);var c=[],l=t.relationList||[];return l.forEach(function(e){var i=e.relation,f=e.getRelation(),l=null;if(-1!==n.with.indexOf(i)?l=i:-1!==n.with.indexOf(e.localField)&&(l=e.localField),l){var s=b(n);s.with=n.with.slice(),w(s,f);var d=s.with.indexOf(l);d>=0&&s.with.splice(d,1),s.with.forEach(function(t,e){t&&0===t.indexOf(l)&&t.length>=l.length&&"."===t[l.length]?s.with[e]=t.substr(l.length+1):s.with[e]=""});var h=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var p=[],g=P(a,e.localKeys)||[];g=Array.isArray(g)?g:Object.keys(g),p=p.concat(g||[]),h=o.findAll(f,{where:r({},f.idAttribute,{in:u(p).filter(function(t){return t})})},s).then(function(t){return j(a,e.localField,t),t})}else"belongsTo"===e.type&&(h=o.find(f,P(a,e.foreignKey),s).then(function(t){return j(a,e.localField,t),t}));else h=o.findAll(f,r({},e.foreignKey,P(a,t.idAttribute)),s).then(function(t){return"hasOne"===e.type&&t.length?j(a,e.localField,t[0]):j(a,e.localField,t),t});h&&c.push(h)}}),Promise.all(c)}).then(function(){return i=n.op="afterFind",O(o[i](t,e,n,a)).then(function(t){return a=F(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",O(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);I(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(x(i))});var c=t.idAttribute,l=new g({index:{getAll:function(){return a}}});a=l.filter(e).run();var s=[],d=t.relationList||[];return d.forEach(function(t){var e=t.relation,i=t.getRelation(),f=null;if(-1!==n.with.indexOf(e)?f=e:-1!==n.with.indexOf(t.localField)&&(f=t.localField),f){var l=b(n);l.with=n.with.slice(),w(l,i);var d=l.with.indexOf(f);d>=0&&l.with.splice(d,1),l.with.forEach(function(t,e){t&&0===t.indexOf(f)&&t.length>=f.length&&"."===t[f.length]?l.with[e]=t.substr(f.length+1):l.with[e]=""});var h=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var e=[];a.forEach(function(n){var r=P(n,t.localKeys)||[];r=Array.isArray(r)?r:Object.keys(r),e=e.concat(r||[])}),h=o.findAll(i,{where:r({},i.idAttribute,{in:u(e).filter(function(t){return t})})},l).then(function(e){return a.forEach(function(n){var r=[],o=P(n,t.localKeys)||[];o=Array.isArray(o)?o:Object.keys(o),e.forEach(function(t){o&&-1!==o.indexOf(t[i.idAttribute])&&r.push(t)}),j(n,t.localField,r)}),e})}():"belongsTo"===t.type&&(h=o.findAll(i,{where:r({},i.idAttribute,{in:a.map(function(e){return P(e,t.foreignKey)}).filter(function(t){return t})})},l).then(function(e){return a.forEach(function(n){e.forEach(function(e){e[i.idAttribute]===P(n,t.foreignKey)&&j(n,t.localField,e)})}),e})):h=o.findAll(i,{where:r({},t.foreignKey,{in:a.map(function(t){return P(t,c)}).filter(function(t){return t})})},l).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){P(e,t.foreignKey)===P(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?j(n,t.localField,r[0]):j(n,t.localField,r)}),e}),h&&s.push(h)}}),Promise.all(s)}).then(function(){return i=n.op="afterFindAll",O(o[i](t,e,n,a)).then(function(t){return a=F(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?x(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,U(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),s(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",O(o[u](t,e,n,r)).then(function(a){n=F(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?x(f):void 0;var c=0;return f&&(A(f,n),o.storage.setItem(i,U(f)),c++),u=r.op="afterUpdate",o[u](t,e,n,r,f).then(function(t){return f=F(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),s(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",O(o[u](t,e,n,r)).then(function(a){return e=F(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=P(n,i),u=o.getIdPath(t,r,a);A(n,e),o.storage.setItem(u,U(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=F(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),s(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",O(r[i](t,e,n)).then(function(o){e=F(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=P(e,a);if(!F(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?x(f):void 0;c&&(A(c,e),r.storage.setItem(i,U(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=F(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),d.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=d},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){O.push(t)}function c(){O.length&&!D&&(D=!0,O[0]())}function s(t){O.length?f(t):(f(t),c())}function l(t){return new Promise(t).then(function(t){return D=!1,O.shift(),setTimeout(c,0),t},function(t){return D=!1,O.shift(),setTimeout(c,0),U(t)})}function d(t){m(this,t||{}),m(this,S)}var h=n(1),p=n(2),g=h.Query,v=h.utils,y=v.addHiddenPropsToTarget,b=v.deepMixIn,A=v.extend,m=v.fillIn,I=v.forEachRelation,P=v.forOwn,x=v.fromJson,w=v.get,E=v.isArray,M=v.isUndefined,j=v.resolve,U=v.reject,F=v.set,K=v.toJson,O=[],D=!1,T=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),j()},C=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),j()},S={basePath:"",debug:!1,storage:localStorage};d.extend=A,y(d.prototype,{afterCreate:C,afterCreateMany:C,afterDEL:C,afterDestroy:C,afterDestroyAll:C,afterFind:C,afterFindAll:C,afterGET:C,afterPUT:C,afterUpdate:C,afterUpdateAll:C,afterUpdateMany:C,beforeCreate:T,beforeCreateMany:T,beforeDEL:T,beforeDestroy:T,beforeDestroyAll:T,beforeFind:T,beforeFindAll:T,beforeGET:T,beforePUT:T,beforeUpdate:T,beforeUpdateAll:T,beforeUpdateMany:T,create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),l(function(o,a){s(function(){var i=void 0;return i=n.op="beforeCreate",j(r[i](t,e,n)).then(function(o){var a=M(o)?e:o,u=w(a,t.idAttribute)||p();F(a,t.idAttribute,u);var f=r.getIdPath(t,n,u);return r.storage.setItem(f,K(a)),r.ensureId(u,t,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),l(function(o,a){s(function(){var i=void 0;return i=n.op="beforeCreateMany",j(r[i](t,e,n)).then(function(o){var a=M(o)?e:o,u=t.idAttribute;return a.forEach(function(e){var o=w(e,u)||p();F(e,u,o);var a=r.getIdPath(t,n,o);r.storage.setItem(a,K(e)),r.ensureId(o,t,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),l(function(o,a){s(function(){var i=void 0;return i=n.op="beforeDestroy",j(r[i](t,e,n)).then(function(){return i=n.op="destroy",r.dbg(i,e,n),r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),i=n.op="afterDestroy",r[i](t,e,n).then(function(t){return e=M(t)?e:t,n.raw?{data:e,deleted:1}:e})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),l(function(o,a){s(function(){var i=void 0;return i=n.op="beforeDestroyAll",j(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return w(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=M(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",j(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),M(a))return void(a=void 0);a=x(a);var c=[];return I(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var s=[],l=w(a,e.localKeys)||[];l=Array.isArray(l)?l:Object.keys(l),s=s.concat(l||[]),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(s).filter(function(t){return t})})},n).then(function(t){return F(a,e.localField,t),t})}else"belongsTo"===e.type&&(f=o.find(i,w(a,e.foreignKey),n).then(function(t){return F(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,w(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?F(a,e.localField,t[0]):F(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",j(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",j(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);P(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(x(i))});var c=t.idAttribute,s=new g({index:{getAll:function(){return a}}});a=s.filter(e).run();var l=[];return I(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=w(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n||[])}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=w(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),F(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return w(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===w(r,t.foreignKey)&&F(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return w(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){w(e,t.foreignKey)===w(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?F(n,t.localField,r[0]):F(n,t.localField,r)}),e}),i&&l.push(i)}),Promise.all(l)}).then(function(){return i=n.op="afterFindAll",j(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?x(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,K(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),l(function(a,i){s(function(){var u=void 0;return u=r.op="beforeUpdate",j(o[u](t,e,n,r)).then(function(a){n=M(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?x(f):void 0;var c=0;return f&&(b(f,n),o.storage.setItem(i,K(f)),c++),u=r.op="afterUpdate",o[u](t,e,n,r,f).then(function(t){return f=M(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),l(function(a,i){s(function(){var u=void 0;return u=r.op="beforeUpdateAll",j(o[u](t,e,n,r)).then(function(a){return e=M(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=w(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,K(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=M(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),l(function(o,a){s(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",j(r[i](t,e,n)).then(function(o){e=M(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=w(e,a);if(!M(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?x(f):void 0;c&&(b(c,e),r.storage.setItem(i,K(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=M(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),d.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=d},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); //# sourceMappingURL=dist/js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index dced51d..b37e7e1 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","copy","deepMixIn","extend","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDEL","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterGET","afterPUT","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDEL","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeGET","beforePUT","beforeUpdate","beforeUpdateAll","beforeUpdateMany","create","mapper","props","success","failure","undefined","_props","record","idAttribute","getIdPath","setItem","ensureId","_record","raw","data","created","createMany","records","_records","_len4","_key4","log","destroy","removeItem","removeId","_id","deleted","destroyAll","query","findAll","ids","map","_ids","getIds","saveKeys","find","with","getItem","tasks","relationList","def","relationName","relation","relatedMapper","getRelation","containedName","indexOf","localField","__opts","slice","index","splice","i","substr","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","relatedItem","all","found","json","_query","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAEA,SAASS,GAAgBC,EAAKC,EAAKC,GAAiK,MAApJD,KAAO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C,EAAa,MAAPA,EAAaE,IAAYF,EAIxBG,KAAKC,MAAOC,EAAKN,EAAM,GAAKC,EAAM,gBAbjD,GAAIC,GAAU7N,EAAoB,GAC9B8N,EAAU9N,EAAoB,GAC9BiO,EAAOjO,EAAoB,EAc3BP,GAAOD,QAAUkO,GAMhB,SAASjO,EAAQD,GAMlBC,EAAOD,QAAU,aAMhB,SAASC,EAAQD,GAMlBC,EAAOD,QAAU,YAMhB,SAASC,EAAQD,EAASQ,GAS3B,QAASiO,GAAKN,EAAKC,GAGf,MAFAD,GAAa,MAAPA,EAAaE,EAAUF,EAC7BC,EAAa,MAAPA,EAAaE,EAAUF,EACtBD,GAAOC,EAAMD,GAAOO,IAVnC,GAAIA,GAASlO,EAAoB,GAC7B6N,EAAU7N,EAAoB,GAC9B8N,EAAU9N,EAAoB,EAW9BP,GAAOD,QAAUyO,GAMhB,SAASxO,EAAQD,GAUlB,QAAS0O,KACL,MAAOA,GAAO/J,MAIlB+J,EAAO/J,IAAM4J,KAAKG,OAElBzO,EAAOD,QAAU0O,GAOhB,SAASzO,EAAQD,EAASQ,GAE/B,GAAImO,GAASnO,EAAoB,IAGzBoE,EAAUxC,MAAMwC,SAAW,SAAUgK,GACrC,MAAOD,GAAOC,EAAK,SAEvB3O,GAAOD,QAAU4E,GAMhB,SAAS3E,EAAQD,EAASQ,GAM3B,QAASmO,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAAStO,EAAoB,GAO7BP,GAAOD,QAAU2O,GAMhB,SAAS1O,EAAQD,GAWlB,QAAS8O,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAUrO,KAAK+N,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAY7N,OAAO2E,UAAUmJ,QAejClP,GAAOD,QAAU8O","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDEL","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterGET","afterPUT","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDEL","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeGET","beforePUT","beforeUpdate","beforeUpdateAll","beforeUpdateMany","create","mapper","props","success","failure","undefined","_props","record","idAttribute","getIdPath","setItem","ensureId","_record","raw","data","created","createMany","records","_records","_len4","_key4","log","destroy","removeItem","removeId","_id","deleted","destroyAll","query","findAll","ids","map","_ids","getIds","saveKeys","find","with","getItem","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","relatedItem","all","found","json","_query","index","getAll","run","attached","indexOf","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxC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uJ,EAAOvJ,IAAMoJ,KAAKG,OAElBjO,EAAOD,QAAUkO,GAOhB,SAASjO,EAAQD,EAASQ,GAE/B,GAAI2N,GAAS3N,EAAoB,IAGzBoE,EAAUxC,MAAMwC,SAAW,SAAUwJ,GACrC,MAAOD,GAAOC,EAAK,SAEvBnO,GAAOD,QAAU4E,GAMhB,SAAS3E,EAAQD,EAASQ,GAM3B,QAAS2N,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAAS9N,EAAoB,GAO7BP,GAAOD,QAAUmO,GAMhB,SAASlO,EAAQD,GAWlB,QAASsO,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAU7N,KAAKuN,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAYrN,OAAO2E,UAAU2I,QAejC1O,GAAOD,QAAUsO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index 3372ac4..ecfbc20 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "version": "3.0.0-alpha.1", + "version": "3.0.0-alpha.2", "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", @@ -38,7 +38,7 @@ "ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | coveralls || true && cat ./coverage/PhantomJS*/lcov.info | codacy-coverage || true" }, "dependencies": { - "js-data": "^3.0.0-alpha.13" + "js-data": "^3.0.0-alpha.14" }, "devDependencies": { "babel-core": "6.5.2", diff --git a/src/index.js b/src/index.js index 023aace..651642f 100644 --- a/src/index.js +++ b/src/index.js @@ -9,10 +9,10 @@ const { const { addHiddenPropsToTarget, - copy, deepMixIn, extend, fillIn, + forEachRelation, forOwn, fromJson, get, @@ -561,35 +561,9 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { } record = fromJson(record) const tasks = [] - const relationList = mapper.relationList || [] - relationList.forEach(function (def) { - const relationName = def.relation + forEachRelation(mapper, opts, function (def, __opts) { const relatedMapper = def.getRelation() - let containedName = null - if (opts.with.indexOf(relationName) !== -1) { - containedName = relationName - } else if (opts.with.indexOf(def.localField) !== -1) { - containedName = def.localField - } - if (!containedName) { - return - } - let __opts = copy(opts) - __opts.with = opts.with.slice() - fillIn(__opts, relatedMapper) - const index = __opts.with.indexOf(containedName) - if (index >= 0) { - __opts.with.splice(index, 1) - } - __opts.with.forEach(function (relation, i) { - if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { - __opts.with[i] = relation.substr(containedName.length + 1) - } else { - __opts.with[i] = '' - } - }) - let task if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { @@ -690,35 +664,9 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { }) records = _query.filter(query).run() const tasks = [] - const relationList = mapper.relationList || [] - relationList.forEach(function (def) { - const relationName = def.relation + forEachRelation(mapper, opts, function (def, __opts) { const relatedMapper = def.getRelation() - let containedName = null - if (opts.with.indexOf(relationName) !== -1) { - containedName = relationName - } else if (opts.with.indexOf(def.localField) !== -1) { - containedName = def.localField - } - if (!containedName) { - return - } - let __opts = copy(opts) - __opts.with = opts.with.slice() - fillIn(__opts, relatedMapper) - const index = __opts.with.indexOf(containedName) - if (index >= 0) { - __opts.with.splice(index, 1) - } - __opts.with.forEach(function (relation, i) { - if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { - __opts.with[i] = relation.substr(containedName.length + 1) - } else { - __opts.with[i] = '' - } - }) - let task if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { From 9e821fec18a487a37f8d4f797065c064efc8b43e Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sun, 14 Feb 2016 00:19:01 -0800 Subject: [PATCH 03/15] Experimental support for deep create. --- karma.start.js | 76 +++++++++++++++++++++++++++++++++++++--- package.json | 11 ++++-- src/index.js | 94 ++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 157 insertions(+), 24 deletions(-) diff --git a/karma.start.js b/karma.start.js index cb49510..7d91a5e 100644 --- a/karma.start.js +++ b/karma.start.js @@ -1,8 +1,8 @@ beforeEach(function () { - localStorage.clear(); -}); + localStorage.clear() +}) -window.assert = TestRunner.assert; +window.assert = TestRunner.assert TestRunner.init({ features: [], @@ -11,4 +11,72 @@ TestRunner.init({ adapterConfig: { debug: false } -}); +}) + +describe('relation functionality', function () { + it('nested create', function () { + var adapter = this.$$adapter + var User = this.$$User + return adapter.create(User, { + name: 'John', + profile: { + email: 'john@test.com' + }, + posts: [ + { + content: 'foo' + } + ] + }, { with: ['profile', 'post'] }).then(function (user) { + // console.log(JSON.stringify(user, null, 2)) + assert.isDefined(user) + assert.isDefined(user.id) + assert.isDefined(user.profile) + assert.isDefined(user.profile.id) + assert.isDefined(user.posts) + assert.equal(user.posts.length, 1) + assert.isDefined(user.posts[0].id) + }) + }) + it('nested create many', function () { + var adapter = this.$$adapter + var User = this.$$User + return adapter.createMany(User, [{ + name: 'John', + profile: { + email: 'john@test.com' + }, + posts: [ + { + content: 'foo' + } + ] + }, { + name: 'Sally', + profile: { + email: 'sally@test.com' + }, + posts: [ + { + content: 'foo' + } + ] + }], { with: ['profile', 'post'] }).then(function (users) { + // console.log(JSON.stringify(users, null, 2)) + assert.isDefined(users[0]) + assert.isDefined(users[0].id) + assert.isDefined(users[0].profile) + assert.isDefined(users[0].profile.id) + assert.isDefined(users[0].posts) + assert.equal(users[0].posts.length, 1) + assert.isDefined(users[0].posts[0].id) + assert.isDefined(users[1]) + assert.isDefined(users[1].id) + assert.isDefined(users[1].profile) + assert.isDefined(users[1].profile.id) + assert.isDefined(users[1].posts) + assert.equal(users[1].posts.length, 1) + assert.isDefined(users[1].posts[0].id) + }) + }) +}) diff --git a/package.json b/package.json index ecfbc20..c0561ee 100644 --- a/package.json +++ b/package.json @@ -21,13 +21,20 @@ "standard": { "parser": "babel-eslint", "globals": [ - "localStorage" + "localStorage", + "beforeEach", + "describe", + "assert", + "TestRunner", + "it", + "JSData", + "LocalStorageAdapter" ] }, "scripts": { "bundle": "webpack --config webpack.config.js --colors", "doc": "jsdoc -c conf.json src && node scripts/cleanup.js", - "lint": "standard src/**/*.js", + "lint": "standard src/**/*.js karma.start.js", "min": "uglifyjs dist/js-data-localstorage.js -o dist/js-data-localstorage.min.js --source-map dist/js-data-localstorage.min.map -v -m -c --screw-ie8", "version": "node scripts/version.js", "banner": "node scripts/banner.js", diff --git a/src/index.js b/src/index.js index 651642f..2f0aaab 100644 --- a/src/index.js +++ b/src/index.js @@ -305,6 +305,79 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { */ beforeUpdateMany: noop, + _create (mapper, props, opts) { + const self = this + const id = get(props, mapper.idAttribute) || guid() + set(props, mapper.idAttribute, id) + const key = self.getIdPath(mapper, opts, id) + + // Create the record + // TODO: Create related records when the "with" option is provided + self.storage.setItem(key, toJson(props)) + self.ensureId(id, mapper, opts) + return fromJson(self.storage.getItem(key)) + }, + + _createWithRelations (mapper, record, opts) { + const self = this + const fields = {} + opts.with || (opts.with = []) + const idAttribute = mapper.idAttribute + forEachRelation(mapper, opts, function (def, __opts) { + const localField = def.localField + const relationData = get(record, localField) + const relatedMapper = def.getRelation() + if (!relationData) { + return + } + if (def.type === 'hasMany') { + fields[localField] = relationData + } else if (def.type === 'hasOne') { + fields[localField] = relationData + } else if (def.type === 'belongsTo') { + fields[localField] = self._createWithRelations(relatedMapper, relationData, __opts) + set(record, def.foreignKey, get(fields[localField], relatedMapper.idAttribute)) + } + }) + const _props = {} + forOwn(record, function (value, key) { + if (!(key in fields)) { + _props[key] = value + } + }) + + const id = get(_props, idAttribute) || guid() + set(_props, idAttribute, id) + const key = self.getIdPath(mapper, opts, id) + + // Create the record + // TODO: Create related records when the "with" option is provided + self.storage.setItem(key, toJson(_props)) + self.ensureId(id, mapper, opts) + record = fromJson(self.storage.getItem(key)) + + forEachRelation(mapper, opts, function (def, __opts) { + const localField = def.localField + const relationData = fields[localField] + const relatedMapper = def.getRelation() + if (!relationData) { + return + } + if (def.type === 'hasMany') { + fields[localField] = relationData.map(function (relatedDataItem) { + set(relatedDataItem, def.foreignKey, id) + return self._createWithRelations(relatedMapper, relatedDataItem, __opts) + }) + } else if (def.type === 'hasOne') { + set(relationData, def.foreignKey, id) + fields[localField] = self._createWithRelations(relatedMapper, relationData, __opts) + } + }) + + fillIn(record, fields) + return record + }, + /** * Create a new record. * @@ -329,14 +402,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { return resolve(self[op](mapper, props, opts)).then(function (_props) { // Allow for re-assignment from lifecycle hook let record = isUndefined(_props) ? props : _props - const id = get(record, mapper.idAttribute) || guid() - set(record, mapper.idAttribute, id) - const key = self.getIdPath(mapper, opts, id) - - // Create the record - // TODO: Create related records when the "with" option is provided - self.storage.setItem(key, toJson(record)) - self.ensureId(id, mapper, opts) + record = self._createWithRelations(mapper, record, opts) // afterCreate lifecycle hook op = opts.op = 'afterCreate' @@ -377,16 +443,8 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { return resolve(self[op](mapper, props, opts)).then(function (_props) { // Allow for re-assignment from lifecycle hook let records = isUndefined(_props) ? props : _props - const idAttribute = mapper.idAttribute - - // Create the record - // TODO: Create related records when the "with" option is provided - records.forEach(function (record) { - const id = get(record, idAttribute) || guid() - set(record, idAttribute, id) - const key = self.getIdPath(mapper, opts, id) - self.storage.setItem(key, toJson(record)) - self.ensureId(id, mapper, opts) + records = records.map(function (record) { + return self._createWithRelations(mapper, record, opts) }) // afterCreateMany lifecycle hook From 2b099ccf8c025ae5dbfdf0bb5df8dc68e71afc93 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Mon, 15 Feb 2016 20:58:36 -0800 Subject: [PATCH 04/15] Cleanup. --- dist/js-data-localstorage.js | 44 ++++++++++--------- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 2 +- dist/js-data-localstorage.min.map | 2 +- karma.start.js | 30 +++++++++---- src/index.js | 71 ++++--------------------------- 6 files changed, 57 insertions(+), 94 deletions(-) diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index b43da9f..180c508 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -384,6 +384,27 @@ return /******/ (function(modules) { // webpackBootstrap */ beforeUpdateMany: noop, + _create: function _create(mapper, props, opts) { + var self = this; + var _props = {}; + var relationFields = mapper.relationFields || []; + forOwn(props, function (value, key) { + if (relationFields.indexOf(key) === -1) { + _props[key] = value; + } + }); + var id = get(_props, mapper.idAttribute) || guid(); + set(_props, mapper.idAttribute, id); + var key = self.getIdPath(mapper, opts, id); + + // Create the record + // TODO: Create related records when the "with" option is provided + self.storage.setItem(key, toJson(_props)); + self.ensureId(id, mapper, opts); + return fromJson(self.storage.getItem(key)); + }, + + /** * Create a new record. * @@ -408,15 +429,7 @@ return /******/ (function(modules) { // webpackBootstrap return resolve(self[op](mapper, props, opts)).then(function (_props) { // Allow for re-assignment from lifecycle hook var record = isUndefined(_props) ? props : _props; - var id = get(record, mapper.idAttribute) || guid(); - set(record, mapper.idAttribute, id); - var key = self.getIdPath(mapper, opts, id); - - // Create the record - // TODO: Create related records when the "with" option is provided - self.storage.setItem(key, toJson(record)); - self.ensureId(id, mapper, opts); - + record = self._create(mapper, record, opts); // afterCreate lifecycle hook op = opts.op = 'afterCreate'; return self[op](mapper, props, opts, record).then(function (_record) { @@ -457,18 +470,9 @@ return /******/ (function(modules) { // webpackBootstrap return resolve(self[op](mapper, props, opts)).then(function (_props) { // Allow for re-assignment from lifecycle hook var records = isUndefined(_props) ? props : _props; - var idAttribute = mapper.idAttribute; - - // Create the record - // TODO: Create related records when the "with" option is provided - records.forEach(function (record) { - var id = get(record, idAttribute) || guid(); - set(record, idAttribute, id); - var key = self.getIdPath(mapper, opts, id); - self.storage.setItem(key, toJson(record)); - self.ensureId(id, mapper, opts); + records = records.map(function (record) { + return self._create(mapper, record, opts); }); - // afterCreateMany lifecycle hook op = opts.op = 'afterCreateMany'; return self[op](mapper, props, opts, records).then(function (_records) { diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index 6656414..d4174c4 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 145c8d90430110fb7773","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;;;;;;ACrCA,KAAM,SAAS,oBAAQ,CAAR,CAAT;AACN,KAAM,OAAO,oBAAQ,CAAR,CAAP;;KAGJ,QAEE,OAFF;KACA,QACE,OADF;KAIA,yBAcE,MAdF;KACA,YAaE,MAbF;KACA,SAYE,MAZF;KACA,SAWE,MAXF;KACA,kBAUE,MAVF;KACA,SASE,MATF;KACA,WAQE,MARF;KACA,MAOE,MAPF;KACA,UAME,MANF;KACA,cAKE,MALF;KACA,UAIE,MAJF;KACA,SAGE,MAHF;KACA,MAEE,MAFF;KACA,SACE,MADF;;;AAGF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A;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 145c8d90430110fb7773\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDEL\n * @method\n */\n afterDEL: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterGET\n * @method\n */\n afterGET: noop2,\n\n /**\n * @name LocalStorageAdapter#afterPUT\n * @method\n */\n afterPUT: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDEL\n * @method\n */\n beforeDEL: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeGET\n * @method\n */\n beforeGET: noop,\n\n /**\n * @name LocalStorageAdapter#beforePUT\n * @method\n */\n beforePUT: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n const id = get(record, mapper.idAttribute) || guid()\n set(record, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(record))\n self.ensureId(id, mapper, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n const idAttribute = mapper.idAttribute\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n records.forEach(function (record) {\n const id = get(record, idAttribute) || guid()\n set(record, idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n self.storage.setItem(key, toJson(record))\n self.ensureId(id, mapper, opts)\n })\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return self[op](mapper, id, opts).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: id,\n deleted: 1\n } : id\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (isUndefined(record)) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return self[op](mapper, id, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 44f46103f4ff839e8bae","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;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GAA8B;AAC5B,SAAM,oBAAN;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,QAA6B,cAA7B,GAA8C,KAA9C;AACP,SAAM,QAA4B,aAA5B,GAA4C,KAA5C;EANR;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,QAAO,OAAP,GAAiB,mBAAjB,C;;;;;;ACrkCA,gD;;;;;;ACAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 44f46103f4ff839e8bae\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDEL\n * @method\n */\n afterDEL: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterGET\n * @method\n */\n afterGET: noop2,\n\n /**\n * @name LocalStorageAdapter#afterPUT\n * @method\n */\n afterPUT: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDEL\n * @method\n */\n beforeDEL: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeGET\n * @method\n */\n beforeGET: noop,\n\n /**\n * @name LocalStorageAdapter#beforePUT\n * @method\n */\n beforePUT: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n _create (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n record = self._create(mapper, record, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n records = records.map(function (record) {\n return self._create(mapper, record, opts)\n })\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return self[op](mapper, id, opts).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: id,\n deleted: 1\n } : id\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (isUndefined(record)) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return self[op](mapper, id, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index aeacdaf..d54cced 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -7,5 +7,5 @@ * * @overview localStorage adapter for js-data. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){O.push(t)}function c(){O.length&&!D&&(D=!0,O[0]())}function s(t){O.length?f(t):(f(t),c())}function l(t){return new Promise(t).then(function(t){return D=!1,O.shift(),setTimeout(c,0),t},function(t){return D=!1,O.shift(),setTimeout(c,0),U(t)})}function d(t){m(this,t||{}),m(this,S)}var h=n(1),p=n(2),g=h.Query,v=h.utils,y=v.addHiddenPropsToTarget,b=v.deepMixIn,A=v.extend,m=v.fillIn,I=v.forEachRelation,P=v.forOwn,x=v.fromJson,w=v.get,E=v.isArray,M=v.isUndefined,j=v.resolve,U=v.reject,F=v.set,K=v.toJson,O=[],D=!1,T=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),j()},C=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),j()},S={basePath:"",debug:!1,storage:localStorage};d.extend=A,y(d.prototype,{afterCreate:C,afterCreateMany:C,afterDEL:C,afterDestroy:C,afterDestroyAll:C,afterFind:C,afterFindAll:C,afterGET:C,afterPUT:C,afterUpdate:C,afterUpdateAll:C,afterUpdateMany:C,beforeCreate:T,beforeCreateMany:T,beforeDEL:T,beforeDestroy:T,beforeDestroyAll:T,beforeFind:T,beforeFindAll:T,beforeGET:T,beforePUT:T,beforeUpdate:T,beforeUpdateAll:T,beforeUpdateMany:T,create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),l(function(o,a){s(function(){var i=void 0;return i=n.op="beforeCreate",j(r[i](t,e,n)).then(function(o){var a=M(o)?e:o,u=w(a,t.idAttribute)||p();F(a,t.idAttribute,u);var f=r.getIdPath(t,n,u);return r.storage.setItem(f,K(a)),r.ensureId(u,t,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),l(function(o,a){s(function(){var i=void 0;return i=n.op="beforeCreateMany",j(r[i](t,e,n)).then(function(o){var a=M(o)?e:o,u=t.idAttribute;return a.forEach(function(e){var o=w(e,u)||p();F(e,u,o);var a=r.getIdPath(t,n,o);r.storage.setItem(a,K(e)),r.ensureId(o,t,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),l(function(o,a){s(function(){var i=void 0;return i=n.op="beforeDestroy",j(r[i](t,e,n)).then(function(){return i=n.op="destroy",r.dbg(i,e,n),r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),i=n.op="afterDestroy",r[i](t,e,n).then(function(t){return e=M(t)?e:t,n.raw?{data:e,deleted:1}:e})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),l(function(o,a){s(function(){var i=void 0;return i=n.op="beforeDestroyAll",j(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return w(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=M(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",j(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),M(a))return void(a=void 0);a=x(a);var c=[];return I(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var s=[],l=w(a,e.localKeys)||[];l=Array.isArray(l)?l:Object.keys(l),s=s.concat(l||[]),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(s).filter(function(t){return t})})},n).then(function(t){return F(a,e.localField,t),t})}else"belongsTo"===e.type&&(f=o.find(i,w(a,e.foreignKey),n).then(function(t){return F(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,w(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?F(a,e.localField,t[0]):F(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",j(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",j(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);P(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(x(i))});var c=t.idAttribute,s=new g({index:{getAll:function(){return a}}});a=s.filter(e).run();var l=[];return I(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=w(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n||[])}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=w(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),F(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return w(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===w(r,t.foreignKey)&&F(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return w(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){w(e,t.foreignKey)===w(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?F(n,t.localField,r[0]):F(n,t.localField,r)}),e}),i&&l.push(i)}),Promise.all(l)}).then(function(){return i=n.op="afterFindAll",j(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?x(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,K(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),l(function(a,i){s(function(){var u=void 0;return u=r.op="beforeUpdate",j(o[u](t,e,n,r)).then(function(a){n=M(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?x(f):void 0;var c=0;return f&&(b(f,n),o.storage.setItem(i,K(f)),c++),u=r.op="afterUpdate",o[u](t,e,n,r,f).then(function(t){return f=M(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),l(function(a,i){s(function(){var u=void 0;return u=r.op="beforeUpdateAll",j(o[u](t,e,n,r)).then(function(a){return e=M(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=w(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,K(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=M(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),l(function(o,a){s(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",j(r[i](t,e,n)).then(function(o){e=M(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=w(e,a);if(!M(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?x(f):void 0;c&&(b(c,e),r.storage.setItem(i,K(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=M(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),d.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=d},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){O.push(t)}function c(){O.length&&!D&&(D=!0,O[0]())}function l(t){O.length?f(t):(f(t),c())}function s(t){return new Promise(t).then(function(t){return D=!1,O.shift(),setTimeout(c,0),t},function(t){return D=!1,O.shift(),setTimeout(c,0),F(t)})}function d(t){m(this,t||{}),m(this,S)}var h=n(1),p=n(2),g=h.Query,v=h.utils,y=v.addHiddenPropsToTarget,b=v.deepMixIn,A=v.extend,m=v.fillIn,I=v.forEachRelation,x=v.forOwn,P=v.fromJson,w=v.get,E=v.isArray,M=v.isUndefined,j=v.resolve,F=v.reject,U=v.set,K=v.toJson,O=[],D=!1,T=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),j()},C=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),j()},S={basePath:"",debug:!1,storage:localStorage};d.extend=A,y(d.prototype,{afterCreate:C,afterCreateMany:C,afterDEL:C,afterDestroy:C,afterDestroyAll:C,afterFind:C,afterFindAll:C,afterGET:C,afterPUT:C,afterUpdate:C,afterUpdateAll:C,afterUpdateMany:C,beforeCreate:T,beforeCreateMany:T,beforeDEL:T,beforeDestroy:T,beforeDestroyAll:T,beforeFind:T,beforeFindAll:T,beforeGET:T,beforePUT:T,beforeUpdate:T,beforeUpdateAll:T,beforeUpdateMany:T,_create:function(t,e,n){var r=this,o={},a=t.relationFields||[];x(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=w(o,t.idAttribute)||p();U(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,K(o)),r.ensureId(i,t,n),P(r.storage.getItem(u))},create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",j(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=r._create(t,a,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",j(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=a.map(function(e){return r._create(t,e,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroy",j(r[i](t,e,n)).then(function(){return i=n.op="destroy",r.dbg(i,e,n),r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),i=n.op="afterDestroy",r[i](t,e,n).then(function(t){return e=M(t)?e:t,n.raw?{data:e,deleted:1}:e})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroyAll",j(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return w(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=M(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",j(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),M(a))return void(a=void 0);a=P(a);var c=[];return I(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var l=[],s=w(a,e.localKeys)||[];s=Array.isArray(s)?s:Object.keys(s),l=l.concat(s||[]),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(l).filter(function(t){return t})})},n).then(function(t){return U(a,e.localField,t),t})}else"belongsTo"===e.type&&(f=o.find(i,w(a,e.foreignKey),n).then(function(t){return U(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,w(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?U(a,e.localField,t[0]):U(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",j(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",j(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);x(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(P(i))});var c=t.idAttribute,l=new g({index:{getAll:function(){return a}}});a=l.filter(e).run();var s=[];return I(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=w(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n||[])}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=w(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),U(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return w(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===w(r,t.foreignKey)&&U(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return w(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){w(e,t.foreignKey)===w(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?U(n,t.localField,r[0]):U(n,t.localField,r)}),e}),i&&s.push(i)}),Promise.all(s)}).then(function(){return i=n.op="afterFindAll",j(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?P(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,K(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),s(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",j(o[u](t,e,n,r)).then(function(a){n=M(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?P(f):void 0;var c=0;return f&&(b(f,n),o.storage.setItem(i,K(f)),c++),u=r.op="afterUpdate",o[u](t,e,n,r,f).then(function(t){return f=M(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),s(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",j(o[u](t,e,n,r)).then(function(a){return e=M(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=w(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,K(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=M(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),s(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",j(r[i](t,e,n)).then(function(o){e=M(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=w(e,a);if(!M(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?P(f):void 0;c&&(b(c,e),r.storage.setItem(i,K(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=M(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),d.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=d},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); //# sourceMappingURL=dist/js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index b37e7e1..1122a62 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDEL","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterGET","afterPUT","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDEL","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeGET","beforePUT","beforeUpdate","beforeUpdateAll","beforeUpdateMany","create","mapper","props","success","failure","undefined","_props","record","idAttribute","getIdPath","setItem","ensureId","_record","raw","data","created","createMany","records","_records","_len4","_key4","log","destroy","removeItem","removeId","_id","deleted","destroyAll","query","findAll","ids","map","_ids","getIds","saveKeys","find","with","getItem","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","relatedItem","all","found","json","_query","index","getAll","run","attached","indexOf","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAEA,SAASS,GAAgBC,EAAKC,EAAKC,GAAiK,MAApJD,KAAOD,GAAOG,OAAOC,eAAeJ,EAAKC,GAAOC,MAAOA,EAAOG,YAAY,EAAMC,cAAc,EAAMC,UAAU,IAAkBP,EAAIC,GAAOC,EAAgBF,EAwB3M,QAASQ,GAAcN,GACrB,MAAgB,OAATA,GAA2B,KAAVA,EAE1B,QAASO,GAAKC,EAAOC,GAEnB,MADAA,KAAcA,EAAY,IACnBD,EAAME,OAAOJ,GAAeC,KAAKE,GAE1C,QAASE,KACP,IAAK,GAAIC,GAAOC,UAAUC,OAAQC,EAAOC,MAAMJ,GAAOK,EAAO,EAAUL,EAAPK,EAAaA,IAC3EF,EAAKE,GAAQJ,UAAUI,EAGzB,IAAI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,IAVnC,GAAIA,GAAS1N,EAAoB,GAC7BqN,EAAUrN,EAAoB,GAC9BsN,EAAUtN,EAAoB,EAW9BP,GAAOD,QAAUiO,GAMhB,SAAShO,EAAQD,GAUlB,QAASkO,KACL,MAAOA,GAAOvJ,MAIlBuJ,EAAOvJ,IAAMoJ,KAAKG,OAElBjO,EAAOD,QAAUkO,GAOhB,SAASjO,EAAQD,EAASQ,GAE/B,GAAI2N,GAAS3N,EAAoB,IAGzBoE,EAAUxC,MAAMwC,SAAW,SAAUwJ,GACrC,MAAOD,GAAOC,EAAK,SAEvBnO,GAAOD,QAAU4E,GAMhB,SAAS3E,EAAQD,EAASQ,GAM3B,QAAS2N,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAAS9N,EAAoB,GAO7BP,GAAOD,QAAUmO,GAMhB,SAASlO,EAAQD,GAWlB,QAASsO,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAU7N,KAAKuN,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAYrN,OAAO2E,UAAU2I,QAejC1O,GAAOD,QAAUsO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDEL","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterGET","afterPUT","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDEL","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeGET","beforePUT","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_create","mapper","props","_props","relationFields","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","create","success","failure","undefined","record","_record","raw","data","created","createMany","records","map","_records","_len4","_key4","log","destroy","removeItem","removeId","_id","deleted","destroyAll","query","findAll","ids","_ids","getIds","saveKeys","find","with","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","relatedItem","all","found","json","_query","index","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAAS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,GAMhB,SAASpO,EAAQD,GAWlB,QAASwO,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAU/N,KAAKyN,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAYvN,OAAO2E,UAAU6I,QAejC5O,GAAOD,QAAUwO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/karma.start.js b/karma.start.js index 7d91a5e..55773fe 100644 --- a/karma.start.js +++ b/karma.start.js @@ -15,22 +15,26 @@ TestRunner.init({ describe('relation functionality', function () { it('nested create', function () { - var adapter = this.$$adapter - var User = this.$$User - return adapter.create(User, { + return this.$$container.create('user', { name: 'John', profile: { email: 'john@test.com' }, + organization: { + name: 'Company Inc' + }, posts: [ { content: 'foo' } ] - }, { with: ['profile', 'post'] }).then(function (user) { + }, { with: ['profile', 'post', 'organization'] }).then(function (user) { // console.log(JSON.stringify(user, null, 2)) assert.isDefined(user) assert.isDefined(user.id) + assert.isDefined(user.organization) + assert.isDefined(user.organization.id) + assert.equal(user.organizationId, user.organization.id) assert.isDefined(user.profile) assert.isDefined(user.profile.id) assert.isDefined(user.posts) @@ -38,14 +42,15 @@ describe('relation functionality', function () { assert.isDefined(user.posts[0].id) }) }) - it('nested create many', function () { - var adapter = this.$$adapter - var User = this.$$User - return adapter.createMany(User, [{ + it.skip('nested create many', function () { + return this.$$container.create('user', [{ name: 'John', profile: { email: 'john@test.com' }, + organization: { + name: 'Company Inc' + }, posts: [ { content: 'foo' @@ -56,6 +61,9 @@ describe('relation functionality', function () { profile: { email: 'sally@test.com' }, + organization: { + name: 'Company Inc' + }, posts: [ { content: 'foo' @@ -65,6 +73,9 @@ describe('relation functionality', function () { // console.log(JSON.stringify(users, null, 2)) assert.isDefined(users[0]) assert.isDefined(users[0].id) + assert.isDefined(users[0].organization) + assert.isDefined(users[0].organization.id) + assert.equal(users[0].organizationId, users[0].organization.id) assert.isDefined(users[0].profile) assert.isDefined(users[0].profile.id) assert.isDefined(users[0].posts) @@ -72,6 +83,9 @@ describe('relation functionality', function () { assert.isDefined(users[0].posts[0].id) assert.isDefined(users[1]) assert.isDefined(users[1].id) + assert.isDefined(users[1].organization) + assert.isDefined(users[1].organization.id) + assert.equal(users[1].organizationId, users[1].organization.id) assert.isDefined(users[1].profile) assert.isDefined(users[1].profile.id) assert.isDefined(users[1].posts) diff --git a/src/index.js b/src/index.js index 2f0aaab..bbd2014 100644 --- a/src/index.js +++ b/src/index.js @@ -307,75 +307,22 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { _create (mapper, props, opts) { const self = this - const id = get(props, mapper.idAttribute) || guid() - set(props, mapper.idAttribute, id) - const key = self.getIdPath(mapper, opts, id) - - // Create the record - // TODO: Create related records when the "with" option is provided - self.storage.setItem(key, toJson(props)) - self.ensureId(id, mapper, opts) - return fromJson(self.storage.getItem(key)) - }, - - _createWithRelations (mapper, record, opts) { - const self = this - const fields = {} - opts.with || (opts.with = []) - const idAttribute = mapper.idAttribute - forEachRelation(mapper, opts, function (def, __opts) { - const localField = def.localField - const relationData = get(record, localField) - const relatedMapper = def.getRelation() - if (!relationData) { - return - } - if (def.type === 'hasMany') { - fields[localField] = relationData - } else if (def.type === 'hasOne') { - fields[localField] = relationData - } else if (def.type === 'belongsTo') { - fields[localField] = self._createWithRelations(relatedMapper, relationData, __opts) - set(record, def.foreignKey, get(fields[localField], relatedMapper.idAttribute)) - } - }) const _props = {} - forOwn(record, function (value, key) { - if (!(key in fields)) { + const relationFields = mapper.relationFields || [] + forOwn(props, function (value, key) { + if (relationFields.indexOf(key) === -1) { _props[key] = value } }) - - const id = get(_props, idAttribute) || guid() - set(_props, idAttribute, id) + const id = get(_props, mapper.idAttribute) || guid() + set(_props, mapper.idAttribute, id) const key = self.getIdPath(mapper, opts, id) // Create the record // TODO: Create related records when the "with" option is provided self.storage.setItem(key, toJson(_props)) self.ensureId(id, mapper, opts) - record = fromJson(self.storage.getItem(key)) - - forEachRelation(mapper, opts, function (def, __opts) { - const localField = def.localField - const relationData = fields[localField] - const relatedMapper = def.getRelation() - if (!relationData) { - return - } - if (def.type === 'hasMany') { - fields[localField] = relationData.map(function (relatedDataItem) { - set(relatedDataItem, def.foreignKey, id) - return self._createWithRelations(relatedMapper, relatedDataItem, __opts) - }) - } else if (def.type === 'hasOne') { - set(relationData, def.foreignKey, id) - fields[localField] = self._createWithRelations(relatedMapper, relationData, __opts) - } - }) - - fillIn(record, fields) - return record + return fromJson(self.storage.getItem(key)) }, /** @@ -402,8 +349,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { return resolve(self[op](mapper, props, opts)).then(function (_props) { // Allow for re-assignment from lifecycle hook let record = isUndefined(_props) ? props : _props - record = self._createWithRelations(mapper, record, opts) - + record = self._create(mapper, record, opts) // afterCreate lifecycle hook op = opts.op = 'afterCreate' return self[op](mapper, props, opts, record).then(function (_record) { @@ -444,9 +390,8 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { // Allow for re-assignment from lifecycle hook let records = isUndefined(_props) ? props : _props records = records.map(function (record) { - return self._createWithRelations(mapper, record, opts) + return self._create(mapper, record, opts) }) - // afterCreateMany lifecycle hook op = opts.op = 'afterCreateMany' return self[op](mapper, props, opts, records).then(function (_records) { From 706c615c9b20df8a3e29674141780ff52a15b302 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Thu, 18 Feb 2016 21:29:58 -0800 Subject: [PATCH 05/15] 3.0.0-alpha.3 --- CHANGELOG.md | 4 ++++ dist/js-data-localstorage.js | 6 +++--- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 2 +- karma.conf.js | 6 ++++-- karma.prestart.js | 1 + karma.start.js | 8 ++++---- package.json | 19 ++++++++++--------- 8 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 karma.prestart.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c3601c..0554207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +##### 3.0.0-alpha.3 - 18 February 2016 + +- Upgraded dependencies + ##### 3.0.0-alpha.2 - 13 February 2016 - Now making use of JSData.utils.forEachRelation diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index 180c508..d01270d 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1,6 +1,6 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.2 - Homepage +* @version 3.0.0-alpha.3 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT @@ -1169,11 +1169,11 @@ return /******/ (function(modules) { // webpackBootstrap * otherwise `false` if the current version is not beta. */ LocalStorageAdapter.version = { - full: '3.0.0-alpha.2', + full: '3.0.0-alpha.3', major: parseInt('3', 10), minor: parseInt('0', 10), patch: parseInt('0', 10), - alpha: true ? '2' : false, + alpha: true ? '3' : false, beta: true ? 'false' : false }; diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index d4174c4..2326291 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 44f46103f4ff839e8bae","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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,uBA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,CAAlB,CALiC;IA7zBiB;EAAtD;;;;;;;;;;;;;;;;AAm4BA,qBAAoB,OAApB,GAA8B;AAC5B,SAAM,oBAAN;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,QAA6B,cAA7B,GAA8C,KAA9C;AACP,SAAM,QAA4B,aAA5B,GAA4C,KAA5C;EANR;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,QAAO,OAAP,GAAiB,mBAAjB,C;;;;;;ACrkCA,gD;;;;;;ACAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 44f46103f4ff839e8bae\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDEL\n * @method\n */\n afterDEL: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterGET\n * @method\n */\n afterGET: noop2,\n\n /**\n * @name LocalStorageAdapter#afterPUT\n * @method\n */\n afterPUT: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDEL\n * @method\n */\n beforeDEL: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeGET\n * @method\n */\n beforeGET: noop,\n\n /**\n * @name LocalStorageAdapter#beforePUT\n * @method\n */\n beforePUT: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n _create (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n record = self._create(mapper, record, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n records = records.map(function (record) {\n return self._create(mapper, record, opts)\n })\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return self[op](mapper, id, opts).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: id,\n deleted: 1\n } : id\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (isUndefined(record)) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return self[op](mapper, id, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 167066b8fe58f17fbc41","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;;;;;;ACrCA,KAAM,SAAS,oBAAQ,CAAR,CAAT;AACN,KAAM,OAAO,oBAAQ,CAAR,CAAP;;KAGJ,QAEE,OAFF;KACA,QACE,OADF;KAIA,yBAcE,MAdF;KACA,YAaE,MAbF;KACA,SAYE,MAZF;KACA,SAWE,MAXF;KACA,kBAUE,MAVF;KACA,SASE,MATF;KACA,WAQE,MARF;KACA,MAOE,MAPF;KACA,UAME,MANF;KACA,cAKE,MALF;KACA,UAIE,MAJF;KACA,SAGE,MAHF;KACA,MAEE,MAFF;KACA,SACE,MADF;;;AAGF,UAAS,aAAT,CAAwB,KAAxB,EAA+B;AAC7B,UAAQ,SAAS,IAAT,IAAiB,UAAU,EAAV,CADI;EAA/B;AAGA,UAAS,IAAT,CAAe,KAAf,EAAsB,SAAtB,EAAiC;AAC/B,iBAAc,YA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AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 167066b8fe58f17fbc41\n **/","/* global: localStorage */\r\nconst JSData = require('js-data')\r\nconst guid = require('mout/random/guid')\r\n\r\nconst {\r\n Query,\r\n utils\r\n} = JSData\r\n\r\nconst {\r\n addHiddenPropsToTarget,\r\n deepMixIn,\r\n extend,\r\n fillIn,\r\n forEachRelation,\r\n forOwn,\r\n fromJson,\r\n get,\r\n isArray,\r\n isUndefined,\r\n resolve,\r\n reject,\r\n set,\r\n toJson\r\n} = utils\r\n\r\nfunction isValidString (value) {\r\n return (value != null && value !== '')\r\n}\r\nfunction join (items, separator) {\r\n separator || (separator = '')\r\n return items.filter(isValidString).join(separator)\r\n}\r\nfunction makePath (...args) {\r\n let result = join(args, '/')\r\n return result.replace(/([^:\\/]|^)\\/{2,}/g, '$1/')\r\n}\r\nfunction unique (array) {\r\n const seen = {}\r\n const final = []\r\n array.forEach(function (item) {\r\n if (item in seen) {\r\n return\r\n }\r\n final.push(item)\r\n seen[item] = 0\r\n })\r\n return final\r\n}\r\nlet queue = []\r\nlet taskInProcess = false\r\n\r\nfunction enqueue (task) {\r\n queue.push(task)\r\n}\r\n\r\nfunction dequeue () {\r\n if (queue.length && !taskInProcess) {\r\n taskInProcess = true\r\n queue[0]()\r\n }\r\n}\r\n\r\nfunction queueTask (task) {\r\n if (!queue.length) {\r\n enqueue(task)\r\n dequeue()\r\n } else {\r\n enqueue(task)\r\n }\r\n}\r\n\r\nfunction createTask (fn) {\r\n return new Promise(fn).then(function (result) {\r\n taskInProcess = false\r\n queue.shift()\r\n setTimeout(dequeue, 0)\r\n return result\r\n }, function (err) {\r\n taskInProcess = false\r\n queue.shift()\r\n setTimeout(dequeue, 0)\r\n return reject(err)\r\n })\r\n}\r\n\r\nconst noop = function (...args) {\r\n const self = this\r\n const opts = args[args.length - 1]\r\n self.dbg(opts.op, ...args)\r\n return resolve()\r\n}\r\n\r\nconst noop2 = function (...args) {\r\n const self = this\r\n const opts = args[args.length - 2]\r\n self.dbg(opts.op, ...args)\r\n return resolve()\r\n}\r\n\r\nconst DEFAULTS = {\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#basePath\r\n * @type {string}\r\n */\r\n basePath: '',\r\n\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#debug\r\n * @type {boolean}\r\n * @default false\r\n */\r\n debug: false,\r\n\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#storage\r\n * @type {Object}\r\n * @default localStorage\r\n */\r\n storage: localStorage\r\n}\r\n\r\n/**\r\n * LocalStorageAdapter class.\r\n *\r\n * @example\r\n * import {DataStore} from 'js-data'\r\n * import LocalStorageAdapter from 'js-data-localstorage'\r\n * const store = new DataStore()\r\n * const adapter = new LocalStorageAdapter()\r\n * store.registerAdapter('ls', adapter, { 'default': true })\r\n *\r\n * @class LocalStorageAdapter\r\n * @param {Object} [opts] Configuration opts.\r\n * @param {string} [opts.basePath=''] TODO\r\n * @param {boolean} [opts.debug=false] TODO\r\n * @param {Object} [opts.storeage=localStorage] TODO\r\n */\r\nfunction LocalStorageAdapter (opts) {\r\n fillIn(this, opts || {})\r\n fillIn(this, DEFAULTS)\r\n}\r\n\r\n/**\r\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\r\n *\r\n * @name LocalStorageAdapter.extend\r\n * @method\r\n * @param {Object} [instanceProps] Properties that will be added to the\r\n * prototype of the subclass.\r\n * @param {Object} [classProps] Properties that will be added as static\r\n * properties to the subclass itself.\r\n * @return {Object} Subclass of `LocalStorageAdapter`.\r\n */\r\nLocalStorageAdapter.extend = extend\r\n\r\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\r\n /**\r\n * @name LocalStorageAdapter#afterCreate\r\n * @method\r\n */\r\n afterCreate: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterCreateMany\r\n * @method\r\n */\r\n afterCreateMany: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterDEL\r\n * @method\r\n */\r\n afterDEL: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterDestroy\r\n * @method\r\n */\r\n afterDestroy: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterDestroyAll\r\n * @method\r\n */\r\n afterDestroyAll: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterFind\r\n * @method\r\n */\r\n afterFind: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterFindAll\r\n * @method\r\n */\r\n afterFindAll: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterGET\r\n * @method\r\n */\r\n afterGET: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterPUT\r\n * @method\r\n */\r\n afterPUT: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterUpdate\r\n * @method\r\n */\r\n afterUpdate: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterUpdateAll\r\n * @method\r\n */\r\n afterUpdateAll: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#afterUpdateMany\r\n * @method\r\n */\r\n afterUpdateMany: noop2,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeCreate\r\n * @method\r\n */\r\n beforeCreate: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeCreateMany\r\n * @method\r\n */\r\n beforeCreateMany: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeDEL\r\n * @method\r\n */\r\n beforeDEL: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeDestroy\r\n * @method\r\n */\r\n beforeDestroy: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeDestroyAll\r\n * @method\r\n */\r\n beforeDestroyAll: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeFind\r\n * @method\r\n */\r\n beforeFind: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeFindAll\r\n * @method\r\n */\r\n beforeFindAll: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeGET\r\n * @method\r\n */\r\n beforeGET: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforePUT\r\n * @method\r\n */\r\n beforePUT: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeUpdate\r\n * @method\r\n */\r\n beforeUpdate: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeUpdateAll\r\n * @method\r\n */\r\n beforeUpdateAll: noop,\r\n\r\n /**\r\n * @name LocalStorageAdapter#beforeUpdateMany\r\n * @method\r\n */\r\n beforeUpdateMany: noop,\r\n\r\n _create (mapper, props, opts) {\r\n const self = this\r\n const _props = {}\r\n const relationFields = mapper.relationFields || []\r\n forOwn(props, function (value, key) {\r\n if (relationFields.indexOf(key) === -1) {\r\n _props[key] = value\r\n }\r\n })\r\n const id = get(_props, mapper.idAttribute) || guid()\r\n set(_props, mapper.idAttribute, id)\r\n const key = self.getIdPath(mapper, opts, id)\r\n\r\n // Create the record\r\n // TODO: Create related records when the \"with\" option is provided\r\n self.storage.setItem(key, toJson(_props))\r\n self.ensureId(id, mapper, opts)\r\n return fromJson(self.storage.getItem(key))\r\n },\r\n\r\n /**\r\n * Create a new record.\r\n *\r\n * @name LocalStorageAdapter#create\r\n * @method\r\n * @param {Object} mapper The mapper.\r\n * @param {Object} props The record to be created.\r\n * @param {Object} [opts] Configuration options.\r\n * @param {boolean} [opts.raw=false] TODO\r\n * @return {Promise}\r\n */\r\n create (mapper, props, opts) {\r\n const self = this\r\n props || (props = {})\r\n opts || (opts = {})\r\n\r\n return createTask(function (success, failure) {\r\n queueTask(function () {\r\n let op\r\n // beforeCreate lifecycle hook\r\n op = opts.op = 'beforeCreate'\r\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\r\n // Allow for re-assignment from lifecycle hook\r\n let record = isUndefined(_props) ? props : _props\r\n record = self._create(mapper, record, opts)\r\n // afterCreate lifecycle hook\r\n op = opts.op = 'afterCreate'\r\n return self[op](mapper, props, opts, record).then(function (_record) {\r\n // Allow for re-assignment from lifecycle hook\r\n record = isUndefined(_record) ? record : _record\r\n return opts.raw ? {\r\n data: record,\r\n created: 1\r\n } : record\r\n })\r\n }).then(success, failure)\r\n })\r\n })\r\n },\r\n\r\n /**\r\n * Create multiple records in a single batch.\r\n *\r\n * @name LocalStorageAdapter#createMany\r\n * @method\r\n * @param {Object} mapper The mapper.\r\n * @param {Array} props Array of records to be created.\r\n * @param {Object} [opts] Configuration options.\r\n * @param {boolean} [opts.raw=false] TODO\r\n * @return {Promise}\r\n */\r\n createMany (mapper, props, opts) {\r\n const self = this\r\n props || (props = {})\r\n opts || (opts = {})\r\n\r\n return createTask(function (success, failure) {\r\n queueTask(function () {\r\n let op\r\n // beforeCreateMany lifecycle hook\r\n op = opts.op = 'beforeCreateMany'\r\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\r\n // Allow for re-assignment from lifecycle hook\r\n let records = isUndefined(_props) ? props : _props\r\n records = records.map(function (record) {\r\n return self._create(mapper, record, opts)\r\n })\r\n // afterCreateMany lifecycle hook\r\n op = opts.op = 'afterCreateMany'\r\n return self[op](mapper, props, opts, records).then(function (_records) {\r\n // Allow for re-assignment from lifecycle hook\r\n records = isUndefined(_records) ? records : _records\r\n return opts.raw ? {\r\n data: records,\r\n created: records.length\r\n } : records\r\n })\r\n }).then(success, failure)\r\n })\r\n })\r\n },\r\n\r\n /**\r\n * @name LocalStorageAdapter#dbg\r\n * @method\r\n */\r\n dbg (...args) {\r\n this.log('debug', ...args)\r\n },\r\n\r\n /**\r\n * Destroy the record with the given primary key.\r\n *\r\n * @name LocalStorageAdapter#destroy\r\n * @method\r\n * @param {Object} mapper The mapper.\r\n * @param {(string|number)} id Primary key of the record to destroy.\r\n * @param {Object} [opts] Configuration options.\r\n * @param {boolean} [opts.raw=false] TODO\r\n * @return {Promise}\r\n */\r\n destroy (mapper, id, opts) {\r\n const self = this\r\n opts || (opts = {})\r\n\r\n return createTask(function (success, failure) {\r\n queueTask(function () {\r\n let op\r\n // beforeDestroy lifecycle hook\r\n op = opts.op = 'beforeDestroy'\r\n return resolve(self[op](mapper, id, opts)).then(function () {\r\n op = opts.op = 'destroy'\r\n self.dbg(op, id, opts)\r\n // Destroy the record\r\n // TODO: Destroy related records when the \"with\" option is provided\r\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\r\n self.removeId(id, mapper, opts)\r\n\r\n // afterDestroy lifecycle hook\r\n op = opts.op = 'afterDestroy'\r\n return self[op](mapper, id, opts).then(function (_id) {\r\n // Allow for re-assignment from lifecycle hook\r\n id = isUndefined(_id) ? id : _id\r\n return opts.raw ? {\r\n data: id,\r\n deleted: 1\r\n } : id\r\n })\r\n }).then(success, failure)\r\n })\r\n })\r\n },\r\n\r\n /**\r\n * Destroy the records that match the selection `query`.\r\n *\r\n * @name LocalStorageAdapter#destroyAll\r\n * @method\r\n * @param {Object} mapper The mapper.\r\n * @param {Object} query Selection query.\r\n * @param {Object} [opts] Configuration opts.\r\n * @param {boolean} [opts.raw=false] TODO\r\n * @return {Promise}\r\n */\r\n destroyAll (mapper, query, opts) {\r\n const self = this\r\n query || (query = {})\r\n opts || (opts = {})\r\n\r\n return createTask(function (success, failure) {\r\n queueTask(function () {\r\n let op\r\n // beforeDestroyAll lifecycle hook\r\n op = opts.op = 'beforeDestroyAll'\r\n return resolve(self[op](mapper, query, opts)).then(function () {\r\n op = opts.op = 'destroyAll'\r\n self.dbg(op, query, opts)\r\n // Find the records that are to be destroyed\r\n return self.findAll(mapper, query, opts)\r\n }).then(function (records) {\r\n const idAttribute = mapper.idAttribute\r\n // Gather IDs of records to be destroyed\r\n let ids = records.map(function (record) {\r\n return get(record, idAttribute)\r\n })\r\n // Destroy each record\r\n // TODO: Destroy related records when the \"with\" option is provided\r\n ids.forEach(function (id) {\r\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\r\n })\r\n self.removeId(ids, mapper, opts)\r\n\r\n // afterDestroyAll lifecycle hook\r\n op = opts.op = 'afterDestroyAll'\r\n return self[op](mapper, query, opts, ids).then(function (_ids) {\r\n // Allow for re-assignment from lifecycle hook\r\n ids = isUndefined(_ids) ? ids : _ids\r\n return opts.raw ? {\r\n data: ids,\r\n deleted: records.length\r\n } : ids\r\n })\r\n }).then(success, failure)\r\n })\r\n })\r\n },\r\n\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#ensureId\r\n * @method\r\n */\r\n ensureId (id, mapper, opts) {\r\n const ids = this.getIds(mapper, opts)\r\n if (isArray(id)) {\r\n if (!id.length) {\r\n return\r\n }\r\n id.forEach(function (_id) {\r\n ids[_id] = 1\r\n })\r\n } else {\r\n ids[id] = 1\r\n }\r\n this.saveKeys(ids, mapper, opts)\r\n },\r\n\r\n /**\r\n * Retrieve the record with the given primary key.\r\n *\r\n * @name LocalStorageAdapter#find\r\n * @method\r\n * @param {Object} mapper The mapper.\r\n * @param {(string|number)} id Primary key of the record to retrieve.\r\n * @param {Object} [opts] Configuration options.\r\n * @param {boolean} [opts.raw=false] TODO\r\n * @param {string[]} [opts.with=[]] TODO\r\n * @return {Promise}\r\n */\r\n find (mapper, id, opts) {\r\n const self = this\r\n let record, op\r\n opts || (opts = {})\r\n opts.with || (opts.with = [])\r\n\r\n // beforeFind lifecycle hook\r\n op = opts.op = 'beforeFind'\r\n return resolve(self[op](mapper, id, opts)).then(function () {\r\n op = opts.op = 'find'\r\n self.dbg(op, id, opts)\r\n const key = self.getIdPath(mapper, opts, id)\r\n record = self.storage.getItem(key)\r\n if (isUndefined(record)) {\r\n record = undefined\r\n return\r\n }\r\n record = fromJson(record)\r\n const tasks = []\r\n\r\n forEachRelation(mapper, opts, function (def, __opts) {\r\n const relatedMapper = def.getRelation()\r\n let task\r\n\r\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\r\n task = self.findAll(relatedMapper, {\r\n [def.foreignKey]: get(record, mapper.idAttribute)\r\n }, __opts).then(function (relatedItems) {\r\n if (def.type === 'hasOne' && relatedItems.length) {\r\n set(record, def.localField, relatedItems[0])\r\n } else {\r\n set(record, def.localField, relatedItems)\r\n }\r\n return relatedItems\r\n })\r\n } else if (def.type === 'hasMany' && def.localKeys) {\r\n let localKeys = []\r\n let itemKeys = get(record, def.localKeys) || []\r\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\r\n localKeys = localKeys.concat(itemKeys || [])\r\n task = self.findAll(relatedMapper, {\r\n where: {\r\n [relatedMapper.idAttribute]: {\r\n 'in': unique(localKeys).filter(function (x) { return x })\r\n }\r\n }\r\n }, __opts).then(function (relatedItems) {\r\n set(record, def.localField, relatedItems)\r\n return relatedItems\r\n })\r\n } else if (def.type === 'belongsTo') {\r\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\r\n set(record, def.localField, relatedItem)\r\n return relatedItem\r\n })\r\n }\r\n\r\n if (task) {\r\n tasks.push(task)\r\n }\r\n })\r\n\r\n return Promise.all(tasks)\r\n }).then(function () {\r\n // afterFind lifecycle hook\r\n op = opts.op = 'afterFind'\r\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\r\n // Allow for re-assignment from lifecycle hook\r\n record = isUndefined(_record) ? record : _record\r\n return opts.raw ? {\r\n data: record,\r\n found: record ? 1 : 0\r\n } : record\r\n })\r\n })\r\n },\r\n\r\n /**\r\n * Retrieve the records that match the selection `query`.\r\n *\r\n * @name LocalStorageAdapter#findAll\r\n * @method\r\n * @param {Object} mapper The mapper.\r\n * @param {Object} query Selection query.\r\n * @param {Object} [opts] Configuration options.\r\n * @param {boolean} [opts.raw=false] TODO\r\n * @param {string[]} [opts.with=[]] TODO\r\n * @return {Promise}\r\n */\r\n findAll (mapper, query, opts) {\r\n const self = this\r\n let records = []\r\n let op\r\n opts || (opts = {})\r\n opts.with || (opts.with = [])\r\n\r\n // beforeFindAll lifecycle hook\r\n op = opts.op = 'beforeFindAll'\r\n return resolve(self[op](mapper, query, opts)).then(function () {\r\n op = opts.op = 'findAll'\r\n self.dbg(op, query, opts)\r\n\r\n // Load all records into memory...\r\n const ids = self.getIds(mapper, opts)\r\n forOwn(ids, function (value, id) {\r\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\r\n if (json) {\r\n records.push(fromJson(json))\r\n }\r\n })\r\n const idAttribute = mapper.idAttribute\r\n // TODO: Verify that this collection gets properly garbage collected\r\n // TODO: Or, find a way to filter without using Collection\r\n const _query = new Query({\r\n index: {\r\n getAll () {\r\n return records\r\n }\r\n }\r\n })\r\n records = _query.filter(query).run()\r\n const tasks = []\r\n\r\n forEachRelation(mapper, opts, function (def, __opts) {\r\n const relatedMapper = def.getRelation()\r\n let task\r\n\r\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\r\n task = self.findAll(relatedMapper, {\r\n where: {\r\n [def.foreignKey]: {\r\n 'in': records.map(function (item) {\r\n return get(item, idAttribute)\r\n }).filter(function (x) { return x })\r\n }\r\n }\r\n }, __opts).then(function (relatedItems) {\r\n records.forEach(function (item) {\r\n const attached = []\r\n relatedItems.forEach(function (relatedItem) {\r\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\r\n attached.push(relatedItem)\r\n }\r\n })\r\n if (def.type === 'hasOne' && attached.length) {\r\n set(item, def.localField, attached[0])\r\n } else {\r\n set(item, def.localField, attached)\r\n }\r\n })\r\n return relatedItems\r\n })\r\n } else if (def.type === 'hasMany' && def.localKeys) {\r\n let localKeys = []\r\n records.forEach(function (item) {\r\n let itemKeys = get(item, def.localKeys) || []\r\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\r\n localKeys = localKeys.concat(itemKeys || [])\r\n })\r\n task = self.findAll(relatedMapper, {\r\n where: {\r\n [relatedMapper.idAttribute]: {\r\n 'in': unique(localKeys).filter(function (x) { return x })\r\n }\r\n }\r\n }, __opts).then(function (relatedItems) {\r\n records.forEach(function (item) {\r\n const attached = []\r\n let itemKeys = get(item, def.localKeys) || []\r\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\r\n relatedItems.forEach(function (relatedItem) {\r\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\r\n attached.push(relatedItem)\r\n }\r\n })\r\n set(item, def.localField, attached)\r\n })\r\n return relatedItems\r\n })\r\n } else if (def.type === 'belongsTo') {\r\n task = self.findAll(relatedMapper, {\r\n where: {\r\n [relatedMapper.idAttribute]: {\r\n 'in': records.map(function (item) {\r\n return get(item, def.foreignKey)\r\n }).filter(function (x) { return x })\r\n }\r\n }\r\n }, __opts).then(function (relatedItems) {\r\n records.forEach(function (item) {\r\n relatedItems.forEach(function (relatedItem) {\r\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\r\n set(item, def.localField, relatedItem)\r\n }\r\n })\r\n })\r\n return relatedItems\r\n })\r\n }\r\n\r\n if (task) {\r\n tasks.push(task)\r\n }\r\n })\r\n return Promise.all(tasks)\r\n }).then(function () {\r\n // afterFindAll lifecycle hook\r\n op = opts.op = 'afterFindAll'\r\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\r\n // Allow for re-assignment from lifecycle hook\r\n records = isUndefined(_records) ? records : _records\r\n return opts.raw ? {\r\n data: records,\r\n found: records.length\r\n } : records\r\n })\r\n })\r\n },\r\n\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#getPath\r\n * @method\r\n */\r\n getPath (mapper, opts) {\r\n opts = opts || {}\r\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\r\n },\r\n\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#getIdPath\r\n * @method\r\n */\r\n getIdPath (mapper, opts, id) {\r\n opts = opts || {}\r\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\r\n },\r\n\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#getIds\r\n * @method\r\n */\r\n getIds (mapper, opts) {\r\n let ids\r\n const idsPath = this.getPath(mapper, opts)\r\n const idsJson = this.storage.getItem(idsPath)\r\n if (idsJson) {\r\n ids = fromJson(idsJson)\r\n } else {\r\n ids = {}\r\n }\r\n return ids\r\n },\r\n\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#log\r\n * @method\r\n */\r\n log (level, ...args) {\r\n if (level && !args.length) {\r\n args.push(level)\r\n level = 'debug'\r\n }\r\n if (level === 'debug' && !this.debug) {\r\n return\r\n }\r\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\r\n if (console[level]) {\r\n console[level](prefix, ...args)\r\n } else {\r\n console.log(prefix, ...args)\r\n }\r\n },\r\n\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#removeId\r\n * @method\r\n */\r\n removeId (id, mapper, opts) {\r\n const ids = this.getIds(mapper, opts)\r\n if (isArray(id)) {\r\n if (!id.length) {\r\n return\r\n }\r\n id.forEach(function (_id) {\r\n delete ids[_id]\r\n })\r\n } else {\r\n delete ids[id]\r\n }\r\n this.saveKeys(ids, mapper, opts)\r\n },\r\n\r\n /**\r\n * TODO\r\n *\r\n * @name LocalStorageAdapter#saveKeys\r\n * @method\r\n */\r\n saveKeys (ids, mapper, opts) {\r\n ids = ids || {}\r\n const idsPath = this.getPath(mapper, opts)\r\n if (Object.keys(ids).length) {\r\n this.storage.setItem(idsPath, toJson(ids))\r\n } else {\r\n this.storage.removeItem(idsPath)\r\n }\r\n },\r\n\r\n /**\r\n * Update the records that match the selection `query`. If a record with the\r\n * specified primary key cannot be found then no update is performed and the\r\n * promise is resolved with `undefined`.\r\n *\r\n * @name LocalStorageAdapter#update\r\n * @method\r\n * @param {Object} mapper The mapper.\r\n * @param {(string|number)} id The primary key of the record to be updated.\r\n * @param {Object} props The update to apply to the record.\r\n * @param {Object} [opts] Configuration options.\r\n * @param {boolean} [opts.raw=false] TODO\r\n * @return {Promise}\r\n */\r\n update (mapper, id, props, opts) {\r\n const self = this\r\n props || (props = {})\r\n opts || (opts = {})\r\n\r\n return createTask(function (success, failure) {\r\n queueTask(function () {\r\n let op\r\n // beforeUpdate lifecycle hook\r\n op = opts.op = 'beforeUpdate'\r\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\r\n // Allow for re-assignment from lifecycle hook\r\n props = isUndefined(_props) ? props : _props\r\n const key = self.getIdPath(mapper, opts, id)\r\n let record = self.storage.getItem(key)\r\n record = record ? fromJson(record) : undefined\r\n let updated = 0\r\n\r\n // Update the record\r\n // TODO: Update related records when the \"with\" option is provided\r\n if (record) {\r\n deepMixIn(record, props)\r\n self.storage.setItem(key, toJson(record))\r\n updated++\r\n }\r\n\r\n // afterUpdate lifecycle hook\r\n op = opts.op = 'afterUpdate'\r\n return self[op](mapper, id, props, opts, record).then(function (_record) {\r\n // Allow for re-assignment from lifecycle hook\r\n record = isUndefined(_record) ? record : _record\r\n return opts.raw ? {\r\n data: record,\r\n updated\r\n } : record\r\n })\r\n }).then(success, failure)\r\n })\r\n })\r\n },\r\n\r\n /**\r\n * Update the records that match the selection `query`.\r\n *\r\n * @name LocalStorageAdapter#updateAll\r\n * @method\r\n * @param {Object} mapper The mapper.\r\n * @param {Object} props The update to apply to the selected records.\r\n * @param {Object} query Selection query.\r\n * @param {Object} [opts] Configuration options.\r\n * @return {Promise}\r\n */\r\n updateAll (mapper, props, query, opts) {\r\n const self = this\r\n props || (props = {})\r\n query || (query = {})\r\n opts || (opts = {})\r\n\r\n return createTask(function (success, failure) {\r\n queueTask(function () {\r\n let op\r\n // beforeUpdateAll lifecycle hook\r\n op = opts.op = 'beforeUpdateAll'\r\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\r\n // Allow for re-assignment from lifecycle hook\r\n props = isUndefined(_props) ? props : _props\r\n op = opts.op = 'updateAll'\r\n self.dbg(op, query, opts)\r\n\r\n // Find the records that are to be updated\r\n return self.findAll(mapper, query, opts)\r\n }).then(function (records) {\r\n const idAttribute = mapper.idAttribute\r\n let updated = 0\r\n\r\n // Update each record\r\n // TODO: Update related records when the \"with\" option is provided\r\n records.forEach(function (record) {\r\n record || (record = {})\r\n const id = get(record, idAttribute)\r\n const key = self.getIdPath(mapper, opts, id)\r\n deepMixIn(record, props)\r\n self.storage.setItem(key, toJson(record))\r\n updated++\r\n })\r\n\r\n // afterUpdateAll lifecycle hook\r\n op = opts.op = 'afterUpdateAll'\r\n return self[op](mapper, props, query, opts, records).then(function (_records) {\r\n // Allow for re-assignment from lifecycle hook\r\n records = isUndefined(_records) ? records : _records\r\n return opts.raw ? {\r\n data: records,\r\n updated\r\n } : records\r\n })\r\n }).then(success, failure)\r\n })\r\n })\r\n },\r\n\r\n /**\r\n * Update the given records in a single batch.\r\n *\r\n * @name LocalStorageAdapter#updateMany\r\n * @method\r\n * @param {Object} mapper The mapper.\r\n * @param {Object} records The records to update.\r\n * @param {Object} [opts] Configuration options.\r\n * @param {boolean} [opts.raw=false] TODO\r\n * @return {Promise}\r\n */\r\n updateMany (mapper, records, opts) {\r\n const self = this\r\n records || (records = [])\r\n opts || (opts = {})\r\n\r\n return createTask(function (success, failure) {\r\n queueTask(function () {\r\n let op\r\n let updatedRecords = []\r\n // beforeUpdateMany lifecycle hook\r\n op = opts.op = 'beforeUpdateMany'\r\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\r\n // Allow for re-assignment from lifecycle hook\r\n records = isUndefined(_records) ? records : _records\r\n op = opts.op = 'updateMany'\r\n self.dbg(op, records, opts)\r\n\r\n const idAttribute = mapper.idAttribute\r\n\r\n // Update each record\r\n // TODO: Update related records when the \"with\" option is provided\r\n records.forEach(function (record) {\r\n if (!record) {\r\n return\r\n }\r\n const id = get(record, idAttribute)\r\n if (isUndefined(id)) {\r\n return\r\n }\r\n const key = self.getIdPath(mapper, opts, id)\r\n let json = self.storage.getItem(key)\r\n const existingRecord = json ? fromJson(json) : undefined\r\n if (!existingRecord) {\r\n return\r\n }\r\n deepMixIn(existingRecord, record)\r\n self.storage.setItem(key, toJson(existingRecord))\r\n updatedRecords.push(existingRecord)\r\n })\r\n\r\n // afterUpdateMany lifecycle hook\r\n op = opts.op = 'afterUpdateMany'\r\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\r\n // Allow for re-assignment from lifecycle hook\r\n records = isUndefined(_records) ? updatedRecords : _records\r\n return opts.raw ? {\r\n data: records,\r\n updated: updatedRecords.length\r\n } : records\r\n })\r\n }).then(success, failure)\r\n })\r\n })\r\n }\r\n})\r\n\r\n/**\r\n * Details of the current version of the `js-data-localstorage` module.\r\n *\r\n * @name LocalStorageAdapter.version\r\n * @type {Object}\r\n * @property {string} version.full The full semver value.\r\n * @property {number} version.major The major version number.\r\n * @property {number} version.minor The minor version number.\r\n * @property {number} version.patch The patch version number.\r\n * @property {(string|boolean)} version.alpha The alpha version value,\r\n * otherwise `false` if the current version is not alpha.\r\n * @property {(string|boolean)} version.beta The beta version value,\r\n * otherwise `false` if the current version is not beta.\r\n */\r\nLocalStorageAdapter.version = {\r\n full: '<%= pkg.version %>',\r\n major: parseInt('<%= major %>', 10),\r\n minor: parseInt('<%= minor %>', 10),\r\n patch: parseInt('<%= patch %>', 10),\r\n alpha: '<%= alpha %>' !== 'false' ? '<%= alpha %>' : false,\r\n beta: '<%= beta %>' !== 'false' ? '<%= beta %>' : false\r\n}\r\n\r\n/**\r\n * Registered as `js-data-localstorage` in NPM and Bower.\r\n *\r\n * __Script tag__:\r\n * ```javascript\r\n * window.LocalStorageAdapter\r\n * ```\r\n * __CommonJS__:\r\n * ```javascript\r\n * var LocalStorageAdapter = require('js-data-localstorage')\r\n * ```\r\n * __ES6 Modules__:\r\n * ```javascript\r\n * import LocalStorageAdapter from 'js-data-localstorage'\r\n * ```\r\n * __AMD__:\r\n * ```javascript\r\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\r\n * ```\r\n *\r\n * @module js-data-localstorage\r\n */\r\n\r\nmodule.exports = LocalStorageAdapter\r\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index d54cced..65b3340 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -1,6 +1,6 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.2 - Homepage +* @version 3.0.0-alpha.3 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT diff --git a/karma.conf.js b/karma.conf.js index dde1087..b73a990 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -41,9 +41,10 @@ module.exports = function (config) { config.set({ // base path, that will be used to resolve files and exclude basePath: './', - frameworks: ['mocha'], + frameworks: ['chai', 'mocha'], plugins: [ // these plugins will be require() by Karma + 'karma-chai', 'karma-mocha', 'karma-phantomjs-launcher', 'karma-coverage', @@ -56,9 +57,10 @@ module.exports = function (config) { // list of files / patterns to load in the browser files: [ - 'node_modules/es6-promise/dist/es6-promise.js', + 'node_modules/babel-polyfill/dist/polyfill.js', 'node_modules/js-data/dist/js-data.js', 'dist/js-data-localstorage.js', + 'karma.prestart.js', 'node_modules/js-data-adapter-tests/dist/js-data-adapter-tests.js', 'karma.start.js' ], diff --git a/karma.prestart.js b/karma.prestart.js new file mode 100644 index 0000000..692a61b --- /dev/null +++ b/karma.prestart.js @@ -0,0 +1 @@ +window.assert = chai.assert diff --git a/karma.start.js b/karma.start.js index 55773fe..8032452 100644 --- a/karma.start.js +++ b/karma.start.js @@ -2,9 +2,8 @@ beforeEach(function () { localStorage.clear() }) -window.assert = TestRunner.assert - TestRunner.init({ + debug: false, features: [], JSData: JSData, Adapter: LocalStorageAdapter, @@ -14,7 +13,8 @@ TestRunner.init({ }) describe('relation functionality', function () { - it('nested create', function () { + // will be available in js-data 3.0.0-alpha.15 + it.skip('nested create', function () { return this.$$container.create('user', { name: 'John', profile: { @@ -29,7 +29,7 @@ describe('relation functionality', function () { } ] }, { with: ['profile', 'post', 'organization'] }).then(function (user) { - // console.log(JSON.stringify(user, null, 2)) + console.log(JSON.stringify(user, null, 2)) assert.isDefined(user) assert.isDefined(user.id) assert.isDefined(user.organization) diff --git a/package.json b/package.json index c0561ee..5a153e4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "version": "3.0.0-alpha.2", + "version": "3.0.0-alpha.3", "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", @@ -49,27 +49,28 @@ }, "devDependencies": { "babel-core": "6.5.2", - "babel-eslint": "4.1.8", - "babel-loader": "6.2.2", + "babel-eslint": "5.0.0", + "babel-loader": "6.2.3", "babel-polyfill": "6.5.0", "babel-preset-es2015": "6.5.0", "chai": "3.5.0", "codacy-coverage": "1.1.3", "coveralls": "2.11.6", - "es6-promise": "3.0.2", - "ink-docstrap": "1.1.1", - "js-data-adapter-tests": "^2.0.0-alpha.1", + "es6-promise": "3.1.2", + "ink-docstrap": "1.1.2", + "js-data-adapter-tests": "^2.0.0-alpha.5", "jsdoc": "3.4.0", "karma": "0.13.21", "karma-browserstack-launcher": "0.1.10", + "karma-chai": "0.1.0", "karma-coverage": "0.5.3", "karma-junit-reporter": "0.3.8", - "karma-mocha": "0.2.1", + "karma-mocha": "0.2.2", "karma-phantomjs-launcher": "1.0.0", "mocha": "2.4.5", "mout": "0.11.1", - "phantomjs-prebuilt": "^2.1.4", - "standard": "6.0.5", + "phantomjs-prebuilt": "2.1.4", + "standard": "6.0.6", "uglify-js": "2.6.1", "webpack": "1.12.13" } From 92e4052cb97b7ce54bb951edfbd4bea048964911 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Tue, 23 Feb 2016 16:56:50 -0800 Subject: [PATCH 06/15] 3.0.0-alpha.3 --- .github/CONTRIBUTING.md | 27 ++++++++++ .github/ISSUE_TEMPLATE.md | 7 +++ .github/PULL_REQUEST_TEMPLATE.md | 8 +++ .mailmap | 1 + AUTHORS | 8 +++ CHANGELOG.md | 5 ++ CONTRIBUTING.md | 46 ----------------- CONTRIBUTORS | 7 +++ LICENSE | 2 +- README.md | 83 ++++++++----------------------- bower.json | 8 +-- dist/js-data-localstorage.js | 42 ++-------------- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 4 +- dist/js-data-localstorage.min.map | 2 +- karma.conf.js | 5 +- package.json | 29 ++++++----- scripts/AUTHORS | 7 +++ scripts/CONTRIBUTORS | 6 +++ scripts/authors.js | 45 +++++++++++++++++ src/index.js | 36 -------------- 21 files changed, 170 insertions(+), 210 deletions(-) create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .mailmap create mode 100644 AUTHORS delete mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTORS create mode 100644 scripts/AUTHORS create mode 100644 scripts/CONTRIBUTORS create mode 100644 scripts/authors.js diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..ad84ef7 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,27 @@ +# Contributing + +[Read the Contributing Guide](http://js-data.io/docs/contributing). + +## Support + +[Find out how to Get Support](http://js-data.io/docs/support). + +## Community + +[Explore the Community](http://js-data.io/docs/community). + +### Have write access? + +To cut a release: + +1. Checkout master +1. Bump version in `package.json` appropriately +1. Run `npm run release` +1. Update `CHANGELOG.md` appropriately +1. Commit and push changes, including the `dist/` folder +1. Make a GitHub release + - set tag name to version + - set release name to version + - set release body to changelog entry for the version + - attach the files in the `dist/` folder +1. `npm publish .` diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2ce62e8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +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) Find out how to Get Support here: http://js-data.io/docs/support. + + + +Thanks! diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..4c14bdc --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,8 @@ +Fixes # (it's a good idea to open an issue first for discussion) + +- [ ] - `npm test` succeeds +- [ ] - Pull request has been squashed into 1 commit +- [ ] - I did NOT commit changes to `dist/` +- [ ] - Code coverage does not decrease (if any source code was changed) +- [ ] - Appropriate JSDoc comments were updated in source code (if applicable) +- [ ] - Approprate changes to js-data.io docs have been suggested ("Suggest Edits" button) diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000..21ac730 --- /dev/null +++ b/.mailmap @@ -0,0 +1 @@ +Jason Dobry Jason Dobry diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e8445ca --- /dev/null +++ b/AUTHORS @@ -0,0 +1,8 @@ +# This is the official list of js-data-localstorage 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. +Jason Dobry diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c3601c..ebe2cdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +##### 3.0.0-alpha.3 - 23 February 2016 + +- Upgraded dependencies +- Updated Readme + ##### 3.0.0-alpha.2 - 13 February 2016 - Now making use of JSData.utils.forEachRelation diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 81066a4..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,46 +0,0 @@ -# Contributing Guide - -## Support - -Support questions are handled via [StackOverflow][so], [Slack][slack], and the -[Mailing List][ml]. Ask your questions there. - -## Community -- [StackOverflow Channel][so] -- [Slack Chat][slack] [![Slack Status][sl_b]][slack] -- [Announcements](http://www.js-data.io/blog) -- [Mailing List](ml) -- [Issues Tracker](https://github.com/js-data/js-data/issues) -- [GitHub](https://github.com/js-data/js-data) -- [Contributing Guide](https://github.com/js-data/js-data/blob/master/CONTRIBUTING.md) - -## Contributing - -When submitting bug reports or feature requests on GitHub, please include _as -much detail as possible_. - -- good - Your versions of Angular, JSData, etc, relevant console logs, stack -traces, code examples that revealed the issue, etc. -- better - A [plnkr](http://plnkr.co/), [fiddle](http://jsfiddle.net/), or -[bin](http://jsbin.com/?html,output) that demonstrates the issue -- best - A Pull Request that fixes the issue, including test coverage for the -issue and the fix - -### Pull Requests - -1. Contribute to the issue/discussion that is the reason you'll be developing in -the first place -1. Fork js-data -1. `git clone git@github.com:/js-data-localstorage.git` -1. `cd js-data-localstorage; npm install;` -1. Write your code, including relevant documentation and tests -1. Run `npm test` (build and test) -1. Your code will be linted and checked for formatting, the tests will be run -1. The `dist/` folder & files will be generated, do NOT commit `dist/*`! They -will be committed when a release is cut. -1. Submit your PR and we'll review! -1. Thanks! - -[slack]: http://slack.js-data.io -[ml]: https://groups.io/org/groupsio/jsdata -[so]: http://stackoverflow.com/questions/tagged/jsdata diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..70d6217 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,7 @@ +# People who have contributed to the js-data-localstorage project. +# +# This file is controlled by scripts/authors.js +# +# Names should be added to this file as: +# [commit count] Name + 59 Jason Dobry diff --git a/LICENSE b/LICENSE index 73d2777..8325e52 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2016 Jason Dobry +Copyright (c) 2014-2016 js-data-localstorage 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 diff --git a/README.md b/README.md index 00b5a69..f658e34 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Tested on IE9, Chrome 46, Firefox 41 & Safari 7.1 using ## Table of contents * [Quick start](#quick-start) -* [Documentation](#documentation) +* [Guides and Tutorials](#guides-and-tutorials) * [API Reference](#api-reference) * [Demo](#demo) * [Support](#support) @@ -66,82 +66,39 @@ var sessionAdapter = new LocalStorageAdapter({ }); ``` -## Documentation -- [Getting Started with js-data](http://www.js-data.io/docs/home) -- [js-data-http](http://www.js-data.io/docs/js-data-localstorage) -- [CHANGELOG.md](https://github.com/js-data/js-data-localstorage/blob/master/CHANGELOG.md) +## Guides and Tutorials -## API Reference -- [js-data](http://api.js-data.io/js-data/) -- [js-data-localstorage](http://api.js-data.io/js-data-localstorage/) +[Get started at http://js-data.io](http://js-data.io) -## Demo -[https://js-data-localstorage.firebaseapp.com/](https://js-data-localstorage.firebaseapp.com/) +## API Reference Docs -## Support +[Visit http://api.js-data.io](http://api.js-data.io). -Support questions are handled via [StackOverflow][so], [Slack][slack], and the -[Mailing List][ml]. Ask your questions there. +## Demo + +https://js-data-localstorage.firebaseapp.com/ ## Community -- [StackOverflow Channel][so] -- [Slack Chat][slack] [![Slack Status][sl_b]][slack] -- [Announcements](http://www.js-data.io/blog) -- [Mailing List](ml) -- [Issues Tracker](https://github.com/js-data/js-data/issues) -- [GitHub](https://github.com/js-data/js-data) -- [Contributing Guide](https://github.com/js-data/js-data/blob/master/CONTRIBUTING.md) + +[Explore the Community](http://js-data.io/docs/community). + +## Support + +[Find out how to Get Support](http://js-data.io/docs/support). ## Contributing -When submitting bug reports or feature requests on GitHub, please include _as -much detail as possible_. - -- good - Your versions of Angular, JSData, etc, relevant console logs, stack -traces, code examples that revealed the issue, etc. -- better - A [plnkr](http://plnkr.co/), [fiddle](http://jsfiddle.net/), or -[bin](http://jsbin.com/?html,output) that demonstrates the issue -- best - A Pull Request that fixes the issue, including test coverage for the -issue and the fix - -### Pull Requests - -1. Contribute to the issue/discussion that is the reason you'll be developing in -the first place -1. Fork js-data -1. `git clone git@github.com:/js-data-localstorage.git` -1. `cd js-data-localstorage; npm install;` -1. Write your code, including relevant documentation and tests -1. Run `npm test` (build and test) -1. Your code will be linted and checked for formatting, the tests will be run -1. The `dist/` folder & files will be generated, do NOT commit `dist/*`! They -will be committed when a release is cut. -1. Submit your PR and we'll review! -1. Thanks! +[Read the Contributing Guide](http://js-data.io/docs/contributing). ## License The MIT License (MIT) -Copyright (c) 2014-2016 Jason Dobry - -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. +Copyright (c) 2014-2016 js-data-http project authors + +* [LICENSE](https://github.com/js-data/js-data-localstorage/blob/master/LICENSE) +* [AUTHORS](https://github.com/js-data/js-data-localstorage/blob/master/AUTHORS) +* [CONTRIBUTORS](https://github.com/js-data/js-data-localstorage/blob/master/CONTRIBUTORS) [sl_b]: http://slack.js-data.io/badge.svg [sl_l]: http://slack.js-data.io diff --git a/bower.json b/bower.json index 0a9c60c..86750e3 100644 --- a/bower.json +++ b/bower.json @@ -1,16 +1,12 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "homepage": "http://www.js-data.io/docs/js-data-localstorage", + "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", "url": "https://github.com/js-data/js-data-localstorage.git" }, - "author": { - "name": "Jason Dobry", - "url": "http://www.pseudobry.com", - "email": "jason.dobry@gmail.com" - }, + "author": "js-data-localstorage project authors", "main": "./dist/js-data-localstorage.js", "ignore": [ ".idea/", diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index 180c508..79b2c1e 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1,6 +1,6 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.2 - Homepage +* @version 3.0.0-alpha.3 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT @@ -252,12 +252,6 @@ return /******/ (function(modules) { // webpackBootstrap */ afterCreateMany: noop2, - /** - * @name LocalStorageAdapter#afterDEL - * @method - */ - afterDEL: noop2, - /** * @name LocalStorageAdapter#afterDestroy * @method @@ -282,18 +276,6 @@ return /******/ (function(modules) { // webpackBootstrap */ afterFindAll: noop2, - /** - * @name LocalStorageAdapter#afterGET - * @method - */ - afterGET: noop2, - - /** - * @name LocalStorageAdapter#afterPUT - * @method - */ - afterPUT: noop2, - /** * @name LocalStorageAdapter#afterUpdate * @method @@ -324,12 +306,6 @@ return /******/ (function(modules) { // webpackBootstrap */ beforeCreateMany: noop, - /** - * @name LocalStorageAdapter#beforeDEL - * @method - */ - beforeDEL: noop, - /** * @name LocalStorageAdapter#beforeDestroy * @method @@ -354,18 +330,6 @@ return /******/ (function(modules) { // webpackBootstrap */ beforeFindAll: noop, - /** - * @name LocalStorageAdapter#beforeGET - * @method - */ - beforeGET: noop, - - /** - * @name LocalStorageAdapter#beforePUT - * @method - */ - beforePUT: noop, - /** * @name LocalStorageAdapter#beforeUpdate * @method @@ -1169,11 +1133,11 @@ return /******/ (function(modules) { // webpackBootstrap * otherwise `false` if the current version is not beta. */ LocalStorageAdapter.version = { - full: '3.0.0-alpha.2', + full: '3.0.0-alpha.3', major: parseInt('3', 10), minor: parseInt('0', 10), patch: parseInt('0', 10), - alpha: true ? '2' : false, + alpha: true ? '3' : false, beta: true ? 'false' : false }; diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index d4174c4..ea028be 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 44f46103f4ff839e8bae","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./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A;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 44f46103f4ff839e8bae\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDEL\n * @method\n */\n afterDEL: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterGET\n * @method\n */\n afterGET: noop2,\n\n /**\n * @name LocalStorageAdapter#afterPUT\n * @method\n */\n afterPUT: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDEL\n * @method\n */\n beforeDEL: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeGET\n * @method\n */\n beforeGET: noop,\n\n /**\n * @name LocalStorageAdapter#beforePUT\n * @method\n */\n beforePUT: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n _create (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n record = self._create(mapper, record, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n records = records.map(function (record) {\n return self._create(mapper, record, opts)\n })\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return self[op](mapper, id, opts).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: id,\n deleted: 1\n } : id\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (isUndefined(record)) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return self[op](mapper, id, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 3f5a51dccb1a65dc93ec","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;;;;;;ACrCA,KAAM,SAAS,oBAAQ,CAAR,CAAT;AACN,KAAM,OAAO,oBAAQ,CAAR,CAAP;;KAGJ,QAEE,OAFF;KACA,QACE,OADF;KAIA,yBAcE,MAdF;KACA,YAaE,MAbF;KACA,SAYE,MAZF;KACA,SAWE,MAXF;KACA,kBAUE,MAVF;KACA,SASE,MATF;KACA,WAQE,MARF;KACA,MAOE,MAPF;KACA,UAME,MANF;KACA,cAKE,MALF;KACA,UAIE,MAJF;KACA,SAGE,MAHF;KACA,MAEE,MAFF;KACA,SACE,MADF;;;AAGF,U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EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 3f5a51dccb1a65dc93ec\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n _create (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n record = self._create(mapper, record, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n records = records.map(function (record) {\n return self._create(mapper, record, opts)\n })\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return self[op](mapper, id, opts).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: id,\n deleted: 1\n } : id\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (isUndefined(record)) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return self[op](mapper, id, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index d54cced..97cd207 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -1,11 +1,11 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.2 - Homepage +* @version 3.0.0-alpha.3 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){O.push(t)}function c(){O.length&&!D&&(D=!0,O[0]())}function l(t){O.length?f(t):(f(t),c())}function s(t){return new Promise(t).then(function(t){return D=!1,O.shift(),setTimeout(c,0),t},function(t){return D=!1,O.shift(),setTimeout(c,0),F(t)})}function d(t){m(this,t||{}),m(this,S)}var h=n(1),p=n(2),g=h.Query,v=h.utils,y=v.addHiddenPropsToTarget,b=v.deepMixIn,A=v.extend,m=v.fillIn,I=v.forEachRelation,x=v.forOwn,P=v.fromJson,w=v.get,E=v.isArray,M=v.isUndefined,j=v.resolve,F=v.reject,U=v.set,K=v.toJson,O=[],D=!1,T=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),j()},C=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),j()},S={basePath:"",debug:!1,storage:localStorage};d.extend=A,y(d.prototype,{afterCreate:C,afterCreateMany:C,afterDEL:C,afterDestroy:C,afterDestroyAll:C,afterFind:C,afterFindAll:C,afterGET:C,afterPUT:C,afterUpdate:C,afterUpdateAll:C,afterUpdateMany:C,beforeCreate:T,beforeCreateMany:T,beforeDEL:T,beforeDestroy:T,beforeDestroyAll:T,beforeFind:T,beforeFindAll:T,beforeGET:T,beforePUT:T,beforeUpdate:T,beforeUpdateAll:T,beforeUpdateMany:T,_create:function(t,e,n){var r=this,o={},a=t.relationFields||[];x(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=w(o,t.idAttribute)||p();U(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,K(o)),r.ensureId(i,t,n),P(r.storage.getItem(u))},create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",j(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=r._create(t,a,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",j(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=a.map(function(e){return r._create(t,e,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroy",j(r[i](t,e,n)).then(function(){return i=n.op="destroy",r.dbg(i,e,n),r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),i=n.op="afterDestroy",r[i](t,e,n).then(function(t){return e=M(t)?e:t,n.raw?{data:e,deleted:1}:e})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),s(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroyAll",j(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return w(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=M(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",j(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),M(a))return void(a=void 0);a=P(a);var c=[];return I(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var l=[],s=w(a,e.localKeys)||[];s=Array.isArray(s)?s:Object.keys(s),l=l.concat(s||[]),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(l).filter(function(t){return t})})},n).then(function(t){return U(a,e.localField,t),t})}else"belongsTo"===e.type&&(f=o.find(i,w(a,e.foreignKey),n).then(function(t){return U(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,w(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?U(a,e.localField,t[0]):U(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",j(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",j(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);x(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(P(i))});var c=t.idAttribute,l=new g({index:{getAll:function(){return a}}});a=l.filter(e).run();var s=[];return I(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=w(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n||[])}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=w(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),U(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return w(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===w(r,t.foreignKey)&&U(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return w(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){w(e,t.foreignKey)===w(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?U(n,t.localField,r[0]):U(n,t.localField,r)}),e}),i&&s.push(i)}),Promise.all(s)}).then(function(){return i=n.op="afterFindAll",j(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?P(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(E(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,K(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),s(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",j(o[u](t,e,n,r)).then(function(a){n=M(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?P(f):void 0;var c=0;return f&&(b(f,n),o.storage.setItem(i,K(f)),c++),u=r.op="afterUpdate",o[u](t,e,n,r,f).then(function(t){return f=M(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),s(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",j(o[u](t,e,n,r)).then(function(a){return e=M(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=w(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,K(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=M(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),s(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",j(r[i](t,e,n)).then(function(o){e=M(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=w(e,a);if(!M(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?P(f):void 0;c&&(b(c,e),r.storage.setItem(i,K(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=M(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),d.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=d},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){O.push(t)}function c(){O.length&&!C&&(C=!0,O[0]())}function l(t){O.length?f(t):(f(t),c())}function d(t){return new Promise(t).then(function(t){return C=!1,O.shift(),setTimeout(c,0),t},function(t){return C=!1,O.shift(),setTimeout(c,0),K(t)})}function s(t){m(this,t||{}),m(this,T)}var h=n(1),p=n(2),v=h.Query,g=h.utils,y=g.addHiddenPropsToTarget,b=g.deepMixIn,A=g.extend,m=g.fillIn,I=g.forEachRelation,x=g.forOwn,P=g.fromJson,w=g.get,M=g.isArray,j=g.isUndefined,F=g.resolve,K=g.reject,U=g.set,E=g.toJson,O=[],C=!1,D=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),F()},S=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),F()},T={basePath:"",debug:!1,storage:localStorage};s.extend=A,y(s.prototype,{afterCreate:S,afterCreateMany:S,afterDestroy:S,afterDestroyAll:S,afterFind:S,afterFindAll:S,afterUpdate:S,afterUpdateAll:S,afterUpdateMany:S,beforeCreate:D,beforeCreateMany:D,beforeDestroy:D,beforeDestroyAll:D,beforeFind:D,beforeFindAll:D,beforeUpdate:D,beforeUpdateAll:D,beforeUpdateMany:D,_create:function(t,e,n){var r=this,o={},a=t.relationFields||[];x(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=w(o,t.idAttribute)||p();U(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,E(o)),r.ensureId(i,t,n),P(r.storage.getItem(u))},create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",F(r[i](t,e,n)).then(function(o){var a=j(o)?e:o;return a=r._create(t,a,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=j(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",F(r[i](t,e,n)).then(function(o){var a=j(o)?e:o;return a=a.map(function(e){return r._create(t,e,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=j(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroy",F(r[i](t,e,n)).then(function(){return i=n.op="destroy",r.dbg(i,e,n),r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),i=n.op="afterDestroy",r[i](t,e,n).then(function(t){return e=j(t)?e:t,n.raw?{data:e,deleted:1}:e})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroyAll",F(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return w(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=j(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(M(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",F(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),j(a))return void(a=void 0);a=P(a);var c=[];return I(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var l=[],d=w(a,e.localKeys)||[];d=Array.isArray(d)?d:Object.keys(d),l=l.concat(d||[]),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(l).filter(function(t){return t})})},n).then(function(t){return U(a,e.localField,t),t})}else"belongsTo"===e.type&&(f=o.find(i,w(a,e.foreignKey),n).then(function(t){return U(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,w(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?U(a,e.localField,t[0]):U(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",F(o[i](t,e,n,a)).then(function(t){return a=j(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",F(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);x(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(P(i))});var c=t.idAttribute,l=new v({index:{getAll:function(){return a}}});a=l.filter(e).run();var d=[];return I(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=w(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n||[])}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=w(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),U(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return w(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===w(r,t.foreignKey)&&U(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return w(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){w(e,t.foreignKey)===w(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?U(n,t.localField,r[0]):U(n,t.localField,r)}),e}),i&&d.push(i)}),Promise.all(d)}).then(function(){return i=n.op="afterFindAll",F(o[i](t,e,n,a)).then(function(t){return a=j(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?P(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(M(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,E(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",F(o[u](t,e,n,r)).then(function(a){n=j(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?P(f):void 0;var c=0;return f&&(b(f,n),o.storage.setItem(i,E(f)),c++),u=r.op="afterUpdate",o[u](t,e,n,r,f).then(function(t){return f=j(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",F(o[u](t,e,n,r)).then(function(a){return e=j(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=w(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,E(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=j(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),d(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",F(r[i](t,e,n)).then(function(o){e=j(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=w(e,a);if(!j(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?P(f):void 0;c&&(b(c,e),r.storage.setItem(i,E(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=j(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),s.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=s},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); //# sourceMappingURL=dist/js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index 1122a62..330b29b 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDEL","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterGET","afterPUT","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDEL","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeGET","beforePUT","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_create","mapper","props","_props","relationFields","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","create","success","failure","undefined","record","_record","raw","data","created","createMany","records","map","_records","_len4","_key4","log","destroy","removeItem","removeId","_id","deleted","destroyAll","query","findAll","ids","_ids","getIds","saveKeys","find","with","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","relatedItem","all","found","json","_query","index","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAEA,SAASS,GAAgBC,EAA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AUwO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_create","mapper","props","_props","relationFields","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","create","success","failure","undefined","record","_record","raw","data","created","createMany","records","map","_records","_len4","_key4","log","destroy","removeItem","removeId","_id","deleted","destroyAll","query","findAll","ids","_ids","getIds","saveKeys","find","with","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","relatedItem","all","found","json","_query","index","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SA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lBmJ,EAAOnJ,IAAMgJ,KAAKG,OAElB7N,EAAOD,QAAU8N,GAOhB,SAAS7N,EAAQD,EAASQ,GAE/B,GAAIuN,GAASvN,EAAoB,IAGzBoE,EAAUxC,MAAMwC,SAAW,SAAUoJ,GACrC,MAAOD,GAAOC,EAAK,SAEvB/N,GAAOD,QAAU4E,GAMhB,SAAS3E,EAAQD,EAASQ,GAM3B,QAASuN,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAAS1N,EAAoB,GAO7BP,GAAOD,QAAU+N,GAMhB,SAAS9N,EAAQD,GAWlB,QAASkO,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAUzN,KAAKmN,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAYjN,OAAO2E,UAAUuI,QAejCtO,GAAOD,QAAUkO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index dde1087..c52628c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -41,9 +41,10 @@ module.exports = function (config) { config.set({ // base path, that will be used to resolve files and exclude basePath: './', - frameworks: ['mocha'], + frameworks: ['chai', 'mocha'], plugins: [ // these plugins will be require() by Karma + 'karma-chai', 'karma-mocha', 'karma-phantomjs-launcher', 'karma-coverage', @@ -56,7 +57,7 @@ module.exports = function (config) { // list of files / patterns to load in the browser files: [ - 'node_modules/es6-promise/dist/es6-promise.js', + 'node_modules/babel-polyfill/dist/polyfill.js', 'node_modules/js-data/dist/js-data.js', 'dist/js-data-localstorage.js', 'node_modules/js-data-adapter-tests/dist/js-data-adapter-tests.js', diff --git a/package.json b/package.json index c0561ee..35a50d7 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "version": "3.0.0-alpha.2", + "version": "3.0.0-alpha.3", "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", "url": "https://github.com/js-data/js-data-localstorage.git" }, - "author": "Jason Dobry (http://www.pseudobry.com)", + "author": "js-data-localstorage project authors", "license": "MIT", "keywords": [ "data", @@ -15,7 +15,9 @@ "store", "database", "adapter", - "localstorage" + "localstorage", + "js-data", + "JSData" ], "main": "./dist/js-data-localstorage.js", "standard": { @@ -42,35 +44,36 @@ "build": "npm run lint && npm run bundle && npm run min && npm run version && npm run banner", "karma": "karma start", "test": "npm run build && npm run karma", + "release": "npm test && npm run doc && node scripts/authors.js", "ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | coveralls || true && cat ./coverage/PhantomJS*/lcov.info | codacy-coverage || true" }, "dependencies": { - "js-data": "^3.0.0-alpha.14" + "js-data": "^3.0.0-alpha.15" }, "devDependencies": { "babel-core": "6.5.2", - "babel-eslint": "4.1.8", - "babel-loader": "6.2.2", + "babel-eslint": "5.0.0", + "babel-loader": "6.2.3", "babel-polyfill": "6.5.0", "babel-preset-es2015": "6.5.0", "chai": "3.5.0", "codacy-coverage": "1.1.3", "coveralls": "2.11.6", - "es6-promise": "3.0.2", - "ink-docstrap": "1.1.1", - "js-data-adapter-tests": "^2.0.0-alpha.1", + "ink-docstrap": "1.1.2", + "js-data-adapter-tests": "^2.0.0-alpha.5", "jsdoc": "3.4.0", "karma": "0.13.21", "karma-browserstack-launcher": "0.1.10", + "karma-chai": "0.1.0", "karma-coverage": "0.5.3", "karma-junit-reporter": "0.3.8", - "karma-mocha": "0.2.1", + "karma-mocha": "0.2.2", "karma-phantomjs-launcher": "1.0.0", "mocha": "2.4.5", "mout": "0.11.1", "phantomjs-prebuilt": "^2.1.4", - "standard": "6.0.5", - "uglify-js": "2.6.1", - "webpack": "1.12.13" + "standard": "6.0.7", + "uglify-js": "2.6.2", + "webpack": "1.12.14" } } diff --git a/scripts/AUTHORS b/scripts/AUTHORS new file mode 100644 index 0000000..b935ea1 --- /dev/null +++ b/scripts/AUTHORS @@ -0,0 +1,7 @@ +# This is the official list of js-data-localstorage 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 new file mode 100644 index 0000000..165d3bd --- /dev/null +++ b/scripts/CONTRIBUTORS @@ -0,0 +1,6 @@ +# People who have contributed to the js-data-localstorage 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 new file mode 100644 index 0000000..82a856d --- /dev/null +++ b/scripts/authors.js @@ -0,0 +1,45 @@ +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/src/index.js b/src/index.js index bbd2014..14082a4 100644 --- a/src/index.js +++ b/src/index.js @@ -173,12 +173,6 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { */ afterCreateMany: noop2, - /** - * @name LocalStorageAdapter#afterDEL - * @method - */ - afterDEL: noop2, - /** * @name LocalStorageAdapter#afterDestroy * @method @@ -203,18 +197,6 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { */ afterFindAll: noop2, - /** - * @name LocalStorageAdapter#afterGET - * @method - */ - afterGET: noop2, - - /** - * @name LocalStorageAdapter#afterPUT - * @method - */ - afterPUT: noop2, - /** * @name LocalStorageAdapter#afterUpdate * @method @@ -245,12 +227,6 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { */ beforeCreateMany: noop, - /** - * @name LocalStorageAdapter#beforeDEL - * @method - */ - beforeDEL: noop, - /** * @name LocalStorageAdapter#beforeDestroy * @method @@ -275,18 +251,6 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { */ beforeFindAll: noop, - /** - * @name LocalStorageAdapter#beforeGET - * @method - */ - beforeGET: noop, - - /** - * @name LocalStorageAdapter#beforePUT - * @method - */ - beforePUT: noop, - /** * @name LocalStorageAdapter#beforeUpdate * @method From 4627b0ee854529b2ecda4daa7a82877e78e428b0 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Tue, 23 Feb 2016 21:34:58 -0800 Subject: [PATCH 07/15] 3.0.0-alpha.4 --- CHANGELOG.md | 5 ++++ CONTRIBUTORS | 2 +- dist/js-data-localstorage.js | 42 ++++++++++++++++++++++--------- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 4 +-- dist/js-data-localstorage.min.map | 2 +- karma.start.js | 5 +++- package.json | 5 ++-- src/index.js | 38 +++++++++++++++++++++------- 9 files changed, 76 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebe2cdf..e3d6e0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +##### 3.0.0-alpha.4 - 23 February 2016 + +- Improved find, destroy, and update methods +- Upgraded to js-data-adapter-tests@2.0.0-alpha.6 + ##### 3.0.0-alpha.3 - 23 February 2016 - Upgraded dependencies diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 053380a..6a1e2ab 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -4,4 +4,4 @@ # # Names should be added to this file as: # [commit count] Name - 60 Jason Dobry + 62 Jason Dobry diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index 79b2c1e..94b97f9 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1,6 +1,6 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.3 - Homepage +* @version 3.0.0-alpha.4 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT @@ -491,18 +491,24 @@ return /******/ (function(modules) { // webpackBootstrap self.dbg(op, id, opts); // Destroy the record // TODO: Destroy related records when the "with" option is provided - self.storage.removeItem(self.getIdPath(mapper, opts, id)); - self.removeId(id, mapper, opts); + var key = self.getIdPath(mapper, opts, id); + var recordJson = self.storage.getItem(key); + var deleted = 0; + if (recordJson) { + self.storage.removeItem(key); + self.removeId(id, mapper, opts); + deleted++; + } // afterDestroy lifecycle hook op = opts.op = 'afterDestroy'; - return self[op](mapper, id, opts).then(function (_id) { + return resolve(self[op](mapper, id, opts, deleted ? id : undefined)).then(function (_id) { // Allow for re-assignment from lifecycle hook id = isUndefined(_id) ? id : _id; return opts.raw ? { - data: id, - deleted: 1 - } : id; + data: deleted ? id : undefined, + deleted: deleted + } : deleted ? id : undefined; }); }).then(success, failure); }); @@ -613,7 +619,7 @@ return /******/ (function(modules) { // webpackBootstrap self.dbg(op, id, opts); var key = self.getIdPath(mapper, opts, id); record = self.storage.getItem(key); - if (isUndefined(record)) { + if (!record) { record = undefined; return; } @@ -637,7 +643,7 @@ return /******/ (function(modules) { // webpackBootstrap var localKeys = []; var itemKeys = get(record, def.localKeys) || []; itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); - localKeys = localKeys.concat(itemKeys || []); + localKeys = localKeys.concat(itemKeys); task = self.findAll(relatedMapper, { where: _defineProperty({}, relatedMapper.idAttribute, { 'in': unique(localKeys).filter(function (x) { @@ -648,6 +654,15 @@ return /******/ (function(modules) { // webpackBootstrap set(record, def.localField, relatedItems); return relatedItems; }); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.findAll(relatedMapper, { + where: _defineProperty({}, def.foreignKeys, { + 'contains': get(record, mapper.idAttribute) + }) + }, __opts).then(function (relatedItems) { + set(record, def.localField, relatedItems); + return relatedItems; + }); } else if (def.type === 'belongsTo') { task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) { set(record, def.localField, relatedItem); @@ -964,6 +979,7 @@ return /******/ (function(modules) { // webpackBootstrap var key = self.getIdPath(mapper, opts, id); var record = self.storage.getItem(key); record = record ? fromJson(record) : undefined; + var updated = 0; // Update the record @@ -972,11 +988,13 @@ return /******/ (function(modules) { // webpackBootstrap deepMixIn(record, props); self.storage.setItem(key, toJson(record)); updated++; + } else { + throw new Error('Not Found'); } // afterUpdate lifecycle hook op = opts.op = 'afterUpdate'; - return self[op](mapper, id, props, opts, record).then(function (_record) { + return resolve(self[op](mapper, id, props, opts, record)).then(function (_record) { // Allow for re-assignment from lifecycle hook record = isUndefined(_record) ? record : _record; return opts.raw ? { @@ -1133,11 +1151,11 @@ return /******/ (function(modules) { // webpackBootstrap * otherwise `false` if the current version is not beta. */ LocalStorageAdapter.version = { - full: '3.0.0-alpha.3', + full: '3.0.0-alpha.4', major: parseInt('3', 10), minor: parseInt('0', 10), patch: parseInt('0', 10), - alpha: true ? '3' : false, + alpha: true ? '4' : false, beta: true ? 'false' : false }; diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index ea028be..f3b0e9f 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 3f5a51dccb1a65dc93ec","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;;;;;;ACrCA,KAAM,SAAS,oBAAQ,CAAR,CAAT;AACN,KAAM,OAAO,oBAAQ,CAAR,CAAP;;KAGJ,QAEE,OAFF;KACA,QACE,OADF;KAIA,yBAcE,MAdF;KACA,YAaE,MAbF;KACA,SAYE,MAZF;KACA,SAWE,MAXF;KACA,kBAUE,MAVF;KACA,SASE,MATF;KACA,WAQE,MARF;KACA,MAOE,MAPF;KACA,UAME,MANF;KACA,cAKE,MALF;KACA,UAIE,MAJF;KACA,SAGE,MAHF;KACA,MAEE,MAFF;KACA,SACE,MADF;;;AAGF,UAAS,aAAT,CAAwB,KAAxB,EAA+B;AAC7B,UAAQ,SAAS,IAAT,IAAiB,UAAU,EAAV,CADI;EAA/B;AAGA,UAAS,IAAT,CAAe,KAAf,EAAsB,SAAtB,EAAiC;AAC/B,iBAAc,YAAY,EAAZ,CAAd,CAD+B;AAE/B,UAAO,MAAM,MAAN,CAAa,aAAb,EAA4B,IAA5B,CAAiC,SAAjC,CAAP,CAF+B;EAAjC;AAIA,UAAS,QAAT,GAA4B;qCAAN;;IAAM;;AAC1B,OAAI,SAAS,KAAK,IAAL,EAAW,GAAX,CAAT,CADsB;AAE1B,UAAO,OAAO,OAAP,CAAe,mBAAf,EAAoC,KAApC,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A;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 3f5a51dccb1a65dc93ec\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n _create (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n record = self._create(mapper, record, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n records = records.map(function (record) {\n return self._create(mapper, record, opts)\n })\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return self[op](mapper, id, opts).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: id,\n deleted: 1\n } : id\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (isUndefined(record)) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return self[op](mapper, id, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 5a8dced2f6409f918f40","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;;;;;;ACrCA,KAAM,SAAS,oBAAQ,CAAR,CAAT;AACN,KAAM,OAAO,oBAAQ,CAAR,CAAP;;KAGJ,QAEE,OAFF;KACA,QACE,OADF;KAIA,yBAcE,MAdF;KACA,YAaE,MAbF;KACA,SAYE,MAZF;KACA,SAWE,MAXF;KACA,kBAUE,MAVF;KACA,SASE,MATF;KACA,WAQE,MARF;KACA,MAOE,MAPF;KACA,UAME,MANF;KACA,cAKE,MALF;KACA,UAIE,MAJF;KACA,SAGE,MAHF;KACA,MAEE,MAFF;KACA,SACE,MADF;;;AAGF,UAAS,aAAT,CAAwB,KAAxB,EAA+B;AAC7B,UAAQ,SAAS,IAAT,IAAiB,UAAU,EAAV,CADI;EAA/B;AAGA,UAAS,IAAT,CAAe,KAAf,EAAsB,SAAtB,EAAiC;AAC/B,iBAAc,YAAY,EAAZ,CAAd,CAD+B;AAE/B,UAAO,MAAM,MAAN,CAAa,aAAb,EAA4B,IAA5B,CAAiC,SAAjC,CAAP,CAF+B;EAAjC;AAIA,UAAS,QAAT,GAA4B;qCAA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B,cAA7B,GAA8C,KAA9C;AACP,SAAM,QAA4B,aAA5B,GAA4C,KAA5C;EANR;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,QAAO,OAAP,GAAiB,mBAAjB,C;;;;;;ACrjCA,gD;;;;;;ACAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 5a8dced2f6409f918f40\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n _create (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n record = self._create(mapper, record, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n records = records.map(function (record) {\n return self._create(mapper, record, opts)\n })\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n const key = self.getIdPath(mapper, opts, id)\n const recordJson = self.storage.getItem(key)\n let deleted = 0\n if (recordJson) {\n self.storage.removeItem(key)\n self.removeId(id, mapper, opts)\n deleted++\n }\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return resolve(self[op](mapper, id, opts, deleted ? id : undefined)).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: deleted ? id : undefined,\n deleted\n } : deleted ? id : undefined\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (!record) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'contains': get(record, mapper.idAttribute)\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n } else {\n throw new Error('Not Found')\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return resolve(self[op](mapper, id, props, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index 97cd207..f42b312 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -1,11 +1,11 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.3 - Homepage +* @version 3.0.0-alpha.4 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){O.push(t)}function c(){O.length&&!C&&(C=!0,O[0]())}function l(t){O.length?f(t):(f(t),c())}function d(t){return new Promise(t).then(function(t){return C=!1,O.shift(),setTimeout(c,0),t},function(t){return C=!1,O.shift(),setTimeout(c,0),K(t)})}function s(t){m(this,t||{}),m(this,T)}var h=n(1),p=n(2),v=h.Query,g=h.utils,y=g.addHiddenPropsToTarget,b=g.deepMixIn,A=g.extend,m=g.fillIn,I=g.forEachRelation,x=g.forOwn,P=g.fromJson,w=g.get,M=g.isArray,j=g.isUndefined,F=g.resolve,K=g.reject,U=g.set,E=g.toJson,O=[],C=!1,D=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),F()},S=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),F()},T={basePath:"",debug:!1,storage:localStorage};s.extend=A,y(s.prototype,{afterCreate:S,afterCreateMany:S,afterDestroy:S,afterDestroyAll:S,afterFind:S,afterFindAll:S,afterUpdate:S,afterUpdateAll:S,afterUpdateMany:S,beforeCreate:D,beforeCreateMany:D,beforeDestroy:D,beforeDestroyAll:D,beforeFind:D,beforeFindAll:D,beforeUpdate:D,beforeUpdateAll:D,beforeUpdateMany:D,_create:function(t,e,n){var r=this,o={},a=t.relationFields||[];x(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=w(o,t.idAttribute)||p();U(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,E(o)),r.ensureId(i,t,n),P(r.storage.getItem(u))},create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",F(r[i](t,e,n)).then(function(o){var a=j(o)?e:o;return a=r._create(t,a,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=j(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",F(r[i](t,e,n)).then(function(o){var a=j(o)?e:o;return a=a.map(function(e){return r._create(t,e,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=j(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroy",F(r[i](t,e,n)).then(function(){return i=n.op="destroy",r.dbg(i,e,n),r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),i=n.op="afterDestroy",r[i](t,e,n).then(function(t){return e=j(t)?e:t,n.raw?{data:e,deleted:1}:e})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroyAll",F(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return w(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=j(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(M(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",F(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),j(a))return void(a=void 0);a=P(a);var c=[];return I(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var l=[],d=w(a,e.localKeys)||[];d=Array.isArray(d)?d:Object.keys(d),l=l.concat(d||[]),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(l).filter(function(t){return t})})},n).then(function(t){return U(a,e.localField,t),t})}else"belongsTo"===e.type&&(f=o.find(i,w(a,e.foreignKey),n).then(function(t){return U(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,w(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?U(a,e.localField,t[0]):U(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",F(o[i](t,e,n,a)).then(function(t){return a=j(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",F(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);x(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(P(i))});var c=t.idAttribute,l=new v({index:{getAll:function(){return a}}});a=l.filter(e).run();var d=[];return I(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=w(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n||[])}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=w(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),U(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return w(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===w(r,t.foreignKey)&&U(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return w(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){w(e,t.foreignKey)===w(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?U(n,t.localField,r[0]):U(n,t.localField,r)}),e}),i&&d.push(i)}),Promise.all(d)}).then(function(){return i=n.op="afterFindAll",F(o[i](t,e,n,a)).then(function(t){return a=j(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?P(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(M(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,E(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",F(o[u](t,e,n,r)).then(function(a){n=j(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?P(f):void 0;var c=0;return f&&(b(f,n),o.storage.setItem(i,E(f)),c++),u=r.op="afterUpdate",o[u](t,e,n,r,f).then(function(t){return f=j(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",F(o[u](t,e,n,r)).then(function(a){return e=j(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=w(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,E(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=j(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),d(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",F(r[i](t,e,n)).then(function(o){e=j(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=w(e,a);if(!j(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?P(f):void 0;c&&(b(c,e),r.storage.setItem(i,E(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=j(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),s.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=s},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){O.push(t)}function c(){O.length&&!C&&(C=!0,O[0]())}function l(t){O.length?f(t):(f(t),c())}function d(t){return new Promise(t).then(function(t){return C=!1,O.shift(),setTimeout(c,0),t},function(t){return C=!1,O.shift(),setTimeout(c,0),j(t)})}function s(t){m(this,t||{}),m(this,T)}var h=n(1),p=n(2),v=h.Query,g=h.utils,y=g.addHiddenPropsToTarget,b=g.deepMixIn,A=g.extend,m=g.fillIn,I=g.forEachRelation,x=g.forOwn,P=g.fromJson,w=g.get,F=g.isArray,M=g.isUndefined,K=g.resolve,j=g.reject,E=g.set,U=g.toJson,O=[],C=!1,D=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),K()},S=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),K()},T={basePath:"",debug:!1,storage:localStorage};s.extend=A,y(s.prototype,{afterCreate:S,afterCreateMany:S,afterDestroy:S,afterDestroyAll:S,afterFind:S,afterFindAll:S,afterUpdate:S,afterUpdateAll:S,afterUpdateMany:S,beforeCreate:D,beforeCreateMany:D,beforeDestroy:D,beforeDestroyAll:D,beforeFind:D,beforeFindAll:D,beforeUpdate:D,beforeUpdateAll:D,beforeUpdateMany:D,_create:function(t,e,n){var r=this,o={},a=t.relationFields||[];x(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=w(o,t.idAttribute)||p();E(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,U(o)),r.ensureId(i,t,n),P(r.storage.getItem(u))},create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",K(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=r._create(t,a,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",K(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=a.map(function(e){return r._create(t,e,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroy",K(r[i](t,e,n)).then(function(){i=n.op="destroy",r.dbg(i,e,n);var o=r.getIdPath(t,n,e),a=r.storage.getItem(o),u=0;return a&&(r.storage.removeItem(o),r.removeId(e,t,n),u++),i=n.op="afterDestroy",K(r[i](t,e,n,u?e:void 0)).then(function(t){return e=M(t)?e:t,n.raw?{data:u?e:void 0,deleted:u}:u?e:void 0})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroyAll",K(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return w(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=M(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(F(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",K(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),!a)return void(a=void 0);a=P(a);var c=[];return I(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var l=[],d=w(a,e.localKeys)||[];d=Array.isArray(d)?d:Object.keys(d),l=l.concat(d),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(l).filter(function(t){return t})})},n).then(function(t){return E(a,e.localField,t),t})}else"hasMany"===e.type&&e.foreignKeys?f=o.findAll(i,{where:r({},e.foreignKeys,{contains:w(a,t.idAttribute)})},n).then(function(t){return E(a,e.localField,t),t}):"belongsTo"===e.type&&(f=o.find(i,w(a,e.foreignKey),n).then(function(t){return E(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,w(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?E(a,e.localField,t[0]):E(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",K(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",K(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);x(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(P(i))});var c=t.idAttribute,l=new v({index:{getAll:function(){return a}}});a=l.filter(e).run();var d=[];return I(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=w(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n||[])}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=w(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),E(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return w(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===w(r,t.foreignKey)&&E(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return w(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){w(e,t.foreignKey)===w(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?E(n,t.localField,r[0]):E(n,t.localField,r)}),e}),i&&d.push(i)}),Promise.all(d)}).then(function(){return i=n.op="afterFindAll",K(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?P(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(F(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,U(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",K(o[u](t,e,n,r)).then(function(a){n=M(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?P(f):void 0;var c=0;if(!f)throw new Error("Not Found");return b(f,n),o.storage.setItem(i,U(f)),c++,u=r.op="afterUpdate",K(o[u](t,e,n,r,f)).then(function(t){return f=M(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",K(o[u](t,e,n,r)).then(function(a){return e=M(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=w(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,U(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=M(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),d(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",K(r[i](t,e,n)).then(function(o){e=M(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=w(e,a);if(!M(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?P(f):void 0;c&&(b(c,e),r.storage.setItem(i,U(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=M(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),s.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=s},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); //# sourceMappingURL=dist/js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index 330b29b..eea71f4 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_create","mapper","props","_props","relationFields","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","create","success","failure","undefined","record","_record","raw","data","created","createMany","records","map","_records","_len4","_key4","log","destroy","removeItem","removeId","_id","deleted","destroyAll","query","findAll","ids","_ids","getIds","saveKeys","find","with","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","relatedItem","all","found","json","_query","index","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_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D,QAAU6N,GAMhB,SAAS5N,EAAQD,GAUlB,QAAS8N,KACL,MAAOA,GAAOnJ,MAIlBmJ,EAAOnJ,IAAMgJ,KAAKG,OAElB7N,EAAOD,QAAU8N,GAOhB,SAAS7N,EAAQD,EAASQ,GAE/B,GAAIuN,GAASvN,EAAoB,IAGzBoE,EAAUxC,MAAMwC,SAAW,SAAUoJ,GACrC,MAAOD,GAAOC,EAAK,SAEvB/N,GAAOD,QAAU4E,GAMhB,SAAS3E,EAAQD,EAASQ,GAM3B,QAASuN,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAAS1N,EAAoB,GAO7BP,GAAOD,QAAU+N,GAMhB,SAAS9N,EAAQD,GAWlB,QAASkO,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAUzN,KAAKmN,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAYjN,OAAO2E,UAAUuI,QAejCtO,GAAOD,QAAUkO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_create","mapper","props","_props","relationFields","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","create","success","failure","undefined","record","_record","raw","data","created","createMany","records","map","_records","_len4","_key4","log","destroy","recordJson","deleted","removeItem","removeId","_id","destroyAll","query","findAll","ids","_ids","getIds","saveKeys","find","with","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","foreignKeys","contains","relatedItem","all","found","json","_query","index","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","Error","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxB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wC,SAAW,SAAUwJ,GACrC,MAAOD,GAAOC,EAAK,SAEvBnO,GAAOD,QAAU4E,GAMhB,SAAS3E,EAAQD,EAASQ,GAM3B,QAAS2N,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAAS9N,EAAoB,GAO7BP,GAAOD,QAAUmO,GAMhB,SAASlO,EAAQD,GAWlB,QAASsO,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAU7N,KAAKuN,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAYrN,OAAO2E,UAAU2I,QAejC1O,GAAOD,QAAUsO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/karma.start.js b/karma.start.js index 8032452..68e0de8 100644 --- a/karma.start.js +++ b/karma.start.js @@ -4,7 +4,10 @@ beforeEach(function () { TestRunner.init({ debug: false, - features: [], + features: [ + 'findHasManyLocalKeys', + 'findHasManyForeignKeys' + ], JSData: JSData, Adapter: LocalStorageAdapter, adapterConfig: { diff --git a/package.json b/package.json index 3be0f72..eac479c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "version": "3.0.0-alpha.3", + "version": "3.0.0-alpha.4", "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", @@ -43,6 +43,7 @@ "gzip": "echo gzipped size: $(cat dist/js-data-localstorage.min.js | gzip -f9 | wc -c)kb", "build": "npm run lint && npm run bundle && npm run min && npm run version && npm run banner", "karma": "karma start", + "quick": "npm run bundle && npm run karma", "test": "npm run build && npm run karma", "release": "npm test && npm run doc && node scripts/authors.js", "ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | coveralls || true && cat ./coverage/PhantomJS*/lcov.info | codacy-coverage || true" @@ -60,7 +61,7 @@ "codacy-coverage": "1.1.3", "coveralls": "2.11.6", "ink-docstrap": "1.1.2", - "js-data-adapter-tests": "^2.0.0-alpha.5", + "js-data-adapter-tests": "^2.0.0-alpha.6", "jsdoc": "3.4.0", "karma": "0.13.21", "karma-browserstack-launcher": "0.1.10", diff --git a/src/index.js b/src/index.js index 14082a4..2e9d5d5 100644 --- a/src/index.js +++ b/src/index.js @@ -404,18 +404,24 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { self.dbg(op, id, opts) // Destroy the record // TODO: Destroy related records when the "with" option is provided - self.storage.removeItem(self.getIdPath(mapper, opts, id)) - self.removeId(id, mapper, opts) + const key = self.getIdPath(mapper, opts, id) + const recordJson = self.storage.getItem(key) + let deleted = 0 + if (recordJson) { + self.storage.removeItem(key) + self.removeId(id, mapper, opts) + deleted++ + } // afterDestroy lifecycle hook op = opts.op = 'afterDestroy' - return self[op](mapper, id, opts).then(function (_id) { + return resolve(self[op](mapper, id, opts, deleted ? id : undefined)).then(function (_id) { // Allow for re-assignment from lifecycle hook id = isUndefined(_id) ? id : _id return opts.raw ? { - data: id, - deleted: 1 - } : id + data: deleted ? id : undefined, + deleted + } : deleted ? id : undefined }) }).then(success, failure) }) @@ -522,7 +528,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { self.dbg(op, id, opts) const key = self.getIdPath(mapper, opts, id) record = self.storage.getItem(key) - if (isUndefined(record)) { + if (!record) { record = undefined return } @@ -548,7 +554,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { let localKeys = [] let itemKeys = get(record, def.localKeys) || [] itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) - localKeys = localKeys.concat(itemKeys || []) + localKeys = localKeys.concat(itemKeys) task = self.findAll(relatedMapper, { where: { [relatedMapper.idAttribute]: { @@ -559,6 +565,17 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { set(record, def.localField, relatedItems) return relatedItems }) + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.findAll(relatedMapper, { + where: { + [def.foreignKeys]: { + 'contains': get(record, mapper.idAttribute) + } + } + }, __opts).then(function (relatedItems) { + set(record, def.localField, relatedItems) + return relatedItems + }) } else if (def.type === 'belongsTo') { task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) { set(record, def.localField, relatedItem) @@ -857,6 +874,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { const key = self.getIdPath(mapper, opts, id) let record = self.storage.getItem(key) record = record ? fromJson(record) : undefined + let updated = 0 // Update the record @@ -865,11 +883,13 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { deepMixIn(record, props) self.storage.setItem(key, toJson(record)) updated++ + } else { + throw new Error('Not Found') } // afterUpdate lifecycle hook op = opts.op = 'afterUpdate' - return self[op](mapper, id, props, opts, record).then(function (_record) { + return resolve(self[op](mapper, id, props, opts, record)).then(function (_record) { // Allow for re-assignment from lifecycle hook record = isUndefined(_record) ? record : _record return opts.raw ? { From 724c251807da8cb32607b9f8723e5ff3e1622df8 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Fri, 26 Feb 2016 17:09:37 -0800 Subject: [PATCH 08/15] 3.0.0-alpha.5 --- CHANGELOG.md | 4 +++ CONTRIBUTORS | 2 +- dist/js-data-localstorage.js | 55 ++++++++++++++++++++++--------- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 4 +-- dist/js-data-localstorage.min.map | 2 +- karma.start.js | 30 ++++------------- package.json | 6 ++-- src/index.js | 48 ++++++++++++++++++++------- 9 files changed, 94 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3d6e0e..a4ac7f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +##### 3.0.0-alpha.5 - 26 February 2016 + +- Couple of fixes + ##### 3.0.0-alpha.4 - 23 February 2016 - Improved find, destroy, and update methods diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 6a1e2ab..f3acb83 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -4,4 +4,4 @@ # # Names should be added to this file as: # [commit count] Name - 62 Jason Dobry + 63 Jason Dobry diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index 94b97f9..2a424df 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1,6 +1,6 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.4 - Homepage +* @version 3.0.0-alpha.5 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT @@ -195,6 +195,15 @@ return /******/ (function(modules) { // webpackBootstrap */ debug: false, + /** + * TODO + * + * @name LocalStorageAdapter#returnDeletedIds + * @type {boolean} + * @default false + */ + returnDeletedIds: false, + /** * TODO * @@ -480,6 +489,7 @@ return /******/ (function(modules) { // webpackBootstrap destroy: function destroy(mapper, id, opts) { var self = this; opts || (opts = {}); + var returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds; return createTask(function (success, failure) { queueTask(function () { @@ -502,13 +512,14 @@ return /******/ (function(modules) { // webpackBootstrap // afterDestroy lifecycle hook op = opts.op = 'afterDestroy'; - return resolve(self[op](mapper, id, opts, deleted ? id : undefined)).then(function (_id) { + return resolve(self[op](mapper, id, opts, deleted && returnDeletedIds ? id : undefined)).then(function (_id) { // Allow for re-assignment from lifecycle hook - id = isUndefined(_id) ? id : _id; - return opts.raw ? { - data: deleted ? id : undefined, + id = isUndefined(_id) && returnDeletedIds ? id : _id; + var result = { + data: id, deleted: deleted - } : deleted ? id : undefined; + }; + return self.getRaw(opts) ? result : result.data; }); }).then(success, failure); }); @@ -531,6 +542,7 @@ return /******/ (function(modules) { // webpackBootstrap var self = this; query || (query = {}); opts || (opts = {}); + var returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds; return createTask(function (success, failure) { queueTask(function () { @@ -541,7 +553,7 @@ return /******/ (function(modules) { // webpackBootstrap op = opts.op = 'destroyAll'; self.dbg(op, query, opts); // Find the records that are to be destroyed - return self.findAll(mapper, query, opts); + return self.findAll(mapper, query, { raw: false }); }).then(function (records) { var idAttribute = mapper.idAttribute; // Gather IDs of records to be destroyed @@ -557,13 +569,14 @@ return /******/ (function(modules) { // webpackBootstrap // afterDestroyAll lifecycle hook op = opts.op = 'afterDestroyAll'; - return self[op](mapper, query, opts, ids).then(function (_ids) { + return self[op](mapper, query, opts, returnDeletedIds ? ids : undefined).then(function (_ids) { // Allow for re-assignment from lifecycle hook - ids = isUndefined(_ids) ? ids : _ids; - return opts.raw ? { + ids = isUndefined(_ids) && returnDeletedIds ? ids : _ids; + var result = { data: ids, deleted: records.length - } : ids; + }; + return self.getRaw(opts) ? result : result.data; }); }).then(success, failure); }); @@ -642,7 +655,7 @@ return /******/ (function(modules) { // webpackBootstrap } else if (def.type === 'hasMany' && def.localKeys) { var localKeys = []; var itemKeys = get(record, def.localKeys) || []; - itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + itemKeys = isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); localKeys = localKeys.concat(itemKeys); task = self.findAll(relatedMapper, { where: _defineProperty({}, relatedMapper.idAttribute, { @@ -772,7 +785,7 @@ return /******/ (function(modules) { // webpackBootstrap records.forEach(function (item) { var itemKeys = get(item, def.localKeys) || []; itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); - localKeys = localKeys.concat(itemKeys || []); + localKeys = localKeys.concat(itemKeys); }); task = self.findAll(relatedMapper, { where: _defineProperty({}, relatedMapper.idAttribute, { @@ -879,6 +892,18 @@ return /******/ (function(modules) { // webpackBootstrap }, + /** + * TODO + * + * @name LocalStorageAdapter#getRaw + * @method + */ + getRaw: function getRaw(opts) { + opts || (opts = {}); + return !!(isUndefined(opts.raw) ? this.raw : opts.raw); + }, + + /** * TODO * @@ -1151,11 +1176,11 @@ return /******/ (function(modules) { // webpackBootstrap * otherwise `false` if the current version is not beta. */ LocalStorageAdapter.version = { - full: '3.0.0-alpha.4', + full: '3.0.0-alpha.5', major: parseInt('3', 10), minor: parseInt('0', 10), patch: parseInt('0', 10), - alpha: true ? '4' : false, + alpha: true ? '5' : false, beta: true ? 'false' : false }; diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index f3b0e9f..2e06035 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 5a8dced2f6409f918f40","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;;;;;;ACrCA,KAAM,SAAS,oBAAQ,CAAR,CAAT;AACN,KAAM,OAAO,oBAAQ,CAAR,CAAP;;KAGJ,QAEE,OAFF;KACA,QACE,OADF;KAIA,yBAcE,MAdF;KACA,YAaE,MAbF;KACA,SAYE,MAZF;KACA,SAWE,MAXF;KACA,kBAUE,MAVF;KACA,SASE,MATF;KACA,WAQE,MARF;KACA,MAOE,MAPF;KACA,UAME,MANF;KACA,cAKE,MALF;KACA,UAIE,MAJF;KACA,SAGE,MAHF;KACA,MAEE,MAF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uCJ,IAvCI,CAuCC,OAvCD,EAuCU,OAvCV,CAAP,CALoB;QAAZ,CAAV,CAD4C;MAA5B,CAAlB,CALiC;IA7yBiB;EAAtD;;;;;;;;;;;;;;;;AAm3BA,qBAAoB,OAApB,GAA8B;AAC5B,SAAM,oBAAN;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,QAA6B,cAA7B,GAA8C,KAA9C;AACP,SAAM,QAA4B,aAA5B,GAA4C,KAA5C;EANR;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,QAAO,OAAP,GAAiB,mBAAjB,C;;;;;;ACrjCA,gD;;;;;;ACAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 5a8dced2f6409f918f40\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n _create (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n record = self._create(mapper, record, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n records = records.map(function (record) {\n return self._create(mapper, record, opts)\n })\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n const key = self.getIdPath(mapper, opts, id)\n const recordJson = self.storage.getItem(key)\n let deleted = 0\n if (recordJson) {\n self.storage.removeItem(key)\n self.removeId(id, mapper, opts)\n deleted++\n }\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return resolve(self[op](mapper, id, opts, deleted ? id : undefined)).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) ? id : _id\n return opts.raw ? {\n data: deleted ? id : undefined,\n deleted\n } : deleted ? id : undefined\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, ids).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) ? ids : _ids\n return opts.raw ? {\n data: ids,\n deleted: records.length\n } : ids\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (!record) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'contains': get(record, mapper.idAttribute)\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys || [])\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n } else {\n throw new Error('Not Found')\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return resolve(self[op](mapper, id, props, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap acffac6d0d2bf9a66e1d","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;;;;;;ACrCA,KAAM,SAAS,oBAAQ,CAAR,CAAT;AACN,KAAM,OAAO,oBAAQ,CAAR,CAAP;;KAGJ,QAEE,OAFF;KACA,QACE,OADF;KAIA,yBAcE,MAdF;KACA,YAaE,MAbF;KACA,SAYE,MAZF;KACA,SAWE,MAXF;KACA,kBAUE,MAVF;KACA,SASE,MATF;KACA,WAQE,MARF;KACA,MAOE,MAPF;KACA,UAME,MANF;KACA,cAKE,MALF;KACA,UAIE,MAJF;KACA,SAGE,MAHF;KACA,MAEE,MAFF;KACA,SACE,MADF;;;AAGF,UAAS,aAAT,CAAwB,KAAxB,EAA+B;AAC7B,UAAQ,SAAS,IAAT,IAAiB,UAAU,EAAV,CADI;EAA/B;AAGA,UAAS,IAAT,CAAe,KAAf,E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ACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 acffac6d0d2bf9a66e1d\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#returnDeletedIds\n * @type {boolean}\n * @default false\n */\n returnDeletedIds: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n _create (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n record = self._create(mapper, record, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n records = records.map(function (record) {\n return self._create(mapper, record, opts)\n })\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n const key = self.getIdPath(mapper, opts, id)\n const recordJson = self.storage.getItem(key)\n let deleted = 0\n if (recordJson) {\n self.storage.removeItem(key)\n self.removeId(id, mapper, opts)\n deleted++\n }\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return resolve(self[op](mapper, id, opts, deleted && returnDeletedIds ? id : undefined)).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) && returnDeletedIds ? id : _id\n const result = {\n data: id,\n deleted\n }\n return self.getRaw(opts) ? result : result.data\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n const returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, { raw: false })\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, returnDeletedIds ? ids : undefined).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) && returnDeletedIds ? ids : _ids\n const result = {\n data: ids,\n deleted: records.length\n }\n return self.getRaw(opts) ? result : result.data\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (!record) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'contains': get(record, mapper.idAttribute)\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getRaw\n * @method\n */\n getRaw (opts) {\n opts || (opts = {})\n return !!(isUndefined(opts.raw) ? this.raw : opts.raw)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n } else {\n throw new Error('Not Found')\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return resolve(self[op](mapper, id, props, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index f42b312..fc8cd26 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -1,11 +1,11 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.4 - Homepage +* @version 3.0.0-alpha.5 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){O.push(t)}function c(){O.length&&!C&&(C=!0,O[0]())}function l(t){O.length?f(t):(f(t),c())}function d(t){return new Promise(t).then(function(t){return C=!1,O.shift(),setTimeout(c,0),t},function(t){return C=!1,O.shift(),setTimeout(c,0),j(t)})}function s(t){m(this,t||{}),m(this,T)}var h=n(1),p=n(2),v=h.Query,g=h.utils,y=g.addHiddenPropsToTarget,b=g.deepMixIn,A=g.extend,m=g.fillIn,I=g.forEachRelation,x=g.forOwn,P=g.fromJson,w=g.get,F=g.isArray,M=g.isUndefined,K=g.resolve,j=g.reject,E=g.set,U=g.toJson,O=[],C=!1,D=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),K()},S=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),K()},T={basePath:"",debug:!1,storage:localStorage};s.extend=A,y(s.prototype,{afterCreate:S,afterCreateMany:S,afterDestroy:S,afterDestroyAll:S,afterFind:S,afterFindAll:S,afterUpdate:S,afterUpdateAll:S,afterUpdateMany:S,beforeCreate:D,beforeCreateMany:D,beforeDestroy:D,beforeDestroyAll:D,beforeFind:D,beforeFindAll:D,beforeUpdate:D,beforeUpdateAll:D,beforeUpdateMany:D,_create:function(t,e,n){var r=this,o={},a=t.relationFields||[];x(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=w(o,t.idAttribute)||p();E(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,U(o)),r.ensureId(i,t,n),P(r.storage.getItem(u))},create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",K(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=r._create(t,a,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",K(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=a.map(function(e){return r._create(t,e,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;return n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroy",K(r[i](t,e,n)).then(function(){i=n.op="destroy",r.dbg(i,e,n);var o=r.getIdPath(t,n,e),a=r.storage.getItem(o),u=0;return a&&(r.storage.removeItem(o),r.removeId(e,t,n),u++),i=n.op="afterDestroy",K(r[i](t,e,n,u?e:void 0)).then(function(t){return e=M(t)?e:t,n.raw?{data:u?e:void 0,deleted:u}:u?e:void 0})}).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeDestroyAll",K(r[i](t,e,n)).then(function(){return i=n.op="destroyAll",r.dbg(i,e,n),r.findAll(t,e,n)}).then(function(o){var a=t.idAttribute,u=o.map(function(t){return w(t,a)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),i=n.op="afterDestroyAll",r[i](t,e,n,u).then(function(t){return u=M(t)?u:t,n.raw?{data:u,deleted:o.length}:u})}).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(F(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",K(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),!a)return void(a=void 0);a=P(a);var c=[];return I(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var l=[],d=w(a,e.localKeys)||[];d=Array.isArray(d)?d:Object.keys(d),l=l.concat(d),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(l).filter(function(t){return t})})},n).then(function(t){return E(a,e.localField,t),t})}else"hasMany"===e.type&&e.foreignKeys?f=o.findAll(i,{where:r({},e.foreignKeys,{contains:w(a,t.idAttribute)})},n).then(function(t){return E(a,e.localField,t),t}):"belongsTo"===e.type&&(f=o.find(i,w(a,e.foreignKey),n).then(function(t){return E(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,w(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?E(a,e.localField,t[0]):E(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",K(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",K(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);x(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(P(i))});var c=t.idAttribute,l=new v({index:{getAll:function(){return a}}});a=l.filter(e).run();var d=[];return I(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=w(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n||[])}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=w(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),E(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return w(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===w(r,t.foreignKey)&&E(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return w(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){w(e,t.foreignKey)===w(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?E(n,t.localField,r[0]):E(n,t.localField,r)}),e}),i&&d.push(i)}),Promise.all(d)}).then(function(){return i=n.op="afterFindAll",K(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?P(o):{}},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(F(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,U(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",K(o[u](t,e,n,r)).then(function(a){n=M(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?P(f):void 0;var c=0;if(!f)throw new Error("Not Found");return b(f,n),o.storage.setItem(i,U(f)),c++,u=r.op="afterUpdate",K(o[u](t,e,n,r,f)).then(function(t){return f=M(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",K(o[u](t,e,n,r)).then(function(a){return e=M(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=w(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,U(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=M(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),d(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",K(r[i](t,e,n)).then(function(o){e=M(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=w(e,a);if(!M(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?P(f):void 0;c&&(b(c,e),r.storage.setItem(i,U(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=M(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),s.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=s},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){U.push(t)}function c(){U.length&&!O&&(O=!0,U[0]())}function l(t){U.length?f(t):(f(t),c())}function d(t){return new Promise(t).then(function(t){return O=!1,U.shift(),setTimeout(c,0),t},function(t){return O=!1,U.shift(),setTimeout(c,0),j(t)})}function s(t){I(this,t||{}),I(this,S)}var h=n(1),p=n(2),v=h.Query,g=h.utils,y=g.addHiddenPropsToTarget,b=g.deepMixIn,A=g.extend,I=g.fillIn,m=g.forEachRelation,w=g.forOwn,x=g.fromJson,P=g.get,F=g.isArray,M=g.isUndefined,K=g.resolve,j=g.reject,D=g.set,E=g.toJson,U=[],O=!1,C=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),K()},R=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),K()},S={basePath:"",debug:!1,returnDeletedIds:!1,storage:localStorage};s.extend=A,y(s.prototype,{afterCreate:R,afterCreateMany:R,afterDestroy:R,afterDestroyAll:R,afterFind:R,afterFindAll:R,afterUpdate:R,afterUpdateAll:R,afterUpdateMany:R,beforeCreate:C,beforeCreateMany:C,beforeDestroy:C,beforeDestroyAll:C,beforeFind:C,beforeFindAll:C,beforeUpdate:C,beforeUpdateAll:C,beforeUpdateMany:C,_create:function(t,e,n){var r=this,o={},a=t.relationFields||[];w(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=P(o,t.idAttribute)||p();D(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,E(o)),r.ensureId(i,t,n),x(r.storage.getItem(u))},create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",K(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=r._create(t,a,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",K(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=a.map(function(e){return r._create(t,e,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;n||(n={});var o=M(n.returnDeletedIds)?r.returnDeletedIds:!!n.returnDeletedIds;return d(function(a,i){l(function(){var u=void 0;return u=n.op="beforeDestroy",K(r[u](t,e,n)).then(function(){u=n.op="destroy",r.dbg(u,e,n);var a=r.getIdPath(t,n,e),i=r.storage.getItem(a),f=0;return i&&(r.storage.removeItem(a),r.removeId(e,t,n),f++),u=n.op="afterDestroy",K(r[u](t,e,n,f&&o?e:void 0)).then(function(t){e=M(t)&&o?e:t;var a={data:e,deleted:f};return r.getRaw(n)?a:a.data})}).then(a,i)})})},destroyAll:function(t,e,n){var r=this;e||(e={}),n||(n={});var o=M(n.returnDeletedIds)?r.returnDeletedIds:!!n.returnDeletedIds;return d(function(a,i){l(function(){var u=void 0;return u=n.op="beforeDestroyAll",K(r[u](t,e,n)).then(function(){return u=n.op="destroyAll",r.dbg(u,e,n),r.findAll(t,e,{raw:!1})}).then(function(a){var i=t.idAttribute,f=a.map(function(t){return P(t,i)});return f.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(f,t,n),u=n.op="afterDestroyAll",r[u](t,e,n,o?f:void 0).then(function(t){f=M(t)&&o?f:t;var e={data:f,deleted:a.length};return r.getRaw(n)?e:e.data})}).then(a,i)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(F(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",K(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),!a)return void(a=void 0);a=x(a);var c=[];return m(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var l=[],d=P(a,e.localKeys)||[];d=F(d)?d:Object.keys(d),l=l.concat(d),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(l).filter(function(t){return t})})},n).then(function(t){return D(a,e.localField,t),t})}else"hasMany"===e.type&&e.foreignKeys?f=o.findAll(i,{where:r({},e.foreignKeys,{contains:P(a,t.idAttribute)})},n).then(function(t){return D(a,e.localField,t),t}):"belongsTo"===e.type&&(f=o.find(i,P(a,e.foreignKey),n).then(function(t){return D(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,P(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?D(a,e.localField,t[0]):D(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",K(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",K(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);w(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(x(i))});var c=t.idAttribute,l=new v({index:{getAll:function(){return a}}});a=l.filter(e).run();var d=[];return m(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=P(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n)}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=P(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),D(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return P(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===P(r,t.foreignKey)&&D(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return P(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){P(e,t.foreignKey)===P(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?D(n,t.localField,r[0]):D(n,t.localField,r)}),e}),i&&d.push(i)}),Promise.all(d)}).then(function(){return i=n.op="afterFindAll",K(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?x(o):{}},getRaw:function(t){return t||(t={}),!!(M(t.raw)?this.raw:t.raw)},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(F(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,E(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",K(o[u](t,e,n,r)).then(function(a){n=M(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?x(f):void 0;var c=0;if(!f)throw new Error("Not Found");return b(f,n),o.storage.setItem(i,E(f)),c++,u=r.op="afterUpdate",K(o[u](t,e,n,r,f)).then(function(t){return f=M(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",K(o[u](t,e,n,r)).then(function(a){return e=M(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=P(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,E(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=M(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),d(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",K(r[i](t,e,n)).then(function(o){e=M(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=P(e,a);if(!M(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?x(f):void 0;c&&(b(c,e),r.storage.setItem(i,E(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=M(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),s.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=s},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); //# sourceMappingURL=dist/js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index eea71f4..3835853 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_create","mapper","props","_props","relationFields","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","create","success","failure","undefined","record","_record","raw","data","created","createMany","records","map","_records","_len4","_key4","log","destroy","recordJson","deleted","removeItem","removeId","_id","destroyAll","query","findAll","ids","_ids","getIds","saveKeys","find","with","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","foreignKeys","contains","relatedItem","all","found","json","_query","index","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","Error","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAEA,SAASS,GAAgBC,EAAKC,EAAKC,GAAiK,MAApJD,KAAOD,GAAOG,OAAOC,eAAeJ,EAAKC,GAAOC,MAAOA,EAAOG,YAAY,EAAMC,cAAc,EAAMC,UAAU,IAAkBP,EAAIC,GAAOC,EAAgBF,EAwB3M,QAASQ,GAAcN,GACrB,MAAgB,OAAT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AA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAU7N,KAAKuN,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAYrN,OAAO2E,UAAU2I,QAejC1O,GAAOD,QAAUsO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","returnDeletedIds","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_create","mapper","props","_props","relationFields","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","create","success","failure","undefined","record","_record","raw","data","created","createMany","records","map","_records","_len4","_key4","log","destroy","recordJson","deleted","removeItem","removeId","_id","getRaw","destroyAll","query","findAll","ids","_ids","getIds","saveKeys","find","with","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","foreignKeys","contains","relatedItem","all","found","json","_query","index","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","Error","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAEA,SAASS,GAAgBC,EAAKC,EAAKC,GAAiK,MAApJD,KAAOD,GAAOG,OAAOC,eAAeJ,EAAKC,GAAOC,MAAOA,EAAOG,YAAY,EAAMC,cAAc,EAAMC,UAAU,IAAkBP,EAAIC,GAAOC,EAAgBF,EAwB3M,QAASQ,GAAcN,GACrB,MAAgB,OAATA,GAA2B,KAAVA,EAE1B,QAASO,GAAKC,EAAOC,GAEnB,MADAA,KAAcA,EAAY,IACnBD,EAAME,OAAOJ,GAAeC,KAAKE,GAE1C,QAASE,KACP,IAAK,GAAIC,GAAOC,UAAUC,OAAQC,EAAOC,MAAMJ,GAAOK,EAAO,EAAUL,EA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AAQD,EAASQ,GAM3B,QAAS6N,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAAShO,EAAoB,GAO7BP,GAAOD,QAAUqO,GAMhB,SAASpO,EAAQD,GAWlB,QAASwO,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAU/N,KAAKyN,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAYvN,OAAO4E,UAAU4I,QAejC5O,GAAOD,QAAUwO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/karma.start.js b/karma.start.js index 68e0de8..300e215 100644 --- a/karma.start.js +++ b/karma.start.js @@ -17,7 +17,7 @@ TestRunner.init({ describe('relation functionality', function () { // will be available in js-data 3.0.0-alpha.15 - it.skip('nested create', function () { + it('nested create', function () { return this.$$container.create('user', { name: 'John', profile: { @@ -32,7 +32,6 @@ describe('relation functionality', function () { } ] }, { with: ['profile', 'post', 'organization'] }).then(function (user) { - console.log(JSON.stringify(user, null, 2)) assert.isDefined(user) assert.isDefined(user.id) assert.isDefined(user.organization) @@ -45,20 +44,15 @@ describe('relation functionality', function () { assert.isDefined(user.posts[0].id) }) }) - it.skip('nested create many', function () { - return this.$$container.create('user', [{ + it('nested create many', function () { + return this.$$container.createMany('user', [{ name: 'John', profile: { email: 'john@test.com' }, organization: { name: 'Company Inc' - }, - posts: [ - { - content: 'foo' - } - ] + } }, { name: 'Sally', profile: { @@ -66,14 +60,8 @@ describe('relation functionality', function () { }, organization: { name: 'Company Inc' - }, - posts: [ - { - content: 'foo' - } - ] - }], { with: ['profile', 'post'] }).then(function (users) { - // console.log(JSON.stringify(users, null, 2)) + } + }], { with: ['profile', 'organization'] }).then(function (users) { assert.isDefined(users[0]) assert.isDefined(users[0].id) assert.isDefined(users[0].organization) @@ -81,9 +69,6 @@ describe('relation functionality', function () { assert.equal(users[0].organizationId, users[0].organization.id) assert.isDefined(users[0].profile) assert.isDefined(users[0].profile.id) - assert.isDefined(users[0].posts) - assert.equal(users[0].posts.length, 1) - assert.isDefined(users[0].posts[0].id) assert.isDefined(users[1]) assert.isDefined(users[1].id) assert.isDefined(users[1].organization) @@ -91,9 +76,6 @@ describe('relation functionality', function () { assert.equal(users[1].organizationId, users[1].organization.id) assert.isDefined(users[1].profile) assert.isDefined(users[1].profile.id) - assert.isDefined(users[1].posts) - assert.equal(users[1].posts.length, 1) - assert.isDefined(users[1].posts[0].id) }) }) }) diff --git a/package.json b/package.json index eac479c..9fd88b6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "version": "3.0.0-alpha.4", + "version": "3.0.0-alpha.5", "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", @@ -59,9 +59,9 @@ "babel-preset-es2015": "6.5.0", "chai": "3.5.0", "codacy-coverage": "1.1.3", - "coveralls": "2.11.6", + "coveralls": "2.11.8", "ink-docstrap": "1.1.2", - "js-data-adapter-tests": "^2.0.0-alpha.6", + "js-data-adapter-tests": "^2.0.0-alpha.7", "jsdoc": "3.4.0", "karma": "0.13.21", "karma-browserstack-launcher": "0.1.10", diff --git a/src/index.js b/src/index.js index 2e9d5d5..b74a6d9 100644 --- a/src/index.js +++ b/src/index.js @@ -116,6 +116,15 @@ const DEFAULTS = { */ debug: false, + /** + * TODO + * + * @name LocalStorageAdapter#returnDeletedIds + * @type {boolean} + * @default false + */ + returnDeletedIds: false, + /** * TODO * @@ -393,6 +402,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { destroy (mapper, id, opts) { const self = this opts || (opts = {}) + const returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds return createTask(function (success, failure) { queueTask(function () { @@ -415,13 +425,14 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { // afterDestroy lifecycle hook op = opts.op = 'afterDestroy' - return resolve(self[op](mapper, id, opts, deleted ? id : undefined)).then(function (_id) { + return resolve(self[op](mapper, id, opts, deleted && returnDeletedIds ? id : undefined)).then(function (_id) { // Allow for re-assignment from lifecycle hook - id = isUndefined(_id) ? id : _id - return opts.raw ? { - data: deleted ? id : undefined, + id = isUndefined(_id) && returnDeletedIds ? id : _id + const result = { + data: id, deleted - } : deleted ? id : undefined + } + return self.getRaw(opts) ? result : result.data }) }).then(success, failure) }) @@ -443,6 +454,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { const self = this query || (query = {}) opts || (opts = {}) + const returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds return createTask(function (success, failure) { queueTask(function () { @@ -453,7 +465,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { op = opts.op = 'destroyAll' self.dbg(op, query, opts) // Find the records that are to be destroyed - return self.findAll(mapper, query, opts) + return self.findAll(mapper, query, { raw: false }) }).then(function (records) { const idAttribute = mapper.idAttribute // Gather IDs of records to be destroyed @@ -469,13 +481,14 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { // afterDestroyAll lifecycle hook op = opts.op = 'afterDestroyAll' - return self[op](mapper, query, opts, ids).then(function (_ids) { + return self[op](mapper, query, opts, returnDeletedIds ? ids : undefined).then(function (_ids) { // Allow for re-assignment from lifecycle hook - ids = isUndefined(_ids) ? ids : _ids - return opts.raw ? { + ids = isUndefined(_ids) && returnDeletedIds ? ids : _ids + const result = { data: ids, deleted: records.length - } : ids + } + return self.getRaw(opts) ? result : result.data }) }).then(success, failure) }) @@ -553,7 +566,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { } else if (def.type === 'hasMany' && def.localKeys) { let localKeys = [] let itemKeys = get(record, def.localKeys) || [] - itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) + itemKeys = isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) localKeys = localKeys.concat(itemKeys) task = self.findAll(relatedMapper, { where: { @@ -683,7 +696,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { records.forEach(function (item) { let itemKeys = get(item, def.localKeys) || [] itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) - localKeys = localKeys.concat(itemKeys || []) + localKeys = localKeys.concat(itemKeys) }) task = self.findAll(relatedMapper, { where: { @@ -785,6 +798,17 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { return ids }, + /** + * TODO + * + * @name LocalStorageAdapter#getRaw + * @method + */ + getRaw (opts) { + opts || (opts = {}) + return !!(isUndefined(opts.raw) ? this.raw : opts.raw) + }, + /** * TODO * From 1045903caa48bdd8b0e519003f02f67bb50f0635 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sat, 27 Feb 2016 13:51:08 -0800 Subject: [PATCH 09/15] Added analytics to conf.json --- conf.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/conf.json b/conf.json index 41b00bc..a537268 100644 --- a/conf.json +++ b/conf.json @@ -14,10 +14,14 @@ "templates": { "theme": "lumen", "systemName": "js-data-localstorage", - "copyright": "js-data-localstorage Copyright © 2014-2016 Jason Dobry", + "copyright": "js-data-localstorage Copyright © 2014-2016 js-data-localstorage project authors", "outputSourceFiles": true, "syntaxTheme": "dark", "linenums": true, - "footer": "
Back to js-data.io
" + "footer": "
Back to js-data.io
", + "analytics": { + "ua": "UA-55528236-2", + "domain": "api.js-data.io" + } } } \ No newline at end of file From d7677150d362774a56f1c208d0d99e2b23c915a7 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Wed, 9 Mar 2016 22:46:39 -0800 Subject: [PATCH 10/15] 3.0.0-alpha.6 --- CHANGELOG.md | 6 + dist/js-data-localstorage.js | 2492 ++++++++++++++++++++--------- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 4 +- dist/js-data-localstorage.min.map | 2 +- karma.conf.js | 191 ++- karma.prestart.js | 1 - karma.start.js | 80 +- package.json | 42 +- scripts/authors.js | 11 +- scripts/banner.js | 20 +- scripts/version.js | 42 +- src/index.js | 944 +++-------- 13 files changed, 2128 insertions(+), 1709 deletions(-) delete mode 100644 karma.prestart.js diff --git a/CHANGELOG.md b/CHANGELOG.md index a4ac7f4..76a36c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +##### 3.0.0-alpha.6 - 10 March 2016 + +###### Other +- Now using js-data-repo-tools +- Now using js-data-adapter + ##### 3.0.0-alpha.5 - 26 February 2016 - Couple of fixes diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index 2a424df..b0a3122 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1,6 +1,6 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.5 - Homepage +* @version 3.0.0-alpha.6 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT @@ -65,11 +65,12 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - 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 _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"); } }; }(); /* global: localStorage */ var JSData = __webpack_require__(1); - var guid = __webpack_require__(2); + var Adapter = __webpack_require__(2); + var guid = __webpack_require__(3); var Query = JSData.Query; var utils = JSData.utils; @@ -77,13 +78,11 @@ return /******/ (function(modules) { // webpackBootstrap var deepMixIn = utils.deepMixIn; var extend = utils.extend; var fillIn = utils.fillIn; - var forEachRelation = utils.forEachRelation; var forOwn = utils.forOwn; var fromJson = utils.fromJson; var get = utils.get; var isArray = utils.isArray; var isUndefined = utils.isUndefined; - var resolve = utils.resolve; var reject = utils.reject; var set = utils.set; var toJson = utils.toJson; @@ -104,18 +103,6 @@ return /******/ (function(modules) { // webpackBootstrap var result = join(args, '/'); return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); } - 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 queue = []; var taskInProcess = false; @@ -153,29 +140,7 @@ return /******/ (function(modules) { // webpackBootstrap }); } - var noop = function noop() { - 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 - 1]; - self.dbg.apply(self, [opts.op].concat(args)); - return resolve(); - }; - - var noop2 = function noop2() { - var self = this; - - for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; - } - - var opts = args[args.length - 2]; - self.dbg.apply(self, [opts.op].concat(args)); - return resolve(); - }; + var __super__ = Adapter.prototype; var DEFAULTS = { /** @@ -195,15 +160,6 @@ return /******/ (function(modules) { // webpackBootstrap */ debug: false, - /** - * TODO - * - * @name LocalStorageAdapter#returnDeletedIds - * @type {boolean} - * @default false - */ - returnDeletedIds: false, - /** * TODO * @@ -231,10 +187,27 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Object} [opts.storeage=localStorage] TODO */ function LocalStorageAdapter(opts) { - fillIn(this, opts || {}); - fillIn(this, DEFAULTS); + var self = this; + opts || (opts = {}); + fillIn(opts, DEFAULTS); + Adapter.call(self, opts); } + // Setup prototype inheritance from Adapter + LocalStorageAdapter.prototype = Object.create(Adapter.prototype, { + constructor: { + value: LocalStorageAdapter, + enumerable: false, + writable: true, + configurable: true + } + }); + + Object.defineProperty(LocalStorageAdapter, '__super__', { + configurable: true, + value: Adapter + }); + /** * Alternative to ES6 class syntax for extending `LocalStorageAdapter`. * @@ -249,115 +222,7 @@ return /******/ (function(modules) { // webpackBootstrap LocalStorageAdapter.extend = extend; addHiddenPropsToTarget(LocalStorageAdapter.prototype, { - /** - * @name LocalStorageAdapter#afterCreate - * @method - */ - afterCreate: noop2, - - /** - * @name LocalStorageAdapter#afterCreateMany - * @method - */ - afterCreateMany: noop2, - - /** - * @name LocalStorageAdapter#afterDestroy - * @method - */ - afterDestroy: noop2, - - /** - * @name LocalStorageAdapter#afterDestroyAll - * @method - */ - afterDestroyAll: noop2, - - /** - * @name LocalStorageAdapter#afterFind - * @method - */ - afterFind: noop2, - - /** - * @name LocalStorageAdapter#afterFindAll - * @method - */ - afterFindAll: noop2, - - /** - * @name LocalStorageAdapter#afterUpdate - * @method - */ - afterUpdate: noop2, - - /** - * @name LocalStorageAdapter#afterUpdateAll - * @method - */ - afterUpdateAll: noop2, - - /** - * @name LocalStorageAdapter#afterUpdateMany - * @method - */ - afterUpdateMany: noop2, - - /** - * @name LocalStorageAdapter#beforeCreate - * @method - */ - beforeCreate: noop, - - /** - * @name LocalStorageAdapter#beforeCreateMany - * @method - */ - beforeCreateMany: noop, - - /** - * @name LocalStorageAdapter#beforeDestroy - * @method - */ - beforeDestroy: noop, - - /** - * @name LocalStorageAdapter#beforeDestroyAll - * @method - */ - beforeDestroyAll: noop, - - /** - * @name LocalStorageAdapter#beforeFind - * @method - */ - beforeFind: noop, - - /** - * @name LocalStorageAdapter#beforeFindAll - * @method - */ - beforeFindAll: noop, - - /** - * @name LocalStorageAdapter#beforeUpdate - * @method - */ - beforeUpdate: noop, - - /** - * @name LocalStorageAdapter#beforeUpdateAll - * @method - */ - beforeUpdateAll: noop, - - /** - * @name LocalStorageAdapter#beforeUpdateMany - * @method - */ - beforeUpdateMany: noop, - - _create: function _create(mapper, props, opts) { + _createHelper: function _createHelper(mapper, props, opts) { var self = this; var _props = {}; var relationFields = mapper.relationFields || []; @@ -379,357 +244,143 @@ return /******/ (function(modules) { // webpackBootstrap /** - * Create a new record. + * Create a new record. Internal method used by Adapter#create. * - * @name LocalStorageAdapter#create + * @name LocalStorageAdapter#_create * @method + * @private * @param {Object} mapper The mapper. * @param {Object} props The record to be created. * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] TODO * @return {Promise} */ - create: function create(mapper, props, opts) { + _create: function _create(mapper, props, opts) { var self = this; - props || (props = {}); - opts || (opts = {}); - - return createTask(function (success, failure) { - queueTask(function () { - var op = undefined; - // beforeCreate lifecycle hook - op = opts.op = 'beforeCreate'; - return resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - var record = isUndefined(_props) ? props : _props; - record = self._create(mapper, record, opts); - // afterCreate lifecycle hook - op = opts.op = 'afterCreate'; - return self[op](mapper, props, opts, record).then(function (_record) { - // Allow for re-assignment from lifecycle hook - record = isUndefined(_record) ? record : _record; - return opts.raw ? { - data: record, - created: 1 - } : record; - }); - }).then(success, failure); - }); + return new Promise(function (resolve) { + return resolve([self._createHelper(mapper, props, opts), {}]); }); }, /** - * Create multiple records in a single batch. + * Create multiple records in a single batch. Internal method used by + * Adapter#createMany. * - * @name LocalStorageAdapter#createMany + * @name LocalStorageAdapter#_createMany * @method + * @private * @param {Object} mapper The mapper. - * @param {Array} props Array of records to be created. + * @param {Object} props The records to be created. * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] TODO * @return {Promise} */ - createMany: function createMany(mapper, props, opts) { + _createMany: function _createMany(mapper, props, opts) { var self = this; - props || (props = {}); - opts || (opts = {}); - - return createTask(function (success, failure) { - queueTask(function () { - var op = undefined; - // beforeCreateMany lifecycle hook - op = opts.op = 'beforeCreateMany'; - return resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - var records = isUndefined(_props) ? props : _props; - records = records.map(function (record) { - return self._create(mapper, record, opts); - }); - // afterCreateMany lifecycle hook - op = opts.op = 'afterCreateMany'; - return self[op](mapper, props, opts, records).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? records : _records; - return opts.raw ? { - data: records, - created: records.length - } : records; - }); - }).then(success, failure); - }); + return new Promise(function (resolve) { + props || (props = []); + return resolve([props.map(function (_props) { + return self._createHelper(mapper, _props, opts); + }), {}]); }); }, /** - * @name LocalStorageAdapter#dbg - * @method - */ - dbg: function dbg() { - for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { - args[_key4] = arguments[_key4]; - } - - this.log.apply(this, ['debug'].concat(args)); - }, - - - /** - * Destroy the record with the given primary key. + * Destroy the record with the given primary key. Internal method used by + * Adapter#destroy. * - * @name LocalStorageAdapter#destroy + * @name LocalStorageAdapter#_destroy * @method + * @private * @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] TODO * @return {Promise} */ - destroy: function destroy(mapper, id, opts) { + _destroy: function _destroy(mapper, id, opts) { var self = this; - opts || (opts = {}); - var returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds; - - return createTask(function (success, failure) { - queueTask(function () { - var op = undefined; - // beforeDestroy lifecycle hook - op = opts.op = 'beforeDestroy'; - return resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'destroy'; - self.dbg(op, id, opts); - // Destroy the record - // TODO: Destroy related records when the "with" option is provided - var key = self.getIdPath(mapper, opts, id); - var recordJson = self.storage.getItem(key); - var deleted = 0; - if (recordJson) { - self.storage.removeItem(key); - self.removeId(id, mapper, opts); - deleted++; - } - - // afterDestroy lifecycle hook - op = opts.op = 'afterDestroy'; - return resolve(self[op](mapper, id, opts, deleted && returnDeletedIds ? id : undefined)).then(function (_id) { - // Allow for re-assignment from lifecycle hook - id = isUndefined(_id) && returnDeletedIds ? id : _id; - var result = { - data: id, - deleted: deleted - }; - return self.getRaw(opts) ? result : result.data; - }); - }).then(success, failure); - }); + return new Promise(function (resolve) { + self.storage.removeItem(self.getIdPath(mapper, opts, id)); + self.removeId(id, mapper, opts); + return resolve([undefined, {}]); }); }, /** - * Destroy the records that match the selection `query`. + * Destroy the records that match the selection query. Internal method used by + * Adapter#destroyAll. * - * @name LocalStorageAdapter#destroyAll + * @name LocalStorageAdapter#_destroyAll * @method - * @param {Object} mapper The mapper. - * @param {Object} query Selection query. - * @param {Object} [opts] Configuration opts. - * @param {boolean} [opts.raw=false] TODO + * @private + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [opts] Configuration options. * @return {Promise} */ - destroyAll: function destroyAll(mapper, query, opts) { + _destroyAll: function _destroyAll(mapper, query, opts) { var self = this; - query || (query = {}); - opts || (opts = {}); - var returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds; + return self._findAll(mapper, query).then(function (results) { + var _results = _slicedToArray(results, 1); - return createTask(function (success, failure) { - queueTask(function () { - var op = undefined; - // beforeDestroyAll lifecycle hook - op = opts.op = 'beforeDestroyAll'; - return resolve(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'destroyAll'; - self.dbg(op, query, opts); - // Find the records that are to be destroyed - return self.findAll(mapper, query, { raw: false }); - }).then(function (records) { - var idAttribute = mapper.idAttribute; - // Gather IDs of records to be destroyed - var ids = records.map(function (record) { - return get(record, idAttribute); - }); - // Destroy each record - // TODO: Destroy related records when the "with" option is provided - ids.forEach(function (id) { - self.storage.removeItem(self.getIdPath(mapper, opts, id)); - }); - self.removeId(ids, mapper, opts); - - // afterDestroyAll lifecycle hook - op = opts.op = 'afterDestroyAll'; - return self[op](mapper, query, opts, returnDeletedIds ? ids : undefined).then(function (_ids) { - // Allow for re-assignment from lifecycle hook - ids = isUndefined(_ids) && returnDeletedIds ? ids : _ids; - var result = { - data: ids, - deleted: records.length - }; - return self.getRaw(opts) ? result : result.data; - }); - }).then(success, failure); - }); - }); - }, + var records = _results[0]; - - /** - * TODO - * - * @name LocalStorageAdapter#ensureId - * @method - */ - ensureId: function ensureId(id, mapper, opts) { - var ids = this.getIds(mapper, opts); - if (isArray(id)) { - if (!id.length) { - return; - } - id.forEach(function (_id) { - ids[_id] = 1; + var idAttribute = mapper.idAttribute; + // Gather IDs of records to be destroyed + var ids = records.map(function (record) { + return get(record, idAttribute); }); - } else { - ids[id] = 1; - } - this.saveKeys(ids, mapper, opts); + // Destroy each record + ids.forEach(function (id) { + self.storage.removeItem(self.getIdPath(mapper, opts, id)); + }); + self.removeId(ids, mapper, opts); + return [undefined, {}]; + }); }, /** - * Retrieve the record with the given primary key. + * Retrieve the record with the given primary key. Internal method used by + * Adapter#find. * - * @name LocalStorageAdapter#find + * @name LocalStorageAdapter#_find * @method + * @private * @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] TODO - * @param {string[]} [opts.with=[]] TODO * @return {Promise} */ - find: function find(mapper, id, opts) { + _find: function _find(mapper, id, opts) { var self = this; - var record = undefined, - op = undefined; - opts || (opts = {}); - opts.with || (opts.with = []); - - // beforeFind lifecycle hook - op = opts.op = 'beforeFind'; - return resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'find'; - self.dbg(op, id, opts); + return new Promise(function (resolve) { var key = self.getIdPath(mapper, opts, id); - record = self.storage.getItem(key); - if (!record) { - record = undefined; - return; - } - record = fromJson(record); - var tasks = []; - - forEachRelation(mapper, opts, function (def, __opts) { - var relatedMapper = def.getRelation(); - var task = undefined; - - if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { - task = self.findAll(relatedMapper, _defineProperty({}, def.foreignKey, get(record, mapper.idAttribute)), __opts).then(function (relatedItems) { - if (def.type === 'hasOne' && relatedItems.length) { - set(record, def.localField, relatedItems[0]); - } else { - set(record, def.localField, relatedItems); - } - return relatedItems; - }); - } else if (def.type === 'hasMany' && def.localKeys) { - var localKeys = []; - var itemKeys = get(record, def.localKeys) || []; - itemKeys = isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); - localKeys = localKeys.concat(itemKeys); - task = self.findAll(relatedMapper, { - where: _defineProperty({}, relatedMapper.idAttribute, { - 'in': unique(localKeys).filter(function (x) { - return x; - }) - }) - }, __opts).then(function (relatedItems) { - set(record, def.localField, relatedItems); - return relatedItems; - }); - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = self.findAll(relatedMapper, { - where: _defineProperty({}, def.foreignKeys, { - 'contains': get(record, mapper.idAttribute) - }) - }, __opts).then(function (relatedItems) { - set(record, def.localField, relatedItems); - return relatedItems; - }); - } else if (def.type === 'belongsTo') { - task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) { - set(record, def.localField, relatedItem); - return relatedItem; - }); - } - - if (task) { - tasks.push(task); - } - }); - - return Promise.all(tasks); - }).then(function () { - // afterFind lifecycle hook - op = opts.op = 'afterFind'; - return resolve(self[op](mapper, id, opts, record)).then(function (_record) { - // Allow for re-assignment from lifecycle hook - record = isUndefined(_record) ? record : _record; - return opts.raw ? { - data: record, - found: record ? 1 : 0 - } : record; - }); + var record = self.storage.getItem(key); + return resolve([record ? fromJson(record) : undefined, {}]); }); }, /** - * Retrieve the records that match the selection `query`. + * Retrieve the records that match the selection query. Internal method used + * by Adapter#findAll. * - * @name LocalStorageAdapter#findAll + * @name LocalStorageAdapter#_findAll * @method + * @private * @param {Object} mapper The mapper. * @param {Object} query Selection query. * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] TODO - * @param {string[]} [opts.with=[]] TODO * @return {Promise} */ - findAll: function findAll(mapper, query, opts) { + _findAll: function _findAll(mapper, query, opts) { var self = this; - var records = []; - var op = undefined; - opts || (opts = {}); - opts.with || (opts.with = []); - - // beforeFindAll lifecycle hook - op = opts.op = 'beforeFindAll'; - return resolve(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'findAll'; - self.dbg(op, query, opts); - + query || (query = {}); + return new Promise(function (resolve) { // Load all records into memory... + var records = []; var ids = self.getIds(mapper, opts); forOwn(ids, function (value, id) { var json = self.storage.getItem(self.getIdPath(mapper, opts, id)); @@ -737,9 +388,6 @@ return /******/ (function(modules) { // webpackBootstrap records.push(fromJson(json)); } }); - var idAttribute = mapper.idAttribute; - // TODO: Verify that this collection gets properly garbage collected - // TODO: Or, find a way to filter without using Collection var _query = new Query({ index: { getAll: function getAll() { @@ -747,191 +395,209 @@ return /******/ (function(modules) { // webpackBootstrap } } }); - records = _query.filter(query).run(); - var tasks = []; - - forEachRelation(mapper, opts, function (def, __opts) { - var relatedMapper = def.getRelation(); - var task = undefined; - - if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { - task = self.findAll(relatedMapper, { - where: _defineProperty({}, def.foreignKey, { - 'in': records.map(function (item) { - return get(item, idAttribute); - }).filter(function (x) { - return x; - }) - }) - }, __opts).then(function (relatedItems) { - records.forEach(function (item) { - var attached = []; - relatedItems.forEach(function (relatedItem) { - if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) { - attached.push(relatedItem); - } - }); - if (def.type === 'hasOne' && attached.length) { - set(item, def.localField, attached[0]); - } else { - set(item, def.localField, attached); - } - }); - return relatedItems; - }); - } else if (def.type === 'hasMany' && def.localKeys) { - (function () { - var localKeys = []; - records.forEach(function (item) { - var itemKeys = get(item, def.localKeys) || []; - itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); - localKeys = localKeys.concat(itemKeys); - }); - task = self.findAll(relatedMapper, { - where: _defineProperty({}, relatedMapper.idAttribute, { - 'in': unique(localKeys).filter(function (x) { - return x; - }) - }) - }, __opts).then(function (relatedItems) { - records.forEach(function (item) { - var attached = []; - var itemKeys = get(item, def.localKeys) || []; - itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); - relatedItems.forEach(function (relatedItem) { - if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { - attached.push(relatedItem); - } - }); - set(item, def.localField, attached); - }); - return relatedItems; - }); - })(); - } else if (def.type === 'belongsTo') { - task = self.findAll(relatedMapper, { - where: _defineProperty({}, relatedMapper.idAttribute, { - 'in': records.map(function (item) { - return get(item, def.foreignKey); - }).filter(function (x) { - return x; - }) - }) - }, __opts).then(function (relatedItems) { - records.forEach(function (item) { - relatedItems.forEach(function (relatedItem) { - if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) { - set(item, def.localField, relatedItem); - } - }); - }); - return relatedItems; - }); - } - - if (task) { - tasks.push(task); - } - }); - return Promise.all(tasks); - }).then(function () { - // afterFindAll lifecycle hook - op = opts.op = 'afterFindAll'; - return resolve(self[op](mapper, query, opts, records)).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? records : _records; - return opts.raw ? { - data: records, - found: records.length - } : records; - }); + return resolve([_query.filter(query).run(), {}]); }); }, /** - * TODO + * Apply the given update to the record with the specified primary key. + * Internal method used by Adapter#update. * - * @name LocalStorageAdapter#getPath + * @name LocalStorageAdapter#_update * @method + * @private + * @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. + * @return {Promise} */ - getPath: function getPath(mapper, opts) { - opts = opts || {}; - return makePath(opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, mapper.name); + _update: function _update(mapper, id, props, opts) { + var self = this; + props || (props = {}); + return new Promise(function (resolve, reject) { + var key = self.getIdPath(mapper, opts, id); + var record = self.storage.getItem(key); + if (!record) { + return reject(new Error('Not Found')); + } + record = fromJson(record); + deepMixIn(record, props); + self.storage.setItem(key, toJson(record)); + return resolve([record, {}]); + }); }, /** - * TODO + * Apply the given update to all records that match the selection query. + * Internal method used by Adapter#updateAll. * - * @name LocalStorageAdapter#getIdPath + * @name LocalStorageAdapter#_updateAll * @method + * @private + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} */ - getIdPath: function getIdPath(mapper, opts, id) { - opts = opts || {}; - return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id); + _updateAll: function _updateAll(mapper, props, query, opts) { + var self = this; + var idAttribute = mapper.idAttribute; + return self._findAll(mapper, query, opts).then(function (results) { + var _results2 = _slicedToArray(results, 1); + + var records = _results2[0]; + + records.forEach(function (record) { + record || (record = {}); + var id = get(record, idAttribute); + var key = self.getIdPath(mapper, opts, id); + deepMixIn(record, props); + self.storage.setItem(key, toJson(record)); + }); + return [records, {}]; + }); + }, + + + /** + * Update the given records in a single batch. Internal method used by + * Adapter#updateMany. + * + * @name LocalStorageAdapter#updateMany + * @method + * @private + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _updateMany: function _updateMany(mapper, records, opts) { + var self = this; + records || (records = []); + return new Promise(function (resolve) { + var updatedRecords = []; + var idAttribute = mapper.idAttribute; + records.forEach(function (record) { + if (!record) { + return; + } + var id = get(record, idAttribute); + if (isUndefined(id)) { + return; + } + var key = self.getIdPath(mapper, opts, id); + var json = self.storage.getItem(key); + if (!json) { + return; + } + var existingRecord = fromJson(json); + deepMixIn(existingRecord, record); + self.storage.setItem(key, toJson(existingRecord)); + updatedRecords.push(existingRecord); + }); + return resolve([records, {}]); + }); + }, + create: function create(mapper, props, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.create.call(self, mapper, props, opts).then(success, failure); + }); + }); + }, + createMany: function createMany(mapper, props, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.createMany.call(self, mapper, props, opts).then(success, failure); + }); + }); + }, + destroy: function destroy(mapper, id, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.destroy.call(self, mapper, id, opts).then(success, failure); + }); + }); + }, + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.destroyAll.call(self, mapper, query, opts).then(success, failure); + }); + }); }, /** * TODO * - * @name LocalStorageAdapter#getIds + * @name LocalStorageAdapter#ensureId * @method */ - getIds: function getIds(mapper, opts) { - var ids = undefined; - var idsPath = this.getPath(mapper, opts); - var idsJson = this.storage.getItem(idsPath); - if (idsJson) { - ids = fromJson(idsJson); + ensureId: function ensureId(id, mapper, opts) { + var ids = this.getIds(mapper, opts); + if (isArray(id)) { + if (!id.length) { + return; + } + id.forEach(function (_id) { + ids[_id] = 1; + }); } else { - ids = {}; + ids[id] = 1; } - return ids; + this.saveKeys(ids, mapper, opts); }, /** * TODO * - * @name LocalStorageAdapter#getRaw + * @name LocalStorageAdapter#getPath * @method */ - getRaw: function getRaw(opts) { - opts || (opts = {}); - return !!(isUndefined(opts.raw) ? this.raw : opts.raw); + getPath: function getPath(mapper, opts) { + opts = opts || {}; + return makePath(opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, mapper.name); }, /** * TODO * - * @name LocalStorageAdapter#log + * @name LocalStorageAdapter#getIdPath * @method */ - log: function log(level) { - for (var _len5 = arguments.length, args = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { - args[_key5 - 1] = arguments[_key5]; - } + getIdPath: function getIdPath(mapper, opts, id) { + opts = opts || {}; + return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id); + }, - if (level && !args.length) { - args.push(level); - level = 'debug'; - } - if (level === 'debug' && !this.debug) { - return; - } - var prefix = level.toUpperCase() + ': (LocalStorageAdapter)'; - if (console[level]) { - var _console; - (_console = console)[level].apply(_console, [prefix].concat(args)); + /** + * TODO + * + * @name LocalStorageAdapter#getIds + * @method + */ + getIds: function getIds(mapper, opts) { + var ids = void 0; + var idsPath = this.getPath(mapper, opts); + var idsJson = this.storage.getItem(idsPath); + if (idsJson) { + ids = fromJson(idsJson); } else { - var _console2; - - (_console2 = console).log.apply(_console2, [prefix].concat(args)); + ids = {}; } + return ids; }, @@ -972,190 +638,27 @@ return /******/ (function(modules) { // webpackBootstrap this.storage.removeItem(idsPath); } }, - - - /** - * Update the records that match the selection `query`. If a record with the - * specified primary key cannot be found then no update is performed and the - * promise is resolved with `undefined`. - * - * @name LocalStorageAdapter#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] TODO - * @return {Promise} - */ update: function update(mapper, id, props, opts) { var self = this; - props || (props = {}); - opts || (opts = {}); - return createTask(function (success, failure) { queueTask(function () { - var op = undefined; - // beforeUpdate lifecycle hook - op = opts.op = 'beforeUpdate'; - return resolve(self[op](mapper, id, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = isUndefined(_props) ? props : _props; - var key = self.getIdPath(mapper, opts, id); - var record = self.storage.getItem(key); - record = record ? fromJson(record) : undefined; - - var updated = 0; - - // Update the record - // TODO: Update related records when the "with" option is provided - if (record) { - deepMixIn(record, props); - self.storage.setItem(key, toJson(record)); - updated++; - } else { - throw new Error('Not Found'); - } - - // afterUpdate lifecycle hook - op = opts.op = 'afterUpdate'; - return resolve(self[op](mapper, id, props, opts, record)).then(function (_record) { - // Allow for re-assignment from lifecycle hook - record = isUndefined(_record) ? record : _record; - return opts.raw ? { - data: record, - updated: updated - } : record; - }); - }).then(success, failure); + __super__.update.call(self, mapper, id, props, opts).then(success, failure); }); }); }, - - - /** - * Update the records that match the selection `query`. - * - * @name LocalStorageAdapter#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} [opts] Configuration options. - * @return {Promise} - */ updateAll: function updateAll(mapper, props, query, opts) { var self = this; - props || (props = {}); - query || (query = {}); - opts || (opts = {}); - return createTask(function (success, failure) { queueTask(function () { - var op = undefined; - // beforeUpdateAll lifecycle hook - op = opts.op = 'beforeUpdateAll'; - return resolve(self[op](mapper, props, query, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = isUndefined(_props) ? props : _props; - op = opts.op = 'updateAll'; - self.dbg(op, query, opts); - - // Find the records that are to be updated - return self.findAll(mapper, query, opts); - }).then(function (records) { - var idAttribute = mapper.idAttribute; - var updated = 0; - - // Update each record - // TODO: Update related records when the "with" option is provided - records.forEach(function (record) { - record || (record = {}); - var id = get(record, idAttribute); - var key = self.getIdPath(mapper, opts, id); - deepMixIn(record, props); - self.storage.setItem(key, toJson(record)); - updated++; - }); - - // afterUpdateAll lifecycle hook - op = opts.op = 'afterUpdateAll'; - return self[op](mapper, props, query, opts, records).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? records : _records; - return opts.raw ? { - data: records, - updated: updated - } : records; - }); - }).then(success, failure); + __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure); }); }); }, - - - /** - * Update the given records in a single batch. - * - * @name LocalStorageAdapter#updateMany - * @method - * @param {Object} mapper The mapper. - * @param {Object} records The records to update. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] TODO - * @return {Promise} - */ updateMany: function updateMany(mapper, records, opts) { var self = this; - records || (records = []); - opts || (opts = {}); - return createTask(function (success, failure) { queueTask(function () { - var op = undefined; - var updatedRecords = []; - // beforeUpdateMany lifecycle hook - op = opts.op = 'beforeUpdateMany'; - return resolve(self[op](mapper, records, opts)).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? records : _records; - op = opts.op = 'updateMany'; - self.dbg(op, records, opts); - - var idAttribute = mapper.idAttribute; - - // Update each record - // TODO: Update related records when the "with" option is provided - records.forEach(function (record) { - if (!record) { - return; - } - var id = get(record, idAttribute); - if (isUndefined(id)) { - return; - } - var key = self.getIdPath(mapper, opts, id); - var json = self.storage.getItem(key); - var existingRecord = json ? fromJson(json) : undefined; - if (!existingRecord) { - return; - } - deepMixIn(existingRecord, record); - self.storage.setItem(key, toJson(existingRecord)); - updatedRecords.push(existingRecord); - }); - - // afterUpdateMany lifecycle hook - op = opts.op = 'afterUpdateMany'; - return self[op](mapper, records, opts, updatedRecords).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? updatedRecords : _records; - return opts.raw ? { - data: records, - updated: updatedRecords.length - } : records; - }); - }).then(success, failure); + __super__.updateMany.call(self, mapper, records, opts).then(success, failure); }); }); } @@ -1176,11 +679,11 @@ return /******/ (function(modules) { // webpackBootstrap * otherwise `false` if the current version is not beta. */ LocalStorageAdapter.version = { - full: '3.0.0-alpha.5', + full: '3.0.0-alpha.6', major: parseInt('3', 10), minor: parseInt('0', 10), patch: parseInt('0', 10), - alpha: true ? '5' : false, + alpha: true ? '6' : false, beta: true ? 'false' : false }; @@ -1219,8 +722,1453 @@ return /******/ (function(modules) { // webpackBootstrap /* 2 */ /***/ function(module, exports, __webpack_require__) { - var randHex = __webpack_require__(3); - var choice = __webpack_require__(4); + (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 addHiddenPropsToTarget = jsData.utils.addHiddenPropsToTarget; + var extend = jsData.utils.extend; + var fillIn = jsData.utils.fillIn; + var forEachRelation = jsData.utils.forEachRelation; + var get = jsData.utils.get; + var isArray = jsData.utils.isArray; + var isObject = jsData.utils.isObject; + var isUndefined = jsData.utils.isUndefined; + var omit = jsData.utils.omit; + var plainCopy = jsData.utils.plainCopy; + var resolve = jsData.utils.resolve; + + + 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 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 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 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 = {}); + fillIn(opts, DEFAULTS); + 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; + 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 = extend; + + addHiddenPropsToTarget(Adapter.prototype, { + /** + * 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 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 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 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)); + }, + + + /** + * 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 resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'create'; + self.dbg(op, mapper, props, opts); + return resolve(self._create(mapper, props, 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, 'create'); + response.created = data ? 1 : 0; + response = self.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return 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 resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = isUndefined(_props) ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'createMany'; + self.dbg(op, mapper, props, opts); + return resolve(self._createMany(mapper, props, opts)); + }).then(function (results) { + var _results2 = babelHelpers.slicedToArray(results, 2); + + var data = _results2[0]; + var result = _results2[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 resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return 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 resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + self.dbg(op, mapper, id, opts); + return resolve(self._destroy(mapper, id, opts)); + }).then(function (results) { + var _results3 = babelHelpers.slicedToArray(results, 2); + + var data = _results3[0]; + var result = _results3[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = self.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return 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 resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + self.dbg(op, mapper, query, opts); + return resolve(self._destroyAll(mapper, query, 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, 'destroyAll'); + response = self.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return 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 = get(record, def.localKeys) || []; + itemKeys = 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 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 (isObject(records) && !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 (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 (isObject(records) && !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 = get(item, def.localKeys) || []; + itemKeys = 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 (isObject(records) && !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 = get(record, idAttribute); + relatedItems.forEach(function (relatedItem) { + var foreignKeys = 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 (isObject(records) && !isArray(records)) { + records = [records]; + } + return this.loadHasMany(mapper, def, records, __opts).then(function () { + records.forEach(function (record) { + var relatedData = def.getLocalField(record); + if (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 (isObject(records) && !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 resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + self.dbg(op, mapper, id, opts); + return resolve(self._find(mapper, id, opts)); + }).then(function (results) { + var _results5 = babelHelpers.slicedToArray(results, 1); + + var _record = _results5[0]; + + if (!_record) { + return; + } + record = _record; + var tasks = []; + + 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 resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return 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; + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + self.dbg(op, mapper, query, opts); + return resolve(self._findAll(mapper, query, opts)); + }).then(function (results) { + var _results6 = babelHelpers.slicedToArray(results, 1); + + var _records = _results6[0]; + + _records || (_records = []); + records = _records; + var tasks = []; + 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 resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return 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 isUndefined(opts[opt]) ? plainCopy(this[opt]) : 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)); + } + }, + + + /** + * @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 resolve(self[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = isUndefined(_props) ? props : _props; + op = opts.op = 'update'; + self.dbg(op, mapper, id, props, opts); + return resolve(self._update(mapper, id, props, opts)); + }).then(function (results) { + var _results7 = babelHelpers.slicedToArray(results, 2); + + var data = _results7[0]; + var result = _results7[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 resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return 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 resolve(self[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = isUndefined(_props) ? props : _props; + op = opts.op = 'updateAll'; + self.dbg(op, mapper, props, query, opts); + return resolve(self._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results8 = babelHelpers.slicedToArray(results, 2); + + var data = _results8[0]; + var result = _results8[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 resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return 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 get(record, idAttribute); + }); + + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return resolve(self[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = isUndefined(_records) ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'updateMany'; + self.dbg(op, mapper, records, opts); + return resolve(self._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results9 = babelHelpers.slicedToArray(results, 2); + + var data = _results9[0]; + var result = _results9[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 resolve(self[op](mapper, records, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return isUndefined(_response) ? response : _response; + }); + }); + } + }); + + module.exports = Adapter; + + })); + //# sourceMappingURL=js-data-adapter.js.map + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + var randHex = __webpack_require__(4); + var choice = __webpack_require__(5); /** * Returns pseudo-random guid (UUID v4) @@ -1246,10 +2194,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 3 */ +/* 4 */ /***/ function(module, exports, __webpack_require__) { - var choice = __webpack_require__(4); + var choice = __webpack_require__(5); var _chars = '0123456789abcdef'.split(''); @@ -1271,11 +2219,11 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 4 */ +/* 5 */ /***/ function(module, exports, __webpack_require__) { - var randInt = __webpack_require__(5); - var isArray = __webpack_require__(10); + var randInt = __webpack_require__(6); + var isArray = __webpack_require__(11); /** * Returns a random element from the supplied arguments @@ -1292,12 +2240,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 5 */ +/* 6 */ /***/ function(module, exports, __webpack_require__) { - var MIN_INT = __webpack_require__(6); - var MAX_INT = __webpack_require__(7); - var rand = __webpack_require__(8); + var MIN_INT = __webpack_require__(7); + var MAX_INT = __webpack_require__(8); + var rand = __webpack_require__(9); /** * Gets random integer inside range or snap to min/max values. @@ -1316,7 +2264,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 6 */ +/* 7 */ /***/ function(module, exports) { /** @@ -1328,7 +2276,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 7 */ +/* 8 */ /***/ function(module, exports) { /** @@ -1340,12 +2288,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 8 */ +/* 9 */ /***/ function(module, exports, __webpack_require__) { - var random = __webpack_require__(9); - var MIN_INT = __webpack_require__(6); - var MAX_INT = __webpack_require__(7); + var random = __webpack_require__(10); + var MIN_INT = __webpack_require__(7); + var MAX_INT = __webpack_require__(8); /** * Returns random number inside range @@ -1361,7 +2309,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 9 */ +/* 10 */ /***/ function(module, exports) { @@ -1385,10 +2333,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 10 */ +/* 11 */ /***/ function(module, exports, __webpack_require__) { - var isKind = __webpack_require__(11); + var isKind = __webpack_require__(12); /** */ var isArray = Array.isArray || function (val) { @@ -1399,10 +2347,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 11 */ +/* 12 */ /***/ function(module, exports, __webpack_require__) { - var kindOf = __webpack_require__(12); + var kindOf = __webpack_require__(13); /** * Check if value is from a specific "kind". */ @@ -1414,7 +2362,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 12 */ +/* 13 */ /***/ function(module, exports) { diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index 2e06035..6702202 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap acffac6d0d2bf9a66e1d","webpack:///./src/index.js","webpack:///external {\"amd\":\"js-data\",\"commonjs\":\"js-data\",\"commonjs2\":\"js-data\",\"root\":\"JSData\"}","webpack:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AAC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,oBAAN;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,SAAS,cAAT,EAAyB,EAAzB,CAAP;AACA,UAAO,QAA6B,cAA7B,GAA8C,KAA9C;AACP,SAAM,QAA4B,aAA5B,GAA4C,KAA5C;EANR;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,QAAO,OAAP,GAAiB,mBAAjB,C;;;;;;AC7kCA,gD;;;;;;ACAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 acffac6d0d2bf9a66e1d\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forEachRelation,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n resolve,\n reject,\n set,\n toJson\n} = utils\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}\nfunction unique (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return 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 resolve()\n}\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#returnDeletedIds\n * @type {boolean}\n * @default false\n */\n returnDeletedIds: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n fillIn(this, opts || {})\n fillIn(this, DEFAULTS)\n}\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * @name LocalStorageAdapter#afterCreate\n * @method\n */\n afterCreate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterCreateMany\n * @method\n */\n afterCreateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroy\n * @method\n */\n afterDestroy: noop2,\n\n /**\n * @name LocalStorageAdapter#afterDestroyAll\n * @method\n */\n afterDestroyAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFind\n * @method\n */\n afterFind: noop2,\n\n /**\n * @name LocalStorageAdapter#afterFindAll\n * @method\n */\n afterFindAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdate\n * @method\n */\n afterUpdate: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateAll\n * @method\n */\n afterUpdateAll: noop2,\n\n /**\n * @name LocalStorageAdapter#afterUpdateMany\n * @method\n */\n afterUpdateMany: noop2,\n\n /**\n * @name LocalStorageAdapter#beforeCreate\n * @method\n */\n beforeCreate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeCreateMany\n * @method\n */\n beforeCreateMany: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroy\n * @method\n */\n beforeDestroy: noop,\n\n /**\n * @name LocalStorageAdapter#beforeDestroyAll\n * @method\n */\n beforeDestroyAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFind\n * @method\n */\n beforeFind: noop,\n\n /**\n * @name LocalStorageAdapter#beforeFindAll\n * @method\n */\n beforeFindAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdate\n * @method\n */\n beforeUpdate: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateAll\n * @method\n */\n beforeUpdateAll: noop,\n\n /**\n * @name LocalStorageAdapter#beforeUpdateMany\n * @method\n */\n beforeUpdateMany: noop,\n\n _create (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let record = isUndefined(_props) ? props : _props\n record = self._create(mapper, record, opts)\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return self[op](mapper, props, opts, record).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n created: 1\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Create multiple records in a single batch.\n *\n * @name LocalStorageAdapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Array} props Array of records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n let records = isUndefined(_props) ? props : _props\n records = records.map(function (record) {\n return self._create(mapper, record, opts)\n })\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return self[op](mapper, props, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n created: records.length\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * @name LocalStorageAdapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Destroy the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n opts || (opts = {})\n const returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, id, opts)\n // Destroy the record\n // TODO: Destroy related records when the \"with\" option is provided\n const key = self.getIdPath(mapper, opts, id)\n const recordJson = self.storage.getItem(key)\n let deleted = 0\n if (recordJson) {\n self.storage.removeItem(key)\n self.removeId(id, mapper, opts)\n deleted++\n }\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return resolve(self[op](mapper, id, opts, deleted && returnDeletedIds ? id : undefined)).then(function (_id) {\n // Allow for re-assignment from lifecycle hook\n id = isUndefined(_id) && returnDeletedIds ? id : _id\n const result = {\n data: id,\n deleted\n }\n return self.getRaw(opts) ? result : result.data\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Destroy the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#destroyAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.raw=false] TODO\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n opts || (opts = {})\n const returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, query, opts)\n // Find the records that are to be destroyed\n return self.findAll(mapper, query, { raw: false })\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n let ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n // TODO: Destroy related records when the \"with\" option is provided\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return self[op](mapper, query, opts, returnDeletedIds ? ids : undefined).then(function (_ids) {\n // Allow for re-assignment from lifecycle hook\n ids = isUndefined(_ids) && returnDeletedIds ? ids : _ids\n const result = {\n data: ids,\n deleted: records.length\n }\n return self.getRaw(opts) ? result : result.data\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * Retrieve the record with the given primary key.\n *\n * @name LocalStorageAdapter#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] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, id, opts)\n const key = self.getIdPath(mapper, opts, id)\n record = self.storage.getItem(key)\n if (!record) {\n record = undefined\n return\n }\n record = fromJson(record)\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n [def.foreignKey]: get(record, mapper.idAttribute)\n }, __opts).then(function (relatedItems) {\n if (def.type === 'hasOne' && relatedItems.length) {\n set(record, def.localField, relatedItems[0])\n } else {\n set(record, def.localField, relatedItems)\n }\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n let itemKeys = get(record, def.localKeys) || []\n itemKeys = isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'contains': get(record, mapper.idAttribute)\n }\n }\n }, __opts).then(function (relatedItems) {\n set(record, def.localField, relatedItems)\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) {\n set(record, def.localField, relatedItem)\n return relatedItem\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return resolve(self[op](mapper, id, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n found: record ? 1 : 0\n } : record\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] TODO\n * @param {string[]} [opts.with=[]] TODO\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n let records = []\n let op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, query, opts)\n\n // Load all records into memory...\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const idAttribute = mapper.idAttribute\n // TODO: Verify that this collection gets properly garbage collected\n // TODO: Or, find a way to filter without using Collection\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n records = _query.filter(query).run()\n const tasks = []\n\n forEachRelation(mapper, opts, function (def, __opts) {\n const relatedMapper = def.getRelation()\n let task\n\n if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {\n task = self.findAll(relatedMapper, {\n where: {\n [def.foreignKey]: {\n 'in': records.map(function (item) {\n return get(item, idAttribute)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n relatedItems.forEach(function (relatedItem) {\n if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) {\n attached.push(relatedItem)\n }\n })\n if (def.type === 'hasOne' && attached.length) {\n set(item, def.localField, attached[0])\n } else {\n set(item, def.localField, attached)\n }\n })\n return relatedItems\n })\n } else if (def.type === 'hasMany' && def.localKeys) {\n let localKeys = []\n records.forEach(function (item) {\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n })\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n const attached = []\n let itemKeys = get(item, def.localKeys) || []\n itemKeys = Array.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 set(item, def.localField, attached)\n })\n return relatedItems\n })\n } else if (def.type === 'belongsTo') {\n task = self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': records.map(function (item) {\n return get(item, def.foreignKey)\n }).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) {\n set(item, def.localField, relatedItem)\n }\n })\n })\n return relatedItems\n })\n }\n\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return resolve(self[op](mapper, query, opts, records)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n found: records.length\n } : records\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getRaw\n * @method\n */\n getRaw (opts) {\n opts || (opts = {})\n return !!(isUndefined(opts.raw) ? this.raw : opts.raw)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#log\n * @method\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n /**\n * Update the records that match the selection `query`. If a record with the\n * specified primary key cannot be found then no update is performed and the\n * promise is resolved with `undefined`.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n record = record ? fromJson(record) : undefined\n\n let updated = 0\n\n // Update the record\n // TODO: Update related records when the \"with\" option is provided\n if (record) {\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n } else {\n throw new Error('Not Found')\n }\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return resolve(self[op](mapper, id, props, opts, record)).then(function (_record) {\n // Allow for re-assignment from lifecycle hook\n record = isUndefined(_record) ? record : _record\n return opts.raw ? {\n data: record,\n updated\n } : record\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the records that match the selection `query`.\n *\n * @name LocalStorageAdapter#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} [opts] Configuration options.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props\n op = opts.op = 'updateAll'\n self.dbg(op, query, opts)\n\n // Find the records that are to be updated\n return self.findAll(mapper, query, opts)\n }).then(function (records) {\n const idAttribute = mapper.idAttribute\n let updated = 0\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n updated++\n })\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return self[op](mapper, props, query, opts, records).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n return opts.raw ? {\n data: records,\n updated\n } : records\n })\n }).then(success, failure)\n })\n })\n },\n\n /**\n * Update the given records in a single batch.\n *\n * @name LocalStorageAdapter#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] TODO\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n\n return createTask(function (success, failure) {\n queueTask(function () {\n let op\n let updatedRecords = []\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? records : _records\n op = opts.op = 'updateMany'\n self.dbg(op, records, opts)\n\n const idAttribute = mapper.idAttribute\n\n // Update each record\n // TODO: Update related records when the \"with\" option is provided\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n const existingRecord = json ? fromJson(json) : undefined\n if (!existingRecord) {\n return\n }\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return self[op](mapper, records, opts, updatedRecords).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = isUndefined(_records) ? updatedRecords : _records\n return opts.raw ? {\n data: records,\n updated: updatedRecords.length\n } : records\n })\n }).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 2\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 3\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 4\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 5\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 8\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 9\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 10\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 11\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 12\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 8147363e5b30b5af34ce","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:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;;;;;;ACrCA,KAAM,SAAS,oBAAQ,CAAR,CAAT;AACN,KAAM,UAAU,oBAAQ,CAAR,CAAV;AACN,KAAM,OAAO,oBAAQ,CAAR,CAAP;;KAGJ,QAEE,OAFF;KACA,QACE,OADF;KAIA,yBAYE,MAZF;KACA,YAWE,MAXF;KACA,SAUE,MAVF;KACA,SASE,MATF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A;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,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,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;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;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,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;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,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;;;;;;AC/5CA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 8147363e5b30b5af34ce\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst Adapter = require('js-data-adapter')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n reject,\n set,\n toJson\n} = utils\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}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n const self = this\n opts || (opts = {})\n fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nLocalStorageAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: LocalStorageAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(LocalStorageAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n _createHelper (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record. Internal method used by Adapter#create.\n *\n * @name LocalStorageAdapter#_create\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _create (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n return resolve([self._createHelper(mapper, props, opts), {}])\n })\n },\n\n /**\n * Create multiple records in a single batch. Internal method used by\n * Adapter#createMany.\n *\n * @name LocalStorageAdapter#_createMany\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _createMany (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n props || (props = [])\n return resolve([props.map(function (_props) {\n return self._createHelper(mapper, _props, opts)\n }), {}])\n })\n },\n\n /**\n * Destroy the record with the given primary key. Internal method used by\n * Adapter#destroy.\n *\n * @name LocalStorageAdapter#_destroy\n * @method\n * @private\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 * @return {Promise}\n */\n _destroy (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n return resolve([undefined, {}])\n })\n },\n\n /**\n * Destroy the records that match the selection query. Internal method used by\n * Adapter#destroyAll.\n *\n * @name LocalStorageAdapter#_destroyAll\n * @method\n * @private\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroyAll (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query).then(function (results) {\n let [records] = results\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n const ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n return [undefined, {}]\n })\n },\n\n /**\n * Retrieve the record with the given primary key. Internal method used by\n * Adapter#find.\n *\n * @name LocalStorageAdapter#_find\n * @method\n * @private\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 * @return {Promise}\n */\n _find (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n const key = self.getIdPath(mapper, opts, id)\n const record = self.storage.getItem(key)\n return resolve([record ? fromJson(record) : undefined, {}])\n })\n },\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#findAll.\n *\n * @name LocalStorageAdapter#_findAll\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n return new Promise(function (resolve) {\n // Load all records into memory...\n let records = []\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n return resolve([_query.filter(query).run(), {}])\n })\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n * Internal method used by Adapter#update.\n *\n * @name LocalStorageAdapter#_update\n * @method\n * @private\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 * @return {Promise}\n */\n _update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n return new Promise(function (resolve, reject) {\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n if (!record) {\n return reject(new Error('Not Found'))\n }\n record = fromJson(record)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n return resolve([record, {}])\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Internal method used by Adapter#updateAll.\n *\n * @name LocalStorageAdapter#_updateAll\n * @method\n * @private\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} [opts] Configuration options.\n * @return {Promise}\n */\n _updateAll (mapper, props, query, opts) {\n const self = this\n const idAttribute = mapper.idAttribute\n return self._findAll(mapper, query, opts).then(function (results) {\n let [records] = results\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n })\n return [records, {}]\n })\n },\n\n /**\n * Update the given records in a single batch. Internal method used by\n * Adapter#updateMany.\n *\n * @name LocalStorageAdapter#updateMany\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n return new Promise(function (resolve) {\n const updatedRecords = []\n const idAttribute = mapper.idAttribute\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n if (!json) {\n return\n }\n const existingRecord = fromJson(json)\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n return resolve([records, {}])\n })\n },\n\n create (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.create.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n createMany (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.createMany.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n destroy (mapper, id, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroy.call(self, mapper, id, opts).then(success, failure)\n })\n })\n },\n\n destroyAll (mapper, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroyAll.call(self, mapper, query, opts).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n update (mapper, id, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.update.call(self, mapper, id, props, opts).then(success, failure)\n })\n })\n },\n\n updateAll (mapper, props, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure)\n })\n })\n },\n\n updateMany (mapper, records, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateMany.call(self, mapper, records, opts).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 addHiddenPropsToTarget = jsData.utils.addHiddenPropsToTarget;\n var extend = jsData.utils.extend;\n var fillIn = jsData.utils.fillIn;\n var forEachRelation = jsData.utils.forEachRelation;\n var get = jsData.utils.get;\n var isArray = jsData.utils.isArray;\n var isObject = jsData.utils.isObject;\n var isUndefined = jsData.utils.isUndefined;\n var omit = jsData.utils.omit;\n var plainCopy = jsData.utils.plainCopy;\n var resolve = jsData.utils.resolve;\n\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 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 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 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 fillIn(opts, DEFAULTS);\n 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 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 = extend;\n\n addHiddenPropsToTarget(Adapter.prototype, {\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 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 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 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 * 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 resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'create';\n self.dbg(op, mapper, props, opts);\n return resolve(self._create(mapper, props, 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, '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 resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = 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 resolve(self._createMany(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 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 resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy';\n self.dbg(op, mapper, id, opts);\n return resolve(self._destroy(mapper, id, 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 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 resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll';\n self.dbg(op, mapper, query, opts);\n return resolve(self._destroyAll(mapper, query, 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, 'destroyAll');\n response = self.respond(response, opts);\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll';\n return resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 = get(record, def.localKeys) || [];\n itemKeys = 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 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 (isObject(records) && !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 (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 (isObject(records) && !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 = get(item, def.localKeys) || [];\n itemKeys = 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 (isObject(records) && !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 = get(record, idAttribute);\n relatedItems.forEach(function (relatedItem) {\n var foreignKeys = 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 (isObject(records) && !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 (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 (isObject(records) && !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 resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find';\n self.dbg(op, mapper, id, opts);\n return resolve(self._find(mapper, id, opts));\n }).then(function (results) {\n var _results5 = babelHelpers.slicedToArray(results, 1);\n\n var _record = _results5[0];\n\n if (!_record) {\n return;\n }\n record = _record;\n var tasks = [];\n\n 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 resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll';\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll';\n self.dbg(op, mapper, query, opts);\n return resolve(self._findAll(mapper, query, opts));\n }).then(function (results) {\n var _results6 = babelHelpers.slicedToArray(results, 1);\n\n var _records = _results6[0];\n\n _records || (_records = []);\n records = _records;\n var tasks = [];\n 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 resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 isUndefined(opts[opt]) ? plainCopy(this[opt]) : 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 * @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 resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props;\n op = opts.op = 'update';\n self.dbg(op, mapper, id, props, opts);\n return resolve(self._update(mapper, id, props, opts));\n }).then(function (results) {\n var _results7 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results7[0];\n var result = _results7[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 resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props;\n op = opts.op = 'updateAll';\n self.dbg(op, mapper, props, query, opts);\n return resolve(self._updateAll(mapper, props, 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 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 resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 get(record, idAttribute);\n });\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany';\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = 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 resolve(self._updateMany(mapper, records, 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 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 resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 3\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 4\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 5\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 8\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 9\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 10\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 11\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 12\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 13\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index fc8cd26..73efd81 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -1,11 +1,11 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.5 - Homepage +* @version 3.0.0-alpha.6 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t){return null!=t&&""!==t}function a(t,e){return e||(e=""),t.filter(o).join(e)}function i(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=a(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function u(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n}function f(t){U.push(t)}function c(){U.length&&!O&&(O=!0,U[0]())}function l(t){U.length?f(t):(f(t),c())}function d(t){return new Promise(t).then(function(t){return O=!1,U.shift(),setTimeout(c,0),t},function(t){return O=!1,U.shift(),setTimeout(c,0),j(t)})}function s(t){I(this,t||{}),I(this,S)}var h=n(1),p=n(2),v=h.Query,g=h.utils,y=g.addHiddenPropsToTarget,b=g.deepMixIn,A=g.extend,I=g.fillIn,m=g.forEachRelation,w=g.forOwn,x=g.fromJson,P=g.get,F=g.isArray,M=g.isUndefined,K=g.resolve,j=g.reject,D=g.set,E=g.toJson,U=[],O=!1,C=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),K()},R=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),K()},S={basePath:"",debug:!1,returnDeletedIds:!1,storage:localStorage};s.extend=A,y(s.prototype,{afterCreate:R,afterCreateMany:R,afterDestroy:R,afterDestroyAll:R,afterFind:R,afterFindAll:R,afterUpdate:R,afterUpdateAll:R,afterUpdateMany:R,beforeCreate:C,beforeCreateMany:C,beforeDestroy:C,beforeDestroyAll:C,beforeFind:C,beforeFindAll:C,beforeUpdate:C,beforeUpdateAll:C,beforeUpdateMany:C,_create:function(t,e,n){var r=this,o={},a=t.relationFields||[];w(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=P(o,t.idAttribute)||p();D(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,E(o)),r.ensureId(i,t,n),x(r.storage.getItem(u))},create:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreate",K(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=r._create(t,a,n),i=n.op="afterCreate",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:1}:a})}).then(o,a)})})},createMany:function(t,e,n){var r=this;return e||(e={}),n||(n={}),d(function(o,a){l(function(){var i=void 0;return i=n.op="beforeCreateMany",K(r[i](t,e,n)).then(function(o){var a=M(o)?e:o;return a=a.map(function(e){return r._create(t,e,n)}),i=n.op="afterCreateMany",r[i](t,e,n,a).then(function(t){return a=M(t)?a:t,n.raw?{data:a,created:a.length}:a})}).then(o,a)})})},dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},destroy:function(t,e,n){var r=this;n||(n={});var o=M(n.returnDeletedIds)?r.returnDeletedIds:!!n.returnDeletedIds;return d(function(a,i){l(function(){var u=void 0;return u=n.op="beforeDestroy",K(r[u](t,e,n)).then(function(){u=n.op="destroy",r.dbg(u,e,n);var a=r.getIdPath(t,n,e),i=r.storage.getItem(a),f=0;return i&&(r.storage.removeItem(a),r.removeId(e,t,n),f++),u=n.op="afterDestroy",K(r[u](t,e,n,f&&o?e:void 0)).then(function(t){e=M(t)&&o?e:t;var a={data:e,deleted:f};return r.getRaw(n)?a:a.data})}).then(a,i)})})},destroyAll:function(t,e,n){var r=this;e||(e={}),n||(n={});var o=M(n.returnDeletedIds)?r.returnDeletedIds:!!n.returnDeletedIds;return d(function(a,i){l(function(){var u=void 0;return u=n.op="beforeDestroyAll",K(r[u](t,e,n)).then(function(){return u=n.op="destroyAll",r.dbg(u,e,n),r.findAll(t,e,{raw:!1})}).then(function(a){var i=t.idAttribute,f=a.map(function(t){return P(t,i)});return f.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(f,t,n),u=n.op="afterDestroyAll",r[u](t,e,n,o?f:void 0).then(function(t){f=M(t)&&o?f:t;var e={data:f,deleted:a.length};return r.getRaw(n)?e:e.data})}).then(a,i)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(F(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},find:function(t,e,n){var o=this,a=void 0,i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFind",K(o[i](t,e,n)).then(function(){i=n.op="find",o.dbg(i,e,n);var f=o.getIdPath(t,n,e);if(a=o.storage.getItem(f),!a)return void(a=void 0);a=x(a);var c=[];return m(t,n,function(e,n){var i=e.getRelation(),f=void 0;if("hasOne"!==e.type&&"hasMany"!==e.type||!e.foreignKey)if("hasMany"===e.type&&e.localKeys){var l=[],d=P(a,e.localKeys)||[];d=F(d)?d:Object.keys(d),l=l.concat(d),f=o.findAll(i,{where:r({},i.idAttribute,{in:u(l).filter(function(t){return t})})},n).then(function(t){return D(a,e.localField,t),t})}else"hasMany"===e.type&&e.foreignKeys?f=o.findAll(i,{where:r({},e.foreignKeys,{contains:P(a,t.idAttribute)})},n).then(function(t){return D(a,e.localField,t),t}):"belongsTo"===e.type&&(f=o.find(i,P(a,e.foreignKey),n).then(function(t){return D(a,e.localField,t),t}));else f=o.findAll(i,r({},e.foreignKey,P(a,t.idAttribute)),n).then(function(t){return"hasOne"===e.type&&t.length?D(a,e.localField,t[0]):D(a,e.localField,t),t});f&&c.push(f)}),Promise.all(c)}).then(function(){return i=n.op="afterFind",K(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a?1:0}:a})})},findAll:function(t,e,n){var o=this,a=[],i=void 0;return n||(n={}),n.with||(n.with=[]),i=n.op="beforeFindAll",K(o[i](t,e,n)).then(function(){i=n.op="findAll",o.dbg(i,e,n);var f=o.getIds(t,n);w(f,function(e,r){var i=o.storage.getItem(o.getIdPath(t,n,r));i&&a.push(x(i))});var c=t.idAttribute,l=new v({index:{getAll:function(){return a}}});a=l.filter(e).run();var d=[];return m(t,n,function(t,e){var n=t.getRelation(),i=void 0;"hasOne"!==t.type&&"hasMany"!==t.type||!t.foreignKey?"hasMany"===t.type&&t.localKeys?!function(){var f=[];a.forEach(function(e){var n=P(e,t.localKeys)||[];n=Array.isArray(n)?n:Object.keys(n),f=f.concat(n)}),i=o.findAll(n,{where:r({},n.idAttribute,{in:u(f).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){var o=[],a=P(r,t.localKeys)||[];a=Array.isArray(a)?a:Object.keys(a),e.forEach(function(t){a&&-1!==a.indexOf(t[n.idAttribute])&&o.push(t)}),D(r,t.localField,o)}),e})}():"belongsTo"===t.type&&(i=o.findAll(n,{where:r({},n.idAttribute,{in:a.map(function(e){return P(e,t.foreignKey)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(r){e.forEach(function(e){e[n.idAttribute]===P(r,t.foreignKey)&&D(r,t.localField,e)})}),e})):i=o.findAll(n,{where:r({},t.foreignKey,{in:a.map(function(t){return P(t,c)}).filter(function(t){return t})})},e).then(function(e){return a.forEach(function(n){var r=[];e.forEach(function(e){P(e,t.foreignKey)===P(n,c)&&r.push(e)}),"hasOne"===t.type&&r.length?D(n,t.localField,r[0]):D(n,t.localField,r)}),e}),i&&d.push(i)}),Promise.all(d)}).then(function(){return i=n.op="afterFindAll",K(o[i](t,e,n,a)).then(function(t){return a=M(t)?a:t,n.raw?{data:a,found:a.length}:a})})},getPath:function(t,e){return e=e||{},i(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},i(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?x(o):{}},getRaw:function(t){return t||(t={}),!!(M(t.raw)?this.raw:t.raw)},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (LocalStorageAdapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},removeId:function(t,e,n){var r=this.getIds(e,n);if(F(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,E(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdate",K(o[u](t,e,n,r)).then(function(a){n=M(a)?n:a;var i=o.getIdPath(t,r,e),f=o.storage.getItem(i);f=f?x(f):void 0;var c=0;if(!f)throw new Error("Not Found");return b(f,n),o.storage.setItem(i,E(f)),c++,u=r.op="afterUpdate",K(o[u](t,e,n,r,f)).then(function(t){return f=M(t)?f:t,r.raw?{data:f,updated:c}:f})}).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return e||(e={}),n||(n={}),r||(r={}),d(function(a,i){l(function(){var u=void 0;return u=r.op="beforeUpdateAll",K(o[u](t,e,n,r)).then(function(a){return e=M(a)?e:a,u=r.op="updateAll",o.dbg(u,n,r),o.findAll(t,n,r)}).then(function(a){var i=t.idAttribute,f=0;return a.forEach(function(n){n||(n={});var a=P(n,i),u=o.getIdPath(t,r,a);b(n,e),o.storage.setItem(u,E(n)),f++}),u=r.op="afterUpdateAll",o[u](t,e,n,r,a).then(function(t){return a=M(t)?a:t,r.raw?{data:a,updated:f}:a})}).then(a,i)})})},updateMany:function(t,e,n){var r=this;return e||(e=[]),n||(n={}),d(function(o,a){l(function(){var i=void 0,u=[];return i=n.op="beforeUpdateMany",K(r[i](t,e,n)).then(function(o){e=M(o)?e:o,i=n.op="updateMany",r.dbg(i,e,n);var a=t.idAttribute;return e.forEach(function(e){if(e){var o=P(e,a);if(!M(o)){var i=r.getIdPath(t,n,o),f=r.storage.getItem(i),c=f?x(f):void 0;c&&(b(c,e),r.storage.setItem(i,E(c)),u.push(c))}}}),i=n.op="afterUpdateMany",r[i](t,e,n,u).then(function(t){return e=M(t)?u:t,n.raw?{data:e,updated:u.length}:e})}).then(o,a)})})}}),s.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=s},function(e,n){e.exports=t},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(3),a=n(4);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(4),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(5),a=n(10);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(6),a=n(7),i=n(8);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(9),a=n(6),i=n(7);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(11),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(12);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return null!=t&&""!==t}function o(t,e){return e||(e=""),t.filter(r).join(e)}function a(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=o(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function i(t){H.push(t)}function u(){H.length&&!T&&(T=!0,H[0]())}function f(t){H.length?i(t):(i(t),u())}function c(t){return new Promise(t).then(function(t){return T=!1,H.shift(),setTimeout(u,0),t},function(t){return T=!1,H.shift(),setTimeout(u,0),x(t)})}function s(t){var e=this;t||(t={}),m(t,O),h.call(e,t)}var l=function(){function t(t,e){var n=[],r=!0,o=!1,a=void 0;try{for(var i,u=t[Symbol.iterator]();!(r=(i=u.next()).done)&&(n.push(i.value),!e||n.length!==e);r=!0);}catch(t){o=!0,a=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw a}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=n(1),h=n(2),p=n(3),y=d.Query,v=d.utils,g=v.addHiddenPropsToTarget,b=v.deepMixIn,A=v.extend,m=v.fillIn,M=v.forOwn,w=v.fromJson,P=v.get,I=v.isArray,K=v.isUndefined,x=v.reject,F=v.set,_=v.toJson,H=[],T=!1,j=h.prototype,O={basePath:"",debug:!1,storage:localStorage};s.prototype=Object.create(h.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(s,"__super__",{configurable:!0,value:h}),s.extend=A,g(s.prototype,{_createHelper:function(t,e,n){var r=this,o={},a=t.relationFields||[];M(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=P(o,t.idAttribute)||p();F(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,_(o)),r.ensureId(i,t,n),w(r.storage.getItem(u))},_create:function(t,e,n){var r=this;return new Promise(function(o){return o([r._createHelper(t,e,n),{}])})},_createMany:function(t,e,n){var r=this;return new Promise(function(o){return e||(e=[]),o([e.map(function(e){return r._createHelper(t,e,n)}),{}])})},_destroy:function(t,e,n){var r=this;return new Promise(function(o){return r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),o([void 0,{}])})},_destroyAll:function(t,e,n){var r=this;return r._findAll(t,e).then(function(e){var o=l(e,1),a=o[0],i=t.idAttribute,u=a.map(function(t){return P(t,i)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),[void 0,{}]})},_find:function(t,e,n){var r=this;return new Promise(function(o){var a=r.getIdPath(t,n,e),i=r.storage.getItem(a);return o([i?w(i):void 0,{}])})},_findAll:function(t,e,n){var r=this;return e||(e={}),new Promise(function(o){var a=[],i=r.getIds(t,n);M(i,function(e,o){var i=r.storage.getItem(r.getIdPath(t,n,o));i&&a.push(w(i))});var u=new y({index:{getAll:function(){return a}}});return o([u.filter(e).run(),{}])})},_update:function(t,e,n,r){var o=this;return n||(n={}),new Promise(function(a,i){var u=o.getIdPath(t,r,e),f=o.storage.getItem(u);return f?(f=w(f),b(f,n),o.storage.setItem(u,_(f)),a([f,{}])):i(new Error("Not Found"))})},_updateAll:function(t,e,n,r){var o=this,a=t.idAttribute;return o._findAll(t,n,r).then(function(n){var i=l(n,1),u=i[0];return u.forEach(function(n){n||(n={});var i=P(n,a),u=o.getIdPath(t,r,i);b(n,e),o.storage.setItem(u,_(n))}),[u,{}]})},_updateMany:function(t,e,n){var r=this;return e||(e=[]),new Promise(function(o){var a=[],i=t.idAttribute;return e.forEach(function(e){if(e){var o=P(e,i);if(!K(o)){var u=r.getIdPath(t,n,o),f=r.storage.getItem(u);if(f){var c=w(f);b(c,e),r.storage.setItem(u,_(c)),a.push(c)}}}}),o([e,{}])})},create:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.create.call(r,t,e,n).then(o,a)})})},createMany:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.createMany.call(r,t,e,n).then(o,a)})})},destroy:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.destroy.call(r,t,e,n).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.destroyAll.call(r,t,e,n).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(I(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},getPath:function(t,e){return e=e||{},a(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},a(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?w(o):{}},removeId:function(t,e,n){var r=this.getIds(e,n);if(I(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,_(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return c(function(a,i){f(function(){j.update.call(o,t,e,n,r).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return c(function(a,i){f(function(){j.updateAll.call(o,t,e,n,r).then(a,i)})})},updateMany:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.updateMany.call(r,t,e,n).then(o,a)})})}}),s.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=s},function(e,n){e.exports=t},function(t,e,n){!function(t,e){e(n(1))}(this,function(e){"use strict";function n(t){var e=this;t||(t={}),u(t,m),u(e,t)}function r(t,e,n){var r=this;e||(e={}),r.data=t,u(r,e),r.op=n}var o={};o.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},o.defineProperty=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},o.slicedToArray=function(){function t(t,e){var n=[],r=!0,o=!1,a=void 0;try{for(var i,u=t[Symbol.iterator]();!(r=(i=u.next()).done)&&(n.push(i.value),!e||n.length!==e);r=!0);}catch(t){o=!0,a=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw a}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var a=e.utils.addHiddenPropsToTarget,i=e.utils.extend,u=e.utils.fillIn,f=e.utils.forEachRelation,c=e.utils.get,s=e.utils.isArray,l=e.utils.isObject,d=e.utils.isUndefined,h=e.utils.omit,p=e.utils.plainCopy,y=e.utils.resolve,v=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),y()},g=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),y()},b=function(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n},A=function(t,e){return h(e,t.relationFields||[])},m={debug:!1,raw:!1};n.reserved=["orderBy","sort","limit","offset","skip","where"],n.Response=r,n.extend=i,a(n.prototype,{afterCreate:g,afterCreateMany:g,afterDestroy:g,afterDestroyAll:g,afterFind:g,afterFindAll:g,afterUpdate:g,afterUpdateAll:g,afterUpdateMany:g,beforeCreate:v,beforeCreateMany:v,beforeDestroy:v,beforeDestroyAll:v,beforeFind:v,beforeFindAll:v,beforeUpdate:v,beforeUpdateAll:v,beforeUpdateMany:v,dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},create:function(t,e,n){var a=this,i=void 0;return e||(e={}),n||(n={}),i=n.op="beforeCreate",y(a[i](t,e,n)).then(function(r){return e=d(r)?e:r,e=A(t,e),i=n.op="create",a.dbg(i,t,e,n),y(a._create(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];s||(s={});var l=new r(c,s,"create");return l.created=c?1:0,l=a.respond(l,n),i=n.op="afterCreate",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})},createMany:function(t,e,n){var a=this,i=void 0;return e||(e={}),n||(n={}),i=n.op="beforeCreateMany",y(a[i](t,e,n)).then(function(r){return e=d(r)?e:r,e=e.map(function(e){return A(t,e)}),i=n.op="createMany",a.dbg(i,t,e,n),y(a._createMany(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];c||(c=[]),s||(s={});var l=new r(c,s,"createMany");return l.created=c.length,l=a.respond(l,n),i=n.op="afterCreateMany",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})},destroy:function(t,e,n){var a=this,i=void 0;return n||(n={}),i=n.op="beforeDestroy",y(a[i](t,e,n)).then(function(){return i=n.op="destroy",a.dbg(i,t,e,n),y(a._destroy(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];s||(s={});var l=new r(c,s,"destroy");return l=a.respond(l,n),i=n.op="afterDestroy",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})},destroyAll:function(t,e,n){var a=this,i=void 0;return e||(e={}),n||(n={}),i=n.op="beforeDestroyAll",y(a[i](t,e,n)).then(function(){return i=n.op="destroyAll",a.dbg(i,t,e,n),y(a._destroyAll(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];s||(s={});var l=new r(c,s,"destroyAll");return l=a.respond(l,n),i=n.op="afterDestroyAll",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})},makeHasManyForeignKey:function(t,e,n){return e.getForeignKey(n)},makeHasManyLocalKeys:function(t,e,n){var r=[],o=c(n,e.localKeys)||[];return o=s(o)?o:Object.keys(o),r=r.concat(o),b(r).filter(function(t){return t})},makeHasManyForeignKeys:function(t,e,n){return c(n,t.idAttribute)},loadHasMany:function(t,e,n,r){var o=this,a=!1;l(n)&&!s(n)&&(a=!0,n=[n]);var i=n.map(function(n){return o.makeHasManyForeignKey(t,e,n)}),u={where:{}},f=u.where[e.foreignKey]={};return a?f["=="]=i[0]:f.in=i.filter(function(t){return t}),o.findAll(e.getRelation(),u,r).then(function(r){n.forEach(function(n){var o=[];a?o=r:r.forEach(function(r){c(r,e.foreignKey)===n[t.idAttribute]&&o.push(r)}),e.setLocalField(n,o)})})},loadHasManyLocalKeys:function(t,e,n,r){var a=this,i=void 0,u=e.getRelation();if(l(n)&&!s(n)&&(i=n),i)return a.findAll(u,{where:o.defineProperty({},u.idAttribute,{in:a.makeHasManyLocalKeys(t,e,i)})},r).then(function(t){e.setLocalField(i,t)});var f=function(){var i=[];return n.forEach(function(n){i=i.concat(a.self.makeHasManyLocalKeys(t,e,n))}),{v:a.findAll(u,{where:o.defineProperty({},u.idAttribute,{in:b(i).filter(function(t){return t})})},r).then(function(t){return n.forEach(function(n){var r=[],o=c(n,e.localKeys)||[];o=s(o)?o:Object.keys(o),t.forEach(function(t){o&&-1!==o.indexOf(t[u.idAttribute])&&r.push(t)}),e.setLocalField(n,r)}),t})}}();return"object"===("undefined"==typeof f?"undefined":o.typeof(f))?f.v:void 0},loadHasManyForeignKeys:function(t,e,n,r){var a=this,i=e.getRelation(),u=t.idAttribute,f=void 0;return l(n)&&!s(n)&&(f=n),f?a.findAll(e.getRelation(),{where:o.defineProperty({},e.foreignKeys,{contains:a.makeHasManyForeignKeys(t,e,f)})},r).then(function(t){e.setLocalField(f,t)}):a.findAll(i,{where:o.defineProperty({},e.foreignKeys,{isectNotEmpty:n.map(function(n){return a.makeHasManyForeignKeys(t,e,n)})})},r).then(function(t){var r=e.foreignKeys;n.forEach(function(n){var o=[],a=c(n,u);t.forEach(function(e){var n=c(t,r)||[];-1!==n.indexOf(a)&&o.push(e)}),e.setLocalField(n,o)})})},loadHasOne:function(t,e,n,r){return l(n)&&!s(n)&&(n=[n]),this.loadHasMany(t,e,n,r).then(function(){n.forEach(function(t){var n=e.getLocalField(t);s(n)&&n.length&&e.setLocalField(t,n[0])})})},makeBelongsToForeignKey:function(t,e,n){return e.getForeignKey(n)},loadBelongsTo:function(t,e,n,r){var a=this,i=e.getRelation();if(!l(n)||s(n)){var u=n.map(function(n){return a.makeBelongsToForeignKey(t,e,n)}).filter(function(t){return t});return a.findAll(i,{where:o.defineProperty({},i.idAttribute,{in:u})},r).then(function(t){n.forEach(function(n){t.forEach(function(t){t[i.idAttribute]===n[e.foreignKey]&&e.setLocalField(n,t)})})})}var f=function(){var o=n;return{v:a.find(i,a.makeBelongsToForeignKey(t,e,o),r).then(function(t){e.setLocalField(o,t)})}}();return"object"===("undefined"==typeof f?"undefined":o.typeof(f))?f.v:void 0},find:function(t,e,n){var a=this,i=void 0,u=void 0;return n||(n={}),n.with||(n.with=[]),u=n.op="beforeFind",y(a[u](t,e,n)).then(function(){return u=n.op="find",a.dbg(u,t,e,n),y(a._find(t,e,n))}).then(function(e){var r=o.slicedToArray(e,1),u=r[0];if(u){i=u;var c=[];return f(t,n,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=a.loadHasManyLocalKeys(t,e,i,n):"hasMany"===e.type&&e.foreignKeys?r=a.loadHasManyForeignKeys(t,e,i,n):"belongsTo"===e.type&&(r=a.loadBelongsTo(t,e,i,n)):r="hasOne"===e.type?a.loadHasOne(t,e,i,n):a.loadHasMany(t,e,i,n),r&&c.push(r)}),Promise.all(c)}}).then(function(){var o=new r(i,{},"find");return o.found=i?1:0,o=a.respond(o,n),u=n.op="afterFind",y(a[u](t,e,n,o)).then(function(t){return d(t)?o:t})})},findAll:function(t,e,n){var a=this;n||(n={}),n.with||(n.with=[]);var i=[],u=void 0;return u=n.op="beforeFindAll",y(a[u](t,e,n)).then(function(){return u=n.op="findAll",a.dbg(u,t,e,n),y(a._findAll(t,e,n))}).then(function(e){var r=o.slicedToArray(e,1),u=r[0];u||(u=[]),i=u;var c=[];return f(t,n,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=a.loadHasManyLocalKeys(t,e,i,n):"hasMany"===e.type&&e.foreignKeys?r=a.loadHasManyForeignKeys(t,e,i,n):"belongsTo"===e.type&&(r=a.loadBelongsTo(t,e,i,n)):r="hasMany"===e.type?a.loadHasMany(t,e,i,n):a.loadHasOne(t,e,i,n),r&&c.push(r)}),Promise.all(c)}).then(function(){var o=new r(i,{},"findAll");return o.found=i.length,o=a.respond(o,n),u=n.op="afterFindAll",y(a[u](t,e,n,o)).then(function(t){return d(t)?o:t})})},getOpt:function(t,e){return e||(e={}),p(d(e[t])?this[t]:e[t])},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (Adapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},respond:function(t,e){return this.getOpt("raw",e)?t:t.data},update:function(t,e,n,a){var i=this;n||(n={}),a||(a={});var u=void 0;return u=a.op="beforeUpdate",y(i[u](t,e,n,a)).then(function(r){return n=d(r)?n:r,u=a.op="update",i.dbg(u,t,e,n,a),y(i._update(t,e,n,a))}).then(function(f){var c=o.slicedToArray(f,2),s=c[0],l=c[1];l||(l={});var h=new r(s,l,"update");return h.updated=s?1:0,h=i.respond(h,a),u=a.op="afterUpdate",y(i[u](t,e,n,a,h)).then(function(t){return d(t)?h:t})})},updateAll:function(t,e,n,a){var i=this;e||(e={}),n||(n={}),a||(a={});var u=void 0;return u=a.op="beforeUpdateAll",y(i[u](t,e,n,a)).then(function(r){return e=d(r)?e:r,u=a.op="updateAll",i.dbg(u,t,e,n,a),y(i._updateAll(t,e,n,a))}).then(function(f){var c=o.slicedToArray(f,2),s=c[0],l=c[1];s||(s=[]),l||(l={});var h=new r(s,l,"updateAll");return h.updated=s.length,h=i.respond(h,a),u=a.op="afterUpdateAll",y(i[u](t,e,n,a,h)).then(function(t){return d(t)?h:t})})},updateMany:function(t,e,n){var a=this;e||(e=[]),n||(n={});var i=void 0,u=t.idAttribute;return e=e.filter(function(t){return c(t,u)}),i=n.op="beforeUpdateMany",y(a[i](t,e,n)).then(function(r){return e=d(r)?e:r,e=e.map(function(e){return A(t,e)}),i=n.op="updateMany",a.dbg(i,t,e,n),y(a._updateMany(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];c||(c=[]),s||(s={});var l=new r(c,s,"updateMany");return l.updated=c.length,l=a.respond(l,n),i=n.op="afterUpdateMany",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})}}),t.exports=n})},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(4),a=n(5);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(5),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(6),a=n(11);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(7),a=n(8),i=n(9);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(10),a=n(7),i=n(8);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(12),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(13);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); //# sourceMappingURL=dist/js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index 3835853..b033f9a 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_defineProperty","obj","key","value","Object","defineProperty","enumerable","configurable","writable","isValidString","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","unique","array","seen","final","forEach","item","push","enqueue","task","queue","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","fillIn","DEFAULTS","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forEachRelation","forOwn","fromJson","get","isArray","isUndefined","resolve","set","toJson","noop","self","_len2","_key2","dbg","apply","op","concat","noop2","_len3","_key3","basePath","debug","returnDeletedIds","storage","localStorage","prototype","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_create","mapper","props","_props","relationFields","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","create","success","failure","undefined","record","_record","raw","data","created","createMany","records","map","_records","_len4","_key4","log","destroy","recordJson","deleted","removeItem","removeId","_id","getRaw","destroyAll","query","findAll","ids","_ids","getIds","saveKeys","find","with","tasks","def","__opts","relatedMapper","getRelation","type","foreignKey","localKeys","itemKeys","keys","where","in","x","relatedItems","localField","foreignKeys","contains","relatedItem","all","found","json","_query","index","getAll","run","attached","getPath","name","endpoint","idsPath","idsJson","level","_len5","_key5","prefix","toUpperCase","console","_console","_console2","update","updated","Error","updateAll","updateMany","updatedRecords","existingRecord","version","full","major","parseInt","minor","patch","alpha","beta","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAEA,SAASS,GAAgBC,EAAKC,EAAKC,GAAiK,MAApJD,KAAOD,GAAOG,OAAOC,eAAeJ,EAAKC,GAAOC,MAAOA,EAAOG,YAAY,E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AAUmO,GAMhB,SAASlO,EAAQD,GAUlB,QAASoO,KACL,MAAOA,GAAOzJ,MAIlByJ,EAAOzJ,IAAMsJ,KAAKG,OAElBnO,EAAOD,QAAUoO,GAOhB,SAASnO,EAAQD,EAASQ,GAE/B,GAAI6N,GAAS7N,EAAoB,IAGzBoE,EAAUxC,MAAMwC,SAAW,SAAU0J,GACrC,MAAOD,GAAOC,EAAK,SAEvBrO,GAAOD,QAAU4E,GAMhB,SAAS3E,EAAQD,EAASQ,GAM3B,QAAS6N,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAAShO,EAAoB,GAO7BP,GAAOD,QAAUqO,GAMhB,SAASpO,EAAQD,GAWlB,QAASwO,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAU/N,KAAKyN,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAYvN,OAAO4E,UAAU4I,QAejC5O,GAAOD,QAAUwO","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","enqueue","task","queue","push","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","self","fillIn","DEFAULTS","Adapter","_slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","Symbol","iterator","next","done","isArray","Object","TypeError","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forOwn","fromJson","get","isUndefined","set","toJson","__super__","prototype","basePath","debug","storage","localStorage","create","constructor","enumerable","writable","configurable","defineProperty","_createHelper","mapper","props","_props","relationFields","key","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","_create","resolve","_createMany","map","_destroy","removeItem","removeId","_destroyAll","query","_findAll","results","_results","records","ids","record","forEach","_find","getIds","json","_query","index","getAll","run","_update","Error","_updateAll","_results2","_updateMany","updatedRecords","existingRecord","success","failure","createMany","destroy","destroyAll","_id","saveKeys","getPath","name","endpoint","idsPath","idsJson","keys","update","updateAll","updateMany","version","full","major","parseInt","minor","patch","alpha","beta","global","jsData","Response","data","meta","op","babelHelpers","typeof","obj","slicedToArray","forEachRelation","isObject","omit","plainCopy","noop","dbg","apply","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","raw","reserved","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","log","response","created","respond","_response","_results3","_results4","makeHasManyForeignKey","def","getForeignKey","makeHasManyLocalKeys","localKeys","itemKeys","x","makeHasManyForeignKeys","loadHasMany","__opts","singular","IDs","where","criteria","foreignKey","findAll","getRelation","relatedItems","attached","relatedItem","setLocalField","loadHasManyLocalKeys","relatedMapper","in","_ret","v","loadHasManyForeignKeys","foreignKeys","contains","isectNotEmpty","foreignKeysField","_relatedItems","loadHasOne","relatedData","getLocalField","makeBelongsToForeignKey","loadBelongsTo","relationDef","_ret2","find","with","_results5","_record","tasks","type","all","found","_results6","_records","getOpt","opt","level","_len4","_key4","prefix","toUpperCase","console","_console","_console2","_results7","updated","_results8","_results9","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC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,MAAOA,GAAOxN,MAIlBwN,EAAOxN,IAAMqN,KAAKG,OAElBvS,EAAOD,QAAUwS,GAOhB,SAASvS,EAAQD,EAASQ,GAE/B,GAAIiS,GAASjS,EAAoB,IAGzB4D,EAAUxC,MAAMwC,SAAW,SAAUsO,GACrC,MAAOD,GAAOC,EAAK,SAEvBzS,GAAOD,QAAUoE,GAMhB,SAASnE,EAAQD,EAASQ,GAM3B,QAASiS,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAASpS,EAAoB,GAO7BP,GAAOD,QAAUyS,GAMhB,SAASxS,EAAQD,GAWlB,QAAS4S,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAUnS,KAAK6R,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAY3O,OAAOgB,UAAU4N,QAejChT,GAAOD,QAAU4S","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index b73a990..e4e87e1 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,84 +1,83 @@ +'use strict' + 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)); + 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({ - // base path, that will be used to resolve files and exclude - basePath: './', - frameworks: ['chai', 'mocha'], - plugins: [ - // these plugins will be require() by Karma - 'karma-chai', - 'karma-mocha', - 'karma-phantomjs-launcher', - 'karma-coverage', - 'karma-browserstack-launcher', - 'karma-junit-reporter' - ], - autoWatch: false, - autoWatchBatchDelay: 4000, - browsers: browsers, - - // list of files / patterns to load in the browser - files: [ - 'node_modules/babel-polyfill/dist/polyfill.js', - 'node_modules/js-data/dist/js-data.js', - 'dist/js-data-localstorage.js', - 'karma.prestart.js', - 'node_modules/js-data-adapter-tests/dist/js-data-adapter-tests.js', - 'karma.start.js' - ], - - reporters: ['dots', 'coverage', 'junit'], - - preprocessors: { - 'dist/js-data-localstorage.js': ['coverage'] - }, - - // optionally, configure the reporter - coverageReporter: { - type: 'lcov', - dir: 'coverage/', - instrumenterOptions: { + config.set({ + // base path, that will be used to resolve files and exclude + basePath: './', + frameworks: ['chai', 'mocha', 'sinon'], + plugins: [ + // these plugins will be require() by Karma + 'karma-chai', + 'karma-mocha', + 'karma-sinon', + 'karma-phantomjs-launcher', + 'karma-coverage', + 'karma-browserstack-launcher', + 'karma-junit-reporter' + ], + autoWatch: false, + autoWatchBatchDelay: 4000, + browsers: browsers, + + // list of files / patterns to load in the browser + files: [ + 'node_modules/babel-polyfill/dist/polyfill.js', + 'node_modules/js-data/dist/js-data.js', + 'dist/js-data-localstorage.js', + 'node_modules/js-data-adapter-tests/dist/js-data-adapter-tests.js', + 'karma.start.js' + ], + + reporters: ['dots', 'coverage', 'junit'], + + preprocessors: { + 'dist/js-data-localstorage.js': ['coverage'] + }, + + // optionally, configure the reporter + coverageReporter: { + type: 'lcov', + dir: 'coverage/', + instrumenterOptions: { istanbul: { noCompact: true } } - }, + }, // the default configuration junitReporter: { @@ -88,32 +87,32 @@ module.exports = function (config) { useBrowserName: false }, - browserStack: { - username: process.env.BROWSERSTACK_USERNAME, - accessKey: process.env.BROWSERSTACK_ACCESS_KEY - }, + browserStack: { + username: process.env.BROWSERSTACK_USERNAME, + accessKey: process.env.BROWSERSTACK_ACCESS_KEY + }, - customLaunchers: customLaunchers, + customLaunchers: customLaunchers, - browserNoActivityTimeout: 90000, + browserNoActivityTimeout: 90000, - // web server port - port: 9876, + // web server port + port: 9876, - // cli runner port - runnerPort: 9100, + // cli runner port + runnerPort: 9100, - // enable / disable colors in the output (reporters and logs) - colors: true, + // enable / disable colors in the output (reporters and logs) + colors: true, - // level of logging - logLevel: config.LOG_INFO, + // level of logging + logLevel: config.LOG_INFO, - // If browser does not capture in given timeout [ms], kill it - captureTimeout: 90000, + // If browser does not capture in given timeout [ms], kill it + captureTimeout: 90000, - // Continuous Integration mode - // if true, it capture browsers, run tests and exit - singleRun: true - }); -}; + // Continuous Integration mode + // if true, it capture browsers, run tests and exit + singleRun: true + }) +} diff --git a/karma.prestart.js b/karma.prestart.js deleted file mode 100644 index 692a61b..0000000 --- a/karma.prestart.js +++ /dev/null @@ -1 +0,0 @@ -window.assert = chai.assert diff --git a/karma.start.js b/karma.start.js index 300e215..d0c7cc4 100644 --- a/karma.start.js +++ b/karma.start.js @@ -2,80 +2,18 @@ beforeEach(function () { localStorage.clear() }) -TestRunner.init({ +window.assert = JSDataAdapterTests.assert + +JSDataAdapterTests.init({ debug: false, - features: [ - 'findHasManyLocalKeys', - 'findHasManyForeignKeys' - ], JSData: JSData, Adapter: LocalStorageAdapter, adapterConfig: { debug: false - } -}) - -describe('relation functionality', function () { - // will be available in js-data 3.0.0-alpha.15 - it('nested create', function () { - return this.$$container.create('user', { - name: 'John', - profile: { - email: 'john@test.com' - }, - organization: { - name: 'Company Inc' - }, - posts: [ - { - content: 'foo' - } - ] - }, { with: ['profile', 'post', 'organization'] }).then(function (user) { - assert.isDefined(user) - assert.isDefined(user.id) - assert.isDefined(user.organization) - assert.isDefined(user.organization.id) - assert.equal(user.organizationId, user.organization.id) - assert.isDefined(user.profile) - assert.isDefined(user.profile.id) - assert.isDefined(user.posts) - assert.equal(user.posts.length, 1) - assert.isDefined(user.posts[0].id) - }) - }) - it('nested create many', function () { - return this.$$container.createMany('user', [{ - name: 'John', - profile: { - email: 'john@test.com' - }, - organization: { - name: 'Company Inc' - } - }, { - name: 'Sally', - profile: { - email: 'sally@test.com' - }, - organization: { - name: 'Company Inc' - } - }], { with: ['profile', 'organization'] }).then(function (users) { - assert.isDefined(users[0]) - assert.isDefined(users[0].id) - assert.isDefined(users[0].organization) - assert.isDefined(users[0].organization.id) - assert.equal(users[0].organizationId, users[0].organization.id) - assert.isDefined(users[0].profile) - assert.isDefined(users[0].profile.id) - assert.isDefined(users[1]) - assert.isDefined(users[1].id) - assert.isDefined(users[1].organization) - assert.isDefined(users[1].organization.id) - assert.equal(users[1].organizationId, users[1].organization.id) - assert.isDefined(users[1].profile) - assert.isDefined(users[1].profile.id) - }) - }) + }, + // js-data-localstorage does NOT support these features + xfeatures: [ + 'findAllOpNotFound', + 'filterOnRelations' + ] }) diff --git a/package.json b/package.json index 9fd88b6..7da4061 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", @@ -27,7 +27,7 @@ "beforeEach", "describe", "assert", - "TestRunner", + "JSDataAdapterTests", "it", "JSData", "LocalStorageAdapter" @@ -36,7 +36,7 @@ "scripts": { "bundle": "webpack --config webpack.config.js --colors", "doc": "jsdoc -c conf.json src && node scripts/cleanup.js", - "lint": "standard src/**/*.js karma.start.js", + "lint": "repo-tools lint src/**/*.js karma.start.js karma.conf.js scripts/*.js", "min": "uglifyjs dist/js-data-localstorage.js -o dist/js-data-localstorage.min.js --source-map dist/js-data-localstorage.min.map -v -m -c --screw-ie8", "version": "node scripts/version.js", "banner": "node scripts/banner.js", @@ -45,35 +45,37 @@ "karma": "karma start", "quick": "npm run bundle && npm run karma", "test": "npm run build && npm run karma", - "release": "npm test && npm run doc && node scripts/authors.js", - "ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | coveralls || true && cat ./coverage/PhantomJS*/lcov.info | codacy-coverage || true" + "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/PhantomJS*/lcov.info | coveralls || true" }, - "dependencies": { - "js-data": "^3.0.0-alpha.15" + "peerDependencies": { + "js-data": "^3.0.0-alpha.16" }, "devDependencies": { - "babel-core": "6.5.2", - "babel-eslint": "5.0.0", - "babel-loader": "6.2.3", - "babel-polyfill": "6.5.0", - "babel-preset-es2015": "6.5.0", + "babel-core": "6.7.0", + "babel-loader": "6.2.4", + "babel-polyfill": "6.6.1", + "babel-preset-es2015": "6.6.0", "chai": "3.5.0", - "codacy-coverage": "1.1.3", "coveralls": "2.11.8", - "ink-docstrap": "1.1.2", - "js-data-adapter-tests": "^2.0.0-alpha.7", + "ink-docstrap": "1.1.4", + "js-data-adapter": "0.2.1", + "js-data-adapter-tests": "^2.0.0-alpha.14", + "js-data-repo-tools": "^0.2.0", "jsdoc": "3.4.0", - "karma": "0.13.21", + "karma": "0.13.22", "karma-browserstack-launcher": "0.1.10", "karma-chai": "0.1.0", - "karma-coverage": "0.5.3", + "karma-coverage": "0.5.5", "karma-junit-reporter": "0.3.8", "karma-mocha": "0.2.2", "karma-phantomjs-launcher": "1.0.0", + "karma-sinon": "1.0.4", "mocha": "2.4.5", - "mout": "0.11.1", - "phantomjs-prebuilt": "2.1.4", - "standard": "6.0.7", + "mout": "0.12.0", + "phantomjs-prebuilt": "2.1.5", + "sinon": "1.17.3", "uglify-js": "2.6.2", "webpack": "1.12.14" } diff --git a/scripts/authors.js b/scripts/authors.js index 82a856d..5ba1712 100644 --- a/scripts/authors.js +++ b/scripts/authors.js @@ -1,16 +1,17 @@ var fs = require('fs') var exec = require('child_process').exec +var path = require('path') console.log('Writing AUTHORS file...') -var authorsFile = fs.readFileSync(__dirname + '/AUTHORS', { +var authorsFile = fs.readFileSync(path.join(__dirname, '/AUTHORS'), { encoding: 'utf-8' }) -var contributorsFile = fs.readFileSync(__dirname + '/CONTRIBUTORS', { +var contributorsFile = fs.readFileSync(path.join(__dirname, '/CONTRIBUTORS'), { encoding: 'utf-8' }) -var tty = process.platform === 'win32' ? 'CON' : '/dev/tty'; +var tty = process.platform === 'win32' ? 'CON' : '/dev/tty' exec('git shortlog -s -e < ' + tty, function (err, stdout, stderr) { if (err) { @@ -27,7 +28,7 @@ exec('git shortlog -s -e < ' + tty, function (err, stdout, stderr) { // Add to or otherwise modify "names" if necessary - fs.writeFileSync(__dirname + '/../AUTHORS', authorsFile + names.join('\n'), { + fs.writeFileSync(path.join(__dirname, '/../AUTHORS'), authorsFile + names.join('\n'), { encoding: 'utf-8' }) console.log('Done!') @@ -37,7 +38,7 @@ exec('git shortlog -s -e < ' + tty, function (err, stdout, stderr) { // Add to or otherwise modify "names" if necessary - fs.writeFileSync(__dirname + '/../CONTRIBUTORS', contributorsFile + names.join('\n'), { + fs.writeFileSync(path.join(__dirname, '/../CONTRIBUTORS'), contributorsFile + names.join('\n'), { encoding: 'utf-8' }) console.log('Done!') diff --git a/scripts/banner.js b/scripts/banner.js index e370a02..1c6fd60 100644 --- a/scripts/banner.js +++ b/scripts/banner.js @@ -1,5 +1,5 @@ -var fs = require('fs'); -var pkg = require('../package.json'); +var fs = require('fs') +var pkg = require('../package.json') var banner = '/*!\n' + '* js-data-localstorage\n' + @@ -9,22 +9,22 @@ var banner = '/*!\n' + '* @license MIT \n' + '*\n' + '* @overview localStorage adapter for js-data.\n' + - '*/\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-localstorage.js'); -addBanner('dist/js-data-localstorage.min.js'); +addBanner('dist/js-data-localstorage.js') +addBanner('dist/js-data-localstorage.min.js') -console.log('Done!'); +console.log('Done!') diff --git a/scripts/version.js b/scripts/version.js index 8ead4ba..511e18a 100644 --- a/scripts/version.js +++ b/scripts/version.js @@ -1,41 +1,39 @@ -var fs = require('fs'); -var pkg = require('../package.json'); +var fs = require('fs') +var pkg = require('../package.json') -console.log('Adding version to dist/ files...'); +console.log('Adding version to dist/ files...') -function version(filepath) { +function version (filepath) { var file = fs.readFileSync(filepath, { encoding: 'utf-8' - }); + }) - file = file.replace(/<%= pkg\.version %>/gi, pkg.version); + file = file.replace(/<%= pkg\.version %>/gi, pkg.version) - var parts = pkg.version.split('-'); - var numbers = parts[0].split('.'); + 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]); + 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); + 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); + 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-localstorage.js'); +version('dist/js-data-localstorage.js') -console.log('Done!'); +console.log('Done!') diff --git a/src/index.js b/src/index.js index b74a6d9..fa6de2b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ /* global: localStorage */ const JSData = require('js-data') +const Adapter = require('js-data-adapter') const guid = require('mout/random/guid') const { @@ -12,13 +13,11 @@ const { deepMixIn, extend, fillIn, - forEachRelation, forOwn, fromJson, get, isArray, isUndefined, - resolve, reject, set, toJson @@ -35,18 +34,6 @@ function makePath (...args) { let result = join(args, '/') return result.replace(/([^:\/]|^)\/{2,}/g, '$1/') } -function unique (array) { - const seen = {} - const final = [] - array.forEach(function (item) { - if (item in seen) { - return - } - final.push(item) - seen[item] = 0 - }) - return final -} let queue = [] let taskInProcess = false @@ -84,19 +71,7 @@ function createTask (fn) { }) } -const noop = function (...args) { - const self = this - const opts = args[args.length - 1] - self.dbg(opts.op, ...args) - return resolve() -} - -const noop2 = function (...args) { - const self = this - const opts = args[args.length - 2] - self.dbg(opts.op, ...args) - return resolve() -} +const __super__ = Adapter.prototype const DEFAULTS = { /** @@ -116,15 +91,6 @@ const DEFAULTS = { */ debug: false, - /** - * TODO - * - * @name LocalStorageAdapter#returnDeletedIds - * @type {boolean} - * @default false - */ - returnDeletedIds: false, - /** * TODO * @@ -152,10 +118,27 @@ const DEFAULTS = { * @param {Object} [opts.storeage=localStorage] TODO */ function LocalStorageAdapter (opts) { - fillIn(this, opts || {}) - fillIn(this, DEFAULTS) + const self = this + opts || (opts = {}) + fillIn(opts, DEFAULTS) + Adapter.call(self, opts) } +// Setup prototype inheritance from Adapter +LocalStorageAdapter.prototype = Object.create(Adapter.prototype, { + constructor: { + value: LocalStorageAdapter, + enumerable: false, + writable: true, + configurable: true + } +}) + +Object.defineProperty(LocalStorageAdapter, '__super__', { + configurable: true, + value: Adapter +}) + /** * Alternative to ES6 class syntax for extending `LocalStorageAdapter`. * @@ -170,115 +153,7 @@ function LocalStorageAdapter (opts) { LocalStorageAdapter.extend = extend addHiddenPropsToTarget(LocalStorageAdapter.prototype, { - /** - * @name LocalStorageAdapter#afterCreate - * @method - */ - afterCreate: noop2, - - /** - * @name LocalStorageAdapter#afterCreateMany - * @method - */ - afterCreateMany: noop2, - - /** - * @name LocalStorageAdapter#afterDestroy - * @method - */ - afterDestroy: noop2, - - /** - * @name LocalStorageAdapter#afterDestroyAll - * @method - */ - afterDestroyAll: noop2, - - /** - * @name LocalStorageAdapter#afterFind - * @method - */ - afterFind: noop2, - - /** - * @name LocalStorageAdapter#afterFindAll - * @method - */ - afterFindAll: noop2, - - /** - * @name LocalStorageAdapter#afterUpdate - * @method - */ - afterUpdate: noop2, - - /** - * @name LocalStorageAdapter#afterUpdateAll - * @method - */ - afterUpdateAll: noop2, - - /** - * @name LocalStorageAdapter#afterUpdateMany - * @method - */ - afterUpdateMany: noop2, - - /** - * @name LocalStorageAdapter#beforeCreate - * @method - */ - beforeCreate: noop, - - /** - * @name LocalStorageAdapter#beforeCreateMany - * @method - */ - beforeCreateMany: noop, - - /** - * @name LocalStorageAdapter#beforeDestroy - * @method - */ - beforeDestroy: noop, - - /** - * @name LocalStorageAdapter#beforeDestroyAll - * @method - */ - beforeDestroyAll: noop, - - /** - * @name LocalStorageAdapter#beforeFind - * @method - */ - beforeFind: noop, - - /** - * @name LocalStorageAdapter#beforeFindAll - * @method - */ - beforeFindAll: noop, - - /** - * @name LocalStorageAdapter#beforeUpdate - * @method - */ - beforeUpdate: noop, - - /** - * @name LocalStorageAdapter#beforeUpdateAll - * @method - */ - beforeUpdateAll: noop, - - /** - * @name LocalStorageAdapter#beforeUpdateMany - * @method - */ - beforeUpdateMany: noop, - - _create (mapper, props, opts) { + _createHelper (mapper, props, opts) { const self = this const _props = {} const relationFields = mapper.relationFields || [] @@ -299,465 +174,308 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { }, /** - * Create a new record. + * Create a new record. Internal method used by Adapter#create. * - * @name LocalStorageAdapter#create + * @name LocalStorageAdapter#_create * @method + * @private * @param {Object} mapper The mapper. * @param {Object} props The record to be created. * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] TODO * @return {Promise} */ - create (mapper, props, opts) { + _create (mapper, props, opts) { const self = this - props || (props = {}) - opts || (opts = {}) - - return createTask(function (success, failure) { - queueTask(function () { - let op - // beforeCreate lifecycle hook - op = opts.op = 'beforeCreate' - return resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - let record = isUndefined(_props) ? props : _props - record = self._create(mapper, record, opts) - // afterCreate lifecycle hook - op = opts.op = 'afterCreate' - return self[op](mapper, props, opts, record).then(function (_record) { - // Allow for re-assignment from lifecycle hook - record = isUndefined(_record) ? record : _record - return opts.raw ? { - data: record, - created: 1 - } : record - }) - }).then(success, failure) - }) + return new Promise(function (resolve) { + return resolve([self._createHelper(mapper, props, opts), {}]) }) }, /** - * Create multiple records in a single batch. + * Create multiple records in a single batch. Internal method used by + * Adapter#createMany. * - * @name LocalStorageAdapter#createMany + * @name LocalStorageAdapter#_createMany * @method + * @private * @param {Object} mapper The mapper. - * @param {Array} props Array of records to be created. + * @param {Object} props The records to be created. * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] TODO * @return {Promise} */ - createMany (mapper, props, opts) { + _createMany (mapper, props, opts) { const self = this - props || (props = {}) - opts || (opts = {}) - - return createTask(function (success, failure) { - queueTask(function () { - let op - // beforeCreateMany lifecycle hook - op = opts.op = 'beforeCreateMany' - return resolve(self[op](mapper, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - let records = isUndefined(_props) ? props : _props - records = records.map(function (record) { - return self._create(mapper, record, opts) - }) - // afterCreateMany lifecycle hook - op = opts.op = 'afterCreateMany' - return self[op](mapper, props, opts, records).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? records : _records - return opts.raw ? { - data: records, - created: records.length - } : records - }) - }).then(success, failure) - }) + return new Promise(function (resolve) { + props || (props = []) + return resolve([props.map(function (_props) { + return self._createHelper(mapper, _props, opts) + }), {}]) }) }, /** - * @name LocalStorageAdapter#dbg + * Destroy the record with the given primary key. Internal method used by + * Adapter#destroy. + * + * @name LocalStorageAdapter#_destroy * @method + * @private + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @return {Promise} */ - dbg (...args) { - this.log('debug', ...args) + _destroy (mapper, id, opts) { + const self = this + return new Promise(function (resolve) { + self.storage.removeItem(self.getIdPath(mapper, opts, id)) + self.removeId(id, mapper, opts) + return resolve([undefined, {}]) + }) }, /** - * Destroy the record with the given primary key. + * Destroy the records that match the selection query. Internal method used by + * Adapter#destroyAll. * - * @name LocalStorageAdapter#destroy + * @name LocalStorageAdapter#_destroyAll * @method - * @param {Object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to destroy. + * @private + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] TODO * @return {Promise} */ - destroy (mapper, id, opts) { + _destroyAll (mapper, query, opts) { const self = this - opts || (opts = {}) - const returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds - - return createTask(function (success, failure) { - queueTask(function () { - let op - // beforeDestroy lifecycle hook - op = opts.op = 'beforeDestroy' - return resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'destroy' - self.dbg(op, id, opts) - // Destroy the record - // TODO: Destroy related records when the "with" option is provided - const key = self.getIdPath(mapper, opts, id) - const recordJson = self.storage.getItem(key) - let deleted = 0 - if (recordJson) { - self.storage.removeItem(key) - self.removeId(id, mapper, opts) - deleted++ - } - - // afterDestroy lifecycle hook - op = opts.op = 'afterDestroy' - return resolve(self[op](mapper, id, opts, deleted && returnDeletedIds ? id : undefined)).then(function (_id) { - // Allow for re-assignment from lifecycle hook - id = isUndefined(_id) && returnDeletedIds ? id : _id - const result = { - data: id, - deleted - } - return self.getRaw(opts) ? result : result.data - }) - }).then(success, failure) + return self._findAll(mapper, query).then(function (results) { + let [records] = results + const idAttribute = mapper.idAttribute + // Gather IDs of records to be destroyed + const ids = records.map(function (record) { + return get(record, idAttribute) + }) + // Destroy each record + ids.forEach(function (id) { + self.storage.removeItem(self.getIdPath(mapper, opts, id)) }) + self.removeId(ids, mapper, opts) + return [undefined, {}] }) }, /** - * Destroy the records that match the selection `query`. + * Retrieve the record with the given primary key. Internal method used by + * Adapter#find. * - * @name LocalStorageAdapter#destroyAll + * @name LocalStorageAdapter#_find * @method + * @private * @param {Object} mapper The mapper. - * @param {Object} query Selection query. - * @param {Object} [opts] Configuration opts. - * @param {boolean} [opts.raw=false] TODO + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. * @return {Promise} */ - destroyAll (mapper, query, opts) { + _find (mapper, id, opts) { const self = this - query || (query = {}) - opts || (opts = {}) - const returnDeletedIds = isUndefined(opts.returnDeletedIds) ? self.returnDeletedIds : !!opts.returnDeletedIds - - return createTask(function (success, failure) { - queueTask(function () { - let op - // beforeDestroyAll lifecycle hook - op = opts.op = 'beforeDestroyAll' - return resolve(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'destroyAll' - self.dbg(op, query, opts) - // Find the records that are to be destroyed - return self.findAll(mapper, query, { raw: false }) - }).then(function (records) { - const idAttribute = mapper.idAttribute - // Gather IDs of records to be destroyed - let ids = records.map(function (record) { - return get(record, idAttribute) - }) - // Destroy each record - // TODO: Destroy related records when the "with" option is provided - ids.forEach(function (id) { - self.storage.removeItem(self.getIdPath(mapper, opts, id)) - }) - self.removeId(ids, mapper, opts) - - // afterDestroyAll lifecycle hook - op = opts.op = 'afterDestroyAll' - return self[op](mapper, query, opts, returnDeletedIds ? ids : undefined).then(function (_ids) { - // Allow for re-assignment from lifecycle hook - ids = isUndefined(_ids) && returnDeletedIds ? ids : _ids - const result = { - data: ids, - deleted: records.length - } - return self.getRaw(opts) ? result : result.data - }) - }).then(success, failure) - }) + return new Promise(function (resolve) { + const key = self.getIdPath(mapper, opts, id) + const record = self.storage.getItem(key) + return resolve([record ? fromJson(record) : undefined, {}]) }) }, /** - * TODO + * Retrieve the records that match the selection query. Internal method used + * by Adapter#findAll. * - * @name LocalStorageAdapter#ensureId + * @name LocalStorageAdapter#_findAll * @method + * @private + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} */ - ensureId (id, mapper, opts) { - const ids = this.getIds(mapper, opts) - if (isArray(id)) { - if (!id.length) { - return - } - id.forEach(function (_id) { - ids[_id] = 1 + _findAll (mapper, query, opts) { + const self = this + query || (query = {}) + return new Promise(function (resolve) { + // Load all records into memory... + let records = [] + const ids = self.getIds(mapper, opts) + forOwn(ids, function (value, id) { + const json = self.storage.getItem(self.getIdPath(mapper, opts, id)) + if (json) { + records.push(fromJson(json)) + } }) - } else { - ids[id] = 1 - } - this.saveKeys(ids, mapper, opts) + const _query = new Query({ + index: { + getAll () { + return records + } + } + }) + return resolve([_query.filter(query).run(), {}]) + }) }, /** - * Retrieve the record with the given primary key. + * Apply the given update to the record with the specified primary key. + * Internal method used by Adapter#update. * - * @name LocalStorageAdapter#find + * @name LocalStorageAdapter#_update * @method + * @private * @param {Object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to retrieve. + * @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] TODO - * @param {string[]} [opts.with=[]] TODO * @return {Promise} */ - find (mapper, id, opts) { + _update (mapper, id, props, opts) { const self = this - let record, op - opts || (opts = {}) - opts.with || (opts.with = []) - - // beforeFind lifecycle hook - op = opts.op = 'beforeFind' - return resolve(self[op](mapper, id, opts)).then(function () { - op = opts.op = 'find' - self.dbg(op, id, opts) + props || (props = {}) + return new Promise(function (resolve, reject) { const key = self.getIdPath(mapper, opts, id) - record = self.storage.getItem(key) + let record = self.storage.getItem(key) if (!record) { - record = undefined - return + return reject(new Error('Not Found')) } record = fromJson(record) - const tasks = [] - - forEachRelation(mapper, opts, function (def, __opts) { - const relatedMapper = def.getRelation() - let task - - if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { - task = self.findAll(relatedMapper, { - [def.foreignKey]: get(record, mapper.idAttribute) - }, __opts).then(function (relatedItems) { - if (def.type === 'hasOne' && relatedItems.length) { - set(record, def.localField, relatedItems[0]) - } else { - set(record, def.localField, relatedItems) - } - return relatedItems - }) - } else if (def.type === 'hasMany' && def.localKeys) { - let localKeys = [] - let itemKeys = get(record, def.localKeys) || [] - itemKeys = isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) - localKeys = localKeys.concat(itemKeys) - task = self.findAll(relatedMapper, { - where: { - [relatedMapper.idAttribute]: { - 'in': unique(localKeys).filter(function (x) { return x }) - } - } - }, __opts).then(function (relatedItems) { - set(record, def.localField, relatedItems) - return relatedItems - }) - } else if (def.type === 'hasMany' && def.foreignKeys) { - task = self.findAll(relatedMapper, { - where: { - [def.foreignKeys]: { - 'contains': get(record, mapper.idAttribute) - } - } - }, __opts).then(function (relatedItems) { - set(record, def.localField, relatedItems) - return relatedItems - }) - } else if (def.type === 'belongsTo') { - task = self.find(relatedMapper, get(record, def.foreignKey), __opts).then(function (relatedItem) { - set(record, def.localField, relatedItem) - return relatedItem - }) - } - - if (task) { - tasks.push(task) - } - }) + deepMixIn(record, props) + self.storage.setItem(key, toJson(record)) + return resolve([record, {}]) + }) + }, - return Promise.all(tasks) - }).then(function () { - // afterFind lifecycle hook - op = opts.op = 'afterFind' - return resolve(self[op](mapper, id, opts, record)).then(function (_record) { - // Allow for re-assignment from lifecycle hook - record = isUndefined(_record) ? record : _record - return opts.raw ? { - data: record, - found: record ? 1 : 0 - } : record + /** + * Apply the given update to all records that match the selection query. + * Internal method used by Adapter#updateAll. + * + * @name LocalStorageAdapter#_updateAll + * @method + * @private + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _updateAll (mapper, props, query, opts) { + const self = this + const idAttribute = mapper.idAttribute + return self._findAll(mapper, query, opts).then(function (results) { + let [records] = results + records.forEach(function (record) { + record || (record = {}) + const id = get(record, idAttribute) + const key = self.getIdPath(mapper, opts, id) + deepMixIn(record, props) + self.storage.setItem(key, toJson(record)) }) + return [records, {}] }) }, /** - * Retrieve the records that match the selection `query`. + * Update the given records in a single batch. Internal method used by + * Adapter#updateMany. * - * @name LocalStorageAdapter#findAll + * @name LocalStorageAdapter#updateMany * @method + * @private * @param {Object} mapper The mapper. - * @param {Object} query Selection query. + * @param {Object[]} records The records to update. * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] TODO - * @param {string[]} [opts.with=[]] TODO * @return {Promise} */ - findAll (mapper, query, opts) { + _updateMany (mapper, records, opts) { const self = this - let records = [] - let op - opts || (opts = {}) - opts.with || (opts.with = []) - - // beforeFindAll lifecycle hook - op = opts.op = 'beforeFindAll' - return resolve(self[op](mapper, query, opts)).then(function () { - op = opts.op = 'findAll' - self.dbg(op, query, opts) - - // Load all records into memory... - const ids = self.getIds(mapper, opts) - forOwn(ids, function (value, id) { - const json = self.storage.getItem(self.getIdPath(mapper, opts, id)) - if (json) { - records.push(fromJson(json)) - } - }) + records || (records = []) + return new Promise(function (resolve) { + const updatedRecords = [] const idAttribute = mapper.idAttribute - // TODO: Verify that this collection gets properly garbage collected - // TODO: Or, find a way to filter without using Collection - const _query = new Query({ - index: { - getAll () { - return records - } + records.forEach(function (record) { + if (!record) { + return + } + const id = get(record, idAttribute) + if (isUndefined(id)) { + return + } + const key = self.getIdPath(mapper, opts, id) + let json = self.storage.getItem(key) + if (!json) { + return } + const existingRecord = fromJson(json) + deepMixIn(existingRecord, record) + self.storage.setItem(key, toJson(existingRecord)) + updatedRecords.push(existingRecord) }) - records = _query.filter(query).run() - const tasks = [] + return resolve([records, {}]) + }) + }, - forEachRelation(mapper, opts, function (def, __opts) { - const relatedMapper = def.getRelation() - let task + create (mapper, props, opts) { + const self = this + return createTask(function (success, failure) { + queueTask(function () { + __super__.create.call(self, mapper, props, opts).then(success, failure) + }) + }) + }, - if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) { - task = self.findAll(relatedMapper, { - where: { - [def.foreignKey]: { - 'in': records.map(function (item) { - return get(item, idAttribute) - }).filter(function (x) { return x }) - } - } - }, __opts).then(function (relatedItems) { - records.forEach(function (item) { - const attached = [] - relatedItems.forEach(function (relatedItem) { - if (get(relatedItem, def.foreignKey) === get(item, idAttribute)) { - attached.push(relatedItem) - } - }) - if (def.type === 'hasOne' && attached.length) { - set(item, def.localField, attached[0]) - } else { - set(item, def.localField, attached) - } - }) - return relatedItems - }) - } else if (def.type === 'hasMany' && def.localKeys) { - let localKeys = [] - records.forEach(function (item) { - let itemKeys = get(item, def.localKeys) || [] - itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) - localKeys = localKeys.concat(itemKeys) - }) - task = self.findAll(relatedMapper, { - where: { - [relatedMapper.idAttribute]: { - 'in': unique(localKeys).filter(function (x) { return x }) - } - } - }, __opts).then(function (relatedItems) { - records.forEach(function (item) { - const attached = [] - let itemKeys = get(item, def.localKeys) || [] - itemKeys = Array.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys) - relatedItems.forEach(function (relatedItem) { - if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { - attached.push(relatedItem) - } - }) - set(item, def.localField, attached) - }) - return relatedItems - }) - } else if (def.type === 'belongsTo') { - task = self.findAll(relatedMapper, { - where: { - [relatedMapper.idAttribute]: { - 'in': records.map(function (item) { - return get(item, def.foreignKey) - }).filter(function (x) { return x }) - } - } - }, __opts).then(function (relatedItems) { - records.forEach(function (item) { - relatedItems.forEach(function (relatedItem) { - if (relatedItem[relatedMapper.idAttribute] === get(item, def.foreignKey)) { - set(item, def.localField, relatedItem) - } - }) - }) - return relatedItems - }) - } + createMany (mapper, props, opts) { + const self = this + return createTask(function (success, failure) { + queueTask(function () { + __super__.createMany.call(self, mapper, props, opts).then(success, failure) + }) + }) + }, - if (task) { - tasks.push(task) - } + destroy (mapper, id, opts) { + const self = this + return createTask(function (success, failure) { + queueTask(function () { + __super__.destroy.call(self, mapper, id, opts).then(success, failure) }) - return Promise.all(tasks) - }).then(function () { - // afterFindAll lifecycle hook - op = opts.op = 'afterFindAll' - return resolve(self[op](mapper, query, opts, records)).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? records : _records - return opts.raw ? { - data: records, - found: records.length - } : records + }) + }, + + destroyAll (mapper, query, opts) { + const self = this + return createTask(function (success, failure) { + queueTask(function () { + __super__.destroyAll.call(self, mapper, query, opts).then(success, failure) }) }) }, + /** + * TODO + * + * @name LocalStorageAdapter#ensureId + * @method + */ + ensureId (id, mapper, opts) { + const ids = this.getIds(mapper, opts) + if (isArray(id)) { + if (!id.length) { + return + } + id.forEach(function (_id) { + ids[_id] = 1 + }) + } else { + ids[id] = 1 + } + this.saveKeys(ids, mapper, opts) + }, + /** * TODO * @@ -798,39 +516,6 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { return ids }, - /** - * TODO - * - * @name LocalStorageAdapter#getRaw - * @method - */ - getRaw (opts) { - opts || (opts = {}) - return !!(isUndefined(opts.raw) ? this.raw : opts.raw) - }, - - /** - * TODO - * - * @name LocalStorageAdapter#log - * @method - */ - log (level, ...args) { - if (level && !args.length) { - args.push(level) - level = 'debug' - } - if (level === 'debug' && !this.debug) { - return - } - const prefix = `${level.toUpperCase()}: (LocalStorageAdapter)` - if (console[level]) { - console[level](prefix, ...args) - } else { - console.log(prefix, ...args) - } - }, - /** * TODO * @@ -868,186 +553,29 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { } }, - /** - * Update the records that match the selection `query`. If a record with the - * specified primary key cannot be found then no update is performed and the - * promise is resolved with `undefined`. - * - * @name LocalStorageAdapter#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] TODO - * @return {Promise} - */ update (mapper, id, props, opts) { const self = this - props || (props = {}) - opts || (opts = {}) - return createTask(function (success, failure) { queueTask(function () { - let op - // beforeUpdate lifecycle hook - op = opts.op = 'beforeUpdate' - return resolve(self[op](mapper, id, props, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = isUndefined(_props) ? props : _props - const key = self.getIdPath(mapper, opts, id) - let record = self.storage.getItem(key) - record = record ? fromJson(record) : undefined - - let updated = 0 - - // Update the record - // TODO: Update related records when the "with" option is provided - if (record) { - deepMixIn(record, props) - self.storage.setItem(key, toJson(record)) - updated++ - } else { - throw new Error('Not Found') - } - - // afterUpdate lifecycle hook - op = opts.op = 'afterUpdate' - return resolve(self[op](mapper, id, props, opts, record)).then(function (_record) { - // Allow for re-assignment from lifecycle hook - record = isUndefined(_record) ? record : _record - return opts.raw ? { - data: record, - updated - } : record - }) - }).then(success, failure) + __super__.update.call(self, mapper, id, props, opts).then(success, failure) }) }) }, - /** - * Update the records that match the selection `query`. - * - * @name LocalStorageAdapter#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} [opts] Configuration options. - * @return {Promise} - */ updateAll (mapper, props, query, opts) { const self = this - props || (props = {}) - query || (query = {}) - opts || (opts = {}) - return createTask(function (success, failure) { queueTask(function () { - let op - // beforeUpdateAll lifecycle hook - op = opts.op = 'beforeUpdateAll' - return resolve(self[op](mapper, props, query, opts)).then(function (_props) { - // Allow for re-assignment from lifecycle hook - props = isUndefined(_props) ? props : _props - op = opts.op = 'updateAll' - self.dbg(op, query, opts) - - // Find the records that are to be updated - return self.findAll(mapper, query, opts) - }).then(function (records) { - const idAttribute = mapper.idAttribute - let updated = 0 - - // Update each record - // TODO: Update related records when the "with" option is provided - records.forEach(function (record) { - record || (record = {}) - const id = get(record, idAttribute) - const key = self.getIdPath(mapper, opts, id) - deepMixIn(record, props) - self.storage.setItem(key, toJson(record)) - updated++ - }) - - // afterUpdateAll lifecycle hook - op = opts.op = 'afterUpdateAll' - return self[op](mapper, props, query, opts, records).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? records : _records - return opts.raw ? { - data: records, - updated - } : records - }) - }).then(success, failure) + __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure) }) }) }, - /** - * Update the given records in a single batch. - * - * @name LocalStorageAdapter#updateMany - * @method - * @param {Object} mapper The mapper. - * @param {Object} records The records to update. - * @param {Object} [opts] Configuration options. - * @param {boolean} [opts.raw=false] TODO - * @return {Promise} - */ updateMany (mapper, records, opts) { const self = this - records || (records = []) - opts || (opts = {}) - return createTask(function (success, failure) { queueTask(function () { - let op - let updatedRecords = [] - // beforeUpdateMany lifecycle hook - op = opts.op = 'beforeUpdateMany' - return resolve(self[op](mapper, records, opts)).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? records : _records - op = opts.op = 'updateMany' - self.dbg(op, records, opts) - - const idAttribute = mapper.idAttribute - - // Update each record - // TODO: Update related records when the "with" option is provided - records.forEach(function (record) { - if (!record) { - return - } - const id = get(record, idAttribute) - if (isUndefined(id)) { - return - } - const key = self.getIdPath(mapper, opts, id) - let json = self.storage.getItem(key) - const existingRecord = json ? fromJson(json) : undefined - if (!existingRecord) { - return - } - deepMixIn(existingRecord, record) - self.storage.setItem(key, toJson(existingRecord)) - updatedRecords.push(existingRecord) - }) - - // afterUpdateMany lifecycle hook - op = opts.op = 'afterUpdateMany' - return self[op](mapper, records, opts, updatedRecords).then(function (_records) { - // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? updatedRecords : _records - return opts.raw ? { - data: records, - updated: updatedRecords.length - } : records - }) - }).then(success, failure) + __super__.updateMany.call(self, mapper, records, opts).then(success, failure) }) }) } From e47e7d37df3afaebb0643442dd395eaeaef593b8 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Fri, 18 Mar 2016 08:28:13 -0700 Subject: [PATCH 11/15] 3.0.0-alpha.7 --- CHANGELOG.md | 5 + dist/js-data-localstorage.js | 519 +++++++++++++++++++++--------- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 6 +- dist/js-data-localstorage.min.map | 2 +- karma.conf.js | 37 +-- package.json | 17 +- src/index.js | 117 ++++--- 8 files changed, 465 insertions(+), 240 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76a36c8..0fceaf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +##### 3.0.0-alpha.7 - 18 March 2016 + +###### Backwards compatible API changes +- Added count and sum methods + ##### 3.0.0-alpha.6 - 10 March 2016 ###### Other diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index b0a3122..5fc5839 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1,6 +1,6 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.6 - Homepage +* @version 3.0.0-alpha.7 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT @@ -74,18 +74,6 @@ return /******/ (function(modules) { // webpackBootstrap var Query = JSData.Query; var utils = JSData.utils; - var addHiddenPropsToTarget = utils.addHiddenPropsToTarget; - var deepMixIn = utils.deepMixIn; - var extend = utils.extend; - var fillIn = utils.fillIn; - var forOwn = utils.forOwn; - var fromJson = utils.fromJson; - var get = utils.get; - var isArray = utils.isArray; - var isUndefined = utils.isUndefined; - var reject = utils.reject; - var set = utils.set; - var toJson = utils.toJson; function isValidString(value) { @@ -136,7 +124,7 @@ return /******/ (function(modules) { // webpackBootstrap taskInProcess = false; queue.shift(); setTimeout(dequeue, 0); - return reject(err); + return utils.reject(err); }); } @@ -188,8 +176,9 @@ return /******/ (function(modules) { // webpackBootstrap */ function LocalStorageAdapter(opts) { var self = this; + utils.classCallCheck(self, LocalStorageAdapter); opts || (opts = {}); - fillIn(opts, DEFAULTS); + utils.fillIn(opts, DEFAULTS); Adapter.call(self, opts); } @@ -219,27 +208,47 @@ return /******/ (function(modules) { // webpackBootstrap * properties to the subclass itself. * @return {Object} Subclass of `LocalStorageAdapter`. */ - LocalStorageAdapter.extend = extend; + LocalStorageAdapter.extend = utils.extend; - addHiddenPropsToTarget(LocalStorageAdapter.prototype, { + utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { + /** + * Retrieve the number of records that match the selection query. Internal + * method used by Adapter#count. + * + * @name LocalStorageAdapter#_count + * @method + * @private + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + + _count: function _count(mapper, query, opts) { + var self = this; + return self._findAll(mapper, query, opts).then(function (result) { + result[0] = result[0].length; + return result; + }); + }, _createHelper: function _createHelper(mapper, props, opts) { var self = this; var _props = {}; var relationFields = mapper.relationFields || []; - forOwn(props, function (value, key) { + utils.forOwn(props, function (value, key) { if (relationFields.indexOf(key) === -1) { _props[key] = value; } }); - var id = get(_props, mapper.idAttribute) || guid(); - set(_props, mapper.idAttribute, id); + var id = utils.get(_props, mapper.idAttribute) || guid(); + utils.set(_props, mapper.idAttribute, id); var key = self.getIdPath(mapper, opts, id); // Create the record // TODO: Create related records when the "with" option is provided - self.storage.setItem(key, toJson(_props)); + self.storage.setItem(key, utils.toJson(_props)); self.ensureId(id, mapper, opts); - return fromJson(self.storage.getItem(key)); + return utils.fromJson(self.storage.getItem(key)); }, @@ -329,7 +338,7 @@ return /******/ (function(modules) { // webpackBootstrap var idAttribute = mapper.idAttribute; // Gather IDs of records to be destroyed var ids = records.map(function (record) { - return get(record, idAttribute); + return utils.get(record, idAttribute); }); // Destroy each record ids.forEach(function (id) { @@ -358,7 +367,7 @@ return /******/ (function(modules) { // webpackBootstrap return new Promise(function (resolve) { var key = self.getIdPath(mapper, opts, id); var record = self.storage.getItem(key); - return resolve([record ? fromJson(record) : undefined, {}]); + return resolve([record ? utils.fromJson(record) : undefined, {}]); }); }, @@ -382,10 +391,10 @@ return /******/ (function(modules) { // webpackBootstrap // Load all records into memory... var records = []; var ids = self.getIds(mapper, opts); - forOwn(ids, function (value, id) { + utils.forOwn(ids, function (value, id) { var json = self.storage.getItem(self.getIdPath(mapper, opts, id)); if (json) { - records.push(fromJson(json)); + records.push(utils.fromJson(json)); } }); var _query = new Query({ @@ -400,6 +409,32 @@ return /******/ (function(modules) { // webpackBootstrap }, + /** + * Retrieve the number of records that match the selection query. Internal + * method used by Adapter#sum. + * + * @name LocalStorageAdapter#_sum + * @method + * @private + * @param {Object} mapper The mapper. + * @param {string} field The field to sum. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _sum: function _sum(mapper, field, query, opts) { + var self = this; + return self._findAll(mapper, query, opts).then(function (result) { + var sum = 0; + result[0].forEach(function (record) { + sum += utils.get(record, field) || 0; + }); + result[0] = sum; + return result; + }); + }, + + /** * Apply the given update to the record with the specified primary key. * Internal method used by Adapter#update. @@ -422,9 +457,9 @@ return /******/ (function(modules) { // webpackBootstrap if (!record) { return reject(new Error('Not Found')); } - record = fromJson(record); - deepMixIn(record, props); - self.storage.setItem(key, toJson(record)); + record = utils.fromJson(record); + utils.deepMixIn(record, props); + self.storage.setItem(key, utils.toJson(record)); return resolve([record, {}]); }); }, @@ -453,10 +488,10 @@ return /******/ (function(modules) { // webpackBootstrap records.forEach(function (record) { record || (record = {}); - var id = get(record, idAttribute); + var id = utils.get(record, idAttribute); var key = self.getIdPath(mapper, opts, id); - deepMixIn(record, props); - self.storage.setItem(key, toJson(record)); + utils.deepMixIn(record, props); + self.storage.setItem(key, utils.toJson(record)); }); return [records, {}]; }); @@ -485,8 +520,8 @@ return /******/ (function(modules) { // webpackBootstrap if (!record) { return; } - var id = get(record, idAttribute); - if (isUndefined(id)) { + var id = utils.get(record, idAttribute); + if (utils.isUndefined(id)) { return; } var key = self.getIdPath(mapper, opts, id); @@ -494,9 +529,9 @@ return /******/ (function(modules) { // webpackBootstrap if (!json) { return; } - var existingRecord = fromJson(json); - deepMixIn(existingRecord, record); - self.storage.setItem(key, toJson(existingRecord)); + var existingRecord = utils.fromJson(json); + utils.deepMixIn(existingRecord, record); + self.storage.setItem(key, utils.toJson(existingRecord)); updatedRecords.push(existingRecord); }); return resolve([records, {}]); @@ -544,7 +579,7 @@ return /******/ (function(modules) { // webpackBootstrap */ ensureId: function ensureId(id, mapper, opts) { var ids = this.getIds(mapper, opts); - if (isArray(id)) { + if (utils.isArray(id)) { if (!id.length) { return; } @@ -593,7 +628,7 @@ return /******/ (function(modules) { // webpackBootstrap var idsPath = this.getPath(mapper, opts); var idsJson = this.storage.getItem(idsPath); if (idsJson) { - ids = fromJson(idsJson); + ids = utils.fromJson(idsJson); } else { ids = {}; } @@ -609,7 +644,7 @@ return /******/ (function(modules) { // webpackBootstrap */ removeId: function removeId(id, mapper, opts) { var ids = this.getIds(mapper, opts); - if (isArray(id)) { + if (utils.isArray(id)) { if (!id.length) { return; } @@ -633,7 +668,7 @@ return /******/ (function(modules) { // webpackBootstrap ids = ids || {}; var idsPath = this.getPath(mapper, opts); if (Object.keys(ids).length) { - this.storage.setItem(idsPath, toJson(ids)); + this.storage.setItem(idsPath, utils.toJson(ids)); } else { this.storage.removeItem(idsPath); } @@ -679,11 +714,11 @@ return /******/ (function(modules) { // webpackBootstrap * otherwise `false` if the current version is not beta. */ LocalStorageAdapter.version = { - full: '3.0.0-alpha.6', + full: '3.0.0-alpha.7', major: parseInt('3', 10), minor: parseInt('0', 10), patch: parseInt('0', 10), - alpha: true ? '6' : false, + alpha: true ? '7' : false, beta: true ? 'false' : false }; @@ -790,19 +825,6 @@ return /******/ (function(modules) { // webpackBootstrap babelHelpers; - var addHiddenPropsToTarget = jsData.utils.addHiddenPropsToTarget; - var extend = jsData.utils.extend; - var fillIn = jsData.utils.fillIn; - var forEachRelation = jsData.utils.forEachRelation; - var get = jsData.utils.get; - var isArray = jsData.utils.isArray; - var isObject = jsData.utils.isObject; - var isUndefined = jsData.utils.isUndefined; - var omit = jsData.utils.omit; - var plainCopy = jsData.utils.plainCopy; - var resolve = jsData.utils.resolve; - - var noop = function noop() { var self = this; @@ -812,7 +834,7 @@ return /******/ (function(modules) { // webpackBootstrap var opts = args[args.length - 1]; self.dbg.apply(self, [opts.op].concat(args)); - return resolve(); + return jsData.utils.resolve(); }; var noop2 = function noop2() { @@ -824,7 +846,7 @@ return /******/ (function(modules) { // webpackBootstrap var opts = args[args.length - 2]; self.dbg.apply(self, [opts.op].concat(args)); - return resolve(); + return jsData.utils.resolve(); }; var unique = function unique(array) { @@ -841,7 +863,7 @@ return /******/ (function(modules) { // webpackBootstrap }; var withoutRelations = function withoutRelations(mapper, props) { - return omit(props, mapper.relationFields || []); + return jsData.utils.omit(props, mapper.relationFields || []); }; var DEFAULTS = { @@ -877,8 +899,8 @@ return /******/ (function(modules) { // webpackBootstrap function Adapter(opts) { var self = this; opts || (opts = {}); - fillIn(opts, DEFAULTS); - fillIn(self, opts); + jsData.utils.fillIn(opts, DEFAULTS); + jsData.utils.fillIn(self, opts); } Adapter.reserved = ['orderBy', 'sort', 'limit', 'offset', 'skip', 'where']; @@ -895,7 +917,7 @@ return /******/ (function(modules) { // webpackBootstrap var self = this; meta || (meta = {}); self.data = data; - fillIn(self, meta); + jsData.utils.fillIn(self, meta); self.op = op; } @@ -912,9 +934,32 @@ return /******/ (function(modules) { // webpackBootstrap * properties to the subclass itself. * @return {Object} Subclass of `Adapter`. */ - Adapter.extend = extend; + 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, - addHiddenPropsToTarget(Adapter.prototype, { /** * Lifecycle method method called by create. * @@ -1053,6 +1098,29 @@ return /******/ (function(modules) { // webpackBootstrap */ 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. * @@ -1124,6 +1192,24 @@ return /******/ (function(modules) { // webpackBootstrap */ 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. * @@ -1236,6 +1322,24 @@ return /******/ (function(modules) { // webpackBootstrap */ 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. * @@ -1313,6 +1417,58 @@ return /******/ (function(modules) { // webpackBootstrap }, + /** + * 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`. * @@ -1333,18 +1489,18 @@ return /******/ (function(modules) { // webpackBootstrap // beforeCreate lifecycle hook op = opts.op = 'beforeCreate'; - return resolve(self[op](mapper, props, opts)).then(function (_props) { + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { // Allow for re-assignment from lifecycle hook - props = isUndefined(_props) ? props : _props; + props = jsData.utils.isUndefined(_props) ? props : _props; props = withoutRelations(mapper, props); op = opts.op = 'create'; self.dbg(op, mapper, props, opts); - return resolve(self._create(mapper, props, opts)); + return jsData.utils.resolve(self._create(mapper, props, opts)); }).then(function (results) { - var _results = babelHelpers.slicedToArray(results, 2); + var _results2 = babelHelpers.slicedToArray(results, 2); - var data = _results[0]; - var result = _results[1]; + var data = _results2[0]; + var result = _results2[1]; result || (result = {}); var response = new Response(data, result, 'create'); @@ -1353,9 +1509,9 @@ return /******/ (function(modules) { // webpackBootstrap // afterCreate lifecycle hook op = opts.op = 'afterCreate'; - return resolve(self[op](mapper, props, opts, response)).then(function (_response) { + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { // Allow for re-assignment from lifecycle hook - return isUndefined(_response) ? response : _response; + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, @@ -1381,20 +1537,20 @@ return /******/ (function(modules) { // webpackBootstrap // beforeCreateMany lifecycle hook op = opts.op = 'beforeCreateMany'; - return resolve(self[op](mapper, props, opts)).then(function (_props) { + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { // Allow for re-assignment from lifecycle hook - props = isUndefined(_props) ? props : _props; + 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 resolve(self._createMany(mapper, props, opts)); + return jsData.utils.resolve(self._createMany(mapper, props, opts)); }).then(function (results) { - var _results2 = babelHelpers.slicedToArray(results, 2); + var _results3 = babelHelpers.slicedToArray(results, 2); - var data = _results2[0]; - var result = _results2[1]; + var data = _results3[0]; + var result = _results3[1]; data || (data = []); result || (result = {}); @@ -1404,9 +1560,9 @@ return /******/ (function(modules) { // webpackBootstrap // afterCreateMany lifecycle hook op = opts.op = 'afterCreateMany'; - return resolve(self[op](mapper, props, opts, response)).then(function (_response) { + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { // Allow for re-assignment from lifecycle hook - return isUndefined(_response) ? response : _response; + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, @@ -1432,15 +1588,15 @@ return /******/ (function(modules) { // webpackBootstrap // beforeDestroy lifecycle hook op = opts.op = 'beforeDestroy'; - return resolve(self[op](mapper, id, opts)).then(function () { + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { op = opts.op = 'destroy'; self.dbg(op, mapper, id, opts); - return resolve(self._destroy(mapper, id, opts)); + return jsData.utils.resolve(self._destroy(mapper, id, opts)); }).then(function (results) { - var _results3 = babelHelpers.slicedToArray(results, 2); + var _results4 = babelHelpers.slicedToArray(results, 2); - var data = _results3[0]; - var result = _results3[1]; + var data = _results4[0]; + var result = _results4[1]; result || (result = {}); var response = new Response(data, result, 'destroy'); @@ -1448,9 +1604,9 @@ return /******/ (function(modules) { // webpackBootstrap // afterDestroy lifecycle hook op = opts.op = 'afterDestroy'; - return resolve(self[op](mapper, id, opts, response)).then(function (_response) { + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { // Allow for re-assignment from lifecycle hook - return isUndefined(_response) ? response : _response; + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, @@ -1483,15 +1639,15 @@ return /******/ (function(modules) { // webpackBootstrap // beforeDestroyAll lifecycle hook op = opts.op = 'beforeDestroyAll'; - return resolve(self[op](mapper, query, opts)).then(function () { + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { op = opts.op = 'destroyAll'; self.dbg(op, mapper, query, opts); - return resolve(self._destroyAll(mapper, query, opts)); + return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); }).then(function (results) { - var _results4 = babelHelpers.slicedToArray(results, 2); + var _results5 = babelHelpers.slicedToArray(results, 2); - var data = _results4[0]; - var result = _results4[1]; + var data = _results5[0]; + var result = _results5[1]; result || (result = {}); var response = new Response(data, result, 'destroyAll'); @@ -1499,9 +1655,9 @@ return /******/ (function(modules) { // webpackBootstrap // afterDestroyAll lifecycle hook op = opts.op = 'afterDestroyAll'; - return resolve(self[op](mapper, query, opts, response)).then(function (_response) { + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { // Allow for re-assignment from lifecycle hook - return isUndefined(_response) ? response : _response; + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, @@ -1535,8 +1691,8 @@ return /******/ (function(modules) { // webpackBootstrap */ makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) { var localKeys = []; - var itemKeys = get(record, def.localKeys) || []; - itemKeys = isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + 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; @@ -1554,7 +1710,7 @@ return /******/ (function(modules) { // webpackBootstrap * @return {*} */ makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) { - return get(record, mapper.idAttribute); + return jsData.utils.get(record, mapper.idAttribute); }, @@ -1571,7 +1727,7 @@ return /******/ (function(modules) { // webpackBootstrap var self = this; var singular = false; - if (isObject(records) && !isArray(records)) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { singular = true; records = [records]; } @@ -1598,7 +1754,7 @@ return /******/ (function(modules) { // webpackBootstrap attached = relatedItems; } else { relatedItems.forEach(function (relatedItem) { - if (get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { + if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { attached.push(relatedItem); } }); @@ -1612,7 +1768,7 @@ return /******/ (function(modules) { // webpackBootstrap var record = void 0; var relatedMapper = def.getRelation(); - if (isObject(records) && !isArray(records)) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { record = records; } @@ -1640,8 +1796,8 @@ return /******/ (function(modules) { // webpackBootstrap }, __opts).then(function (relatedItems) { records.forEach(function (item) { var attached = []; - var itemKeys = get(item, def.localKeys) || []; - itemKeys = isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + 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); @@ -1663,7 +1819,7 @@ return /******/ (function(modules) { // webpackBootstrap var idAttribute = mapper.idAttribute; var record = void 0; - if (isObject(records) && !isArray(records)) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { record = records; } @@ -1686,9 +1842,9 @@ return /******/ (function(modules) { // webpackBootstrap var foreignKeysField = def.foreignKeys; records.forEach(function (record) { var _relatedItems = []; - var id = get(record, idAttribute); + var id = jsData.utils.get(record, idAttribute); relatedItems.forEach(function (relatedItem) { - var foreignKeys = get(relatedItems, foreignKeysField) || []; + var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; if (foreignKeys.indexOf(id) !== -1) { _relatedItems.push(relatedItem); } @@ -1710,13 +1866,13 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Promise} */ loadHasOne: function loadHasOne(mapper, def, records, __opts) { - if (isObject(records) && !isArray(records)) { + 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 (isArray(relatedData) && relatedData.length) { + if (jsData.utils.isArray(relatedData) && relatedData.length) { def.setLocalField(record, relatedData[0]); } }); @@ -1751,7 +1907,7 @@ return /******/ (function(modules) { // webpackBootstrap var self = this; var relationDef = def.getRelation(); - if (isObject(records) && !isArray(records)) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { var _ret2 = function () { var record = records; return { @@ -1807,14 +1963,14 @@ return /******/ (function(modules) { // webpackBootstrap // beforeFind lifecycle hook op = opts.op = 'beforeFind'; - return resolve(self[op](mapper, id, opts)).then(function () { + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { op = opts.op = 'find'; self.dbg(op, mapper, id, opts); - return resolve(self._find(mapper, id, opts)); + return jsData.utils.resolve(self._find(mapper, id, opts)); }).then(function (results) { - var _results5 = babelHelpers.slicedToArray(results, 1); + var _results6 = babelHelpers.slicedToArray(results, 1); - var _record = _results5[0]; + var _record = _results6[0]; if (!_record) { return; @@ -1822,7 +1978,7 @@ return /******/ (function(modules) { // webpackBootstrap record = _record; var tasks = []; - forEachRelation(mapper, opts, function (def, __opts) { + 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') { @@ -1850,9 +2006,9 @@ return /******/ (function(modules) { // webpackBootstrap // afterFind lifecycle hook op = opts.op = 'afterFind'; - return resolve(self[op](mapper, id, opts, response)).then(function (_response) { + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { // Allow for re-assignment from lifecycle hook - return isUndefined(_response) ? response : _response; + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, @@ -1884,21 +2040,32 @@ return /******/ (function(modules) { // webpackBootstrap 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 resolve(self[op](mapper, query, opts)).then(function () { + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { op = opts.op = 'findAll'; self.dbg(op, mapper, query, opts); - return resolve(self._findAll(mapper, query, opts)); + return jsData.utils.resolve(self._findAll(mapper, query, opts)); }).then(function (results) { - var _results6 = babelHelpers.slicedToArray(results, 1); + var _results7 = babelHelpers.slicedToArray(results, 1); - var _records = _results6[0]; + var _records = _results7[0]; _records || (_records = []); records = _records; var tasks = []; - forEachRelation(mapper, opts, function (def, __opts) { + 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') { @@ -1925,9 +2092,9 @@ return /******/ (function(modules) { // webpackBootstrap // afterFindAll lifecycle hook op = opts.op = 'afterFindAll'; - return resolve(self[op](mapper, query, opts, response)).then(function (_response) { + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { // Allow for re-assignment from lifecycle hook - return isUndefined(_response) ? response : _response; + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, @@ -1945,7 +2112,7 @@ return /******/ (function(modules) { // webpackBootstrap */ getOpt: function getOpt(opt, opts) { opts || (opts = {}); - return isUndefined(opts[opt]) ? plainCopy(this[opt]) : plainCopy(opts[opt]); + return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); }, @@ -1983,6 +2150,62 @@ return /******/ (function(modules) { // webpackBootstrap }, + /** + * 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 @@ -2018,17 +2241,17 @@ return /******/ (function(modules) { // webpackBootstrap // beforeUpdate lifecycle hook op = opts.op = 'beforeUpdate'; - return resolve(self[op](mapper, id, props, opts)).then(function (_props) { + return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { // Allow for re-assignment from lifecycle hook - props = isUndefined(_props) ? props : _props; + props = jsData.utils.isUndefined(_props) ? props : _props; op = opts.op = 'update'; self.dbg(op, mapper, id, props, opts); - return resolve(self._update(mapper, id, props, opts)); + return jsData.utils.resolve(self._update(mapper, id, props, opts)); }).then(function (results) { - var _results7 = babelHelpers.slicedToArray(results, 2); + var _results9 = babelHelpers.slicedToArray(results, 2); - var data = _results7[0]; - var result = _results7[1]; + var data = _results9[0]; + var result = _results9[1]; result || (result = {}); var response = new Response(data, result, 'update'); @@ -2037,9 +2260,9 @@ return /******/ (function(modules) { // webpackBootstrap // afterUpdate lifecycle hook op = opts.op = 'afterUpdate'; - return resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { + return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { // Allow for re-assignment from lifecycle hook - return isUndefined(_response) ? response : _response; + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, @@ -2074,17 +2297,17 @@ return /******/ (function(modules) { // webpackBootstrap // beforeUpdateAll lifecycle hook op = opts.op = 'beforeUpdateAll'; - return resolve(self[op](mapper, props, query, opts)).then(function (_props) { + return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { // Allow for re-assignment from lifecycle hook - props = isUndefined(_props) ? props : _props; + props = jsData.utils.isUndefined(_props) ? props : _props; op = opts.op = 'updateAll'; self.dbg(op, mapper, props, query, opts); - return resolve(self._updateAll(mapper, props, query, opts)); + return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); }).then(function (results) { - var _results8 = babelHelpers.slicedToArray(results, 2); + var _results10 = babelHelpers.slicedToArray(results, 2); - var data = _results8[0]; - var result = _results8[1]; + var data = _results10[0]; + var result = _results10[1]; data || (data = []); result || (result = {}); @@ -2094,9 +2317,9 @@ return /******/ (function(modules) { // webpackBootstrap // afterUpdateAll lifecycle hook op = opts.op = 'afterUpdateAll'; - return resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { + return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { // Allow for re-assignment from lifecycle hook - return isUndefined(_response) ? response : _response; + return jsData.utils.isUndefined(_response) ? response : _response; }); }); }, @@ -2122,25 +2345,25 @@ return /******/ (function(modules) { // webpackBootstrap var idAttribute = mapper.idAttribute; records = records.filter(function (record) { - return get(record, idAttribute); + return jsData.utils.get(record, idAttribute); }); // beforeUpdateMany lifecycle hook op = opts.op = 'beforeUpdateMany'; - return resolve(self[op](mapper, records, opts)).then(function (_records) { + return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) { // Allow for re-assignment from lifecycle hook - records = isUndefined(_records) ? records : _records; + 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 resolve(self._updateMany(mapper, records, opts)); + return jsData.utils.resolve(self._updateMany(mapper, records, opts)); }).then(function (results) { - var _results9 = babelHelpers.slicedToArray(results, 2); + var _results11 = babelHelpers.slicedToArray(results, 2); - var data = _results9[0]; - var result = _results9[1]; + var data = _results11[0]; + var result = _results11[1]; data || (data = []); result || (result = {}); @@ -2150,9 +2373,9 @@ return /******/ (function(modules) { // webpackBootstrap // afterUpdateMany lifecycle hook op = opts.op = 'afterUpdateMany'; - return resolve(self[op](mapper, records, opts, response)).then(function (_response) { + return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { // Allow for re-assignment from lifecycle hook - return isUndefined(_response) ? response : _response; + return jsData.utils.isUndefined(_response) ? response : _response; }); }); } diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index 6702202..631acb9 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 8147363e5b30b5af34ce","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:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.js"],"names":[],"mappings":"AAAA;AACA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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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;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,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,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;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;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,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;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,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;;;;;;AC/5CA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 8147363e5b30b5af34ce\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst Adapter = require('js-data-adapter')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\n\nconst {\n addHiddenPropsToTarget,\n deepMixIn,\n extend,\n fillIn,\n forOwn,\n fromJson,\n get,\n isArray,\n isUndefined,\n reject,\n set,\n toJson\n} = utils\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}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return reject(err)\n })\n}\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n const self = this\n opts || (opts = {})\n fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nLocalStorageAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: LocalStorageAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(LocalStorageAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = extend\n\naddHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n _createHelper (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = get(_props, mapper.idAttribute) || guid()\n set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, toJson(_props))\n self.ensureId(id, mapper, opts)\n return fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record. Internal method used by Adapter#create.\n *\n * @name LocalStorageAdapter#_create\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _create (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n return resolve([self._createHelper(mapper, props, opts), {}])\n })\n },\n\n /**\n * Create multiple records in a single batch. Internal method used by\n * Adapter#createMany.\n *\n * @name LocalStorageAdapter#_createMany\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _createMany (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n props || (props = [])\n return resolve([props.map(function (_props) {\n return self._createHelper(mapper, _props, opts)\n }), {}])\n })\n },\n\n /**\n * Destroy the record with the given primary key. Internal method used by\n * Adapter#destroy.\n *\n * @name LocalStorageAdapter#_destroy\n * @method\n * @private\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 * @return {Promise}\n */\n _destroy (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n return resolve([undefined, {}])\n })\n },\n\n /**\n * Destroy the records that match the selection query. Internal method used by\n * Adapter#destroyAll.\n *\n * @name LocalStorageAdapter#_destroyAll\n * @method\n * @private\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroyAll (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query).then(function (results) {\n let [records] = results\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n const ids = records.map(function (record) {\n return get(record, idAttribute)\n })\n // Destroy each record\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n return [undefined, {}]\n })\n },\n\n /**\n * Retrieve the record with the given primary key. Internal method used by\n * Adapter#find.\n *\n * @name LocalStorageAdapter#_find\n * @method\n * @private\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 * @return {Promise}\n */\n _find (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n const key = self.getIdPath(mapper, opts, id)\n const record = self.storage.getItem(key)\n return resolve([record ? fromJson(record) : undefined, {}])\n })\n },\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#findAll.\n *\n * @name LocalStorageAdapter#_findAll\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n return new Promise(function (resolve) {\n // Load all records into memory...\n let records = []\n const ids = self.getIds(mapper, opts)\n forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(fromJson(json))\n }\n })\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n return resolve([_query.filter(query).run(), {}])\n })\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n * Internal method used by Adapter#update.\n *\n * @name LocalStorageAdapter#_update\n * @method\n * @private\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 * @return {Promise}\n */\n _update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n return new Promise(function (resolve, reject) {\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n if (!record) {\n return reject(new Error('Not Found'))\n }\n record = fromJson(record)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n return resolve([record, {}])\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Internal method used by Adapter#updateAll.\n *\n * @name LocalStorageAdapter#_updateAll\n * @method\n * @private\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} [opts] Configuration options.\n * @return {Promise}\n */\n _updateAll (mapper, props, query, opts) {\n const self = this\n const idAttribute = mapper.idAttribute\n return self._findAll(mapper, query, opts).then(function (results) {\n let [records] = results\n records.forEach(function (record) {\n record || (record = {})\n const id = get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n deepMixIn(record, props)\n self.storage.setItem(key, toJson(record))\n })\n return [records, {}]\n })\n },\n\n /**\n * Update the given records in a single batch. Internal method used by\n * Adapter#updateMany.\n *\n * @name LocalStorageAdapter#updateMany\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n return new Promise(function (resolve) {\n const updatedRecords = []\n const idAttribute = mapper.idAttribute\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = get(record, idAttribute)\n if (isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n if (!json) {\n return\n }\n const existingRecord = fromJson(json)\n deepMixIn(existingRecord, record)\n self.storage.setItem(key, toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n return resolve([records, {}])\n })\n },\n\n create (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.create.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n createMany (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.createMany.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n destroy (mapper, id, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroy.call(self, mapper, id, opts).then(success, failure)\n })\n })\n },\n\n destroyAll (mapper, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroyAll.call(self, mapper, query, opts).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n update (mapper, id, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.update.call(self, mapper, id, props, opts).then(success, failure)\n })\n })\n },\n\n updateAll (mapper, props, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure)\n })\n })\n },\n\n updateMany (mapper, records, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateMany.call(self, mapper, records, opts).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 addHiddenPropsToTarget = jsData.utils.addHiddenPropsToTarget;\n var extend = jsData.utils.extend;\n var fillIn = jsData.utils.fillIn;\n var forEachRelation = jsData.utils.forEachRelation;\n var get = jsData.utils.get;\n var isArray = jsData.utils.isArray;\n var isObject = jsData.utils.isObject;\n var isUndefined = jsData.utils.isUndefined;\n var omit = jsData.utils.omit;\n var plainCopy = jsData.utils.plainCopy;\n var resolve = jsData.utils.resolve;\n\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 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 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 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 fillIn(opts, DEFAULTS);\n 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 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 = extend;\n\n addHiddenPropsToTarget(Adapter.prototype, {\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 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 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 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 * 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 resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props;\n props = withoutRelations(mapper, props);\n op = opts.op = 'create';\n self.dbg(op, mapper, props, opts);\n return resolve(self._create(mapper, props, 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, '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 resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = 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 resolve(self._createMany(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 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 resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy';\n self.dbg(op, mapper, id, opts);\n return resolve(self._destroy(mapper, id, 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 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 resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll';\n self.dbg(op, mapper, query, opts);\n return resolve(self._destroyAll(mapper, query, 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, 'destroyAll');\n response = self.respond(response, opts);\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll';\n return resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 = get(record, def.localKeys) || [];\n itemKeys = 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 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 (isObject(records) && !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 (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 (isObject(records) && !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 = get(item, def.localKeys) || [];\n itemKeys = 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 (isObject(records) && !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 = get(record, idAttribute);\n relatedItems.forEach(function (relatedItem) {\n var foreignKeys = 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 (isObject(records) && !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 (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 (isObject(records) && !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 resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find';\n self.dbg(op, mapper, id, opts);\n return resolve(self._find(mapper, id, opts));\n }).then(function (results) {\n var _results5 = babelHelpers.slicedToArray(results, 1);\n\n var _record = _results5[0];\n\n if (!_record) {\n return;\n }\n record = _record;\n var tasks = [];\n\n 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 resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll';\n return resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll';\n self.dbg(op, mapper, query, opts);\n return resolve(self._findAll(mapper, query, opts));\n }).then(function (results) {\n var _results6 = babelHelpers.slicedToArray(results, 1);\n\n var _records = _results6[0];\n\n _records || (_records = []);\n records = _records;\n var tasks = [];\n 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 resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 isUndefined(opts[opt]) ? plainCopy(this[opt]) : 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 * @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 resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props;\n op = opts.op = 'update';\n self.dbg(op, mapper, id, props, opts);\n return resolve(self._update(mapper, id, props, opts));\n }).then(function (results) {\n var _results7 = babelHelpers.slicedToArray(results, 2);\n\n var data = _results7[0];\n var result = _results7[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 resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = isUndefined(_props) ? props : _props;\n op = opts.op = 'updateAll';\n self.dbg(op, mapper, props, query, opts);\n return resolve(self._updateAll(mapper, props, 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 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 resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 get(record, idAttribute);\n });\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany';\n return resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = 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 resolve(self._updateMany(mapper, records, 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 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 resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return 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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 3\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 4\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 5\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 8\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 9\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 10\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 11\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 12\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 13\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap e52e9d21ae62b1c8472e","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:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;;;;;;ACrCA,KAAM,SAAS,oBAAQ,CAAR,CAAT;AACN,KAAM,UAAU,oBAAQ,CAAR,CAAV;AACN,KAAM,OAAO,oBAAQ,CAAR,CAAP;;KAGJ,QAEE,OAFF;KACA,QACE,OADF;;;AAGF,UAAS,aAAT,CAAwB,KAAxB,EAA+B;AAC7B,UAAQ,SAAS,IAAT,IAAiB,UAAU,EAAV,CADI;EAA/B;AAGA,UAAS,IAAT,CAAe,KAAf,EAAsB,SAAtB,EAAiC;AAC/B,iBAAc,YAAY,EAAZ,CAAd,CAD+B;AAE/B,UAAO,MAAM,MAAN,CAAa,aAAb,EAA4B,IAA5B,CAAiC,SAAjC,CAAP,CAF+B;EAAjC;AAIA,UAAS,QAAT,GAA4B;qCAAN;;IAAM;;AAC1B,OAAI,SAAS,KAAK,IAAL,EAAW,GAAX,CAAT,CADsB;AAE1B,UAAO,OAAO,OAAP,CAAe,mBAAf,EAAoC,KAApC,CAAP,CAF0B;EAA5B;AAIA,KAAI,QAAQ,EAA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AACP,SAAM,QAA4B,aAA5B,GAA4C,KAA5C;EANR;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,QAAO,OAAP,GAAiB,mBAAjB,C;;;;;;ACppBA,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;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 e52e9d21ae62b1c8472e\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst Adapter = require('js-data-adapter')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\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}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return utils.reject(err)\n })\n}\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n const self = this\n utils.classCallCheck(self, LocalStorageAdapter)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nLocalStorageAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: LocalStorageAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(LocalStorageAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#count.\n *\n * @name LocalStorageAdapter#_count\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _count (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n result[0] = result[0].length\n return result\n })\n },\n\n _createHelper (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n utils.forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = utils.get(_props, mapper.idAttribute) || guid()\n utils.set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, utils.toJson(_props))\n self.ensureId(id, mapper, opts)\n return utils.fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record. Internal method used by Adapter#create.\n *\n * @name LocalStorageAdapter#_create\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _create (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n return resolve([self._createHelper(mapper, props, opts), {}])\n })\n },\n\n /**\n * Create multiple records in a single batch. Internal method used by\n * Adapter#createMany.\n *\n * @name LocalStorageAdapter#_createMany\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _createMany (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n props || (props = [])\n return resolve([props.map(function (_props) {\n return self._createHelper(mapper, _props, opts)\n }), {}])\n })\n },\n\n /**\n * Destroy the record with the given primary key. Internal method used by\n * Adapter#destroy.\n *\n * @name LocalStorageAdapter#_destroy\n * @method\n * @private\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 * @return {Promise}\n */\n _destroy (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n return resolve([undefined, {}])\n })\n },\n\n /**\n * Destroy the records that match the selection query. Internal method used by\n * Adapter#destroyAll.\n *\n * @name LocalStorageAdapter#_destroyAll\n * @method\n * @private\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroyAll (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query).then(function (results) {\n let [records] = results\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n const ids = records.map(function (record) {\n return utils.get(record, idAttribute)\n })\n // Destroy each record\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n return [undefined, {}]\n })\n },\n\n /**\n * Retrieve the record with the given primary key. Internal method used by\n * Adapter#find.\n *\n * @name LocalStorageAdapter#_find\n * @method\n * @private\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 * @return {Promise}\n */\n _find (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n const key = self.getIdPath(mapper, opts, id)\n const record = self.storage.getItem(key)\n return resolve([record ? utils.fromJson(record) : undefined, {}])\n })\n },\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#findAll.\n *\n * @name LocalStorageAdapter#_findAll\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n return new Promise(function (resolve) {\n // Load all records into memory...\n let records = []\n const ids = self.getIds(mapper, opts)\n utils.forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(utils.fromJson(json))\n }\n })\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n return resolve([_query.filter(query).run(), {}])\n })\n },\n\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#sum.\n *\n * @name LocalStorageAdapter#_sum\n * @method\n * @private\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 * @return {Promise}\n */\n _sum (mapper, field, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n let sum = 0\n result[0].forEach(function (record) {\n sum += utils.get(record, field) || 0\n })\n result[0] = sum\n return result\n })\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n * Internal method used by Adapter#update.\n *\n * @name LocalStorageAdapter#_update\n * @method\n * @private\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 * @return {Promise}\n */\n _update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n return new Promise(function (resolve, reject) {\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n if (!record) {\n return reject(new Error('Not Found'))\n }\n record = utils.fromJson(record)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n return resolve([record, {}])\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Internal method used by Adapter#updateAll.\n *\n * @name LocalStorageAdapter#_updateAll\n * @method\n * @private\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} [opts] Configuration options.\n * @return {Promise}\n */\n _updateAll (mapper, props, query, opts) {\n const self = this\n const idAttribute = mapper.idAttribute\n return self._findAll(mapper, query, opts).then(function (results) {\n let [records] = results\n records.forEach(function (record) {\n record || (record = {})\n const id = utils.get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n })\n return [records, {}]\n })\n },\n\n /**\n * Update the given records in a single batch. Internal method used by\n * Adapter#updateMany.\n *\n * @name LocalStorageAdapter#updateMany\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n return new Promise(function (resolve) {\n const updatedRecords = []\n const idAttribute = mapper.idAttribute\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = utils.get(record, idAttribute)\n if (utils.isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n if (!json) {\n return\n }\n const existingRecord = utils.fromJson(json)\n utils.deepMixIn(existingRecord, record)\n self.storage.setItem(key, utils.toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n return resolve([records, {}])\n })\n },\n\n create (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.create.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n createMany (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.createMany.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n destroy (mapper, id, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroy.call(self, mapper, id, opts).then(success, failure)\n })\n })\n },\n\n destroyAll (mapper, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroyAll.call(self, mapper, query, opts).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = utils.fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, utils.toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n update (mapper, id, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.update.call(self, mapper, id, props, opts).then(success, failure)\n })\n })\n },\n\n updateAll (mapper, props, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure)\n })\n })\n },\n\n updateMany (mapper, records, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateMany.call(self, mapper, records, opts).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 3\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 4\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 5\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 8\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 9\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 10\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 11\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 12\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 13\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index 73efd81..d92fbb4 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -1,11 +1,11 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.6 - Homepage +* @version 3.0.0-alpha.7 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("js-data")):"function"==typeof define&&define.amd?define(["js-data"],e):"object"==typeof exports?exports.LocalStorageAdapter=e(require("js-data")):t.LocalStorageAdapter=e(t.JSData)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return null!=t&&""!==t}function o(t,e){return e||(e=""),t.filter(r).join(e)}function a(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=o(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function i(t){H.push(t)}function u(){H.length&&!T&&(T=!0,H[0]())}function f(t){H.length?i(t):(i(t),u())}function c(t){return new Promise(t).then(function(t){return T=!1,H.shift(),setTimeout(u,0),t},function(t){return T=!1,H.shift(),setTimeout(u,0),x(t)})}function s(t){var e=this;t||(t={}),m(t,O),h.call(e,t)}var l=function(){function t(t,e){var n=[],r=!0,o=!1,a=void 0;try{for(var i,u=t[Symbol.iterator]();!(r=(i=u.next()).done)&&(n.push(i.value),!e||n.length!==e);r=!0);}catch(t){o=!0,a=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw a}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=n(1),h=n(2),p=n(3),y=d.Query,v=d.utils,g=v.addHiddenPropsToTarget,b=v.deepMixIn,A=v.extend,m=v.fillIn,M=v.forOwn,w=v.fromJson,P=v.get,I=v.isArray,K=v.isUndefined,x=v.reject,F=v.set,_=v.toJson,H=[],T=!1,j=h.prototype,O={basePath:"",debug:!1,storage:localStorage};s.prototype=Object.create(h.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(s,"__super__",{configurable:!0,value:h}),s.extend=A,g(s.prototype,{_createHelper:function(t,e,n){var r=this,o={},a=t.relationFields||[];M(e,function(t,e){-1===a.indexOf(e)&&(o[e]=t)});var i=P(o,t.idAttribute)||p();F(o,t.idAttribute,i);var u=r.getIdPath(t,n,i);return r.storage.setItem(u,_(o)),r.ensureId(i,t,n),w(r.storage.getItem(u))},_create:function(t,e,n){var r=this;return new Promise(function(o){return o([r._createHelper(t,e,n),{}])})},_createMany:function(t,e,n){var r=this;return new Promise(function(o){return e||(e=[]),o([e.map(function(e){return r._createHelper(t,e,n)}),{}])})},_destroy:function(t,e,n){var r=this;return new Promise(function(o){return r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),o([void 0,{}])})},_destroyAll:function(t,e,n){var r=this;return r._findAll(t,e).then(function(e){var o=l(e,1),a=o[0],i=t.idAttribute,u=a.map(function(t){return P(t,i)});return u.forEach(function(e){r.storage.removeItem(r.getIdPath(t,n,e))}),r.removeId(u,t,n),[void 0,{}]})},_find:function(t,e,n){var r=this;return new Promise(function(o){var a=r.getIdPath(t,n,e),i=r.storage.getItem(a);return o([i?w(i):void 0,{}])})},_findAll:function(t,e,n){var r=this;return e||(e={}),new Promise(function(o){var a=[],i=r.getIds(t,n);M(i,function(e,o){var i=r.storage.getItem(r.getIdPath(t,n,o));i&&a.push(w(i))});var u=new y({index:{getAll:function(){return a}}});return o([u.filter(e).run(),{}])})},_update:function(t,e,n,r){var o=this;return n||(n={}),new Promise(function(a,i){var u=o.getIdPath(t,r,e),f=o.storage.getItem(u);return f?(f=w(f),b(f,n),o.storage.setItem(u,_(f)),a([f,{}])):i(new Error("Not Found"))})},_updateAll:function(t,e,n,r){var o=this,a=t.idAttribute;return o._findAll(t,n,r).then(function(n){var i=l(n,1),u=i[0];return u.forEach(function(n){n||(n={});var i=P(n,a),u=o.getIdPath(t,r,i);b(n,e),o.storage.setItem(u,_(n))}),[u,{}]})},_updateMany:function(t,e,n){var r=this;return e||(e=[]),new Promise(function(o){var a=[],i=t.idAttribute;return e.forEach(function(e){if(e){var o=P(e,i);if(!K(o)){var u=r.getIdPath(t,n,o),f=r.storage.getItem(u);if(f){var c=w(f);b(c,e),r.storage.setItem(u,_(c)),a.push(c)}}}}),o([e,{}])})},create:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.create.call(r,t,e,n).then(o,a)})})},createMany:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.createMany.call(r,t,e,n).then(o,a)})})},destroy:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.destroy.call(r,t,e,n).then(o,a)})})},destroyAll:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.destroyAll.call(r,t,e,n).then(o,a)})})},ensureId:function(t,e,n){var r=this.getIds(e,n);if(I(t)){if(!t.length)return;t.forEach(function(t){r[t]=1})}else r[t]=1;this.saveKeys(r,e,n)},getPath:function(t,e){return e=e||{},a(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},a(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,e){var n=void 0,r=this.getPath(t,e),o=this.storage.getItem(r);return n=o?w(o):{}},removeId:function(t,e,n){var r=this.getIds(e,n);if(I(t)){if(!t.length)return;t.forEach(function(t){delete r[t]})}else delete r[t];this.saveKeys(r,e,n)},saveKeys:function(t,e,n){t=t||{};var r=this.getPath(e,n);Object.keys(t).length?this.storage.setItem(r,_(t)):this.storage.removeItem(r)},update:function(t,e,n,r){var o=this;return c(function(a,i){f(function(){j.update.call(o,t,e,n,r).then(a,i)})})},updateAll:function(t,e,n,r){var o=this;return c(function(a,i){f(function(){j.updateAll.call(o,t,e,n,r).then(a,i)})})},updateMany:function(t,e,n){var r=this;return c(function(o,a){f(function(){j.updateMany.call(r,t,e,n).then(o,a)})})}}),s.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},t.exports=s},function(e,n){e.exports=t},function(t,e,n){!function(t,e){e(n(1))}(this,function(e){"use strict";function n(t){var e=this;t||(t={}),u(t,m),u(e,t)}function r(t,e,n){var r=this;e||(e={}),r.data=t,u(r,e),r.op=n}var o={};o.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},o.defineProperty=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},o.slicedToArray=function(){function t(t,e){var n=[],r=!0,o=!1,a=void 0;try{for(var i,u=t[Symbol.iterator]();!(r=(i=u.next()).done)&&(n.push(i.value),!e||n.length!==e);r=!0);}catch(t){o=!0,a=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw a}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var a=e.utils.addHiddenPropsToTarget,i=e.utils.extend,u=e.utils.fillIn,f=e.utils.forEachRelation,c=e.utils.get,s=e.utils.isArray,l=e.utils.isObject,d=e.utils.isUndefined,h=e.utils.omit,p=e.utils.plainCopy,y=e.utils.resolve,v=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-1];return t.dbg.apply(t,[o.op].concat(n)),y()},g=function(){for(var t=this,e=arguments.length,n=Array(e),r=0;e>r;r++)n[r]=arguments[r];var o=n[n.length-2];return t.dbg.apply(t,[o.op].concat(n)),y()},b=function(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n},A=function(t,e){return h(e,t.relationFields||[])},m={debug:!1,raw:!1};n.reserved=["orderBy","sort","limit","offset","skip","where"],n.Response=r,n.extend=i,a(n.prototype,{afterCreate:g,afterCreateMany:g,afterDestroy:g,afterDestroyAll:g,afterFind:g,afterFindAll:g,afterUpdate:g,afterUpdateAll:g,afterUpdateMany:g,beforeCreate:v,beforeCreateMany:v,beforeDestroy:v,beforeDestroyAll:v,beforeFind:v,beforeFindAll:v,beforeUpdate:v,beforeUpdateAll:v,beforeUpdateMany:v,dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},create:function(t,e,n){var a=this,i=void 0;return e||(e={}),n||(n={}),i=n.op="beforeCreate",y(a[i](t,e,n)).then(function(r){return e=d(r)?e:r,e=A(t,e),i=n.op="create",a.dbg(i,t,e,n),y(a._create(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];s||(s={});var l=new r(c,s,"create");return l.created=c?1:0,l=a.respond(l,n),i=n.op="afterCreate",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})},createMany:function(t,e,n){var a=this,i=void 0;return e||(e={}),n||(n={}),i=n.op="beforeCreateMany",y(a[i](t,e,n)).then(function(r){return e=d(r)?e:r,e=e.map(function(e){return A(t,e)}),i=n.op="createMany",a.dbg(i,t,e,n),y(a._createMany(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];c||(c=[]),s||(s={});var l=new r(c,s,"createMany");return l.created=c.length,l=a.respond(l,n),i=n.op="afterCreateMany",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})},destroy:function(t,e,n){var a=this,i=void 0;return n||(n={}),i=n.op="beforeDestroy",y(a[i](t,e,n)).then(function(){return i=n.op="destroy",a.dbg(i,t,e,n),y(a._destroy(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];s||(s={});var l=new r(c,s,"destroy");return l=a.respond(l,n),i=n.op="afterDestroy",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})},destroyAll:function(t,e,n){var a=this,i=void 0;return e||(e={}),n||(n={}),i=n.op="beforeDestroyAll",y(a[i](t,e,n)).then(function(){return i=n.op="destroyAll",a.dbg(i,t,e,n),y(a._destroyAll(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];s||(s={});var l=new r(c,s,"destroyAll");return l=a.respond(l,n),i=n.op="afterDestroyAll",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})},makeHasManyForeignKey:function(t,e,n){return e.getForeignKey(n)},makeHasManyLocalKeys:function(t,e,n){var r=[],o=c(n,e.localKeys)||[];return o=s(o)?o:Object.keys(o),r=r.concat(o),b(r).filter(function(t){return t})},makeHasManyForeignKeys:function(t,e,n){return c(n,t.idAttribute)},loadHasMany:function(t,e,n,r){var o=this,a=!1;l(n)&&!s(n)&&(a=!0,n=[n]);var i=n.map(function(n){return o.makeHasManyForeignKey(t,e,n)}),u={where:{}},f=u.where[e.foreignKey]={};return a?f["=="]=i[0]:f.in=i.filter(function(t){return t}),o.findAll(e.getRelation(),u,r).then(function(r){n.forEach(function(n){var o=[];a?o=r:r.forEach(function(r){c(r,e.foreignKey)===n[t.idAttribute]&&o.push(r)}),e.setLocalField(n,o)})})},loadHasManyLocalKeys:function(t,e,n,r){var a=this,i=void 0,u=e.getRelation();if(l(n)&&!s(n)&&(i=n),i)return a.findAll(u,{where:o.defineProperty({},u.idAttribute,{in:a.makeHasManyLocalKeys(t,e,i)})},r).then(function(t){e.setLocalField(i,t)});var f=function(){var i=[];return n.forEach(function(n){i=i.concat(a.self.makeHasManyLocalKeys(t,e,n))}),{v:a.findAll(u,{where:o.defineProperty({},u.idAttribute,{in:b(i).filter(function(t){return t})})},r).then(function(t){return n.forEach(function(n){var r=[],o=c(n,e.localKeys)||[];o=s(o)?o:Object.keys(o),t.forEach(function(t){o&&-1!==o.indexOf(t[u.idAttribute])&&r.push(t)}),e.setLocalField(n,r)}),t})}}();return"object"===("undefined"==typeof f?"undefined":o.typeof(f))?f.v:void 0},loadHasManyForeignKeys:function(t,e,n,r){var a=this,i=e.getRelation(),u=t.idAttribute,f=void 0;return l(n)&&!s(n)&&(f=n),f?a.findAll(e.getRelation(),{where:o.defineProperty({},e.foreignKeys,{contains:a.makeHasManyForeignKeys(t,e,f)})},r).then(function(t){e.setLocalField(f,t)}):a.findAll(i,{where:o.defineProperty({},e.foreignKeys,{isectNotEmpty:n.map(function(n){return a.makeHasManyForeignKeys(t,e,n)})})},r).then(function(t){var r=e.foreignKeys;n.forEach(function(n){var o=[],a=c(n,u);t.forEach(function(e){var n=c(t,r)||[];-1!==n.indexOf(a)&&o.push(e)}),e.setLocalField(n,o)})})},loadHasOne:function(t,e,n,r){return l(n)&&!s(n)&&(n=[n]),this.loadHasMany(t,e,n,r).then(function(){n.forEach(function(t){var n=e.getLocalField(t);s(n)&&n.length&&e.setLocalField(t,n[0])})})},makeBelongsToForeignKey:function(t,e,n){return e.getForeignKey(n)},loadBelongsTo:function(t,e,n,r){var a=this,i=e.getRelation();if(!l(n)||s(n)){var u=n.map(function(n){return a.makeBelongsToForeignKey(t,e,n)}).filter(function(t){return t});return a.findAll(i,{where:o.defineProperty({},i.idAttribute,{in:u})},r).then(function(t){n.forEach(function(n){t.forEach(function(t){t[i.idAttribute]===n[e.foreignKey]&&e.setLocalField(n,t)})})})}var f=function(){var o=n;return{v:a.find(i,a.makeBelongsToForeignKey(t,e,o),r).then(function(t){e.setLocalField(o,t)})}}();return"object"===("undefined"==typeof f?"undefined":o.typeof(f))?f.v:void 0},find:function(t,e,n){var a=this,i=void 0,u=void 0;return n||(n={}),n.with||(n.with=[]),u=n.op="beforeFind",y(a[u](t,e,n)).then(function(){return u=n.op="find",a.dbg(u,t,e,n),y(a._find(t,e,n))}).then(function(e){var r=o.slicedToArray(e,1),u=r[0];if(u){i=u;var c=[];return f(t,n,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=a.loadHasManyLocalKeys(t,e,i,n):"hasMany"===e.type&&e.foreignKeys?r=a.loadHasManyForeignKeys(t,e,i,n):"belongsTo"===e.type&&(r=a.loadBelongsTo(t,e,i,n)):r="hasOne"===e.type?a.loadHasOne(t,e,i,n):a.loadHasMany(t,e,i,n),r&&c.push(r)}),Promise.all(c)}}).then(function(){var o=new r(i,{},"find");return o.found=i?1:0,o=a.respond(o,n),u=n.op="afterFind",y(a[u](t,e,n,o)).then(function(t){return d(t)?o:t})})},findAll:function(t,e,n){var a=this;n||(n={}),n.with||(n.with=[]);var i=[],u=void 0;return u=n.op="beforeFindAll",y(a[u](t,e,n)).then(function(){return u=n.op="findAll",a.dbg(u,t,e,n),y(a._findAll(t,e,n))}).then(function(e){var r=o.slicedToArray(e,1),u=r[0];u||(u=[]),i=u;var c=[];return f(t,n,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=a.loadHasManyLocalKeys(t,e,i,n):"hasMany"===e.type&&e.foreignKeys?r=a.loadHasManyForeignKeys(t,e,i,n):"belongsTo"===e.type&&(r=a.loadBelongsTo(t,e,i,n)):r="hasMany"===e.type?a.loadHasMany(t,e,i,n):a.loadHasOne(t,e,i,n),r&&c.push(r)}),Promise.all(c)}).then(function(){var o=new r(i,{},"findAll");return o.found=i.length,o=a.respond(o,n),u=n.op="afterFindAll",y(a[u](t,e,n,o)).then(function(t){return d(t)?o:t})})},getOpt:function(t,e){return e||(e={}),p(d(e[t])?this[t]:e[t])},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (Adapter)";if(console[t]){var a;(a=console)[t].apply(a,[o].concat(n))}else{var i;(i=console).log.apply(i,[o].concat(n))}}},respond:function(t,e){return this.getOpt("raw",e)?t:t.data},update:function(t,e,n,a){var i=this;n||(n={}),a||(a={});var u=void 0;return u=a.op="beforeUpdate",y(i[u](t,e,n,a)).then(function(r){return n=d(r)?n:r,u=a.op="update",i.dbg(u,t,e,n,a),y(i._update(t,e,n,a))}).then(function(f){var c=o.slicedToArray(f,2),s=c[0],l=c[1];l||(l={});var h=new r(s,l,"update");return h.updated=s?1:0,h=i.respond(h,a),u=a.op="afterUpdate",y(i[u](t,e,n,a,h)).then(function(t){return d(t)?h:t})})},updateAll:function(t,e,n,a){var i=this;e||(e={}),n||(n={}),a||(a={});var u=void 0;return u=a.op="beforeUpdateAll",y(i[u](t,e,n,a)).then(function(r){return e=d(r)?e:r,u=a.op="updateAll",i.dbg(u,t,e,n,a),y(i._updateAll(t,e,n,a))}).then(function(f){var c=o.slicedToArray(f,2),s=c[0],l=c[1];s||(s=[]),l||(l={});var h=new r(s,l,"updateAll");return h.updated=s.length,h=i.respond(h,a),u=a.op="afterUpdateAll",y(i[u](t,e,n,a,h)).then(function(t){return d(t)?h:t})})},updateMany:function(t,e,n){var a=this;e||(e=[]),n||(n={});var i=void 0,u=t.idAttribute;return e=e.filter(function(t){return c(t,u)}),i=n.op="beforeUpdateMany",y(a[i](t,e,n)).then(function(r){return e=d(r)?e:r,e=e.map(function(e){return A(t,e)}),i=n.op="updateMany",a.dbg(i,t,e,n),y(a._updateMany(t,e,n))}).then(function(u){var f=o.slicedToArray(u,2),c=f[0],s=f[1];c||(c=[]),s||(s={});var l=new r(c,s,"updateMany");return l.updated=c.length,l=a.respond(l,n),i=n.op="afterUpdateMany",y(a[i](t,e,n,l)).then(function(t){return d(t)?l:t})})}}),t.exports=n})},function(t,e,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+a(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(4),a=n(5);t.exports=r},function(t,e,n){function r(t){t=t&&t>0?t:6;for(var e="";t--;)e+=o(a);return e}var o=n(5),a="0123456789abcdef".split("");t.exports=r},function(t,e,n){function r(t){var e=1===arguments.length&&a(t)?t:arguments;return e[o(0,e.length-1)]}var o=n(6),a=n(11);t.exports=r},function(t,e,n){function r(t,e){return t=null==t?o:~~t,e=null==e?a:~~e,Math.round(i(t-.5,e+.499999999999))}var o=n(7),a=n(8),i=n(9);t.exports=r},function(t,e){t.exports=-2147483648},function(t,e){t.exports=2147483647},function(t,e,n){function r(t,e){return t=null==t?a:t,e=null==e?i:e,t+(e-t)*o()}var o=n(10),a=n(7),i=n(8);t.exports=r},function(t,e){function n(){return n.get()}n.get=Math.random,t.exports=n},function(t,e,n){var r=n(12),o=Array.isArray||function(t){return r(t,"Array")};t.exports=o},function(t,e,n){function r(t,e){return o(t)===e}var o=n(13);t.exports=r},function(t,e){function n(t){return null===t?"Null":t===r?"Undefined":o.exec(a.call(t))[1]}var r,o=/^\[object (.*)\]$/,a=Object.prototype.toString;t.exports=n}])}); -//# sourceMappingURL=dist/js-data-localstorage.min.map \ No newline at end of file +!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.LocalStorageAdapter=t(require("js-data")):e.LocalStorageAdapter=t(e.JSData)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return null!=e&&""!==e}function o(e,t){return t||(t=""),e.filter(r).join(t)}function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var r=o(t,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function a(e){g.push(e)}function u(){g.length&&!b&&(b=!0,g[0]())}function s(e){g.length?a(e):(a(e),u())}function l(e){return new Promise(e).then(function(e){return b=!1,g.shift(),setTimeout(u,0),e},function(e){return b=!1,g.shift(),setTimeout(u,0),y.reject(e)})}function f(e){var t=this;y.classCallCheck(t,f),e||(e={}),y.fillIn(e,m),h.call(t,e)}var c=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=n(1),h=n(2),p=n(3),v=d.Query,y=d.utils,g=[],b=!1,A=h.prototype,m={basePath:"",debug:!1,storage:localStorage};f.prototype=Object.create(h.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(f,"__super__",{configurable:!0,value:h}),f.extend=y.extend,y.addHiddenPropsToTarget(f.prototype,{_count:function(e,t,n){var r=this;return r._findAll(e,t,n).then(function(e){return e[0]=e[0].length,e})},_createHelper:function(e,t,n){var r=this,o={},i=e.relationFields||[];y.forOwn(t,function(e,t){-1===i.indexOf(t)&&(o[t]=e)});var a=y.get(o,e.idAttribute)||p();y.set(o,e.idAttribute,a);var u=r.getIdPath(e,n,a);return r.storage.setItem(u,y.toJson(o)),r.ensureId(a,e,n),y.fromJson(r.storage.getItem(u))},_create:function(e,t,n){var r=this;return new Promise(function(o){return o([r._createHelper(e,t,n),{}])})},_createMany:function(e,t,n){var r=this;return new Promise(function(o){return t||(t=[]),o([t.map(function(t){return r._createHelper(e,t,n)}),{}])})},_destroy:function(e,t,n){var r=this;return new Promise(function(o){return r.storage.removeItem(r.getIdPath(e,n,t)),r.removeId(t,e,n),o([void 0,{}])})},_destroyAll:function(e,t,n){var r=this;return r._findAll(e,t).then(function(t){var o=c(t,1),i=o[0],a=e.idAttribute,u=i.map(function(e){return y.get(e,a)});return u.forEach(function(t){r.storage.removeItem(r.getIdPath(e,n,t))}),r.removeId(u,e,n),[void 0,{}]})},_find:function(e,t,n){var r=this;return new Promise(function(o){var i=r.getIdPath(e,n,t),a=r.storage.getItem(i);return o([a?y.fromJson(a):void 0,{}])})},_findAll:function(e,t,n){var r=this;return t||(t={}),new Promise(function(o){var i=[],a=r.getIds(e,n);y.forOwn(a,function(t,o){var a=r.storage.getItem(r.getIdPath(e,n,o));a&&i.push(y.fromJson(a))});var u=new v({index:{getAll:function(){return i}}});return o([u.filter(t).run(),{}])})},_sum:function(e,t,n,r){var o=this;return o._findAll(e,n,r).then(function(e){var n=0;return e[0].forEach(function(e){n+=y.get(e,t)||0}),e[0]=n,e})},_update:function(e,t,n,r){var o=this;return n||(n={}),new Promise(function(i,a){var u=o.getIdPath(e,r,t),s=o.storage.getItem(u);return s?(s=y.fromJson(s),y.deepMixIn(s,n),o.storage.setItem(u,y.toJson(s)),i([s,{}])):a(new Error("Not Found"))})},_updateAll:function(e,t,n,r){var o=this,i=e.idAttribute;return o._findAll(e,n,r).then(function(n){var a=c(n,1),u=a[0];return u.forEach(function(n){n||(n={});var a=y.get(n,i),u=o.getIdPath(e,r,a);y.deepMixIn(n,t),o.storage.setItem(u,y.toJson(n))}),[u,{}]})},_updateMany:function(e,t,n){var r=this;return t||(t=[]),new Promise(function(o){var i=[],a=e.idAttribute;return t.forEach(function(t){if(t){var o=y.get(t,a);if(!y.isUndefined(o)){var u=r.getIdPath(e,n,o),s=r.storage.getItem(u);if(s){var l=y.fromJson(s);y.deepMixIn(l,t),r.storage.setItem(u,y.toJson(l)),i.push(l)}}}}),o([t,{}])})},create:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.create.call(r,e,t,n).then(o,i)})})},createMany:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.createMany.call(r,e,t,n).then(o,i)})})},destroy:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.destroy.call(r,e,t,n).then(o,i)})})},destroyAll:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.destroyAll.call(r,e,t,n).then(o,i)})})},ensureId:function(e,t,n){var r=this.getIds(t,n);if(y.isArray(e)){if(!e.length)return;e.forEach(function(e){r[e]=1})}else r[e]=1;this.saveKeys(r,t,n)},getPath:function(e,t){return t=t||{},i(void 0===t.basePath?void 0===e.basePath?this.basePath:e.basePath:t.basePath,e.name)},getIdPath:function(e,t,n){return t=t||{},i(t.basePath||this.basePath||e.basePath,e.endpoint,n)},getIds:function(e,t){var n=void 0,r=this.getPath(e,t),o=this.storage.getItem(r);return n=o?y.fromJson(o):{}},removeId:function(e,t,n){var r=this.getIds(t,n);if(y.isArray(e)){if(!e.length)return;e.forEach(function(e){delete r[e]})}else delete r[e];this.saveKeys(r,t,n)},saveKeys:function(e,t,n){e=e||{};var r=this.getPath(t,n);Object.keys(e).length?this.storage.setItem(r,y.toJson(e)):this.storage.removeItem(r)},update:function(e,t,n,r){var o=this;return l(function(i,a){s(function(){A.update.call(o,e,t,n,r).then(i,a)})})},updateAll:function(e,t,n,r){var o=this;return l(function(i,a){s(function(){A.updateAll.call(o,e,t,n,r).then(i,a)})})},updateMany:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.updateMany.call(r,e,t,n).then(o,i)})})}}),f.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},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,l),t.utils.fillIn(n,e)}function r(e,n,r){var o=this;n||(n={}),o.data=e,t.utils.fillIn(o,n),o.op=r}var o={};o.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},o.slicedToArray=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var i=function(){for(var e=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-1];return e.dbg.apply(e,[i.op].concat(r)),t.utils.resolve()},a=function(){for(var e=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-2];return e.dbg.apply(e,[i.op].concat(r)),t.utils.resolve()},u=function(e){var t={},n=[];return e.forEach(function(e){e in t||(n.push(e),t[e]=0)}),n},s=function(e,n){return t.utils.omit(n,e.relationFields||[])},l={debug:!1,raw:!1};n.reserved=["orderBy","sort","limit","offset","skip","where"],n.Response=r,n.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(n.prototype,{afterCount:a,afterCreate:a,afterCreateMany:a,afterDestroy:a,afterDestroyAll:a,afterFind:a,afterFindAll:a,afterSum:a,afterUpdate:a,afterUpdateAll:a,afterUpdateMany:a,beforeCount:i,beforeCreate:i,beforeCreateMany:i,beforeDestroy:i,beforeDestroyAll:i,beforeFind:i,beforeFindAll:i,beforeSum:i,beforeUpdate:i,beforeUpdateAll:i,beforeUpdateMany:i,dbg:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},count:function(e,n,i){var a=this,u=void 0;return n||(n={}),i||(i={}),u=i.op="beforeCount",t.utils.resolve(a[u](e,n,i)).then(function(){return u=i.op="count",a.dbg(u,e,n,i),t.utils.resolve(a._count(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new r(f,c,u);return d=a.respond(d,i),u=i.op="afterCount",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},create:function(e,n,i){var a=this,u=void 0;return n||(n={}),i||(i={}),u=i.op="beforeCreate",t.utils.resolve(a[u](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=s(e,n),u=i.op="create",a.dbg(u,e,n,i),t.utils.resolve(a._create(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new r(f,c,"create");return d.created=f?1:0,d=a.respond(d,i),u=i.op="afterCreate",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},createMany:function(e,n,i){var a=this,u=void 0;return n||(n={}),i||(i={}),u=i.op="beforeCreateMany",t.utils.resolve(a[u](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),u=i.op="createMany",a.dbg(u,e,n,i),t.utils.resolve(a._createMany(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];f||(f=[]),c||(c={});var d=new r(f,c,"createMany");return d.created=f.length,d=a.respond(d,i),u=i.op="afterCreateMany",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroy:function(e,n,i){var a=this,u=void 0;return i||(i={}),u=i.op="beforeDestroy",t.utils.resolve(a[u](e,n,i)).then(function(){return u=i.op="destroy",a.dbg(u,e,n,i),t.utils.resolve(a._destroy(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new r(f,c,"destroy");return d=a.respond(d,i),u=i.op="afterDestroy",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroyAll:function(e,n,i){var a=this,u=void 0;return n||(n={}),i||(i={}),u=i.op="beforeDestroyAll",t.utils.resolve(a[u](e,n,i)).then(function(){return u=i.op="destroyAll",a.dbg(u,e,n,i),t.utils.resolve(a._destroyAll(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new r(f,c,"destroyAll");return d=a.respond(d,i),u=i.op="afterDestroyAll",t.utils.resolve(a[u](e,n,i,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 o=[],i=t.utils.get(r,n.localKeys)||[];return i=t.utils.isArray(i)?i:Object.keys(i),o=o.concat(i),u(o).filter(function(e){return e})},makeHasManyForeignKeys:function(e,n,r){return t.utils.get(r,e.idAttribute)},loadHasMany:function(e,n,r,o){var i=this,a=!1;t.utils.isObject(r)&&!t.utils.isArray(r)&&(a=!0,r=[r]);var u=r.map(function(t){return i.makeHasManyForeignKey(e,n,t)}),s={where:{}},l=s.where[n.foreignKey]={};return a?l["=="]=u[0]:l.in=u.filter(function(e){return e}),i.findAll(n.getRelation(),s,o).then(function(o){r.forEach(function(r){var i=[];a?i=o:o.forEach(function(o){t.utils.get(o,n.foreignKey)===r[e.idAttribute]&&i.push(o)}),n.setLocalField(r,i)})})},loadHasManyLocalKeys:function(e,n,r,i){var a=this,s=void 0,l=n.getRelation();if(t.utils.isObject(r)&&!t.utils.isArray(r)&&(s=r),s)return a.findAll(l,{where:o.defineProperty({},l.idAttribute,{in:a.makeHasManyLocalKeys(e,n,s)})},i).then(function(e){n.setLocalField(s,e)});var f=function(){var s=[];return r.forEach(function(t){s=s.concat(a.self.makeHasManyLocalKeys(e,n,t))}),{v:a.findAll(l,{where:o.defineProperty({},l.idAttribute,{in:u(s).filter(function(e){return e})})},i).then(function(e){return r.forEach(function(r){var o=[],i=t.utils.get(r,n.localKeys)||[];i=t.utils.isArray(i)?i:Object.keys(i),e.forEach(function(e){i&&-1!==i.indexOf(e[l.idAttribute])&&o.push(e)}),n.setLocalField(r,o)}),e})}}();return"object"===("undefined"==typeof f?"undefined":o.typeof(f))?f.v:void 0},loadHasManyForeignKeys:function(e,n,r,i){var a=this,u=n.getRelation(),s=e.idAttribute,l=void 0;return t.utils.isObject(r)&&!t.utils.isArray(r)&&(l=r),l?a.findAll(n.getRelation(),{where:o.defineProperty({},n.foreignKeys,{contains:a.makeHasManyForeignKeys(e,n,l)})},i).then(function(e){n.setLocalField(l,e)}):a.findAll(u,{where:o.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(t){return a.makeHasManyForeignKeys(e,n,t)})})},i).then(function(e){var o=n.foreignKeys;r.forEach(function(r){var i=[],a=t.utils.get(r,s);e.forEach(function(n){var r=t.utils.get(e,o)||[];-1!==r.indexOf(a)&&i.push(n)}),n.setLocalField(r,i)})})},loadHasOne:function(e,n,r,o){return t.utils.isObject(r)&&!t.utils.isArray(r)&&(r=[r]),this.loadHasMany(e,n,r,o).then(function(){r.forEach(function(e){var r=n.getLocalField(e);t.utils.isArray(r)&&r.length&&n.setLocalField(e,r[0])})})},makeBelongsToForeignKey:function(e,t,n){return t.getForeignKey(n)},loadBelongsTo:function(e,n,r,i){var a=this,u=n.getRelation();if(!t.utils.isObject(r)||t.utils.isArray(r)){var s=r.map(function(t){return a.makeBelongsToForeignKey(e,n,t)}).filter(function(e){return e});return a.findAll(u,{where:o.defineProperty({},u.idAttribute,{in:s})},i).then(function(e){r.forEach(function(t){e.forEach(function(e){e[u.idAttribute]===t[n.foreignKey]&&n.setLocalField(t,e)})})})}var l=function(){var t=r;return{v:a.find(u,a.makeBelongsToForeignKey(e,n,t),i).then(function(e){n.setLocalField(t,e)})}}();return"object"===("undefined"==typeof l?"undefined":o.typeof(l))?l.v:void 0},find:function(e,n,i){var a=this,u=void 0,s=void 0;return i||(i={}),i.with||(i.with=[]),s=i.op="beforeFind",t.utils.resolve(a[s](e,n,i)).then(function(){return s=i.op="find",a.dbg(s,e,n,i),t.utils.resolve(a._find(e,n,i))}).then(function(n){var r=o.slicedToArray(n,1),s=r[0];if(s){u=s;var l=[];return t.utils.forEachRelation(e,i,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=a.loadHasManyLocalKeys(e,t,u,n):"hasMany"===t.type&&t.foreignKeys?r=a.loadHasManyForeignKeys(e,t,u,n):"belongsTo"===t.type&&(r=a.loadBelongsTo(e,t,u,n)):r="hasOne"===t.type?a.loadHasOne(e,t,u,n):a.loadHasMany(e,t,u,n),r&&l.push(r)}),Promise.all(l)}}).then(function(){var o=new r(u,{},"find");return o.found=u?1:0,o=a.respond(o,i),s=i.op="afterFind",t.utils.resolve(a[s](e,n,i,o)).then(function(e){return t.utils.isUndefined(e)?o:e})})},findAll:function(e,n,i){var a=this;i||(i={}),i.with||(i.with=[]);var u=[],s=void 0,l=i._activeWith;if(t.utils.isObject(l)){var f=l.query||{};l.replace?n=f:t.utils.deepFillIn(n,f)}return s=i.op="beforeFindAll",t.utils.resolve(a[s](e,n,i)).then(function(){return s=i.op="findAll",a.dbg(s,e,n,i),t.utils.resolve(a._findAll(e,n,i))}).then(function(n){var r=o.slicedToArray(n,1),s=r[0];s||(s=[]),u=s;var l=[];return t.utils.forEachRelation(e,i,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=a.loadHasManyLocalKeys(e,t,u,n):"hasMany"===t.type&&t.foreignKeys?r=a.loadHasManyForeignKeys(e,t,u,n):"belongsTo"===t.type&&(r=a.loadBelongsTo(e,t,u,n)):r="hasMany"===t.type?a.loadHasMany(e,t,u,n):a.loadHasOne(e,t,u,n),r&&l.push(r)}),Promise.all(l)}).then(function(){var o=new r(u,{},"findAll");return o.found=u.length,o=a.respond(o,i),s=i.op="afterFindAll",t.utils.resolve(a[s](e,n,i,o)).then(function(e){return t.utils.isUndefined(e)?o:e})})},getOpt:function(e,n){return n||(n={}),t.utils.isUndefined(n[e])?t.utils.plainCopy(this[e]):t.utils.plainCopy(n[e])},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var o=e.toUpperCase()+": (Adapter)";if(console[e]){var i;(i=console)[e].apply(i,[o].concat(n))}else{var a;(a=console).log.apply(a,[o].concat(n))}}},sum:function(e,n,i,a){var u=this,s=void 0;if(!t.utils.isString(n))throw new Error("field must be a string!");return i||(i={}),a||(a={}),s=a.op="beforeSum",t.utils.resolve(u[s](e,n,i,a)).then(function(){return s=a.op="sum",u.dbg(s,e,n,i,a),t.utils.resolve(u._sum(e,n,i,a))}).then(function(l){var f=o.slicedToArray(l,2),c=f[0],d=f[1];d||(d={});var h=new r(c,d,s);return h=u.respond(h,a),s=a.op="afterSum",t.utils.resolve(u[s](e,n,i,a,h)).then(function(e){return t.utils.isUndefined(e)?h:e})})},respond:function(e,t){return this.getOpt("raw",t)?e:e.data},update:function(e,n,i,a){var u=this;i||(i={}),a||(a={});var s=void 0;return s=a.op="beforeUpdate",t.utils.resolve(u[s](e,n,i,a)).then(function(r){return i=t.utils.isUndefined(r)?i:r,s=a.op="update",u.dbg(s,e,n,i,a),t.utils.resolve(u._update(e,n,i,a))}).then(function(l){var f=o.slicedToArray(l,2),c=f[0],d=f[1];d||(d={});var h=new r(c,d,"update");return h.updated=c?1:0,h=u.respond(h,a),s=a.op="afterUpdate",t.utils.resolve(u[s](e,n,i,a,h)).then(function(e){return t.utils.isUndefined(e)?h:e})})},updateAll:function(e,n,i,a){var u=this;n||(n={}),i||(i={}),a||(a={});var s=void 0;return s=a.op="beforeUpdateAll",t.utils.resolve(u[s](e,n,i,a)).then(function(r){return n=t.utils.isUndefined(r)?n:r,s=a.op="updateAll",u.dbg(s,e,n,i,a),t.utils.resolve(u._updateAll(e,n,i,a))}).then(function(l){var f=o.slicedToArray(l,2),c=f[0],d=f[1];c||(c=[]),d||(d={});var h=new r(c,d,"updateAll");return h.updated=c.length,h=u.respond(h,a),s=a.op="afterUpdateAll",t.utils.resolve(u[s](e,n,i,a,h)).then(function(e){return t.utils.isUndefined(e)?h:e})})},updateMany:function(e,n,i){var a=this;n||(n=[]),i||(i={});var u=void 0,l=e.idAttribute;return n=n.filter(function(e){return t.utils.get(e,l)}),u=i.op="beforeUpdateMany",t.utils.resolve(a[u](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),u=i.op="updateMany",a.dbg(u,e,n,i),t.utils.resolve(a._updateMany(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];f||(f=[]),c||(c={});var d=new r(f,c,"updateMany");return d.updated=f.length,d=a.respond(d,i),u=i.op="afterUpdateMany",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})}}),e.exports=n})},function(e,t,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+i(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(4),i=n(5);e.exports=r},function(e,t,n){function r(e){e=e&&e>0?e:6;for(var t="";e--;)t+=o(i);return t}var o=n(5),i="0123456789abcdef".split("");e.exports=r},function(e,t,n){function r(e){var t=1===arguments.length&&i(e)?e:arguments;return t[o(0,t.length-1)]}var o=n(6),i=n(11);e.exports=r},function(e,t,n){function r(e,t){return e=null==e?o:~~e,t=null==t?i:~~t,Math.round(a(e-.5,t+.499999999999))}var o=n(7),i=n(8),a=n(9);e.exports=r},function(e,t){e.exports=-2147483648},function(e,t){e.exports=2147483647},function(e,t,n){function r(e,t){return e=null==e?i:e,t=null==t?a:t,e+(t-e)*o()}var o=n(10),i=n(7),a=n(8);e.exports=r},function(e,t){function n(){return n.get()}n.get=Math.random,e.exports=n},function(e,t,n){var r=n(12),o=Array.isArray||function(e){return r(e,"Array")};e.exports=o},function(e,t,n){function r(e,t){return o(e)===t}var o=n(13);e.exports=r},function(e,t){function n(e){return null===e?"Null":e===r?"Undefined":o.exec(i.call(e))[1]}var r,o=/^\[object (.*)\]$/,i=Object.prototype.toString;e.exports=n}])}); +//# sourceMappingURL=js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index b033f9a..4f36720 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","enqueue","task","queue","push","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","opts","self","fillIn","DEFAULTS","Adapter","_slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","Symbol","iterator","next","done","isArray","Object","TypeError","JSData","guid","Query","utils","addHiddenPropsToTarget","deepMixIn","extend","forOwn","fromJson","get","isUndefined","set","toJson","__super__","prototype","basePath","debug","storage","localStorage","create","constructor","enumerable","writable","configurable","defineProperty","_createHelper","mapper","props","_props","relationFields","key","indexOf","idAttribute","getIdPath","setItem","ensureId","getItem","_create","resolve","_createMany","map","_destroy","removeItem","removeId","_destroyAll","query","_findAll","results","_results","records","ids","record","forEach","_find","getIds","json","_query","index","getAll","run","_update","Error","_updateAll","_results2","_updateMany","updatedRecords","existingRecord","success","failure","createMany","destroy","destroyAll","_id","saveKeys","getPath","name","endpoint","idsPath","idsJson","keys","update","updateAll","updateMany","version","full","major","parseInt","minor","patch","alpha","beta","global","jsData","Response","data","meta","op","babelHelpers","typeof","obj","slicedToArray","forEachRelation","isObject","omit","plainCopy","noop","dbg","apply","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","raw","reserved","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","log","response","created","respond","_response","_results3","_results4","makeHasManyForeignKey","def","getForeignKey","makeHasManyLocalKeys","localKeys","itemKeys","x","makeHasManyForeignKeys","loadHasMany","__opts","singular","IDs","where","criteria","foreignKey","findAll","getRelation","relatedItems","attached","relatedItem","setLocalField","loadHasManyLocalKeys","relatedMapper","in","_ret","v","loadHasManyForeignKeys","foreignKeys","contains","isectNotEmpty","foreignKeysField","_relatedItems","loadHasOne","relatedData","getLocalField","makeBelongsToForeignKey","loadBelongsTo","relationDef","_ret2","find","with","_results5","_record","tasks","type","all","found","_results6","_records","getOpt","opt","level","_len4","_key4","prefix","toUpperCase","console","_console","_console2","_results7","updated","_results8","_results9","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAyBA,SAASS,GAAcC,GACrB,MAAgB,OAATA,GAA2B,KAAVA,EAE1B,QAASC,GAAKC,EAAOC,GAEnB,MADAA,KAAcA,EAAY,IACnBD,EAAME,OAAOL,GAAeE,KAAK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],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","enqueue","task","queue","push","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","utils","reject","LocalStorageAdapter","opts","self","classCallCheck","fillIn","DEFAULTS","Adapter","_slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","Symbol","iterator","next","done","isArray","Object","TypeError","JSData","guid","Query","__super__","prototype","basePath","debug","storage","localStorage","create","constructor","enumerable","writable","configurable","defineProperty","extend","addHiddenPropsToTarget","_count","mapper","query","_findAll","_createHelper","props","_props","relationFields","forOwn","key","indexOf","get","idAttribute","set","getIdPath","setItem","toJson","ensureId","fromJson","getItem","_create","resolve","_createMany","map","_destroy","removeItem","removeId","_destroyAll","results","_results","records","ids","record","forEach","_find","getIds","json","_query","index","getAll","run","_sum","field","sum","_update","deepMixIn","Error","_updateAll","_results2","_updateMany","updatedRecords","isUndefined","existingRecord","success","failure","createMany","destroy","destroyAll","_id","saveKeys","getPath","name","endpoint","idsPath","idsJson","keys","update","updateAll","updateMany","version","full","major","parseInt","minor","patch","alpha","beta","global","jsData","Response","data","meta","op","babelHelpers","typeof","obj","slicedToArray","noop","dbg","apply","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","omit","raw","reserved","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","log","count","response","respond","_response","created","_results3","_results4","_results5","makeHasManyForeignKey","def","getForeignKey","makeHasManyLocalKeys","localKeys","itemKeys","x","makeHasManyForeignKeys","loadHasMany","__opts","singular","isObject","IDs","where","criteria","foreignKey","findAll","getRelation","relatedItems","attached","relatedItem","setLocalField","loadHasManyLocalKeys","relatedMapper","in","_ret","v","loadHasManyForeignKeys","foreignKeys","contains","isectNotEmpty","foreignKeysField","_relatedItems","loadHasOne","relatedData","getLocalField","makeBelongsToForeignKey","loadBelongsTo","relationDef","_ret2","find","with","_results6","_record","tasks","forEachRelation","type","all","found","activeWith","_activeWith","activeQuery","deepFillIn","_results7","_records","getOpt","opt","plainCopy","level","_len4","_key4","prefix","toUpperCase","console","_console","_console2","isString","_results8","_results9","updated","_results10","_results11","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ,GACM,gBAAZC,SACdA,QAA6B,oBAAID,EAAQG,QAAQ,YAEjDJ,EAA0B,oBAAIC,EAAQD,EAAa,SAClDO,KAAM,SAASC,GAClB,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUT,OAGnC,IAAIC,GAASS,EAAiBD,IAC7BT,WACAW,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKZ,EAAOD,QAASC,EAAQA,EAAOD,QAASQ,GAG/DP,EAAOW,QAAS,EAGTX,EAAOD,QAvBf,GAAIU,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASP,EAAQD,EAASQ,GAE/B,YAaA,SAASS,GAAcC,GACrB,MAAgB,OAATA,GAA2B,KAAVA,EAE1B,QAASC,GAAKC,EAAOC,GAEnB,MADAA,KAAcA,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QAAU,YAMhB,SAASC,EAAQD,EAASQ,GAS3B,QAASgT,GAAKN,EAAKC,GAGf,MAFAD,GAAa,MAAPA,EAAaE,EAAUF,EAC7BC,EAAa,MAAPA,EAAaE,EAAUF,EACtBD,GAAOC,EAAMD,GAAOO,IAVnC,GAAIA,GAASjT,EAAoB,IAC7B4S,EAAU5S,EAAoB,GAC9B6S,EAAU7S,EAAoB,EAW9BP,GAAOD,QAAUwT,GAMhB,SAASvT,EAAQD,GAUlB,QAASyT,KACL,MAAOA,GAAOpN,MAIlBoN,EAAOpN,IAAMiN,KAAKG,OAElBxT,EAAOD,QAAUyT,GAOhB,SAASxT,EAAQD,EAASQ,GAE/B,GAAIkT,GAASlT,EAAoB,IAGzB8D,EAAU1C,MAAM0C,SAAW,SAAUqP,GACrC,MAAOD,GAAOC,EAAK,SAEvB1T,GAAOD,QAAUsE,GAMhB,SAASrE,EAAQD,EAASQ,GAM3B,QAASkT,GAAOC,EAAKC,GACjB,MAAOC,GAAOF,KAASC,EAL/B,GAAIC,GAASrT,EAAoB,GAO7BP,GAAOD,QAAU0T,GAMhB,SAASzT,EAAQD,GAWlB,QAAS6T,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAUpT,KAAK8S,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAY1P,OAAOM,UAAUqP,QAejCjU,GAAOD,QAAU6T","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index e4e87e1..dc0cdf7 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -38,24 +38,19 @@ if (process.env.BROWSERSTACK_USERNAME && process.env.BROWSERSTACK_ACCESS_KEY) { module.exports = function (config) { config.set({ - // base path, that will be used to resolve files and exclude basePath: './', frameworks: ['chai', 'mocha', 'sinon'], plugins: [ - // these plugins will be require() by Karma 'karma-chai', 'karma-mocha', 'karma-sinon', 'karma-phantomjs-launcher', 'karma-coverage', - 'karma-browserstack-launcher', - 'karma-junit-reporter' + 'karma-browserstack-launcher' ], autoWatch: false, autoWatchBatchDelay: 4000, browsers: browsers, - - // list of files / patterns to load in the browser files: [ 'node_modules/babel-polyfill/dist/polyfill.js', 'node_modules/js-data/dist/js-data.js', @@ -63,14 +58,10 @@ module.exports = function (config) { 'node_modules/js-data-adapter-tests/dist/js-data-adapter-tests.js', 'karma.start.js' ], - - reporters: ['dots', 'coverage', 'junit'], - + reporters: ['dots', 'coverage'], preprocessors: { 'dist/js-data-localstorage.js': ['coverage'] }, - - // optionally, configure the reporter coverageReporter: { type: 'lcov', dir: 'coverage/', @@ -78,41 +69,17 @@ module.exports = function (config) { istanbul: { noCompact: true } } }, - - // the default configuration - junitReporter: { - outputDir: process.env.CIRCLE_TEST_REPORTS || 'junit', - outputFile: undefined, - suite: 'js-data-localstorage', - useBrowserName: false - }, - browserStack: { username: process.env.BROWSERSTACK_USERNAME, accessKey: process.env.BROWSERSTACK_ACCESS_KEY }, - customLaunchers: customLaunchers, - browserNoActivityTimeout: 90000, - - // 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: 90000, - - // Continuous Integration mode - // if true, it capture browsers, run tests and exit singleRun: true }) } diff --git a/package.json b/package.json index 7da4061..62f7562 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "version": "3.0.0-alpha.6", + "version": "3.0.0-alpha.7", "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", @@ -35,9 +35,9 @@ }, "scripts": { "bundle": "webpack --config webpack.config.js --colors", - "doc": "jsdoc -c conf.json src && node scripts/cleanup.js", + "doc": "jsdoc -c conf.json src node_modules/js-data-adapter/src && node scripts/cleanup.js", "lint": "repo-tools lint src/**/*.js karma.start.js karma.conf.js scripts/*.js", - "min": "uglifyjs dist/js-data-localstorage.js -o dist/js-data-localstorage.min.js --source-map dist/js-data-localstorage.min.map -v -m -c --screw-ie8", + "min": "uglifyjs dist/js-data-localstorage.js -o dist/js-data-localstorage.min.js --source-map dist/js-data-localstorage.min.map --source-map-url js-data-localstorage.min.map -v -m -c --screw-ie8", "version": "node scripts/version.js", "banner": "node scripts/banner.js", "gzip": "echo gzipped size: $(cat dist/js-data-localstorage.min.js | gzip -f9 | wc -c)kb", @@ -50,25 +50,24 @@ "ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | coveralls || true" }, "peerDependencies": { - "js-data": "^3.0.0-alpha.16" + "js-data": "^3.0.0-alpha.19" }, "devDependencies": { - "babel-core": "6.7.0", + "babel-core": "6.7.2", "babel-loader": "6.2.4", - "babel-polyfill": "6.6.1", + "babel-polyfill": "6.7.2", "babel-preset-es2015": "6.6.0", "chai": "3.5.0", "coveralls": "2.11.8", "ink-docstrap": "1.1.4", - "js-data-adapter": "0.2.1", - "js-data-adapter-tests": "^2.0.0-alpha.14", + "js-data-adapter": "0.2.4", + "js-data-adapter-tests": "^2.0.0-alpha.16", "js-data-repo-tools": "^0.2.0", "jsdoc": "3.4.0", "karma": "0.13.22", "karma-browserstack-launcher": "0.1.10", "karma-chai": "0.1.0", "karma-coverage": "0.5.5", - "karma-junit-reporter": "0.3.8", "karma-mocha": "0.2.2", "karma-phantomjs-launcher": "1.0.0", "karma-sinon": "1.0.4", diff --git a/src/index.js b/src/index.js index fa6de2b..1804237 100644 --- a/src/index.js +++ b/src/index.js @@ -8,21 +8,6 @@ const { utils } = JSData -const { - addHiddenPropsToTarget, - deepMixIn, - extend, - fillIn, - forOwn, - fromJson, - get, - isArray, - isUndefined, - reject, - set, - toJson -} = utils - function isValidString (value) { return (value != null && value !== '') } @@ -67,7 +52,7 @@ function createTask (fn) { taskInProcess = false queue.shift() setTimeout(dequeue, 0) - return reject(err) + return utils.reject(err) }) } @@ -119,8 +104,9 @@ const DEFAULTS = { */ function LocalStorageAdapter (opts) { const self = this + utils.classCallCheck(self, LocalStorageAdapter) opts || (opts = {}) - fillIn(opts, DEFAULTS) + utils.fillIn(opts, DEFAULTS) Adapter.call(self, opts) } @@ -150,27 +136,47 @@ Object.defineProperty(LocalStorageAdapter, '__super__', { * properties to the subclass itself. * @return {Object} Subclass of `LocalStorageAdapter`. */ -LocalStorageAdapter.extend = extend +LocalStorageAdapter.extend = utils.extend + +utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { + /** + * Retrieve the number of records that match the selection query. Internal + * method used by Adapter#count. + * + * @name LocalStorageAdapter#_count + * @method + * @private + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _count (mapper, query, opts) { + const self = this + return self._findAll(mapper, query, opts).then(function (result) { + result[0] = result[0].length + return result + }) + }, -addHiddenPropsToTarget(LocalStorageAdapter.prototype, { _createHelper (mapper, props, opts) { const self = this const _props = {} const relationFields = mapper.relationFields || [] - forOwn(props, function (value, key) { + utils.forOwn(props, function (value, key) { if (relationFields.indexOf(key) === -1) { _props[key] = value } }) - const id = get(_props, mapper.idAttribute) || guid() - set(_props, mapper.idAttribute, id) + const id = utils.get(_props, mapper.idAttribute) || guid() + utils.set(_props, mapper.idAttribute, id) const key = self.getIdPath(mapper, opts, id) // Create the record // TODO: Create related records when the "with" option is provided - self.storage.setItem(key, toJson(_props)) + self.storage.setItem(key, utils.toJson(_props)) self.ensureId(id, mapper, opts) - return fromJson(self.storage.getItem(key)) + return utils.fromJson(self.storage.getItem(key)) }, /** @@ -253,7 +259,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { const idAttribute = mapper.idAttribute // Gather IDs of records to be destroyed const ids = records.map(function (record) { - return get(record, idAttribute) + return utils.get(record, idAttribute) }) // Destroy each record ids.forEach(function (id) { @@ -281,7 +287,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { return new Promise(function (resolve) { const key = self.getIdPath(mapper, opts, id) const record = self.storage.getItem(key) - return resolve([record ? fromJson(record) : undefined, {}]) + return resolve([record ? utils.fromJson(record) : undefined, {}]) }) }, @@ -304,10 +310,10 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { // Load all records into memory... let records = [] const ids = self.getIds(mapper, opts) - forOwn(ids, function (value, id) { + utils.forOwn(ids, function (value, id) { const json = self.storage.getItem(self.getIdPath(mapper, opts, id)) if (json) { - records.push(fromJson(json)) + records.push(utils.fromJson(json)) } }) const _query = new Query({ @@ -321,6 +327,31 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { }) }, + /** + * Retrieve the number of records that match the selection query. Internal + * method used by Adapter#sum. + * + * @name LocalStorageAdapter#_sum + * @method + * @private + * @param {Object} mapper The mapper. + * @param {string} field The field to sum. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _sum (mapper, field, query, opts) { + const self = this + return self._findAll(mapper, query, opts).then(function (result) { + let sum = 0 + result[0].forEach(function (record) { + sum += utils.get(record, field) || 0 + }) + result[0] = sum + return result + }) + }, + /** * Apply the given update to the record with the specified primary key. * Internal method used by Adapter#update. @@ -343,9 +374,9 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { if (!record) { return reject(new Error('Not Found')) } - record = fromJson(record) - deepMixIn(record, props) - self.storage.setItem(key, toJson(record)) + record = utils.fromJson(record) + utils.deepMixIn(record, props) + self.storage.setItem(key, utils.toJson(record)) return resolve([record, {}]) }) }, @@ -370,10 +401,10 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { let [records] = results records.forEach(function (record) { record || (record = {}) - const id = get(record, idAttribute) + const id = utils.get(record, idAttribute) const key = self.getIdPath(mapper, opts, id) - deepMixIn(record, props) - self.storage.setItem(key, toJson(record)) + utils.deepMixIn(record, props) + self.storage.setItem(key, utils.toJson(record)) }) return [records, {}] }) @@ -401,8 +432,8 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { if (!record) { return } - const id = get(record, idAttribute) - if (isUndefined(id)) { + const id = utils.get(record, idAttribute) + if (utils.isUndefined(id)) { return } const key = self.getIdPath(mapper, opts, id) @@ -410,9 +441,9 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { if (!json) { return } - const existingRecord = fromJson(json) - deepMixIn(existingRecord, record) - self.storage.setItem(key, toJson(existingRecord)) + const existingRecord = utils.fromJson(json) + utils.deepMixIn(existingRecord, record) + self.storage.setItem(key, utils.toJson(existingRecord)) updatedRecords.push(existingRecord) }) return resolve([records, {}]) @@ -463,7 +494,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { */ ensureId (id, mapper, opts) { const ids = this.getIds(mapper, opts) - if (isArray(id)) { + if (utils.isArray(id)) { if (!id.length) { return } @@ -509,7 +540,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { const idsPath = this.getPath(mapper, opts) const idsJson = this.storage.getItem(idsPath) if (idsJson) { - ids = fromJson(idsJson) + ids = utils.fromJson(idsJson) } else { ids = {} } @@ -524,7 +555,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { */ removeId (id, mapper, opts) { const ids = this.getIds(mapper, opts) - if (isArray(id)) { + if (utils.isArray(id)) { if (!id.length) { return } @@ -547,7 +578,7 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, { ids = ids || {} const idsPath = this.getPath(mapper, opts) if (Object.keys(ids).length) { - this.storage.setItem(idsPath, toJson(ids)) + this.storage.setItem(idsPath, utils.toJson(ids)) } else { this.storage.removeItem(idsPath) } From b76d366604cab89d99978123a01446689e99f06e Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sat, 30 Apr 2016 22:19:24 -0700 Subject: [PATCH 12/15] Prepare for 3.0.0-beta.1 --- .babelrc | 3 - .npmignore | 34 - AUTHORS | 8 +- CHANGELOG.md | 33 + CONTRIBUTORS | 9 +- README.md | 96 +- circle.yml | 5 +- conf.json | 5 +- dist/js-data-localstorage.d.ts | 24 + dist/js-data-localstorage.js | 5099 ++++++++++++++--------------- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 4 +- dist/js-data-localstorage.min.map | 2 +- karma.start.js | 11 +- package.json | 67 +- rollup.config.js | 27 + scripts/AUTHORS | 7 - scripts/CONTRIBUTORS | 6 - scripts/authors.js | 46 - scripts/cleanup.js | 25 - scripts/version.js | 39 - src/index.js | 222 +- webpack.config.js | 32 - 23 files changed, 2762 insertions(+), 3044 deletions(-) delete mode 100644 .babelrc delete mode 100644 .npmignore create mode 100644 dist/js-data-localstorage.d.ts create mode 100644 rollup.config.js delete mode 100644 scripts/AUTHORS delete mode 100644 scripts/CONTRIBUTORS delete mode 100644 scripts/authors.js delete mode 100644 scripts/cleanup.js delete mode 100644 scripts/version.js delete mode 100644 webpack.config.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index c13c5f6..0000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["es2015"] -} diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 57378b4..0000000 --- a/.npmignore +++ /dev/null @@ -1,34 +0,0 @@ -lib-cov -*.seed -*.log -*.csv -*.dat -*.out -*.pid -*.gz - -pids -logs -results - -npm-debug.log -node_modules - -coverage/ -doc/ -bower_components/ - -*.iml -.idea/ -bs.jpg -*.png -CONTRIBUTING.md -favicon.ico -circle.yml -bower.json -*.start.js -karma.conf.js -test/ -src/ -junit/ -doc/ \ No newline at end of file diff --git a/AUTHORS b/AUTHORS index e8445ca..a988233 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,8 +1,8 @@ -# This is the official list of js-data-localstorage project authors. -# -# This file is controlled by scripts/authors.js +# This is the official list of js-data-rethinkdb project authors. # # Names are formatted as: -# # commits Name or Organization +# Name or Organization +# # The email address is not required for organizations. +# Jason Dobry diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fceaf5..7e405f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,36 @@ +##### 3.0.0-beta.1 - 30 April 2016 + +Official v3 beta release + +###### Breaking changes +- How you must now import in ES2015: + + ```js + import LocalStorageAdapter from 'js-data-localstorage' + const adapter = new LocalStorageAdapter() + ``` + or + ```js + import {LocalStorageAdapter, version} from 'js-data-localstorage' + console.log(version) + const adapter = new LocalStorageAdapter() + ``` + +- How you must now import in ES5: + + ```js + var JSDataLocalStorage = require('js-data-localstorage') + var LocalStorageAdapter = JSDataLocalStorage.LocalStorageAdapter + var adapter = new LocalStorageAdapter() + ``` + +- Moved some `dist` files to `release` to reduce noise + +###### Other +- Upgraded dependencies +- Improved JSDoc comments +- Now using js-data JSDoc template + ##### 3.0.0-alpha.7 - 18 March 2016 ###### Backwards compatible API changes diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f3acb83..8a31d26 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,7 +1,6 @@ -# People who have contributed to the js-data-localstorage project. +# This is the official list of js-data-rethinkdb 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 - 63 Jason Dobry +Jason Dobry diff --git a/README.md b/README.md index f658e34..a1d3648 100644 --- a/README.md +++ b/README.md @@ -7,88 +7,23 @@ [![Circle CI][circle_b]][circle_l] [![npm downloads][dn_b]][dn_l] [![Coverage Status][cov_b]][cov_l] -[![Codacy][cod_b]][cod_l] localStorage adapter for [js-data](http://www.js-data.io/). +To get started, visit __[http://js-data.io](http://www.js-data.io/docs/js-data-localstorage)__. + Tested on IE9, Chrome 46, Firefox 41 & Safari 7.1 using bs logo -## Table of contents - -* [Quick start](#quick-start) -* [Guides and Tutorials](#guides-and-tutorials) -* [API Reference](#api-reference) -* [Demo](#demo) -* [Support](#support) -* [Community](#community) -* [Contributing](#contributing) -* [License](#license) - -## Quick Start - -`npm install --save js-data js-data-localstorage` or `bower install --save js-data js-data-localstorage`. - -Load `js-data-localstorage.js` after `js-data.js`. - -```js -var adapter = new LocalStorageAdapter(); - -var store = new JSData.DataStore(); -store.registerAdapter('localstorage', adapter, { default: true }); - -// "store" will now use the localstorage adapter -``` - -You can also provide a custom storage medium (it just needs to implement the `localStorage` API): - -```js -var memory = {}; - -// Turn js-data-localstorage into an in-memory adapter -var memoryAdapter = new LocalStorageAdapter({ - storage: { - getItem: function (key) { - return memory[key]; - }, - setItem: function (key, value) { - return memory[key] = value; - }, - removeItem: function (key) { - delete memory[key]; - } - } -}); - -// Turn js-data-localstorage into a sessionStorage adapter -var sessionAdapter = new LocalStorageAdapter({ - storage: sessionStorage -}); -``` - -## 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). - -## Demo - -https://js-data-localstorage.firebaseapp.com/ - -## Community - -[Explore the Community](http://js-data.io/docs/community). - -## Support - -[Find out how to Get Support](http://js-data.io/docs/support). - -## Contributing +## Links -[Read the Contributing Guide](http://js-data.io/docs/contributing). +* [Quick start](http://www.js-data.io/docs/home#quick-start) - Get started in 5 minutes +* [Guides and Tutorials](http://www.js-data.io/docs/home) - Learn how to use JSData +* [`LocalStorageAdapter` Guide](http://www.js-data.io/docs/js-data-localstorage) - Learn how to use `LocalStorageAdapter` +* [API Reference Docs](http://api.js-data.io) - Explore components, methods, options, etc. +* [Community & Support](http://js-data.io/docs/community) - Find solutions and chat with the community +* [General Contributing Guide](http://js-data.io/docs/contributing) - Give back and move the project forward + * [Contributing to js-data-localstorage](https://github.com/js-data/js-data-localstorage/blob/master/.github/CONTRIBUTING.md) ## License @@ -104,12 +39,9 @@ Copyright (c) 2014-2016 js-data-http project authors [sl_l]: http://slack.js-data.io [npm_b]: https://img.shields.io/npm/v/js-data-localstorage.svg?style=flat [npm_l]: https://www.npmjs.org/package/js-data-localstorage -[circle_b]: https://img.shields.io/circleci/project/js-data/js-data-localstorage/master.svg?style=flat -[circle_l]: https://circleci.com/gh/js-data/js-data-localstorage/tree/master +[circle_b]: https://img.shields.io/circleci/project/js-data/js-data-localstorage.svg?style=flat +[circle_l]: https://circleci.com/gh/js-data/js-data-localstorage [dn_b]: https://img.shields.io/npm/dm/js-data-localstorage.svg?style=flat [dn_l]: https://www.npmjs.org/package/js-data-localstorage -[cov_b]: https://img.shields.io/coveralls/js-data/js-data-localstorage/master.svg?style=flat -[cov_l]: https://coveralls.io/github/js-data/js-data-localstorage?branch=master -[cod_b]: https://img.shields.io/codacy/b8e46008e6ad45159b7a6927dbfd66c3.svg -[cod_l]: https://www.codacy.com/app/jasondobry/js-data-localstorage/dashboard -[so]: http://stackoverflow.com/questions/tagged/jsdata +[cov_b]: https://img.shields.io/codecov/c/github/js-data/js-data-localstorage.svg?style=flat +[cov_l]: https://codecov.io/github/js-data/js-data-localstorage diff --git a/circle.yml b/circle.yml index 21adefe..0fa8da4 100644 --- a/circle.yml +++ b/circle.yml @@ -1,8 +1,7 @@ dependencies: pre: - - bower install - cache_directories: - - "bower_components" + - npm i -g npm + - npm i jsdata@^3.0.0-beta.3 test: override: - npm run ci diff --git a/conf.json b/conf.json index a537268..0318378 100644 --- a/conf.json +++ b/conf.json @@ -12,13 +12,12 @@ "package": "./package.json" }, "templates": { - "theme": "lumen", + "theme": "jsdata", "systemName": "js-data-localstorage", "copyright": "js-data-localstorage Copyright © 2014-2016 js-data-localstorage project authors", "outputSourceFiles": true, - "syntaxTheme": "dark", "linenums": true, - "footer": "
Back to js-data.io
", + "footer": "", "analytics": { "ua": "UA-55528236-2", "domain": "api.js-data.io" diff --git a/dist/js-data-localstorage.d.ts b/dist/js-data-localstorage.d.ts new file mode 100644 index 0000000..c9b2ea4 --- /dev/null +++ b/dist/js-data-localstorage.d.ts @@ -0,0 +1,24 @@ +import {Adapter} from 'js-data-adapter' + +interface IDict { + [key: string]: any; +} +interface IBaseAdapter extends IDict { + debug?: boolean, + raw?: boolean +} +interface IBaseLocalStorageAdapter extends IBaseAdapter { + basePath?: string +} +export class LocalStorageAdapter extends Adapter { + static extend(instanceProps?: IDict, classProps?: IDict): typeof LocalStorageAdapter + constructor(opts?: IBaseLocalStorageAdapter) +} +export interface version { + full: string + minor: string + major: string + patch: string + alpha: string | boolean + beta: string | boolean +} \ No newline at end of file diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index 5fc5839..0bab743 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1,2617 +1,2500 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.7 - Homepage +* @version 3.0.0-beta.1 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. */ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("js-data")); - else if(typeof define === 'function' && define.amd) - define(["js-data"], factory); - else if(typeof exports === 'object') - exports["LocalStorageAdapter"] = factory(require("js-data")); - else - root["LocalStorageAdapter"] = factory(root["JSData"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; -/******/ -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.loaded = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var _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"); } }; }(); - - /* global: localStorage */ - var JSData = __webpack_require__(1); - var Adapter = __webpack_require__(2); - var guid = __webpack_require__(3); - - var Query = JSData.Query; - var utils = JSData.utils; - - - function isValidString(value) { - return value != null && value !== ''; - } - function join(items, separator) { - separator || (separator = ''); - return items.filter(isValidString).join(separator); - } - function makePath() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var result = join(args, '/'); - return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); - } - var queue = []; - var taskInProcess = false; - - function enqueue(task) { - queue.push(task); - } - - function dequeue() { - if (queue.length && !taskInProcess) { - taskInProcess = true; - queue[0](); - } - } - - function queueTask(task) { - if (!queue.length) { - enqueue(task); - dequeue(); - } else { - enqueue(task); - } - } - - function createTask(fn) { - return new Promise(fn).then(function (result) { - taskInProcess = false; - queue.shift(); - setTimeout(dequeue, 0); - return result; - }, function (err) { - taskInProcess = false; - queue.shift(); - setTimeout(dequeue, 0); - return utils.reject(err); - }); - } - - var __super__ = Adapter.prototype; - - var DEFAULTS = { - /** - * TODO - * - * @name LocalStorageAdapter#basePath - * @type {string} - */ - basePath: '', - - /** - * TODO - * - * @name LocalStorageAdapter#debug - * @type {boolean} - * @default false - */ - debug: false, - - /** - * TODO - * - * @name LocalStorageAdapter#storage - * @type {Object} - * @default localStorage - */ - storage: localStorage - }; - - /** - * LocalStorageAdapter class. - * - * @example - * import {DataStore} from 'js-data' - * import LocalStorageAdapter from 'js-data-localstorage' - * const store = new DataStore() - * const adapter = new LocalStorageAdapter() - * store.registerAdapter('ls', adapter, { 'default': true }) - * - * @class LocalStorageAdapter - * @param {Object} [opts] Configuration opts. - * @param {string} [opts.basePath=''] TODO - * @param {boolean} [opts.debug=false] TODO - * @param {Object} [opts.storeage=localStorage] TODO - */ - function LocalStorageAdapter(opts) { - var self = this; - utils.classCallCheck(self, LocalStorageAdapter); - opts || (opts = {}); - utils.fillIn(opts, DEFAULTS); - Adapter.call(self, opts); - } - - // Setup prototype inheritance from Adapter - LocalStorageAdapter.prototype = Object.create(Adapter.prototype, { - constructor: { - value: LocalStorageAdapter, - enumerable: false, - writable: true, - configurable: true - } - }); - - Object.defineProperty(LocalStorageAdapter, '__super__', { - configurable: true, - value: Adapter - }); - - /** - * Alternative to ES6 class syntax for extending `LocalStorageAdapter`. - * - * @name LocalStorageAdapter.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 `LocalStorageAdapter`. - */ - LocalStorageAdapter.extend = utils.extend; - - utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { - /** - * Retrieve the number of records that match the selection query. Internal - * method used by Adapter#count. - * - * @name LocalStorageAdapter#_count - * @method - * @private - * @param {Object} mapper The mapper. - * @param {Object} query Selection query. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - - _count: function _count(mapper, query, opts) { - var self = this; - return self._findAll(mapper, query, opts).then(function (result) { - result[0] = result[0].length; - return result; - }); - }, - _createHelper: function _createHelper(mapper, props, opts) { - var self = this; - var _props = {}; - var relationFields = mapper.relationFields || []; - utils.forOwn(props, function (value, key) { - if (relationFields.indexOf(key) === -1) { - _props[key] = value; - } - }); - var id = utils.get(_props, mapper.idAttribute) || guid(); - utils.set(_props, mapper.idAttribute, id); - var key = self.getIdPath(mapper, opts, id); - - // Create the record - // TODO: Create related records when the "with" option is provided - self.storage.setItem(key, utils.toJson(_props)); - self.ensureId(id, mapper, opts); - return utils.fromJson(self.storage.getItem(key)); - }, - - - /** - * Create a new record. Internal method used by Adapter#create. - * - * @name LocalStorageAdapter#_create - * @method - * @private - * @param {Object} mapper The mapper. - * @param {Object} props The record to be created. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - _create: function _create(mapper, props, opts) { - var self = this; - return new Promise(function (resolve) { - return resolve([self._createHelper(mapper, props, opts), {}]); - }); - }, - - - /** - * Create multiple records in a single batch. Internal method used by - * Adapter#createMany. - * - * @name LocalStorageAdapter#_createMany - * @method - * @private - * @param {Object} mapper The mapper. - * @param {Object} props The records to be created. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - _createMany: function _createMany(mapper, props, opts) { - var self = this; - return new Promise(function (resolve) { - props || (props = []); - return resolve([props.map(function (_props) { - return self._createHelper(mapper, _props, opts); - }), {}]); - }); - }, - - - /** - * Destroy the record with the given primary key. Internal method used by - * Adapter#destroy. - * - * @name LocalStorageAdapter#_destroy - * @method - * @private - * @param {Object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to destroy. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - _destroy: function _destroy(mapper, id, opts) { - var self = this; - return new Promise(function (resolve) { - self.storage.removeItem(self.getIdPath(mapper, opts, id)); - self.removeId(id, mapper, opts); - return resolve([undefined, {}]); - }); - }, - - - /** - * Destroy the records that match the selection query. Internal method used by - * Adapter#destroyAll. - * - * @name LocalStorageAdapter#_destroyAll - * @method - * @private - * @param {Object} mapper the mapper. - * @param {Object} [query] Selection query. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - _destroyAll: function _destroyAll(mapper, query, opts) { - var self = this; - return self._findAll(mapper, query).then(function (results) { - var _results = _slicedToArray(results, 1); - - var records = _results[0]; - - var idAttribute = mapper.idAttribute; - // Gather IDs of records to be destroyed - var ids = records.map(function (record) { - return utils.get(record, idAttribute); - }); - // Destroy each record - ids.forEach(function (id) { - self.storage.removeItem(self.getIdPath(mapper, opts, id)); - }); - self.removeId(ids, mapper, opts); - return [undefined, {}]; - }); - }, - - - /** - * Retrieve the record with the given primary key. Internal method used by - * Adapter#find. - * - * @name LocalStorageAdapter#_find - * @method - * @private - * @param {Object} mapper The mapper. - * @param {(string|number)} id Primary key of the record to retrieve. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - _find: function _find(mapper, id, opts) { - var self = this; - return new Promise(function (resolve) { - var key = self.getIdPath(mapper, opts, id); - var record = self.storage.getItem(key); - return resolve([record ? utils.fromJson(record) : undefined, {}]); - }); - }, - - - /** - * Retrieve the records that match the selection query. Internal method used - * by Adapter#findAll. - * - * @name LocalStorageAdapter#_findAll - * @method - * @private - * @param {Object} mapper The mapper. - * @param {Object} query Selection query. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - _findAll: function _findAll(mapper, query, opts) { - var self = this; - query || (query = {}); - return new Promise(function (resolve) { - // Load all records into memory... - var records = []; - var ids = self.getIds(mapper, opts); - utils.forOwn(ids, function (value, id) { - var json = self.storage.getItem(self.getIdPath(mapper, opts, id)); - if (json) { - records.push(utils.fromJson(json)); - } - }); - var _query = new Query({ - index: { - getAll: function getAll() { - return records; - } - } - }); - return resolve([_query.filter(query).run(), {}]); - }); - }, - - - /** - * Retrieve the number of records that match the selection query. Internal - * method used by Adapter#sum. - * - * @name LocalStorageAdapter#_sum - * @method - * @private - * @param {Object} mapper The mapper. - * @param {string} field The field to sum. - * @param {Object} query Selection query. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - _sum: function _sum(mapper, field, query, opts) { - var self = this; - return self._findAll(mapper, query, opts).then(function (result) { - var sum = 0; - result[0].forEach(function (record) { - sum += utils.get(record, field) || 0; - }); - result[0] = sum; - return result; - }); - }, - - - /** - * Apply the given update to the record with the specified primary key. - * Internal method used by Adapter#update. - * - * @name LocalStorageAdapter#_update - * @method - * @private - * @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. - * @return {Promise} - */ - _update: function _update(mapper, id, props, opts) { - var self = this; - props || (props = {}); - return new Promise(function (resolve, reject) { - var key = self.getIdPath(mapper, opts, id); - var record = self.storage.getItem(key); - if (!record) { - return reject(new Error('Not Found')); - } - record = utils.fromJson(record); - utils.deepMixIn(record, props); - self.storage.setItem(key, utils.toJson(record)); - return resolve([record, {}]); - }); - }, - - - /** - * Apply the given update to all records that match the selection query. - * Internal method used by Adapter#updateAll. - * - * @name LocalStorageAdapter#_updateAll - * @method - * @private - * @param {Object} mapper The mapper. - * @param {Object} props The update to apply to the selected records. - * @param {Object} [query] Selection query. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - _updateAll: function _updateAll(mapper, props, query, opts) { - var self = this; - var idAttribute = mapper.idAttribute; - return self._findAll(mapper, query, opts).then(function (results) { - var _results2 = _slicedToArray(results, 1); - - var records = _results2[0]; - - records.forEach(function (record) { - record || (record = {}); - var id = utils.get(record, idAttribute); - var key = self.getIdPath(mapper, opts, id); - utils.deepMixIn(record, props); - self.storage.setItem(key, utils.toJson(record)); - }); - return [records, {}]; - }); - }, - - - /** - * Update the given records in a single batch. Internal method used by - * Adapter#updateMany. - * - * @name LocalStorageAdapter#updateMany - * @method - * @private - * @param {Object} mapper The mapper. - * @param {Object[]} records The records to update. - * @param {Object} [opts] Configuration options. - * @return {Promise} - */ - _updateMany: function _updateMany(mapper, records, opts) { - var self = this; - records || (records = []); - return new Promise(function (resolve) { - var updatedRecords = []; - var idAttribute = mapper.idAttribute; - records.forEach(function (record) { - if (!record) { - return; - } - var id = utils.get(record, idAttribute); - if (utils.isUndefined(id)) { - return; - } - var key = self.getIdPath(mapper, opts, id); - var json = self.storage.getItem(key); - if (!json) { - return; - } - var existingRecord = utils.fromJson(json); - utils.deepMixIn(existingRecord, record); - self.storage.setItem(key, utils.toJson(existingRecord)); - updatedRecords.push(existingRecord); - }); - return resolve([records, {}]); - }); - }, - create: function create(mapper, props, opts) { - var self = this; - return createTask(function (success, failure) { - queueTask(function () { - __super__.create.call(self, mapper, props, opts).then(success, failure); - }); - }); - }, - createMany: function createMany(mapper, props, opts) { - var self = this; - return createTask(function (success, failure) { - queueTask(function () { - __super__.createMany.call(self, mapper, props, opts).then(success, failure); - }); - }); - }, - destroy: function destroy(mapper, id, opts) { - var self = this; - return createTask(function (success, failure) { - queueTask(function () { - __super__.destroy.call(self, mapper, id, opts).then(success, failure); - }); - }); - }, - destroyAll: function destroyAll(mapper, query, opts) { - var self = this; - return createTask(function (success, failure) { - queueTask(function () { - __super__.destroyAll.call(self, mapper, query, opts).then(success, failure); - }); - }); - }, - - - /** - * TODO - * - * @name LocalStorageAdapter#ensureId - * @method - */ - ensureId: function ensureId(id, mapper, opts) { - var ids = this.getIds(mapper, opts); - if (utils.isArray(id)) { - if (!id.length) { - return; - } - id.forEach(function (_id) { - ids[_id] = 1; - }); - } else { - ids[id] = 1; - } - this.saveKeys(ids, mapper, opts); - }, - - - /** - * TODO - * - * @name LocalStorageAdapter#getPath - * @method - */ - getPath: function getPath(mapper, opts) { - opts = opts || {}; - return makePath(opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, mapper.name); - }, - - - /** - * TODO - * - * @name LocalStorageAdapter#getIdPath - * @method - */ - getIdPath: function getIdPath(mapper, opts, id) { - opts = opts || {}; - return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id); - }, - - - /** - * TODO - * - * @name LocalStorageAdapter#getIds - * @method - */ - getIds: function getIds(mapper, opts) { - var ids = void 0; - var idsPath = this.getPath(mapper, opts); - var idsJson = this.storage.getItem(idsPath); - if (idsJson) { - ids = utils.fromJson(idsJson); - } else { - ids = {}; - } - return ids; - }, - - - /** - * TODO - * - * @name LocalStorageAdapter#removeId - * @method - */ - removeId: function removeId(id, mapper, opts) { - var ids = this.getIds(mapper, opts); - if (utils.isArray(id)) { - if (!id.length) { - return; - } - id.forEach(function (_id) { - delete ids[_id]; - }); - } else { - delete ids[id]; - } - this.saveKeys(ids, mapper, opts); - }, - - - /** - * TODO - * - * @name LocalStorageAdapter#saveKeys - * @method - */ - saveKeys: function saveKeys(ids, mapper, opts) { - ids = ids || {}; - var idsPath = this.getPath(mapper, opts); - if (Object.keys(ids).length) { - this.storage.setItem(idsPath, utils.toJson(ids)); - } else { - this.storage.removeItem(idsPath); - } - }, - update: function update(mapper, id, props, opts) { - var self = this; - return createTask(function (success, failure) { - queueTask(function () { - __super__.update.call(self, mapper, id, props, opts).then(success, failure); - }); - }); - }, - updateAll: function updateAll(mapper, props, query, opts) { - var self = this; - return createTask(function (success, failure) { - queueTask(function () { - __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure); - }); - }); - }, - updateMany: function updateMany(mapper, records, opts) { - var self = this; - return createTask(function (success, failure) { - queueTask(function () { - __super__.updateMany.call(self, mapper, records, opts).then(success, failure); - }); - }); - } - }); - - /** - * Details of the current version of the `js-data-localstorage` module. - * - * @name LocalStorageAdapter.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. - */ - LocalStorageAdapter.version = { - full: '3.0.0-alpha.7', - major: parseInt('3', 10), - minor: parseInt('0', 10), - patch: parseInt('0', 10), - alpha: true ? '7' : false, - beta: true ? 'false' : false - }; - - /** - * Registered as `js-data-localstorage` in NPM and Bower. - * - * __Script tag__: - * ```javascript - * window.LocalStorageAdapter - * ``` - * __CommonJS__: - * ```javascript - * var LocalStorageAdapter = require('js-data-localstorage') - * ``` - * __ES6 Modules__: - * ```javascript - * import LocalStorageAdapter from 'js-data-localstorage' - * ``` - * __AMD__: - * ```javascript - * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... }) - * ``` - * - * @module js-data-localstorage - */ - - module.exports = LocalStorageAdapter; - -/***/ }, -/* 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, __webpack_require__) { - - var randHex = __webpack_require__(4); - var choice = __webpack_require__(5); - - /** - * Returns pseudo-random guid (UUID v4) - * IMPORTANT: it's not totally "safe" since randHex/choice uses Math.random - * by default and sequences can be predicted in some cases. See the - * "random/random" documentation for more info about it and how to replace - * the default PRNG. - */ - function guid() { - return ( - randHex(8)+'-'+ - randHex(4)+'-'+ - // v4 UUID always contain "4" at this position to specify it was - // randomly generated - '4' + randHex(3) +'-'+ - // v4 UUID always contain chars [a,b,8,9] at this position - choice(8, 9, 'a', 'b') + randHex(3)+'-'+ - randHex(12) - ); - } - module.exports = guid; - - - -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - var choice = __webpack_require__(5); - - var _chars = '0123456789abcdef'.split(''); - - /** - * Returns a random hexadecimal string - */ - function randHex(size){ - size = size && size > 0? size : 6; - var str = ''; - while (size--) { - str += choice(_chars); - } - return str; - } - - module.exports = randHex; - - - - -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - - var randInt = __webpack_require__(6); - var isArray = __webpack_require__(11); - - /** - * Returns a random element from the supplied arguments - * or from the array (if single argument is an array). - */ - function choice(items) { - var target = (arguments.length === 1 && isArray(items))? items : arguments; - return target[ randInt(0, target.length - 1) ]; - } - - module.exports = choice; - - - - -/***/ }, -/* 6 */ -/***/ function(module, exports, __webpack_require__) { - - var MIN_INT = __webpack_require__(7); - var MAX_INT = __webpack_require__(8); - var rand = __webpack_require__(9); - - /** - * Gets random integer inside range or snap to min/max values. - */ - function randInt(min, max){ - min = min == null? MIN_INT : ~~min; - max = max == null? MAX_INT : ~~max; - // can't be max + 0.5 otherwise it will round up if `rand` - // returns `max` causing it to overflow range. - // -0.5 and + 0.49 are required to avoid bias caused by rounding - return Math.round( rand(min - 0.5, max + 0.499999999999) ); - } - - module.exports = randInt; - - - -/***/ }, -/* 7 */ -/***/ function(module, exports) { - - /** - * @constant Minimum 32-bit signed integer value (-2^31). - */ - - module.exports = -2147483648; - - - -/***/ }, -/* 8 */ -/***/ function(module, exports) { - - /** - * @constant Maximum 32-bit signed integer value. (2^31 - 1) - */ - - module.exports = 2147483647; - - - -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { - - var random = __webpack_require__(10); - var MIN_INT = __webpack_require__(7); - var MAX_INT = __webpack_require__(8); - - /** - * Returns random number inside range - */ - function rand(min, max){ - min = min == null? MIN_INT : min; - max = max == null? MAX_INT : max; - return min + (max - min) * random(); - } - - module.exports = rand; - - - -/***/ }, -/* 10 */ -/***/ function(module, exports) { - - - - /** - * Just a wrapper to Math.random. No methods inside mout/random should call - * Math.random() directly so we can inject the pseudo-random number - * generator if needed (ie. in case we need a seeded random or a better - * algorithm than the native one) - */ - function random(){ - return random.get(); - } - - // we expose the method so it can be swapped if needed - random.get = Math.random; - - module.exports = random; - - - - -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { - - var isKind = __webpack_require__(12); - /** - */ - var isArray = Array.isArray || function (val) { - return isKind(val, 'Array'); - }; - module.exports = isArray; - - - -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { - - var kindOf = __webpack_require__(13); - /** - * Check if value is from a specific "kind". - */ - function isKind(val, kind){ - return kindOf(val) === kind; - } - module.exports = isKind; - - - -/***/ }, -/* 13 */ -/***/ function(module, exports) { - - - - var _rKind = /^\[object (.*)\]$/, - _toString = Object.prototype.toString, - UNDEF; - - /** - * Gets the "kind" of value. (e.g. "String", "Number", etc) - */ - function kindOf(val) { - if (val === null) { - return 'Null'; - } else if (val === UNDEF) { - return 'Undefined'; - } else { - return _rKind.exec( _toString.call(val) )[1]; - } - } - module.exports = kindOf; - - - -/***/ } -/******/ ]) -}); -; +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-data')) : + typeof define === 'function' && define.amd ? define('js-data-localstorage', ['exports', 'js-data'], factory) : + (factory((global.JSDataLocalStorage = global.JSDataLocalStorage || {}),global.JSData)); +}(this, function (exports,jsData) { 'use strict'; + + var babelHelpers = {}; + babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; + }; + + babelHelpers.defineProperty = function (obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + }; + + babelHelpers.slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + }(); + + babelHelpers; + + + function __commonjs(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } + + var noop = function noop() { + var self = this; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = args[args.length - 1]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var noop2 = function noop2() { + var self = this; + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var opts = args[args.length - 2]; + self.dbg.apply(self, [opts.op].concat(args)); + return jsData.utils.resolve(); + }; + + var unique = function unique(array) { + var seen = {}; + var final = []; + array.forEach(function (item) { + if (item in seen) { + return; + } + final.push(item); + seen[item] = 0; + }); + return final; + }; + + var withoutRelations = function withoutRelations(mapper, props) { + return jsData.utils.omit(props, mapper.relationFields || []); + }; + + var DEFAULTS$1 = { + /** + * Whether to log debugging information. + * + * @name Adapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * Whether to return a more detailed response object. + * + * @name Adapter#raw + * @type {boolean} + * @default false + */ + raw: false + }; + + /** + * Abstract class meant to be extended by adapters. + * + * @class Adapter + * @abstract + * @param {Object} [opts] Configuration opts. + * @param {boolean} [opts.debug=false] Whether to log debugging information. + * @param {boolean} [opts.raw=false] Whether to return a more detailed response + * object. + */ + function Adapter(opts) { + var self = this; + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS$1); + jsData.utils.fillIn(self, opts); + } + + /** + * Response object used when `raw` is `true`. May contain other fields in + * addition to `data`. + * + * @class Response + */ + function Response(data, meta, op) { + var self = this; + meta || (meta = {}); + + /** + * Response data. + * + * @name Response#data + * @type {*} + */ + self.data = data; + + jsData.utils.fillIn(self, meta); + + /** + * The operation for which the response was created. + * + * @name Response#op + * @type {string} + */ + self.op = op; + } + + /** + * Alternative to ES6 class syntax for extending `Adapter`. + * + * @name Adapter.extend + * @method + * @param {Object} [instanceProps] Properties that will be added to the + * prototype of the subclass. + * @param {Object} [classProps] Properties that will be added as static + * properties to the subclass itself. + * @return {Object} Subclass of `Adapter`. + */ + Adapter.extend = jsData.utils.extend; + + jsData.utils.addHiddenPropsToTarget(Adapter.prototype, { + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#afterCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} props The `props` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `afterCount` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterCount: noop2, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `afterCreate` + * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreate: noop2, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#afterCreate + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `afterCreateMany` + * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`. + */ + afterCreateMany: noop2, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#afterDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `afterDestroy` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroy: noop2, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#afterDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `afterDestroyAll` + * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`. + */ + afterDestroyAll: noop2, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#afterFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `afterFind` + * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`. + */ + afterFind: noop2, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#afterFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `afterFindAll` + * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`. + */ + afterFindAll: noop2, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#afterSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {string} field The `field` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `afterSum` + * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`. + */ + afterSum: noop2, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#afterUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `afterUpdate` + * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdate: noop2, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#afterUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `afterUpdateAll` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateAll: noop2, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any. + * + * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#afterUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} records The `records` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `afterUpdateMany` + * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`. + */ + afterUpdateMany: noop2, + + /** + * Lifecycle method method called by count. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes count to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by count. + * + * @name Adapter#beforeCount + * @method + * @param {Object} mapper The `mapper` argument passed to count. + * @param {Object} query The `query` argument passed to count. + * @param {Object} opts The `opts` argument passed to count. + * @property {string} opts.op `beforeCount` + */ + beforeCount: noop, + + /** + * Lifecycle method method called by create. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes create to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by create. + * + * @name Adapter#beforeCreate + * @method + * @param {Object} mapper The `mapper` argument passed to create. + * @param {Object} props The `props` argument passed to create. + * @param {Object} opts The `opts` argument passed to create. + * @property {string} opts.op `beforeCreate` + */ + beforeCreate: noop, + + /** + * Lifecycle method method called by createMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes createMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany. + * + * @name Adapter#beforeCreateMany + * @method + * @param {Object} mapper The `mapper` argument passed to createMany. + * @param {Object[]} props The `props` argument passed to createMany. + * @param {Object} opts The `opts` argument passed to createMany. + * @property {string} opts.op `beforeCreateMany` + */ + beforeCreateMany: noop, + + /** + * Lifecycle method method called by destroy. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroy to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy. + * + * @name Adapter#beforeDestroy + * @method + * @param {Object} mapper The `mapper` argument passed to destroy. + * @param {(string|number)} id The `id` argument passed to destroy. + * @param {Object} opts The `opts` argument passed to destroy. + * @property {string} opts.op `beforeDestroy` + */ + beforeDestroy: noop, + + /** + * Lifecycle method method called by destroyAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll. + * + * @name Adapter#beforeDestroyAll + * @method + * @param {Object} mapper The `mapper` argument passed to destroyAll. + * @param {Object} query The `query` argument passed to destroyAll. + * @param {Object} opts The `opts` argument passed to destroyAll. + * @property {string} opts.op `beforeDestroyAll` + */ + beforeDestroyAll: noop, + + /** + * Lifecycle method method called by find. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes find to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by find. + * + * @name Adapter#beforeFind + * @method + * @param {Object} mapper The `mapper` argument passed to find. + * @param {(string|number)} id The `id` argument passed to find. + * @param {Object} opts The `opts` argument passed to find. + * @property {string} opts.op `beforeFind` + */ + beforeFind: noop, + + /** + * Lifecycle method method called by findAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes findAll to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll. + * + * @name Adapter#beforeFindAll + * @method + * @param {Object} mapper The `mapper` argument passed to findAll. + * @param {Object} query The `query` argument passed to findAll. + * @param {Object} opts The `opts` argument passed to findAll. + * @property {string} opts.op `beforeFindAll` + */ + beforeFindAll: noop, + + /** + * Lifecycle method method called by sum. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes sum to wait for the Promise to resolve before continuing. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum. + * + * @name Adapter#beforeSum + * @method + * @param {Object} mapper The `mapper` argument passed to sum. + * @param {Object} query The `query` argument passed to sum. + * @param {Object} opts The `opts` argument passed to sum. + * @property {string} opts.op `beforeSum` + */ + beforeSum: noop, + + /** + * Lifecycle method method called by update. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes update to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by update. + * + * @name Adapter#beforeUpdate + * @method + * @param {Object} mapper The `mapper` argument passed to update. + * @param {(string|number)} id The `id` argument passed to update. + * @param {Object} props The `props` argument passed to update. + * @param {Object} opts The `opts` argument passed to update. + * @property {string} opts.op `beforeUpdate` + */ + beforeUpdate: noop, + + /** + * Lifecycle method method called by updateAll. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll. + * + * @name Adapter#beforeUpdateAll + * @method + * @param {Object} mapper The `mapper` argument passed to updateAll. + * @param {Object} props The `props` argument passed to updateAll. + * @param {Object} query The `query` argument passed to updateAll. + * @param {Object} opts The `opts` argument passed to updateAll. + * @property {string} opts.op `beforeUpdateAll` + */ + beforeUpdateAll: noop, + + /** + * Lifecycle method method called by updateMany. + * + * Override this method to add custom behavior for this lifecycle hook. + * + * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing. + * + * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value. + * + * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany. + * + * @name Adapter#beforeUpdateMany + * @method + * @param {Object} mapper The `mapper` argument passed to updateMany. + * @param {Object[]} props The `props` argument passed to updateMany. + * @param {Object} opts The `opts` argument passed to updateMany. + * @property {string} opts.op `beforeUpdateMany` + */ + beforeUpdateMany: noop, + + /** + * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`. + * + * @name Adapter#dbg + * @method + */ + dbg: function dbg() { + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + this.log.apply(this, ['debug'].concat(args)); + }, + + + /** + * Retrieve the number of records that match the selection query. Called by + * `Mapper#count`. + * + * @name Adapter#count + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + count: function count(mapper, query, opts) { + var self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeCount lifecycle hook + op = opts.op = 'beforeCount'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'count'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._count(mapper, query, opts)); + }).then(function (results) { + var _results = babelHelpers.slicedToArray(results, 2); + + var data = _results[0]; + var result = _results[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterCount lifecycle hook + op = opts.op = 'afterCount'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Create a new record. Called by `Mapper#create`. + * + * @name Adapter#create + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + create: function create(mapper, props, opts) { + var self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreate lifecycle hook + op = opts.op = 'beforeCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'create'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._create(mapper, props, opts)); + }).then(function (results) { + var _results2 = babelHelpers.slicedToArray(results, 2); + + var data = _results2[0]; + var result = _results2[1]; + + result || (result = {}); + var response = new Response(data, result, 'create'); + response.created = data ? 1 : 0; + response = self.respond(response, opts); + + // afterCreate lifecycle hook + op = opts.op = 'afterCreate'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Create multiple records in a single batch. Called by `Mapper#createMany`. + * + * @name Adapter#createMany + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + createMany: function createMany(mapper, props, opts) { + var self = this; + var op = void 0; + props || (props = {}); + opts || (opts = {}); + + // beforeCreateMany lifecycle hook + op = opts.op = 'beforeCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = props.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'createMany'; + self.dbg(op, mapper, props, opts); + return jsData.utils.resolve(self._createMany(mapper, props, opts)); + }).then(function (results) { + var _results3 = babelHelpers.slicedToArray(results, 2); + + var data = _results3[0]; + var result = _results3[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'createMany'); + response.created = data.length; + response = self.respond(response, opts); + + // afterCreateMany lifecycle hook + op = opts.op = 'afterCreateMany'; + return jsData.utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Destroy the record with the given primary key. Called by + * `Mapper#destroy`. + * + * @name Adapter#destroy + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroy: function destroy(mapper, id, opts) { + var self = this; + var op = void 0; + opts || (opts = {}); + + // beforeDestroy lifecycle hook + op = opts.op = 'beforeDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'destroy'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._destroy(mapper, id, opts)); + }).then(function (results) { + var _results4 = babelHelpers.slicedToArray(results, 2); + + var data = _results4[0]; + var result = _results4[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroy'); + response = self.respond(response, opts); + + // afterDestroy lifecycle hook + op = opts.op = 'afterDestroy'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Destroy the records that match the selection query. Called by + * `Mapper#destroyAll`. + * + * @name Adapter#destroyAll + * @method + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + var op = void 0; + query || (query = {}); + opts || (opts = {}); + + // beforeDestroyAll lifecycle hook + op = opts.op = 'beforeDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'destroyAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._destroyAll(mapper, query, opts)); + }).then(function (results) { + var _results5 = babelHelpers.slicedToArray(results, 2); + + var data = _results5[0]; + var result = _results5[1]; + + result || (result = {}); + var response = new Response(data, result, 'destroyAll'); + response = self.respond(response, opts); + + // afterDestroyAll lifecycle hook + op = opts.op = 'afterDestroyAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Load a belongsTo relationship. + * + * Override with care. + * + * @name Adapter#loadBelongsTo + * @method + * @return {Promise} + */ + loadBelongsTo: function loadBelongsTo(mapper, def, records, __opts) { + var self = this; + var relationDef = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + var _ret = function () { + var record = records; + return { + v: self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) { + def.setLocalField(record, relatedItem); + }) + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret)) === "object") return _ret.v; + } else { + var keys = records.map(function (record) { + return self.makeBelongsToForeignKey(mapper, def, record); + }).filter(function (key) { + return key; + }); + return self.findAll(relationDef, { + where: babelHelpers.defineProperty({}, relationDef.idAttribute, { + 'in': keys + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (record) { + relatedItems.forEach(function (relatedItem) { + if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) { + def.setLocalField(record, relatedItem); + } + }); + }); + }); + } + }, + + + /** + * Retrieve the record with the given primary key. Called by `Mapper#find`. + * + * @name Adapter#find + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + find: function find(mapper, id, opts) { + var self = this; + var record = void 0, + op = void 0; + opts || (opts = {}); + opts.with || (opts.with = []); + + // beforeFind lifecycle hook + op = opts.op = 'beforeFind'; + return jsData.utils.resolve(self[op](mapper, id, opts)).then(function () { + op = opts.op = 'find'; + self.dbg(op, mapper, id, opts); + return jsData.utils.resolve(self._find(mapper, id, opts)); + }).then(function (results) { + var _results6 = babelHelpers.slicedToArray(results, 1); + + var _record = _results6[0]; + + if (!_record) { + return; + } + record = _record; + var tasks = []; + + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasOne') { + task = self.loadHasOne(mapper, def, record, __opts); + } else { + task = self.loadHasMany(mapper, def, record, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, record, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, record, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, record, __opts); + } + if (task) { + tasks.push(task); + } + }); + + return Promise.all(tasks); + }).then(function () { + var response = new Response(record, {}, 'find'); + response.found = record ? 1 : 0; + response = self.respond(response, opts); + + // afterFind lifecycle hook + op = opts.op = 'afterFind'; + return jsData.utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Retrieve the records that match the selection query. + * + * @name Adapter#findAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @param {string[]} [opts.with=[]] Relations to eager load. + * @return {Promise} + */ + findAll: function findAll(mapper, query, opts) { + var self = this; + opts || (opts = {}); + opts.with || (opts.with = []); + + var records = []; + var op = void 0; + var activeWith = opts._activeWith; + + if (jsData.utils.isObject(activeWith)) { + var activeQuery = activeWith.query || {}; + if (activeWith.replace) { + query = activeQuery; + } else { + jsData.utils.deepFillIn(query, activeQuery); + } + } + + // beforeFindAll lifecycle hook + op = opts.op = 'beforeFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts)).then(function () { + op = opts.op = 'findAll'; + self.dbg(op, mapper, query, opts); + return jsData.utils.resolve(self._findAll(mapper, query, opts)); + }).then(function (results) { + var _results7 = babelHelpers.slicedToArray(results, 1); + + var _records = _results7[0]; + + _records || (_records = []); + records = _records; + var tasks = []; + jsData.utils.forEachRelation(mapper, opts, function (def, __opts) { + var task = void 0; + if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) { + if (def.type === 'hasMany') { + task = self.loadHasMany(mapper, def, records, __opts); + } else { + task = self.loadHasOne(mapper, def, records, __opts); + } + } else if (def.type === 'hasMany' && def.localKeys) { + task = self.loadHasManyLocalKeys(mapper, def, records, __opts); + } else if (def.type === 'hasMany' && def.foreignKeys) { + task = self.loadHasManyForeignKeys(mapper, def, records, __opts); + } else if (def.type === 'belongsTo') { + task = self.loadBelongsTo(mapper, def, records, __opts); + } + if (task) { + tasks.push(task); + } + }); + return Promise.all(tasks); + }).then(function () { + var response = new Response(records, {}, 'findAll'); + response.found = records.length; + response = self.respond(response, opts); + + // afterFindAll lifecycle hook + op = opts.op = 'afterFindAll'; + return jsData.utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Resolve the value of the specified option based on the given options and + * this adapter's settings. Override with care. + * + * @name Adapter#getOpt + * @method + * @param {string} opt The name of the option. + * @param {Object} [opts] Configuration options. + * @return {*} The value of the specified option. + */ + getOpt: function getOpt(opt, opts) { + opts || (opts = {}); + return jsData.utils.isUndefined(opts[opt]) ? jsData.utils.plainCopy(this[opt]) : jsData.utils.plainCopy(opts[opt]); + }, + + + /** + * Load a hasMany relationship. + * + * Override with care. + * + * @name Adapter#loadHasMany + * @method + * @return {Promise} + */ + loadHasMany: function loadHasMany(mapper, def, records, __opts) { + var self = this; + var singular = false; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + singular = true; + records = [records]; + } + var IDs = records.map(function (record) { + return self.makeHasManyForeignKey(mapper, def, record); + }); + var query = { + where: {} + }; + var criteria = query.where[def.foreignKey] = {}; + if (singular) { + // more efficient query when we only have one record + criteria['=='] = IDs[0]; + } else { + criteria['in'] = IDs.filter(function (id) { + return id; + }); + } + return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) { + records.forEach(function (record) { + var attached = []; + // avoid unneccesary iteration when we only have one record + if (singular) { + attached = relatedItems; + } else { + relatedItems.forEach(function (relatedItem) { + if (jsData.utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) { + attached.push(relatedItem); + } + }); + } + def.setLocalField(record, attached); + }); + }); + }, + loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) { + var self = this; + var record = void 0; + var relatedMapper = def.getRelation(); + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': self.makeHasManyLocalKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + var _ret2 = function () { + var localKeys = []; + records.forEach(function (record) { + localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record)); + }); + return { + v: self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, { + 'in': unique(localKeys).filter(function (x) { + return x; + }) + }) + }, __opts).then(function (relatedItems) { + records.forEach(function (item) { + var attached = []; + var itemKeys = jsData.utils.get(item, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + relatedItems.forEach(function (relatedItem) { + if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) { + attached.push(relatedItem); + } + }); + def.setLocalField(item, attached); + }); + return relatedItems; + }) + }; + }(); + + if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v; + } + }, + loadHasManyForeignKeys: function loadHasManyForeignKeys(mapper, def, records, __opts) { + var self = this; + var relatedMapper = def.getRelation(); + var idAttribute = mapper.idAttribute; + var record = void 0; + + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + record = records; + } + + if (record) { + return self.findAll(def.getRelation(), { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'contains': self.makeHasManyForeignKeys(mapper, def, record) + }) + }, __opts).then(function (relatedItems) { + def.setLocalField(record, relatedItems); + }); + } else { + return self.findAll(relatedMapper, { + where: babelHelpers.defineProperty({}, def.foreignKeys, { + 'isectNotEmpty': records.map(function (record) { + return self.makeHasManyForeignKeys(mapper, def, record); + }) + }) + }, __opts).then(function (relatedItems) { + var foreignKeysField = def.foreignKeys; + records.forEach(function (record) { + var _relatedItems = []; + var id = jsData.utils.get(record, idAttribute); + relatedItems.forEach(function (relatedItem) { + var foreignKeys = jsData.utils.get(relatedItems, foreignKeysField) || []; + if (foreignKeys.indexOf(id) !== -1) { + _relatedItems.push(relatedItem); + } + }); + def.setLocalField(record, _relatedItems); + }); + }); + } + }, + + + /** + * Load a hasOne relationship. + * + * Override with care. + * + * @name Adapter#loadHasOne + * @method + * @return {Promise} + */ + loadHasOne: function loadHasOne(mapper, def, records, __opts) { + if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) { + records = [records]; + } + return this.loadHasMany(mapper, def, records, __opts).then(function () { + records.forEach(function (record) { + var relatedData = def.getLocalField(record); + if (jsData.utils.isArray(relatedData) && relatedData.length) { + def.setLocalField(record, relatedData[0]); + } + }); + }); + }, + + + /** + * Logging utility method. Override this method if you want to send log + * messages to something other than the console. + * + * @name Adapter#log + * @method + * @param {string} level Log level. + * @param {...*} values Values to log. + */ + log: function log(level) { + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + if (level && !args.length) { + args.push(level); + level = 'debug'; + } + if (level === 'debug' && !this.debug) { + return; + } + var prefix = level.toUpperCase() + ': (Adapter)'; + if (console[level]) { + var _console; + + (_console = console)[level].apply(_console, [prefix].concat(args)); + } else { + var _console2; + + (_console2 = console).log.apply(_console2, [prefix].concat(args)); + } + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * There may be reasons why you may want to override this method, like when + * the id of the parent doesn't exactly match up to the key on the child. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKey + * @method + * @return {*} + */ + makeHasManyForeignKey: function makeHasManyForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Return the localKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyLocalKeys + * @method + * @return {*} + */ + makeHasManyLocalKeys: function makeHasManyLocalKeys(mapper, def, record) { + var localKeys = []; + var itemKeys = jsData.utils.get(record, def.localKeys) || []; + itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys); + localKeys = localKeys.concat(itemKeys); + return unique(localKeys).filter(function (x) { + return x; + }); + }, + + + /** + * Return the foreignKeys from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeHasManyForeignKeys + * @method + * @return {*} + */ + makeHasManyForeignKeys: function makeHasManyForeignKeys(mapper, def, record) { + return jsData.utils.get(record, mapper.idAttribute); + }, + + + /** + * Return the foreignKey from the given record for the provided relationship. + * + * Override with care. + * + * @name Adapter#makeBelongsToForeignKey + * @method + * @return {*} + */ + makeBelongsToForeignKey: function makeBelongsToForeignKey(mapper, def, record) { + return def.getForeignKey(record); + }, + + + /** + * Retrieve sum of the specified field of the records that match the selection + * query. Called by `Mapper#sum`. + * + * @name Adapter#sum + * @method + * @param {Object} mapper The mapper. + * @param {string} field By to sum. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + sum: function sum(mapper, field, query, opts) { + var self = this; + var op = void 0; + if (!jsData.utils.isString(field)) { + throw new Error('field must be a string!'); + } + query || (query = {}); + opts || (opts = {}); + + // beforeSum lifecycle hook + op = opts.op = 'beforeSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts)).then(function () { + // Allow for re-assignment from lifecycle hook + op = opts.op = 'sum'; + self.dbg(op, mapper, field, query, opts); + return jsData.utils.resolve(self._sum(mapper, field, query, opts)); + }).then(function (results) { + var _results8 = babelHelpers.slicedToArray(results, 2); + + var data = _results8[0]; + var result = _results8[1]; + + result || (result = {}); + var response = new Response(data, result, op); + response = self.respond(response, opts); + + // afterSum lifecycle hook + op = opts.op = 'afterSum'; + return jsData.utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * @name Adapter#respond + * @method + * @param {Object} response Response object. + * @param {Object} opts Configuration options. + * return {Object} If `opts.raw == true` then return `response`, else return + * `response.data`. + */ + respond: function respond(response, opts) { + return this.getOpt('raw', opts) ? response : response.data; + }, + + + /** + * Apply the given update to the record with the specified primary key. Called + * by `Mapper#update`. + * + * @name Adapter#update + * @method + * @param {Object} mapper The mapper. + * @param {(string|number)} id The primary key of the record to be updated. + * @param {Object} props The update to apply to the record. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + update: function update(mapper, id, props, opts) { + var self = this; + props || (props = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdate lifecycle hook + op = opts.op = 'beforeUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'update'; + self.dbg(op, mapper, id, props, opts); + return jsData.utils.resolve(self._update(mapper, id, props, opts)); + }).then(function (results) { + var _results9 = babelHelpers.slicedToArray(results, 2); + + var data = _results9[0]; + var result = _results9[1]; + + result || (result = {}); + var response = new Response(data, result, 'update'); + response.updated = data ? 1 : 0; + response = self.respond(response, opts); + + // afterUpdate lifecycle hook + op = opts.op = 'afterUpdate'; + return jsData.utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Apply the given update to all records that match the selection query. + * Called by `Mapper#updateAll`. + * + * @name Adapter#updateAll + * @method + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [query.where] Filtering criteria. + * @param {string|Array} [query.orderBy] Sorting criteria. + * @param {string|Array} [query.sort] Same as `query.sort`. + * @param {number} [query.limit] Limit results. + * @param {number} [query.skip] Offset results. + * @param {number} [query.offset] Same as `query.skip`. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + props || (props = {}); + query || (query = {}); + opts || (opts = {}); + var op = void 0; + + // beforeUpdateAll lifecycle hook + op = opts.op = 'beforeUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) { + // Allow for re-assignment from lifecycle hook + props = jsData.utils.isUndefined(_props) ? props : _props; + props = withoutRelations(mapper, props); + op = opts.op = 'updateAll'; + self.dbg(op, mapper, props, query, opts); + return jsData.utils.resolve(self._updateAll(mapper, props, query, opts)); + }).then(function (results) { + var _results10 = babelHelpers.slicedToArray(results, 2); + + var data = _results10[0]; + var result = _results10[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateAll'); + response.updated = data.length; + response = self.respond(response, opts); + + // afterUpdateAll lifecycle hook + op = opts.op = 'afterUpdateAll'; + return jsData.utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + }, + + + /** + * Update the given records in a single batch. Called by `Mapper#updateMany`. + * + * @name Adapter#updateMany + * @method + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @param {boolean} [opts.raw=false] Whether to return a more detailed + * response object. + * @return {Promise} + */ + updateMany: function updateMany(mapper, records, opts) { + var self = this; + records || (records = []); + opts || (opts = {}); + var op = void 0; + var idAttribute = mapper.idAttribute; + + records = records.filter(function (record) { + return jsData.utils.get(record, idAttribute); + }); + + // beforeUpdateMany lifecycle hook + op = opts.op = 'beforeUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts)).then(function (_records) { + // Allow for re-assignment from lifecycle hook + records = jsData.utils.isUndefined(_records) ? records : _records; + records = records.map(function (record) { + return withoutRelations(mapper, record); + }); + op = opts.op = 'updateMany'; + self.dbg(op, mapper, records, opts); + return jsData.utils.resolve(self._updateMany(mapper, records, opts)); + }).then(function (results) { + var _results11 = babelHelpers.slicedToArray(results, 2); + + var data = _results11[0]; + var result = _results11[1]; + + data || (data = []); + result || (result = {}); + var response = new Response(data, result, 'updateMany'); + response.updated = data.length; + response = self.respond(response, opts); + + // afterUpdateMany lifecycle hook + op = opts.op = 'afterUpdateMany'; + return jsData.utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) { + // Allow for re-assignment from lifecycle hook + return jsData.utils.isUndefined(_response) ? response : _response; + }); + }); + } + }); + + var kindOf = __commonjs(function (module) { + var _rKind = /^\[object (.*)\]$/, + _toString = Object.prototype.toString, + UNDEF; + + /** + * Gets the "kind" of value. (e.g. "String", "Number", etc) + */ + function kindOf(val) { + if (val === null) { + return 'Null'; + } else if (val === UNDEF) { + return 'Undefined'; + } else { + return _rKind.exec( _toString.call(val) )[1]; + } + } + module.exports = kindOf; + }); + + var require$$0$3 = (kindOf && typeof kindOf === 'object' && 'default' in kindOf ? kindOf['default'] : kindOf); + + var isKind = __commonjs(function (module) { + var kindOf = require$$0$3; + /** + * Check if value is from a specific "kind". + */ + function isKind(val, kind){ + return kindOf(val) === kind; + } + module.exports = isKind; + }); + + var require$$0$2 = (isKind && typeof isKind === 'object' && 'default' in isKind ? isKind['default'] : isKind); + + var isArray = __commonjs(function (module) { + var isKind = require$$0$2; + /** + */ + var isArray = Array.isArray || function (val) { + return isKind(val, 'Array'); + }; + module.exports = isArray; + }); + + var require$$0$1 = (isArray && typeof isArray === 'object' && 'default' in isArray ? isArray['default'] : isArray); + + var MAX_INT = __commonjs(function (module) { + /** + * @constant Maximum 32-bit signed integer value. (2^31 - 1) + */ + + module.exports = 2147483647; + }); + + var require$$0$5 = (MAX_INT && typeof MAX_INT === 'object' && 'default' in MAX_INT ? MAX_INT['default'] : MAX_INT); + + var MIN_INT = __commonjs(function (module) { + /** + * @constant Minimum 32-bit signed integer value (-2^31). + */ + + module.exports = -2147483648; + }); + + var require$$1$1 = (MIN_INT && typeof MIN_INT === 'object' && 'default' in MIN_INT ? MIN_INT['default'] : MIN_INT); + + var random = __commonjs(function (module) { + /** + * Just a wrapper to Math.random. No methods inside mout/random should call + * Math.random() directly so we can inject the pseudo-random number + * generator if needed (ie. in case we need a seeded random or a better + * algorithm than the native one) + */ + function random(){ + return random.get(); + } + + // we expose the method so it can be swapped if needed + random.get = Math.random; + + module.exports = random; + }); + + var require$$2 = (random && typeof random === 'object' && 'default' in random ? random['default'] : random); + + var rand = __commonjs(function (module) { + var random = require$$2; + var MIN_INT = require$$1$1; + var MAX_INT = require$$0$5; + + /** + * Returns random number inside range + */ + function rand(min, max){ + min = min == null? MIN_INT : min; + max = max == null? MAX_INT : max; + return min + (max - min) * random(); + } + + module.exports = rand; + }); + + var require$$0$4 = (rand && typeof rand === 'object' && 'default' in rand ? rand['default'] : rand); + + var randInt = __commonjs(function (module) { + var MIN_INT = require$$1$1; + var MAX_INT = require$$0$5; + var rand = require$$0$4; + + /** + * Gets random integer inside range or snap to min/max values. + */ + function randInt(min, max){ + min = min == null? MIN_INT : ~~min; + max = max == null? MAX_INT : ~~max; + // can't be max + 0.5 otherwise it will round up if `rand` + // returns `max` causing it to overflow range. + // -0.5 and + 0.49 are required to avoid bias caused by rounding + return Math.round( rand(min - 0.5, max + 0.499999999999) ); + } + + module.exports = randInt; + }); + + var require$$1 = (randInt && typeof randInt === 'object' && 'default' in randInt ? randInt['default'] : randInt); + + var choice = __commonjs(function (module) { + var randInt = require$$1; + var isArray = require$$0$1; + + /** + * Returns a random element from the supplied arguments + * or from the array (if single argument is an array). + */ + function choice(items) { + var target = (arguments.length === 1 && isArray(items))? items : arguments; + return target[ randInt(0, target.length - 1) ]; + } + + module.exports = choice; + }); + + var require$$0 = (choice && typeof choice === 'object' && 'default' in choice ? choice['default'] : choice); + + var randHex = __commonjs(function (module) { + var choice = require$$0; + + var _chars = '0123456789abcdef'.split(''); + + /** + * Returns a random hexadecimal string + */ + function randHex(size){ + size = size && size > 0? size : 6; + var str = ''; + while (size--) { + str += choice(_chars); + } + return str; + } + + module.exports = randHex; + }); + + var require$$1$2 = (randHex && typeof randHex === 'object' && 'default' in randHex ? randHex['default'] : randHex); + + var guid$1 = __commonjs(function (module) { + var randHex = require$$1$2; + var choice = require$$0; + + /** + * Returns pseudo-random guid (UUID v4) + * IMPORTANT: it's not totally "safe" since randHex/choice uses Math.random + * by default and sequences can be predicted in some cases. See the + * "random/random" documentation for more info about it and how to replace + * the default PRNG. + */ + function guid() { + return ( + randHex(8)+'-'+ + randHex(4)+'-'+ + // v4 UUID always contain "4" at this position to specify it was + // randomly generated + '4' + randHex(3) +'-'+ + // v4 UUID always contain chars [a,b,8,9] at this position + choice(8, 9, 'a', 'b') + randHex(3)+'-'+ + randHex(12) + ); + } + module.exports = guid; + }); + + var guid$2 = (guid$1 && typeof guid$1 === 'object' && 'default' in guid$1 ? guid$1['default'] : guid$1); + + var guid = guid$2; + + + var __super__ = Adapter.prototype; + + var DEFAULTS = { + /** + * TODO + * + * @name LocalStorageAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * TODO + * + * @name LocalStorageAdapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * TODO + * + * @name LocalStorageAdapter#storage + * @type {Object} + * @default localStorage + */ + storage: localStorage + }; + + function isValidString(value) { + return value != null && value !== ''; + } + function join(items, separator) { + separator || (separator = ''); + return items.filter(isValidString).join(separator); + } + function makePath() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var result = join(args, '/'); + return result.replace(/([^:\/]|^)\/{2,}/g, '$1/'); + } + var queue = []; + var taskInProcess = false; + + function enqueue(task) { + queue.push(task); + } + + function dequeue() { + if (queue.length && !taskInProcess) { + taskInProcess = true; + queue[0](); + } + } + + function queueTask(task) { + if (!queue.length) { + enqueue(task); + dequeue(); + } else { + enqueue(task); + } + } + + function createTask(fn) { + return new Promise(fn).then(function (result) { + taskInProcess = false; + queue.shift(); + setTimeout(dequeue, 0); + return result; + }, function (err) { + taskInProcess = false; + queue.shift(); + setTimeout(dequeue, 0); + return jsData.utils.reject(err); + }); + } + + /** + * {@link LocalStorageAdapter} class. + * + * @name module:js-data-localstorage.LocalStorageAdapter + * @see LocalStorageAdapter + */ + + /** + * LocalStorageAdapter class. + * + * @example + * import {DataStore} from 'js-data' + * import {LocalStorageAdapter} from 'js-data-localstorage' + * const store = new DataStore() + * const adapter = new LocalStorageAdapter() + * store.registerAdapter('ls', adapter, { 'default': true }) + * + * @class LocalStorageAdapter + * @extends Adapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.basePath=''] See {@link LocalStorageAdapter#basePath}. + * @param {boolean} [opts.debug=false] See {@link Adapter#debug}. + * @param {boolean} [opts.raw=false] See {@link Adapter#raw}. + * @param {Object} [opts.storeage=localStorage] See {@link LocalStorageAdapter#storage}. + */ + function LocalStorageAdapter(opts) { + var self = this; + jsData.utils.classCallCheck(self, LocalStorageAdapter); + opts || (opts = {}); + jsData.utils.fillIn(opts, DEFAULTS); + Adapter.call(self, opts); + } + + // Setup prototype inheritance from Adapter + LocalStorageAdapter.prototype = Object.create(Adapter.prototype, { + constructor: { + value: LocalStorageAdapter, + enumerable: false, + writable: true, + configurable: true + } + }); + + Object.defineProperty(LocalStorageAdapter, '__super__', { + configurable: true, + value: Adapter + }); + + /** + * Alternative to ES6 class syntax for extending `LocalStorageAdapter`. + * + * @example Using the ES2015 class syntax. + * class MyLocalStorageAdapter extends LocalStorageAdapter {...} + * const adapter = new MyLocalStorageAdapter() + * + * @example Using {@link LocalStorageAdapter.extend}. + * var instanceProps = {...} + * var classProps = {...} + * + * var MyLocalStorageAdapter = LocalStorageAdapter.extend(instanceProps, classProps) + * var adapter = new MyLocalStorageAdapter() + * + * @method LocalStorageAdapter.extend + * @static + * @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 {Constructor} Subclass of `LocalStorageAdapter`. + */ + LocalStorageAdapter.extend = jsData.utils.extend; + + jsData.utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { + /** + * Retrieve the number of records that match the selection query. Internal + * method used by Adapter#count. + * + * @method LocalStorageAdapter#_count + * @private + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + + _count: function _count(mapper, query, opts) { + var self = this; + return self._findAll(mapper, query, opts).then(function (result) { + result[0] = result[0].length; + return result; + }); + }, + _createHelper: function _createHelper(mapper, props, opts) { + var self = this; + var _props = {}; + var relationFields = mapper.relationFields || []; + jsData.utils.forOwn(props, function (value, key) { + if (relationFields.indexOf(key) === -1) { + _props[key] = value; + } + }); + var id = jsData.utils.get(_props, mapper.idAttribute) || guid(); + jsData.utils.set(_props, mapper.idAttribute, id); + var key = self.getIdPath(mapper, opts, id); + + // Create the record + // TODO: Create related records when the "with" option is provided + self.storage.setItem(key, jsData.utils.toJson(_props)); + self.ensureId(id, mapper, opts); + return jsData.utils.fromJson(self.storage.getItem(key)); + }, + + + /** + * Create a new record. Internal method used by Adapter#create. + * + * @method LocalStorageAdapter#_create + * @private + * @param {Object} mapper The mapper. + * @param {Object} props The record to be created. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _create: function _create(mapper, props, opts) { + var self = this; + return new Promise(function (resolve) { + return resolve([self._createHelper(mapper, props, opts), {}]); + }); + }, + + + /** + * Create multiple records in a single batch. Internal method used by + * Adapter#createMany. + * + * @method LocalStorageAdapter#_createMany + * @private + * @param {Object} mapper The mapper. + * @param {Object} props The records to be created. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _createMany: function _createMany(mapper, props, opts) { + var self = this; + return new Promise(function (resolve) { + props || (props = []); + return resolve([props.map(function (_props) { + return self._createHelper(mapper, _props, opts); + }), {}]); + }); + }, + + + /** + * Destroy the record with the given primary key. Internal method used by + * Adapter#destroy. + * + * @method LocalStorageAdapter#_destroy + * @private + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to destroy. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _destroy: function _destroy(mapper, id, opts) { + var self = this; + return new Promise(function (resolve) { + self.storage.removeItem(self.getIdPath(mapper, opts, id)); + self.removeId(id, mapper, opts); + return resolve([undefined, {}]); + }); + }, + + + /** + * Destroy the records that match the selection query. Internal method used by + * Adapter#destroyAll. + * + * @method LocalStorageAdapter#_destroyAll + * @private + * @param {Object} mapper the mapper. + * @param {Object} [query] Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _destroyAll: function _destroyAll(mapper, query, opts) { + var self = this; + return self._findAll(mapper, query).then(function (results) { + var _results = babelHelpers.slicedToArray(results, 1); + + var records = _results[0]; + + var idAttribute = mapper.idAttribute; + // Gather IDs of records to be destroyed + var ids = records.map(function (record) { + return jsData.utils.get(record, idAttribute); + }); + // Destroy each record + ids.forEach(function (id) { + self.storage.removeItem(self.getIdPath(mapper, opts, id)); + }); + self.removeId(ids, mapper, opts); + return [undefined, {}]; + }); + }, + + + /** + * Retrieve the record with the given primary key. Internal method used by + * Adapter#find. + * + * @method LocalStorageAdapter#_find + * @private + * @param {Object} mapper The mapper. + * @param {(string|number)} id Primary key of the record to retrieve. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _find: function _find(mapper, id, opts) { + var self = this; + return new Promise(function (resolve) { + var key = self.getIdPath(mapper, opts, id); + var record = self.storage.getItem(key); + return resolve([record ? jsData.utils.fromJson(record) : undefined, {}]); + }); + }, + + + /** + * Retrieve the records that match the selection query. Internal method used + * by Adapter#findAll. + * + * @method LocalStorageAdapter#_findAll + * @private + * @param {Object} mapper The mapper. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _findAll: function _findAll(mapper, query, opts) { + var self = this; + query || (query = {}); + return new Promise(function (resolve) { + // Load all records into memory... + var records = []; + var ids = self.getIds(mapper, opts); + jsData.utils.forOwn(ids, function (value, id) { + var json = self.storage.getItem(self.getIdPath(mapper, opts, id)); + if (json) { + records.push(jsData.utils.fromJson(json)); + } + }); + var _query = new jsData.Query({ + index: { + getAll: function getAll() { + return records; + } + } + }); + return resolve([_query.filter(query).run(), {}]); + }); + }, + + + /** + * Retrieve the number of records that match the selection query. Internal + * method used by Adapter#sum. + * + * @method LocalStorageAdapter#_sum + * @private + * @param {Object} mapper The mapper. + * @param {string} field The field to sum. + * @param {Object} query Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _sum: function _sum(mapper, field, query, opts) { + var self = this; + return self._findAll(mapper, query, opts).then(function (result) { + var sum = 0; + result[0].forEach(function (record) { + sum += jsData.utils.get(record, field) || 0; + }); + result[0] = sum; + return result; + }); + }, + + + /** + * Apply the given update to the record with the specified primary key. + * Internal method used by Adapter#update. + * + * @method LocalStorageAdapter#_update + * @private + * @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. + * @return {Promise} + */ + _update: function _update(mapper, id, props, opts) { + var self = this; + props || (props = {}); + return new Promise(function (resolve, reject) { + var key = self.getIdPath(mapper, opts, id); + var record = self.storage.getItem(key); + if (!record) { + return reject(new Error('Not Found')); + } + record = jsData.utils.fromJson(record); + jsData.utils.deepMixIn(record, props); + self.storage.setItem(key, jsData.utils.toJson(record)); + return resolve([record, {}]); + }); + }, + + + /** + * Apply the given update to all records that match the selection query. + * Internal method used by Adapter#updateAll. + * + * @method LocalStorageAdapter#_updateAll + * @private + * @param {Object} mapper The mapper. + * @param {Object} props The update to apply to the selected records. + * @param {Object} [query] Selection query. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _updateAll: function _updateAll(mapper, props, query, opts) { + var self = this; + var idAttribute = mapper.idAttribute; + return self._findAll(mapper, query, opts).then(function (results) { + var _results2 = babelHelpers.slicedToArray(results, 1); + + var records = _results2[0]; + + records.forEach(function (record) { + record || (record = {}); + var id = jsData.utils.get(record, idAttribute); + var key = self.getIdPath(mapper, opts, id); + jsData.utils.deepMixIn(record, props); + self.storage.setItem(key, jsData.utils.toJson(record)); + }); + return [records, {}]; + }); + }, + + + /** + * Update the given records in a single batch. Internal method used by + * Adapter#updateMany. + * + * @method LocalStorageAdapter#updateMany + * @private + * @param {Object} mapper The mapper. + * @param {Object[]} records The records to update. + * @param {Object} [opts] Configuration options. + * @return {Promise} + */ + _updateMany: function _updateMany(mapper, records, opts) { + var self = this; + records || (records = []); + return new Promise(function (resolve) { + var updatedRecords = []; + var idAttribute = mapper.idAttribute; + records.forEach(function (record) { + if (!record) { + return; + } + var id = jsData.utils.get(record, idAttribute); + if (jsData.utils.isUndefined(id)) { + return; + } + var key = self.getIdPath(mapper, opts, id); + var json = self.storage.getItem(key); + if (!json) { + return; + } + var existingRecord = jsData.utils.fromJson(json); + jsData.utils.deepMixIn(existingRecord, record); + self.storage.setItem(key, jsData.utils.toJson(existingRecord)); + updatedRecords.push(existingRecord); + }); + return resolve([records, {}]); + }); + }, + create: function create(mapper, props, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.create.call(self, mapper, props, opts).then(success, failure); + }); + }); + }, + createMany: function createMany(mapper, props, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.createMany.call(self, mapper, props, opts).then(success, failure); + }); + }); + }, + destroy: function destroy(mapper, id, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.destroy.call(self, mapper, id, opts).then(success, failure); + }); + }); + }, + destroyAll: function destroyAll(mapper, query, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.destroyAll.call(self, mapper, query, opts).then(success, failure); + }); + }); + }, + + + /** + * TODO + * + * @method LocalStorageAdapter#ensureId + */ + ensureId: function ensureId(id, mapper, opts) { + var ids = this.getIds(mapper, opts); + if (jsData.utils.isArray(id)) { + if (!id.length) { + return; + } + id.forEach(function (_id) { + ids[_id] = 1; + }); + } else { + ids[id] = 1; + } + this.saveKeys(ids, mapper, opts); + }, + + + /** + * TODO + * + * @method LocalStorageAdapter#getPath + */ + getPath: function getPath(mapper, opts) { + opts = opts || {}; + return makePath(opts.basePath === undefined ? mapper.basePath === undefined ? this.basePath : mapper.basePath : opts.basePath, mapper.name); + }, + + + /** + * TODO + * + * @method LocalStorageAdapter#getIdPath + */ + getIdPath: function getIdPath(mapper, opts, id) { + opts = opts || {}; + return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id); + }, + + + /** + * TODO + * + * @method LocalStorageAdapter#getIds + */ + getIds: function getIds(mapper, opts) { + var ids = void 0; + var idsPath = this.getPath(mapper, opts); + var idsJson = this.storage.getItem(idsPath); + if (idsJson) { + ids = jsData.utils.fromJson(idsJson); + } else { + ids = {}; + } + return ids; + }, + + + /** + * TODO + * + * @method LocalStorageAdapter#removeId + */ + removeId: function removeId(id, mapper, opts) { + var ids = this.getIds(mapper, opts); + if (jsData.utils.isArray(id)) { + if (!id.length) { + return; + } + id.forEach(function (_id) { + delete ids[_id]; + }); + } else { + delete ids[id]; + } + this.saveKeys(ids, mapper, opts); + }, + + + /** + * TODO + * + * @method LocalStorageAdapter#saveKeys + */ + saveKeys: function saveKeys(ids, mapper, opts) { + ids = ids || {}; + var idsPath = this.getPath(mapper, opts); + if (Object.keys(ids).length) { + this.storage.setItem(idsPath, jsData.utils.toJson(ids)); + } else { + this.storage.removeItem(idsPath); + } + }, + update: function update(mapper, id, props, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.update.call(self, mapper, id, props, opts).then(success, failure); + }); + }); + }, + updateAll: function updateAll(mapper, props, query, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure); + }); + }); + }, + updateMany: function updateMany(mapper, records, opts) { + var self = this; + return createTask(function (success, failure) { + queueTask(function () { + __super__.updateMany.call(self, mapper, records, opts).then(success, failure); + }); + }); + } + }); + + /** + * Details of the current version of the `js-data-localstorage` module. + * + * @name module:js-data-localstorage.version + * @type {Object} + * @property {string} version.full The full semver value. + * @property {number} version.major The major version number. + * @property {number} version.minor The minor version number. + * @property {number} version.patch The patch version number. + * @property {(string|boolean)} version.alpha The alpha version value, + * otherwise `false` if the current version is not alpha. + * @property {(string|boolean)} version.beta The beta version value, + * otherwise `false` if the current version is not beta. + */ + var version = { + beta: 1, + full: '3.0.0-beta.1', + major: 3, + minor: 0, + patch: 0 +}; + + exports.LocalStorageAdapter = LocalStorageAdapter; + exports.version = version; + exports['default'] = LocalStorageAdapter; + +})); //# sourceMappingURL=js-data-localstorage.js.map \ No newline at end of file diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index 631acb9..c45cdb8 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap e52e9d21ae62b1c8472e","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:///./~/mout/random/guid.js","webpack:///./~/mout/random/randHex.js","webpack:///./~/mout/random/choice.js","webpack:///./~/mout/random/randInt.js","webpack:///./~/mout/number/MIN_INT.js","webpack:///./~/mout/number/MAX_INT.js","webpack:///./~/mout/random/rand.js","webpack:///./~/mout/random/random.js","webpack:///./~/mout/lang/isArray.js","webpack:///./~/mout/lang/isKind.js","webpack:///./~/mout/lang/kindOf.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;;;;;;;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A,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;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACtBA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;AChBA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;ACZA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AChBA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;;;;;;;;ACJA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;ACfA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;ACLA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,UAAS;AACT;AACA;AACA;AACA","file":"./dist/js-data-localstorage.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[\"LocalStorageAdapter\"] = factory(require(\"js-data\"));\n\telse\n\t\troot[\"LocalStorageAdapter\"] = 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 e52e9d21ae62b1c8472e\n **/","/* global: localStorage */\nconst JSData = require('js-data')\nconst Adapter = require('js-data-adapter')\nconst guid = require('mout/random/guid')\n\nconst {\n Query,\n utils\n} = JSData\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}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return utils.reject(err)\n })\n}\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\n}\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import LocalStorageAdapter from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @param {Object} [opts] Configuration opts.\n * @param {string} [opts.basePath=''] TODO\n * @param {boolean} [opts.debug=false] TODO\n * @param {Object} [opts.storeage=localStorage] TODO\n */\nfunction LocalStorageAdapter (opts) {\n const self = this\n utils.classCallCheck(self, LocalStorageAdapter)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nLocalStorageAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: LocalStorageAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(LocalStorageAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @name LocalStorageAdapter.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 `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#count.\n *\n * @name LocalStorageAdapter#_count\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _count (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n result[0] = result[0].length\n return result\n })\n },\n\n _createHelper (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n utils.forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = utils.get(_props, mapper.idAttribute) || guid()\n utils.set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, utils.toJson(_props))\n self.ensureId(id, mapper, opts)\n return utils.fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record. Internal method used by Adapter#create.\n *\n * @name LocalStorageAdapter#_create\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _create (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n return resolve([self._createHelper(mapper, props, opts), {}])\n })\n },\n\n /**\n * Create multiple records in a single batch. Internal method used by\n * Adapter#createMany.\n *\n * @name LocalStorageAdapter#_createMany\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _createMany (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n props || (props = [])\n return resolve([props.map(function (_props) {\n return self._createHelper(mapper, _props, opts)\n }), {}])\n })\n },\n\n /**\n * Destroy the record with the given primary key. Internal method used by\n * Adapter#destroy.\n *\n * @name LocalStorageAdapter#_destroy\n * @method\n * @private\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 * @return {Promise}\n */\n _destroy (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n return resolve([undefined, {}])\n })\n },\n\n /**\n * Destroy the records that match the selection query. Internal method used by\n * Adapter#destroyAll.\n *\n * @name LocalStorageAdapter#_destroyAll\n * @method\n * @private\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroyAll (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query).then(function (results) {\n let [records] = results\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n const ids = records.map(function (record) {\n return utils.get(record, idAttribute)\n })\n // Destroy each record\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n return [undefined, {}]\n })\n },\n\n /**\n * Retrieve the record with the given primary key. Internal method used by\n * Adapter#find.\n *\n * @name LocalStorageAdapter#_find\n * @method\n * @private\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 * @return {Promise}\n */\n _find (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n const key = self.getIdPath(mapper, opts, id)\n const record = self.storage.getItem(key)\n return resolve([record ? utils.fromJson(record) : undefined, {}])\n })\n },\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#findAll.\n *\n * @name LocalStorageAdapter#_findAll\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n return new Promise(function (resolve) {\n // Load all records into memory...\n let records = []\n const ids = self.getIds(mapper, opts)\n utils.forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(utils.fromJson(json))\n }\n })\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n return resolve([_query.filter(query).run(), {}])\n })\n },\n\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#sum.\n *\n * @name LocalStorageAdapter#_sum\n * @method\n * @private\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 * @return {Promise}\n */\n _sum (mapper, field, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n let sum = 0\n result[0].forEach(function (record) {\n sum += utils.get(record, field) || 0\n })\n result[0] = sum\n return result\n })\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n * Internal method used by Adapter#update.\n *\n * @name LocalStorageAdapter#_update\n * @method\n * @private\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 * @return {Promise}\n */\n _update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n return new Promise(function (resolve, reject) {\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n if (!record) {\n return reject(new Error('Not Found'))\n }\n record = utils.fromJson(record)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n return resolve([record, {}])\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Internal method used by Adapter#updateAll.\n *\n * @name LocalStorageAdapter#_updateAll\n * @method\n * @private\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} [opts] Configuration options.\n * @return {Promise}\n */\n _updateAll (mapper, props, query, opts) {\n const self = this\n const idAttribute = mapper.idAttribute\n return self._findAll(mapper, query, opts).then(function (results) {\n let [records] = results\n records.forEach(function (record) {\n record || (record = {})\n const id = utils.get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n })\n return [records, {}]\n })\n },\n\n /**\n * Update the given records in a single batch. Internal method used by\n * Adapter#updateMany.\n *\n * @name LocalStorageAdapter#updateMany\n * @method\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n return new Promise(function (resolve) {\n const updatedRecords = []\n const idAttribute = mapper.idAttribute\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = utils.get(record, idAttribute)\n if (utils.isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n if (!json) {\n return\n }\n const existingRecord = utils.fromJson(json)\n utils.deepMixIn(existingRecord, record)\n self.storage.setItem(key, utils.toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n return resolve([records, {}])\n })\n },\n\n create (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.create.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n createMany (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.createMany.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n destroy (mapper, id, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroy.call(self, mapper, id, opts).then(success, failure)\n })\n })\n },\n\n destroyAll (mapper, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroyAll.call(self, mapper, query, opts).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#ensureId\n * @method\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getPath\n * @method\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIdPath\n * @method\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#getIds\n * @method\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = utils.fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#removeId\n * @method\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#saveKeys\n * @method\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, utils.toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n update (mapper, id, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.update.call(self, mapper, id, props, opts).then(success, failure)\n })\n })\n },\n\n updateAll (mapper, props, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure)\n })\n })\n },\n\n updateMany (mapper, records, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateMany.call(self, mapper, records, opts).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name LocalStorageAdapter.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 */\nLocalStorageAdapter.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\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * __Script tag__:\n * ```javascript\n * window.LocalStorageAdapter\n * ```\n * __CommonJS__:\n * ```javascript\n * var LocalStorageAdapter = require('js-data-localstorage')\n * ```\n * __ES6 Modules__:\n * ```javascript\n * import LocalStorageAdapter from 'js-data-localstorage'\n * ```\n * __AMD__:\n * ```javascript\n * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... })\n * ```\n *\n * @module js-data-localstorage\n */\n\nmodule.exports = LocalStorageAdapter\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 **/","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/guid.js\n ** module id = 3\n ** module chunks = 0\n **/","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randHex.js\n ** module id = 4\n ** module chunks = 0\n **/","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/choice.js\n ** module id = 5\n ** module chunks = 0\n **/","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/randInt.js\n ** module id = 6\n ** module chunks = 0\n **/","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MIN_INT.js\n ** module id = 7\n ** module chunks = 0\n **/","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/number/MAX_INT.js\n ** module id = 8\n ** module chunks = 0\n **/","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/rand.js\n ** module id = 9\n ** module chunks = 0\n **/","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/random/random.js\n ** module id = 10\n ** module chunks = 0\n **/","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isArray.js\n ** module id = 11\n ** module chunks = 0\n **/","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/isKind.js\n ** module id = 12\n ** module chunks = 0\n **/","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/mout/lang/kindOf.js\n ** module id = 13\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"js-data-localstorage.js","sources":["../node_modules/js-data-adapter/src/index.js","../node_modules/mout/lang/kindOf.js","../node_modules/mout/lang/isKind.js","../node_modules/mout/lang/isArray.js","../node_modules/mout/number/MAX_INT.js","../node_modules/mout/number/MIN_INT.js","../node_modules/mout/random/random.js","../node_modules/mout/random/rand.js","../node_modules/mout/random/randInt.js","../node_modules/mout/random/choice.js","../node_modules/mout/random/randHex.js","../node_modules/mout/random/guid.js","../src/index.js"],"sourcesContent":["\nimport {utils} from 'js-data'\n\nexport const noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const self = this\n const opts = args[args.length - 2]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const unique = function (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\n\nexport const withoutRelations = function (mapper, props) {\n return utils.omit(props, mapper.relationFields || [])\n}\n\nconst DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\nexport function Adapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(self, opts)\n}\n\nexport const reserved = [\n 'orderBy',\n 'sort',\n 'limit',\n 'offset',\n 'skip',\n 'where'\n]\n\n/**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\nexport function Response (data, meta, op) {\n const self = this\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n self.data = data\n\n utils.fillIn(self, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n self.op = op\n}\n\n/**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\nAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(Adapter.prototype, {\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {string} field The `field` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._count(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'create'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._create(mapper, props, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'create')\n response.created = data ? 1 : 0\n response = self.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = props.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'createMany'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._createMany(mapper, props, opts))\n }).then(function (results) {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'createMany')\n response.created = data.length\n response = self.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._destroy(mapper, id, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = self.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._destroyAll(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = self.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo (mapper, def, records, __opts) {\n const self = this\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record)\n }).filter(function (key) {\n return key\n })\n return self.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem)\n }\n })\n })\n })\n }\n },\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._find(mapper, id, opts))\n }).then(function (results) {\n let [_record] = results\n if (!_record) {\n return\n }\n record = _record\n const tasks = []\n\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts)\n } else {\n task = self.loadHasMany(mapper, def, record, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(record, {}, 'find')\n response.found = record ? 1 : 0\n response = self.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n let records = []\n let op\n const activeWith = opts._activeWith\n\n if (utils.isObject(activeWith)) {\n const activeQuery = activeWith.query || {}\n if (activeWith.replace) {\n query = activeQuery\n } else {\n utils.deepFillIn(query, activeQuery)\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._findAll(mapper, query, opts))\n }).then(function (results) {\n let [_records] = results\n _records || (_records = [])\n records = _records\n const tasks = []\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts)\n } else {\n task = self.loadHasOne(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(records, {}, 'findAll')\n response.found = records.length\n response = self.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt (opt, opts) {\n opts || (opts = {})\n return utils.isUndefined(opts[opt]) ? utils.plainCopy(this[opt]) : utils.plainCopy(opts[opt])\n },\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany (mapper, def, records, __opts) {\n const self = this\n let singular = false\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n const IDs = records.map(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record)\n })\n const query = {\n where: {}\n }\n const criteria = query.where[def.foreignKey] = {}\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0]\n } else {\n criteria['in'] = IDs.filter(function (id) {\n return id\n })\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n let attached = []\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems\n } else {\n relatedItems.forEach(function (relatedItem) {\n if (utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem)\n }\n })\n }\n def.setLocalField(record, attached)\n })\n })\n },\n\n loadHasManyLocalKeys (mapper, def, records, __opts) {\n const self = this\n let record\n const relatedMapper = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record))\n })\n return self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach(function (relatedItem) {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem)\n }\n })\n def.setLocalField(item, attached)\n })\n return relatedItems\n })\n }\n },\n\n loadHasManyForeignKeys (mapper, def, records, __opts) {\n const self = this\n const relatedMapper = def.getRelation()\n const idAttribute = mapper.idAttribute\n let record\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return self.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return self.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record)\n })\n }\n }\n }, __opts).then(function (relatedItems) {\n const foreignKeysField = def.foreignKeys\n records.forEach(function (record) {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach(function (relatedItem) {\n const foreignKeys = utils.get(relatedItems, foreignKeysField) || []\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem)\n }\n })\n def.setLocalField(record, _relatedItems)\n })\n })\n }\n },\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne (mapper, def, records, __opts) {\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n }\n return this.loadHasMany(mapper, def, records, __opts).then(function () {\n records.forEach(function (record) {\n const relatedData = def.getLocalField(record)\n if (utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0])\n }\n })\n })\n },\n\n /**\n * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (Adapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n let localKeys = []\n let itemKeys = utils.get(record, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n return unique(localKeys).filter(function (x) { return x })\n },\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys (mapper, def, record) {\n return utils.get(record, mapper.idAttribute)\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n let op\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n query || (query = {})\n opts || (opts = {})\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum'\n return utils.resolve(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n self.dbg(op, mapper, field, query, opts)\n return utils.resolve(self._sum(mapper, field, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond (response, opts) {\n return this.getOpt('raw', opts) ? response : response.data\n },\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'update'\n self.dbg(op, mapper, id, props, opts)\n return utils.resolve(self._update(mapper, id, props, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'update')\n response.updated = data ? 1 : 0\n response = self.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let op\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'updateAll'\n self.dbg(op, mapper, props, query, opts)\n return utils.resolve(self._updateAll(mapper, props, query, opts))\n }).then(function (results) {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateAll')\n response.updated = data.length\n response = self.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter(function (record) {\n return utils.get(record, idAttribute)\n })\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = utils.isUndefined(_records) ? records : _records\n records = records.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'updateMany'\n self.dbg(op, mapper, records, opts)\n return utils.resolve(self._updateMany(mapper, records, opts))\n }).then(function (results) {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateMany')\n response.updated = data.length\n response = self.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n }\n})\n","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n","/* global: localStorage */\n\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * @example Script tag\n * var LocalStorageAdapter = window.JSDataLocalStorage.LocalStorageAdapter\n * var adapter = new LocalStorageAdapter()\n *\n * @example CommonJS\n * var LocalStorageAdapter = require('js-data-localstorage').LocalStorageAdapter\n * var adapter = new LocalStorageAdapter()\n *\n * @example ES6 Modules\n * import {LocalStorageAdapter} from 'js-data-localstorage'\n * const adapter = new LocalStorageAdapter()\n *\n * @example AMD\n * define('myApp', ['js-data-localstorage'], function (JSDataLocalStorage) {\n * var LocalStorageAdapter = JSDataLocalStorage.LocalStorageAdapter\n * var adapter = new LocalStorageAdapter()\n *\n * // ...\n * })\n *\n * @module js-data-localstorage\n */\n\nimport {Query, utils} from 'js-data'\nimport {Adapter} from '../node_modules/js-data-adapter/src/index'\n\n// This is kinda weird, but it's so we can use Rollup.js\nimport * as Guid from '../node_modules/mout/random/guid'\nconst { default: guid } = Guid\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\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}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return utils.reject(err)\n })\n}\n\n/**\n * {@link LocalStorageAdapter} class.\n *\n * @name module:js-data-localstorage.LocalStorageAdapter\n * @see LocalStorageAdapter\n */\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import {LocalStorageAdapter} from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link LocalStorageAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link Adapter#debug}.\n * @param {boolean} [opts.raw=false] See {@link Adapter#raw}.\n * @param {Object} [opts.storeage=localStorage] See {@link LocalStorageAdapter#storage}.\n */\nexport function LocalStorageAdapter (opts) {\n const self = this\n utils.classCallCheck(self, LocalStorageAdapter)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nLocalStorageAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: LocalStorageAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(LocalStorageAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyLocalStorageAdapter extends LocalStorageAdapter {...}\n * const adapter = new MyLocalStorageAdapter()\n *\n * @example Using {@link LocalStorageAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyLocalStorageAdapter = LocalStorageAdapter.extend(instanceProps, classProps)\n * var adapter = new MyLocalStorageAdapter()\n *\n * @method LocalStorageAdapter.extend\n * @static\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 {Constructor} Subclass of `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#count.\n *\n * @method LocalStorageAdapter#_count\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _count (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n result[0] = result[0].length\n return result\n })\n },\n\n _createHelper (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n utils.forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = utils.get(_props, mapper.idAttribute) || guid()\n utils.set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, utils.toJson(_props))\n self.ensureId(id, mapper, opts)\n return utils.fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record. Internal method used by Adapter#create.\n *\n * @method LocalStorageAdapter#_create\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _create (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n return resolve([self._createHelper(mapper, props, opts), {}])\n })\n },\n\n /**\n * Create multiple records in a single batch. Internal method used by\n * Adapter#createMany.\n *\n * @method LocalStorageAdapter#_createMany\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _createMany (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n props || (props = [])\n return resolve([props.map(function (_props) {\n return self._createHelper(mapper, _props, opts)\n }), {}])\n })\n },\n\n /**\n * Destroy the record with the given primary key. Internal method used by\n * Adapter#destroy.\n *\n * @method LocalStorageAdapter#_destroy\n * @private\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 * @return {Promise}\n */\n _destroy (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n return resolve([undefined, {}])\n })\n },\n\n /**\n * Destroy the records that match the selection query. Internal method used by\n * Adapter#destroyAll.\n *\n * @method LocalStorageAdapter#_destroyAll\n * @private\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroyAll (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query).then(function (results) {\n let [records] = results\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n const ids = records.map(function (record) {\n return utils.get(record, idAttribute)\n })\n // Destroy each record\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n return [undefined, {}]\n })\n },\n\n /**\n * Retrieve the record with the given primary key. Internal method used by\n * Adapter#find.\n *\n * @method LocalStorageAdapter#_find\n * @private\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 * @return {Promise}\n */\n _find (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n const key = self.getIdPath(mapper, opts, id)\n const record = self.storage.getItem(key)\n return resolve([record ? utils.fromJson(record) : undefined, {}])\n })\n },\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#findAll.\n *\n * @method LocalStorageAdapter#_findAll\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n return new Promise(function (resolve) {\n // Load all records into memory...\n let records = []\n const ids = self.getIds(mapper, opts)\n utils.forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(utils.fromJson(json))\n }\n })\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n return resolve([_query.filter(query).run(), {}])\n })\n },\n\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#sum.\n *\n * @method LocalStorageAdapter#_sum\n * @private\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 * @return {Promise}\n */\n _sum (mapper, field, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n let sum = 0\n result[0].forEach(function (record) {\n sum += utils.get(record, field) || 0\n })\n result[0] = sum\n return result\n })\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n * Internal method used by Adapter#update.\n *\n * @method LocalStorageAdapter#_update\n * @private\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 * @return {Promise}\n */\n _update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n return new Promise(function (resolve, reject) {\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n if (!record) {\n return reject(new Error('Not Found'))\n }\n record = utils.fromJson(record)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n return resolve([record, {}])\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Internal method used by Adapter#updateAll.\n *\n * @method LocalStorageAdapter#_updateAll\n * @private\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} [opts] Configuration options.\n * @return {Promise}\n */\n _updateAll (mapper, props, query, opts) {\n const self = this\n const idAttribute = mapper.idAttribute\n return self._findAll(mapper, query, opts).then(function (results) {\n let [records] = results\n records.forEach(function (record) {\n record || (record = {})\n const id = utils.get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n })\n return [records, {}]\n })\n },\n\n /**\n * Update the given records in a single batch. Internal method used by\n * Adapter#updateMany.\n *\n * @method LocalStorageAdapter#updateMany\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n return new Promise(function (resolve) {\n const updatedRecords = []\n const idAttribute = mapper.idAttribute\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = utils.get(record, idAttribute)\n if (utils.isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n if (!json) {\n return\n }\n const existingRecord = utils.fromJson(json)\n utils.deepMixIn(existingRecord, record)\n self.storage.setItem(key, utils.toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n return resolve([records, {}])\n })\n },\n\n create (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.create.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n createMany (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.createMany.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n destroy (mapper, id, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroy.call(self, mapper, id, opts).then(success, failure)\n })\n })\n },\n\n destroyAll (mapper, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroyAll.call(self, mapper, query, opts).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#ensureId\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#getPath\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#getIdPath\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#getIds\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = utils.fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#removeId\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#saveKeys\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, utils.toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n update (mapper, id, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.update.call(self, mapper, id, props, opts).then(success, failure)\n })\n })\n },\n\n updateAll (mapper, props, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure)\n })\n })\n },\n\n updateMany (mapper, records, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateMany.call(self, mapper, records, opts).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name module:js-data-localstorage.version\n * @type {Object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\nexport default LocalStorageAdapter\n"],"names":["utils","DEFAULTS","require$$0","require$$1","require$$2","Guid.default","Query"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGO,IAAM,OAAO,SAAP,IAAO,GAAmB;AACrC,EAAA,MAAM,OAAO,IAAb;;AADqC,EAAA,oCAAN,IAAM;AAAN,EAAA,QAAM;AAAA,EAAA;;AAErC,EAAA,MAAM,OAAO,KAAK,KAAK,MAAL,GAAc,CAAnB,CAAb;AACA,EAAA,OAAK,GAAL,cAAS,KAAK,EAAd,SAAqB,IAArB;AACA,EAAA,SAAOA,aAAM,OAAN,EAAP;AACD,EAAA,CALM;;AAOP,EAAO,IAAM,QAAQ,SAAR,KAAQ,GAAmB;AACtC,EAAA,MAAM,OAAO,IAAb;;AADsC,EAAA,qCAAN,IAAM;AAAN,EAAA,QAAM;AAAA,EAAA;;AAEtC,EAAA,MAAM,OAAO,KAAK,KAAK,MAAL,GAAc,CAAnB,CAAb;AACA,EAAA,OAAK,GAAL,cAAS,KAAK,EAAd,SAAqB,IAArB;AACA,EAAA,SAAOA,aAAM,OAAN,EAAP;AACD,EAAA,CALM;;AAOP,EAAO,IAAM,SAAS,SAAT,MAAS,CAAU,KAAV,EAAiB;AACrC,EAAA,MAAM,OAAO,EAAb;AACA,EAAA,MAAM,QAAQ,EAAd;AACA,EAAA,QAAM,OAAN,CAAc,UAAU,IAAV,EAAgB;AAC5B,EAAA,QAAI,QAAQ,IAAZ,EAAkB;AAChB,EAAA;AACD,EAAA;AACD,EAAA,UAAM,IAAN,CAAW,IAAX;AACA,EAAA,SAAK,IAAL,IAAa,CAAb;AACD,EAAA,GAND;AAOA,EAAA,SAAO,KAAP;AACD,EAA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B,OAAnB,EAA4B;AAC5C,EAAA,gBAAU,YAAY;AACpB,EAAA,kBAAU,UAAV,CAAqB,IAArB,CAA0B,IAA1B,EAAgC,MAAhC,EAAwC,OAAxC,EAAiD,IAAjD,EAAuD,IAAvD,CAA4D,OAA5D,EAAqE,OAArE;AACD,EAAA,OAFD;AAGD,EAAA,KAJM,CAAP;AAKD,EAAA;AAtcyD,EAAA,CAA5D;;;;;;;;;;;;;;;;AAudA,EAAO,IAAM,UAAU,gBAAhB;;;;;;"} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index d92fbb4..d114ad2 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -1,11 +1,11 @@ /*! * js-data-localstorage -* @version 3.0.0-alpha.7 - Homepage +* @version 3.0.0-beta.1 - Homepage * @author Jason Dobry * @copyright (c) 2014-2016 Jason Dobry * @license MIT * * @overview localStorage adapter for js-data. */ -!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.LocalStorageAdapter=t(require("js-data")):e.LocalStorageAdapter=t(e.JSData)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return null!=e&&""!==e}function o(e,t){return t||(t=""),e.filter(r).join(t)}function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];var r=o(t,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function a(e){g.push(e)}function u(){g.length&&!b&&(b=!0,g[0]())}function s(e){g.length?a(e):(a(e),u())}function l(e){return new Promise(e).then(function(e){return b=!1,g.shift(),setTimeout(u,0),e},function(e){return b=!1,g.shift(),setTimeout(u,0),y.reject(e)})}function f(e){var t=this;y.classCallCheck(t,f),e||(e={}),y.fillIn(e,m),h.call(t,e)}var c=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=n(1),h=n(2),p=n(3),v=d.Query,y=d.utils,g=[],b=!1,A=h.prototype,m={basePath:"",debug:!1,storage:localStorage};f.prototype=Object.create(h.prototype,{constructor:{value:f,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(f,"__super__",{configurable:!0,value:h}),f.extend=y.extend,y.addHiddenPropsToTarget(f.prototype,{_count:function(e,t,n){var r=this;return r._findAll(e,t,n).then(function(e){return e[0]=e[0].length,e})},_createHelper:function(e,t,n){var r=this,o={},i=e.relationFields||[];y.forOwn(t,function(e,t){-1===i.indexOf(t)&&(o[t]=e)});var a=y.get(o,e.idAttribute)||p();y.set(o,e.idAttribute,a);var u=r.getIdPath(e,n,a);return r.storage.setItem(u,y.toJson(o)),r.ensureId(a,e,n),y.fromJson(r.storage.getItem(u))},_create:function(e,t,n){var r=this;return new Promise(function(o){return o([r._createHelper(e,t,n),{}])})},_createMany:function(e,t,n){var r=this;return new Promise(function(o){return t||(t=[]),o([t.map(function(t){return r._createHelper(e,t,n)}),{}])})},_destroy:function(e,t,n){var r=this;return new Promise(function(o){return r.storage.removeItem(r.getIdPath(e,n,t)),r.removeId(t,e,n),o([void 0,{}])})},_destroyAll:function(e,t,n){var r=this;return r._findAll(e,t).then(function(t){var o=c(t,1),i=o[0],a=e.idAttribute,u=i.map(function(e){return y.get(e,a)});return u.forEach(function(t){r.storage.removeItem(r.getIdPath(e,n,t))}),r.removeId(u,e,n),[void 0,{}]})},_find:function(e,t,n){var r=this;return new Promise(function(o){var i=r.getIdPath(e,n,t),a=r.storage.getItem(i);return o([a?y.fromJson(a):void 0,{}])})},_findAll:function(e,t,n){var r=this;return t||(t={}),new Promise(function(o){var i=[],a=r.getIds(e,n);y.forOwn(a,function(t,o){var a=r.storage.getItem(r.getIdPath(e,n,o));a&&i.push(y.fromJson(a))});var u=new v({index:{getAll:function(){return i}}});return o([u.filter(t).run(),{}])})},_sum:function(e,t,n,r){var o=this;return o._findAll(e,n,r).then(function(e){var n=0;return e[0].forEach(function(e){n+=y.get(e,t)||0}),e[0]=n,e})},_update:function(e,t,n,r){var o=this;return n||(n={}),new Promise(function(i,a){var u=o.getIdPath(e,r,t),s=o.storage.getItem(u);return s?(s=y.fromJson(s),y.deepMixIn(s,n),o.storage.setItem(u,y.toJson(s)),i([s,{}])):a(new Error("Not Found"))})},_updateAll:function(e,t,n,r){var o=this,i=e.idAttribute;return o._findAll(e,n,r).then(function(n){var a=c(n,1),u=a[0];return u.forEach(function(n){n||(n={});var a=y.get(n,i),u=o.getIdPath(e,r,a);y.deepMixIn(n,t),o.storage.setItem(u,y.toJson(n))}),[u,{}]})},_updateMany:function(e,t,n){var r=this;return t||(t=[]),new Promise(function(o){var i=[],a=e.idAttribute;return t.forEach(function(t){if(t){var o=y.get(t,a);if(!y.isUndefined(o)){var u=r.getIdPath(e,n,o),s=r.storage.getItem(u);if(s){var l=y.fromJson(s);y.deepMixIn(l,t),r.storage.setItem(u,y.toJson(l)),i.push(l)}}}}),o([t,{}])})},create:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.create.call(r,e,t,n).then(o,i)})})},createMany:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.createMany.call(r,e,t,n).then(o,i)})})},destroy:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.destroy.call(r,e,t,n).then(o,i)})})},destroyAll:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.destroyAll.call(r,e,t,n).then(o,i)})})},ensureId:function(e,t,n){var r=this.getIds(t,n);if(y.isArray(e)){if(!e.length)return;e.forEach(function(e){r[e]=1})}else r[e]=1;this.saveKeys(r,t,n)},getPath:function(e,t){return t=t||{},i(void 0===t.basePath?void 0===e.basePath?this.basePath:e.basePath:t.basePath,e.name)},getIdPath:function(e,t,n){return t=t||{},i(t.basePath||this.basePath||e.basePath,e.endpoint,n)},getIds:function(e,t){var n=void 0,r=this.getPath(e,t),o=this.storage.getItem(r);return n=o?y.fromJson(o):{}},removeId:function(e,t,n){var r=this.getIds(t,n);if(y.isArray(e)){if(!e.length)return;e.forEach(function(e){delete r[e]})}else delete r[e];this.saveKeys(r,t,n)},saveKeys:function(e,t,n){e=e||{};var r=this.getPath(t,n);Object.keys(e).length?this.storage.setItem(r,y.toJson(e)):this.storage.removeItem(r)},update:function(e,t,n,r){var o=this;return l(function(i,a){s(function(){A.update.call(o,e,t,n,r).then(i,a)})})},updateAll:function(e,t,n,r){var o=this;return l(function(i,a){s(function(){A.updateAll.call(o,e,t,n,r).then(i,a)})})},updateMany:function(e,t,n){var r=this;return l(function(o,i){s(function(){A.updateMany.call(r,e,t,n).then(o,i)})})}}),f.version={full:"<%= pkg.version %>",major:parseInt("<%= major %>",10),minor:parseInt("<%= minor %>",10),patch:parseInt("<%= patch %>",10),alpha:"<%= alpha %>",beta:"<%= beta %>"},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,l),t.utils.fillIn(n,e)}function r(e,n,r){var o=this;n||(n={}),o.data=e,t.utils.fillIn(o,n),o.op=r}var o={};o.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o.defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},o.slicedToArray=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var i=function(){for(var e=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-1];return e.dbg.apply(e,[i.op].concat(r)),t.utils.resolve()},a=function(){for(var e=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-2];return e.dbg.apply(e,[i.op].concat(r)),t.utils.resolve()},u=function(e){var t={},n=[];return e.forEach(function(e){e in t||(n.push(e),t[e]=0)}),n},s=function(e,n){return t.utils.omit(n,e.relationFields||[])},l={debug:!1,raw:!1};n.reserved=["orderBy","sort","limit","offset","skip","where"],n.Response=r,n.extend=t.utils.extend,t.utils.addHiddenPropsToTarget(n.prototype,{afterCount:a,afterCreate:a,afterCreateMany:a,afterDestroy:a,afterDestroyAll:a,afterFind:a,afterFindAll:a,afterSum:a,afterUpdate:a,afterUpdateAll:a,afterUpdateMany:a,beforeCount:i,beforeCreate:i,beforeCreateMany:i,beforeDestroy:i,beforeDestroyAll:i,beforeFind:i,beforeFindAll:i,beforeSum:i,beforeUpdate:i,beforeUpdateAll:i,beforeUpdateMany:i,dbg:function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];this.log.apply(this,["debug"].concat(t))},count:function(e,n,i){var a=this,u=void 0;return n||(n={}),i||(i={}),u=i.op="beforeCount",t.utils.resolve(a[u](e,n,i)).then(function(){return u=i.op="count",a.dbg(u,e,n,i),t.utils.resolve(a._count(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new r(f,c,u);return d=a.respond(d,i),u=i.op="afterCount",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},create:function(e,n,i){var a=this,u=void 0;return n||(n={}),i||(i={}),u=i.op="beforeCreate",t.utils.resolve(a[u](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=s(e,n),u=i.op="create",a.dbg(u,e,n,i),t.utils.resolve(a._create(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new r(f,c,"create");return d.created=f?1:0,d=a.respond(d,i),u=i.op="afterCreate",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},createMany:function(e,n,i){var a=this,u=void 0;return n||(n={}),i||(i={}),u=i.op="beforeCreateMany",t.utils.resolve(a[u](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),u=i.op="createMany",a.dbg(u,e,n,i),t.utils.resolve(a._createMany(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];f||(f=[]),c||(c={});var d=new r(f,c,"createMany");return d.created=f.length,d=a.respond(d,i),u=i.op="afterCreateMany",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroy:function(e,n,i){var a=this,u=void 0;return i||(i={}),u=i.op="beforeDestroy",t.utils.resolve(a[u](e,n,i)).then(function(){return u=i.op="destroy",a.dbg(u,e,n,i),t.utils.resolve(a._destroy(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new r(f,c,"destroy");return d=a.respond(d,i),u=i.op="afterDestroy",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})},destroyAll:function(e,n,i){var a=this,u=void 0;return n||(n={}),i||(i={}),u=i.op="beforeDestroyAll",t.utils.resolve(a[u](e,n,i)).then(function(){return u=i.op="destroyAll",a.dbg(u,e,n,i),t.utils.resolve(a._destroyAll(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new r(f,c,"destroyAll");return d=a.respond(d,i),u=i.op="afterDestroyAll",t.utils.resolve(a[u](e,n,i,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 o=[],i=t.utils.get(r,n.localKeys)||[];return i=t.utils.isArray(i)?i:Object.keys(i),o=o.concat(i),u(o).filter(function(e){return e})},makeHasManyForeignKeys:function(e,n,r){return t.utils.get(r,e.idAttribute)},loadHasMany:function(e,n,r,o){var i=this,a=!1;t.utils.isObject(r)&&!t.utils.isArray(r)&&(a=!0,r=[r]);var u=r.map(function(t){return i.makeHasManyForeignKey(e,n,t)}),s={where:{}},l=s.where[n.foreignKey]={};return a?l["=="]=u[0]:l.in=u.filter(function(e){return e}),i.findAll(n.getRelation(),s,o).then(function(o){r.forEach(function(r){var i=[];a?i=o:o.forEach(function(o){t.utils.get(o,n.foreignKey)===r[e.idAttribute]&&i.push(o)}),n.setLocalField(r,i)})})},loadHasManyLocalKeys:function(e,n,r,i){var a=this,s=void 0,l=n.getRelation();if(t.utils.isObject(r)&&!t.utils.isArray(r)&&(s=r),s)return a.findAll(l,{where:o.defineProperty({},l.idAttribute,{in:a.makeHasManyLocalKeys(e,n,s)})},i).then(function(e){n.setLocalField(s,e)});var f=function(){var s=[];return r.forEach(function(t){s=s.concat(a.self.makeHasManyLocalKeys(e,n,t))}),{v:a.findAll(l,{where:o.defineProperty({},l.idAttribute,{in:u(s).filter(function(e){return e})})},i).then(function(e){return r.forEach(function(r){var o=[],i=t.utils.get(r,n.localKeys)||[];i=t.utils.isArray(i)?i:Object.keys(i),e.forEach(function(e){i&&-1!==i.indexOf(e[l.idAttribute])&&o.push(e)}),n.setLocalField(r,o)}),e})}}();return"object"===("undefined"==typeof f?"undefined":o.typeof(f))?f.v:void 0},loadHasManyForeignKeys:function(e,n,r,i){var a=this,u=n.getRelation(),s=e.idAttribute,l=void 0;return t.utils.isObject(r)&&!t.utils.isArray(r)&&(l=r),l?a.findAll(n.getRelation(),{where:o.defineProperty({},n.foreignKeys,{contains:a.makeHasManyForeignKeys(e,n,l)})},i).then(function(e){n.setLocalField(l,e)}):a.findAll(u,{where:o.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(t){return a.makeHasManyForeignKeys(e,n,t)})})},i).then(function(e){var o=n.foreignKeys;r.forEach(function(r){var i=[],a=t.utils.get(r,s);e.forEach(function(n){var r=t.utils.get(e,o)||[];-1!==r.indexOf(a)&&i.push(n)}),n.setLocalField(r,i)})})},loadHasOne:function(e,n,r,o){return t.utils.isObject(r)&&!t.utils.isArray(r)&&(r=[r]),this.loadHasMany(e,n,r,o).then(function(){r.forEach(function(e){var r=n.getLocalField(e);t.utils.isArray(r)&&r.length&&n.setLocalField(e,r[0])})})},makeBelongsToForeignKey:function(e,t,n){return t.getForeignKey(n)},loadBelongsTo:function(e,n,r,i){var a=this,u=n.getRelation();if(!t.utils.isObject(r)||t.utils.isArray(r)){var s=r.map(function(t){return a.makeBelongsToForeignKey(e,n,t)}).filter(function(e){return e});return a.findAll(u,{where:o.defineProperty({},u.idAttribute,{in:s})},i).then(function(e){r.forEach(function(t){e.forEach(function(e){e[u.idAttribute]===t[n.foreignKey]&&n.setLocalField(t,e)})})})}var l=function(){var t=r;return{v:a.find(u,a.makeBelongsToForeignKey(e,n,t),i).then(function(e){n.setLocalField(t,e)})}}();return"object"===("undefined"==typeof l?"undefined":o.typeof(l))?l.v:void 0},find:function(e,n,i){var a=this,u=void 0,s=void 0;return i||(i={}),i.with||(i.with=[]),s=i.op="beforeFind",t.utils.resolve(a[s](e,n,i)).then(function(){return s=i.op="find",a.dbg(s,e,n,i),t.utils.resolve(a._find(e,n,i))}).then(function(n){var r=o.slicedToArray(n,1),s=r[0];if(s){u=s;var l=[];return t.utils.forEachRelation(e,i,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=a.loadHasManyLocalKeys(e,t,u,n):"hasMany"===t.type&&t.foreignKeys?r=a.loadHasManyForeignKeys(e,t,u,n):"belongsTo"===t.type&&(r=a.loadBelongsTo(e,t,u,n)):r="hasOne"===t.type?a.loadHasOne(e,t,u,n):a.loadHasMany(e,t,u,n),r&&l.push(r)}),Promise.all(l)}}).then(function(){var o=new r(u,{},"find");return o.found=u?1:0,o=a.respond(o,i),s=i.op="afterFind",t.utils.resolve(a[s](e,n,i,o)).then(function(e){return t.utils.isUndefined(e)?o:e})})},findAll:function(e,n,i){var a=this;i||(i={}),i.with||(i.with=[]);var u=[],s=void 0,l=i._activeWith;if(t.utils.isObject(l)){var f=l.query||{};l.replace?n=f:t.utils.deepFillIn(n,f)}return s=i.op="beforeFindAll",t.utils.resolve(a[s](e,n,i)).then(function(){return s=i.op="findAll",a.dbg(s,e,n,i),t.utils.resolve(a._findAll(e,n,i))}).then(function(n){var r=o.slicedToArray(n,1),s=r[0];s||(s=[]),u=s;var l=[];return t.utils.forEachRelation(e,i,function(t,n){var r=void 0;!t.foreignKey||"hasOne"!==t.type&&"hasMany"!==t.type?"hasMany"===t.type&&t.localKeys?r=a.loadHasManyLocalKeys(e,t,u,n):"hasMany"===t.type&&t.foreignKeys?r=a.loadHasManyForeignKeys(e,t,u,n):"belongsTo"===t.type&&(r=a.loadBelongsTo(e,t,u,n)):r="hasMany"===t.type?a.loadHasMany(e,t,u,n):a.loadHasOne(e,t,u,n),r&&l.push(r)}),Promise.all(l)}).then(function(){var o=new r(u,{},"findAll");return o.found=u.length,o=a.respond(o,i),s=i.op="afterFindAll",t.utils.resolve(a[s](e,n,i,o)).then(function(e){return t.utils.isUndefined(e)?o:e})})},getOpt:function(e,n){return n||(n={}),t.utils.isUndefined(n[e])?t.utils.plainCopy(this[e]):t.utils.plainCopy(n[e])},log:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];if(e&&!n.length&&(n.push(e),e="debug"),"debug"!==e||this.debug){var o=e.toUpperCase()+": (Adapter)";if(console[e]){var i;(i=console)[e].apply(i,[o].concat(n))}else{var a;(a=console).log.apply(a,[o].concat(n))}}},sum:function(e,n,i,a){var u=this,s=void 0;if(!t.utils.isString(n))throw new Error("field must be a string!");return i||(i={}),a||(a={}),s=a.op="beforeSum",t.utils.resolve(u[s](e,n,i,a)).then(function(){return s=a.op="sum",u.dbg(s,e,n,i,a),t.utils.resolve(u._sum(e,n,i,a))}).then(function(l){var f=o.slicedToArray(l,2),c=f[0],d=f[1];d||(d={});var h=new r(c,d,s);return h=u.respond(h,a),s=a.op="afterSum",t.utils.resolve(u[s](e,n,i,a,h)).then(function(e){return t.utils.isUndefined(e)?h:e})})},respond:function(e,t){return this.getOpt("raw",t)?e:e.data},update:function(e,n,i,a){var u=this;i||(i={}),a||(a={});var s=void 0;return s=a.op="beforeUpdate",t.utils.resolve(u[s](e,n,i,a)).then(function(r){return i=t.utils.isUndefined(r)?i:r,s=a.op="update",u.dbg(s,e,n,i,a),t.utils.resolve(u._update(e,n,i,a))}).then(function(l){var f=o.slicedToArray(l,2),c=f[0],d=f[1];d||(d={});var h=new r(c,d,"update");return h.updated=c?1:0,h=u.respond(h,a),s=a.op="afterUpdate",t.utils.resolve(u[s](e,n,i,a,h)).then(function(e){return t.utils.isUndefined(e)?h:e})})},updateAll:function(e,n,i,a){var u=this;n||(n={}),i||(i={}),a||(a={});var s=void 0;return s=a.op="beforeUpdateAll",t.utils.resolve(u[s](e,n,i,a)).then(function(r){return n=t.utils.isUndefined(r)?n:r,s=a.op="updateAll",u.dbg(s,e,n,i,a),t.utils.resolve(u._updateAll(e,n,i,a))}).then(function(l){var f=o.slicedToArray(l,2),c=f[0],d=f[1];c||(c=[]),d||(d={});var h=new r(c,d,"updateAll");return h.updated=c.length,h=u.respond(h,a),s=a.op="afterUpdateAll",t.utils.resolve(u[s](e,n,i,a,h)).then(function(e){return t.utils.isUndefined(e)?h:e})})},updateMany:function(e,n,i){var a=this;n||(n=[]),i||(i={});var u=void 0,l=e.idAttribute;return n=n.filter(function(e){return t.utils.get(e,l)}),u=i.op="beforeUpdateMany",t.utils.resolve(a[u](e,n,i)).then(function(r){return n=t.utils.isUndefined(r)?n:r,n=n.map(function(t){return s(e,t)}),u=i.op="updateMany",a.dbg(u,e,n,i),t.utils.resolve(a._updateMany(e,n,i))}).then(function(s){var l=o.slicedToArray(s,2),f=l[0],c=l[1];f||(f=[]),c||(c={});var d=new r(f,c,"updateMany");return d.updated=f.length,d=a.respond(d,i),u=i.op="afterUpdateMany",t.utils.resolve(a[u](e,n,i,d)).then(function(e){return t.utils.isUndefined(e)?d:e})})}}),e.exports=n})},function(e,t,n){function r(){return o(8)+"-"+o(4)+"-4"+o(3)+"-"+i(8,9,"a","b")+o(3)+"-"+o(12)}var o=n(4),i=n(5);e.exports=r},function(e,t,n){function r(e){e=e&&e>0?e:6;for(var t="";e--;)t+=o(i);return t}var o=n(5),i="0123456789abcdef".split("");e.exports=r},function(e,t,n){function r(e){var t=1===arguments.length&&i(e)?e:arguments;return t[o(0,t.length-1)]}var o=n(6),i=n(11);e.exports=r},function(e,t,n){function r(e,t){return e=null==e?o:~~e,t=null==t?i:~~t,Math.round(a(e-.5,t+.499999999999))}var o=n(7),i=n(8),a=n(9);e.exports=r},function(e,t){e.exports=-2147483648},function(e,t){e.exports=2147483647},function(e,t,n){function r(e,t){return e=null==e?i:e,t=null==t?a:t,e+(t-e)*o()}var o=n(10),i=n(7),a=n(8);e.exports=r},function(e,t){function n(){return n.get()}n.get=Math.random,e.exports=n},function(e,t,n){var r=n(12),o=Array.isArray||function(e){return r(e,"Array")};e.exports=o},function(e,t,n){function r(e,t){return o(e)===t}var o=n(13);e.exports=r},function(e,t){function n(e){return null===e?"Null":e===r?"Undefined":o.exec(i.call(e))[1]}var r,o=/^\[object (.*)\]$/,i=Object.prototype.toString;e.exports=n}])}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-localstorage",["exports","js-data"],e):e(t.JSDataLocalStorage=t.JSDataLocalStorage||{},t.JSData)}(this,function(t,e){"use strict";function n(t,e){return e={exports:{}},t(e,e.exports),e.exports}function r(t){var n=this;t||(t={}),e.utils.fillIn(t,b),e.utils.fillIn(n,t)}function o(t,n,r){var o=this;n||(n={}),o.data=t,e.utils.fillIn(o,n),o.op=r}function i(t){return null!=t&&""!==t}function u(t,e){return e||(e=""),t.filter(i).join(e)}function a(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=u(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function s(t){q.push(t)}function l(){q.length&&!$&&($=!0,q[0]())}function f(t){q.length?s(t):(s(t),l())}function c(t){return new Promise(t).then(function(t){return $=!1,q.shift(),setTimeout(l,0),t},function(t){return $=!1,q.shift(),setTimeout(l,0),e.utils.reject(t)})}function d(t){var n=this;e.utils.classCallCheck(n,d),t||(t={}),e.utils.fillIn(t,N),r.call(n,t)}var h={};h.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},h.defineProperty=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},h.slicedToArray=function(){function t(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var y=function(){for(var t=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-1];return t.dbg.apply(t,[i.op].concat(r)),e.utils.resolve()},p=function(){for(var t=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-2];return t.dbg.apply(t,[i.op].concat(r)),e.utils.resolve()},v=function(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n},g=function(t,n){return e.utils.omit(n,t.relationFields||[])},b={debug:!1,raw:!1};r.extend=e.utils.extend,e.utils.addHiddenPropsToTarget(r.prototype,{afterCount:p,afterCreate:p,afterCreateMany:p,afterDestroy:p,afterDestroyAll:p,afterFind:p,afterFindAll:p,afterSum:p,afterUpdate:p,afterUpdateAll:p,afterUpdateMany:p,beforeCount:y,beforeCreate:y,beforeCreateMany:y,beforeDestroy:y,beforeDestroyAll:y,beforeFind:y,beforeFindAll:y,beforeSum:y,beforeUpdate:y,beforeUpdateAll:y,beforeUpdateMany:y,dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},count:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeCount",e.utils.resolve(i[u](t,n,r)).then(function(){return u=r.op="count",i.dbg(u,t,n,r),e.utils.resolve(i._count(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,u);return c=i.respond(c,r),u=r.op="afterCount",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},create:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeCreate",e.utils.resolve(i[u](t,n,r)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=g(t,n),u=r.op="create",i.dbg(u,t,n,r),e.utils.resolve(i._create(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,"create");return c.created=l?1:0,c=i.respond(c,r),u=r.op="afterCreate",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},createMany:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeCreateMany",e.utils.resolve(i[u](t,n,r)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=n.map(function(e){return g(t,e)}),u=r.op="createMany",i.dbg(u,t,n,r),e.utils.resolve(i._createMany(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];l||(l=[]),f||(f={});var c=new o(l,f,"createMany");return c.created=l.length,c=i.respond(c,r),u=r.op="afterCreateMany",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},destroy:function(t,n,r){var i=this,u=void 0;return r||(r={}),u=r.op="beforeDestroy",e.utils.resolve(i[u](t,n,r)).then(function(){return u=r.op="destroy",i.dbg(u,t,n,r),e.utils.resolve(i._destroy(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,"destroy");return c=i.respond(c,r),u=r.op="afterDestroy",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},destroyAll:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeDestroyAll",e.utils.resolve(i[u](t,n,r)).then(function(){return u=r.op="destroyAll",i.dbg(u,t,n,r),e.utils.resolve(i._destroyAll(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,"destroyAll");return c=i.respond(c,r),u=r.op="afterDestroyAll",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},loadBelongsTo:function(t,n,r,o){var i=this,u=n.getRelation();if(!e.utils.isObject(r)||e.utils.isArray(r)){var a=r.map(function(e){return i.makeBelongsToForeignKey(t,n,e)}).filter(function(t){return t});return i.findAll(u,{where:h.defineProperty({},u.idAttribute,{in:a})},o).then(function(t){r.forEach(function(e){t.forEach(function(t){t[u.idAttribute]===e[n.foreignKey]&&n.setLocalField(e,t)})})})}var s=function(){var e=r;return{v:i.find(u,i.makeBelongsToForeignKey(t,n,e),o).then(function(t){n.setLocalField(e,t)})}}();return"object"===("undefined"==typeof s?"undefined":h.typeof(s))?s.v:void 0},find:function(t,n,r){var i=this,u=void 0,a=void 0;return r||(r={}),r.with||(r.with=[]),a=r.op="beforeFind",e.utils.resolve(i[a](t,n,r)).then(function(){return a=r.op="find",i.dbg(a,t,n,r),e.utils.resolve(i._find(t,n,r))}).then(function(n){var o=h.slicedToArray(n,1),a=o[0];if(a){u=a;var s=[];return e.utils.forEachRelation(t,r,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=i.loadHasManyLocalKeys(t,e,u,n):"hasMany"===e.type&&e.foreignKeys?r=i.loadHasManyForeignKeys(t,e,u,n):"belongsTo"===e.type&&(r=i.loadBelongsTo(t,e,u,n)):r="hasOne"===e.type?i.loadHasOne(t,e,u,n):i.loadHasMany(t,e,u,n),r&&s.push(r)}),Promise.all(s)}}).then(function(){var s=new o(u,{},"find");return s.found=u?1:0,s=i.respond(s,r),a=r.op="afterFind",e.utils.resolve(i[a](t,n,r,s)).then(function(t){return e.utils.isUndefined(t)?s:t})})},findAll:function(t,n,r){var i=this;r||(r={}),r.with||(r.with=[]);var u=[],a=void 0,s=r._activeWith;if(e.utils.isObject(s)){var l=s.query||{};s.replace?n=l:e.utils.deepFillIn(n,l)}return a=r.op="beforeFindAll",e.utils.resolve(i[a](t,n,r)).then(function(){return a=r.op="findAll",i.dbg(a,t,n,r),e.utils.resolve(i._findAll(t,n,r))}).then(function(n){var o=h.slicedToArray(n,1),a=o[0];a||(a=[]),u=a;var s=[];return e.utils.forEachRelation(t,r,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=i.loadHasManyLocalKeys(t,e,u,n):"hasMany"===e.type&&e.foreignKeys?r=i.loadHasManyForeignKeys(t,e,u,n):"belongsTo"===e.type&&(r=i.loadBelongsTo(t,e,u,n)):r="hasMany"===e.type?i.loadHasMany(t,e,u,n):i.loadHasOne(t,e,u,n),r&&s.push(r)}),Promise.all(s)}).then(function(){var s=new o(u,{},"findAll");return s.found=u.length,s=i.respond(s,r),a=r.op="afterFindAll",e.utils.resolve(i[a](t,n,r,s)).then(function(t){return e.utils.isUndefined(t)?s:t})})},getOpt:function(t,n){return n||(n={}),e.utils.isUndefined(n[t])?e.utils.plainCopy(this[t]):e.utils.plainCopy(n[t])},loadHasMany:function(t,n,r,o){var i=this,u=!1;e.utils.isObject(r)&&!e.utils.isArray(r)&&(u=!0,r=[r]);var a=r.map(function(e){return i.makeHasManyForeignKey(t,n,e)}),s={where:{}},l=s.where[n.foreignKey]={};return u?l["=="]=a[0]:l.in=a.filter(function(t){return t}),i.findAll(n.getRelation(),s,o).then(function(o){r.forEach(function(r){var i=[];u?i=o:o.forEach(function(o){e.utils.get(o,n.foreignKey)===r[t.idAttribute]&&i.push(o)}),n.setLocalField(r,i)})})},loadHasManyLocalKeys:function(t,n,r,o){var i=this,u=void 0,a=n.getRelation();if(e.utils.isObject(r)&&!e.utils.isArray(r)&&(u=r),u)return i.findAll(a,{where:h.defineProperty({},a.idAttribute,{in:i.makeHasManyLocalKeys(t,n,u)})},o).then(function(t){n.setLocalField(u,t)});var s=function(){var u=[];return r.forEach(function(e){u=u.concat(i.self.makeHasManyLocalKeys(t,n,e))}),{v:i.findAll(a,{where:h.defineProperty({},a.idAttribute,{in:v(u).filter(function(t){return t})})},o).then(function(t){return r.forEach(function(r){var o=[],i=e.utils.get(r,n.localKeys)||[];i=e.utils.isArray(i)?i:Object.keys(i),t.forEach(function(t){i&&-1!==i.indexOf(t[a.idAttribute])&&o.push(t)}),n.setLocalField(r,o)}),t})}}();return"object"===("undefined"==typeof s?"undefined":h.typeof(s))?s.v:void 0},loadHasManyForeignKeys:function(t,n,r,o){var i=this,u=n.getRelation(),a=t.idAttribute,s=void 0;return e.utils.isObject(r)&&!e.utils.isArray(r)&&(s=r),s?i.findAll(n.getRelation(),{where:h.defineProperty({},n.foreignKeys,{contains:i.makeHasManyForeignKeys(t,n,s)})},o).then(function(t){n.setLocalField(s,t)}):i.findAll(u,{where:h.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(e){return i.makeHasManyForeignKeys(t,n,e)})})},o).then(function(t){var o=n.foreignKeys;r.forEach(function(r){var i=[],u=e.utils.get(r,a);t.forEach(function(n){var r=e.utils.get(t,o)||[];-1!==r.indexOf(u)&&i.push(n)}),n.setLocalField(r,i)})})},loadHasOne:function(t,n,r,o){return e.utils.isObject(r)&&!e.utils.isArray(r)&&(r=[r]),this.loadHasMany(t,n,r,o).then(function(){r.forEach(function(t){var r=n.getLocalField(t);e.utils.isArray(r)&&r.length&&n.setLocalField(t,r[0])})})},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (Adapter)";if(console[t]){var i;(i=console)[t].apply(i,[o].concat(n))}else{var u;(u=console).log.apply(u,[o].concat(n))}}},makeHasManyForeignKey:function(t,e,n){return e.getForeignKey(n)},makeHasManyLocalKeys:function(t,n,r){var o=[],i=e.utils.get(r,n.localKeys)||[];return i=e.utils.isArray(i)?i:Object.keys(i),o=o.concat(i),v(o).filter(function(t){return t})},makeHasManyForeignKeys:function(t,n,r){return e.utils.get(r,t.idAttribute)},makeBelongsToForeignKey:function(t,e,n){return e.getForeignKey(n)},sum:function(t,n,r,i){var u=this,a=void 0;if(!e.utils.isString(n))throw new Error("field must be a string!");return r||(r={}),i||(i={}),a=i.op="beforeSum",e.utils.resolve(u[a](t,n,r,i)).then(function(){return a=i.op="sum",u.dbg(a,t,n,r,i),e.utils.resolve(u._sum(t,n,r,i))}).then(function(s){var l=h.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new o(f,c,a);return d=u.respond(d,i),a=i.op="afterSum",e.utils.resolve(u[a](t,n,r,i,d)).then(function(t){return e.utils.isUndefined(t)?d:t})})},respond:function(t,e){return this.getOpt("raw",e)?t:t.data},update:function(t,n,r,i){var u=this;r||(r={}),i||(i={});var a=void 0;return a=i.op="beforeUpdate",e.utils.resolve(u[a](t,n,r,i)).then(function(o){return r=e.utils.isUndefined(o)?r:o,r=g(t,r),a=i.op="update",u.dbg(a,t,n,r,i),e.utils.resolve(u._update(t,n,r,i))}).then(function(s){var l=h.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new o(f,c,"update");return d.updated=f?1:0,d=u.respond(d,i),a=i.op="afterUpdate",e.utils.resolve(u[a](t,n,r,i,d)).then(function(t){return e.utils.isUndefined(t)?d:t})})},updateAll:function(t,n,r,i){var u=this;n||(n={}),r||(r={}),i||(i={});var a=void 0;return a=i.op="beforeUpdateAll",e.utils.resolve(u[a](t,n,r,i)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=g(t,n),a=i.op="updateAll",u.dbg(a,t,n,r,i),e.utils.resolve(u._updateAll(t,n,r,i))}).then(function(s){var l=h.slicedToArray(s,2),f=l[0],c=l[1];f||(f=[]),c||(c={});var d=new o(f,c,"updateAll");return d.updated=f.length,d=u.respond(d,i),a=i.op="afterUpdateAll",e.utils.resolve(u[a](t,n,r,i,d)).then(function(t){return e.utils.isUndefined(t)?d:t})})},updateMany:function(t,n,r){var i=this;n||(n=[]),r||(r={});var u=void 0,a=t.idAttribute;return n=n.filter(function(t){return e.utils.get(t,a)}),u=r.op="beforeUpdateMany",e.utils.resolve(i[u](t,n,r)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=n.map(function(e){return g(t,e)}),u=r.op="updateMany",i.dbg(u,t,n,r),e.utils.resolve(i._updateMany(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];l||(l=[]),f||(f={});var c=new o(l,f,"updateMany");return c.updated=l.length,c=i.respond(c,r),u=r.op="afterUpdateMany",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})}});var A=n(function(t){function e(t){return null===t?"Null":t===n?"Undefined":r.exec(o.call(t))[1]}var n,r=/^\[object (.*)\]$/,o=Object.prototype.toString;t.exports=e}),m=A&&"object"==typeof A&&"default"in A?A.default:A,M=n(function(t){function e(t,e){return n(t)===e}var n=m;t.exports=e}),w=M&&"object"==typeof M&&"default"in M?M.default:M,I=n(function(t){var e=w,n=Array.isArray||function(t){return e(t,"Array")};t.exports=n}),P=I&&"object"==typeof I&&"default"in I?I.default:I,K=n(function(t){t.exports=2147483647}),j=K&&"object"==typeof K&&"default"in K?K.default:K,F=n(function(t){t.exports=-2147483648}),_=F&&"object"==typeof F&&"default"in F?F.default:F,U=n(function(t){function e(){return e.get()}e.get=Math.random,t.exports=e}),x=U&&"object"==typeof U&&"default"in U?U.default:U,T=n(function(t){function e(t,e){return t=null==t?r:t,e=null==e?o:e,t+(e-t)*n()}var n=x,r=_,o=j;t.exports=e}),O=T&&"object"==typeof T&&"default"in T?T.default:T,H=n(function(t){function e(t,e){return t=null==t?n:~~t,e=null==e?r:~~e,Math.round(o(t-.5,e+.499999999999))}var n=_,r=j,o=O;t.exports=e}),E=H&&"object"==typeof H&&"default"in H?H.default:H,S=n(function(t){function e(t){var e=1===arguments.length&&r(t)?t:arguments;return e[n(0,e.length-1)]}var n=E,r=P;t.exports=e}),L=S&&"object"==typeof S&&"default"in S?S.default:S,C=n(function(t){function e(t){t=t&&t>0?t:6;for(var e="";t--;)e+=n(r);return e}var n=L,r="0123456789abcdef".split("");t.exports=e}),k=C&&"object"==typeof C&&"default"in C?C.default:C,J=n(function(t){function e(){return n(8)+"-"+n(4)+"-4"+n(3)+"-"+r(8,9,"a","b")+n(3)+"-"+n(12)}var n=k,r=L;t.exports=e}),D=J&&"object"==typeof J&&"default"in J?J.default:J,R=D,B=r.prototype,N={basePath:"",debug:!1,storage:localStorage},q=[],$=!1;d.prototype=Object.create(r.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(d,"__super__",{configurable:!0,value:r}),d.extend=e.utils.extend,e.utils.addHiddenPropsToTarget(d.prototype,{_count:function(t,e,n){var r=this;return r._findAll(t,e,n).then(function(t){return t[0]=t[0].length,t})},_createHelper:function(t,n,r){var o=this,i={},u=t.relationFields||[];e.utils.forOwn(n,function(t,e){-1===u.indexOf(e)&&(i[e]=t)});var a=e.utils.get(i,t.idAttribute)||R();e.utils.set(i,t.idAttribute,a);var s=o.getIdPath(t,r,a);return o.storage.setItem(s,e.utils.toJson(i)),o.ensureId(a,t,r),e.utils.fromJson(o.storage.getItem(s))},_create:function(t,e,n){var r=this;return new Promise(function(o){return o([r._createHelper(t,e,n),{}])})},_createMany:function(t,e,n){var r=this;return new Promise(function(o){return e||(e=[]),o([e.map(function(e){return r._createHelper(t,e,n)}),{}])})},_destroy:function(t,e,n){var r=this;return new Promise(function(o){return r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),o([void 0,{}])})},_destroyAll:function(t,n,r){var o=this;return o._findAll(t,n).then(function(n){var i=h.slicedToArray(n,1),u=i[0],a=t.idAttribute,s=u.map(function(t){return e.utils.get(t,a)});return s.forEach(function(e){o.storage.removeItem(o.getIdPath(t,r,e))}),o.removeId(s,t,r),[void 0,{}]})},_find:function(t,n,r){var o=this;return new Promise(function(i){var u=o.getIdPath(t,r,n),a=o.storage.getItem(u);return i([a?e.utils.fromJson(a):void 0,{}])})},_findAll:function(t,n,r){var o=this;return n||(n={}),new Promise(function(i){var u=[],a=o.getIds(t,r);e.utils.forOwn(a,function(n,i){var a=o.storage.getItem(o.getIdPath(t,r,i));a&&u.push(e.utils.fromJson(a))});var s=new e.Query({index:{getAll:function(){return u}}});return i([s.filter(n).run(),{}])})},_sum:function(t,n,r,o){var i=this;return i._findAll(t,r,o).then(function(t){var r=0;return t[0].forEach(function(t){r+=e.utils.get(t,n)||0}),t[0]=r,t})},_update:function(t,n,r,o){var i=this;return r||(r={}),new Promise(function(u,a){var s=i.getIdPath(t,o,n),l=i.storage.getItem(s);return l?(l=e.utils.fromJson(l),e.utils.deepMixIn(l,r),i.storage.setItem(s,e.utils.toJson(l)),u([l,{}])):a(new Error("Not Found"))})},_updateAll:function(t,n,r,o){var i=this,u=t.idAttribute;return i._findAll(t,r,o).then(function(r){var a=h.slicedToArray(r,1),s=a[0];return s.forEach(function(r){r||(r={});var a=e.utils.get(r,u),s=i.getIdPath(t,o,a);e.utils.deepMixIn(r,n),i.storage.setItem(s,e.utils.toJson(r))}),[s,{}]})},_updateMany:function(t,n,r){var o=this;return n||(n=[]),new Promise(function(i){var u=[],a=t.idAttribute;return n.forEach(function(n){if(n){var i=e.utils.get(n,a);if(!e.utils.isUndefined(i)){var s=o.getIdPath(t,r,i),l=o.storage.getItem(s);if(l){var f=e.utils.fromJson(l);e.utils.deepMixIn(f,n),o.storage.setItem(s,e.utils.toJson(f)),u.push(f)}}}}),i([n,{}])})},create:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.create.call(r,t,e,n).then(o,i)})})},createMany:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.createMany.call(r,t,e,n).then(o,i)})})},destroy:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.destroy.call(r,t,e,n).then(o,i)})})},destroyAll:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.destroyAll.call(r,t,e,n).then(o,i)})})},ensureId:function(t,n,r){var o=this.getIds(n,r);if(e.utils.isArray(t)){if(!t.length)return;t.forEach(function(t){o[t]=1})}else o[t]=1;this.saveKeys(o,n,r)},getPath:function(t,e){return e=e||{},a(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},a(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,n){var r=void 0,o=this.getPath(t,n),i=this.storage.getItem(o);return r=i?e.utils.fromJson(i):{}},removeId:function(t,n,r){var o=this.getIds(n,r);if(e.utils.isArray(t)){if(!t.length)return;t.forEach(function(t){delete o[t]})}else delete o[t];this.saveKeys(o,n,r)},saveKeys:function(t,n,r){t=t||{};var o=this.getPath(n,r);Object.keys(t).length?this.storage.setItem(o,e.utils.toJson(t)):this.storage.removeItem(o)},update:function(t,e,n,r){var o=this;return c(function(i,u){f(function(){B.update.call(o,t,e,n,r).then(i,u)})})},updateAll:function(t,e,n,r){var o=this;return c(function(i,u){f(function(){B.updateAll.call(o,t,e,n,r).then(i,u)})})},updateMany:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.updateMany.call(r,t,e,n).then(o,i)})})}});var Q={beta:1,full:"3.0.0-beta.1",major:3,minor:0,patch:0};t.LocalStorageAdapter=d,t.version=Q,t.default=d}); //# sourceMappingURL=js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index 4f36720..b83c8c8 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","enqueue","task","queue","push","dequeue","taskInProcess","queueTask","createTask","fn","Promise","then","shift","setTimeout","err","utils","reject","LocalStorageAdapter","opts","self","classCallCheck","fillIn","DEFAULTS","Adapter","_slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","Symbol","iterator","next","done","isArray","Object","TypeError","JSData","guid","Query","__super__","prototype","basePath","debug","storage","localStorage","create","constructor","enumerable","writable","configurable","defineProperty","extend","addHiddenPropsToTarget","_count","mapper","query","_findAll","_createHelper","props","_props","relationFields","forOwn","key","indexOf","get","idAttribute","set","getIdPath","setItem","toJson","ensureId","fromJson","getItem","_create","resolve","_createMany","map","_destroy","removeItem","removeId","_destroyAll","results","_results","records","ids","record","forEach","_find","getIds","json","_query","index","getAll","run","_sum","field","sum","_update","deepMixIn","Error","_updateAll","_results2","_updateMany","updatedRecords","isUndefined","existingRecord","success","failure","createMany","destroy","destroyAll","_id","saveKeys","getPath","name","endpoint","idsPath","idsJson","keys","update","updateAll","updateMany","version","full","major","parseInt","minor","patch","alpha","beta","global","jsData","Response","data","meta","op","babelHelpers","typeof","obj","slicedToArray","noop","dbg","apply","concat","noop2","_len2","_key2","unique","array","seen","final","item","withoutRelations","omit","raw","reserved","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","log","count","response","respond","_response","created","_results3","_results4","_results5","makeHasManyForeignKey","def","getForeignKey","makeHasManyLocalKeys","localKeys","itemKeys","x","makeHasManyForeignKeys","loadHasMany","__opts","singular","isObject","IDs","where","criteria","foreignKey","findAll","getRelation","relatedItems","attached","relatedItem","setLocalField","loadHasManyLocalKeys","relatedMapper","in","_ret","v","loadHasManyForeignKeys","foreignKeys","contains","isectNotEmpty","foreignKeysField","_relatedItems","loadHasOne","relatedData","getLocalField","makeBelongsToForeignKey","loadBelongsTo","relationDef","_ret2","find","with","_results6","_record","tasks","forEachRelation","type","all","found","activeWith","_activeWith","activeQuery","deepFillIn","_results7","_records","getOpt","opt","plainCopy","level","_len4","_key4","prefix","toUpperCase","console","_console","_console2","isString","_results8","_results9","updated","_results10","_results11","randHex","choice","size","str","_chars","split","target","randInt","min","max","MIN_INT","MAX_INT","Math","round","rand","random","isKind","val","kind","kindOf","UNDEF","_rKind","exec","_toString","toString"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,EAAQG,QAAQ,YACR,kBAAXC,SAAyBA,OAAOC,IAC9CD,QAAQ,WAAYJ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AASC,EAL/B,GAAIC,GAASrT,EAAoB,GAO7BP,GAAOD,QAAU0T,GAMhB,SAASzT,EAAQD,GAWlB,QAAS6T,GAAOF,GACZ,MAAY,QAARA,EACO,OACAA,IAAQG,EACR,YAEAC,EAAOC,KAAMC,EAAUpT,KAAK8S,IAAO,GAblD,GAEIG,GAFAC,EAAS,oBACTE,EAAY1P,OAAOM,UAAUqP,QAejCjU,GAAOD,QAAU6T","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["global","factory","exports","module","require","define","amd","JSDataLocalStorage","JSData","this","jsData","__commonjs","fn","Adapter","opts","self","utils","fillIn","DEFAULTS$1","Response","data","meta","op","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","enqueue","task","queue","push","dequeue","taskInProcess","queueTask","createTask","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","classCallCheck","DEFAULTS","call","babelHelpers","typeof","Symbol","iterator","obj","constructor","defineProperty","key","Object","enumerable","configurable","writable","slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","next","done","isArray","TypeError","noop","dbg","apply","concat","resolve","noop2","_len2","_key2","unique","array","seen","final","forEach","item","withoutRelations","mapper","props","omit","relationFields","debug","raw","extend","addHiddenPropsToTarget","prototype","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","log","count","query","_count","results","_results","response","respond","_response","isUndefined","create","_props","_create","_results2","created","createMany","map","record","_createMany","_results3","destroy","id","_destroy","_results4","destroyAll","_destroyAll","_results5","loadBelongsTo","def","records","__opts","relationDef","getRelation","isObject","keys","makeBelongsToForeignKey","findAll","where","idAttribute","in","relatedItems","relatedItem","foreignKey","setLocalField","_ret","v","find","with","_find","_results6","_record","tasks","forEachRelation","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","all","found","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_results7","_records","getOpt","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","attached","get","relatedMapper","makeHasManyLocalKeys","_ret2","x","itemKeys","indexOf","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","level","_len4","_key4","prefix","toUpperCase","console","_console","_console2","getForeignKey","sum","field","isString","Error","_sum","_results8","update","_update","_results9","updated","updateAll","_updateAll","_results10","updateMany","_updateMany","_results11","kindOf","val","UNDEF","_rKind","exec","_toString","toString","require$$0$3","isKind","kind","require$$0$2","require$$0$1","MAX_INT","require$$0$5","MIN_INT","require$$1$1","random","Math","require$$2","rand","min","max","require$$0$4","randInt","round","require$$1","choice","target","require$$0","randHex","size","str","_chars","split","require$$1$2","guid$1","guid","guid$2","__super__","basePath","storage","localStorage","_createHelper","forOwn","set","getIdPath","setItem","toJson","ensureId","fromJson","getItem","removeItem","removeId","ids","getIds","json","_query","Query","index","getAll","run","deepMixIn","updatedRecords","existingRecord","success","failure","_id","saveKeys","getPath","name","endpoint","idsPath","idsJson","version","beta","full","major","minor","patch"],"mappings":"CAAC,SAAUA,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,QAASE,QAAQ,YACtE,kBAAXC,SAAyBA,OAAOC,IAAMD,OAAO,wBAAyB,UAAW,WAAYJ,GACnGA,EAASD,EAAOO,mBAAqBP,EAAOO,uBAA0BP,EAAOQ,SAC9EC,KAAM,SAAUP,EAAQQ,GAAU,YAiElC,SAASC,GAAWC,EAAIT,GAAU,MAAOA,IAAWD,YAAeU,EAAGT,EAAQA,EAAOD,SAAUC,EAAOD,QAyEtG,QAASW,GAAQC,GACf,GAAIC,GAAON,IACXK,KAASA,MACTJ,EAAOM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AG5BjF,OAAQ,SAAgB3I,EAAQsD,EAAIrD,EAAOrF,GACzC,GAAIC,GAAON,IACX,OAAOoC,GAAW,SAAU0Q,EAASC,GACnC5Q,EAAU,WACRiP,EAAUhD,OAAOtL,KAAKxC,EAAMmF,EAAQsD,EAAIrD,EAAOrF,GAAMiC,KAAKwQ,EAASC,QAIzEvE,UAAW,SAAmB/I,EAAQC,EAAOkC,EAAOvH,GAClD,GAAIC,GAAON,IACX,OAAOoC,GAAW,SAAU0Q,EAASC,GACnC5Q,EAAU,WACRiP,EAAU5C,UAAU1L,KAAKxC,EAAMmF,EAAQC,EAAOkC,EAAOvH,GAAMiC,KAAKwQ,EAASC,QAI/EpE,WAAY,SAAoBlJ,EAAQ8D,EAASlJ,GAC/C,GAAIC,GAAON,IACX,OAAOoC,GAAW,SAAU0Q,EAASC,GACnC5Q,EAAU,WACRiP,EAAUzC,WAAW7L,KAAKxC,EAAMmF,EAAQ8D,EAASlJ,GAAMiC,KAAKwQ,EAASC,SAoB7E,IAAIQ,IACJC,KAAM,EACNC,KAAM,eACNC,MAAO,EACPC,MAAO,EACPC,MAAO,EAGPnU,GAAQkD,oBAAsBA,EAC9BlD,EAAQ8T,QAAUA,EAClB9T,EAAiB,QAAIkD","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/karma.start.js b/karma.start.js index d0c7cc4..ed7c9db 100644 --- a/karma.start.js +++ b/karma.start.js @@ -1,3 +1,4 @@ +/* global JSDataLocalStorage */ beforeEach(function () { localStorage.clear() }) @@ -7,7 +8,7 @@ window.assert = JSDataAdapterTests.assert JSDataAdapterTests.init({ debug: false, JSData: JSData, - Adapter: LocalStorageAdapter, + Adapter: JSDataLocalStorage.LocalStorageAdapter, adapterConfig: { debug: false }, @@ -17,3 +18,11 @@ JSDataAdapterTests.init({ 'filterOnRelations' ] }) + +describe('exports', function () { + it('should have correct exports', function () { + assert(JSDataLocalStorage) + assert(JSDataLocalStorage.LocalStorageAdapter) + assert(JSDataLocalStorage.version) + }) +}) diff --git a/package.json b/package.json index 62f7562..6a81b89 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-localstorage", "description": "localStorage adapter for js-data.", - "version": "3.0.0-alpha.7", + "version": "3.0.0-beta.1", "homepage": "https://github.com/js-data/js-data-localstorage", "repository": { "type": "git", @@ -9,6 +9,14 @@ }, "author": "js-data-localstorage project authors", "license": "MIT", + "main": "./dist/js-data-localstorage.js", + "typings": "./dist/js-data-localstorage.d.ts", + "files": [ + "dist/", + "src/", + "AUTHORS", + "CONTRIBUTORS" + ], "keywords": [ "data", "datastore", @@ -19,7 +27,6 @@ "js-data", "JSData" ], - "main": "./dist/js-data-localstorage.js", "standard": { "parser": "babel-eslint", "globals": [ @@ -31,51 +38,51 @@ "it", "JSData", "LocalStorageAdapter" + ], + "ignore": [ + "dist/", + "example/" + ] + }, + "babel": { + "presets": [ + "es2015-rollup" ] }, "scripts": { - "bundle": "webpack --config webpack.config.js --colors", - "doc": "jsdoc -c conf.json src node_modules/js-data-adapter/src && node scripts/cleanup.js", - "lint": "repo-tools lint src/**/*.js karma.start.js karma.conf.js scripts/*.js", + "lint": "repo-tools lint \"**/*.js\"", + "bundle": "rollup src/index.js -c -o dist/js-data-localstorage.js -m dist/js-data-localstorage.js.map -f umd && repo-tools write-version dist/js-data-localstorage.js", + "doc": "jsdoc -c conf.json src node_modules/js-data-adapter/src", "min": "uglifyjs dist/js-data-localstorage.js -o dist/js-data-localstorage.min.js --source-map dist/js-data-localstorage.min.map --source-map-url js-data-localstorage.min.map -v -m -c --screw-ie8", - "version": "node scripts/version.js", "banner": "node scripts/banner.js", - "gzip": "echo gzipped size: $(cat dist/js-data-localstorage.min.js | gzip -f9 | wc -c)kb", - "build": "npm run lint && npm run bundle && npm run min && npm run version && npm run banner", + "build": "npm run lint && npm run bundle && npm run min && npm run banner", "karma": "karma start", - "quick": "npm run bundle && npm run karma", "test": "npm run build && npm run karma", - "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/PhantomJS*/lcov.info | coveralls || true" + "release": "npm test && npm run doc && repo-tools updates && repo-tools changelog && repo-tools authors", + "ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | codecov" }, "peerDependencies": { - "js-data": "^3.0.0-alpha.19" + "js-data": "^3.0.0-beta.3" }, "devDependencies": { - "babel-core": "6.7.2", - "babel-loader": "6.2.4", - "babel-polyfill": "6.7.2", - "babel-preset-es2015": "6.6.0", - "chai": "3.5.0", - "coveralls": "2.11.8", - "ink-docstrap": "1.1.4", - "js-data-adapter": "0.2.4", + "babel-polyfill": "6.7.4", + "babel-preset-es2015-rollup": "1.1.1", + "js-data-adapter": "~0.6.1", "js-data-adapter-tests": "^2.0.0-alpha.16", - "js-data-repo-tools": "^0.2.0", - "jsdoc": "3.4.0", + "js-data-repo-tools": "0.5.0", "karma": "0.13.22", - "karma-browserstack-launcher": "0.1.10", + "karma-browserstack-launcher": "0.1.11", "karma-chai": "0.1.0", "karma-coverage": "0.5.5", "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", - "sinon": "1.17.3", - "uglify-js": "2.6.2", - "webpack": "1.12.14" + "mout": "1.0.0", + "phantomjs-prebuilt": "2.1.7", + "rollup": "0.26.1", + "rollup-plugin-babel": "2.4.0", + "rollup-plugin-commonjs": "^2.2.1", + "rollup-plugin-node-resolve": "^1.5.0", + "uglify-js": "2.6.2" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..66072f0 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,27 @@ +var babel = require('rollup-plugin-babel') +var commonjs = require('rollup-plugin-commonjs') +var nodeResolve = require('rollup-plugin-node-resolve') + +module.exports = { + moduleName: 'JSDataLocalStorage', + moduleId: 'js-data-localstorage', + external: [ + 'js-data' + ], + globals: { + 'js-data': 'JSData' + }, + plugins: [ + babel({ + exclude: ['node_modules/mout/**/*'] + }), + nodeResolve({ + jsnext: false, + main: true + }), + commonjs({ + include: 'node_modules/mout/**', + sourceMap: true + }) + ] +} diff --git a/scripts/AUTHORS b/scripts/AUTHORS deleted file mode 100644 index b935ea1..0000000 --- a/scripts/AUTHORS +++ /dev/null @@ -1,7 +0,0 @@ -# This is the official list of js-data-localstorage 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 165d3bd..0000000 --- a/scripts/CONTRIBUTORS +++ /dev/null @@ -1,6 +0,0 @@ -# People who have contributed to the js-data-localstorage 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 5ba1712..0000000 --- a/scripts/authors.js +++ /dev/null @@ -1,46 +0,0 @@ -var fs = require('fs') -var exec = require('child_process').exec -var path = require('path') - -console.log('Writing AUTHORS file...') - -var authorsFile = fs.readFileSync(path.join(__dirname, '/AUTHORS'), { - encoding: 'utf-8' -}) -var contributorsFile = fs.readFileSync(path.join(__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(path.join(__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(path.join(__dirname, '/../CONTRIBUTORS'), contributorsFile + names.join('\n'), { - encoding: 'utf-8' - }) - console.log('Done!') - } -}) diff --git a/scripts/cleanup.js b/scripts/cleanup.js deleted file mode 100644 index aaa3689..0000000 --- a/scripts/cleanup.js +++ /dev/null @@ -1,25 +0,0 @@ -var fs = require('fs') - -var pkg = require('../package.json') - -var path = './doc/js-data-localstorage/' + 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-localstorage/' + 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 511e18a..0000000 --- a/scripts/version.js +++ /dev/null @@ -1,39 +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-localstorage.js') - -console.log('Done!') diff --git a/src/index.js b/src/index.js index 1804237..0f2c1cd 100644 --- a/src/index.js +++ b/src/index.js @@ -1,12 +1,67 @@ /* global: localStorage */ -const JSData = require('js-data') -const Adapter = require('js-data-adapter') -const guid = require('mout/random/guid') -const { - Query, - utils -} = JSData +/** + * Registered as `js-data-localstorage` in NPM and Bower. + * + * @example Script tag + * var LocalStorageAdapter = window.JSDataLocalStorage.LocalStorageAdapter + * var adapter = new LocalStorageAdapter() + * + * @example CommonJS + * var LocalStorageAdapter = require('js-data-localstorage').LocalStorageAdapter + * var adapter = new LocalStorageAdapter() + * + * @example ES6 Modules + * import {LocalStorageAdapter} from 'js-data-localstorage' + * const adapter = new LocalStorageAdapter() + * + * @example AMD + * define('myApp', ['js-data-localstorage'], function (JSDataLocalStorage) { + * var LocalStorageAdapter = JSDataLocalStorage.LocalStorageAdapter + * var adapter = new LocalStorageAdapter() + * + * // ... + * }) + * + * @module js-data-localstorage + */ + +import {Query, utils} from 'js-data' +import {Adapter} from '../node_modules/js-data-adapter/src/index' + +// This is kinda weird, but it's so we can use Rollup.js +import * as Guid from '../node_modules/mout/random/guid' +const { default: guid } = Guid + +const __super__ = Adapter.prototype + +const DEFAULTS = { + /** + * TODO + * + * @name LocalStorageAdapter#basePath + * @type {string} + */ + basePath: '', + + /** + * TODO + * + * @name LocalStorageAdapter#debug + * @type {boolean} + * @default false + */ + debug: false, + + /** + * TODO + * + * @name LocalStorageAdapter#storage + * @type {Object} + * @default localStorage + */ + storage: localStorage +} function isValidString (value) { return (value != null && value !== '') @@ -56,53 +111,32 @@ function createTask (fn) { }) } -const __super__ = Adapter.prototype - -const DEFAULTS = { - /** - * TODO - * - * @name LocalStorageAdapter#basePath - * @type {string} - */ - basePath: '', - - /** - * TODO - * - * @name LocalStorageAdapter#debug - * @type {boolean} - * @default false - */ - debug: false, - - /** - * TODO - * - * @name LocalStorageAdapter#storage - * @type {Object} - * @default localStorage - */ - storage: localStorage -} +/** + * {@link LocalStorageAdapter} class. + * + * @name module:js-data-localstorage.LocalStorageAdapter + * @see LocalStorageAdapter + */ /** * LocalStorageAdapter class. * * @example * import {DataStore} from 'js-data' - * import LocalStorageAdapter from 'js-data-localstorage' + * import {LocalStorageAdapter} from 'js-data-localstorage' * const store = new DataStore() * const adapter = new LocalStorageAdapter() * store.registerAdapter('ls', adapter, { 'default': true }) * * @class LocalStorageAdapter - * @param {Object} [opts] Configuration opts. - * @param {string} [opts.basePath=''] TODO - * @param {boolean} [opts.debug=false] TODO - * @param {Object} [opts.storeage=localStorage] TODO + * @extends Adapter + * @param {Object} [opts] Configuration options. + * @param {string} [opts.basePath=''] See {@link LocalStorageAdapter#basePath}. + * @param {boolean} [opts.debug=false] See {@link Adapter#debug}. + * @param {boolean} [opts.raw=false] See {@link Adapter#raw}. + * @param {Object} [opts.storeage=localStorage] See {@link LocalStorageAdapter#storage}. */ -function LocalStorageAdapter (opts) { +export function LocalStorageAdapter (opts) { const self = this utils.classCallCheck(self, LocalStorageAdapter) opts || (opts = {}) @@ -128,13 +162,24 @@ Object.defineProperty(LocalStorageAdapter, '__super__', { /** * Alternative to ES6 class syntax for extending `LocalStorageAdapter`. * - * @name LocalStorageAdapter.extend - * @method + * @example Using the ES2015 class syntax. + * class MyLocalStorageAdapter extends LocalStorageAdapter {...} + * const adapter = new MyLocalStorageAdapter() + * + * @example Using {@link LocalStorageAdapter.extend}. + * var instanceProps = {...} + * var classProps = {...} + * + * var MyLocalStorageAdapter = LocalStorageAdapter.extend(instanceProps, classProps) + * var adapter = new MyLocalStorageAdapter() + * + * @method LocalStorageAdapter.extend + * @static * @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 `LocalStorageAdapter`. + * @return {Constructor} Subclass of `LocalStorageAdapter`. */ LocalStorageAdapter.extend = utils.extend @@ -143,8 +188,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Retrieve the number of records that match the selection query. Internal * method used by Adapter#count. * - * @name LocalStorageAdapter#_count - * @method + * @method LocalStorageAdapter#_count * @private * @param {Object} mapper The mapper. * @param {Object} query Selection query. @@ -182,8 +226,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { /** * Create a new record. Internal method used by Adapter#create. * - * @name LocalStorageAdapter#_create - * @method + * @method LocalStorageAdapter#_create * @private * @param {Object} mapper The mapper. * @param {Object} props The record to be created. @@ -201,8 +244,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Create multiple records in a single batch. Internal method used by * Adapter#createMany. * - * @name LocalStorageAdapter#_createMany - * @method + * @method LocalStorageAdapter#_createMany * @private * @param {Object} mapper The mapper. * @param {Object} props The records to be created. @@ -223,8 +265,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Destroy the record with the given primary key. Internal method used by * Adapter#destroy. * - * @name LocalStorageAdapter#_destroy - * @method + * @method LocalStorageAdapter#_destroy * @private * @param {Object} mapper The mapper. * @param {(string|number)} id Primary key of the record to destroy. @@ -244,8 +285,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Destroy the records that match the selection query. Internal method used by * Adapter#destroyAll. * - * @name LocalStorageAdapter#_destroyAll - * @method + * @method LocalStorageAdapter#_destroyAll * @private * @param {Object} mapper the mapper. * @param {Object} [query] Selection query. @@ -274,8 +314,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Retrieve the record with the given primary key. Internal method used by * Adapter#find. * - * @name LocalStorageAdapter#_find - * @method + * @method LocalStorageAdapter#_find * @private * @param {Object} mapper The mapper. * @param {(string|number)} id Primary key of the record to retrieve. @@ -295,8 +334,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Retrieve the records that match the selection query. Internal method used * by Adapter#findAll. * - * @name LocalStorageAdapter#_findAll - * @method + * @method LocalStorageAdapter#_findAll * @private * @param {Object} mapper The mapper. * @param {Object} query Selection query. @@ -331,8 +369,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Retrieve the number of records that match the selection query. Internal * method used by Adapter#sum. * - * @name LocalStorageAdapter#_sum - * @method + * @method LocalStorageAdapter#_sum * @private * @param {Object} mapper The mapper. * @param {string} field The field to sum. @@ -356,8 +393,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Apply the given update to the record with the specified primary key. * Internal method used by Adapter#update. * - * @name LocalStorageAdapter#_update - * @method + * @method LocalStorageAdapter#_update * @private * @param {Object} mapper The mapper. * @param {(string|number)} id The primary key of the record to be updated. @@ -385,8 +421,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Apply the given update to all records that match the selection query. * Internal method used by Adapter#updateAll. * - * @name LocalStorageAdapter#_updateAll - * @method + * @method LocalStorageAdapter#_updateAll * @private * @param {Object} mapper The mapper. * @param {Object} props The update to apply to the selected records. @@ -414,8 +449,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * Update the given records in a single batch. Internal method used by * Adapter#updateMany. * - * @name LocalStorageAdapter#updateMany - * @method + * @method LocalStorageAdapter#updateMany * @private * @param {Object} mapper The mapper. * @param {Object[]} records The records to update. @@ -489,8 +523,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { /** * TODO * - * @name LocalStorageAdapter#ensureId - * @method + * @method LocalStorageAdapter#ensureId */ ensureId (id, mapper, opts) { const ids = this.getIds(mapper, opts) @@ -510,8 +543,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { /** * TODO * - * @name LocalStorageAdapter#getPath - * @method + * @method LocalStorageAdapter#getPath */ getPath (mapper, opts) { opts = opts || {} @@ -521,8 +553,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { /** * TODO * - * @name LocalStorageAdapter#getIdPath - * @method + * @method LocalStorageAdapter#getIdPath */ getIdPath (mapper, opts, id) { opts = opts || {} @@ -532,8 +563,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { /** * TODO * - * @name LocalStorageAdapter#getIds - * @method + * @method LocalStorageAdapter#getIds */ getIds (mapper, opts) { let ids @@ -550,8 +580,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { /** * TODO * - * @name LocalStorageAdapter#removeId - * @method + * @method LocalStorageAdapter#removeId */ removeId (id, mapper, opts) { const ids = this.getIds(mapper, opts) @@ -571,8 +600,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { /** * TODO * - * @name LocalStorageAdapter#saveKeys - * @method + * @method LocalStorageAdapter#saveKeys */ saveKeys (ids, mapper, opts) { ids = ids || {} @@ -615,7 +643,7 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { /** * Details of the current version of the `js-data-localstorage` module. * - * @name LocalStorageAdapter.version + * @name module:js-data-localstorage.version * @type {Object} * @property {string} version.full The full semver value. * @property {number} version.major The major version number. @@ -626,36 +654,6 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { * @property {(string|boolean)} version.beta The beta version value, * otherwise `false` if the current version is not beta. */ -LocalStorageAdapter.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 -} - -/** - * Registered as `js-data-localstorage` in NPM and Bower. - * - * __Script tag__: - * ```javascript - * window.LocalStorageAdapter - * ``` - * __CommonJS__: - * ```javascript - * var LocalStorageAdapter = require('js-data-localstorage') - * ``` - * __ES6 Modules__: - * ```javascript - * import LocalStorageAdapter from 'js-data-localstorage' - * ``` - * __AMD__: - * ```javascript - * define('myApp', ['js-data-localstorage'], function (LocalStorageAdapter) { ... }) - * ``` - * - * @module js-data-localstorage - */ +export const version = '<%= version %>' -module.exports = LocalStorageAdapter +export default LocalStorageAdapter diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index a35e29c..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,32 +0,0 @@ -var path = require('path') - -module.exports = { - devtool: 'source-map', - entry: { - './dist/js-data-localstorage.js': './src/index.js' - }, - output: { - filename: '[name]', - libraryTarget: 'umd', - library: 'LocalStorageAdapter' - }, - externals: { - 'js-data': { - amd: 'js-data', - commonjs: 'js-data', - commonjs2: 'js-data', - root: 'JSData' - } - }, - module: { - loaders: [ - { - loader: 'babel-loader', - include: [ - path.resolve(__dirname, 'src') - ], - test: /\.js$/ - } - ] - } -} From 9230ed9276bf319bd61721bb4ce77ec43e6ca059 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sat, 30 Apr 2016 22:22:08 -0700 Subject: [PATCH 13/15] Fix build --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 0fa8da4..eba7a64 100644 --- a/circle.yml +++ b/circle.yml @@ -1,7 +1,7 @@ dependencies: pre: - npm i -g npm - - npm i jsdata@^3.0.0-beta.3 + - npm i js-data@^3.0.0-beta.3 test: override: - npm run ci From 41cd59114d683cdd8b72fcba6120ff352938e194 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sat, 30 Apr 2016 22:31:42 -0700 Subject: [PATCH 14/15] Fix build --- circle.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/circle.yml b/circle.yml index eba7a64..0a4c36a 100644 --- a/circle.yml +++ b/circle.yml @@ -1,3 +1,7 @@ +machine: + node: + version: 5.0.0 + dependencies: pre: - npm i -g npm From 412af5625d1b058b1d4df5a41e58dde800acc287 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Sun, 1 May 2016 00:03:54 -0700 Subject: [PATCH 15/15] Fix JSDoc --- dist/js-data-localstorage.js | 17 ++++---- dist/js-data-localstorage.js.map | 2 +- dist/js-data-localstorage.min.js | 2 +- dist/js-data-localstorage.min.map | 2 +- package.json | 2 +- src/index.js | 69 +++++++++++++++---------------- 6 files changed, 46 insertions(+), 48 deletions(-) diff --git a/dist/js-data-localstorage.js b/dist/js-data-localstorage.js index 0bab743..229f6d4 100644 --- a/dist/js-data-localstorage.js +++ b/dist/js-data-localstorage.js @@ -1855,15 +1855,6 @@ */ basePath: '', - /** - * TODO - * - * @name LocalStorageAdapter#debug - * @type {boolean} - * @default false - */ - debug: false, - /** * TODO * @@ -1933,6 +1924,13 @@ * @see LocalStorageAdapter */ + /** + * {@link LocalStorageAdapter} class. ES2015 default import. + * + * @name module:js-data-localstorage.default + * @see LocalStorageAdapter + */ + /** * LocalStorageAdapter class. * @@ -1944,6 +1942,7 @@ * store.registerAdapter('ls', adapter, { 'default': true }) * * @class LocalStorageAdapter + * @alias LocalStorageAdapter * @extends Adapter * @param {Object} [opts] Configuration options. * @param {string} [opts.basePath=''] See {@link LocalStorageAdapter#basePath}. diff --git a/dist/js-data-localstorage.js.map b/dist/js-data-localstorage.js.map index c45cdb8..afc873e 100644 --- a/dist/js-data-localstorage.js.map +++ b/dist/js-data-localstorage.js.map @@ -1 +1 @@ -{"version":3,"file":"js-data-localstorage.js","sources":["../node_modules/js-data-adapter/src/index.js","../node_modules/mout/lang/kindOf.js","../node_modules/mout/lang/isKind.js","../node_modules/mout/lang/isArray.js","../node_modules/mout/number/MAX_INT.js","../node_modules/mout/number/MIN_INT.js","../node_modules/mout/random/random.js","../node_modules/mout/random/rand.js","../node_modules/mout/random/randInt.js","../node_modules/mout/random/choice.js","../node_modules/mout/random/randHex.js","../node_modules/mout/random/guid.js","../src/index.js"],"sourcesContent":["\nimport {utils} from 'js-data'\n\nexport const noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const self = this\n const opts = args[args.length - 2]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const unique = function (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\n\nexport const withoutRelations = function (mapper, props) {\n return utils.omit(props, mapper.relationFields || [])\n}\n\nconst DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\nexport function Adapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(self, opts)\n}\n\nexport const reserved = [\n 'orderBy',\n 'sort',\n 'limit',\n 'offset',\n 'skip',\n 'where'\n]\n\n/**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\nexport function Response (data, meta, op) {\n const self = this\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n self.data = data\n\n utils.fillIn(self, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n self.op = op\n}\n\n/**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\nAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(Adapter.prototype, {\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {string} field The `field` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._count(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'create'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._create(mapper, props, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'create')\n response.created = data ? 1 : 0\n response = self.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = props.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'createMany'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._createMany(mapper, props, opts))\n }).then(function (results) {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'createMany')\n response.created = data.length\n response = self.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._destroy(mapper, id, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = self.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._destroyAll(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = self.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo (mapper, def, records, __opts) {\n const self = this\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record)\n }).filter(function (key) {\n return key\n })\n return self.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem)\n }\n })\n })\n })\n }\n },\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._find(mapper, id, opts))\n }).then(function (results) {\n let [_record] = results\n if (!_record) {\n return\n }\n record = _record\n const tasks = []\n\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts)\n } else {\n task = self.loadHasMany(mapper, def, record, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(record, {}, 'find')\n response.found = record ? 1 : 0\n response = self.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n let records = []\n let op\n const activeWith = opts._activeWith\n\n if (utils.isObject(activeWith)) {\n const activeQuery = activeWith.query || {}\n if (activeWith.replace) {\n query = activeQuery\n } else {\n utils.deepFillIn(query, activeQuery)\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._findAll(mapper, query, opts))\n }).then(function (results) {\n let [_records] = results\n _records || (_records = [])\n records = _records\n const tasks = []\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts)\n } else {\n task = self.loadHasOne(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(records, {}, 'findAll')\n response.found = records.length\n response = self.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt (opt, opts) {\n opts || (opts = {})\n return utils.isUndefined(opts[opt]) ? utils.plainCopy(this[opt]) : utils.plainCopy(opts[opt])\n },\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany (mapper, def, records, __opts) {\n const self = this\n let singular = false\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n const IDs = records.map(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record)\n })\n const query = {\n where: {}\n }\n const criteria = query.where[def.foreignKey] = {}\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0]\n } else {\n criteria['in'] = IDs.filter(function (id) {\n return id\n })\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n let attached = []\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems\n } else {\n relatedItems.forEach(function (relatedItem) {\n if (utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem)\n }\n })\n }\n def.setLocalField(record, attached)\n })\n })\n },\n\n loadHasManyLocalKeys (mapper, def, records, __opts) {\n const self = this\n let record\n const relatedMapper = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record))\n })\n return self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach(function (relatedItem) {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem)\n }\n })\n def.setLocalField(item, attached)\n })\n return relatedItems\n })\n }\n },\n\n loadHasManyForeignKeys (mapper, def, records, __opts) {\n const self = this\n const relatedMapper = def.getRelation()\n const idAttribute = mapper.idAttribute\n let record\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return self.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return self.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record)\n })\n }\n }\n }, __opts).then(function (relatedItems) {\n const foreignKeysField = def.foreignKeys\n records.forEach(function (record) {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach(function (relatedItem) {\n const foreignKeys = utils.get(relatedItems, foreignKeysField) || []\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem)\n }\n })\n def.setLocalField(record, _relatedItems)\n })\n })\n }\n },\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne (mapper, def, records, __opts) {\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n }\n return this.loadHasMany(mapper, def, records, __opts).then(function () {\n records.forEach(function (record) {\n const relatedData = def.getLocalField(record)\n if (utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0])\n }\n })\n })\n },\n\n /**\n * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (Adapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n let localKeys = []\n let itemKeys = utils.get(record, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n return unique(localKeys).filter(function (x) { return x })\n },\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys (mapper, def, record) {\n return utils.get(record, mapper.idAttribute)\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n let op\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n query || (query = {})\n opts || (opts = {})\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum'\n return utils.resolve(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n self.dbg(op, mapper, field, query, opts)\n return utils.resolve(self._sum(mapper, field, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond (response, opts) {\n return this.getOpt('raw', opts) ? response : response.data\n },\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'update'\n self.dbg(op, mapper, id, props, opts)\n return utils.resolve(self._update(mapper, id, props, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'update')\n response.updated = data ? 1 : 0\n response = self.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let op\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'updateAll'\n self.dbg(op, mapper, props, query, opts)\n return utils.resolve(self._updateAll(mapper, props, query, opts))\n }).then(function (results) {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateAll')\n response.updated = data.length\n response = self.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter(function (record) {\n return utils.get(record, idAttribute)\n })\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = utils.isUndefined(_records) ? records : _records\n records = records.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'updateMany'\n self.dbg(op, mapper, records, opts)\n return utils.resolve(self._updateMany(mapper, records, opts))\n }).then(function (results) {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateMany')\n response.updated = data.length\n response = self.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n }\n})\n","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n","/* global: localStorage */\n\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * @example Script tag\n * var LocalStorageAdapter = window.JSDataLocalStorage.LocalStorageAdapter\n * var adapter = new LocalStorageAdapter()\n *\n * @example CommonJS\n * var LocalStorageAdapter = require('js-data-localstorage').LocalStorageAdapter\n * var adapter = new LocalStorageAdapter()\n *\n * @example ES6 Modules\n * import {LocalStorageAdapter} from 'js-data-localstorage'\n * const adapter = new LocalStorageAdapter()\n *\n * @example AMD\n * define('myApp', ['js-data-localstorage'], function (JSDataLocalStorage) {\n * var LocalStorageAdapter = JSDataLocalStorage.LocalStorageAdapter\n * var adapter = new LocalStorageAdapter()\n *\n * // ...\n * })\n *\n * @module js-data-localstorage\n */\n\nimport {Query, utils} from 'js-data'\nimport {Adapter} from '../node_modules/js-data-adapter/src/index'\n\n// This is kinda weird, but it's so we can use Rollup.js\nimport * as Guid from '../node_modules/mout/random/guid'\nconst { default: guid } = Guid\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\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}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return utils.reject(err)\n })\n}\n\n/**\n * {@link LocalStorageAdapter} class.\n *\n * @name module:js-data-localstorage.LocalStorageAdapter\n * @see LocalStorageAdapter\n */\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import {LocalStorageAdapter} from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link LocalStorageAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link Adapter#debug}.\n * @param {boolean} [opts.raw=false] See {@link Adapter#raw}.\n * @param {Object} [opts.storeage=localStorage] See {@link LocalStorageAdapter#storage}.\n */\nexport function LocalStorageAdapter (opts) {\n const self = this\n utils.classCallCheck(self, LocalStorageAdapter)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nLocalStorageAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: LocalStorageAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(LocalStorageAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyLocalStorageAdapter extends LocalStorageAdapter {...}\n * const adapter = new MyLocalStorageAdapter()\n *\n * @example Using {@link LocalStorageAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyLocalStorageAdapter = LocalStorageAdapter.extend(instanceProps, classProps)\n * var adapter = new MyLocalStorageAdapter()\n *\n * @method LocalStorageAdapter.extend\n * @static\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 {Constructor} Subclass of `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#count.\n *\n * @method LocalStorageAdapter#_count\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _count (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n result[0] = result[0].length\n return result\n })\n },\n\n _createHelper (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n utils.forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = utils.get(_props, mapper.idAttribute) || guid()\n utils.set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, utils.toJson(_props))\n self.ensureId(id, mapper, opts)\n return utils.fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record. Internal method used by Adapter#create.\n *\n * @method LocalStorageAdapter#_create\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _create (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n return resolve([self._createHelper(mapper, props, opts), {}])\n })\n },\n\n /**\n * Create multiple records in a single batch. Internal method used by\n * Adapter#createMany.\n *\n * @method LocalStorageAdapter#_createMany\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _createMany (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n props || (props = [])\n return resolve([props.map(function (_props) {\n return self._createHelper(mapper, _props, opts)\n }), {}])\n })\n },\n\n /**\n * Destroy the record with the given primary key. Internal method used by\n * Adapter#destroy.\n *\n * @method LocalStorageAdapter#_destroy\n * @private\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 * @return {Promise}\n */\n _destroy (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n return resolve([undefined, {}])\n })\n },\n\n /**\n * Destroy the records that match the selection query. Internal method used by\n * Adapter#destroyAll.\n *\n * @method LocalStorageAdapter#_destroyAll\n * @private\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroyAll (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query).then(function (results) {\n let [records] = results\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n const ids = records.map(function (record) {\n return utils.get(record, idAttribute)\n })\n // Destroy each record\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n return [undefined, {}]\n })\n },\n\n /**\n * Retrieve the record with the given primary key. Internal method used by\n * Adapter#find.\n *\n * @method LocalStorageAdapter#_find\n * @private\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 * @return {Promise}\n */\n _find (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n const key = self.getIdPath(mapper, opts, id)\n const record = self.storage.getItem(key)\n return resolve([record ? utils.fromJson(record) : undefined, {}])\n })\n },\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#findAll.\n *\n * @method LocalStorageAdapter#_findAll\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n return new Promise(function (resolve) {\n // Load all records into memory...\n let records = []\n const ids = self.getIds(mapper, opts)\n utils.forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(utils.fromJson(json))\n }\n })\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n return resolve([_query.filter(query).run(), {}])\n })\n },\n\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#sum.\n *\n * @method LocalStorageAdapter#_sum\n * @private\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 * @return {Promise}\n */\n _sum (mapper, field, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n let sum = 0\n result[0].forEach(function (record) {\n sum += utils.get(record, field) || 0\n })\n result[0] = sum\n return result\n })\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n * Internal method used by Adapter#update.\n *\n * @method LocalStorageAdapter#_update\n * @private\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 * @return {Promise}\n */\n _update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n return new Promise(function (resolve, reject) {\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n if (!record) {\n return reject(new Error('Not Found'))\n }\n record = utils.fromJson(record)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n return resolve([record, {}])\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Internal method used by Adapter#updateAll.\n *\n * @method LocalStorageAdapter#_updateAll\n * @private\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} [opts] Configuration options.\n * @return {Promise}\n */\n _updateAll (mapper, props, query, opts) {\n const self = this\n const idAttribute = mapper.idAttribute\n return self._findAll(mapper, query, opts).then(function (results) {\n let [records] = results\n records.forEach(function (record) {\n record || (record = {})\n const id = utils.get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n })\n return [records, {}]\n })\n },\n\n /**\n * Update the given records in a single batch. Internal method used by\n * Adapter#updateMany.\n *\n * @method LocalStorageAdapter#updateMany\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n return new Promise(function (resolve) {\n const updatedRecords = []\n const idAttribute = mapper.idAttribute\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = utils.get(record, idAttribute)\n if (utils.isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n if (!json) {\n return\n }\n const existingRecord = utils.fromJson(json)\n utils.deepMixIn(existingRecord, record)\n self.storage.setItem(key, utils.toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n return resolve([records, {}])\n })\n },\n\n create (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.create.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n createMany (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.createMany.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n destroy (mapper, id, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroy.call(self, mapper, id, opts).then(success, failure)\n })\n })\n },\n\n destroyAll (mapper, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroyAll.call(self, mapper, query, opts).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#ensureId\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#getPath\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#getIdPath\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#getIds\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = utils.fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#removeId\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#saveKeys\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, utils.toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n update (mapper, id, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.update.call(self, mapper, id, props, opts).then(success, failure)\n })\n })\n },\n\n updateAll (mapper, props, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure)\n })\n })\n },\n\n updateMany (mapper, records, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateMany.call(self, mapper, records, opts).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name module:js-data-localstorage.version\n * @type {Object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\nexport default LocalStorageAdapter\n"],"names":["utils","DEFAULTS","require$$0","require$$1","require$$2","Guid.default","Query"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGO,IAAM,OAAO,SAAP,IAAO,GAAmB;AACrC,EAAA,MAAM,OAAO,IAAb;;AADqC,EAAA,oCAAN,IAAM;AAAN,EAAA,QAAM;AAAA,EAAA;;AAErC,EAAA,MAAM,OAAO,KAAK,KAAK,MAAL,GAAc,CAAnB,CAAb;AACA,EAAA,OAAK,GAAL,cAAS,KAAK,EAAd,SAAqB,IAArB;AACA,EAAA,SAAOA,aAAM,OAAN,EAAP;AACD,EAAA,CALM;;AAOP,EAAO,IAAM,QAAQ,SAAR,KAAQ,GAAmB;AACtC,EAAA,MAAM,OAAO,IAAb;;AADsC,EAAA,qCAAN,IAAM;AAAN,EAAA,QAAM;AAAA,EAAA;;AAEtC,EAAA,MAAM,OAAO,KAAK,KAAK,MAAL,GAAc,CAAnB,CAAb;AACA,EAAA,OAAK,GAAL,cAAS,KAAK,EAAd,SAAqB,IAArB;AACA,EAAA,SAAOA,aAAM,OAAN,EAAP;AACD,EAAA,CALM;;AAOP,EAAO,IAAM,SAAS,SAAT,MAAS,CAAU,KAAV,EAAiB;AACrC,EAAA,MAAM,OAAO,EAAb;AACA,EAAA,MAAM,QAAQ,EAAd;AACA,EAAA,QAAM,OAAN,CAAc,UAAU,IA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GD,EAAA,KAJM,CAAP;AAKD,EAAA,GA7byD;AA+b1D,EAAA,YA/b0D,sBA+b9C,MA/b8C,EA+btC,OA/bsC,EA+b7B,IA/b6B,EA+bvB;AACjC,EAAA,QAAM,OAAO,IAAb;AACA,EAAA,WAAO,WAAW,UAAU,OAAV,EAAmB,OAAnB,EAA4B;AAC5C,EAAA,gBAAU,YAAY;AACpB,EAAA,kBAAU,UAAV,CAAqB,IAArB,CAA0B,IAA1B,EAAgC,MAAhC,EAAwC,OAAxC,EAAiD,IAAjD,EAAuD,IAAvD,CAA4D,OAA5D,EAAqE,OAArE;AACD,EAAA,OAFD;AAGD,EAAA,KAJM,CAAP;AAKD,EAAA;AAtcyD,EAAA,CAA5D;;;;;;;;;;;;;;;;AAudA,EAAO,IAAM,UAAU,gBAAhB;;;;;;"} \ No newline at end of file +{"version":3,"file":"js-data-localstorage.js","sources":["../node_modules/js-data-adapter/src/index.js","../node_modules/mout/lang/kindOf.js","../node_modules/mout/lang/isKind.js","../node_modules/mout/lang/isArray.js","../node_modules/mout/number/MAX_INT.js","../node_modules/mout/number/MIN_INT.js","../node_modules/mout/random/random.js","../node_modules/mout/random/rand.js","../node_modules/mout/random/randInt.js","../node_modules/mout/random/choice.js","../node_modules/mout/random/randHex.js","../node_modules/mout/random/guid.js","../src/index.js"],"sourcesContent":["\nimport {utils} from 'js-data'\n\nexport const noop = function (...args) {\n const self = this\n const opts = args[args.length - 1]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const noop2 = function (...args) {\n const self = this\n const opts = args[args.length - 2]\n self.dbg(opts.op, ...args)\n return utils.resolve()\n}\n\nexport const unique = function (array) {\n const seen = {}\n const final = []\n array.forEach(function (item) {\n if (item in seen) {\n return\n }\n final.push(item)\n seen[item] = 0\n })\n return final\n}\n\nexport const withoutRelations = function (mapper, props) {\n return utils.omit(props, mapper.relationFields || [])\n}\n\nconst DEFAULTS = {\n /**\n * Whether to log debugging information.\n *\n * @name Adapter#debug\n * @type {boolean}\n * @default false\n */\n debug: false,\n\n /**\n * Whether to return a more detailed response object.\n *\n * @name Adapter#raw\n * @type {boolean}\n * @default false\n */\n raw: false\n}\n\n/**\n * Abstract class meant to be extended by adapters.\n *\n * @class Adapter\n * @abstract\n * @param {Object} [opts] Configuration opts.\n * @param {boolean} [opts.debug=false] Whether to log debugging information.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed response\n * object.\n */\nexport function Adapter (opts) {\n const self = this\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n utils.fillIn(self, opts)\n}\n\nexport const reserved = [\n 'orderBy',\n 'sort',\n 'limit',\n 'offset',\n 'skip',\n 'where'\n]\n\n/**\n * Response object used when `raw` is `true`. May contain other fields in\n * addition to `data`.\n *\n * @class Response\n */\nexport function Response (data, meta, op) {\n const self = this\n meta || (meta = {})\n\n /**\n * Response data.\n *\n * @name Response#data\n * @type {*}\n */\n self.data = data\n\n utils.fillIn(self, meta)\n\n /**\n * The operation for which the response was created.\n *\n * @name Response#op\n * @type {string}\n */\n self.op = op\n}\n\n/**\n * Alternative to ES6 class syntax for extending `Adapter`.\n *\n * @name Adapter.extend\n * @method\n * @param {Object} [instanceProps] Properties that will be added to the\n * prototype of the subclass.\n * @param {Object} [classProps] Properties that will be added as static\n * properties to the subclass itself.\n * @return {Object} Subclass of `Adapter`.\n */\nAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(Adapter.prototype, {\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the count.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#afterCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} props The `props` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `afterCount`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCount: noop2,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `afterCreate`\n * @param {Object|Response} response Created record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreate: noop2,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the created records.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#afterCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `afterCreateMany`\n * @param {Object[]|Response} response Created records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterCreateMany: noop2,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#afterDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `afterDestroy`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroy: noop2,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be `undefined`.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#afterDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `afterDestroyAll`\n * @param {undefined|Response} response `undefined` or {@link Response}, depending on the value of `opts.raw`.\n */\n afterDestroyAll: noop2,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found record, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#afterFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `afterFind`\n * @param {Object|Response} response The found record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFind: noop2,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the found records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#afterFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `afterFindAll`\n * @param {Object[]|Response} response The found records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterFindAll: noop2,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the sum.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#afterSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {string} field The `field` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `afterSum`\n * @param {Object|Response} response Count or {@link Response}, depending on the value of `opts.raw`.\n */\n afterSum: noop2,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated record.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#afterUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `afterUpdate`\n * @param {Object|Response} response The updated record or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdate: noop2,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#afterUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `afterUpdateAll`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateAll: noop2,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * If `opts.raw` is `true` then `response` will be a detailed response object, otherwise `response` will be the updated records, if any.\n *\n * `response` may be modified. You can also re-assign `response` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#afterUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} records The `records` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `afterUpdateMany`\n * @param {Object[]|Response} response The updated records or {@link Response}, depending on the value of `opts.raw`.\n */\n afterUpdateMany: noop2,\n\n /**\n * Lifecycle method method called by count.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes count to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by count.\n *\n * @name Adapter#beforeCount\n * @method\n * @param {Object} mapper The `mapper` argument passed to count.\n * @param {Object} query The `query` argument passed to count.\n * @param {Object} opts The `opts` argument passed to count.\n * @property {string} opts.op `beforeCount`\n */\n beforeCount: noop,\n\n /**\n * Lifecycle method method called by create.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes create to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by create.\n *\n * @name Adapter#beforeCreate\n * @method\n * @param {Object} mapper The `mapper` argument passed to create.\n * @param {Object} props The `props` argument passed to create.\n * @param {Object} opts The `opts` argument passed to create.\n * @property {string} opts.op `beforeCreate`\n */\n beforeCreate: noop,\n\n /**\n * Lifecycle method method called by createMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes createMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.\n *\n * @name Adapter#beforeCreateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to createMany.\n * @param {Object[]} props The `props` argument passed to createMany.\n * @param {Object} opts The `opts` argument passed to createMany.\n * @property {string} opts.op `beforeCreateMany`\n */\n beforeCreateMany: noop,\n\n /**\n * Lifecycle method method called by destroy.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroy to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.\n *\n * @name Adapter#beforeDestroy\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroy.\n * @param {(string|number)} id The `id` argument passed to destroy.\n * @param {Object} opts The `opts` argument passed to destroy.\n * @property {string} opts.op `beforeDestroy`\n */\n beforeDestroy: noop,\n\n /**\n * Lifecycle method method called by destroyAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.\n *\n * @name Adapter#beforeDestroyAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to destroyAll.\n * @param {Object} query The `query` argument passed to destroyAll.\n * @param {Object} opts The `opts` argument passed to destroyAll.\n * @property {string} opts.op `beforeDestroyAll`\n */\n beforeDestroyAll: noop,\n\n /**\n * Lifecycle method method called by find.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes find to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by find.\n *\n * @name Adapter#beforeFind\n * @method\n * @param {Object} mapper The `mapper` argument passed to find.\n * @param {(string|number)} id The `id` argument passed to find.\n * @param {Object} opts The `opts` argument passed to find.\n * @property {string} opts.op `beforeFind`\n */\n beforeFind: noop,\n\n /**\n * Lifecycle method method called by findAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes findAll to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.\n *\n * @name Adapter#beforeFindAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to findAll.\n * @param {Object} query The `query` argument passed to findAll.\n * @param {Object} opts The `opts` argument passed to findAll.\n * @property {string} opts.op `beforeFindAll`\n */\n beforeFindAll: noop,\n\n /**\n * Lifecycle method method called by sum.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes sum to wait for the Promise to resolve before continuing.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.\n *\n * @name Adapter#beforeSum\n * @method\n * @param {Object} mapper The `mapper` argument passed to sum.\n * @param {Object} query The `query` argument passed to sum.\n * @param {Object} opts The `opts` argument passed to sum.\n * @property {string} opts.op `beforeSum`\n */\n beforeSum: noop,\n\n /**\n * Lifecycle method method called by update.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes update to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by update.\n *\n * @name Adapter#beforeUpdate\n * @method\n * @param {Object} mapper The `mapper` argument passed to update.\n * @param {(string|number)} id The `id` argument passed to update.\n * @param {Object} props The `props` argument passed to update.\n * @param {Object} opts The `opts` argument passed to update.\n * @property {string} opts.op `beforeUpdate`\n */\n beforeUpdate: noop,\n\n /**\n * Lifecycle method method called by updateAll.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.\n *\n * @name Adapter#beforeUpdateAll\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateAll.\n * @param {Object} props The `props` argument passed to updateAll.\n * @param {Object} query The `query` argument passed to updateAll.\n * @param {Object} opts The `opts` argument passed to updateAll.\n * @property {string} opts.op `beforeUpdateAll`\n */\n beforeUpdateAll: noop,\n\n /**\n * Lifecycle method method called by updateMany.\n *\n * Override this method to add custom behavior for this lifecycle hook.\n *\n * Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.\n *\n * `props` may be modified. You can also re-assign `props` to another value by returning a different value or a Promise that resolves to a different value.\n *\n * A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.\n *\n * @name Adapter#beforeUpdateMany\n * @method\n * @param {Object} mapper The `mapper` argument passed to updateMany.\n * @param {Object[]} props The `props` argument passed to updateMany.\n * @param {Object} opts The `opts` argument passed to updateMany.\n * @property {string} opts.op `beforeUpdateMany`\n */\n beforeUpdateMany: noop,\n\n /**\n * Shortcut for `#log('debug'[, arg1[, arg2[, argn]]])`.\n *\n * @name Adapter#dbg\n * @method\n */\n dbg (...args) {\n this.log('debug', ...args)\n },\n\n /**\n * Retrieve the number of records that match the selection query. Called by\n * `Mapper#count`.\n *\n * @name Adapter#count\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n count (mapper, query, opts) {\n const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeCount lifecycle hook\n op = opts.op = 'beforeCount'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'count'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._count(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterCount lifecycle hook\n op = opts.op = 'afterCount'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Create a new record. Called by `Mapper#create`.\n *\n * @name Adapter#create\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n create (mapper, props, opts) {\n const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreate lifecycle hook\n op = opts.op = 'beforeCreate'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'create'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._create(mapper, props, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'create')\n response.created = data ? 1 : 0\n response = self.respond(response, opts)\n\n // afterCreate lifecycle hook\n op = opts.op = 'afterCreate'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Create multiple records in a single batch. Called by `Mapper#createMany`.\n *\n * @name Adapter#createMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n createMany (mapper, props, opts) {\n const self = this\n let op\n props || (props = {})\n opts || (opts = {})\n\n // beforeCreateMany lifecycle hook\n op = opts.op = 'beforeCreateMany'\n return utils.resolve(self[op](mapper, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = props.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'createMany'\n self.dbg(op, mapper, props, opts)\n return utils.resolve(self._createMany(mapper, props, opts))\n }).then(function (results) {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'createMany')\n response.created = data.length\n response = self.respond(response, opts)\n\n // afterCreateMany lifecycle hook\n op = opts.op = 'afterCreateMany'\n return utils.resolve(self[op](mapper, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Destroy the record with the given primary key. Called by\n * `Mapper#destroy`.\n *\n * @name Adapter#destroy\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to destroy.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroy (mapper, id, opts) {\n const self = this\n let op\n opts || (opts = {})\n\n // beforeDestroy lifecycle hook\n op = opts.op = 'beforeDestroy'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'destroy'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._destroy(mapper, id, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroy')\n response = self.respond(response, opts)\n\n // afterDestroy lifecycle hook\n op = opts.op = 'afterDestroy'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Destroy the records that match the selection query. Called by\n * `Mapper#destroyAll`.\n *\n * @name Adapter#destroyAll\n * @method\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n destroyAll (mapper, query, opts) {\n const self = this\n let op\n query || (query = {})\n opts || (opts = {})\n\n // beforeDestroyAll lifecycle hook\n op = opts.op = 'beforeDestroyAll'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'destroyAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._destroyAll(mapper, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'destroyAll')\n response = self.respond(response, opts)\n\n // afterDestroyAll lifecycle hook\n op = opts.op = 'afterDestroyAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Load a belongsTo relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadBelongsTo\n * @method\n * @return {Promise}\n */\n loadBelongsTo (mapper, def, records, __opts) {\n const self = this\n const relationDef = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n const record = records\n return self.find(relationDef, self.makeBelongsToForeignKey(mapper, def, record), __opts).then(function (relatedItem) {\n def.setLocalField(record, relatedItem)\n })\n } else {\n const keys = records.map(function (record) {\n return self.makeBelongsToForeignKey(mapper, def, record)\n }).filter(function (key) {\n return key\n })\n return self.findAll(relationDef, {\n where: {\n [relationDef.idAttribute]: {\n 'in': keys\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n relatedItems.forEach(function (relatedItem) {\n if (relatedItem[relationDef.idAttribute] === record[def.foreignKey]) {\n def.setLocalField(record, relatedItem)\n }\n })\n })\n })\n }\n },\n\n /**\n * Retrieve the record with the given primary key. Called by `Mapper#find`.\n *\n * @name Adapter#find\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id Primary key of the record to retrieve.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n find (mapper, id, opts) {\n const self = this\n let record, op\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n // beforeFind lifecycle hook\n op = opts.op = 'beforeFind'\n return utils.resolve(self[op](mapper, id, opts)).then(function () {\n op = opts.op = 'find'\n self.dbg(op, mapper, id, opts)\n return utils.resolve(self._find(mapper, id, opts))\n }).then(function (results) {\n let [_record] = results\n if (!_record) {\n return\n }\n record = _record\n const tasks = []\n\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasOne') {\n task = self.loadHasOne(mapper, def, record, __opts)\n } else {\n task = self.loadHasMany(mapper, def, record, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, record, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, record, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, record, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(record, {}, 'find')\n response.found = record ? 1 : 0\n response = self.respond(response, opts)\n\n // afterFind lifecycle hook\n op = opts.op = 'afterFind'\n return utils.resolve(self[op](mapper, id, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Retrieve the records that match the selection query.\n *\n * @name Adapter#findAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @param {string[]} [opts.with=[]] Relations to eager load.\n * @return {Promise}\n */\n findAll (mapper, query, opts) {\n const self = this\n opts || (opts = {})\n opts.with || (opts.with = [])\n\n let records = []\n let op\n const activeWith = opts._activeWith\n\n if (utils.isObject(activeWith)) {\n const activeQuery = activeWith.query || {}\n if (activeWith.replace) {\n query = activeQuery\n } else {\n utils.deepFillIn(query, activeQuery)\n }\n }\n\n // beforeFindAll lifecycle hook\n op = opts.op = 'beforeFindAll'\n return utils.resolve(self[op](mapper, query, opts)).then(function () {\n op = opts.op = 'findAll'\n self.dbg(op, mapper, query, opts)\n return utils.resolve(self._findAll(mapper, query, opts))\n }).then(function (results) {\n let [_records] = results\n _records || (_records = [])\n records = _records\n const tasks = []\n utils.forEachRelation(mapper, opts, function (def, __opts) {\n let task\n if (def.foreignKey && (def.type === 'hasOne' || def.type === 'hasMany')) {\n if (def.type === 'hasMany') {\n task = self.loadHasMany(mapper, def, records, __opts)\n } else {\n task = self.loadHasOne(mapper, def, records, __opts)\n }\n } else if (def.type === 'hasMany' && def.localKeys) {\n task = self.loadHasManyLocalKeys(mapper, def, records, __opts)\n } else if (def.type === 'hasMany' && def.foreignKeys) {\n task = self.loadHasManyForeignKeys(mapper, def, records, __opts)\n } else if (def.type === 'belongsTo') {\n task = self.loadBelongsTo(mapper, def, records, __opts)\n }\n if (task) {\n tasks.push(task)\n }\n })\n return Promise.all(tasks)\n }).then(function () {\n let response = new Response(records, {}, 'findAll')\n response.found = records.length\n response = self.respond(response, opts)\n\n // afterFindAll lifecycle hook\n op = opts.op = 'afterFindAll'\n return utils.resolve(self[op](mapper, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Resolve the value of the specified option based on the given options and\n * this adapter's settings. Override with care.\n *\n * @name Adapter#getOpt\n * @method\n * @param {string} opt The name of the option.\n * @param {Object} [opts] Configuration options.\n * @return {*} The value of the specified option.\n */\n getOpt (opt, opts) {\n opts || (opts = {})\n return utils.isUndefined(opts[opt]) ? utils.plainCopy(this[opt]) : utils.plainCopy(opts[opt])\n },\n\n /**\n * Load a hasMany relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasMany\n * @method\n * @return {Promise}\n */\n loadHasMany (mapper, def, records, __opts) {\n const self = this\n let singular = false\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n singular = true\n records = [records]\n }\n const IDs = records.map(function (record) {\n return self.makeHasManyForeignKey(mapper, def, record)\n })\n const query = {\n where: {}\n }\n const criteria = query.where[def.foreignKey] = {}\n if (singular) {\n // more efficient query when we only have one record\n criteria['=='] = IDs[0]\n } else {\n criteria['in'] = IDs.filter(function (id) {\n return id\n })\n }\n return self.findAll(def.getRelation(), query, __opts).then(function (relatedItems) {\n records.forEach(function (record) {\n let attached = []\n // avoid unneccesary iteration when we only have one record\n if (singular) {\n attached = relatedItems\n } else {\n relatedItems.forEach(function (relatedItem) {\n if (utils.get(relatedItem, def.foreignKey) === record[mapper.idAttribute]) {\n attached.push(relatedItem)\n }\n })\n }\n def.setLocalField(record, attached)\n })\n })\n },\n\n loadHasManyLocalKeys (mapper, def, records, __opts) {\n const self = this\n let record\n const relatedMapper = def.getRelation()\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': self.makeHasManyLocalKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n let localKeys = []\n records.forEach(function (record) {\n localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record))\n })\n return self.findAll(relatedMapper, {\n where: {\n [relatedMapper.idAttribute]: {\n 'in': unique(localKeys).filter(function (x) { return x })\n }\n }\n }, __opts).then(function (relatedItems) {\n records.forEach(function (item) {\n let attached = []\n let itemKeys = utils.get(item, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n relatedItems.forEach(function (relatedItem) {\n if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {\n attached.push(relatedItem)\n }\n })\n def.setLocalField(item, attached)\n })\n return relatedItems\n })\n }\n },\n\n loadHasManyForeignKeys (mapper, def, records, __opts) {\n const self = this\n const relatedMapper = def.getRelation()\n const idAttribute = mapper.idAttribute\n let record\n\n if (utils.isObject(records) && !utils.isArray(records)) {\n record = records\n }\n\n if (record) {\n return self.findAll(def.getRelation(), {\n where: {\n [def.foreignKeys]: {\n 'contains': self.makeHasManyForeignKeys(mapper, def, record)\n }\n }\n }, __opts).then(function (relatedItems) {\n def.setLocalField(record, relatedItems)\n })\n } else {\n return self.findAll(relatedMapper, {\n where: {\n [def.foreignKeys]: {\n 'isectNotEmpty': records.map(function (record) {\n return self.makeHasManyForeignKeys(mapper, def, record)\n })\n }\n }\n }, __opts).then(function (relatedItems) {\n const foreignKeysField = def.foreignKeys\n records.forEach(function (record) {\n const _relatedItems = []\n const id = utils.get(record, idAttribute)\n relatedItems.forEach(function (relatedItem) {\n const foreignKeys = utils.get(relatedItems, foreignKeysField) || []\n if (foreignKeys.indexOf(id) !== -1) {\n _relatedItems.push(relatedItem)\n }\n })\n def.setLocalField(record, _relatedItems)\n })\n })\n }\n },\n\n /**\n * Load a hasOne relationship.\n *\n * Override with care.\n *\n * @name Adapter#loadHasOne\n * @method\n * @return {Promise}\n */\n loadHasOne (mapper, def, records, __opts) {\n if (utils.isObject(records) && !utils.isArray(records)) {\n records = [records]\n }\n return this.loadHasMany(mapper, def, records, __opts).then(function () {\n records.forEach(function (record) {\n const relatedData = def.getLocalField(record)\n if (utils.isArray(relatedData) && relatedData.length) {\n def.setLocalField(record, relatedData[0])\n }\n })\n })\n },\n\n /**\n * Logging utility method. Override this method if you want to send log\n * messages to something other than the console.\n *\n * @name Adapter#log\n * @method\n * @param {string} level Log level.\n * @param {...*} values Values to log.\n */\n log (level, ...args) {\n if (level && !args.length) {\n args.push(level)\n level = 'debug'\n }\n if (level === 'debug' && !this.debug) {\n return\n }\n const prefix = `${level.toUpperCase()}: (Adapter)`\n if (console[level]) {\n console[level](prefix, ...args)\n } else {\n console.log(prefix, ...args)\n }\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * There may be reasons why you may want to override this method, like when\n * the id of the parent doesn't exactly match up to the key on the child.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKey\n * @method\n * @return {*}\n */\n makeHasManyForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Return the localKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyLocalKeys\n * @method\n * @return {*}\n */\n makeHasManyLocalKeys (mapper, def, record) {\n let localKeys = []\n let itemKeys = utils.get(record, def.localKeys) || []\n itemKeys = utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys)\n localKeys = localKeys.concat(itemKeys)\n return unique(localKeys).filter(function (x) { return x })\n },\n\n /**\n * Return the foreignKeys from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeHasManyForeignKeys\n * @method\n * @return {*}\n */\n makeHasManyForeignKeys (mapper, def, record) {\n return utils.get(record, mapper.idAttribute)\n },\n\n /**\n * Return the foreignKey from the given record for the provided relationship.\n *\n * Override with care.\n *\n * @name Adapter#makeBelongsToForeignKey\n * @method\n * @return {*}\n */\n makeBelongsToForeignKey (mapper, def, record) {\n return def.getForeignKey(record)\n },\n\n /**\n * Retrieve sum of the specified field of the records that match the selection\n * query. Called by `Mapper#sum`.\n *\n * @name Adapter#sum\n * @method\n * @param {Object} mapper The mapper.\n * @param {string} field By to sum.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n sum (mapper, field, query, opts) {\n const self = this\n let op\n if (!utils.isString(field)) {\n throw new Error('field must be a string!')\n }\n query || (query = {})\n opts || (opts = {})\n\n // beforeSum lifecycle hook\n op = opts.op = 'beforeSum'\n return utils.resolve(self[op](mapper, field, query, opts)).then(function () {\n // Allow for re-assignment from lifecycle hook\n op = opts.op = 'sum'\n self.dbg(op, mapper, field, query, opts)\n return utils.resolve(self._sum(mapper, field, query, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, op)\n response = self.respond(response, opts)\n\n // afterSum lifecycle hook\n op = opts.op = 'afterSum'\n return utils.resolve(self[op](mapper, field, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * @name Adapter#respond\n * @method\n * @param {Object} response Response object.\n * @param {Object} opts Configuration options.\n * return {Object} If `opts.raw == true` then return `response`, else return\n * `response.data`.\n */\n respond (response, opts) {\n return this.getOpt('raw', opts) ? response : response.data\n },\n\n /**\n * Apply the given update to the record with the specified primary key. Called\n * by `Mapper#update`.\n *\n * @name Adapter#update\n * @method\n * @param {Object} mapper The mapper.\n * @param {(string|number)} id The primary key of the record to be updated.\n * @param {Object} props The update to apply to the record.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n opts || (opts = {})\n let op\n\n // beforeUpdate lifecycle hook\n op = opts.op = 'beforeUpdate'\n return utils.resolve(self[op](mapper, id, props, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'update'\n self.dbg(op, mapper, id, props, opts)\n return utils.resolve(self._update(mapper, id, props, opts))\n }).then(function (results) {\n let [data, result] = results\n result || (result = {})\n let response = new Response(data, result, 'update')\n response.updated = data ? 1 : 0\n response = self.respond(response, opts)\n\n // afterUpdate lifecycle hook\n op = opts.op = 'afterUpdate'\n return utils.resolve(self[op](mapper, id, props, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Called by `Mapper#updateAll`.\n *\n * @name Adapter#updateAll\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object} props The update to apply to the selected records.\n * @param {Object} [query] Selection query.\n * @param {Object} [query.where] Filtering criteria.\n * @param {string|Array} [query.orderBy] Sorting criteria.\n * @param {string|Array} [query.sort] Same as `query.sort`.\n * @param {number} [query.limit] Limit results.\n * @param {number} [query.skip] Offset results.\n * @param {number} [query.offset] Same as `query.skip`.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateAll (mapper, props, query, opts) {\n const self = this\n props || (props = {})\n query || (query = {})\n opts || (opts = {})\n let op\n\n // beforeUpdateAll lifecycle hook\n op = opts.op = 'beforeUpdateAll'\n return utils.resolve(self[op](mapper, props, query, opts)).then(function (_props) {\n // Allow for re-assignment from lifecycle hook\n props = utils.isUndefined(_props) ? props : _props\n props = withoutRelations(mapper, props)\n op = opts.op = 'updateAll'\n self.dbg(op, mapper, props, query, opts)\n return utils.resolve(self._updateAll(mapper, props, query, opts))\n }).then(function (results) {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateAll')\n response.updated = data.length\n response = self.respond(response, opts)\n\n // afterUpdateAll lifecycle hook\n op = opts.op = 'afterUpdateAll'\n return utils.resolve(self[op](mapper, props, query, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n },\n\n /**\n * Update the given records in a single batch. Called by `Mapper#updateMany`.\n *\n * @name Adapter#updateMany\n * @method\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @param {boolean} [opts.raw=false] Whether to return a more detailed\n * response object.\n * @return {Promise}\n */\n updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n opts || (opts = {})\n let op\n const idAttribute = mapper.idAttribute\n\n records = records.filter(function (record) {\n return utils.get(record, idAttribute)\n })\n\n // beforeUpdateMany lifecycle hook\n op = opts.op = 'beforeUpdateMany'\n return utils.resolve(self[op](mapper, records, opts)).then(function (_records) {\n // Allow for re-assignment from lifecycle hook\n records = utils.isUndefined(_records) ? records : _records\n records = records.map(function (record) {\n return withoutRelations(mapper, record)\n })\n op = opts.op = 'updateMany'\n self.dbg(op, mapper, records, opts)\n return utils.resolve(self._updateMany(mapper, records, opts))\n }).then(function (results) {\n let [data, result] = results\n data || (data = [])\n result || (result = {})\n let response = new Response(data, result, 'updateMany')\n response.updated = data.length\n response = self.respond(response, opts)\n\n // afterUpdateMany lifecycle hook\n op = opts.op = 'afterUpdateMany'\n return utils.resolve(self[op](mapper, records, opts, response)).then(function (_response) {\n // Allow for re-assignment from lifecycle hook\n return utils.isUndefined(_response) ? response : _response\n })\n })\n }\n})\n","\n\n var _rKind = /^\\[object (.*)\\]$/,\n _toString = Object.prototype.toString,\n UNDEF;\n\n /**\n * Gets the \"kind\" of value. (e.g. \"String\", \"Number\", etc)\n */\n function kindOf(val) {\n if (val === null) {\n return 'Null';\n } else if (val === UNDEF) {\n return 'Undefined';\n } else {\n return _rKind.exec( _toString.call(val) )[1];\n }\n }\n module.exports = kindOf;\n\n","var kindOf = require('./kindOf');\n /**\n * Check if value is from a specific \"kind\".\n */\n function isKind(val, kind){\n return kindOf(val) === kind;\n }\n module.exports = isKind;\n\n","var isKind = require('./isKind');\n /**\n */\n var isArray = Array.isArray || function (val) {\n return isKind(val, 'Array');\n };\n module.exports = isArray;\n\n","/**\n * @constant Maximum 32-bit signed integer value. (2^31 - 1)\n */\n\n module.exports = 2147483647;\n\n","/**\n * @constant Minimum 32-bit signed integer value (-2^31).\n */\n\n module.exports = -2147483648;\n\n","\n\n /**\n * Just a wrapper to Math.random. No methods inside mout/random should call\n * Math.random() directly so we can inject the pseudo-random number\n * generator if needed (ie. in case we need a seeded random or a better\n * algorithm than the native one)\n */\n function random(){\n return random.get();\n }\n\n // we expose the method so it can be swapped if needed\n random.get = Math.random;\n\n module.exports = random;\n\n\n","var random = require('./random');\nvar MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\n\n /**\n * Returns random number inside range\n */\n function rand(min, max){\n min = min == null? MIN_INT : min;\n max = max == null? MAX_INT : max;\n return min + (max - min) * random();\n }\n\n module.exports = rand;\n\n","var MIN_INT = require('../number/MIN_INT');\nvar MAX_INT = require('../number/MAX_INT');\nvar rand = require('./rand');\n\n /**\n * Gets random integer inside range or snap to min/max values.\n */\n function randInt(min, max){\n min = min == null? MIN_INT : ~~min;\n max = max == null? MAX_INT : ~~max;\n // can't be max + 0.5 otherwise it will round up if `rand`\n // returns `max` causing it to overflow range.\n // -0.5 and + 0.49 are required to avoid bias caused by rounding\n return Math.round( rand(min - 0.5, max + 0.499999999999) );\n }\n\n module.exports = randInt;\n\n","var randInt = require('./randInt');\nvar isArray = require('../lang/isArray');\n\n /**\n * Returns a random element from the supplied arguments\n * or from the array (if single argument is an array).\n */\n function choice(items) {\n var target = (arguments.length === 1 && isArray(items))? items : arguments;\n return target[ randInt(0, target.length - 1) ];\n }\n\n module.exports = choice;\n\n\n","var choice = require('./choice');\n\n var _chars = '0123456789abcdef'.split('');\n\n /**\n * Returns a random hexadecimal string\n */\n function randHex(size){\n size = size && size > 0? size : 6;\n var str = '';\n while (size--) {\n str += choice(_chars);\n }\n return str;\n }\n\n module.exports = randHex;\n\n\n","var randHex = require('./randHex');\nvar choice = require('./choice');\n\n /**\n * Returns pseudo-random guid (UUID v4)\n * IMPORTANT: it's not totally \"safe\" since randHex/choice uses Math.random\n * by default and sequences can be predicted in some cases. See the\n * \"random/random\" documentation for more info about it and how to replace\n * the default PRNG.\n */\n function guid() {\n return (\n randHex(8)+'-'+\n randHex(4)+'-'+\n // v4 UUID always contain \"4\" at this position to specify it was\n // randomly generated\n '4' + randHex(3) +'-'+\n // v4 UUID always contain chars [a,b,8,9] at this position\n choice(8, 9, 'a', 'b') + randHex(3)+'-'+\n randHex(12)\n );\n }\n module.exports = guid;\n\n","/* global: localStorage */\n\nimport {Query, utils} from 'js-data'\nimport {Adapter} from '../node_modules/js-data-adapter/src/index'\n\n// This is kinda weird, but it's so we can use Rollup.js\nimport * as Guid from '../node_modules/mout/random/guid'\nconst { default: guid } = Guid\n\nconst __super__ = Adapter.prototype\n\nconst DEFAULTS = {\n /**\n * TODO\n *\n * @name LocalStorageAdapter#basePath\n * @type {string}\n */\n basePath: '',\n\n /**\n * TODO\n *\n * @name LocalStorageAdapter#storage\n * @type {Object}\n * @default localStorage\n */\n storage: localStorage\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}\nlet queue = []\nlet taskInProcess = false\n\nfunction enqueue (task) {\n queue.push(task)\n}\n\nfunction dequeue () {\n if (queue.length && !taskInProcess) {\n taskInProcess = true\n queue[0]()\n }\n}\n\nfunction queueTask (task) {\n if (!queue.length) {\n enqueue(task)\n dequeue()\n } else {\n enqueue(task)\n }\n}\n\nfunction createTask (fn) {\n return new Promise(fn).then(function (result) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return result\n }, function (err) {\n taskInProcess = false\n queue.shift()\n setTimeout(dequeue, 0)\n return utils.reject(err)\n })\n}\n\n/**\n * {@link LocalStorageAdapter} class.\n *\n * @name module:js-data-localstorage.LocalStorageAdapter\n * @see LocalStorageAdapter\n */\n\n/**\n * {@link LocalStorageAdapter} class. ES2015 default import.\n *\n * @name module:js-data-localstorage.default\n * @see LocalStorageAdapter\n */\n\n/**\n * LocalStorageAdapter class.\n *\n * @example\n * import {DataStore} from 'js-data'\n * import {LocalStorageAdapter} from 'js-data-localstorage'\n * const store = new DataStore()\n * const adapter = new LocalStorageAdapter()\n * store.registerAdapter('ls', adapter, { 'default': true })\n *\n * @class LocalStorageAdapter\n * @alias LocalStorageAdapter\n * @extends Adapter\n * @param {Object} [opts] Configuration options.\n * @param {string} [opts.basePath=''] See {@link LocalStorageAdapter#basePath}.\n * @param {boolean} [opts.debug=false] See {@link Adapter#debug}.\n * @param {boolean} [opts.raw=false] See {@link Adapter#raw}.\n * @param {Object} [opts.storeage=localStorage] See {@link LocalStorageAdapter#storage}.\n */\nexport function LocalStorageAdapter (opts) {\n const self = this\n utils.classCallCheck(self, LocalStorageAdapter)\n opts || (opts = {})\n utils.fillIn(opts, DEFAULTS)\n Adapter.call(self, opts)\n}\n\n// Setup prototype inheritance from Adapter\nLocalStorageAdapter.prototype = Object.create(Adapter.prototype, {\n constructor: {\n value: LocalStorageAdapter,\n enumerable: false,\n writable: true,\n configurable: true\n }\n})\n\nObject.defineProperty(LocalStorageAdapter, '__super__', {\n configurable: true,\n value: Adapter\n})\n\n/**\n * Alternative to ES6 class syntax for extending `LocalStorageAdapter`.\n *\n * @example Using the ES2015 class syntax.\n * class MyLocalStorageAdapter extends LocalStorageAdapter {...}\n * const adapter = new MyLocalStorageAdapter()\n *\n * @example Using {@link LocalStorageAdapter.extend}.\n * var instanceProps = {...}\n * var classProps = {...}\n *\n * var MyLocalStorageAdapter = LocalStorageAdapter.extend(instanceProps, classProps)\n * var adapter = new MyLocalStorageAdapter()\n *\n * @method LocalStorageAdapter.extend\n * @static\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 {Constructor} Subclass of `LocalStorageAdapter`.\n */\nLocalStorageAdapter.extend = utils.extend\n\nutils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, {\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#count.\n *\n * @method LocalStorageAdapter#_count\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _count (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n result[0] = result[0].length\n return result\n })\n },\n\n _createHelper (mapper, props, opts) {\n const self = this\n const _props = {}\n const relationFields = mapper.relationFields || []\n utils.forOwn(props, function (value, key) {\n if (relationFields.indexOf(key) === -1) {\n _props[key] = value\n }\n })\n const id = utils.get(_props, mapper.idAttribute) || guid()\n utils.set(_props, mapper.idAttribute, id)\n const key = self.getIdPath(mapper, opts, id)\n\n // Create the record\n // TODO: Create related records when the \"with\" option is provided\n self.storage.setItem(key, utils.toJson(_props))\n self.ensureId(id, mapper, opts)\n return utils.fromJson(self.storage.getItem(key))\n },\n\n /**\n * Create a new record. Internal method used by Adapter#create.\n *\n * @method LocalStorageAdapter#_create\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The record to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _create (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n return resolve([self._createHelper(mapper, props, opts), {}])\n })\n },\n\n /**\n * Create multiple records in a single batch. Internal method used by\n * Adapter#createMany.\n *\n * @method LocalStorageAdapter#_createMany\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} props The records to be created.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _createMany (mapper, props, opts) {\n const self = this\n return new Promise(function (resolve) {\n props || (props = [])\n return resolve([props.map(function (_props) {\n return self._createHelper(mapper, _props, opts)\n }), {}])\n })\n },\n\n /**\n * Destroy the record with the given primary key. Internal method used by\n * Adapter#destroy.\n *\n * @method LocalStorageAdapter#_destroy\n * @private\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 * @return {Promise}\n */\n _destroy (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n self.removeId(id, mapper, opts)\n return resolve([undefined, {}])\n })\n },\n\n /**\n * Destroy the records that match the selection query. Internal method used by\n * Adapter#destroyAll.\n *\n * @method LocalStorageAdapter#_destroyAll\n * @private\n * @param {Object} mapper the mapper.\n * @param {Object} [query] Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _destroyAll (mapper, query, opts) {\n const self = this\n return self._findAll(mapper, query).then(function (results) {\n let [records] = results\n const idAttribute = mapper.idAttribute\n // Gather IDs of records to be destroyed\n const ids = records.map(function (record) {\n return utils.get(record, idAttribute)\n })\n // Destroy each record\n ids.forEach(function (id) {\n self.storage.removeItem(self.getIdPath(mapper, opts, id))\n })\n self.removeId(ids, mapper, opts)\n return [undefined, {}]\n })\n },\n\n /**\n * Retrieve the record with the given primary key. Internal method used by\n * Adapter#find.\n *\n * @method LocalStorageAdapter#_find\n * @private\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 * @return {Promise}\n */\n _find (mapper, id, opts) {\n const self = this\n return new Promise(function (resolve) {\n const key = self.getIdPath(mapper, opts, id)\n const record = self.storage.getItem(key)\n return resolve([record ? utils.fromJson(record) : undefined, {}])\n })\n },\n\n /**\n * Retrieve the records that match the selection query. Internal method used\n * by Adapter#findAll.\n *\n * @method LocalStorageAdapter#_findAll\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object} query Selection query.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _findAll (mapper, query, opts) {\n const self = this\n query || (query = {})\n return new Promise(function (resolve) {\n // Load all records into memory...\n let records = []\n const ids = self.getIds(mapper, opts)\n utils.forOwn(ids, function (value, id) {\n const json = self.storage.getItem(self.getIdPath(mapper, opts, id))\n if (json) {\n records.push(utils.fromJson(json))\n }\n })\n const _query = new Query({\n index: {\n getAll () {\n return records\n }\n }\n })\n return resolve([_query.filter(query).run(), {}])\n })\n },\n\n /**\n * Retrieve the number of records that match the selection query. Internal\n * method used by Adapter#sum.\n *\n * @method LocalStorageAdapter#_sum\n * @private\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 * @return {Promise}\n */\n _sum (mapper, field, query, opts) {\n const self = this\n return self._findAll(mapper, query, opts).then(function (result) {\n let sum = 0\n result[0].forEach(function (record) {\n sum += utils.get(record, field) || 0\n })\n result[0] = sum\n return result\n })\n },\n\n /**\n * Apply the given update to the record with the specified primary key.\n * Internal method used by Adapter#update.\n *\n * @method LocalStorageAdapter#_update\n * @private\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 * @return {Promise}\n */\n _update (mapper, id, props, opts) {\n const self = this\n props || (props = {})\n return new Promise(function (resolve, reject) {\n const key = self.getIdPath(mapper, opts, id)\n let record = self.storage.getItem(key)\n if (!record) {\n return reject(new Error('Not Found'))\n }\n record = utils.fromJson(record)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n return resolve([record, {}])\n })\n },\n\n /**\n * Apply the given update to all records that match the selection query.\n * Internal method used by Adapter#updateAll.\n *\n * @method LocalStorageAdapter#_updateAll\n * @private\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} [opts] Configuration options.\n * @return {Promise}\n */\n _updateAll (mapper, props, query, opts) {\n const self = this\n const idAttribute = mapper.idAttribute\n return self._findAll(mapper, query, opts).then(function (results) {\n let [records] = results\n records.forEach(function (record) {\n record || (record = {})\n const id = utils.get(record, idAttribute)\n const key = self.getIdPath(mapper, opts, id)\n utils.deepMixIn(record, props)\n self.storage.setItem(key, utils.toJson(record))\n })\n return [records, {}]\n })\n },\n\n /**\n * Update the given records in a single batch. Internal method used by\n * Adapter#updateMany.\n *\n * @method LocalStorageAdapter#updateMany\n * @private\n * @param {Object} mapper The mapper.\n * @param {Object[]} records The records to update.\n * @param {Object} [opts] Configuration options.\n * @return {Promise}\n */\n _updateMany (mapper, records, opts) {\n const self = this\n records || (records = [])\n return new Promise(function (resolve) {\n const updatedRecords = []\n const idAttribute = mapper.idAttribute\n records.forEach(function (record) {\n if (!record) {\n return\n }\n const id = utils.get(record, idAttribute)\n if (utils.isUndefined(id)) {\n return\n }\n const key = self.getIdPath(mapper, opts, id)\n let json = self.storage.getItem(key)\n if (!json) {\n return\n }\n const existingRecord = utils.fromJson(json)\n utils.deepMixIn(existingRecord, record)\n self.storage.setItem(key, utils.toJson(existingRecord))\n updatedRecords.push(existingRecord)\n })\n return resolve([records, {}])\n })\n },\n\n create (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.create.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n createMany (mapper, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.createMany.call(self, mapper, props, opts).then(success, failure)\n })\n })\n },\n\n destroy (mapper, id, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroy.call(self, mapper, id, opts).then(success, failure)\n })\n })\n },\n\n destroyAll (mapper, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.destroyAll.call(self, mapper, query, opts).then(success, failure)\n })\n })\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#ensureId\n */\n ensureId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n ids[_id] = 1\n })\n } else {\n ids[id] = 1\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#getPath\n */\n getPath (mapper, opts) {\n opts = opts || {}\n return makePath(opts.basePath === undefined ? (mapper.basePath === undefined ? this.basePath : mapper.basePath) : opts.basePath, mapper.name)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#getIdPath\n */\n getIdPath (mapper, opts, id) {\n opts = opts || {}\n return makePath(opts.basePath || this.basePath || mapper.basePath, mapper.endpoint, id)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#getIds\n */\n getIds (mapper, opts) {\n let ids\n const idsPath = this.getPath(mapper, opts)\n const idsJson = this.storage.getItem(idsPath)\n if (idsJson) {\n ids = utils.fromJson(idsJson)\n } else {\n ids = {}\n }\n return ids\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#removeId\n */\n removeId (id, mapper, opts) {\n const ids = this.getIds(mapper, opts)\n if (utils.isArray(id)) {\n if (!id.length) {\n return\n }\n id.forEach(function (_id) {\n delete ids[_id]\n })\n } else {\n delete ids[id]\n }\n this.saveKeys(ids, mapper, opts)\n },\n\n /**\n * TODO\n *\n * @method LocalStorageAdapter#saveKeys\n */\n saveKeys (ids, mapper, opts) {\n ids = ids || {}\n const idsPath = this.getPath(mapper, opts)\n if (Object.keys(ids).length) {\n this.storage.setItem(idsPath, utils.toJson(ids))\n } else {\n this.storage.removeItem(idsPath)\n }\n },\n\n update (mapper, id, props, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.update.call(self, mapper, id, props, opts).then(success, failure)\n })\n })\n },\n\n updateAll (mapper, props, query, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateAll.call(self, mapper, props, query, opts).then(success, failure)\n })\n })\n },\n\n updateMany (mapper, records, opts) {\n const self = this\n return createTask(function (success, failure) {\n queueTask(function () {\n __super__.updateMany.call(self, mapper, records, opts).then(success, failure)\n })\n })\n }\n})\n\n/**\n * Details of the current version of the `js-data-localstorage` module.\n *\n * @name module:js-data-localstorage.version\n * @type {Object}\n * @property {string} version.full The full semver value.\n * @property {number} version.major The major version number.\n * @property {number} version.minor The minor version number.\n * @property {number} version.patch The patch version number.\n * @property {(string|boolean)} version.alpha The alpha version value,\n * otherwise `false` if the current version is not alpha.\n * @property {(string|boolean)} version.beta The beta version value,\n * otherwise `false` if the current version is not beta.\n */\nexport const version = '<%= version %>'\n\n/**\n * Registered as `js-data-localstorage` in NPM and Bower.\n *\n * @example Script tag\n * var LocalStorageAdapter = window.JSDataLocalStorage.LocalStorageAdapter\n * var adapter = new LocalStorageAdapter()\n *\n * @example CommonJS\n * var LocalStorageAdapter = require('js-data-localstorage').LocalStorageAdapter\n * var adapter = new LocalStorageAdapter()\n *\n * @example ES2015 Modules\n * import {LocalStorageAdapter} from 'js-data-localstorage'\n * const adapter = new LocalStorageAdapter()\n *\n * @example AMD\n * define('myApp', ['js-data-localstorage'], function (JSDataLocalStorage) {\n * var LocalStorageAdapter = JSDataLocalStorage.LocalStorageAdapter\n * var adapter = new LocalStorageAdapter()\n *\n * // ...\n * })\n *\n * @module js-data-localstorage\n */\n\nexport default LocalStorageAdapter\n"],"names":["utils","DEFAULTS","require$$0","require$$1","require$$2","Guid.default","Query"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGO,IAAM,OAAO,SAAP,IAAO,GAAmB;AACrC,EAAA,MAAM,OAAO,IAAb;;AADqC,EAAA,oCAAN,IAAM;AAAN,EAAA,QAAM;AAAA,EAAA;;AAErC,EAAA,MAAM,OAAO,KAAK,KAAK,MAAL,GAAc,CAAnB,CAAb;AACA,EAAA,OAAK,GAAL,cAAS,KAAK,EAAd,SAAqB,IAArB;AACA,EAAA,SAAOA,aAAM,OAAN,EAAP;AACD,EAAA,CALM;;AAOP,EAAO,IAAM,QAAQ,SAAR,KAAQ,GAAmB;AACtC,EAAA,MAAM,OAAO,IAAb;;AADsC,EAAA,qCAAN,IAAM;AAAN,EAAA,QAAM;AAAA,EAAA;;AAEtC,EAAA,MAAM,OAAO,KAAK,KAAK,MAAL,GAAc,CAAnB,CAAb;AACA,EAAA,OAAK,GAAL,cAAS,KAAK,EAAd,SAAqB,IAArB;AACA,EAAA,SAAOA,aAAM,OAAN,EAAP;AACD,EAAA,CALM;;AAOP,EAAO,IAAM,SAAS,SAAT,MAAS,CAAU,KAAV,EAAiB;AACrC,EAAA,MAAM,OAAO,EAAb;AACA,EAAA,MAAM,QAAQ,EAAd;AACA,EAAA,QAAM,OAAN,CAAc,UAAU,IAAV,EAAgB;AAC5B,EAAA,QAAI,QAAQ,IAAZ,EAAkB;AAChB,EAAA;AACD,EAAA;AACD,EAAA,UAAM,IAAN,CAAW,IAAX;AACA,EAAA,SAAK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AACA,EAAA,WAAO,WAAW,UAAU,OAAV,EAAmB,OAAnB,EAA4B;AAC5C,EAAA,gBAAU,YAAY;AACpB,EAAA,kBAAU,UAAV,CAAqB,IAArB,CAA0B,IAA1B,EAAgC,MAAhC,EAAwC,OAAxC,EAAiD,IAAjD,EAAuD,IAAvD,CAA4D,OAA5D,EAAqE,OAArE;AACD,EAAA,OAFD;AAGD,EAAA,KAJM,CAAP;AAKD,EAAA;AAtcyD,EAAA,CAA5D;;;;;;;;;;;;;;;;AAudA,EAAO,IAAM,UAAU,gBAAhB;;;;;;"} \ No newline at end of file diff --git a/dist/js-data-localstorage.min.js b/dist/js-data-localstorage.min.js index d114ad2..74c9da6 100644 --- a/dist/js-data-localstorage.min.js +++ b/dist/js-data-localstorage.min.js @@ -7,5 +7,5 @@ * * @overview localStorage adapter for js-data. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-localstorage",["exports","js-data"],e):e(t.JSDataLocalStorage=t.JSDataLocalStorage||{},t.JSData)}(this,function(t,e){"use strict";function n(t,e){return e={exports:{}},t(e,e.exports),e.exports}function r(t){var n=this;t||(t={}),e.utils.fillIn(t,b),e.utils.fillIn(n,t)}function o(t,n,r){var o=this;n||(n={}),o.data=t,e.utils.fillIn(o,n),o.op=r}function i(t){return null!=t&&""!==t}function u(t,e){return e||(e=""),t.filter(i).join(e)}function a(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=u(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function s(t){q.push(t)}function l(){q.length&&!$&&($=!0,q[0]())}function f(t){q.length?s(t):(s(t),l())}function c(t){return new Promise(t).then(function(t){return $=!1,q.shift(),setTimeout(l,0),t},function(t){return $=!1,q.shift(),setTimeout(l,0),e.utils.reject(t)})}function d(t){var n=this;e.utils.classCallCheck(n,d),t||(t={}),e.utils.fillIn(t,N),r.call(n,t)}var h={};h.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},h.defineProperty=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},h.slicedToArray=function(){function t(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var y=function(){for(var t=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-1];return t.dbg.apply(t,[i.op].concat(r)),e.utils.resolve()},p=function(){for(var t=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-2];return t.dbg.apply(t,[i.op].concat(r)),e.utils.resolve()},v=function(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n},g=function(t,n){return e.utils.omit(n,t.relationFields||[])},b={debug:!1,raw:!1};r.extend=e.utils.extend,e.utils.addHiddenPropsToTarget(r.prototype,{afterCount:p,afterCreate:p,afterCreateMany:p,afterDestroy:p,afterDestroyAll:p,afterFind:p,afterFindAll:p,afterSum:p,afterUpdate:p,afterUpdateAll:p,afterUpdateMany:p,beforeCount:y,beforeCreate:y,beforeCreateMany:y,beforeDestroy:y,beforeDestroyAll:y,beforeFind:y,beforeFindAll:y,beforeSum:y,beforeUpdate:y,beforeUpdateAll:y,beforeUpdateMany:y,dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},count:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeCount",e.utils.resolve(i[u](t,n,r)).then(function(){return u=r.op="count",i.dbg(u,t,n,r),e.utils.resolve(i._count(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,u);return c=i.respond(c,r),u=r.op="afterCount",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},create:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeCreate",e.utils.resolve(i[u](t,n,r)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=g(t,n),u=r.op="create",i.dbg(u,t,n,r),e.utils.resolve(i._create(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,"create");return c.created=l?1:0,c=i.respond(c,r),u=r.op="afterCreate",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},createMany:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeCreateMany",e.utils.resolve(i[u](t,n,r)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=n.map(function(e){return g(t,e)}),u=r.op="createMany",i.dbg(u,t,n,r),e.utils.resolve(i._createMany(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];l||(l=[]),f||(f={});var c=new o(l,f,"createMany");return c.created=l.length,c=i.respond(c,r),u=r.op="afterCreateMany",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},destroy:function(t,n,r){var i=this,u=void 0;return r||(r={}),u=r.op="beforeDestroy",e.utils.resolve(i[u](t,n,r)).then(function(){return u=r.op="destroy",i.dbg(u,t,n,r),e.utils.resolve(i._destroy(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,"destroy");return c=i.respond(c,r),u=r.op="afterDestroy",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},destroyAll:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeDestroyAll",e.utils.resolve(i[u](t,n,r)).then(function(){return u=r.op="destroyAll",i.dbg(u,t,n,r),e.utils.resolve(i._destroyAll(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,"destroyAll");return c=i.respond(c,r),u=r.op="afterDestroyAll",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},loadBelongsTo:function(t,n,r,o){var i=this,u=n.getRelation();if(!e.utils.isObject(r)||e.utils.isArray(r)){var a=r.map(function(e){return i.makeBelongsToForeignKey(t,n,e)}).filter(function(t){return t});return i.findAll(u,{where:h.defineProperty({},u.idAttribute,{in:a})},o).then(function(t){r.forEach(function(e){t.forEach(function(t){t[u.idAttribute]===e[n.foreignKey]&&n.setLocalField(e,t)})})})}var s=function(){var e=r;return{v:i.find(u,i.makeBelongsToForeignKey(t,n,e),o).then(function(t){n.setLocalField(e,t)})}}();return"object"===("undefined"==typeof s?"undefined":h.typeof(s))?s.v:void 0},find:function(t,n,r){var i=this,u=void 0,a=void 0;return r||(r={}),r.with||(r.with=[]),a=r.op="beforeFind",e.utils.resolve(i[a](t,n,r)).then(function(){return a=r.op="find",i.dbg(a,t,n,r),e.utils.resolve(i._find(t,n,r))}).then(function(n){var o=h.slicedToArray(n,1),a=o[0];if(a){u=a;var s=[];return e.utils.forEachRelation(t,r,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=i.loadHasManyLocalKeys(t,e,u,n):"hasMany"===e.type&&e.foreignKeys?r=i.loadHasManyForeignKeys(t,e,u,n):"belongsTo"===e.type&&(r=i.loadBelongsTo(t,e,u,n)):r="hasOne"===e.type?i.loadHasOne(t,e,u,n):i.loadHasMany(t,e,u,n),r&&s.push(r)}),Promise.all(s)}}).then(function(){var s=new o(u,{},"find");return s.found=u?1:0,s=i.respond(s,r),a=r.op="afterFind",e.utils.resolve(i[a](t,n,r,s)).then(function(t){return e.utils.isUndefined(t)?s:t})})},findAll:function(t,n,r){var i=this;r||(r={}),r.with||(r.with=[]);var u=[],a=void 0,s=r._activeWith;if(e.utils.isObject(s)){var l=s.query||{};s.replace?n=l:e.utils.deepFillIn(n,l)}return a=r.op="beforeFindAll",e.utils.resolve(i[a](t,n,r)).then(function(){return a=r.op="findAll",i.dbg(a,t,n,r),e.utils.resolve(i._findAll(t,n,r))}).then(function(n){var o=h.slicedToArray(n,1),a=o[0];a||(a=[]),u=a;var s=[];return e.utils.forEachRelation(t,r,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=i.loadHasManyLocalKeys(t,e,u,n):"hasMany"===e.type&&e.foreignKeys?r=i.loadHasManyForeignKeys(t,e,u,n):"belongsTo"===e.type&&(r=i.loadBelongsTo(t,e,u,n)):r="hasMany"===e.type?i.loadHasMany(t,e,u,n):i.loadHasOne(t,e,u,n),r&&s.push(r)}),Promise.all(s)}).then(function(){var s=new o(u,{},"findAll");return s.found=u.length,s=i.respond(s,r),a=r.op="afterFindAll",e.utils.resolve(i[a](t,n,r,s)).then(function(t){return e.utils.isUndefined(t)?s:t})})},getOpt:function(t,n){return n||(n={}),e.utils.isUndefined(n[t])?e.utils.plainCopy(this[t]):e.utils.plainCopy(n[t])},loadHasMany:function(t,n,r,o){var i=this,u=!1;e.utils.isObject(r)&&!e.utils.isArray(r)&&(u=!0,r=[r]);var a=r.map(function(e){return i.makeHasManyForeignKey(t,n,e)}),s={where:{}},l=s.where[n.foreignKey]={};return u?l["=="]=a[0]:l.in=a.filter(function(t){return t}),i.findAll(n.getRelation(),s,o).then(function(o){r.forEach(function(r){var i=[];u?i=o:o.forEach(function(o){e.utils.get(o,n.foreignKey)===r[t.idAttribute]&&i.push(o)}),n.setLocalField(r,i)})})},loadHasManyLocalKeys:function(t,n,r,o){var i=this,u=void 0,a=n.getRelation();if(e.utils.isObject(r)&&!e.utils.isArray(r)&&(u=r),u)return i.findAll(a,{where:h.defineProperty({},a.idAttribute,{in:i.makeHasManyLocalKeys(t,n,u)})},o).then(function(t){n.setLocalField(u,t)});var s=function(){var u=[];return r.forEach(function(e){u=u.concat(i.self.makeHasManyLocalKeys(t,n,e))}),{v:i.findAll(a,{where:h.defineProperty({},a.idAttribute,{in:v(u).filter(function(t){return t})})},o).then(function(t){return r.forEach(function(r){var o=[],i=e.utils.get(r,n.localKeys)||[];i=e.utils.isArray(i)?i:Object.keys(i),t.forEach(function(t){i&&-1!==i.indexOf(t[a.idAttribute])&&o.push(t)}),n.setLocalField(r,o)}),t})}}();return"object"===("undefined"==typeof s?"undefined":h.typeof(s))?s.v:void 0},loadHasManyForeignKeys:function(t,n,r,o){var i=this,u=n.getRelation(),a=t.idAttribute,s=void 0;return e.utils.isObject(r)&&!e.utils.isArray(r)&&(s=r),s?i.findAll(n.getRelation(),{where:h.defineProperty({},n.foreignKeys,{contains:i.makeHasManyForeignKeys(t,n,s)})},o).then(function(t){n.setLocalField(s,t)}):i.findAll(u,{where:h.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(e){return i.makeHasManyForeignKeys(t,n,e)})})},o).then(function(t){var o=n.foreignKeys;r.forEach(function(r){var i=[],u=e.utils.get(r,a);t.forEach(function(n){var r=e.utils.get(t,o)||[];-1!==r.indexOf(u)&&i.push(n)}),n.setLocalField(r,i)})})},loadHasOne:function(t,n,r,o){return e.utils.isObject(r)&&!e.utils.isArray(r)&&(r=[r]),this.loadHasMany(t,n,r,o).then(function(){r.forEach(function(t){var r=n.getLocalField(t);e.utils.isArray(r)&&r.length&&n.setLocalField(t,r[0])})})},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (Adapter)";if(console[t]){var i;(i=console)[t].apply(i,[o].concat(n))}else{var u;(u=console).log.apply(u,[o].concat(n))}}},makeHasManyForeignKey:function(t,e,n){return e.getForeignKey(n)},makeHasManyLocalKeys:function(t,n,r){var o=[],i=e.utils.get(r,n.localKeys)||[];return i=e.utils.isArray(i)?i:Object.keys(i),o=o.concat(i),v(o).filter(function(t){return t})},makeHasManyForeignKeys:function(t,n,r){return e.utils.get(r,t.idAttribute)},makeBelongsToForeignKey:function(t,e,n){return e.getForeignKey(n)},sum:function(t,n,r,i){var u=this,a=void 0;if(!e.utils.isString(n))throw new Error("field must be a string!");return r||(r={}),i||(i={}),a=i.op="beforeSum",e.utils.resolve(u[a](t,n,r,i)).then(function(){return a=i.op="sum",u.dbg(a,t,n,r,i),e.utils.resolve(u._sum(t,n,r,i))}).then(function(s){var l=h.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new o(f,c,a);return d=u.respond(d,i),a=i.op="afterSum",e.utils.resolve(u[a](t,n,r,i,d)).then(function(t){return e.utils.isUndefined(t)?d:t})})},respond:function(t,e){return this.getOpt("raw",e)?t:t.data},update:function(t,n,r,i){var u=this;r||(r={}),i||(i={});var a=void 0;return a=i.op="beforeUpdate",e.utils.resolve(u[a](t,n,r,i)).then(function(o){return r=e.utils.isUndefined(o)?r:o,r=g(t,r),a=i.op="update",u.dbg(a,t,n,r,i),e.utils.resolve(u._update(t,n,r,i))}).then(function(s){var l=h.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new o(f,c,"update");return d.updated=f?1:0,d=u.respond(d,i),a=i.op="afterUpdate",e.utils.resolve(u[a](t,n,r,i,d)).then(function(t){return e.utils.isUndefined(t)?d:t})})},updateAll:function(t,n,r,i){var u=this;n||(n={}),r||(r={}),i||(i={});var a=void 0;return a=i.op="beforeUpdateAll",e.utils.resolve(u[a](t,n,r,i)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=g(t,n),a=i.op="updateAll",u.dbg(a,t,n,r,i),e.utils.resolve(u._updateAll(t,n,r,i))}).then(function(s){var l=h.slicedToArray(s,2),f=l[0],c=l[1];f||(f=[]),c||(c={});var d=new o(f,c,"updateAll");return d.updated=f.length,d=u.respond(d,i),a=i.op="afterUpdateAll",e.utils.resolve(u[a](t,n,r,i,d)).then(function(t){return e.utils.isUndefined(t)?d:t})})},updateMany:function(t,n,r){var i=this;n||(n=[]),r||(r={});var u=void 0,a=t.idAttribute;return n=n.filter(function(t){return e.utils.get(t,a)}),u=r.op="beforeUpdateMany",e.utils.resolve(i[u](t,n,r)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=n.map(function(e){return g(t,e)}),u=r.op="updateMany",i.dbg(u,t,n,r),e.utils.resolve(i._updateMany(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];l||(l=[]),f||(f={});var c=new o(l,f,"updateMany");return c.updated=l.length,c=i.respond(c,r),u=r.op="afterUpdateMany",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})}});var A=n(function(t){function e(t){return null===t?"Null":t===n?"Undefined":r.exec(o.call(t))[1]}var n,r=/^\[object (.*)\]$/,o=Object.prototype.toString;t.exports=e}),m=A&&"object"==typeof A&&"default"in A?A.default:A,M=n(function(t){function e(t,e){return n(t)===e}var n=m;t.exports=e}),w=M&&"object"==typeof M&&"default"in M?M.default:M,I=n(function(t){var e=w,n=Array.isArray||function(t){return e(t,"Array")};t.exports=n}),P=I&&"object"==typeof I&&"default"in I?I.default:I,K=n(function(t){t.exports=2147483647}),j=K&&"object"==typeof K&&"default"in K?K.default:K,F=n(function(t){t.exports=-2147483648}),_=F&&"object"==typeof F&&"default"in F?F.default:F,U=n(function(t){function e(){return e.get()}e.get=Math.random,t.exports=e}),x=U&&"object"==typeof U&&"default"in U?U.default:U,T=n(function(t){function e(t,e){return t=null==t?r:t,e=null==e?o:e,t+(e-t)*n()}var n=x,r=_,o=j;t.exports=e}),O=T&&"object"==typeof T&&"default"in T?T.default:T,H=n(function(t){function e(t,e){return t=null==t?n:~~t,e=null==e?r:~~e,Math.round(o(t-.5,e+.499999999999))}var n=_,r=j,o=O;t.exports=e}),E=H&&"object"==typeof H&&"default"in H?H.default:H,S=n(function(t){function e(t){var e=1===arguments.length&&r(t)?t:arguments;return e[n(0,e.length-1)]}var n=E,r=P;t.exports=e}),L=S&&"object"==typeof S&&"default"in S?S.default:S,C=n(function(t){function e(t){t=t&&t>0?t:6;for(var e="";t--;)e+=n(r);return e}var n=L,r="0123456789abcdef".split("");t.exports=e}),k=C&&"object"==typeof C&&"default"in C?C.default:C,J=n(function(t){function e(){return n(8)+"-"+n(4)+"-4"+n(3)+"-"+r(8,9,"a","b")+n(3)+"-"+n(12)}var n=k,r=L;t.exports=e}),D=J&&"object"==typeof J&&"default"in J?J.default:J,R=D,B=r.prototype,N={basePath:"",debug:!1,storage:localStorage},q=[],$=!1;d.prototype=Object.create(r.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(d,"__super__",{configurable:!0,value:r}),d.extend=e.utils.extend,e.utils.addHiddenPropsToTarget(d.prototype,{_count:function(t,e,n){var r=this;return r._findAll(t,e,n).then(function(t){return t[0]=t[0].length,t})},_createHelper:function(t,n,r){var o=this,i={},u=t.relationFields||[];e.utils.forOwn(n,function(t,e){-1===u.indexOf(e)&&(i[e]=t)});var a=e.utils.get(i,t.idAttribute)||R();e.utils.set(i,t.idAttribute,a);var s=o.getIdPath(t,r,a);return o.storage.setItem(s,e.utils.toJson(i)),o.ensureId(a,t,r),e.utils.fromJson(o.storage.getItem(s))},_create:function(t,e,n){var r=this;return new Promise(function(o){return o([r._createHelper(t,e,n),{}])})},_createMany:function(t,e,n){var r=this;return new Promise(function(o){return e||(e=[]),o([e.map(function(e){return r._createHelper(t,e,n)}),{}])})},_destroy:function(t,e,n){var r=this;return new Promise(function(o){return r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),o([void 0,{}])})},_destroyAll:function(t,n,r){var o=this;return o._findAll(t,n).then(function(n){var i=h.slicedToArray(n,1),u=i[0],a=t.idAttribute,s=u.map(function(t){return e.utils.get(t,a)});return s.forEach(function(e){o.storage.removeItem(o.getIdPath(t,r,e))}),o.removeId(s,t,r),[void 0,{}]})},_find:function(t,n,r){var o=this;return new Promise(function(i){var u=o.getIdPath(t,r,n),a=o.storage.getItem(u);return i([a?e.utils.fromJson(a):void 0,{}])})},_findAll:function(t,n,r){var o=this;return n||(n={}),new Promise(function(i){var u=[],a=o.getIds(t,r);e.utils.forOwn(a,function(n,i){var a=o.storage.getItem(o.getIdPath(t,r,i));a&&u.push(e.utils.fromJson(a))});var s=new e.Query({index:{getAll:function(){return u}}});return i([s.filter(n).run(),{}])})},_sum:function(t,n,r,o){var i=this;return i._findAll(t,r,o).then(function(t){var r=0;return t[0].forEach(function(t){r+=e.utils.get(t,n)||0}),t[0]=r,t})},_update:function(t,n,r,o){var i=this;return r||(r={}),new Promise(function(u,a){var s=i.getIdPath(t,o,n),l=i.storage.getItem(s);return l?(l=e.utils.fromJson(l),e.utils.deepMixIn(l,r),i.storage.setItem(s,e.utils.toJson(l)),u([l,{}])):a(new Error("Not Found"))})},_updateAll:function(t,n,r,o){var i=this,u=t.idAttribute;return i._findAll(t,r,o).then(function(r){var a=h.slicedToArray(r,1),s=a[0];return s.forEach(function(r){r||(r={});var a=e.utils.get(r,u),s=i.getIdPath(t,o,a);e.utils.deepMixIn(r,n),i.storage.setItem(s,e.utils.toJson(r))}),[s,{}]})},_updateMany:function(t,n,r){var o=this;return n||(n=[]),new Promise(function(i){var u=[],a=t.idAttribute;return n.forEach(function(n){if(n){var i=e.utils.get(n,a);if(!e.utils.isUndefined(i)){var s=o.getIdPath(t,r,i),l=o.storage.getItem(s);if(l){var f=e.utils.fromJson(l);e.utils.deepMixIn(f,n),o.storage.setItem(s,e.utils.toJson(f)),u.push(f)}}}}),i([n,{}])})},create:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.create.call(r,t,e,n).then(o,i)})})},createMany:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.createMany.call(r,t,e,n).then(o,i)})})},destroy:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.destroy.call(r,t,e,n).then(o,i)})})},destroyAll:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.destroyAll.call(r,t,e,n).then(o,i)})})},ensureId:function(t,n,r){var o=this.getIds(n,r);if(e.utils.isArray(t)){if(!t.length)return;t.forEach(function(t){o[t]=1})}else o[t]=1;this.saveKeys(o,n,r)},getPath:function(t,e){return e=e||{},a(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},a(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,n){var r=void 0,o=this.getPath(t,n),i=this.storage.getItem(o);return r=i?e.utils.fromJson(i):{}},removeId:function(t,n,r){var o=this.getIds(n,r);if(e.utils.isArray(t)){if(!t.length)return;t.forEach(function(t){delete o[t]})}else delete o[t];this.saveKeys(o,n,r)},saveKeys:function(t,n,r){t=t||{};var o=this.getPath(n,r);Object.keys(t).length?this.storage.setItem(o,e.utils.toJson(t)):this.storage.removeItem(o)},update:function(t,e,n,r){var o=this;return c(function(i,u){f(function(){B.update.call(o,t,e,n,r).then(i,u)})})},updateAll:function(t,e,n,r){var o=this;return c(function(i,u){f(function(){B.updateAll.call(o,t,e,n,r).then(i,u)})})},updateMany:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.updateMany.call(r,t,e,n).then(o,i)})})}});var Q={beta:1,full:"3.0.0-beta.1",major:3,minor:0,patch:0};t.LocalStorageAdapter=d,t.version=Q,t.default=d}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("js-data")):"function"==typeof define&&define.amd?define("js-data-localstorage",["exports","js-data"],e):e(t.JSDataLocalStorage=t.JSDataLocalStorage||{},t.JSData)}(this,function(t,e){"use strict";function n(t,e){return e={exports:{}},t(e,e.exports),e.exports}function r(t){var n=this;t||(t={}),e.utils.fillIn(t,b),e.utils.fillIn(n,t)}function o(t,n,r){var o=this;n||(n={}),o.data=t,e.utils.fillIn(o,n),o.op=r}function i(t){return null!=t&&""!==t}function u(t,e){return e||(e=""),t.filter(i).join(e)}function a(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=u(e,"/");return r.replace(/([^:\/]|^)\/{2,}/g,"$1/")}function s(t){q.push(t)}function l(){q.length&&!$&&($=!0,q[0]())}function f(t){q.length?s(t):(s(t),l())}function c(t){return new Promise(t).then(function(t){return $=!1,q.shift(),setTimeout(l,0),t},function(t){return $=!1,q.shift(),setTimeout(l,0),e.utils.reject(t)})}function d(t){var n=this;e.utils.classCallCheck(n,d),t||(t={}),e.utils.fillIn(t,N),r.call(n,t)}var h={};h.typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},h.defineProperty=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},h.slicedToArray=function(){function t(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var y=function(){for(var t=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-1];return t.dbg.apply(t,[i.op].concat(r)),e.utils.resolve()},p=function(){for(var t=this,n=arguments.length,r=Array(n),o=0;n>o;o++)r[o]=arguments[o];var i=r[r.length-2];return t.dbg.apply(t,[i.op].concat(r)),e.utils.resolve()},v=function(t){var e={},n=[];return t.forEach(function(t){t in e||(n.push(t),e[t]=0)}),n},g=function(t,n){return e.utils.omit(n,t.relationFields||[])},b={debug:!1,raw:!1};r.extend=e.utils.extend,e.utils.addHiddenPropsToTarget(r.prototype,{afterCount:p,afterCreate:p,afterCreateMany:p,afterDestroy:p,afterDestroyAll:p,afterFind:p,afterFindAll:p,afterSum:p,afterUpdate:p,afterUpdateAll:p,afterUpdateMany:p,beforeCount:y,beforeCreate:y,beforeCreateMany:y,beforeDestroy:y,beforeDestroyAll:y,beforeFind:y,beforeFindAll:y,beforeSum:y,beforeUpdate:y,beforeUpdateAll:y,beforeUpdateMany:y,dbg:function(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];this.log.apply(this,["debug"].concat(e))},count:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeCount",e.utils.resolve(i[u](t,n,r)).then(function(){return u=r.op="count",i.dbg(u,t,n,r),e.utils.resolve(i._count(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,u);return c=i.respond(c,r),u=r.op="afterCount",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},create:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeCreate",e.utils.resolve(i[u](t,n,r)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=g(t,n),u=r.op="create",i.dbg(u,t,n,r),e.utils.resolve(i._create(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,"create");return c.created=l?1:0,c=i.respond(c,r),u=r.op="afterCreate",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},createMany:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeCreateMany",e.utils.resolve(i[u](t,n,r)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=n.map(function(e){return g(t,e)}),u=r.op="createMany",i.dbg(u,t,n,r),e.utils.resolve(i._createMany(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];l||(l=[]),f||(f={});var c=new o(l,f,"createMany");return c.created=l.length,c=i.respond(c,r),u=r.op="afterCreateMany",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},destroy:function(t,n,r){var i=this,u=void 0;return r||(r={}),u=r.op="beforeDestroy",e.utils.resolve(i[u](t,n,r)).then(function(){return u=r.op="destroy",i.dbg(u,t,n,r),e.utils.resolve(i._destroy(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,"destroy");return c=i.respond(c,r),u=r.op="afterDestroy",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},destroyAll:function(t,n,r){var i=this,u=void 0;return n||(n={}),r||(r={}),u=r.op="beforeDestroyAll",e.utils.resolve(i[u](t,n,r)).then(function(){return u=r.op="destroyAll",i.dbg(u,t,n,r),e.utils.resolve(i._destroyAll(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];f||(f={});var c=new o(l,f,"destroyAll");return c=i.respond(c,r),u=r.op="afterDestroyAll",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})},loadBelongsTo:function(t,n,r,o){var i=this,u=n.getRelation();if(!e.utils.isObject(r)||e.utils.isArray(r)){var a=r.map(function(e){return i.makeBelongsToForeignKey(t,n,e)}).filter(function(t){return t});return i.findAll(u,{where:h.defineProperty({},u.idAttribute,{in:a})},o).then(function(t){r.forEach(function(e){t.forEach(function(t){t[u.idAttribute]===e[n.foreignKey]&&n.setLocalField(e,t)})})})}var s=function(){var e=r;return{v:i.find(u,i.makeBelongsToForeignKey(t,n,e),o).then(function(t){n.setLocalField(e,t)})}}();return"object"===("undefined"==typeof s?"undefined":h.typeof(s))?s.v:void 0},find:function(t,n,r){var i=this,u=void 0,a=void 0;return r||(r={}),r.with||(r.with=[]),a=r.op="beforeFind",e.utils.resolve(i[a](t,n,r)).then(function(){return a=r.op="find",i.dbg(a,t,n,r),e.utils.resolve(i._find(t,n,r))}).then(function(n){var o=h.slicedToArray(n,1),a=o[0];if(a){u=a;var s=[];return e.utils.forEachRelation(t,r,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=i.loadHasManyLocalKeys(t,e,u,n):"hasMany"===e.type&&e.foreignKeys?r=i.loadHasManyForeignKeys(t,e,u,n):"belongsTo"===e.type&&(r=i.loadBelongsTo(t,e,u,n)):r="hasOne"===e.type?i.loadHasOne(t,e,u,n):i.loadHasMany(t,e,u,n),r&&s.push(r)}),Promise.all(s)}}).then(function(){var s=new o(u,{},"find");return s.found=u?1:0,s=i.respond(s,r),a=r.op="afterFind",e.utils.resolve(i[a](t,n,r,s)).then(function(t){return e.utils.isUndefined(t)?s:t})})},findAll:function(t,n,r){var i=this;r||(r={}),r.with||(r.with=[]);var u=[],a=void 0,s=r._activeWith;if(e.utils.isObject(s)){var l=s.query||{};s.replace?n=l:e.utils.deepFillIn(n,l)}return a=r.op="beforeFindAll",e.utils.resolve(i[a](t,n,r)).then(function(){return a=r.op="findAll",i.dbg(a,t,n,r),e.utils.resolve(i._findAll(t,n,r))}).then(function(n){var o=h.slicedToArray(n,1),a=o[0];a||(a=[]),u=a;var s=[];return e.utils.forEachRelation(t,r,function(e,n){var r=void 0;!e.foreignKey||"hasOne"!==e.type&&"hasMany"!==e.type?"hasMany"===e.type&&e.localKeys?r=i.loadHasManyLocalKeys(t,e,u,n):"hasMany"===e.type&&e.foreignKeys?r=i.loadHasManyForeignKeys(t,e,u,n):"belongsTo"===e.type&&(r=i.loadBelongsTo(t,e,u,n)):r="hasMany"===e.type?i.loadHasMany(t,e,u,n):i.loadHasOne(t,e,u,n),r&&s.push(r)}),Promise.all(s)}).then(function(){var s=new o(u,{},"findAll");return s.found=u.length,s=i.respond(s,r),a=r.op="afterFindAll",e.utils.resolve(i[a](t,n,r,s)).then(function(t){return e.utils.isUndefined(t)?s:t})})},getOpt:function(t,n){return n||(n={}),e.utils.isUndefined(n[t])?e.utils.plainCopy(this[t]):e.utils.plainCopy(n[t])},loadHasMany:function(t,n,r,o){var i=this,u=!1;e.utils.isObject(r)&&!e.utils.isArray(r)&&(u=!0,r=[r]);var a=r.map(function(e){return i.makeHasManyForeignKey(t,n,e)}),s={where:{}},l=s.where[n.foreignKey]={};return u?l["=="]=a[0]:l.in=a.filter(function(t){return t}),i.findAll(n.getRelation(),s,o).then(function(o){r.forEach(function(r){var i=[];u?i=o:o.forEach(function(o){e.utils.get(o,n.foreignKey)===r[t.idAttribute]&&i.push(o)}),n.setLocalField(r,i)})})},loadHasManyLocalKeys:function(t,n,r,o){var i=this,u=void 0,a=n.getRelation();if(e.utils.isObject(r)&&!e.utils.isArray(r)&&(u=r),u)return i.findAll(a,{where:h.defineProperty({},a.idAttribute,{in:i.makeHasManyLocalKeys(t,n,u)})},o).then(function(t){n.setLocalField(u,t)});var s=function(){var u=[];return r.forEach(function(e){u=u.concat(i.self.makeHasManyLocalKeys(t,n,e))}),{v:i.findAll(a,{where:h.defineProperty({},a.idAttribute,{in:v(u).filter(function(t){return t})})},o).then(function(t){return r.forEach(function(r){var o=[],i=e.utils.get(r,n.localKeys)||[];i=e.utils.isArray(i)?i:Object.keys(i),t.forEach(function(t){i&&-1!==i.indexOf(t[a.idAttribute])&&o.push(t)}),n.setLocalField(r,o)}),t})}}();return"object"===("undefined"==typeof s?"undefined":h.typeof(s))?s.v:void 0},loadHasManyForeignKeys:function(t,n,r,o){var i=this,u=n.getRelation(),a=t.idAttribute,s=void 0;return e.utils.isObject(r)&&!e.utils.isArray(r)&&(s=r),s?i.findAll(n.getRelation(),{where:h.defineProperty({},n.foreignKeys,{contains:i.makeHasManyForeignKeys(t,n,s)})},o).then(function(t){n.setLocalField(s,t)}):i.findAll(u,{where:h.defineProperty({},n.foreignKeys,{isectNotEmpty:r.map(function(e){return i.makeHasManyForeignKeys(t,n,e)})})},o).then(function(t){var o=n.foreignKeys;r.forEach(function(r){var i=[],u=e.utils.get(r,a);t.forEach(function(n){var r=e.utils.get(t,o)||[];-1!==r.indexOf(u)&&i.push(n)}),n.setLocalField(r,i)})})},loadHasOne:function(t,n,r,o){return e.utils.isObject(r)&&!e.utils.isArray(r)&&(r=[r]),this.loadHasMany(t,n,r,o).then(function(){r.forEach(function(t){var r=n.getLocalField(t);e.utils.isArray(r)&&r.length&&n.setLocalField(t,r[0])})})},log:function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];if(t&&!n.length&&(n.push(t),t="debug"),"debug"!==t||this.debug){var o=t.toUpperCase()+": (Adapter)";if(console[t]){var i;(i=console)[t].apply(i,[o].concat(n))}else{var u;(u=console).log.apply(u,[o].concat(n))}}},makeHasManyForeignKey:function(t,e,n){return e.getForeignKey(n)},makeHasManyLocalKeys:function(t,n,r){var o=[],i=e.utils.get(r,n.localKeys)||[];return i=e.utils.isArray(i)?i:Object.keys(i),o=o.concat(i),v(o).filter(function(t){return t})},makeHasManyForeignKeys:function(t,n,r){return e.utils.get(r,t.idAttribute)},makeBelongsToForeignKey:function(t,e,n){return e.getForeignKey(n)},sum:function(t,n,r,i){var u=this,a=void 0;if(!e.utils.isString(n))throw new Error("field must be a string!");return r||(r={}),i||(i={}),a=i.op="beforeSum",e.utils.resolve(u[a](t,n,r,i)).then(function(){return a=i.op="sum",u.dbg(a,t,n,r,i),e.utils.resolve(u._sum(t,n,r,i))}).then(function(s){var l=h.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new o(f,c,a);return d=u.respond(d,i),a=i.op="afterSum",e.utils.resolve(u[a](t,n,r,i,d)).then(function(t){return e.utils.isUndefined(t)?d:t})})},respond:function(t,e){return this.getOpt("raw",e)?t:t.data},update:function(t,n,r,i){var u=this;r||(r={}),i||(i={});var a=void 0;return a=i.op="beforeUpdate",e.utils.resolve(u[a](t,n,r,i)).then(function(o){return r=e.utils.isUndefined(o)?r:o,r=g(t,r),a=i.op="update",u.dbg(a,t,n,r,i),e.utils.resolve(u._update(t,n,r,i))}).then(function(s){var l=h.slicedToArray(s,2),f=l[0],c=l[1];c||(c={});var d=new o(f,c,"update");return d.updated=f?1:0,d=u.respond(d,i),a=i.op="afterUpdate",e.utils.resolve(u[a](t,n,r,i,d)).then(function(t){return e.utils.isUndefined(t)?d:t})})},updateAll:function(t,n,r,i){var u=this;n||(n={}),r||(r={}),i||(i={});var a=void 0;return a=i.op="beforeUpdateAll",e.utils.resolve(u[a](t,n,r,i)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=g(t,n),a=i.op="updateAll",u.dbg(a,t,n,r,i),e.utils.resolve(u._updateAll(t,n,r,i))}).then(function(s){var l=h.slicedToArray(s,2),f=l[0],c=l[1];f||(f=[]),c||(c={});var d=new o(f,c,"updateAll");return d.updated=f.length,d=u.respond(d,i),a=i.op="afterUpdateAll",e.utils.resolve(u[a](t,n,r,i,d)).then(function(t){return e.utils.isUndefined(t)?d:t})})},updateMany:function(t,n,r){var i=this;n||(n=[]),r||(r={});var u=void 0,a=t.idAttribute;return n=n.filter(function(t){return e.utils.get(t,a)}),u=r.op="beforeUpdateMany",e.utils.resolve(i[u](t,n,r)).then(function(o){return n=e.utils.isUndefined(o)?n:o,n=n.map(function(e){return g(t,e)}),u=r.op="updateMany",i.dbg(u,t,n,r),e.utils.resolve(i._updateMany(t,n,r))}).then(function(a){var s=h.slicedToArray(a,2),l=s[0],f=s[1];l||(l=[]),f||(f={});var c=new o(l,f,"updateMany");return c.updated=l.length,c=i.respond(c,r),u=r.op="afterUpdateMany",e.utils.resolve(i[u](t,n,r,c)).then(function(t){return e.utils.isUndefined(t)?c:t})})}});var A=n(function(t){function e(t){return null===t?"Null":t===n?"Undefined":r.exec(o.call(t))[1]}var n,r=/^\[object (.*)\]$/,o=Object.prototype.toString;t.exports=e}),m=A&&"object"==typeof A&&"default"in A?A.default:A,M=n(function(t){function e(t,e){return n(t)===e}var n=m;t.exports=e}),w=M&&"object"==typeof M&&"default"in M?M.default:M,I=n(function(t){var e=w,n=Array.isArray||function(t){return e(t,"Array")};t.exports=n}),P=I&&"object"==typeof I&&"default"in I?I.default:I,K=n(function(t){t.exports=2147483647}),j=K&&"object"==typeof K&&"default"in K?K.default:K,F=n(function(t){t.exports=-2147483648}),_=F&&"object"==typeof F&&"default"in F?F.default:F,U=n(function(t){function e(){return e.get()}e.get=Math.random,t.exports=e}),x=U&&"object"==typeof U&&"default"in U?U.default:U,T=n(function(t){function e(t,e){return t=null==t?r:t,e=null==e?o:e,t+(e-t)*n()}var n=x,r=_,o=j;t.exports=e}),O=T&&"object"==typeof T&&"default"in T?T.default:T,H=n(function(t){function e(t,e){return t=null==t?n:~~t,e=null==e?r:~~e,Math.round(o(t-.5,e+.499999999999))}var n=_,r=j,o=O;t.exports=e}),E=H&&"object"==typeof H&&"default"in H?H.default:H,S=n(function(t){function e(t){var e=1===arguments.length&&r(t)?t:arguments;return e[n(0,e.length-1)]}var n=E,r=P;t.exports=e}),L=S&&"object"==typeof S&&"default"in S?S.default:S,C=n(function(t){function e(t){t=t&&t>0?t:6;for(var e="";t--;)e+=n(r);return e}var n=L,r="0123456789abcdef".split("");t.exports=e}),k=C&&"object"==typeof C&&"default"in C?C.default:C,J=n(function(t){function e(){return n(8)+"-"+n(4)+"-4"+n(3)+"-"+r(8,9,"a","b")+n(3)+"-"+n(12)}var n=k,r=L;t.exports=e}),D=J&&"object"==typeof J&&"default"in J?J.default:J,R=D,B=r.prototype,N={basePath:"",storage:localStorage},q=[],$=!1;d.prototype=Object.create(r.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),Object.defineProperty(d,"__super__",{configurable:!0,value:r}),d.extend=e.utils.extend,e.utils.addHiddenPropsToTarget(d.prototype,{_count:function(t,e,n){var r=this;return r._findAll(t,e,n).then(function(t){return t[0]=t[0].length,t})},_createHelper:function(t,n,r){var o=this,i={},u=t.relationFields||[];e.utils.forOwn(n,function(t,e){-1===u.indexOf(e)&&(i[e]=t)});var a=e.utils.get(i,t.idAttribute)||R();e.utils.set(i,t.idAttribute,a);var s=o.getIdPath(t,r,a);return o.storage.setItem(s,e.utils.toJson(i)),o.ensureId(a,t,r),e.utils.fromJson(o.storage.getItem(s))},_create:function(t,e,n){var r=this;return new Promise(function(o){return o([r._createHelper(t,e,n),{}])})},_createMany:function(t,e,n){var r=this;return new Promise(function(o){return e||(e=[]),o([e.map(function(e){return r._createHelper(t,e,n)}),{}])})},_destroy:function(t,e,n){var r=this;return new Promise(function(o){return r.storage.removeItem(r.getIdPath(t,n,e)),r.removeId(e,t,n),o([void 0,{}])})},_destroyAll:function(t,n,r){var o=this;return o._findAll(t,n).then(function(n){var i=h.slicedToArray(n,1),u=i[0],a=t.idAttribute,s=u.map(function(t){return e.utils.get(t,a)});return s.forEach(function(e){o.storage.removeItem(o.getIdPath(t,r,e))}),o.removeId(s,t,r),[void 0,{}]})},_find:function(t,n,r){var o=this;return new Promise(function(i){var u=o.getIdPath(t,r,n),a=o.storage.getItem(u);return i([a?e.utils.fromJson(a):void 0,{}])})},_findAll:function(t,n,r){var o=this;return n||(n={}),new Promise(function(i){var u=[],a=o.getIds(t,r);e.utils.forOwn(a,function(n,i){var a=o.storage.getItem(o.getIdPath(t,r,i));a&&u.push(e.utils.fromJson(a))});var s=new e.Query({index:{getAll:function(){return u}}});return i([s.filter(n).run(),{}])})},_sum:function(t,n,r,o){var i=this;return i._findAll(t,r,o).then(function(t){var r=0;return t[0].forEach(function(t){r+=e.utils.get(t,n)||0}),t[0]=r,t})},_update:function(t,n,r,o){var i=this;return r||(r={}),new Promise(function(u,a){var s=i.getIdPath(t,o,n),l=i.storage.getItem(s);return l?(l=e.utils.fromJson(l),e.utils.deepMixIn(l,r),i.storage.setItem(s,e.utils.toJson(l)),u([l,{}])):a(new Error("Not Found"))})},_updateAll:function(t,n,r,o){var i=this,u=t.idAttribute;return i._findAll(t,r,o).then(function(r){var a=h.slicedToArray(r,1),s=a[0];return s.forEach(function(r){r||(r={});var a=e.utils.get(r,u),s=i.getIdPath(t,o,a);e.utils.deepMixIn(r,n),i.storage.setItem(s,e.utils.toJson(r))}),[s,{}]})},_updateMany:function(t,n,r){var o=this;return n||(n=[]),new Promise(function(i){var u=[],a=t.idAttribute;return n.forEach(function(n){if(n){var i=e.utils.get(n,a);if(!e.utils.isUndefined(i)){var s=o.getIdPath(t,r,i),l=o.storage.getItem(s);if(l){var f=e.utils.fromJson(l);e.utils.deepMixIn(f,n),o.storage.setItem(s,e.utils.toJson(f)),u.push(f)}}}}),i([n,{}])})},create:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.create.call(r,t,e,n).then(o,i)})})},createMany:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.createMany.call(r,t,e,n).then(o,i)})})},destroy:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.destroy.call(r,t,e,n).then(o,i)})})},destroyAll:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.destroyAll.call(r,t,e,n).then(o,i)})})},ensureId:function(t,n,r){var o=this.getIds(n,r);if(e.utils.isArray(t)){if(!t.length)return;t.forEach(function(t){o[t]=1})}else o[t]=1;this.saveKeys(o,n,r)},getPath:function(t,e){return e=e||{},a(void 0===e.basePath?void 0===t.basePath?this.basePath:t.basePath:e.basePath,t.name)},getIdPath:function(t,e,n){return e=e||{},a(e.basePath||this.basePath||t.basePath,t.endpoint,n)},getIds:function(t,n){var r=void 0,o=this.getPath(t,n),i=this.storage.getItem(o);return r=i?e.utils.fromJson(i):{}},removeId:function(t,n,r){var o=this.getIds(n,r);if(e.utils.isArray(t)){if(!t.length)return;t.forEach(function(t){delete o[t]})}else delete o[t];this.saveKeys(o,n,r)},saveKeys:function(t,n,r){t=t||{};var o=this.getPath(n,r);Object.keys(t).length?this.storage.setItem(o,e.utils.toJson(t)):this.storage.removeItem(o)},update:function(t,e,n,r){var o=this;return c(function(i,u){f(function(){B.update.call(o,t,e,n,r).then(i,u)})})},updateAll:function(t,e,n,r){var o=this;return c(function(i,u){f(function(){B.updateAll.call(o,t,e,n,r).then(i,u)})})},updateMany:function(t,e,n){var r=this;return c(function(o,i){f(function(){B.updateMany.call(r,t,e,n).then(o,i)})})}});var Q={beta:1,full:"3.0.0-beta.1",major:3,minor:0,patch:0};t.LocalStorageAdapter=d,t.version=Q,t.default=d}); //# sourceMappingURL=js-data-localstorage.min.map \ No newline at end of file diff --git a/dist/js-data-localstorage.min.map b/dist/js-data-localstorage.min.map index b83c8c8..882d40d 100644 --- a/dist/js-data-localstorage.min.map +++ b/dist/js-data-localstorage.min.map @@ -1 +1 @@ -{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["global","factory","exports","module","require","define","amd","JSDataLocalStorage","JSData","this","jsData","__commonjs","fn","Adapter","opts","self","utils","fillIn","DEFAULTS$1","Response","data","meta","op","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","enqueue","task","queue","push","dequeue","taskInProcess","queueTask","createTask","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","classCallCheck","DEFAULTS","call","babelHelpers","typeof","Symbol","iterator","obj","constructor","defineProperty","key","Object","enumerable","configurable","writable","slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","next","done","isArray","TypeError","noop","dbg","apply","concat","resolve","noop2","_len2","_key2","unique","array","seen","final","forEach","item","withoutRelations","mapper","props","omit","relationFields","debug","raw","extend","addHiddenPropsToTarget","prototype","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","log","count","query","_count","results","_results","response","respond","_response","isUndefined","create","_props","_create","_results2","created","createMany","map","record","_createMany","_results3","destroy","id","_destroy","_results4","destroyAll","_destroyAll","_results5","loadBelongsTo","def","records","__opts","relationDef","getRelation","isObject","keys","makeBelongsToForeignKey","findAll","where","idAttribute","in","relatedItems","relatedItem","foreignKey","setLocalField","_ret","v","find","with","_find","_results6","_record","tasks","forEachRelation","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","all","found","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_results7","_records","getOpt","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","attached","get","relatedMapper","makeHasManyLocalKeys","_ret2","x","itemKeys","indexOf","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","level","_len4","_key4","prefix","toUpperCase","console","_console","_console2","getForeignKey","sum","field","isString","Error","_sum","_results8","update","_update","_results9","updated","updateAll","_updateAll","_results10","updateMany","_updateMany","_results11","kindOf","val","UNDEF","_rKind","exec","_toString","toString","require$$0$3","isKind","kind","require$$0$2","require$$0$1","MAX_INT","require$$0$5","MIN_INT","require$$1$1","random","Math","require$$2","rand","min","max","require$$0$4","randInt","round","require$$1","choice","target","require$$0","randHex","size","str","_chars","split","require$$1$2","guid$1","guid","guid$2","__super__","basePath","storage","localStorage","_createHelper","forOwn","set","getIdPath","setItem","toJson","ensureId","fromJson","getItem","removeItem","removeId","ids","getIds","json","_query","Query","index","getAll","run","deepMixIn","updatedRecords","existingRecord","success","failure","_id","saveKeys","getPath","name","endpoint","idsPath","idsJson","version","beta","full","major","minor","patch"],"mappings":"CAAC,SAAUA,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,QAASE,QAAQ,YACtE,kBAAXC,SAAyBA,OAAOC,IAAMD,OAAO,wBAAyB,UAAW,WAAYJ,GACnGA,EAASD,EAAOO,mBAAqBP,EAAOO,uBAA0BP,EAAOQ,SAC9EC,KAAM,SAAUP,EAAQQ,GAAU,YAiElC,SAASC,GAAWC,EAAIT,G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BkD,QAAOqG,KAAKuI,GAAK5Q,OACnBvB,KAAKsR,QAAQM,QAAQyB,EAASpT,EAAOM,MAAMsR,OAAOM,IAElDnS,KAAKsR,QAAQW,WAAWoB,IAG5BjF,OAAQ,SAAgB3I,EAAQsD,EAAIrD,EAAOrF,GACzC,GAAIC,GAAON,IACX,OAAOoC,GAAW,SAAU0Q,EAASC,GACnC5Q,EAAU,WACRiP,EAAUhD,OAAOtL,KAAKxC,EAAMmF,EAAQsD,EAAIrD,EAAOrF,GAAMiC,KAAKwQ,EAASC,QAIzEvE,UAAW,SAAmB/I,EAAQC,EAAOkC,EAAOvH,GAClD,GAAIC,GAAON,IACX,OAAOoC,GAAW,SAAU0Q,EAASC,GACnC5Q,EAAU,WACRiP,EAAU5C,UAAU1L,KAAKxC,EAAMmF,EAAQC,EAAOkC,EAAOvH,GAAMiC,KAAKwQ,EAASC,QAI/EpE,WAAY,SAAoBlJ,EAAQ8D,EAASlJ,GAC/C,GAAIC,GAAON,IACX,OAAOoC,GAAW,SAAU0Q,EAASC,GACnC5Q,EAAU,WACRiP,EAAUzC,WAAW7L,KAAKxC,EAAMmF,EAAQ8D,EAASlJ,GAAMiC,KAAKwQ,EAASC,SAoB7E,IAAIQ,IACJC,KAAM,EACNC,KAAM,eACNC,MAAO,EACPC,MAAO,EACPC,MAAO,EAGPnU,GAAQkD,oBAAsBA,EAC9BlD,EAAQ8T,QAAUA,EAClB9T,EAAiB,QAAIkD","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file +{"version":3,"sources":["dist/js-data-localstorage.js"],"names":["global","factory","exports","module","require","define","amd","JSDataLocalStorage","JSData","this","jsData","__commonjs","fn","Adapter","opts","self","utils","fillIn","DEFAULTS$1","Response","data","meta","op","isValidString","value","join","items","separator","filter","makePath","_len","arguments","length","args","Array","_key","result","replace","enqueue","task","queue","push","dequeue","taskInProcess","queueTask","createTask","Promise","then","shift","setTimeout","err","reject","LocalStorageAdapter","classCallCheck","DEFAULTS","call","babelHelpers","typeof","Symbol","iterator","obj","constructor","defineProperty","key","Object","enumerable","configurable","writable","slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","next","done","isArray","TypeError","noop","dbg","apply","concat","resolve","noop2","_len2","_key2","unique","array","seen","final","forEach","item","withoutRelations","mapper","props","omit","relationFields","debug","raw","extend","addHiddenPropsToTarget","prototype","afterCount","afterCreate","afterCreateMany","afterDestroy","afterDestroyAll","afterFind","afterFindAll","afterSum","afterUpdate","afterUpdateAll","afterUpdateMany","beforeCount","beforeCreate","beforeCreateMany","beforeDestroy","beforeDestroyAll","beforeFind","beforeFindAll","beforeSum","beforeUpdate","beforeUpdateAll","beforeUpdateMany","_len3","_key3","log","count","query","_count","results","_results","response","respond","_response","isUndefined","create","_props","_create","_results2","created","createMany","map","record","_createMany","_results3","destroy","id","_destroy","_results4","destroyAll","_destroyAll","_results5","loadBelongsTo","def","records","__opts","relationDef","getRelation","isObject","keys","makeBelongsToForeignKey","findAll","where","idAttribute","in","relatedItems","relatedItem","foreignKey","setLocalField","_ret","v","find","with","_find","_results6","_record","tasks","forEachRelation","type","localKeys","loadHasManyLocalKeys","foreignKeys","loadHasManyForeignKeys","loadHasOne","loadHasMany","all","found","activeWith","_activeWith","activeQuery","deepFillIn","_findAll","_results7","_records","getOpt","opt","plainCopy","singular","IDs","makeHasManyForeignKey","criteria","attached","get","relatedMapper","makeHasManyLocalKeys","_ret2","x","itemKeys","indexOf","contains","makeHasManyForeignKeys","isectNotEmpty","foreignKeysField","_relatedItems","relatedData","getLocalField","level","_len4","_key4","prefix","toUpperCase","console","_console","_console2","getForeignKey","sum","field","isString","Error","_sum","_results8","update","_update","_results9","updated","updateAll","_updateAll","_results10","updateMany","_updateMany","_results11","kindOf","val","UNDEF","_rKind","exec","_toString","toString","require$$0$3","isKind","kind","require$$0$2","require$$0$1","MAX_INT","require$$0$5","MIN_INT","require$$1$1","random","Math","require$$2","rand","min","max","require$$0$4","randInt","round","require$$1","choice","target","require$$0","randHex","size","str","_chars","split","require$$1$2","guid$1","guid","guid$2","__super__","basePath","storage","localStorage","_createHelper","forOwn","set","getIdPath","setItem","toJson","ensureId","fromJson","getItem","removeItem","removeId","ids","getIds","json","_query","Query","index","getAll","run","deepMixIn","updatedRecords","existingRecord","success","failure","_id","saveKeys","getPath","name","endpoint","idsPath","idsJson","version","beta","full","major","minor","patch"],"mappings":"CAAC,SAAUA,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,QAASE,QAAQ,YACtE,kBAAXC,SAAyBA,OAAOC,IAAMD,OAAO,wBAAyB,UAAW,WAAYJ,GACnGA,EAASD,EAAOO,mBAAqBP,EAAOO,uBAA0BP,EAAOQ,SAC9EC,KAAM,SAAUP,EAAQQ,GAAU,YAiElC,SAASC,GAAWC,EAAIT,GAAU,MAAOA,IAAWD,YAAeU,EAAGT,EAAQA,EAAOD,SAAUC,EAAOD,QAyEtG,QAASW,GAAQC,GACf,GAAIC,GAAON,IACXK,KAASA,MACTJ,EAAOM,MAAMC,OAAOH,EAAMI,GAC1BR,EAAOM,MAAMC,OAAOF,EAAMD,GAS5B,QAASK,GAASC,EAAMC,EAAMC,GAC5B,GAAIP,GAAON,IACXY,KAASA,MAQTN,EAAKK,KAAOA,EAEZV,EAAOM,MAAMC,OAAOF,EAAMM,GAQ1BN,EAAKO,GAAKA,EAmpDZ,QAASC,GAAcC,GACrB,MAAgB,OAATA,GAA2B,KAAVA,EAE1B,QAASC,GAAKC,EAAOC,GAEnB,MADAA,KAAcA,EAAY,IACnBD,EAAME,OAAOL,GAAeE,KAAKE,GAE1C,QAASE,KACP,IAAK,GAAIC,GAAOC,UAAUC,OAAQC,EAAOC,MAAMJ,GAAOK,EAAO,EAAUL,EAAPK,EAAaA,IAC3EF,EAAKE,GAAQJ,UAAUI,EAGzB,IAAIC,GAASX,EAAKQ,EAAM,IACxB,OAAOG,GAAOC,QAAQ,oBAAqB,OAK7C,QAASC,GAAQC,GACfC,EAAMC,KAAKF,GA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SAoB7E,IAAIQ,IACJC,KAAM,EACNC,KAAM,eACNC,MAAO,EACPC,MAAO,EACPC,MAAO,EAGPnU,GAAQkD,oBAAsBA,EAC9BlD,EAAQ8T,QAAUA,EAClB9T,EAAiB,QAAIkD","file":"dist/js-data-localstorage.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index 6a81b89..3e9ce94 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "babel-polyfill": "6.7.4", "babel-preset-es2015-rollup": "1.1.1", "js-data-adapter": "~0.6.1", - "js-data-adapter-tests": "^2.0.0-alpha.16", + "js-data-adapter-tests": "^2.0.0-alpha.17", "js-data-repo-tools": "0.5.0", "karma": "0.13.22", "karma-browserstack-launcher": "0.1.11", diff --git a/src/index.js b/src/index.js index 0f2c1cd..44be57e 100644 --- a/src/index.js +++ b/src/index.js @@ -1,31 +1,5 @@ /* global: localStorage */ -/** - * Registered as `js-data-localstorage` in NPM and Bower. - * - * @example Script tag - * var LocalStorageAdapter = window.JSDataLocalStorage.LocalStorageAdapter - * var adapter = new LocalStorageAdapter() - * - * @example CommonJS - * var LocalStorageAdapter = require('js-data-localstorage').LocalStorageAdapter - * var adapter = new LocalStorageAdapter() - * - * @example ES6 Modules - * import {LocalStorageAdapter} from 'js-data-localstorage' - * const adapter = new LocalStorageAdapter() - * - * @example AMD - * define('myApp', ['js-data-localstorage'], function (JSDataLocalStorage) { - * var LocalStorageAdapter = JSDataLocalStorage.LocalStorageAdapter - * var adapter = new LocalStorageAdapter() - * - * // ... - * }) - * - * @module js-data-localstorage - */ - import {Query, utils} from 'js-data' import {Adapter} from '../node_modules/js-data-adapter/src/index' @@ -44,15 +18,6 @@ const DEFAULTS = { */ basePath: '', - /** - * TODO - * - * @name LocalStorageAdapter#debug - * @type {boolean} - * @default false - */ - debug: false, - /** * TODO * @@ -118,6 +83,13 @@ function createTask (fn) { * @see LocalStorageAdapter */ +/** + * {@link LocalStorageAdapter} class. ES2015 default import. + * + * @name module:js-data-localstorage.default + * @see LocalStorageAdapter + */ + /** * LocalStorageAdapter class. * @@ -129,6 +101,7 @@ function createTask (fn) { * store.registerAdapter('ls', adapter, { 'default': true }) * * @class LocalStorageAdapter + * @alias LocalStorageAdapter * @extends Adapter * @param {Object} [opts] Configuration options. * @param {string} [opts.basePath=''] See {@link LocalStorageAdapter#basePath}. @@ -656,4 +629,30 @@ utils.addHiddenPropsToTarget(LocalStorageAdapter.prototype, { */ export const version = '<%= version %>' +/** + * Registered as `js-data-localstorage` in NPM and Bower. + * + * @example Script tag + * var LocalStorageAdapter = window.JSDataLocalStorage.LocalStorageAdapter + * var adapter = new LocalStorageAdapter() + * + * @example CommonJS + * var LocalStorageAdapter = require('js-data-localstorage').LocalStorageAdapter + * var adapter = new LocalStorageAdapter() + * + * @example ES2015 Modules + * import {LocalStorageAdapter} from 'js-data-localstorage' + * const adapter = new LocalStorageAdapter() + * + * @example AMD + * define('myApp', ['js-data-localstorage'], function (JSDataLocalStorage) { + * var LocalStorageAdapter = JSDataLocalStorage.LocalStorageAdapter + * var adapter = new LocalStorageAdapter() + * + * // ... + * }) + * + * @module js-data-localstorage + */ + export default LocalStorageAdapter