@feathersjs/client 4.5.9 → 4.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -8,102 +8,16 @@
8
8
  else
9
9
  root["feathers"] = factory();
10
10
  })(this, function() {
11
- return /******/ (function(modules) { // webpackBootstrap
12
- /******/ // The module cache
13
- /******/ var installedModules = {};
14
- /******/
15
- /******/ // The require function
16
- /******/ function __webpack_require__(moduleId) {
17
- /******/
18
- /******/ // Check if module is in cache
19
- /******/ if(installedModules[moduleId]) {
20
- /******/ return installedModules[moduleId].exports;
21
- /******/ }
22
- /******/ // Create a new module (and put it into the cache)
23
- /******/ var module = installedModules[moduleId] = {
24
- /******/ i: moduleId,
25
- /******/ l: false,
26
- /******/ exports: {}
27
- /******/ };
28
- /******/
29
- /******/ // Execute the module function
30
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
- /******/
32
- /******/ // Flag the module as loaded
33
- /******/ module.l = true;
34
- /******/
35
- /******/ // Return the exports of the module
36
- /******/ return module.exports;
37
- /******/ }
38
- /******/
39
- /******/
40
- /******/ // expose the modules object (__webpack_modules__)
41
- /******/ __webpack_require__.m = modules;
42
- /******/
43
- /******/ // expose the module cache
44
- /******/ __webpack_require__.c = installedModules;
45
- /******/
46
- /******/ // define getter function for harmony exports
47
- /******/ __webpack_require__.d = function(exports, name, getter) {
48
- /******/ if(!__webpack_require__.o(exports, name)) {
49
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
- /******/ }
51
- /******/ };
52
- /******/
53
- /******/ // define __esModule on exports
54
- /******/ __webpack_require__.r = function(exports) {
55
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
- /******/ }
58
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
59
- /******/ };
60
- /******/
61
- /******/ // create a fake namespace object
62
- /******/ // mode & 1: value is a module id, require it
63
- /******/ // mode & 2: merge all properties of value into the ns
64
- /******/ // mode & 4: return value when already ns object
65
- /******/ // mode & 8|1: behave like require
66
- /******/ __webpack_require__.t = function(value, mode) {
67
- /******/ if(mode & 1) value = __webpack_require__(value);
68
- /******/ if(mode & 8) return value;
69
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
- /******/ var ns = Object.create(null);
71
- /******/ __webpack_require__.r(ns);
72
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
- /******/ return ns;
75
- /******/ };
76
- /******/
77
- /******/ // getDefaultExport function for compatibility with non-harmony modules
78
- /******/ __webpack_require__.n = function(module) {
79
- /******/ var getter = module && module.__esModule ?
80
- /******/ function getDefault() { return module['default']; } :
81
- /******/ function getModuleExports() { return module; };
82
- /******/ __webpack_require__.d(getter, 'a', getter);
83
- /******/ return getter;
84
- /******/ };
85
- /******/
86
- /******/ // Object.prototype.hasOwnProperty.call
87
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
- /******/
89
- /******/ // __webpack_public_path__
90
- /******/ __webpack_require__.p = "";
91
- /******/
92
- /******/
93
- /******/ // Load entry module and return exports
94
- /******/ return __webpack_require__(__webpack_require__.s = "./src/core.js");
95
- /******/ })
96
- /************************************************************************/
97
- /******/ ({
11
+ return /******/ (function() { // webpackBootstrap
12
+ /******/ var __webpack_modules__ = ({
98
13
 
99
14
  /***/ "../../node_modules/debug/src/browser.js":
100
- /*!**************************************************************************************!*\
101
- !*** /Users/daffl/Development/feathersjs/feathers/node_modules/debug/src/browser.js ***!
102
- \**************************************************************************************/
103
- /*! no static exports found */
15
+ /*!***********************************************!*\
16
+ !*** ../../node_modules/debug/src/browser.js ***!
17
+ \***********************************************/
104
18
  /***/ (function(module, exports, __webpack_require__) {
105
19
 
106
- /* WEBPACK VAR INJECTION */(function(process) {/* eslint-env browser */
20
+ /* eslint-env browser */
107
21
 
108
22
  /**
109
23
  * This is the web browser implementation of `debug()`.
@@ -113,10 +27,21 @@ exports.save = save;
113
27
  exports.load = load;
114
28
  exports.useColors = useColors;
115
29
  exports.storage = localstorage();
30
+
31
+ exports.destroy = function () {
32
+ var warned = false;
33
+ return function () {
34
+ if (!warned) {
35
+ warned = true;
36
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
37
+ }
38
+ };
39
+ }();
116
40
  /**
117
41
  * Colors.
118
42
  */
119
43
 
44
+
120
45
  exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
121
46
  /**
122
47
  * Currently only WebKit-based Web Inspectors, Firefox >= v31,
@@ -273,16 +198,14 @@ formatters.j = function (v) {
273
198
  return '[UnexpectedJSONParseError]: ' + error.message;
274
199
  }
275
200
  };
276
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "../../node_modules/process/browser.js")))
277
201
 
278
202
  /***/ }),
279
203
 
280
204
  /***/ "../../node_modules/debug/src/common.js":
281
- /*!*************************************************************************************!*\
282
- !*** /Users/daffl/Development/feathersjs/feathers/node_modules/debug/src/common.js ***!
283
- \*************************************************************************************/
284
- /*! no static exports found */
285
- /***/ (function(module, exports, __webpack_require__) {
205
+ /*!**********************************************!*\
206
+ !*** ../../node_modules/debug/src/common.js ***!
207
+ \**********************************************/
208
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
286
209
 
287
210
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
288
211
 
@@ -290,7 +213,7 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
290
213
 
291
214
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
292
215
 
293
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
216
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
294
217
 
295
218
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
296
219
 
@@ -308,15 +231,11 @@ function setup(env) {
308
231
  createDebug.enable = enable;
309
232
  createDebug.enabled = enabled;
310
233
  createDebug.humanize = __webpack_require__(/*! ms */ "../../node_modules/ms/index.js");
234
+ createDebug.destroy = destroy;
311
235
  Object.keys(env).forEach(function (key) {
312
236
  createDebug[key] = env[key];
313
237
  });
314
238
  /**
315
- * Active `debug` instances.
316
- */
317
-
318
- createDebug.instances = [];
319
- /**
320
239
  * The currently active debug mode names, and names to skip.
321
240
  */
322
241
 
@@ -331,7 +250,7 @@ function setup(env) {
331
250
  createDebug.formatters = {};
332
251
  /**
333
252
  * Selects a color for a debug namespace
334
- * @param {String} namespace The namespace string for the for the debug instance to be colored
253
+ * @param {String} namespace The namespace string for the debug instance to be colored
335
254
  * @return {Number|String} An ANSI color code for the given namespace
336
255
  * @api private
337
256
  */
@@ -358,6 +277,9 @@ function setup(env) {
358
277
 
359
278
  function createDebug(namespace) {
360
279
  var prevTime;
280
+ var enableOverride = null;
281
+ var namespacesCache;
282
+ var enabledCache;
361
283
 
362
284
  function debug() {
363
285
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -389,7 +311,7 @@ function setup(env) {
389
311
  args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
390
312
  // If we encounter an escaped % then don't increase the array index
391
313
  if (match === '%%') {
392
- return match;
314
+ return '%';
393
315
  }
394
316
 
395
317
  index++;
@@ -412,31 +334,38 @@ function setup(env) {
412
334
  }
413
335
 
414
336
  debug.namespace = namespace;
415
- debug.enabled = createDebug.enabled(namespace);
416
337
  debug.useColors = createDebug.useColors();
417
338
  debug.color = createDebug.selectColor(namespace);
418
- debug.destroy = destroy;
419
- debug.extend = extend; // Env-specific initialization logic for debug instances
339
+ debug.extend = extend;
340
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
341
+
342
+ Object.defineProperty(debug, 'enabled', {
343
+ enumerable: true,
344
+ configurable: false,
345
+ get: function get() {
346
+ if (enableOverride !== null) {
347
+ return enableOverride;
348
+ }
349
+
350
+ if (namespacesCache !== createDebug.namespaces) {
351
+ namespacesCache = createDebug.namespaces;
352
+ enabledCache = createDebug.enabled(namespace);
353
+ }
354
+
355
+ return enabledCache;
356
+ },
357
+ set: function set(v) {
358
+ enableOverride = v;
359
+ }
360
+ }); // Env-specific initialization logic for debug instances
420
361
 
421
362
  if (typeof createDebug.init === 'function') {
422
363
  createDebug.init(debug);
423
364
  }
424
365
 
425
- createDebug.instances.push(debug);
426
366
  return debug;
427
367
  }
428
368
 
429
- function destroy() {
430
- var index = createDebug.instances.indexOf(this);
431
-
432
- if (index !== -1) {
433
- createDebug.instances.splice(index, 1);
434
- return true;
435
- }
436
-
437
- return false;
438
- }
439
-
440
369
  function extend(namespace, delimiter) {
441
370
  var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
442
371
  newDebug.log = this.log;
@@ -453,6 +382,7 @@ function setup(env) {
453
382
 
454
383
  function enable(namespaces) {
455
384
  createDebug.save(namespaces);
385
+ createDebug.namespaces = namespaces;
456
386
  createDebug.names = [];
457
387
  createDebug.skips = [];
458
388
  var i;
@@ -473,11 +403,6 @@ function setup(env) {
473
403
  createDebug.names.push(new RegExp('^' + namespaces + '$'));
474
404
  }
475
405
  }
476
-
477
- for (i = 0; i < createDebug.instances.length; i++) {
478
- var instance = createDebug.instances[i];
479
- instance.enabled = createDebug.enabled(instance.namespace);
480
- }
481
406
  }
482
407
  /**
483
408
  * Disable debug output.
@@ -553,6 +478,15 @@ function setup(env) {
553
478
 
554
479
  return val;
555
480
  }
481
+ /**
482
+ * XXX DO NOT USE. This is a temporary stub function.
483
+ * XXX It WILL be removed in the next major release.
484
+ */
485
+
486
+
487
+ function destroy() {
488
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
489
+ }
556
490
 
557
491
  createDebug.enable(createDebug.load());
558
492
  return createDebug;
@@ -562,2040 +496,1887 @@ module.exports = setup;
562
496
 
563
497
  /***/ }),
564
498
 
565
- /***/ "../../node_modules/events/events.js":
566
- /*!**********************************************************************************!*\
567
- !*** /Users/daffl/Development/feathersjs/feathers/node_modules/events/events.js ***!
568
- \**********************************************************************************/
569
- /*! no static exports found */
570
- /***/ (function(module, exports, __webpack_require__) {
499
+ /***/ "./src/core.js":
500
+ /*!*********************!*\
501
+ !*** ./src/core.js ***!
502
+ \*********************/
503
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
571
504
 
572
- "use strict";
573
- // Copyright Joyent, Inc. and other Node contributors.
574
- //
575
- // Permission is hereby granted, free of charge, to any person obtaining a
576
- // copy of this software and associated documentation files (the
577
- // "Software"), to deal in the Software without restriction, including
578
- // without limitation the rights to use, copy, modify, merge, publish,
579
- // distribute, sublicense, and/or sell copies of the Software, and to permit
580
- // persons to whom the Software is furnished to do so, subject to the
581
- // following conditions:
582
- //
583
- // The above copyright notice and this permission notice shall be included
584
- // in all copies or substantial portions of the Software.
585
- //
586
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
587
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
588
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
589
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
590
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
591
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
592
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
505
+ module.exports = __webpack_require__(/*! @feathersjs/feathers */ "../feathers/lib/index.js");
593
506
 
507
+ /***/ }),
594
508
 
509
+ /***/ "../commons/lib/hooks.js":
510
+ /*!*******************************!*\
511
+ !*** ../commons/lib/hooks.js ***!
512
+ \*******************************/
513
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
595
514
 
596
- var R = typeof Reflect === 'object' ? Reflect : null
597
- var ReflectApply = R && typeof R.apply === 'function'
598
- ? R.apply
599
- : function ReflectApply(target, receiver, args) {
600
- return Function.prototype.apply.call(target, receiver, args);
601
- }
515
+ "use strict";
602
516
 
603
- var ReflectOwnKeys
604
- if (R && typeof R.ownKeys === 'function') {
605
- ReflectOwnKeys = R.ownKeys
606
- } else if (Object.getOwnPropertySymbols) {
607
- ReflectOwnKeys = function ReflectOwnKeys(target) {
608
- return Object.getOwnPropertyNames(target)
609
- .concat(Object.getOwnPropertySymbols(target));
610
- };
611
- } else {
612
- ReflectOwnKeys = function ReflectOwnKeys(target) {
613
- return Object.getOwnPropertyNames(target);
614
- };
615
- }
616
517
 
617
- function ProcessEmitWarning(warning) {
618
- if (console && console.warn) console.warn(warning);
619
- }
518
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
620
519
 
621
- var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
622
- return value !== value;
623
- }
520
+ Object.defineProperty(exports, "__esModule", ({
521
+ value: true
522
+ }));
523
+ exports.enableHooks = exports.processHooks = exports.getHooks = exports.isHookObject = exports.convertHookData = exports.makeArguments = exports.defaultMakeArguments = exports.createHookObject = exports.ACTIVATE_HOOKS = void 0;
624
524
 
625
- function EventEmitter() {
626
- EventEmitter.init.call(this);
627
- }
628
- module.exports = EventEmitter;
629
- module.exports.once = once;
525
+ var utils_1 = __webpack_require__(/*! ./utils */ "../commons/lib/utils.js");
630
526
 
631
- // Backwards-compat with node 0.10.x
632
- EventEmitter.EventEmitter = EventEmitter;
527
+ var _utils_1$_ = utils_1._,
528
+ each = _utils_1$_.each,
529
+ pick = _utils_1$_.pick;
530
+ exports.ACTIVATE_HOOKS = (0, utils_1.createSymbol)('__feathersActivateHooks');
633
531
 
634
- EventEmitter.prototype._events = undefined;
635
- EventEmitter.prototype._eventsCount = 0;
636
- EventEmitter.prototype._maxListeners = undefined;
532
+ function createHookObject(method) {
533
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
534
+ var hook = {};
535
+ Object.defineProperty(hook, 'toJSON', {
536
+ value: function value() {
537
+ return pick(this, 'type', 'method', 'path', 'params', 'id', 'data', 'result', 'error');
538
+ }
539
+ });
540
+ return Object.assign(hook, data, {
541
+ method: method,
637
542
 
638
- // By default EventEmitters will print a warning if more than 10 listeners are
639
- // added to it. This is a useful default which helps finding memory leaks.
640
- var defaultMaxListeners = 10;
543
+ // A dynamic getter that returns the path of the service
544
+ get path() {
545
+ var app = data.app,
546
+ service = data.service;
641
547
 
642
- function checkListener(listener) {
643
- if (typeof listener !== 'function') {
644
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
645
- }
646
- }
548
+ if (!service || !app || !app.services) {
549
+ return null;
550
+ }
647
551
 
648
- Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
649
- enumerable: true,
650
- get: function() {
651
- return defaultMaxListeners;
652
- },
653
- set: function(arg) {
654
- if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
655
- throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
552
+ return Object.keys(app.services).find(function (path) {
553
+ return app.services[path] === service;
554
+ });
656
555
  }
657
- defaultMaxListeners = arg;
658
- }
659
- });
660
556
 
661
- EventEmitter.init = function() {
557
+ });
558
+ }
662
559
 
663
- if (this._events === undefined ||
664
- this._events === Object.getPrototypeOf(this)._events) {
665
- this._events = Object.create(null);
666
- this._eventsCount = 0;
667
- }
560
+ exports.createHookObject = createHookObject; // Fallback used by `makeArguments` which usually won't be used
668
561
 
669
- this._maxListeners = this._maxListeners || undefined;
670
- };
562
+ function defaultMakeArguments(hook) {
563
+ var result = [];
671
564
 
672
- // Obviously not all Emitters should be limited to 10. This function allows
673
- // that to be increased. Set to zero for unlimited.
674
- EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
675
- if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
676
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
565
+ if (typeof hook.id !== 'undefined') {
566
+ result.push(hook.id);
677
567
  }
678
- this._maxListeners = n;
679
- return this;
680
- };
681
568
 
682
- function _getMaxListeners(that) {
683
- if (that._maxListeners === undefined)
684
- return EventEmitter.defaultMaxListeners;
685
- return that._maxListeners;
569
+ if (hook.data) {
570
+ result.push(hook.data);
571
+ }
572
+
573
+ result.push(hook.params || {});
574
+ return result;
686
575
  }
687
576
 
688
- EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
689
- return _getMaxListeners(this);
690
- };
577
+ exports.defaultMakeArguments = defaultMakeArguments; // Turns a hook object back into a list of arguments
578
+ // to call a service method with
691
579
 
692
- EventEmitter.prototype.emit = function emit(type) {
693
- var args = [];
694
- for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
695
- var doError = (type === 'error');
580
+ function makeArguments(hook) {
581
+ switch (hook.method) {
582
+ case 'find':
583
+ return [hook.params];
696
584
 
697
- var events = this._events;
698
- if (events !== undefined)
699
- doError = (doError && events.error === undefined);
700
- else if (!doError)
701
- return false;
585
+ case 'get':
586
+ case 'remove':
587
+ return [hook.id, hook.params];
702
588
 
703
- // If there is no 'error' event listener then throw.
704
- if (doError) {
705
- var er;
706
- if (args.length > 0)
707
- er = args[0];
708
- if (er instanceof Error) {
709
- // Note: The comments on the `throw` lines are intentional, they show
710
- // up in Node's output if this results in an unhandled exception.
711
- throw er; // Unhandled 'error' event
712
- }
713
- // At least give some kind of context to the user
714
- var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
715
- err.context = er;
716
- throw err; // Unhandled 'error' event
717
- }
589
+ case 'update':
590
+ case 'patch':
591
+ return [hook.id, hook.data, hook.params];
718
592
 
719
- var handler = events[type];
593
+ case 'create':
594
+ return [hook.data, hook.params];
595
+ }
720
596
 
721
- if (handler === undefined)
722
- return false;
597
+ return defaultMakeArguments(hook);
598
+ }
723
599
 
724
- if (typeof handler === 'function') {
725
- ReflectApply(handler, this, args);
726
- } else {
727
- var len = handler.length;
728
- var listeners = arrayClone(handler, len);
729
- for (var i = 0; i < len; ++i)
730
- ReflectApply(listeners[i], this, args);
731
- }
600
+ exports.makeArguments = makeArguments; // Converts different hook registration formats into the
601
+ // same internal format
732
602
 
733
- return true;
734
- };
603
+ function convertHookData(obj) {
604
+ var hook = {};
735
605
 
736
- function _addListener(target, type, listener, prepend) {
737
- var m;
738
- var events;
739
- var existing;
740
-
741
- checkListener(listener);
742
-
743
- events = target._events;
744
- if (events === undefined) {
745
- events = target._events = Object.create(null);
746
- target._eventsCount = 0;
606
+ if (Array.isArray(obj)) {
607
+ hook = {
608
+ all: obj
609
+ };
610
+ } else if (_typeof(obj) !== 'object') {
611
+ hook = {
612
+ all: [obj]
613
+ };
747
614
  } else {
748
- // To avoid recursion in the case that type === "newListener"! Before
749
- // adding it to the listeners, first emit "newListener".
750
- if (events.newListener !== undefined) {
751
- target.emit('newListener', type,
752
- listener.listener ? listener.listener : listener);
753
-
754
- // Re-assign `events` because a newListener handler could have caused the
755
- // this._events to be assigned to a new object
756
- events = target._events;
757
- }
758
- existing = events[type];
615
+ each(obj, function (value, key) {
616
+ hook[key] = !Array.isArray(value) ? [value] : value;
617
+ });
759
618
  }
760
619
 
761
- if (existing === undefined) {
762
- // Optimize the case of one listener. Don't need the extra array object.
763
- existing = events[type] = listener;
764
- ++target._eventsCount;
765
- } else {
766
- if (typeof existing === 'function') {
767
- // Adding the second element, need to change to array.
768
- existing = events[type] =
769
- prepend ? [listener, existing] : [existing, listener];
770
- // If we've already got an array, just append.
771
- } else if (prepend) {
772
- existing.unshift(listener);
773
- } else {
774
- existing.push(listener);
775
- }
620
+ return hook;
621
+ }
776
622
 
777
- // Check for listener leak
778
- m = _getMaxListeners(target);
779
- if (m > 0 && existing.length > m && !existing.warned) {
780
- existing.warned = true;
781
- // No error code for this since it is a Warning
782
- // eslint-disable-next-line no-restricted-syntax
783
- var w = new Error('Possible EventEmitter memory leak detected. ' +
784
- existing.length + ' ' + String(type) + ' listeners ' +
785
- 'added. Use emitter.setMaxListeners() to ' +
786
- 'increase limit');
787
- w.name = 'MaxListenersExceededWarning';
788
- w.emitter = target;
789
- w.type = type;
790
- w.count = existing.length;
791
- ProcessEmitWarning(w);
792
- }
793
- }
623
+ exports.convertHookData = convertHookData; // Duck-checks a given object to be a hook object
624
+ // A valid hook object has `type` and `method`
794
625
 
795
- return target;
626
+ function isHookObject(hookObject) {
627
+ return _typeof(hookObject) === 'object' && typeof hookObject.method === 'string' && typeof hookObject.type === 'string';
796
628
  }
797
629
 
798
- EventEmitter.prototype.addListener = function addListener(type, listener) {
799
- return _addListener(this, type, listener, false);
800
- };
801
-
802
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
630
+ exports.isHookObject = isHookObject; // Returns all service and application hooks combined
631
+ // for a given method and type `appLast` sets if the hooks
632
+ // from `app` should be added last (or first by default)
803
633
 
804
- EventEmitter.prototype.prependListener =
805
- function prependListener(type, listener) {
806
- return _addListener(this, type, listener, true);
807
- };
634
+ function getHooks(app, service, type, method) {
635
+ var appLast = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
636
+ var appHooks = app.__hooks[type][method] || [];
637
+ var serviceHooks = service.__hooks[type][method] || [];
808
638
 
809
- function onceWrapper() {
810
- if (!this.fired) {
811
- this.target.removeListener(this.type, this.wrapFn);
812
- this.fired = true;
813
- if (arguments.length === 0)
814
- return this.listener.call(this.target);
815
- return this.listener.apply(this.target, arguments);
639
+ if (appLast) {
640
+ // Run hooks in the order of service -> app -> finally
641
+ return serviceHooks.concat(appHooks);
816
642
  }
817
- }
818
643
 
819
- function _onceWrap(target, type, listener) {
820
- var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
821
- var wrapped = onceWrapper.bind(state);
822
- wrapped.listener = listener;
823
- state.wrapFn = wrapped;
824
- return wrapped;
644
+ return appHooks.concat(serviceHooks);
825
645
  }
826
646
 
827
- EventEmitter.prototype.once = function once(type, listener) {
828
- checkListener(listener);
829
- this.on(type, _onceWrap(this, type, listener));
830
- return this;
831
- };
647
+ exports.getHooks = getHooks;
832
648
 
833
- EventEmitter.prototype.prependOnceListener =
834
- function prependOnceListener(type, listener) {
835
- checkListener(listener);
836
- this.prependListener(type, _onceWrap(this, type, listener));
837
- return this;
838
- };
649
+ function processHooks(hooks, initialHookObject) {
650
+ var _this = this;
839
651
 
840
- // Emits a 'removeListener' event if and only if the listener was removed.
841
- EventEmitter.prototype.removeListener =
842
- function removeListener(type, listener) {
843
- var list, events, position, i, originalListener;
652
+ var hookObject = initialHookObject;
844
653
 
845
- checkListener(listener);
654
+ var updateCurrentHook = function updateCurrentHook(current) {
655
+ // Either use the returned hook object or the current
656
+ // hook object from the chain if the hook returned undefined
657
+ if (current) {
658
+ if (!isHookObject(current)) {
659
+ throw new Error("".concat(hookObject.type, " hook for '").concat(hookObject.method, "' method returned invalid hook object"));
660
+ }
846
661
 
847
- events = this._events;
848
- if (events === undefined)
849
- return this;
662
+ hookObject = current;
663
+ }
850
664
 
851
- list = events[type];
852
- if (list === undefined)
853
- return this;
665
+ return hookObject;
666
+ }; // Go through all hooks and chain them into our promise
854
667
 
855
- if (list === listener || list.listener === listener) {
856
- if (--this._eventsCount === 0)
857
- this._events = Object.create(null);
858
- else {
859
- delete events[type];
860
- if (events.removeListener)
861
- this.emit('removeListener', type, list.listener || listener);
862
- }
863
- } else if (typeof list !== 'function') {
864
- position = -1;
865
668
 
866
- for (i = list.length - 1; i >= 0; i--) {
867
- if (list[i] === listener || list[i].listener === listener) {
868
- originalListener = list[i].listener;
869
- position = i;
870
- break;
871
- }
872
- }
669
+ var promise = hooks.reduce(function (current, fn) {
670
+ // @ts-ignore
671
+ var hook = fn.bind(_this); // Use the returned hook object or the old one
873
672
 
874
- if (position < 0)
875
- return this;
673
+ return current.then(function (currentHook) {
674
+ return hook(currentHook);
675
+ }).then(updateCurrentHook);
676
+ }, Promise.resolve(hookObject));
677
+ return promise.then(function () {
678
+ return hookObject;
679
+ }).catch(function (error) {
680
+ // Add the hook information to any errors
681
+ error.hook = hookObject;
682
+ throw error;
683
+ });
684
+ }
876
685
 
877
- if (position === 0)
878
- list.shift();
879
- else {
880
- spliceOne(list, position);
686
+ exports.processHooks = processHooks; // Add `.hooks` functionality to an object
687
+
688
+ function enableHooks(obj, methods, types) {
689
+ if (typeof obj.hooks === 'function') {
690
+ return obj;
691
+ }
692
+
693
+ var hookData = {};
694
+ types.forEach(function (type) {
695
+ // Initialize properties where hook functions are stored
696
+ hookData[type] = {};
697
+ }); // Add non-enumerable `__hooks` property to the object
698
+
699
+ Object.defineProperty(obj, '__hooks', {
700
+ configurable: true,
701
+ value: hookData,
702
+ writable: true
703
+ });
704
+ return Object.assign(obj, {
705
+ hooks: function hooks(allHooks) {
706
+ var _this2 = this;
707
+
708
+ each(allHooks, function (current, type) {
709
+ // @ts-ignore
710
+ if (!_this2.__hooks[type]) {
711
+ throw new Error("'".concat(type, "' is not a valid hook type"));
881
712
  }
882
713
 
883
- if (list.length === 1)
884
- events[type] = list[0];
714
+ var hooks = convertHookData(current);
715
+ each(hooks, function (_value, method) {
716
+ if (method !== 'all' && methods.indexOf(method) === -1) {
717
+ throw new Error("'".concat(method, "' is not a valid hook method"));
718
+ }
719
+ });
720
+ methods.forEach(function (method) {
721
+ // @ts-ignore
722
+ var myHooks = _this2.__hooks[type][method] || (_this2.__hooks[type][method] = []);
885
723
 
886
- if (events.removeListener !== undefined)
887
- this.emit('removeListener', type, originalListener || listener);
888
- }
724
+ if (hooks.all) {
725
+ myHooks.push.apply(myHooks, hooks.all);
726
+ }
889
727
 
728
+ if (hooks[method]) {
729
+ myHooks.push.apply(myHooks, hooks[method]);
730
+ }
731
+ });
732
+ });
890
733
  return this;
891
- };
734
+ }
735
+ });
736
+ }
892
737
 
893
- EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
738
+ exports.enableHooks = enableHooks;
894
739
 
895
- EventEmitter.prototype.removeAllListeners =
896
- function removeAllListeners(type) {
897
- var listeners, events, i;
740
+ /***/ }),
898
741
 
899
- events = this._events;
900
- if (events === undefined)
901
- return this;
742
+ /***/ "../commons/lib/index.js":
743
+ /*!*******************************!*\
744
+ !*** ../commons/lib/index.js ***!
745
+ \*******************************/
746
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
902
747
 
903
- // not listening for removeListener, no need to emit
904
- if (events.removeListener === undefined) {
905
- if (arguments.length === 0) {
906
- this._events = Object.create(null);
907
- this._eventsCount = 0;
908
- } else if (events[type] !== undefined) {
909
- if (--this._eventsCount === 0)
910
- this._events = Object.create(null);
911
- else
912
- delete events[type];
913
- }
914
- return this;
915
- }
748
+ "use strict";
916
749
 
917
- // emit removeListener for all listeners on all events
918
- if (arguments.length === 0) {
919
- var keys = Object.keys(events);
920
- var key;
921
- for (i = 0; i < keys.length; ++i) {
922
- key = keys[i];
923
- if (key === 'removeListener') continue;
924
- this.removeAllListeners(key);
925
- }
926
- this.removeAllListeners('removeListener');
927
- this._events = Object.create(null);
928
- this._eventsCount = 0;
929
- return this;
930
- }
931
750
 
932
- listeners = events[type];
751
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
752
+ if (k2 === undefined) k2 = k;
753
+ Object.defineProperty(o, k2, {
754
+ enumerable: true,
755
+ get: function get() {
756
+ return m[k];
757
+ }
758
+ });
759
+ } : function (o, m, k, k2) {
760
+ if (k2 === undefined) k2 = k;
761
+ o[k2] = m[k];
762
+ });
933
763
 
934
- if (typeof listeners === 'function') {
935
- this.removeListener(type, listeners);
936
- } else if (listeners !== undefined) {
937
- // LIFO order
938
- for (i = listeners.length - 1; i >= 0; i--) {
939
- this.removeListener(type, listeners[i]);
940
- }
941
- }
764
+ var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
765
+ Object.defineProperty(o, "default", {
766
+ enumerable: true,
767
+ value: v
768
+ });
769
+ } : function (o, v) {
770
+ o["default"] = v;
771
+ });
942
772
 
943
- return this;
944
- };
773
+ var __importStar = this && this.__importStar || function (mod) {
774
+ if (mod && mod.__esModule) return mod;
775
+ var result = {};
776
+ if (mod != null) for (var k in mod) {
777
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
778
+ }
945
779
 
946
- function _listeners(target, type, unwrap) {
947
- var events = target._events;
780
+ __setModuleDefault(result, mod);
948
781
 
949
- if (events === undefined)
950
- return [];
782
+ return result;
783
+ };
951
784
 
952
- var evlistener = events[type];
953
- if (evlistener === undefined)
954
- return [];
785
+ var __exportStar = this && this.__exportStar || function (m, exports) {
786
+ for (var p in m) {
787
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
788
+ }
789
+ };
955
790
 
956
- if (typeof evlistener === 'function')
957
- return unwrap ? [evlistener.listener || evlistener] : [evlistener];
791
+ Object.defineProperty(exports, "__esModule", ({
792
+ value: true
793
+ }));
794
+ exports.hooks = void 0;
958
795
 
959
- return unwrap ?
960
- unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
961
- }
796
+ var hookUtils = __importStar(__webpack_require__(/*! ./hooks */ "../commons/lib/hooks.js"));
962
797
 
963
- EventEmitter.prototype.listeners = function listeners(type) {
964
- return _listeners(this, type, true);
965
- };
798
+ __exportStar(__webpack_require__(/*! ./utils */ "../commons/lib/utils.js"), exports);
966
799
 
967
- EventEmitter.prototype.rawListeners = function rawListeners(type) {
968
- return _listeners(this, type, false);
969
- };
800
+ exports.hooks = hookUtils;
970
801
 
971
- EventEmitter.listenerCount = function(emitter, type) {
972
- if (typeof emitter.listenerCount === 'function') {
973
- return emitter.listenerCount(type);
974
- } else {
975
- return listenerCount.call(emitter, type);
976
- }
977
- };
802
+ /***/ }),
978
803
 
979
- EventEmitter.prototype.listenerCount = listenerCount;
980
- function listenerCount(type) {
981
- var events = this._events;
804
+ /***/ "../commons/lib/utils.js":
805
+ /*!*******************************!*\
806
+ !*** ../commons/lib/utils.js ***!
807
+ \*******************************/
808
+ /***/ (function(__unused_webpack_module, exports) {
982
809
 
983
- if (events !== undefined) {
984
- var evlistener = events[type];
810
+ "use strict";
985
811
 
986
- if (typeof evlistener === 'function') {
987
- return 1;
988
- } else if (evlistener !== undefined) {
989
- return evlistener.length;
990
- }
991
- }
992
812
 
993
- return 0;
994
- }
813
+ 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; }
995
814
 
996
- EventEmitter.prototype.eventNames = function eventNames() {
997
- return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
998
- };
815
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
999
816
 
1000
- function arrayClone(arr, n) {
1001
- var copy = new Array(n);
1002
- for (var i = 0; i < n; ++i)
1003
- copy[i] = arr[i];
1004
- return copy;
1005
- }
817
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
1006
818
 
1007
- function spliceOne(list, index) {
1008
- for (; index + 1 < list.length; index++)
1009
- list[index] = list[index + 1];
1010
- list.pop();
1011
- }
819
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1012
820
 
1013
- function unwrapListeners(arr) {
1014
- var ret = new Array(arr.length);
1015
- for (var i = 0; i < ret.length; ++i) {
1016
- ret[i] = arr[i].listener || arr[i];
1017
- }
1018
- return ret;
1019
- }
821
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1020
822
 
1021
- function once(emitter, name) {
1022
- return new Promise(function (resolve, reject) {
1023
- function eventListener() {
1024
- if (errorListener !== undefined) {
1025
- emitter.removeListener('error', errorListener);
1026
- }
1027
- resolve([].slice.call(arguments));
1028
- };
1029
- var errorListener;
1030
-
1031
- // Adding an error listener is not optional because
1032
- // if an error is thrown on an event emitter we cannot
1033
- // guarantee that the actual event we are waiting will
1034
- // be fired. The result could be a silent way to create
1035
- // memory or file descriptor leaks, which is something
1036
- // we should avoid.
1037
- if (name !== 'error') {
1038
- errorListener = function errorListener(err) {
1039
- emitter.removeListener(name, eventListener);
1040
- reject(err);
1041
- };
823
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1042
824
 
1043
- emitter.once('error', errorListener);
1044
- }
825
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
1045
826
 
1046
- emitter.once(name, eventListener);
1047
- });
1048
- }
827
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1049
828
 
829
+ Object.defineProperty(exports, "__esModule", ({
830
+ value: true
831
+ }));
832
+ exports.createSymbol = exports.makeUrl = exports.isPromise = exports._ = exports.stripSlashes = void 0; // Removes all leading and trailing slashes from a path
1050
833
 
1051
- /***/ }),
834
+ function stripSlashes(name) {
835
+ return name.replace(/^(\/+)|(\/+)$/g, '');
836
+ }
1052
837
 
1053
- /***/ "../../node_modules/ms/index.js":
1054
- /*!*****************************************************************************!*\
1055
- !*** /Users/daffl/Development/feathersjs/feathers/node_modules/ms/index.js ***!
1056
- \*****************************************************************************/
1057
- /*! no static exports found */
1058
- /***/ (function(module, exports) {
838
+ exports.stripSlashes = stripSlashes; // A set of lodash-y utility functions that use ES6
1059
839
 
1060
- /**
1061
- * Helpers.
1062
- */
840
+ exports._ = {
841
+ each: function each(obj, callback) {
842
+ if (obj && typeof obj.forEach === 'function') {
843
+ obj.forEach(callback);
844
+ } else if (exports._.isObject(obj)) {
845
+ Object.keys(obj).forEach(function (key) {
846
+ return callback(obj[key], key);
847
+ });
848
+ }
849
+ },
850
+ some: function some(value, callback) {
851
+ return Object.keys(value).map(function (key) {
852
+ return [value[key], key];
853
+ }).some(function (_ref) {
854
+ var _ref2 = _slicedToArray(_ref, 2),
855
+ val = _ref2[0],
856
+ key = _ref2[1];
1063
857
 
1064
- var s = 1000;
1065
- var m = s * 60;
1066
- var h = m * 60;
1067
- var d = h * 24;
1068
- var w = d * 7;
1069
- var y = d * 365.25;
858
+ return callback(val, key);
859
+ });
860
+ },
861
+ every: function every(value, callback) {
862
+ return Object.keys(value).map(function (key) {
863
+ return [value[key], key];
864
+ }).every(function (_ref3) {
865
+ var _ref4 = _slicedToArray(_ref3, 2),
866
+ val = _ref4[0],
867
+ key = _ref4[1];
1070
868
 
1071
- /**
1072
- * Parse or format the given `val`.
1073
- *
1074
- * Options:
1075
- *
1076
- * - `long` verbose formatting [false]
1077
- *
1078
- * @param {String|Number} val
1079
- * @param {Object} [options]
1080
- * @throws {Error} throw an error if val is not a non-empty string or a number
1081
- * @return {String|Number}
1082
- * @api public
1083
- */
869
+ return callback(val, key);
870
+ });
871
+ },
872
+ keys: function keys(obj) {
873
+ return Object.keys(obj);
874
+ },
875
+ values: function values(obj) {
876
+ return exports._.keys(obj).map(function (key) {
877
+ return obj[key];
878
+ });
879
+ },
880
+ isMatch: function isMatch(obj, item) {
881
+ return exports._.keys(item).every(function (key) {
882
+ return obj[key] === item[key];
883
+ });
884
+ },
885
+ isEmpty: function isEmpty(obj) {
886
+ return exports._.keys(obj).length === 0;
887
+ },
888
+ isObject: function isObject(item) {
889
+ return _typeof(item) === 'object' && !Array.isArray(item) && item !== null;
890
+ },
891
+ isObjectOrArray: function isObjectOrArray(value) {
892
+ return _typeof(value) === 'object' && value !== null;
893
+ },
894
+ extend: function extend(first) {
895
+ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
896
+ rest[_key - 1] = arguments[_key];
897
+ }
1084
898
 
1085
- module.exports = function(val, options) {
1086
- options = options || {};
1087
- var type = typeof val;
1088
- if (type === 'string' && val.length > 0) {
1089
- return parse(val);
1090
- } else if (type === 'number' && isFinite(val)) {
1091
- return options.long ? fmtLong(val) : fmtShort(val);
1092
- }
1093
- throw new Error(
1094
- 'val is not a non-empty string or a valid number. val=' +
1095
- JSON.stringify(val)
1096
- );
1097
- };
899
+ return Object.assign.apply(Object, [first].concat(rest));
900
+ },
901
+ omit: function omit(obj) {
902
+ var result = exports._.extend({}, obj);
1098
903
 
1099
- /**
1100
- * Parse the given `str` and return milliseconds.
1101
- *
1102
- * @param {String} str
1103
- * @return {Number}
1104
- * @api private
1105
- */
1106
-
1107
- function parse(str) {
1108
- str = String(str);
1109
- if (str.length > 100) {
1110
- return;
1111
- }
1112
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
1113
- str
1114
- );
1115
- if (!match) {
1116
- return;
1117
- }
1118
- var n = parseFloat(match[1]);
1119
- var type = (match[2] || 'ms').toLowerCase();
1120
- switch (type) {
1121
- case 'years':
1122
- case 'year':
1123
- case 'yrs':
1124
- case 'yr':
1125
- case 'y':
1126
- return n * y;
1127
- case 'weeks':
1128
- case 'week':
1129
- case 'w':
1130
- return n * w;
1131
- case 'days':
1132
- case 'day':
1133
- case 'd':
1134
- return n * d;
1135
- case 'hours':
1136
- case 'hour':
1137
- case 'hrs':
1138
- case 'hr':
1139
- case 'h':
1140
- return n * h;
1141
- case 'minutes':
1142
- case 'minute':
1143
- case 'mins':
1144
- case 'min':
1145
- case 'm':
1146
- return n * m;
1147
- case 'seconds':
1148
- case 'second':
1149
- case 'secs':
1150
- case 'sec':
1151
- case 's':
1152
- return n * s;
1153
- case 'milliseconds':
1154
- case 'millisecond':
1155
- case 'msecs':
1156
- case 'msec':
1157
- case 'ms':
1158
- return n;
1159
- default:
1160
- return undefined;
1161
- }
1162
- }
1163
-
1164
- /**
1165
- * Short format for `ms`.
1166
- *
1167
- * @param {Number} ms
1168
- * @return {String}
1169
- * @api private
1170
- */
1171
-
1172
- function fmtShort(ms) {
1173
- var msAbs = Math.abs(ms);
1174
- if (msAbs >= d) {
1175
- return Math.round(ms / d) + 'd';
1176
- }
1177
- if (msAbs >= h) {
1178
- return Math.round(ms / h) + 'h';
1179
- }
1180
- if (msAbs >= m) {
1181
- return Math.round(ms / m) + 'm';
1182
- }
1183
- if (msAbs >= s) {
1184
- return Math.round(ms / s) + 's';
1185
- }
1186
- return ms + 'ms';
1187
- }
1188
-
1189
- /**
1190
- * Long format for `ms`.
1191
- *
1192
- * @param {Number} ms
1193
- * @return {String}
1194
- * @api private
1195
- */
1196
-
1197
- function fmtLong(ms) {
1198
- var msAbs = Math.abs(ms);
1199
- if (msAbs >= d) {
1200
- return plural(ms, msAbs, d, 'day');
1201
- }
1202
- if (msAbs >= h) {
1203
- return plural(ms, msAbs, h, 'hour');
1204
- }
1205
- if (msAbs >= m) {
1206
- return plural(ms, msAbs, m, 'minute');
1207
- }
1208
- if (msAbs >= s) {
1209
- return plural(ms, msAbs, s, 'second');
1210
- }
1211
- return ms + ' ms';
1212
- }
1213
-
1214
- /**
1215
- * Pluralization helper.
1216
- */
1217
-
1218
- function plural(ms, msAbs, n, name) {
1219
- var isPlural = msAbs >= n * 1.5;
1220
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
1221
- }
1222
-
1223
-
1224
- /***/ }),
1225
-
1226
- /***/ "../../node_modules/process/browser.js":
1227
- /*!************************************************************************************!*\
1228
- !*** /Users/daffl/Development/feathersjs/feathers/node_modules/process/browser.js ***!
1229
- \************************************************************************************/
1230
- /*! no static exports found */
1231
- /***/ (function(module, exports) {
904
+ for (var _len2 = arguments.length, keys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
905
+ keys[_key2 - 1] = arguments[_key2];
906
+ }
1232
907
 
1233
- // shim for using process in browser
1234
- var process = module.exports = {};
908
+ keys.forEach(function (key) {
909
+ return delete result[key];
910
+ });
911
+ return result;
912
+ },
913
+ pick: function pick(source) {
914
+ for (var _len3 = arguments.length, keys = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
915
+ keys[_key3 - 1] = arguments[_key3];
916
+ }
1235
917
 
1236
- // cached from whatever global is present so that test runners that stub it
1237
- // don't break things. But we need to wrap it in a try catch in case it is
1238
- // wrapped in strict mode code which doesn't define any globals. It's inside a
1239
- // function because try/catches deoptimize in certain engines.
918
+ return keys.reduce(function (result, key) {
919
+ if (source[key] !== undefined) {
920
+ result[key] = source[key];
921
+ }
1240
922
 
1241
- var cachedSetTimeout;
1242
- var cachedClearTimeout;
923
+ return result;
924
+ }, {});
925
+ },
926
+ // Recursively merge the source object into the target object
927
+ merge: function merge(target, source) {
928
+ if (exports._.isObject(target) && exports._.isObject(source)) {
929
+ Object.keys(source).forEach(function (key) {
930
+ if (exports._.isObject(source[key])) {
931
+ if (!target[key]) {
932
+ Object.assign(target, _defineProperty({}, key, {}));
933
+ }
1243
934
 
1244
- function defaultSetTimout() {
1245
- throw new Error('setTimeout has not been defined');
1246
- }
1247
- function defaultClearTimeout () {
1248
- throw new Error('clearTimeout has not been defined');
1249
- }
1250
- (function () {
1251
- try {
1252
- if (typeof setTimeout === 'function') {
1253
- cachedSetTimeout = setTimeout;
1254
- } else {
1255
- cachedSetTimeout = defaultSetTimout;
1256
- }
1257
- } catch (e) {
1258
- cachedSetTimeout = defaultSetTimout;
1259
- }
1260
- try {
1261
- if (typeof clearTimeout === 'function') {
1262
- cachedClearTimeout = clearTimeout;
935
+ exports._.merge(target[key], source[key]);
1263
936
  } else {
1264
- cachedClearTimeout = defaultClearTimeout;
1265
- }
1266
- } catch (e) {
1267
- cachedClearTimeout = defaultClearTimeout;
1268
- }
1269
- } ())
1270
- function runTimeout(fun) {
1271
- if (cachedSetTimeout === setTimeout) {
1272
- //normal enviroments in sane situations
1273
- return setTimeout(fun, 0);
1274
- }
1275
- // if setTimeout wasn't available but was latter defined
1276
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1277
- cachedSetTimeout = setTimeout;
1278
- return setTimeout(fun, 0);
1279
- }
1280
- try {
1281
- // when when somebody has screwed with setTimeout but no I.E. maddness
1282
- return cachedSetTimeout(fun, 0);
1283
- } catch(e){
1284
- try {
1285
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1286
- return cachedSetTimeout.call(null, fun, 0);
1287
- } catch(e){
1288
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
1289
- return cachedSetTimeout.call(this, fun, 0);
1290
- }
1291
- }
1292
-
1293
-
1294
- }
1295
- function runClearTimeout(marker) {
1296
- if (cachedClearTimeout === clearTimeout) {
1297
- //normal enviroments in sane situations
1298
- return clearTimeout(marker);
1299
- }
1300
- // if clearTimeout wasn't available but was latter defined
1301
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1302
- cachedClearTimeout = clearTimeout;
1303
- return clearTimeout(marker);
1304
- }
1305
- try {
1306
- // when when somebody has screwed with setTimeout but no I.E. maddness
1307
- return cachedClearTimeout(marker);
1308
- } catch (e){
1309
- try {
1310
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1311
- return cachedClearTimeout.call(null, marker);
1312
- } catch (e){
1313
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
1314
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
1315
- return cachedClearTimeout.call(this, marker);
937
+ Object.assign(target, _defineProperty({}, key, source[key]));
1316
938
  }
939
+ });
1317
940
  }
1318
941
 
942
+ return target;
943
+ }
944
+ }; // Duck-checks if an object looks like a promise
1319
945
 
1320
-
946
+ function isPromise(result) {
947
+ return exports._.isObject(result) && typeof result.then === 'function';
1321
948
  }
1322
- var queue = [];
1323
- var draining = false;
1324
- var currentQueue;
1325
- var queueIndex = -1;
1326
949
 
1327
- function cleanUpNextTick() {
1328
- if (!draining || !currentQueue) {
1329
- return;
1330
- }
1331
- draining = false;
1332
- if (currentQueue.length) {
1333
- queue = currentQueue.concat(queue);
1334
- } else {
1335
- queueIndex = -1;
1336
- }
1337
- if (queue.length) {
1338
- drainQueue();
1339
- }
1340
- }
950
+ exports.isPromise = isPromise;
1341
951
 
1342
- function drainQueue() {
1343
- if (draining) {
1344
- return;
1345
- }
1346
- var timeout = runTimeout(cleanUpNextTick);
1347
- draining = true;
1348
-
1349
- var len = queue.length;
1350
- while(len) {
1351
- currentQueue = queue;
1352
- queue = [];
1353
- while (++queueIndex < len) {
1354
- if (currentQueue) {
1355
- currentQueue[queueIndex].run();
1356
- }
1357
- }
1358
- queueIndex = -1;
1359
- len = queue.length;
1360
- }
1361
- currentQueue = null;
1362
- draining = false;
1363
- runClearTimeout(timeout);
952
+ function makeUrl(path) {
953
+ var app = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
954
+ var get = typeof app.get === 'function' ? app.get.bind(app) : function () {};
955
+ var env = get('env') || "development";
956
+ var host = get('host') || process.env.HOST_NAME || 'localhost';
957
+ var protocol = env === 'development' || env === 'test' || env === undefined ? 'http' : 'https';
958
+ var PORT = get('port') || process.env.PORT || 3030;
959
+ var port = env === 'development' || env === 'test' || env === undefined ? ":".concat(PORT) : '';
960
+ path = path || '';
961
+ return "".concat(protocol, "://").concat(host).concat(port, "/").concat(exports.stripSlashes(path));
1364
962
  }
1365
963
 
1366
- process.nextTick = function (fun) {
1367
- var args = new Array(arguments.length - 1);
1368
- if (arguments.length > 1) {
1369
- for (var i = 1; i < arguments.length; i++) {
1370
- args[i - 1] = arguments[i];
1371
- }
1372
- }
1373
- queue.push(new Item(fun, args));
1374
- if (queue.length === 1 && !draining) {
1375
- runTimeout(drainQueue);
1376
- }
1377
- };
964
+ exports.makeUrl = makeUrl;
1378
965
 
1379
- // v8 likes predictible objects
1380
- function Item(fun, array) {
1381
- this.fun = fun;
1382
- this.array = array;
966
+ function createSymbol(name) {
967
+ return typeof Symbol !== 'undefined' ? Symbol(name) : name;
1383
968
  }
1384
- Item.prototype.run = function () {
1385
- this.fun.apply(null, this.array);
1386
- };
1387
- process.title = 'browser';
1388
- process.browser = true;
1389
- process.env = {};
1390
- process.argv = [];
1391
- process.version = ''; // empty string to avoid regexp issues
1392
- process.versions = {};
1393
-
1394
- function noop() {}
1395
-
1396
- process.on = noop;
1397
- process.addListener = noop;
1398
- process.once = noop;
1399
- process.off = noop;
1400
- process.removeListener = noop;
1401
- process.removeAllListeners = noop;
1402
- process.emit = noop;
1403
- process.prependListener = noop;
1404
- process.prependOnceListener = noop;
1405
-
1406
- process.listeners = function (name) { return [] }
1407
-
1408
- process.binding = function (name) {
1409
- throw new Error('process.binding is not supported');
1410
- };
1411
-
1412
- process.cwd = function () { return '/' };
1413
- process.chdir = function (dir) {
1414
- throw new Error('process.chdir is not supported');
1415
- };
1416
- process.umask = function() { return 0; };
1417
969
 
970
+ exports.createSymbol = createSymbol;
1418
971
 
1419
972
  /***/ }),
1420
973
 
1421
- /***/ "../../node_modules/uberproto/lib/proto.js":
1422
- /*!****************************************************************************************!*\
1423
- !*** /Users/daffl/Development/feathersjs/feathers/node_modules/uberproto/lib/proto.js ***!
1424
- \****************************************************************************************/
1425
- /*! no static exports found */
1426
- /***/ (function(module, exports, __webpack_require__) {
974
+ /***/ "../feathers/lib/application.js":
975
+ /*!**************************************!*\
976
+ !*** ../feathers/lib/application.js ***!
977
+ \**************************************/
978
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1427
979
 
1428
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* global define */
1429
- /**
1430
- * Uberproto
1431
- *
1432
- * A base object for ECMAScript 5 style prototypal inheritance.
1433
- *
1434
- * @see https://github.com/rauschma/proto-js/
1435
- * @see http://ejohn.org/blog/simple-javascript-inheritance/
1436
- * @see http://uxebu.com/blog/2011/02/23/object-based-inheritance-for-ecmascript-5/
1437
- */
1438
- (function (root, factory) {
1439
- if (true) {
1440
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
1441
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
1442
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
1443
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
1444
- } else {}
1445
- }(this, function () {
1446
- var HAS_SYMBOLS = typeof Object.getOwnPropertySymbols === 'function';
980
+ var debug = __webpack_require__(/*! debug */ "../../node_modules/debug/src/browser.js")('feathers:application');
1447
981
 
1448
- function makeSuper (_super, old, name, fn) {
1449
- var isFunction = typeof old === 'function';
1450
- var newMethod = function () {
1451
- var tmp = this._super;
982
+ var _require = __webpack_require__(/*! @feathersjs/commons */ "../commons/lib/index.js"),
983
+ stripSlashes = _require.stripSlashes;
1452
984
 
1453
- // Add a new ._super() method that is the same method
1454
- // but either pointing to the prototype method
1455
- // or to the overwritten method
1456
- this._super = isFunction ? old : _super[name];
985
+ var Uberproto = __webpack_require__(/*! uberproto */ "../../node_modules/uberproto/lib/proto.js");
1457
986
 
1458
- // The method only need to be bound temporarily, so we
1459
- // remove it when we're done executing
1460
- var ret = fn.apply(this, arguments);
987
+ var events = __webpack_require__(/*! ./events */ "../feathers/lib/events.js");
1461
988
 
1462
- this._super = tmp;
989
+ var hooks = __webpack_require__(/*! ./hooks */ "../feathers/lib/hooks/index.js");
1463
990
 
1464
- return ret;
1465
- };
991
+ var version = __webpack_require__(/*! ./version */ "../feathers/lib/version.js");
1466
992
 
1467
- if (isFunction) {
1468
- Object.keys(old).forEach(function (name) {
1469
- newMethod[name] = old[name];
1470
- });
993
+ var Proto = Uberproto.extend({
994
+ create: null
995
+ });
996
+ var application = {
997
+ init: function init() {
998
+ Object.assign(this, {
999
+ version: version,
1000
+ methods: ['find', 'get', 'create', 'update', 'patch', 'remove'],
1001
+ mixins: [],
1002
+ services: {},
1003
+ providers: [],
1004
+ _setup: false,
1005
+ settings: {}
1006
+ });
1007
+ this.configure(hooks());
1008
+ this.configure(events());
1009
+ },
1010
+ get: function get(name) {
1011
+ return this.settings[name];
1012
+ },
1013
+ set: function set(name, value) {
1014
+ this.settings[name] = value;
1015
+ return this;
1016
+ },
1017
+ disable: function disable(name) {
1018
+ this.settings[name] = false;
1019
+ return this;
1020
+ },
1021
+ disabled: function disabled(name) {
1022
+ return !this.settings[name];
1023
+ },
1024
+ enable: function enable(name) {
1025
+ this.settings[name] = true;
1026
+ return this;
1027
+ },
1028
+ enabled: function enabled(name) {
1029
+ return !!this.settings[name];
1030
+ },
1031
+ configure: function configure(fn) {
1032
+ fn.call(this, this);
1033
+ return this;
1034
+ },
1035
+ service: function service(path, _service) {
1036
+ if (typeof _service !== 'undefined') {
1037
+ throw new Error('Registering a new service with `app.service(path, service)` is no longer supported. Use `app.use(path, service)` instead.');
1038
+ }
1471
1039
 
1472
- if (HAS_SYMBOLS) {
1473
- Object.getOwnPropertySymbols(old).forEach(function (name) {
1474
- newMethod[name] = old[name];
1475
- });
1476
- }
1040
+ var location = stripSlashes(path) || '/';
1041
+ var current = this.services[location];
1042
+
1043
+ if (typeof current === 'undefined' && typeof this.defaultService === 'function') {
1044
+ return this.use(location, this.defaultService(location)).service(location);
1477
1045
  }
1478
1046
 
1479
- return newMethod;
1480
- }
1047
+ return current;
1048
+ },
1049
+ use: function use(path, service) {
1050
+ var _this = this;
1481
1051
 
1482
- return {
1483
- /**
1484
- * Create a new object using Object.create. The arguments will be
1485
- * passed to the new instances init method or to a method name set in
1486
- * __init.
1487
- */
1488
- create: function () {
1489
- var instance = Object.create(this);
1490
- var init = typeof instance.__init === 'string' ? instance.__init : 'init';
1052
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1491
1053
 
1492
- if (typeof instance[init] === 'function') {
1493
- instance[init].apply(instance, arguments);
1494
- }
1495
- return instance;
1496
- },
1497
- /**
1498
- * Mixin a given set of properties
1499
- * @param prop The properties to mix in
1500
- * @param obj [optional]
1501
- * The object to add the mixin
1502
- */
1503
- mixin: function (prop, obj) {
1504
- var self = obj || this;
1505
- var fnTest = /\b_super\b/;
1506
- var _super = Object.getPrototypeOf(self) || self.prototype;
1507
- var descriptors = {};
1508
- var proto = prop;
1509
- var processProperty = function (name) {
1510
- var descriptor = Object.getOwnPropertyDescriptor(proto, name);
1054
+ if (typeof path !== 'string') {
1055
+ throw new Error("'".concat(path, "' is not a valid service path."));
1056
+ }
1511
1057
 
1512
- if (!descriptors[name] && descriptor) {
1513
- descriptors[name] = descriptor;
1514
- }
1515
- };
1058
+ var location = stripSlashes(path) || '/';
1059
+ var isSubApp = typeof service.service === 'function' && service.services;
1060
+ var isService = this.methods.concat('setup').some(function (name) {
1061
+ return typeof service[name] === 'function';
1062
+ });
1516
1063
 
1517
- // Collect all property descriptors
1518
- do {
1519
- Object.getOwnPropertyNames(proto).forEach(processProperty);
1064
+ if (isSubApp) {
1065
+ var subApp = service;
1066
+ Object.keys(subApp.services).forEach(function (subPath) {
1067
+ return _this.use("".concat(location, "/").concat(subPath), subApp.service(subPath));
1068
+ });
1069
+ return this;
1070
+ }
1520
1071
 
1521
- if (HAS_SYMBOLS) {
1522
- Object.getOwnPropertySymbols(proto).forEach(processProperty);
1523
- }
1524
- } while ((proto = Object.getPrototypeOf(proto)) && Object.getPrototypeOf(proto));
1072
+ if (!isService) {
1073
+ throw new Error("Invalid service object passed for path `".concat(location, "`"));
1074
+ } // If the service is already Uberproto'd use it directly
1525
1075
 
1526
- var processDescriptor = function (name) {
1527
- var descriptor = descriptors[name];
1528
1076
 
1529
- if (typeof descriptor.value === 'function' && fnTest.test(descriptor.value)) {
1530
- descriptor.value = makeSuper(_super, self[name], name, descriptor.value);
1531
- }
1077
+ var protoService = Proto.isPrototypeOf(service) ? service : Proto.extend(service);
1078
+ debug("Registering new service at `".concat(location, "`")); // Add all the mixins
1532
1079
 
1533
- Object.defineProperty(self, name, descriptor);
1534
- };
1080
+ this.mixins.forEach(function (fn) {
1081
+ return fn.call(_this, protoService, location, options);
1082
+ });
1535
1083
 
1536
- Object.keys(descriptors).forEach(processDescriptor);
1084
+ if (typeof protoService._setup === 'function') {
1085
+ protoService._setup(this, location);
1086
+ } // Run the provider functions to register the service
1537
1087
 
1538
- if (HAS_SYMBOLS) {
1539
- Object.getOwnPropertySymbols(descriptors).forEach(processDescriptor);
1540
- }
1541
1088
 
1542
- return self;
1543
- },
1544
- /**
1545
- * Extend the current or a given object with the given property and return the extended object.
1546
- * @param prop The properties to extend with
1547
- * @param obj [optional] The object to extend from
1548
- * @returns The extended object
1549
- */
1550
- extend: function (prop, obj) {
1551
- return this.mixin(prop, Object.create(obj || this));
1552
- },
1553
- /**
1554
- * Return a callback function with this set to the current or a given context object.
1555
- * @param name Name of the method to proxy
1556
- * @param args... [optional] Arguments to use for partial application
1557
- */
1558
- proxy: function (name) {
1559
- var fn = this[name];
1560
- var args = Array.prototype.slice.call(arguments, 1);
1089
+ this.providers.forEach(function (provider) {
1090
+ return provider.call(_this, protoService, location, options);
1091
+ }); // If we ran setup already, set this service up explicitly
1561
1092
 
1562
- args.unshift(this);
1563
- return fn.bind.apply(fn, args);
1093
+ if (this._isSetup && typeof protoService.setup === 'function') {
1094
+ debug("Setting up service for `".concat(location, "`"));
1095
+ protoService.setup(this, location);
1564
1096
  }
1565
- };
1566
- }));
1567
1097
 
1098
+ this.services[location] = protoService;
1099
+ return this;
1100
+ },
1101
+ setup: function setup() {
1102
+ var _this2 = this;
1568
1103
 
1569
- /***/ }),
1104
+ // Setup each service (pass the app so that they can look up other services etc.)
1105
+ Object.keys(this.services).forEach(function (path) {
1106
+ var service = _this2.services[path];
1107
+ debug("Setting up service for `".concat(path, "`"));
1570
1108
 
1571
- /***/ "../commons/lib/hooks.js":
1572
- /*!*******************************!*\
1573
- !*** ../commons/lib/hooks.js ***!
1574
- \*******************************/
1575
- /*! no static exports found */
1576
- /***/ (function(module, exports, __webpack_require__) {
1109
+ if (typeof service.setup === 'function') {
1110
+ service.setup(_this2, path);
1111
+ }
1112
+ });
1113
+ this._isSetup = true;
1114
+ return this;
1115
+ }
1116
+ };
1117
+ module.exports = application;
1577
1118
 
1578
- "use strict";
1119
+ /***/ }),
1579
1120
 
1121
+ /***/ "../feathers/lib/events.js":
1122
+ /*!*********************************!*\
1123
+ !*** ../feathers/lib/events.js ***!
1124
+ \*********************************/
1125
+ /***/ (function(module, exports, __webpack_require__) {
1580
1126
 
1581
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1127
+ var _require = __webpack_require__(/*! events */ "../../node_modules/events/events.js"),
1128
+ EventEmitter = _require.EventEmitter;
1582
1129
 
1583
- Object.defineProperty(exports, "__esModule", {
1584
- value: true
1585
- });
1586
- exports.enableHooks = exports.processHooks = exports.getHooks = exports.isHookObject = exports.convertHookData = exports.makeArguments = exports.defaultMakeArguments = exports.createHookObject = exports.ACTIVATE_HOOKS = void 0;
1130
+ var Proto = __webpack_require__(/*! uberproto */ "../../node_modules/uberproto/lib/proto.js"); // Returns a hook that emits service events. Should always be
1131
+ // used as the very last hook in the chain
1587
1132
 
1588
- var utils_1 = __webpack_require__(/*! ./utils */ "../commons/lib/utils.js");
1589
1133
 
1590
- var _utils_1$_ = utils_1._,
1591
- each = _utils_1$_.each,
1592
- pick = _utils_1$_.pick;
1593
- exports.ACTIVATE_HOOKS = utils_1.createSymbol('__feathersActivateHooks');
1134
+ var eventHook = exports.eventHook = function eventHook() {
1135
+ return function (hook) {
1136
+ var app = hook.app,
1137
+ service = hook.service;
1138
+ var eventName = hook.event === null ? hook.event : app.eventMappings[hook.method];
1139
+ var isHookEvent = service._hookEvents && service._hookEvents.indexOf(eventName) !== -1; // If this event is not being sent yet and we are not in an error hook
1594
1140
 
1595
- function createHookObject(method) {
1596
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1597
- var hook = {};
1598
- Object.defineProperty(hook, 'toJSON', {
1599
- value: function value() {
1600
- return pick(this, 'type', 'method', 'path', 'params', 'id', 'data', 'result', 'error');
1141
+ if (eventName && isHookEvent && hook.type !== 'error') {
1142
+ var results = Array.isArray(hook.result) ? hook.result : [hook.result];
1143
+ results.forEach(function (element) {
1144
+ return service.emit(eventName, element, hook);
1145
+ });
1601
1146
  }
1602
- });
1603
- return Object.assign(hook, data, {
1604
- method: method,
1605
-
1606
- // A dynamic getter that returns the path of the service
1607
- get path() {
1608
- var app = data.app,
1609
- service = data.service;
1147
+ };
1148
+ }; // Mixin that turns a service into a Node event emitter
1610
1149
 
1611
- if (!service || !app || !app.services) {
1612
- return null;
1613
- }
1614
1150
 
1615
- return Object.keys(app.services).find(function (path) {
1616
- return app.services[path] === service;
1617
- });
1618
- }
1151
+ var eventMixin = exports.eventMixin = function eventMixin(service) {
1152
+ if (service._serviceEvents) {
1153
+ return;
1154
+ }
1619
1155
 
1620
- });
1621
- }
1156
+ var app = this; // Indicates if the service is already an event emitter
1622
1157
 
1623
- exports.createHookObject = createHookObject; // Fallback used by `makeArguments` which usually won't be used
1158
+ var isEmitter = typeof service.on === 'function' && typeof service.emit === 'function'; // If not, mix it in (the service is always an Uberproto object that has a .mixin)
1624
1159
 
1625
- function defaultMakeArguments(hook) {
1626
- var result = [];
1627
-
1628
- if (typeof hook.id !== 'undefined') {
1629
- result.push(hook.id);
1630
- }
1631
-
1632
- if (hook.data) {
1633
- result.push(hook.data);
1634
- }
1160
+ if (typeof service.mixin === 'function' && !isEmitter) {
1161
+ service.mixin(EventEmitter.prototype);
1162
+ } // Define non-enumerable properties of
1635
1163
 
1636
- result.push(hook.params || {});
1637
- return result;
1638
- }
1639
1164
 
1640
- exports.defaultMakeArguments = defaultMakeArguments; // Turns a hook object back into a list of arguments
1641
- // to call a service method with
1165
+ Object.defineProperties(service, {
1166
+ // A list of all events that this service sends
1167
+ _serviceEvents: {
1168
+ value: Array.isArray(service.events) ? service.events.slice() : []
1169
+ },
1170
+ // A list of events that should be handled through the event hooks
1171
+ _hookEvents: {
1172
+ value: []
1173
+ }
1174
+ }); // `app.eventMappings` has the mapping from method name to event name
1642
1175
 
1643
- function makeArguments(hook) {
1644
- switch (hook.method) {
1645
- case 'find':
1646
- return [hook.params];
1176
+ Object.keys(app.eventMappings).forEach(function (method) {
1177
+ var event = app.eventMappings[method];
1178
+ var alreadyEmits = service._serviceEvents.indexOf(event) !== -1; // Add events for known methods to _serviceEvents and _hookEvents
1179
+ // if the service indicated it does not send it itself yet
1647
1180
 
1648
- case 'get':
1649
- case 'remove':
1650
- return [hook.id, hook.params];
1181
+ if (typeof service[method] === 'function' && !alreadyEmits) {
1182
+ service._serviceEvents.push(event);
1651
1183
 
1652
- case 'update':
1653
- case 'patch':
1654
- return [hook.id, hook.data, hook.params];
1184
+ service._hookEvents.push(event);
1185
+ }
1186
+ });
1187
+ };
1655
1188
 
1656
- case 'create':
1657
- return [hook.data, hook.params];
1658
- }
1189
+ module.exports = function () {
1190
+ return function (app) {
1191
+ // Mappings from service method to event name
1192
+ Object.assign(app, {
1193
+ eventMappings: {
1194
+ create: 'created',
1195
+ update: 'updated',
1196
+ remove: 'removed',
1197
+ patch: 'patched'
1198
+ }
1199
+ }); // Register the event hook
1200
+ // `finally` hooks always run last after `error` and `after` hooks
1659
1201
 
1660
- return defaultMakeArguments(hook);
1661
- }
1202
+ app.hooks({
1203
+ finally: eventHook()
1204
+ }); // Make the app an event emitter
1662
1205
 
1663
- exports.makeArguments = makeArguments; // Converts different hook registration formats into the
1664
- // same internal format
1206
+ Proto.mixin(EventEmitter.prototype, app);
1207
+ app.mixins.push(eventMixin);
1208
+ };
1209
+ };
1665
1210
 
1666
- function convertHookData(obj) {
1667
- var hook = {};
1211
+ /***/ }),
1668
1212
 
1669
- if (Array.isArray(obj)) {
1670
- hook = {
1671
- all: obj
1672
- };
1673
- } else if (_typeof(obj) !== 'object') {
1674
- hook = {
1675
- all: [obj]
1676
- };
1677
- } else {
1678
- each(obj, function (value, key) {
1679
- hook[key] = !Array.isArray(value) ? [value] : value;
1680
- });
1681
- }
1213
+ /***/ "../feathers/lib/hooks/base.js":
1214
+ /*!*************************************!*\
1215
+ !*** ../feathers/lib/hooks/base.js ***!
1216
+ \*************************************/
1217
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1682
1218
 
1683
- return hook;
1684
- }
1219
+ var _require = __webpack_require__(/*! @feathersjs/commons */ "../commons/lib/index.js"),
1220
+ _ = _require._;
1685
1221
 
1686
- exports.convertHookData = convertHookData; // Duck-checks a given object to be a hook object
1687
- // A valid hook object has `type` and `method`
1222
+ var assignArguments = function assignArguments(context) {
1223
+ var service = context.service,
1224
+ method = context.method;
1225
+ var parameters = service.methods[method];
1226
+ context.arguments.forEach(function (value, index) {
1227
+ context[parameters[index]] = value;
1228
+ });
1688
1229
 
1689
- function isHookObject(hookObject) {
1690
- return _typeof(hookObject) === 'object' && typeof hookObject.method === 'string' && typeof hookObject.type === 'string';
1691
- }
1230
+ if (!context.params) {
1231
+ context.params = {};
1232
+ }
1692
1233
 
1693
- exports.isHookObject = isHookObject; // Returns all service and application hooks combined
1694
- // for a given method and type `appLast` sets if the hooks
1695
- // from `app` should be added last (or first by default)
1234
+ return context;
1235
+ };
1696
1236
 
1697
- function getHooks(app, service, type, method) {
1698
- var appLast = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1699
- var appHooks = app.__hooks[type][method] || [];
1700
- var serviceHooks = service.__hooks[type][method] || [];
1237
+ var validate = function validate(context) {
1238
+ var service = context.service,
1239
+ method = context.method,
1240
+ path = context.path;
1241
+ var parameters = service.methods[method];
1701
1242
 
1702
- if (appLast) {
1703
- // Run hooks in the order of service -> app -> finally
1704
- return serviceHooks.concat(appHooks);
1243
+ if (parameters.includes('id') && context.id === undefined) {
1244
+ throw new Error("An id must be provided to the '".concat(path, ".").concat(method, "' method"));
1705
1245
  }
1706
1246
 
1707
- return appHooks.concat(serviceHooks);
1708
- }
1247
+ if (parameters.includes('data') && !_.isObjectOrArray(context.data)) {
1248
+ throw new Error("A data object must be provided to the '".concat(path, ".").concat(method, "' method"));
1249
+ }
1709
1250
 
1710
- exports.getHooks = getHooks;
1251
+ return context;
1252
+ };
1711
1253
 
1712
- function processHooks(hooks, initialHookObject) {
1713
- var _this = this;
1254
+ module.exports = [assignArguments, validate];
1714
1255
 
1715
- var hookObject = initialHookObject;
1256
+ /***/ }),
1716
1257
 
1717
- var updateCurrentHook = function updateCurrentHook(current) {
1718
- // Either use the returned hook object or the current
1719
- // hook object from the chain if the hook returned undefined
1720
- if (current) {
1721
- if (!isHookObject(current)) {
1722
- throw new Error("".concat(hookObject.type, " hook for '").concat(hookObject.method, "' method returned invalid hook object"));
1723
- }
1258
+ /***/ "../feathers/lib/hooks/index.js":
1259
+ /*!**************************************!*\
1260
+ !*** ../feathers/lib/hooks/index.js ***!
1261
+ \**************************************/
1262
+ /***/ (function(module, exports, __webpack_require__) {
1724
1263
 
1725
- hookObject = current;
1726
- }
1264
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1727
1265
 
1728
- return hookObject;
1729
- }; // Go through all hooks and chain them into our promise
1266
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1730
1267
 
1268
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1731
1269
 
1732
- var promise = hooks.reduce(function (current, fn) {
1733
- // @ts-ignore
1734
- var hook = fn.bind(_this); // Use the returned hook object or the old one
1270
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
1735
1271
 
1736
- return current.then(function (currentHook) {
1737
- return hook(currentHook);
1738
- }).then(updateCurrentHook);
1739
- }, Promise.resolve(hookObject));
1740
- return promise.then(function () {
1741
- return hookObject;
1742
- }).catch(function (error) {
1743
- // Add the hook information to any errors
1744
- error.hook = hookObject;
1745
- throw error;
1746
- });
1747
- }
1272
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
1748
1273
 
1749
- exports.processHooks = processHooks; // Add `.hooks` functionality to an object
1274
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1750
1275
 
1751
- function enableHooks(obj, methods, types) {
1752
- if (typeof obj.hooks === 'function') {
1753
- return obj;
1754
- }
1276
+ var _require = __webpack_require__(/*! @feathersjs/commons */ "../commons/lib/index.js"),
1277
+ hooks = _require.hooks,
1278
+ isPromise = _require.isPromise;
1755
1279
 
1756
- var hookData = {};
1757
- types.forEach(function (type) {
1758
- // Initialize properties where hook functions are stored
1759
- hookData[type] = {};
1760
- }); // Add non-enumerable `__hooks` property to the object
1280
+ var baseHooks = __webpack_require__(/*! ./base */ "../feathers/lib/hooks/base.js");
1761
1281
 
1762
- Object.defineProperty(obj, '__hooks', {
1763
- configurable: true,
1764
- value: hookData,
1765
- writable: true
1766
- });
1767
- return Object.assign(obj, {
1768
- hooks: function hooks(allHooks) {
1769
- var _this2 = this;
1282
+ var createHookObject = hooks.createHookObject,
1283
+ getHooks = hooks.getHooks,
1284
+ processHooks = hooks.processHooks,
1285
+ enableHooks = hooks.enableHooks,
1286
+ ACTIVATE_HOOKS = hooks.ACTIVATE_HOOKS;
1770
1287
 
1771
- each(allHooks, function (current, type) {
1772
- // @ts-ignore
1773
- if (!_this2.__hooks[type]) {
1774
- throw new Error("'".concat(type, "' is not a valid hook type"));
1775
- }
1288
+ var withHooks = function withHooks(_ref) {
1289
+ var app = _ref.app,
1290
+ service = _ref.service,
1291
+ method = _ref.method,
1292
+ original = _ref.original;
1293
+ return function () {
1294
+ var _hooks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1776
1295
 
1777
- var hooks = convertHookData(current);
1778
- each(hooks, function (_value, method) {
1779
- if (method !== 'all' && methods.indexOf(method) === -1) {
1780
- throw new Error("'".concat(method, "' is not a valid hook method"));
1781
- }
1782
- });
1783
- methods.forEach(function (method) {
1784
- // @ts-ignore
1785
- var myHooks = _this2.__hooks[type][method] || (_this2.__hooks[type][method] = []);
1296
+ var hooks = app.hookTypes.reduce(function (result, type) {
1297
+ var value = _hooks[type] || [];
1298
+ result[type] = Array.isArray(value) ? value : [value];
1299
+ return result;
1300
+ }, {});
1301
+ return function () {
1302
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1303
+ args[_key] = arguments[_key];
1304
+ }
1786
1305
 
1787
- if (hooks.all) {
1788
- myHooks.push.apply(myHooks, hooks.all);
1789
- }
1306
+ var returnHook = args[args.length - 1] === true ? args.pop() : false; // Create the hook object that gets passed through
1790
1307
 
1791
- if (hooks[method]) {
1792
- myHooks.push.apply(myHooks, hooks[method]);
1793
- }
1794
- });
1308
+ var hookObject = createHookObject(method, {
1309
+ type: 'before',
1310
+ // initial hook object type
1311
+ arguments: args,
1312
+ service: service,
1313
+ app: app
1795
1314
  });
1796
- return this;
1797
- }
1798
- });
1799
- }
1315
+ return Promise.resolve(hookObject) // Run `before` hooks
1316
+ .then(function (hookObject) {
1317
+ return processHooks.call(service, baseHooks.concat(hooks.before), hookObject);
1318
+ }) // Run the original method
1319
+ .then(function (hookObject) {
1320
+ // If `hookObject.result` is set, skip the original method
1321
+ if (typeof hookObject.result !== 'undefined') {
1322
+ return hookObject;
1323
+ } // Otherwise, call it with arguments created from the hook object
1800
1324
 
1801
- exports.enableHooks = enableHooks;
1802
1325
 
1803
- /***/ }),
1326
+ var promise = new Promise(function (resolve) {
1327
+ var func = original || service[method];
1328
+ var args = service.methods[method].map(function (value) {
1329
+ return hookObject[value];
1330
+ });
1331
+ var result = func.apply(service, args);
1804
1332
 
1805
- /***/ "../commons/lib/index.js":
1806
- /*!*******************************!*\
1807
- !*** ../commons/lib/index.js ***!
1808
- \*******************************/
1809
- /*! no static exports found */
1810
- /***/ (function(module, exports, __webpack_require__) {
1333
+ if (!isPromise(result)) {
1334
+ throw new Error("Service method '".concat(hookObject.method, "' for '").concat(hookObject.path, "' service must return a promise"));
1335
+ }
1811
1336
 
1812
- "use strict";
1337
+ resolve(result);
1338
+ });
1339
+ return promise.then(function (result) {
1340
+ hookObject.result = result;
1341
+ return hookObject;
1342
+ }).catch(function (error) {
1343
+ error.hook = hookObject;
1344
+ throw error;
1345
+ });
1346
+ }) // Run `after` hooks
1347
+ .then(function (hookObject) {
1348
+ var afterHookObject = Object.assign({}, hookObject, {
1349
+ type: 'after'
1350
+ });
1351
+ return processHooks.call(service, hooks.after, afterHookObject);
1352
+ }) // Run `errors` hooks
1353
+ .catch(function (error) {
1354
+ var errorHookObject = Object.assign({}, error.hook, {
1355
+ type: 'error',
1356
+ original: error.hook,
1357
+ error: error,
1358
+ result: undefined
1359
+ });
1360
+ return processHooks.call(service, hooks.error, errorHookObject).catch(function (error) {
1361
+ var errorHookObject = Object.assign({}, error.hook, {
1362
+ error: error,
1363
+ result: undefined
1364
+ });
1365
+ return errorHookObject;
1366
+ });
1367
+ }) // Run `finally` hooks
1368
+ .then(function (hookObject) {
1369
+ return processHooks.call(service, hooks.finally, hookObject).catch(function (error) {
1370
+ var errorHookObject = Object.assign({}, error.hook, {
1371
+ error: error,
1372
+ result: undefined
1373
+ });
1374
+ return errorHookObject;
1375
+ });
1376
+ }) // Resolve with a result or reject with an error
1377
+ .then(function (hookObject) {
1378
+ if (typeof hookObject.error !== 'undefined' && typeof hookObject.result === 'undefined') {
1379
+ return Promise.reject(returnHook ? hookObject : hookObject.error);
1380
+ } else {
1381
+ return returnHook ? hookObject : hookObject.result;
1382
+ }
1383
+ });
1384
+ };
1385
+ };
1386
+ }; // A service mixin that adds `service.hooks()` method and functionality
1813
1387
 
1814
1388
 
1815
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1816
- if (k2 === undefined) k2 = k;
1817
- Object.defineProperty(o, k2, {
1818
- enumerable: true,
1819
- get: function get() {
1820
- return m[k];
1821
- }
1822
- });
1823
- } : function (o, m, k, k2) {
1824
- if (k2 === undefined) k2 = k;
1825
- o[k2] = m[k];
1826
- });
1389
+ var hookMixin = exports.hookMixin = function hookMixin(service) {
1390
+ if (typeof service.hooks === 'function') {
1391
+ return;
1392
+ }
1827
1393
 
1828
- var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
1829
- Object.defineProperty(o, "default", {
1830
- enumerable: true,
1831
- value: v
1394
+ service.methods = Object.getOwnPropertyNames(service).filter(function (key) {
1395
+ return typeof service[key] === 'function' && service[key][ACTIVATE_HOOKS];
1396
+ }).reduce(function (result, methodName) {
1397
+ result[methodName] = service[methodName][ACTIVATE_HOOKS];
1398
+ return result;
1399
+ }, service.methods || {});
1400
+ Object.assign(service.methods, {
1401
+ find: ['params'],
1402
+ get: ['id', 'params'],
1403
+ create: ['data', 'params'],
1404
+ update: ['id', 'data', 'params'],
1405
+ patch: ['id', 'data', 'params'],
1406
+ remove: ['id', 'params']
1832
1407
  });
1833
- } : function (o, v) {
1834
- o["default"] = v;
1835
- });
1408
+ var app = this;
1409
+ var methodNames = Object.keys(service.methods); // Assemble the mixin object that contains all "hooked" service methods
1836
1410
 
1837
- var __importStar = this && this.__importStar || function (mod) {
1838
- if (mod && mod.__esModule) return mod;
1839
- var result = {};
1840
- if (mod != null) for (var k in mod) {
1841
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1842
- }
1411
+ var mixin = methodNames.reduce(function (mixin, method) {
1412
+ if (typeof service[method] !== 'function') {
1413
+ return mixin;
1414
+ }
1843
1415
 
1844
- __setModuleDefault(result, mod);
1416
+ mixin[method] = function () {
1417
+ var service = this;
1418
+ var args = Array.from(arguments);
1845
1419
 
1846
- return result;
1847
- };
1420
+ var original = service._super.bind(service);
1848
1421
 
1849
- var __exportStar = this && this.__exportStar || function (m, exports) {
1850
- for (var p in m) {
1851
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1852
- }
1422
+ return withHooks({
1423
+ app: app,
1424
+ service: service,
1425
+ method: method,
1426
+ original: original
1427
+ })({
1428
+ before: getHooks(app, service, 'before', method),
1429
+ after: getHooks(app, service, 'after', method, true),
1430
+ error: getHooks(app, service, 'error', method, true),
1431
+ finally: getHooks(app, service, 'finally', method, true)
1432
+ }).apply(void 0, _toConsumableArray(args));
1433
+ };
1434
+
1435
+ return mixin;
1436
+ }, {}); // Add .hooks method and properties to the service
1437
+
1438
+ enableHooks(service, methodNames, app.hookTypes);
1439
+ service.mixin(mixin);
1853
1440
  };
1854
1441
 
1855
- Object.defineProperty(exports, "__esModule", {
1856
- value: true
1857
- });
1858
- exports.hooks = void 0;
1442
+ module.exports = function () {
1443
+ return function (app) {
1444
+ // We store a reference of all supported hook types on the app
1445
+ // in case someone needs it
1446
+ Object.assign(app, {
1447
+ hookTypes: ['before', 'after', 'error', 'finally']
1448
+ }); // Add functionality for hooks to be registered as app.hooks
1859
1449
 
1860
- var hookUtils = __importStar(__webpack_require__(/*! ./hooks */ "../commons/lib/hooks.js"));
1450
+ enableHooks(app, app.methods, app.hookTypes);
1451
+ app.mixins.push(hookMixin);
1452
+ };
1453
+ };
1861
1454
 
1862
- __exportStar(__webpack_require__(/*! ./utils */ "../commons/lib/utils.js"), exports);
1455
+ module.exports.withHooks = withHooks;
1456
+ module.exports.ACTIVATE_HOOKS = ACTIVATE_HOOKS;
1863
1457
 
1864
- exports.hooks = hookUtils;
1458
+ module.exports.activateHooks = function activateHooks(args) {
1459
+ return function (fn) {
1460
+ Object.defineProperty(fn, ACTIVATE_HOOKS, {
1461
+ value: args
1462
+ });
1463
+ return fn;
1464
+ };
1465
+ };
1865
1466
 
1866
1467
  /***/ }),
1867
1468
 
1868
- /***/ "../commons/lib/utils.js":
1869
- /*!*******************************!*\
1870
- !*** ../commons/lib/utils.js ***!
1871
- \*******************************/
1872
- /*! no static exports found */
1873
- /***/ (function(module, exports, __webpack_require__) {
1469
+ /***/ "../feathers/lib/index.js":
1470
+ /*!********************************!*\
1471
+ !*** ../feathers/lib/index.js ***!
1472
+ \********************************/
1473
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1874
1474
 
1875
- "use strict";
1876
- /* WEBPACK VAR INJECTION */(function(process) {
1475
+ var Proto = __webpack_require__(/*! uberproto */ "../../node_modules/uberproto/lib/proto.js");
1877
1476
 
1878
- 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; }
1477
+ var Application = __webpack_require__(/*! ./application */ "../feathers/lib/application.js");
1879
1478
 
1880
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1479
+ var version = __webpack_require__(/*! ./version */ "../feathers/lib/version.js");
1881
1480
 
1882
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
1481
+ var _require = __webpack_require__(/*! ./hooks */ "../feathers/lib/hooks/index.js"),
1482
+ ACTIVATE_HOOKS = _require.ACTIVATE_HOOKS,
1483
+ activateHooks = _require.activateHooks; // A base object Prototype that does not inherit from a
1484
+ // potentially polluted Object prototype
1883
1485
 
1884
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1885
1486
 
1886
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1487
+ var baseObject = Object.create(null);
1887
1488
 
1888
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1489
+ function createApplication() {
1490
+ var app = Object.create(baseObject); // Mix in the base application
1889
1491
 
1890
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 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"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
1492
+ Proto.mixin(Application, app);
1493
+ app.init();
1494
+ return app;
1495
+ }
1891
1496
 
1892
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1497
+ createApplication.version = version;
1498
+ createApplication.ACTIVATE_HOOKS = ACTIVATE_HOOKS;
1499
+ createApplication.activateHooks = activateHooks;
1500
+ module.exports = createApplication; // For better ES module (TypeScript) compatibility
1893
1501
 
1894
- Object.defineProperty(exports, "__esModule", {
1895
- value: true
1896
- });
1897
- exports.createSymbol = exports.makeUrl = exports.isPromise = exports._ = exports.stripSlashes = void 0; // Removes all leading and trailing slashes from a path
1502
+ module.exports["default"] = createApplication;
1898
1503
 
1899
- function stripSlashes(name) {
1900
- return name.replace(/^(\/+)|(\/+)$/g, '');
1901
- }
1504
+ /***/ }),
1902
1505
 
1903
- exports.stripSlashes = stripSlashes; // A set of lodash-y utility functions that use ES6
1506
+ /***/ "../feathers/lib/version.js":
1507
+ /*!**********************************!*\
1508
+ !*** ../feathers/lib/version.js ***!
1509
+ \**********************************/
1510
+ /***/ (function(module) {
1904
1511
 
1905
- exports._ = {
1906
- each: function each(obj, callback) {
1907
- if (obj && typeof obj.forEach === 'function') {
1908
- obj.forEach(callback);
1909
- } else if (exports._.isObject(obj)) {
1910
- Object.keys(obj).forEach(function (key) {
1911
- return callback(obj[key], key);
1912
- });
1913
- }
1914
- },
1915
- some: function some(value, callback) {
1916
- return Object.keys(value).map(function (key) {
1917
- return [value[key], key];
1918
- }).some(function (_ref) {
1919
- var _ref2 = _slicedToArray(_ref, 2),
1920
- val = _ref2[0],
1921
- key = _ref2[1];
1512
+ module.exports = 'development';
1922
1513
 
1923
- return callback(val, key);
1924
- });
1925
- },
1926
- every: function every(value, callback) {
1927
- return Object.keys(value).map(function (key) {
1928
- return [value[key], key];
1929
- }).every(function (_ref3) {
1930
- var _ref4 = _slicedToArray(_ref3, 2),
1931
- val = _ref4[0],
1932
- key = _ref4[1];
1514
+ /***/ }),
1933
1515
 
1934
- return callback(val, key);
1935
- });
1936
- },
1937
- keys: function keys(obj) {
1938
- return Object.keys(obj);
1939
- },
1940
- values: function values(obj) {
1941
- return exports._.keys(obj).map(function (key) {
1942
- return obj[key];
1943
- });
1944
- },
1945
- isMatch: function isMatch(obj, item) {
1946
- return exports._.keys(item).every(function (key) {
1947
- return obj[key] === item[key];
1948
- });
1949
- },
1950
- isEmpty: function isEmpty(obj) {
1951
- return exports._.keys(obj).length === 0;
1952
- },
1953
- isObject: function isObject(item) {
1954
- return _typeof(item) === 'object' && !Array.isArray(item) && item !== null;
1955
- },
1956
- isObjectOrArray: function isObjectOrArray(value) {
1957
- return _typeof(value) === 'object' && value !== null;
1958
- },
1959
- extend: function extend(first) {
1960
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1961
- rest[_key - 1] = arguments[_key];
1962
- }
1963
-
1964
- return Object.assign.apply(Object, [first].concat(rest));
1965
- },
1966
- omit: function omit(obj) {
1967
- var result = exports._.extend({}, obj);
1968
-
1969
- for (var _len2 = arguments.length, keys = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1970
- keys[_key2 - 1] = arguments[_key2];
1971
- }
1972
-
1973
- keys.forEach(function (key) {
1974
- return delete result[key];
1975
- });
1976
- return result;
1977
- },
1978
- pick: function pick(source) {
1979
- for (var _len3 = arguments.length, keys = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
1980
- keys[_key3 - 1] = arguments[_key3];
1981
- }
1516
+ /***/ "../../node_modules/events/events.js":
1517
+ /*!*******************************************!*\
1518
+ !*** ../../node_modules/events/events.js ***!
1519
+ \*******************************************/
1520
+ /***/ (function(module) {
1982
1521
 
1983
- return keys.reduce(function (result, key) {
1984
- if (source[key] !== undefined) {
1985
- result[key] = source[key];
1986
- }
1522
+ "use strict";
1523
+ // Copyright Joyent, Inc. and other Node contributors.
1524
+ //
1525
+ // Permission is hereby granted, free of charge, to any person obtaining a
1526
+ // copy of this software and associated documentation files (the
1527
+ // "Software"), to deal in the Software without restriction, including
1528
+ // without limitation the rights to use, copy, modify, merge, publish,
1529
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
1530
+ // persons to whom the Software is furnished to do so, subject to the
1531
+ // following conditions:
1532
+ //
1533
+ // The above copyright notice and this permission notice shall be included
1534
+ // in all copies or substantial portions of the Software.
1535
+ //
1536
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1537
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1538
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1539
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1540
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1541
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1542
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
1987
1543
 
1988
- return result;
1989
- }, {});
1990
- },
1991
- // Recursively merge the source object into the target object
1992
- merge: function merge(target, source) {
1993
- if (exports._.isObject(target) && exports._.isObject(source)) {
1994
- Object.keys(source).forEach(function (key) {
1995
- if (exports._.isObject(source[key])) {
1996
- if (!target[key]) {
1997
- Object.assign(target, _defineProperty({}, key, {}));
1998
- }
1999
1544
 
2000
- exports._.merge(target[key], source[key]);
2001
- } else {
2002
- Object.assign(target, _defineProperty({}, key, source[key]));
2003
- }
2004
- });
2005
- }
2006
1545
 
2007
- return target;
1546
+ var R = typeof Reflect === 'object' ? Reflect : null
1547
+ var ReflectApply = R && typeof R.apply === 'function'
1548
+ ? R.apply
1549
+ : function ReflectApply(target, receiver, args) {
1550
+ return Function.prototype.apply.call(target, receiver, args);
2008
1551
  }
2009
- }; // Duck-checks if an object looks like a promise
2010
1552
 
2011
- function isPromise(result) {
2012
- return exports._.isObject(result) && typeof result.then === 'function';
1553
+ var ReflectOwnKeys
1554
+ if (R && typeof R.ownKeys === 'function') {
1555
+ ReflectOwnKeys = R.ownKeys
1556
+ } else if (Object.getOwnPropertySymbols) {
1557
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
1558
+ return Object.getOwnPropertyNames(target)
1559
+ .concat(Object.getOwnPropertySymbols(target));
1560
+ };
1561
+ } else {
1562
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
1563
+ return Object.getOwnPropertyNames(target);
1564
+ };
2013
1565
  }
2014
1566
 
2015
- exports.isPromise = isPromise;
2016
-
2017
- function makeUrl(path) {
2018
- var app = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2019
- var get = typeof app.get === 'function' ? app.get.bind(app) : function () {};
2020
- var env = get('env') || "development";
2021
- var host = get('host') || process.env.HOST_NAME || 'localhost';
2022
- var protocol = env === 'development' || env === 'test' || env === undefined ? 'http' : 'https';
2023
- var PORT = get('port') || process.env.PORT || 3030;
2024
- var port = env === 'development' || env === 'test' || env === undefined ? ":".concat(PORT) : '';
2025
- path = path || '';
2026
- return "".concat(protocol, "://").concat(host).concat(port, "/").concat(exports.stripSlashes(path));
1567
+ function ProcessEmitWarning(warning) {
1568
+ if (console && console.warn) console.warn(warning);
2027
1569
  }
2028
1570
 
2029
- exports.makeUrl = makeUrl;
2030
-
2031
- function createSymbol(name) {
2032
- return typeof Symbol !== 'undefined' ? Symbol(name) : name;
1571
+ var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
1572
+ return value !== value;
2033
1573
  }
2034
1574
 
2035
- exports.createSymbol = createSymbol;
2036
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/process/browser.js */ "../../node_modules/process/browser.js")))
2037
-
2038
- /***/ }),
2039
-
2040
- /***/ "../feathers/lib/application.js":
2041
- /*!**************************************!*\
2042
- !*** ../feathers/lib/application.js ***!
2043
- \**************************************/
2044
- /*! no static exports found */
2045
- /***/ (function(module, exports, __webpack_require__) {
2046
-
2047
- var debug = __webpack_require__(/*! debug */ "../../node_modules/debug/src/browser.js")('feathers:application');
2048
-
2049
- var _require = __webpack_require__(/*! @feathersjs/commons */ "../commons/lib/index.js"),
2050
- stripSlashes = _require.stripSlashes;
1575
+ function EventEmitter() {
1576
+ EventEmitter.init.call(this);
1577
+ }
1578
+ module.exports = EventEmitter;
1579
+ module.exports.once = once;
2051
1580
 
2052
- var Uberproto = __webpack_require__(/*! uberproto */ "../../node_modules/uberproto/lib/proto.js");
1581
+ // Backwards-compat with node 0.10.x
1582
+ EventEmitter.EventEmitter = EventEmitter;
2053
1583
 
2054
- var events = __webpack_require__(/*! ./events */ "../feathers/lib/events.js");
1584
+ EventEmitter.prototype._events = undefined;
1585
+ EventEmitter.prototype._eventsCount = 0;
1586
+ EventEmitter.prototype._maxListeners = undefined;
2055
1587
 
2056
- var hooks = __webpack_require__(/*! ./hooks */ "../feathers/lib/hooks/index.js");
1588
+ // By default EventEmitters will print a warning if more than 10 listeners are
1589
+ // added to it. This is a useful default which helps finding memory leaks.
1590
+ var defaultMaxListeners = 10;
2057
1591
 
2058
- var version = __webpack_require__(/*! ./version */ "../feathers/lib/version.js");
1592
+ function checkListener(listener) {
1593
+ if (typeof listener !== 'function') {
1594
+ throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
1595
+ }
1596
+ }
2059
1597
 
2060
- var Proto = Uberproto.extend({
2061
- create: null
2062
- });
2063
- var application = {
2064
- init: function init() {
2065
- Object.assign(this, {
2066
- version: version,
2067
- methods: ['find', 'get', 'create', 'update', 'patch', 'remove'],
2068
- mixins: [],
2069
- services: {},
2070
- providers: [],
2071
- _setup: false,
2072
- settings: {}
2073
- });
2074
- this.configure(hooks());
2075
- this.configure(events());
2076
- },
2077
- get: function get(name) {
2078
- return this.settings[name];
2079
- },
2080
- set: function set(name, value) {
2081
- this.settings[name] = value;
2082
- return this;
2083
- },
2084
- disable: function disable(name) {
2085
- this.settings[name] = false;
2086
- return this;
2087
- },
2088
- disabled: function disabled(name) {
2089
- return !this.settings[name];
2090
- },
2091
- enable: function enable(name) {
2092
- this.settings[name] = true;
2093
- return this;
2094
- },
2095
- enabled: function enabled(name) {
2096
- return !!this.settings[name];
2097
- },
2098
- configure: function configure(fn) {
2099
- fn.call(this, this);
2100
- return this;
1598
+ Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
1599
+ enumerable: true,
1600
+ get: function() {
1601
+ return defaultMaxListeners;
2101
1602
  },
2102
- service: function service(path, _service) {
2103
- if (typeof _service !== 'undefined') {
2104
- throw new Error('Registering a new service with `app.service(path, service)` is no longer supported. Use `app.use(path, service)` instead.');
1603
+ set: function(arg) {
1604
+ if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
1605
+ throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
2105
1606
  }
1607
+ defaultMaxListeners = arg;
1608
+ }
1609
+ });
2106
1610
 
2107
- var location = stripSlashes(path) || '/';
2108
- var current = this.services[location];
1611
+ EventEmitter.init = function() {
2109
1612
 
2110
- if (typeof current === 'undefined' && typeof this.defaultService === 'function') {
2111
- return this.use(location, this.defaultService(location)).service(location);
2112
- }
1613
+ if (this._events === undefined ||
1614
+ this._events === Object.getPrototypeOf(this)._events) {
1615
+ this._events = Object.create(null);
1616
+ this._eventsCount = 0;
1617
+ }
2113
1618
 
2114
- return current;
2115
- },
2116
- use: function use(path, service) {
2117
- var _this = this;
1619
+ this._maxListeners = this._maxListeners || undefined;
1620
+ };
2118
1621
 
2119
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1622
+ // Obviously not all Emitters should be limited to 10. This function allows
1623
+ // that to be increased. Set to zero for unlimited.
1624
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
1625
+ if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
1626
+ throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
1627
+ }
1628
+ this._maxListeners = n;
1629
+ return this;
1630
+ };
2120
1631
 
2121
- if (typeof path !== 'string') {
2122
- throw new Error("'".concat(path, "' is not a valid service path."));
2123
- }
1632
+ function _getMaxListeners(that) {
1633
+ if (that._maxListeners === undefined)
1634
+ return EventEmitter.defaultMaxListeners;
1635
+ return that._maxListeners;
1636
+ }
2124
1637
 
2125
- var location = stripSlashes(path) || '/';
2126
- var isSubApp = typeof service.service === 'function' && service.services;
2127
- var isService = this.methods.concat('setup').some(function (name) {
2128
- return typeof service[name] === 'function';
2129
- });
1638
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
1639
+ return _getMaxListeners(this);
1640
+ };
2130
1641
 
2131
- if (isSubApp) {
2132
- var subApp = service;
2133
- Object.keys(subApp.services).forEach(function (subPath) {
2134
- return _this.use("".concat(location, "/").concat(subPath), subApp.service(subPath));
2135
- });
2136
- return this;
1642
+ EventEmitter.prototype.emit = function emit(type) {
1643
+ var args = [];
1644
+ for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
1645
+ var doError = (type === 'error');
1646
+
1647
+ var events = this._events;
1648
+ if (events !== undefined)
1649
+ doError = (doError && events.error === undefined);
1650
+ else if (!doError)
1651
+ return false;
1652
+
1653
+ // If there is no 'error' event listener then throw.
1654
+ if (doError) {
1655
+ var er;
1656
+ if (args.length > 0)
1657
+ er = args[0];
1658
+ if (er instanceof Error) {
1659
+ // Note: The comments on the `throw` lines are intentional, they show
1660
+ // up in Node's output if this results in an unhandled exception.
1661
+ throw er; // Unhandled 'error' event
2137
1662
  }
1663
+ // At least give some kind of context to the user
1664
+ var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
1665
+ err.context = er;
1666
+ throw err; // Unhandled 'error' event
1667
+ }
2138
1668
 
2139
- if (!isService) {
2140
- throw new Error("Invalid service object passed for path `".concat(location, "`"));
2141
- } // If the service is already Uberproto'd use it directly
1669
+ var handler = events[type];
2142
1670
 
1671
+ if (handler === undefined)
1672
+ return false;
2143
1673
 
2144
- var protoService = Proto.isPrototypeOf(service) ? service : Proto.extend(service);
2145
- debug("Registering new service at `".concat(location, "`")); // Add all the mixins
1674
+ if (typeof handler === 'function') {
1675
+ ReflectApply(handler, this, args);
1676
+ } else {
1677
+ var len = handler.length;
1678
+ var listeners = arrayClone(handler, len);
1679
+ for (var i = 0; i < len; ++i)
1680
+ ReflectApply(listeners[i], this, args);
1681
+ }
2146
1682
 
2147
- this.mixins.forEach(function (fn) {
2148
- return fn.call(_this, protoService, location, options);
2149
- });
1683
+ return true;
1684
+ };
2150
1685
 
2151
- if (typeof protoService._setup === 'function') {
2152
- protoService._setup(this, location);
2153
- } // Run the provider functions to register the service
1686
+ function _addListener(target, type, listener, prepend) {
1687
+ var m;
1688
+ var events;
1689
+ var existing;
2154
1690
 
1691
+ checkListener(listener);
2155
1692
 
2156
- this.providers.forEach(function (provider) {
2157
- return provider.call(_this, protoService, location, options);
2158
- }); // If we ran setup already, set this service up explicitly
1693
+ events = target._events;
1694
+ if (events === undefined) {
1695
+ events = target._events = Object.create(null);
1696
+ target._eventsCount = 0;
1697
+ } else {
1698
+ // To avoid recursion in the case that type === "newListener"! Before
1699
+ // adding it to the listeners, first emit "newListener".
1700
+ if (events.newListener !== undefined) {
1701
+ target.emit('newListener', type,
1702
+ listener.listener ? listener.listener : listener);
2159
1703
 
2160
- if (this._isSetup && typeof protoService.setup === 'function') {
2161
- debug("Setting up service for `".concat(location, "`"));
2162
- protoService.setup(this, location);
1704
+ // Re-assign `events` because a newListener handler could have caused the
1705
+ // this._events to be assigned to a new object
1706
+ events = target._events;
2163
1707
  }
1708
+ existing = events[type];
1709
+ }
2164
1710
 
2165
- this.services[location] = protoService;
2166
- return this;
2167
- },
2168
- setup: function setup() {
2169
- var _this2 = this;
2170
-
2171
- // Setup each service (pass the app so that they can look up other services etc.)
2172
- Object.keys(this.services).forEach(function (path) {
2173
- var service = _this2.services[path];
2174
- debug("Setting up service for `".concat(path, "`"));
1711
+ if (existing === undefined) {
1712
+ // Optimize the case of one listener. Don't need the extra array object.
1713
+ existing = events[type] = listener;
1714
+ ++target._eventsCount;
1715
+ } else {
1716
+ if (typeof existing === 'function') {
1717
+ // Adding the second element, need to change to array.
1718
+ existing = events[type] =
1719
+ prepend ? [listener, existing] : [existing, listener];
1720
+ // If we've already got an array, just append.
1721
+ } else if (prepend) {
1722
+ existing.unshift(listener);
1723
+ } else {
1724
+ existing.push(listener);
1725
+ }
2175
1726
 
2176
- if (typeof service.setup === 'function') {
2177
- service.setup(_this2, path);
2178
- }
2179
- });
2180
- this._isSetup = true;
2181
- return this;
1727
+ // Check for listener leak
1728
+ m = _getMaxListeners(target);
1729
+ if (m > 0 && existing.length > m && !existing.warned) {
1730
+ existing.warned = true;
1731
+ // No error code for this since it is a Warning
1732
+ // eslint-disable-next-line no-restricted-syntax
1733
+ var w = new Error('Possible EventEmitter memory leak detected. ' +
1734
+ existing.length + ' ' + String(type) + ' listeners ' +
1735
+ 'added. Use emitter.setMaxListeners() to ' +
1736
+ 'increase limit');
1737
+ w.name = 'MaxListenersExceededWarning';
1738
+ w.emitter = target;
1739
+ w.type = type;
1740
+ w.count = existing.length;
1741
+ ProcessEmitWarning(w);
1742
+ }
2182
1743
  }
2183
- };
2184
- module.exports = application;
2185
-
2186
- /***/ }),
2187
1744
 
2188
- /***/ "../feathers/lib/events.js":
2189
- /*!*********************************!*\
2190
- !*** ../feathers/lib/events.js ***!
2191
- \*********************************/
2192
- /*! no static exports found */
2193
- /***/ (function(module, exports, __webpack_require__) {
1745
+ return target;
1746
+ }
2194
1747
 
2195
- var _require = __webpack_require__(/*! events */ "../../node_modules/events/events.js"),
2196
- EventEmitter = _require.EventEmitter;
1748
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
1749
+ return _addListener(this, type, listener, false);
1750
+ };
2197
1751
 
2198
- var Proto = __webpack_require__(/*! uberproto */ "../../node_modules/uberproto/lib/proto.js"); // Returns a hook that emits service events. Should always be
2199
- // used as the very last hook in the chain
1752
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
2200
1753
 
1754
+ EventEmitter.prototype.prependListener =
1755
+ function prependListener(type, listener) {
1756
+ return _addListener(this, type, listener, true);
1757
+ };
2201
1758
 
2202
- var eventHook = exports.eventHook = function eventHook() {
2203
- return function (hook) {
2204
- var app = hook.app,
2205
- service = hook.service;
2206
- var eventName = hook.event === null ? hook.event : app.eventMappings[hook.method];
2207
- var isHookEvent = service._hookEvents && service._hookEvents.indexOf(eventName) !== -1; // If this event is not being sent yet and we are not in an error hook
1759
+ function onceWrapper() {
1760
+ if (!this.fired) {
1761
+ this.target.removeListener(this.type, this.wrapFn);
1762
+ this.fired = true;
1763
+ if (arguments.length === 0)
1764
+ return this.listener.call(this.target);
1765
+ return this.listener.apply(this.target, arguments);
1766
+ }
1767
+ }
2208
1768
 
2209
- if (eventName && isHookEvent && hook.type !== 'error') {
2210
- var results = Array.isArray(hook.result) ? hook.result : [hook.result];
2211
- results.forEach(function (element) {
2212
- return service.emit(eventName, element, hook);
2213
- });
2214
- }
2215
- };
2216
- }; // Mixin that turns a service into a Node event emitter
1769
+ function _onceWrap(target, type, listener) {
1770
+ var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
1771
+ var wrapped = onceWrapper.bind(state);
1772
+ wrapped.listener = listener;
1773
+ state.wrapFn = wrapped;
1774
+ return wrapped;
1775
+ }
2217
1776
 
1777
+ EventEmitter.prototype.once = function once(type, listener) {
1778
+ checkListener(listener);
1779
+ this.on(type, _onceWrap(this, type, listener));
1780
+ return this;
1781
+ };
2218
1782
 
2219
- var eventMixin = exports.eventMixin = function eventMixin(service) {
2220
- if (service._serviceEvents) {
2221
- return;
2222
- }
1783
+ EventEmitter.prototype.prependOnceListener =
1784
+ function prependOnceListener(type, listener) {
1785
+ checkListener(listener);
1786
+ this.prependListener(type, _onceWrap(this, type, listener));
1787
+ return this;
1788
+ };
2223
1789
 
2224
- var app = this; // Indicates if the service is already an event emitter
1790
+ // Emits a 'removeListener' event if and only if the listener was removed.
1791
+ EventEmitter.prototype.removeListener =
1792
+ function removeListener(type, listener) {
1793
+ var list, events, position, i, originalListener;
2225
1794
 
2226
- var isEmitter = typeof service.on === 'function' && typeof service.emit === 'function'; // If not, mix it in (the service is always an Uberproto object that has a .mixin)
1795
+ checkListener(listener);
2227
1796
 
2228
- if (typeof service.mixin === 'function' && !isEmitter) {
2229
- service.mixin(EventEmitter.prototype);
2230
- } // Define non-enumerable properties of
1797
+ events = this._events;
1798
+ if (events === undefined)
1799
+ return this;
2231
1800
 
1801
+ list = events[type];
1802
+ if (list === undefined)
1803
+ return this;
2232
1804
 
2233
- Object.defineProperties(service, {
2234
- // A list of all events that this service sends
2235
- _serviceEvents: {
2236
- value: Array.isArray(service.events) ? service.events.slice() : []
2237
- },
2238
- // A list of events that should be handled through the event hooks
2239
- _hookEvents: {
2240
- value: []
2241
- }
2242
- }); // `app.eventMappings` has the mapping from method name to event name
1805
+ if (list === listener || list.listener === listener) {
1806
+ if (--this._eventsCount === 0)
1807
+ this._events = Object.create(null);
1808
+ else {
1809
+ delete events[type];
1810
+ if (events.removeListener)
1811
+ this.emit('removeListener', type, list.listener || listener);
1812
+ }
1813
+ } else if (typeof list !== 'function') {
1814
+ position = -1;
2243
1815
 
2244
- Object.keys(app.eventMappings).forEach(function (method) {
2245
- var event = app.eventMappings[method];
2246
- var alreadyEmits = service._serviceEvents.indexOf(event) !== -1; // Add events for known methods to _serviceEvents and _hookEvents
2247
- // if the service indicated it does not send it itself yet
1816
+ for (i = list.length - 1; i >= 0; i--) {
1817
+ if (list[i] === listener || list[i].listener === listener) {
1818
+ originalListener = list[i].listener;
1819
+ position = i;
1820
+ break;
1821
+ }
1822
+ }
2248
1823
 
2249
- if (typeof service[method] === 'function' && !alreadyEmits) {
2250
- service._serviceEvents.push(event);
1824
+ if (position < 0)
1825
+ return this;
2251
1826
 
2252
- service._hookEvents.push(event);
2253
- }
2254
- });
2255
- };
1827
+ if (position === 0)
1828
+ list.shift();
1829
+ else {
1830
+ spliceOne(list, position);
1831
+ }
2256
1832
 
2257
- module.exports = function () {
2258
- return function (app) {
2259
- // Mappings from service method to event name
2260
- Object.assign(app, {
2261
- eventMappings: {
2262
- create: 'created',
2263
- update: 'updated',
2264
- remove: 'removed',
2265
- patch: 'patched'
1833
+ if (list.length === 1)
1834
+ events[type] = list[0];
1835
+
1836
+ if (events.removeListener !== undefined)
1837
+ this.emit('removeListener', type, originalListener || listener);
2266
1838
  }
2267
- }); // Register the event hook
2268
- // `finally` hooks always run last after `error` and `after` hooks
2269
1839
 
2270
- app.hooks({
2271
- finally: eventHook()
2272
- }); // Make the app an event emitter
1840
+ return this;
1841
+ };
2273
1842
 
2274
- Proto.mixin(EventEmitter.prototype, app);
2275
- app.mixins.push(eventMixin);
2276
- };
2277
- };
1843
+ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
2278
1844
 
2279
- /***/ }),
1845
+ EventEmitter.prototype.removeAllListeners =
1846
+ function removeAllListeners(type) {
1847
+ var listeners, events, i;
2280
1848
 
2281
- /***/ "../feathers/lib/hooks/base.js":
2282
- /*!*************************************!*\
2283
- !*** ../feathers/lib/hooks/base.js ***!
2284
- \*************************************/
2285
- /*! no static exports found */
2286
- /***/ (function(module, exports, __webpack_require__) {
1849
+ events = this._events;
1850
+ if (events === undefined)
1851
+ return this;
2287
1852
 
2288
- var _require = __webpack_require__(/*! @feathersjs/commons */ "../commons/lib/index.js"),
2289
- _ = _require._;
1853
+ // not listening for removeListener, no need to emit
1854
+ if (events.removeListener === undefined) {
1855
+ if (arguments.length === 0) {
1856
+ this._events = Object.create(null);
1857
+ this._eventsCount = 0;
1858
+ } else if (events[type] !== undefined) {
1859
+ if (--this._eventsCount === 0)
1860
+ this._events = Object.create(null);
1861
+ else
1862
+ delete events[type];
1863
+ }
1864
+ return this;
1865
+ }
2290
1866
 
2291
- var assignArguments = function assignArguments(context) {
2292
- var service = context.service,
2293
- method = context.method;
2294
- var parameters = service.methods[method];
2295
- context.arguments.forEach(function (value, index) {
2296
- context[parameters[index]] = value;
2297
- });
1867
+ // emit removeListener for all listeners on all events
1868
+ if (arguments.length === 0) {
1869
+ var keys = Object.keys(events);
1870
+ var key;
1871
+ for (i = 0; i < keys.length; ++i) {
1872
+ key = keys[i];
1873
+ if (key === 'removeListener') continue;
1874
+ this.removeAllListeners(key);
1875
+ }
1876
+ this.removeAllListeners('removeListener');
1877
+ this._events = Object.create(null);
1878
+ this._eventsCount = 0;
1879
+ return this;
1880
+ }
2298
1881
 
2299
- if (!context.params) {
2300
- context.params = {};
2301
- }
1882
+ listeners = events[type];
2302
1883
 
2303
- return context;
2304
- };
1884
+ if (typeof listeners === 'function') {
1885
+ this.removeListener(type, listeners);
1886
+ } else if (listeners !== undefined) {
1887
+ // LIFO order
1888
+ for (i = listeners.length - 1; i >= 0; i--) {
1889
+ this.removeListener(type, listeners[i]);
1890
+ }
1891
+ }
2305
1892
 
2306
- var validate = function validate(context) {
2307
- var service = context.service,
2308
- method = context.method,
2309
- path = context.path;
2310
- var parameters = service.methods[method];
1893
+ return this;
1894
+ };
2311
1895
 
2312
- if (parameters.includes('id') && context.id === undefined) {
2313
- throw new Error("An id must be provided to the '".concat(path, ".").concat(method, "' method"));
2314
- }
1896
+ function _listeners(target, type, unwrap) {
1897
+ var events = target._events;
2315
1898
 
2316
- if (parameters.includes('data') && !_.isObjectOrArray(context.data)) {
2317
- throw new Error("A data object must be provided to the '".concat(path, ".").concat(method, "' method"));
2318
- }
1899
+ if (events === undefined)
1900
+ return [];
2319
1901
 
2320
- return context;
1902
+ var evlistener = events[type];
1903
+ if (evlistener === undefined)
1904
+ return [];
1905
+
1906
+ if (typeof evlistener === 'function')
1907
+ return unwrap ? [evlistener.listener || evlistener] : [evlistener];
1908
+
1909
+ return unwrap ?
1910
+ unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
1911
+ }
1912
+
1913
+ EventEmitter.prototype.listeners = function listeners(type) {
1914
+ return _listeners(this, type, true);
2321
1915
  };
2322
1916
 
2323
- module.exports = [assignArguments, validate];
1917
+ EventEmitter.prototype.rawListeners = function rawListeners(type) {
1918
+ return _listeners(this, type, false);
1919
+ };
2324
1920
 
2325
- /***/ }),
1921
+ EventEmitter.listenerCount = function(emitter, type) {
1922
+ if (typeof emitter.listenerCount === 'function') {
1923
+ return emitter.listenerCount(type);
1924
+ } else {
1925
+ return listenerCount.call(emitter, type);
1926
+ }
1927
+ };
2326
1928
 
2327
- /***/ "../feathers/lib/hooks/index.js":
2328
- /*!**************************************!*\
2329
- !*** ../feathers/lib/hooks/index.js ***!
2330
- \**************************************/
2331
- /*! no static exports found */
2332
- /***/ (function(module, exports, __webpack_require__) {
1929
+ EventEmitter.prototype.listenerCount = listenerCount;
1930
+ function listenerCount(type) {
1931
+ var events = this._events;
2333
1932
 
2334
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1933
+ if (events !== undefined) {
1934
+ var evlistener = events[type];
2335
1935
 
2336
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1936
+ if (typeof evlistener === 'function') {
1937
+ return 1;
1938
+ } else if (evlistener !== undefined) {
1939
+ return evlistener.length;
1940
+ }
1941
+ }
2337
1942
 
2338
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1943
+ return 0;
1944
+ }
2339
1945
 
2340
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
1946
+ EventEmitter.prototype.eventNames = function eventNames() {
1947
+ return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
1948
+ };
2341
1949
 
2342
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
1950
+ function arrayClone(arr, n) {
1951
+ var copy = new Array(n);
1952
+ for (var i = 0; i < n; ++i)
1953
+ copy[i] = arr[i];
1954
+ return copy;
1955
+ }
2343
1956
 
2344
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1957
+ function spliceOne(list, index) {
1958
+ for (; index + 1 < list.length; index++)
1959
+ list[index] = list[index + 1];
1960
+ list.pop();
1961
+ }
2345
1962
 
2346
- var _require = __webpack_require__(/*! @feathersjs/commons */ "../commons/lib/index.js"),
2347
- hooks = _require.hooks,
2348
- isPromise = _require.isPromise;
1963
+ function unwrapListeners(arr) {
1964
+ var ret = new Array(arr.length);
1965
+ for (var i = 0; i < ret.length; ++i) {
1966
+ ret[i] = arr[i].listener || arr[i];
1967
+ }
1968
+ return ret;
1969
+ }
2349
1970
 
2350
- var baseHooks = __webpack_require__(/*! ./base */ "../feathers/lib/hooks/base.js");
1971
+ function once(emitter, name) {
1972
+ return new Promise(function (resolve, reject) {
1973
+ function errorListener(err) {
1974
+ emitter.removeListener(name, resolver);
1975
+ reject(err);
1976
+ }
2351
1977
 
2352
- var createHookObject = hooks.createHookObject,
2353
- getHooks = hooks.getHooks,
2354
- processHooks = hooks.processHooks,
2355
- enableHooks = hooks.enableHooks,
2356
- ACTIVATE_HOOKS = hooks.ACTIVATE_HOOKS;
1978
+ function resolver() {
1979
+ if (typeof emitter.removeListener === 'function') {
1980
+ emitter.removeListener('error', errorListener);
1981
+ }
1982
+ resolve([].slice.call(arguments));
1983
+ };
2357
1984
 
2358
- var withHooks = function withHooks(_ref) {
2359
- var app = _ref.app,
2360
- service = _ref.service,
2361
- method = _ref.method,
2362
- original = _ref.original;
2363
- return function () {
2364
- var _hooks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1985
+ eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
1986
+ if (name !== 'error') {
1987
+ addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
1988
+ }
1989
+ });
1990
+ }
2365
1991
 
2366
- var hooks = app.hookTypes.reduce(function (result, type) {
2367
- var value = _hooks[type] || [];
2368
- result[type] = Array.isArray(value) ? value : [value];
2369
- return result;
2370
- }, {});
2371
- return function () {
2372
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2373
- args[_key] = arguments[_key];
1992
+ function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
1993
+ if (typeof emitter.on === 'function') {
1994
+ eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
1995
+ }
1996
+ }
1997
+
1998
+ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
1999
+ if (typeof emitter.on === 'function') {
2000
+ if (flags.once) {
2001
+ emitter.once(name, listener);
2002
+ } else {
2003
+ emitter.on(name, listener);
2004
+ }
2005
+ } else if (typeof emitter.addEventListener === 'function') {
2006
+ // EventTarget does not have `error` event semantics like Node
2007
+ // EventEmitters, we do not listen for `error` events here.
2008
+ emitter.addEventListener(name, function wrapListener(arg) {
2009
+ // IE does not have builtin `{ once: true }` support so we
2010
+ // have to do it manually.
2011
+ if (flags.once) {
2012
+ emitter.removeEventListener(name, wrapListener);
2374
2013
  }
2014
+ listener(arg);
2015
+ });
2016
+ } else {
2017
+ throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
2018
+ }
2019
+ }
2375
2020
 
2376
- var returnHook = args[args.length - 1] === true ? args.pop() : false; // Create the hook object that gets passed through
2377
2021
 
2378
- var hookObject = createHookObject(method, {
2379
- type: 'before',
2380
- // initial hook object type
2381
- arguments: args,
2382
- service: service,
2383
- app: app
2384
- });
2385
- return Promise.resolve(hookObject) // Run `before` hooks
2386
- .then(function (hookObject) {
2387
- return processHooks.call(service, baseHooks.concat(hooks.before), hookObject);
2388
- }) // Run the original method
2389
- .then(function (hookObject) {
2390
- // If `hookObject.result` is set, skip the original method
2391
- if (typeof hookObject.result !== 'undefined') {
2392
- return hookObject;
2393
- } // Otherwise, call it with arguments created from the hook object
2022
+ /***/ }),
2394
2023
 
2024
+ /***/ "../../node_modules/ms/index.js":
2025
+ /*!**************************************!*\
2026
+ !*** ../../node_modules/ms/index.js ***!
2027
+ \**************************************/
2028
+ /***/ (function(module) {
2395
2029
 
2396
- var promise = new Promise(function (resolve) {
2397
- var func = original || service[method];
2398
- var args = service.methods[method].map(function (value) {
2399
- return hookObject[value];
2400
- });
2401
- var result = func.apply(service, args);
2030
+ /**
2031
+ * Helpers.
2032
+ */
2402
2033
 
2403
- if (!isPromise(result)) {
2404
- throw new Error("Service method '".concat(hookObject.method, "' for '").concat(hookObject.path, "' service must return a promise"));
2405
- }
2034
+ var s = 1000;
2035
+ var m = s * 60;
2036
+ var h = m * 60;
2037
+ var d = h * 24;
2038
+ var w = d * 7;
2039
+ var y = d * 365.25;
2406
2040
 
2407
- resolve(result);
2408
- });
2409
- return promise.then(function (result) {
2410
- hookObject.result = result;
2411
- return hookObject;
2412
- }).catch(function (error) {
2413
- error.hook = hookObject;
2414
- throw error;
2415
- });
2416
- }) // Run `after` hooks
2417
- .then(function (hookObject) {
2418
- var afterHookObject = Object.assign({}, hookObject, {
2419
- type: 'after'
2420
- });
2421
- return processHooks.call(service, hooks.after, afterHookObject);
2422
- }) // Run `errors` hooks
2423
- .catch(function (error) {
2424
- var errorHookObject = Object.assign({}, error.hook, {
2425
- type: 'error',
2426
- original: error.hook,
2427
- error: error,
2428
- result: undefined
2429
- });
2430
- return processHooks.call(service, hooks.error, errorHookObject).catch(function (error) {
2431
- var errorHookObject = Object.assign({}, error.hook, {
2432
- error: error,
2433
- result: undefined
2434
- });
2435
- return errorHookObject;
2436
- });
2437
- }) // Run `finally` hooks
2438
- .then(function (hookObject) {
2439
- return processHooks.call(service, hooks.finally, hookObject).catch(function (error) {
2440
- var errorHookObject = Object.assign({}, error.hook, {
2441
- error: error,
2442
- result: undefined
2443
- });
2444
- return errorHookObject;
2445
- });
2446
- }) // Resolve with a result or reject with an error
2447
- .then(function (hookObject) {
2448
- if (typeof hookObject.error !== 'undefined' && typeof hookObject.result === 'undefined') {
2449
- return Promise.reject(returnHook ? hookObject : hookObject.error);
2450
- } else {
2451
- return returnHook ? hookObject : hookObject.result;
2452
- }
2453
- });
2454
- };
2455
- };
2456
- }; // A service mixin that adds `service.hooks()` method and functionality
2041
+ /**
2042
+ * Parse or format the given `val`.
2043
+ *
2044
+ * Options:
2045
+ *
2046
+ * - `long` verbose formatting [false]
2047
+ *
2048
+ * @param {String|Number} val
2049
+ * @param {Object} [options]
2050
+ * @throws {Error} throw an error if val is not a non-empty string or a number
2051
+ * @return {String|Number}
2052
+ * @api public
2053
+ */
2457
2054
 
2055
+ module.exports = function(val, options) {
2056
+ options = options || {};
2057
+ var type = typeof val;
2058
+ if (type === 'string' && val.length > 0) {
2059
+ return parse(val);
2060
+ } else if (type === 'number' && isFinite(val)) {
2061
+ return options.long ? fmtLong(val) : fmtShort(val);
2062
+ }
2063
+ throw new Error(
2064
+ 'val is not a non-empty string or a valid number. val=' +
2065
+ JSON.stringify(val)
2066
+ );
2067
+ };
2458
2068
 
2459
- var hookMixin = exports.hookMixin = function hookMixin(service) {
2460
- if (typeof service.hooks === 'function') {
2069
+ /**
2070
+ * Parse the given `str` and return milliseconds.
2071
+ *
2072
+ * @param {String} str
2073
+ * @return {Number}
2074
+ * @api private
2075
+ */
2076
+
2077
+ function parse(str) {
2078
+ str = String(str);
2079
+ if (str.length > 100) {
2461
2080
  return;
2462
2081
  }
2082
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
2083
+ str
2084
+ );
2085
+ if (!match) {
2086
+ return;
2087
+ }
2088
+ var n = parseFloat(match[1]);
2089
+ var type = (match[2] || 'ms').toLowerCase();
2090
+ switch (type) {
2091
+ case 'years':
2092
+ case 'year':
2093
+ case 'yrs':
2094
+ case 'yr':
2095
+ case 'y':
2096
+ return n * y;
2097
+ case 'weeks':
2098
+ case 'week':
2099
+ case 'w':
2100
+ return n * w;
2101
+ case 'days':
2102
+ case 'day':
2103
+ case 'd':
2104
+ return n * d;
2105
+ case 'hours':
2106
+ case 'hour':
2107
+ case 'hrs':
2108
+ case 'hr':
2109
+ case 'h':
2110
+ return n * h;
2111
+ case 'minutes':
2112
+ case 'minute':
2113
+ case 'mins':
2114
+ case 'min':
2115
+ case 'm':
2116
+ return n * m;
2117
+ case 'seconds':
2118
+ case 'second':
2119
+ case 'secs':
2120
+ case 'sec':
2121
+ case 's':
2122
+ return n * s;
2123
+ case 'milliseconds':
2124
+ case 'millisecond':
2125
+ case 'msecs':
2126
+ case 'msec':
2127
+ case 'ms':
2128
+ return n;
2129
+ default:
2130
+ return undefined;
2131
+ }
2132
+ }
2463
2133
 
2464
- service.methods = Object.getOwnPropertyNames(service).filter(function (key) {
2465
- return typeof service[key] === 'function' && service[key][ACTIVATE_HOOKS];
2466
- }).reduce(function (result, methodName) {
2467
- result[methodName] = service[methodName][ACTIVATE_HOOKS];
2468
- return result;
2469
- }, service.methods || {});
2470
- Object.assign(service.methods, {
2471
- find: ['params'],
2472
- get: ['id', 'params'],
2473
- create: ['data', 'params'],
2474
- update: ['id', 'data', 'params'],
2475
- patch: ['id', 'data', 'params'],
2476
- remove: ['id', 'params']
2477
- });
2478
- var app = this;
2479
- var methodNames = Object.keys(service.methods); // Assemble the mixin object that contains all "hooked" service methods
2134
+ /**
2135
+ * Short format for `ms`.
2136
+ *
2137
+ * @param {Number} ms
2138
+ * @return {String}
2139
+ * @api private
2140
+ */
2141
+
2142
+ function fmtShort(ms) {
2143
+ var msAbs = Math.abs(ms);
2144
+ if (msAbs >= d) {
2145
+ return Math.round(ms / d) + 'd';
2146
+ }
2147
+ if (msAbs >= h) {
2148
+ return Math.round(ms / h) + 'h';
2149
+ }
2150
+ if (msAbs >= m) {
2151
+ return Math.round(ms / m) + 'm';
2152
+ }
2153
+ if (msAbs >= s) {
2154
+ return Math.round(ms / s) + 's';
2155
+ }
2156
+ return ms + 'ms';
2157
+ }
2480
2158
 
2481
- var mixin = methodNames.reduce(function (mixin, method) {
2482
- if (typeof service[method] !== 'function') {
2483
- return mixin;
2484
- }
2159
+ /**
2160
+ * Long format for `ms`.
2161
+ *
2162
+ * @param {Number} ms
2163
+ * @return {String}
2164
+ * @api private
2165
+ */
2485
2166
 
2486
- mixin[method] = function () {
2487
- var service = this;
2488
- var args = Array.from(arguments);
2167
+ function fmtLong(ms) {
2168
+ var msAbs = Math.abs(ms);
2169
+ if (msAbs >= d) {
2170
+ return plural(ms, msAbs, d, 'day');
2171
+ }
2172
+ if (msAbs >= h) {
2173
+ return plural(ms, msAbs, h, 'hour');
2174
+ }
2175
+ if (msAbs >= m) {
2176
+ return plural(ms, msAbs, m, 'minute');
2177
+ }
2178
+ if (msAbs >= s) {
2179
+ return plural(ms, msAbs, s, 'second');
2180
+ }
2181
+ return ms + ' ms';
2182
+ }
2489
2183
 
2490
- var original = service._super.bind(service);
2184
+ /**
2185
+ * Pluralization helper.
2186
+ */
2491
2187
 
2492
- return withHooks({
2493
- app: app,
2494
- service: service,
2495
- method: method,
2496
- original: original
2497
- })({
2498
- before: getHooks(app, service, 'before', method),
2499
- after: getHooks(app, service, 'after', method, true),
2500
- error: getHooks(app, service, 'error', method, true),
2501
- finally: getHooks(app, service, 'finally', method, true)
2502
- }).apply(void 0, _toConsumableArray(args));
2503
- };
2188
+ function plural(ms, msAbs, n, name) {
2189
+ var isPlural = msAbs >= n * 1.5;
2190
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
2191
+ }
2504
2192
 
2505
- return mixin;
2506
- }, {}); // Add .hooks method and properties to the service
2507
2193
 
2508
- enableHooks(service, methodNames, app.hookTypes);
2509
- service.mixin(mixin);
2510
- };
2194
+ /***/ }),
2511
2195
 
2512
- module.exports = function () {
2513
- return function (app) {
2514
- // We store a reference of all supported hook types on the app
2515
- // in case someone needs it
2516
- Object.assign(app, {
2517
- hookTypes: ['before', 'after', 'error', 'finally']
2518
- }); // Add functionality for hooks to be registered as app.hooks
2196
+ /***/ "../../node_modules/uberproto/lib/proto.js":
2197
+ /*!*************************************************!*\
2198
+ !*** ../../node_modules/uberproto/lib/proto.js ***!
2199
+ \*************************************************/
2200
+ /***/ (function(module, exports) {
2519
2201
 
2520
- enableHooks(app, app.methods, app.hookTypes);
2521
- app.mixins.push(hookMixin);
2522
- };
2523
- };
2202
+ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* global define */
2203
+ /**
2204
+ * Uberproto
2205
+ *
2206
+ * A base object for ECMAScript 5 style prototypal inheritance.
2207
+ *
2208
+ * @see https://github.com/rauschma/proto-js/
2209
+ * @see http://ejohn.org/blog/simple-javascript-inheritance/
2210
+ * @see http://uxebu.com/blog/2011/02/23/object-based-inheritance-for-ecmascript-5/
2211
+ */
2212
+ (function (root, factory) {
2213
+ if (true) {
2214
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
2215
+ __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
2216
+ (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
2217
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
2218
+ } else {}
2219
+ }(this, function () {
2220
+ var HAS_SYMBOLS = typeof Object.getOwnPropertySymbols === 'function';
2524
2221
 
2525
- module.exports.withHooks = withHooks;
2526
- module.exports.ACTIVATE_HOOKS = ACTIVATE_HOOKS;
2222
+ function makeSuper (_super, old, name, fn) {
2223
+ var isFunction = typeof old === 'function';
2224
+ var newMethod = function () {
2225
+ var tmp = this._super;
2527
2226
 
2528
- module.exports.activateHooks = function activateHooks(args) {
2529
- return function (fn) {
2530
- Object.defineProperty(fn, ACTIVATE_HOOKS, {
2531
- value: args
2532
- });
2533
- return fn;
2534
- };
2535
- };
2227
+ // Add a new ._super() method that is the same method
2228
+ // but either pointing to the prototype method
2229
+ // or to the overwritten method
2230
+ this._super = isFunction ? old : _super[name];
2536
2231
 
2537
- /***/ }),
2232
+ // The method only need to be bound temporarily, so we
2233
+ // remove it when we're done executing
2234
+ var ret = fn.apply(this, arguments);
2538
2235
 
2539
- /***/ "../feathers/lib/index.js":
2540
- /*!********************************!*\
2541
- !*** ../feathers/lib/index.js ***!
2542
- \********************************/
2543
- /*! no static exports found */
2544
- /***/ (function(module, exports, __webpack_require__) {
2236
+ this._super = tmp;
2545
2237
 
2546
- var Proto = __webpack_require__(/*! uberproto */ "../../node_modules/uberproto/lib/proto.js");
2238
+ return ret;
2239
+ };
2547
2240
 
2548
- var Application = __webpack_require__(/*! ./application */ "../feathers/lib/application.js");
2241
+ if (isFunction) {
2242
+ Object.keys(old).forEach(function (name) {
2243
+ newMethod[name] = old[name];
2244
+ });
2549
2245
 
2550
- var version = __webpack_require__(/*! ./version */ "../feathers/lib/version.js");
2246
+ if (HAS_SYMBOLS) {
2247
+ Object.getOwnPropertySymbols(old).forEach(function (name) {
2248
+ newMethod[name] = old[name];
2249
+ });
2250
+ }
2251
+ }
2551
2252
 
2552
- var _require = __webpack_require__(/*! ./hooks */ "../feathers/lib/hooks/index.js"),
2553
- ACTIVATE_HOOKS = _require.ACTIVATE_HOOKS,
2554
- activateHooks = _require.activateHooks; // A base object Prototype that does not inherit from a
2555
- // potentially polluted Object prototype
2253
+ return newMethod;
2254
+ }
2556
2255
 
2256
+ return {
2257
+ /**
2258
+ * Create a new object using Object.create. The arguments will be
2259
+ * passed to the new instances init method or to a method name set in
2260
+ * __init.
2261
+ */
2262
+ create: function () {
2263
+ var instance = Object.create(this);
2264
+ var init = typeof instance.__init === 'string' ? instance.__init : 'init';
2557
2265
 
2558
- var baseObject = Object.create(null);
2266
+ if (typeof instance[init] === 'function') {
2267
+ instance[init].apply(instance, arguments);
2268
+ }
2269
+ return instance;
2270
+ },
2271
+ /**
2272
+ * Mixin a given set of properties
2273
+ * @param prop The properties to mix in
2274
+ * @param obj [optional]
2275
+ * The object to add the mixin
2276
+ */
2277
+ mixin: function (prop, obj) {
2278
+ var self = obj || this;
2279
+ var fnTest = /\b_super\b/;
2280
+ var _super = Object.getPrototypeOf(self) || self.prototype;
2281
+ var descriptors = {};
2282
+ var proto = prop;
2283
+ var processProperty = function (name) {
2284
+ var descriptor = Object.getOwnPropertyDescriptor(proto, name);
2559
2285
 
2560
- function createApplication() {
2561
- var app = Object.create(baseObject); // Mix in the base application
2286
+ if (!descriptors[name] && descriptor) {
2287
+ descriptors[name] = descriptor;
2288
+ }
2289
+ };
2562
2290
 
2563
- Proto.mixin(Application, app);
2564
- app.init();
2565
- return app;
2566
- }
2291
+ // Collect all property descriptors
2292
+ do {
2293
+ Object.getOwnPropertyNames(proto).forEach(processProperty);
2567
2294
 
2568
- createApplication.version = version;
2569
- createApplication.ACTIVATE_HOOKS = ACTIVATE_HOOKS;
2570
- createApplication.activateHooks = activateHooks;
2571
- module.exports = createApplication; // For better ES module (TypeScript) compatibility
2295
+ if (HAS_SYMBOLS) {
2296
+ Object.getOwnPropertySymbols(proto).forEach(processProperty);
2297
+ }
2298
+ } while ((proto = Object.getPrototypeOf(proto)) && Object.getPrototypeOf(proto));
2572
2299
 
2573
- module.exports.default = createApplication;
2300
+ var processDescriptor = function (name) {
2301
+ var descriptor = descriptors[name];
2574
2302
 
2575
- /***/ }),
2303
+ if (typeof descriptor.value === 'function' && fnTest.test(descriptor.value)) {
2304
+ descriptor.value = makeSuper(_super, self[name], name, descriptor.value);
2305
+ }
2576
2306
 
2577
- /***/ "../feathers/lib/version.js":
2578
- /*!**********************************!*\
2579
- !*** ../feathers/lib/version.js ***!
2580
- \**********************************/
2581
- /*! no static exports found */
2582
- /***/ (function(module, exports) {
2307
+ Object.defineProperty(self, name, descriptor);
2308
+ };
2583
2309
 
2584
- module.exports = '4.5.9';
2310
+ Object.keys(descriptors).forEach(processDescriptor);
2585
2311
 
2586
- /***/ }),
2312
+ if (HAS_SYMBOLS) {
2313
+ Object.getOwnPropertySymbols(descriptors).forEach(processDescriptor);
2314
+ }
2587
2315
 
2588
- /***/ "./src/core.js":
2589
- /*!*********************!*\
2590
- !*** ./src/core.js ***!
2591
- \*********************/
2592
- /*! no static exports found */
2593
- /***/ (function(module, exports, __webpack_require__) {
2316
+ return self;
2317
+ },
2318
+ /**
2319
+ * Extend the current or a given object with the given property and return the extended object.
2320
+ * @param prop The properties to extend with
2321
+ * @param obj [optional] The object to extend from
2322
+ * @returns The extended object
2323
+ */
2324
+ extend: function (prop, obj) {
2325
+ return this.mixin(prop, Object.create(obj || this));
2326
+ },
2327
+ /**
2328
+ * Return a callback function with this set to the current or a given context object.
2329
+ * @param name Name of the method to proxy
2330
+ * @param args... [optional] Arguments to use for partial application
2331
+ */
2332
+ proxy: function (name) {
2333
+ var fn = this[name];
2334
+ var args = Array.prototype.slice.call(arguments, 1);
2335
+
2336
+ args.unshift(this);
2337
+ return fn.bind.apply(fn, args);
2338
+ }
2339
+ };
2340
+ }));
2594
2341
 
2595
- module.exports = __webpack_require__(/*! @feathersjs/feathers */ "../feathers/lib/index.js");
2596
2342
 
2597
2343
  /***/ })
2598
2344
 
2599
- /******/ });
2345
+ /******/ });
2346
+ /************************************************************************/
2347
+ /******/ // The module cache
2348
+ /******/ var __webpack_module_cache__ = {};
2349
+ /******/
2350
+ /******/ // The require function
2351
+ /******/ function __webpack_require__(moduleId) {
2352
+ /******/ // Check if module is in cache
2353
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
2354
+ /******/ if (cachedModule !== undefined) {
2355
+ /******/ return cachedModule.exports;
2356
+ /******/ }
2357
+ /******/ // Create a new module (and put it into the cache)
2358
+ /******/ var module = __webpack_module_cache__[moduleId] = {
2359
+ /******/ // no module.id needed
2360
+ /******/ // no module.loaded needed
2361
+ /******/ exports: {}
2362
+ /******/ };
2363
+ /******/
2364
+ /******/ // Execute the module function
2365
+ /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
2366
+ /******/
2367
+ /******/ // Return the exports of the module
2368
+ /******/ return module.exports;
2369
+ /******/ }
2370
+ /******/
2371
+ /************************************************************************/
2372
+ /******/
2373
+ /******/ // startup
2374
+ /******/ // Load entry module and return exports
2375
+ /******/ // This entry module used 'module' so it can't be inlined
2376
+ /******/ var __webpack_exports__ = __webpack_require__("./src/core.js");
2377
+ /******/
2378
+ /******/ return __webpack_exports__;
2379
+ /******/ })()
2380
+ ;
2600
2381
  });
2601
2382
  //# sourceMappingURL=core.js.map