@feathersjs/client 5.0.0-pre.10 → 5.0.0-pre.16
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/CHANGELOG.md +51 -0
- package/dist/core.js +240 -148
- package/dist/core.js.map +1 -1
- package/dist/core.min.js +1 -1
- package/dist/feathers.js +385 -222
- package/dist/feathers.js.map +1 -1
- package/dist/feathers.min.js +1 -1
- package/package.json +20 -20
package/dist/core.js
CHANGED
|
@@ -20,9 +20,9 @@ return /******/ (function() { // webpackBootstrap
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
23
|
+
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); }
|
|
24
24
|
|
|
25
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
25
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
26
26
|
|
|
27
27
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
28
28
|
|
|
@@ -38,7 +38,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
38
38
|
|
|
39
39
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
40
40
|
|
|
41
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
41
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
42
42
|
|
|
43
43
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
44
44
|
|
|
@@ -54,7 +54,7 @@ exports.HOOKS = Symbol('@feathersjs/hooks');
|
|
|
54
54
|
* The base hook context.
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
|
-
var BaseHookContext = function BaseHookContext() {
|
|
57
|
+
var BaseHookContext = /*#__PURE__*/_createClass(function BaseHookContext() {
|
|
58
58
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
59
59
|
|
|
60
60
|
_classCallCheck(this, BaseHookContext);
|
|
@@ -66,7 +66,7 @@ var BaseHookContext = function BaseHookContext() {
|
|
|
66
66
|
value: void 0
|
|
67
67
|
});
|
|
68
68
|
Object.assign(this, data);
|
|
69
|
-
};
|
|
69
|
+
});
|
|
70
70
|
|
|
71
71
|
exports.BaseHookContext = BaseHookContext;
|
|
72
72
|
|
|
@@ -229,7 +229,7 @@ var HookManager = /*#__PURE__*/function () {
|
|
|
229
229
|
return _this;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
return ContextClass;
|
|
232
|
+
return _createClass(ContextClass);
|
|
233
233
|
}(Base);
|
|
234
234
|
|
|
235
235
|
var params = this.getParams();
|
|
@@ -812,7 +812,7 @@ exports.createDebug = createDebug;
|
|
|
812
812
|
|
|
813
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; }
|
|
814
814
|
|
|
815
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
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); }
|
|
816
816
|
|
|
817
817
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
818
818
|
|
|
@@ -986,7 +986,7 @@ __exportStar(__webpack_require__(/*! ./debug */ "../commons/lib/debug.js"), expo
|
|
|
986
986
|
|
|
987
987
|
|
|
988
988
|
|
|
989
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
989
|
+
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); }
|
|
990
990
|
|
|
991
991
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
992
992
|
|
|
@@ -1008,9 +1008,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
1008
1008
|
|
|
1009
1009
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1010
1010
|
|
|
1011
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
1011
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
1012
1012
|
|
|
1013
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
1013
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
1014
1014
|
|
|
1015
1015
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
1016
1016
|
|
|
@@ -1045,7 +1045,7 @@ var index_1 = __webpack_require__(/*! ./hooks/index */ "../feathers/lib/hooks/in
|
|
|
1045
1045
|
|
|
1046
1046
|
var service_1 = __webpack_require__(/*! ./service */ "../feathers/lib/service.js");
|
|
1047
1047
|
|
|
1048
|
-
var
|
|
1048
|
+
var regular_1 = __webpack_require__(/*! ./hooks/regular */ "../feathers/lib/hooks/regular.js");
|
|
1049
1049
|
|
|
1050
1050
|
var debug = (0, dependencies_1.createDebug)('@feathersjs/feathers');
|
|
1051
1051
|
|
|
@@ -1066,7 +1066,7 @@ var Feathers = /*#__PURE__*/function (_dependencies_1$Event) {
|
|
|
1066
1066
|
_this.version = version_1.default;
|
|
1067
1067
|
_this._isSetup = false;
|
|
1068
1068
|
_this.appHooks = _defineProperty({}, dependencies_1.HOOKS, [events_1.eventHook]);
|
|
1069
|
-
_this.
|
|
1069
|
+
_this.regularHooks = (0, regular_1.enableRegularHooks)(_assertThisInitialized(_this));
|
|
1070
1070
|
return _this;
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
@@ -1126,7 +1126,7 @@ var Feathers = /*#__PURE__*/function (_dependencies_1$Event) {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
|
|
1128
1128
|
var protoService = (0, service_1.wrapService)(location, service, options);
|
|
1129
|
-
var serviceOptions = (0, service_1.getServiceOptions)(
|
|
1129
|
+
var serviceOptions = (0, service_1.getServiceOptions)(protoService);
|
|
1130
1130
|
|
|
1131
1131
|
var _iterator = _createForOfIteratorHelper(service_1.protectedMethods),
|
|
1132
1132
|
_step;
|
|
@@ -1164,10 +1164,10 @@ var Feathers = /*#__PURE__*/function (_dependencies_1$Event) {
|
|
|
1164
1164
|
value: function hooks(hookMap) {
|
|
1165
1165
|
var _this3 = this;
|
|
1166
1166
|
|
|
1167
|
-
var
|
|
1167
|
+
var regularMap = hookMap;
|
|
1168
1168
|
|
|
1169
|
-
if (
|
|
1170
|
-
return this.
|
|
1169
|
+
if (regularMap.before || regularMap.after || regularMap.error) {
|
|
1170
|
+
return this.regularHooks(regularMap);
|
|
1171
1171
|
}
|
|
1172
1172
|
|
|
1173
1173
|
if (Array.isArray(hookMap)) {
|
|
@@ -1341,7 +1341,7 @@ exports.eventMixin = eventMixin;
|
|
|
1341
1341
|
|
|
1342
1342
|
|
|
1343
1343
|
|
|
1344
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
1344
|
+
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); }
|
|
1345
1345
|
|
|
1346
1346
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
1347
1347
|
|
|
@@ -1359,13 +1359,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
1359
1359
|
|
|
1360
1360
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1361
1361
|
|
|
1362
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
1362
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
1363
1363
|
|
|
1364
|
-
function _get(
|
|
1364
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
1365
1365
|
|
|
1366
1366
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
1367
1367
|
|
|
1368
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
1368
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
1369
1369
|
|
|
1370
1370
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
1371
1371
|
|
|
@@ -1382,30 +1382,50 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
1382
1382
|
Object.defineProperty(exports, "__esModule", ({
|
|
1383
1383
|
value: true
|
|
1384
1384
|
}));
|
|
1385
|
-
exports.hookMixin = exports.FeathersHookManager = exports.createContext = exports.fromErrorHooks = exports.
|
|
1385
|
+
exports.hookMixin = exports.FeathersHookManager = exports.createContext = exports.fromErrorHooks = exports.fromErrorHook = exports.fromAfterHooks = exports.fromAfterHook = exports.fromBeforeHooks = exports.fromBeforeHook = void 0;
|
|
1386
1386
|
|
|
1387
1387
|
var dependencies_1 = __webpack_require__(/*! ../dependencies */ "../feathers/lib/dependencies.js");
|
|
1388
1388
|
|
|
1389
1389
|
var service_1 = __webpack_require__(/*! ../service */ "../feathers/lib/service.js");
|
|
1390
1390
|
|
|
1391
|
-
var
|
|
1391
|
+
var regular_1 = __webpack_require__(/*! ./regular */ "../feathers/lib/hooks/regular.js");
|
|
1392
1392
|
|
|
1393
|
+
var regular_2 = __webpack_require__(/*! ./regular */ "../feathers/lib/hooks/regular.js");
|
|
1394
|
+
|
|
1395
|
+
Object.defineProperty(exports, "fromBeforeHook", ({
|
|
1396
|
+
enumerable: true,
|
|
1397
|
+
get: function get() {
|
|
1398
|
+
return regular_2.fromBeforeHook;
|
|
1399
|
+
}
|
|
1400
|
+
}));
|
|
1401
|
+
Object.defineProperty(exports, "fromBeforeHooks", ({
|
|
1402
|
+
enumerable: true,
|
|
1403
|
+
get: function get() {
|
|
1404
|
+
return regular_2.fromBeforeHooks;
|
|
1405
|
+
}
|
|
1406
|
+
}));
|
|
1393
1407
|
Object.defineProperty(exports, "fromAfterHook", ({
|
|
1394
1408
|
enumerable: true,
|
|
1395
1409
|
get: function get() {
|
|
1396
|
-
return
|
|
1410
|
+
return regular_2.fromAfterHook;
|
|
1397
1411
|
}
|
|
1398
1412
|
}));
|
|
1399
|
-
Object.defineProperty(exports, "
|
|
1413
|
+
Object.defineProperty(exports, "fromAfterHooks", ({
|
|
1414
|
+
enumerable: true,
|
|
1415
|
+
get: function get() {
|
|
1416
|
+
return regular_2.fromAfterHooks;
|
|
1417
|
+
}
|
|
1418
|
+
}));
|
|
1419
|
+
Object.defineProperty(exports, "fromErrorHook", ({
|
|
1400
1420
|
enumerable: true,
|
|
1401
1421
|
get: function get() {
|
|
1402
|
-
return
|
|
1422
|
+
return regular_2.fromErrorHook;
|
|
1403
1423
|
}
|
|
1404
1424
|
}));
|
|
1405
1425
|
Object.defineProperty(exports, "fromErrorHooks", ({
|
|
1406
1426
|
enumerable: true,
|
|
1407
1427
|
get: function get() {
|
|
1408
|
-
return
|
|
1428
|
+
return regular_2.fromErrorHooks;
|
|
1409
1429
|
}
|
|
1410
1430
|
}));
|
|
1411
1431
|
|
|
@@ -1444,12 +1464,12 @@ var FeathersHookManager = /*#__PURE__*/function (_dependencies_1$HookM) {
|
|
|
1444
1464
|
value: function collectMiddleware(self, args) {
|
|
1445
1465
|
var app = this.app;
|
|
1446
1466
|
var appHooks = app.appHooks[dependencies_1.HOOKS].concat(app.appHooks[this.method] || []);
|
|
1447
|
-
var
|
|
1467
|
+
var regularAppHooks = (0, regular_1.collectRegularHooks)(this.app, this.method);
|
|
1448
1468
|
|
|
1449
1469
|
var middleware = _get(_getPrototypeOf(FeathersHookManager.prototype), "collectMiddleware", this).call(this, self, args);
|
|
1450
1470
|
|
|
1451
|
-
var
|
|
1452
|
-
return [].concat(_toConsumableArray(appHooks), _toConsumableArray(
|
|
1471
|
+
var regularHooks = (0, regular_1.collectRegularHooks)(self, this.method);
|
|
1472
|
+
return [].concat(_toConsumableArray(appHooks), _toConsumableArray(regularAppHooks), _toConsumableArray(middleware), _toConsumableArray(regularHooks));
|
|
1453
1473
|
}
|
|
1454
1474
|
}, {
|
|
1455
1475
|
key: "initializeContext",
|
|
@@ -1481,7 +1501,8 @@ function hookMixin(service, path, options) {
|
|
|
1481
1501
|
}
|
|
1482
1502
|
|
|
1483
1503
|
var app = this;
|
|
1484
|
-
var
|
|
1504
|
+
var hookMethods = (0, service_1.getHookMethods)(service, options);
|
|
1505
|
+
var serviceMethodHooks = hookMethods.reduce(function (res, method) {
|
|
1485
1506
|
var _FeathersHookManager;
|
|
1486
1507
|
|
|
1487
1508
|
var params = service_1.defaultServiceArguments[method] || ['data', 'params'];
|
|
@@ -1491,18 +1512,29 @@ function hookMixin(service, path, options) {
|
|
|
1491
1512
|
method: method,
|
|
1492
1513
|
service: service,
|
|
1493
1514
|
event: null,
|
|
1494
|
-
type: null
|
|
1515
|
+
type: null,
|
|
1516
|
+
|
|
1517
|
+
get statusCode() {
|
|
1518
|
+
var _a;
|
|
1519
|
+
|
|
1520
|
+
return (_a = this.http) === null || _a === void 0 ? void 0 : _a.statusCode;
|
|
1521
|
+
},
|
|
1522
|
+
|
|
1523
|
+
set statusCode(value) {
|
|
1524
|
+
(this.http || (this.http = {})).statusCode = value;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1495
1527
|
});
|
|
1496
1528
|
return res;
|
|
1497
1529
|
}, {});
|
|
1498
|
-
var
|
|
1530
|
+
var handleRegularHooks = (0, regular_1.enableRegularHooks)(service, hookMethods);
|
|
1499
1531
|
(0, dependencies_1.hooks)(service, serviceMethodHooks);
|
|
1500
1532
|
|
|
1501
1533
|
service.hooks = function (hookOptions) {
|
|
1502
1534
|
var _this2 = this;
|
|
1503
1535
|
|
|
1504
1536
|
if (hookOptions.before || hookOptions.after || hookOptions.error) {
|
|
1505
|
-
return
|
|
1537
|
+
return handleRegularHooks.call(this, hookOptions);
|
|
1506
1538
|
}
|
|
1507
1539
|
|
|
1508
1540
|
if (Array.isArray(hookOptions)) {
|
|
@@ -1528,16 +1560,14 @@ exports.hookMixin = hookMixin;
|
|
|
1528
1560
|
|
|
1529
1561
|
/***/ }),
|
|
1530
1562
|
|
|
1531
|
-
/***/ "../feathers/lib/hooks/
|
|
1532
|
-
|
|
1533
|
-
!*** ../feathers/lib/hooks/
|
|
1534
|
-
|
|
1563
|
+
/***/ "../feathers/lib/hooks/regular.js":
|
|
1564
|
+
/*!****************************************!*\
|
|
1565
|
+
!*** ../feathers/lib/hooks/regular.js ***!
|
|
1566
|
+
\****************************************/
|
|
1535
1567
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1536
1568
|
|
|
1537
1569
|
|
|
1538
1570
|
|
|
1539
|
-
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); }
|
|
1540
|
-
|
|
1541
1571
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
1542
1572
|
|
|
1543
1573
|
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."); }
|
|
@@ -1552,28 +1582,35 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
1552
1582
|
|
|
1553
1583
|
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; }
|
|
1554
1584
|
|
|
1555
|
-
function
|
|
1585
|
+
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); }
|
|
1556
1586
|
|
|
1557
|
-
function
|
|
1587
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1588
|
+
|
|
1589
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1558
1590
|
|
|
1559
1591
|
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; }
|
|
1560
1592
|
|
|
1561
1593
|
Object.defineProperty(exports, "__esModule", ({
|
|
1562
1594
|
value: true
|
|
1563
1595
|
}));
|
|
1564
|
-
exports.
|
|
1596
|
+
exports.enableRegularHooks = exports.convertHookData = exports.collectRegularHooks = exports.fromErrorHooks = exports.fromAfterHooks = exports.fromBeforeHooks = exports.fromErrorHook = exports.fromAfterHook = exports.fromBeforeHook = void 0;
|
|
1565
1597
|
|
|
1566
|
-
var
|
|
1598
|
+
var service_1 = __webpack_require__(/*! ../service */ "../feathers/lib/service.js");
|
|
1567
1599
|
|
|
1568
|
-
var
|
|
1600
|
+
var runHook = function runHook(hook, context, type) {
|
|
1601
|
+
if (type) context.type = type;
|
|
1602
|
+
return Promise.resolve(hook.call(context.self, context)).then(function (res) {
|
|
1603
|
+
if (type) context.type = null;
|
|
1604
|
+
|
|
1605
|
+
if (res && res !== context) {
|
|
1606
|
+
Object.assign(context, res);
|
|
1607
|
+
}
|
|
1608
|
+
});
|
|
1609
|
+
};
|
|
1569
1610
|
|
|
1570
1611
|
function fromBeforeHook(hook) {
|
|
1571
1612
|
return function (context, next) {
|
|
1572
|
-
context
|
|
1573
|
-
return Promise.resolve(hook.call(context.self, context)).then(function () {
|
|
1574
|
-
context.type = null;
|
|
1575
|
-
return next();
|
|
1576
|
-
});
|
|
1613
|
+
return runHook(hook, context, 'before').then(next);
|
|
1577
1614
|
};
|
|
1578
1615
|
}
|
|
1579
1616
|
|
|
@@ -1582,49 +1619,24 @@ exports.fromBeforeHook = fromBeforeHook;
|
|
|
1582
1619
|
function fromAfterHook(hook) {
|
|
1583
1620
|
return function (context, next) {
|
|
1584
1621
|
return next().then(function () {
|
|
1585
|
-
context
|
|
1586
|
-
return hook.call(context.self, context);
|
|
1587
|
-
}).then(function () {
|
|
1588
|
-
context.type = null;
|
|
1622
|
+
return runHook(hook, context, 'after');
|
|
1589
1623
|
});
|
|
1590
1624
|
};
|
|
1591
1625
|
}
|
|
1592
1626
|
|
|
1593
1627
|
exports.fromAfterHook = fromAfterHook;
|
|
1594
1628
|
|
|
1595
|
-
function
|
|
1629
|
+
function fromErrorHook(hook) {
|
|
1596
1630
|
return function (context, next) {
|
|
1597
1631
|
return next().catch(function (error) {
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
delete context.result;
|
|
1603
|
-
|
|
1604
|
-
var _iterator = _createForOfIteratorHelper(hooks),
|
|
1605
|
-
_step;
|
|
1606
|
-
|
|
1607
|
-
try {
|
|
1608
|
-
var _loop = function _loop() {
|
|
1609
|
-
var hook = _step.value;
|
|
1610
|
-
promise = promise.then(function () {
|
|
1611
|
-
return hook.call(context.self, context);
|
|
1612
|
-
});
|
|
1613
|
-
};
|
|
1614
|
-
|
|
1615
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1616
|
-
_loop();
|
|
1617
|
-
}
|
|
1618
|
-
} catch (err) {
|
|
1619
|
-
_iterator.e(err);
|
|
1620
|
-
} finally {
|
|
1621
|
-
_iterator.f();
|
|
1632
|
+
if (context.error !== error || context.result !== undefined) {
|
|
1633
|
+
context.original = _objectSpread({}, context);
|
|
1634
|
+
context.error = error;
|
|
1635
|
+
delete context.result;
|
|
1622
1636
|
}
|
|
1623
1637
|
|
|
1624
|
-
return
|
|
1625
|
-
context.
|
|
1626
|
-
|
|
1627
|
-
if (context.result === undefined) {
|
|
1638
|
+
return runHook(hook, context, 'error').then(function () {
|
|
1639
|
+
if (context.result === undefined && context.error !== undefined) {
|
|
1628
1640
|
throw context.error;
|
|
1629
1641
|
}
|
|
1630
1642
|
});
|
|
@@ -1632,99 +1644,179 @@ function fromErrorHooks(hooks) {
|
|
|
1632
1644
|
};
|
|
1633
1645
|
}
|
|
1634
1646
|
|
|
1635
|
-
exports.
|
|
1647
|
+
exports.fromErrorHook = fromErrorHook;
|
|
1636
1648
|
|
|
1637
|
-
function
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1649
|
+
var RunHooks = function RunHooks(hooks) {
|
|
1650
|
+
return function (context) {
|
|
1651
|
+
return hooks.reduce(function (promise, hook) {
|
|
1652
|
+
return promise.then(function () {
|
|
1653
|
+
return runHook(hook, context);
|
|
1654
|
+
});
|
|
1655
|
+
}, Promise.resolve(undefined));
|
|
1656
|
+
};
|
|
1657
|
+
};
|
|
1658
|
+
|
|
1659
|
+
function fromBeforeHooks(hooks) {
|
|
1660
|
+
return fromBeforeHook(RunHooks(hooks));
|
|
1661
|
+
}
|
|
1646
1662
|
|
|
1647
|
-
|
|
1663
|
+
exports.fromBeforeHooks = fromBeforeHooks;
|
|
1648
1664
|
|
|
1649
|
-
|
|
1650
|
-
return
|
|
1665
|
+
function fromAfterHooks(hooks) {
|
|
1666
|
+
return fromAfterHook(RunHooks(hooks));
|
|
1651
1667
|
}
|
|
1652
1668
|
|
|
1653
|
-
exports.
|
|
1669
|
+
exports.fromAfterHooks = fromAfterHooks;
|
|
1670
|
+
|
|
1671
|
+
function fromErrorHooks(hooks) {
|
|
1672
|
+
return fromErrorHook(RunHooks(hooks));
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
exports.fromErrorHooks = fromErrorHooks;
|
|
1676
|
+
|
|
1677
|
+
function collectRegularHooks(target, method) {
|
|
1678
|
+
return target.__hooks.hooks[method] || [];
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
exports.collectRegularHooks = collectRegularHooks; // Converts different hook registration formats into the
|
|
1654
1682
|
// same internal format
|
|
1655
1683
|
|
|
1656
|
-
function convertHookData(
|
|
1657
|
-
var
|
|
1684
|
+
function convertHookData(input) {
|
|
1685
|
+
var result = {};
|
|
1658
1686
|
|
|
1659
|
-
if (Array.isArray(
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
} else if (_typeof(obj) !== 'object') {
|
|
1664
|
-
hook = {
|
|
1665
|
-
all: [obj]
|
|
1666
|
-
};
|
|
1687
|
+
if (Array.isArray(input)) {
|
|
1688
|
+
result.all = input;
|
|
1689
|
+
} else if (_typeof(input) !== 'object') {
|
|
1690
|
+
result.all = [input];
|
|
1667
1691
|
} else {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1692
|
+
for (var _i = 0, _Object$keys = Object.keys(input); _i < _Object$keys.length; _i++) {
|
|
1693
|
+
var key = _Object$keys[_i];
|
|
1694
|
+
var value = input[key];
|
|
1695
|
+
result[key] = Array.isArray(value) ? value : [value];
|
|
1696
|
+
}
|
|
1671
1697
|
}
|
|
1672
1698
|
|
|
1673
|
-
return
|
|
1699
|
+
return result;
|
|
1674
1700
|
}
|
|
1675
1701
|
|
|
1676
|
-
exports.convertHookData = convertHookData;
|
|
1702
|
+
exports.convertHookData = convertHookData;
|
|
1703
|
+
var types = ['before', 'after', 'error'];
|
|
1704
|
+
|
|
1705
|
+
var isType = function isType(value) {
|
|
1706
|
+
return types.includes(value);
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
var wrappers = {
|
|
1710
|
+
before: fromBeforeHooks,
|
|
1711
|
+
after: fromAfterHooks,
|
|
1712
|
+
error: fromErrorHooks
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
var createStore = function createStore(methods) {
|
|
1716
|
+
var store = {
|
|
1717
|
+
before: {},
|
|
1718
|
+
after: {},
|
|
1719
|
+
error: {},
|
|
1720
|
+
hooks: {}
|
|
1721
|
+
};
|
|
1677
1722
|
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1723
|
+
var _iterator = _createForOfIteratorHelper(methods),
|
|
1724
|
+
_step;
|
|
1725
|
+
|
|
1726
|
+
try {
|
|
1727
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1728
|
+
var method = _step.value;
|
|
1729
|
+
store.hooks[method] = [];
|
|
1730
|
+
}
|
|
1731
|
+
} catch (err) {
|
|
1732
|
+
_iterator.e(err);
|
|
1733
|
+
} finally {
|
|
1734
|
+
_iterator.f();
|
|
1735
|
+
}
|
|
1686
1736
|
|
|
1687
|
-
|
|
1737
|
+
return store;
|
|
1738
|
+
};
|
|
1739
|
+
|
|
1740
|
+
var setStore = function setStore(object, store) {
|
|
1741
|
+
Object.defineProperty(object, '__hooks', {
|
|
1688
1742
|
configurable: true,
|
|
1689
|
-
value:
|
|
1743
|
+
value: store,
|
|
1690
1744
|
writable: true
|
|
1691
1745
|
});
|
|
1692
|
-
|
|
1693
|
-
|
|
1746
|
+
};
|
|
1747
|
+
|
|
1748
|
+
var getStore = function getStore(object) {
|
|
1749
|
+
return object.__hooks;
|
|
1750
|
+
};
|
|
1751
|
+
|
|
1752
|
+
var createMap = function createMap(input, methods) {
|
|
1753
|
+
var map = {};
|
|
1754
|
+
Object.keys(input).forEach(function (type) {
|
|
1755
|
+
if (!isType(type)) {
|
|
1756
|
+
throw new Error("'".concat(type, "' is not a valid hook type"));
|
|
1757
|
+
}
|
|
1694
1758
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1759
|
+
var data = convertHookData(input[type]);
|
|
1760
|
+
Object.keys(data).forEach(function (method) {
|
|
1761
|
+
if (method !== 'all' && !methods.includes(method)) {
|
|
1762
|
+
throw new Error("'".concat(method, "' is not a valid hook method"));
|
|
1698
1763
|
}
|
|
1764
|
+
});
|
|
1765
|
+
map[type] = data;
|
|
1766
|
+
});
|
|
1767
|
+
return map;
|
|
1768
|
+
};
|
|
1699
1769
|
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1770
|
+
var createAdapter = function createAdapter(type) {
|
|
1771
|
+
var hooks = [];
|
|
1772
|
+
var hook = wrappers[type](hooks);
|
|
1773
|
+
var adapter = Object.assign(hook, {
|
|
1774
|
+
hooks: hooks
|
|
1775
|
+
});
|
|
1776
|
+
return adapter;
|
|
1777
|
+
};
|
|
1708
1778
|
|
|
1709
|
-
|
|
1710
|
-
|
|
1779
|
+
var updateStore = function updateStore(store, map) {
|
|
1780
|
+
Object.keys(store.hooks).forEach(function (method) {
|
|
1781
|
+
var adapted = false;
|
|
1782
|
+
Object.keys(map).forEach(function (key) {
|
|
1783
|
+
var _a;
|
|
1711
1784
|
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1785
|
+
var type = key;
|
|
1786
|
+
var allHooks = map[type].all || [];
|
|
1787
|
+
var methodHooks = map[type][method] || [];
|
|
1715
1788
|
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
}
|
|
1789
|
+
if (allHooks.length || methodHooks.length) {
|
|
1790
|
+
var _adapter$hooks;
|
|
1719
1791
|
|
|
1720
|
-
(
|
|
1721
|
-
|
|
1792
|
+
var adapter = (_a = store[type])[method] || (_a[method] = (adapted = true, createAdapter(type)));
|
|
1793
|
+
|
|
1794
|
+
(_adapter$hooks = adapter.hooks).push.apply(_adapter$hooks, _toConsumableArray(allHooks).concat(_toConsumableArray(methodHooks)));
|
|
1795
|
+
}
|
|
1722
1796
|
});
|
|
1797
|
+
|
|
1798
|
+
if (adapted) {
|
|
1799
|
+
store.hooks[method] = [store.error[method], store.before[method], store.after[method]].filter(function (hook) {
|
|
1800
|
+
return hook;
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
});
|
|
1804
|
+
}; // Add `.hooks` functionality to an object
|
|
1805
|
+
|
|
1806
|
+
|
|
1807
|
+
function enableRegularHooks(object) {
|
|
1808
|
+
var methods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : service_1.defaultServiceMethods;
|
|
1809
|
+
var store = createStore(methods);
|
|
1810
|
+
setStore(object, store);
|
|
1811
|
+
return function regularHooks(input) {
|
|
1812
|
+
var store = getStore(this);
|
|
1813
|
+
var map = createMap(input, methods);
|
|
1814
|
+
updateStore(store, map);
|
|
1723
1815
|
return this;
|
|
1724
1816
|
};
|
|
1725
1817
|
}
|
|
1726
1818
|
|
|
1727
|
-
exports.
|
|
1819
|
+
exports.enableRegularHooks = enableRegularHooks;
|
|
1728
1820
|
|
|
1729
1821
|
/***/ }),
|
|
1730
1822
|
|
|
@@ -1808,9 +1900,9 @@ if (true) {
|
|
|
1808
1900
|
|
|
1809
1901
|
|
|
1810
1902
|
|
|
1811
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1903
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1812
1904
|
|
|
1813
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
1905
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1814
1906
|
|
|
1815
1907
|
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; }
|
|
1816
1908
|
|
|
@@ -1837,7 +1929,7 @@ exports.defaultEventMap = {
|
|
|
1837
1929
|
patch: 'patched',
|
|
1838
1930
|
remove: 'removed'
|
|
1839
1931
|
};
|
|
1840
|
-
exports.protectedMethods = Object.keys(Object.prototype).concat(Object.keys(dependencies_1.EventEmitter.prototype)).concat(['before', 'after', 'error', 'hooks', 'setup', 'publish']);
|
|
1932
|
+
exports.protectedMethods = Object.keys(Object.prototype).concat(Object.keys(dependencies_1.EventEmitter.prototype)).concat(['all', 'before', 'after', 'error', 'hooks', 'setup', 'publish']);
|
|
1841
1933
|
|
|
1842
1934
|
function getHookMethods(service, options) {
|
|
1843
1935
|
var methods = options.methods;
|