@feathersjs/client 5.0.0-pre.17 → 5.0.0-pre.18

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
7
+
8
+ **Note:** Version bump only for package @feathersjs/client
9
+
10
+
11
+
12
+
13
+
6
14
  # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
7
15
 
8
16
  **Note:** Version bump only for package @feathersjs/client
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/feathersjs/feathers/workflows/CI/badge.svg)](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
4
4
  [![Download Status](https://img.shields.io/npm/dm/@feathersjs/client.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/client)
5
+ [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](https://discord.gg/qa8kez8QBx)
5
6
 
6
7
  > A client build for FeathersJS
7
8
 
package/dist/core.js CHANGED
@@ -82,12 +82,18 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
82
82
 
83
83
  var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
84
84
  if (k2 === undefined) k2 = k;
85
- Object.defineProperty(o, k2, {
86
- enumerable: true,
87
- get: function get() {
88
- return m[k];
89
- }
90
- });
85
+ var desc = Object.getOwnPropertyDescriptor(m, k);
86
+
87
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
88
+ desc = {
89
+ enumerable: true,
90
+ get: function get() {
91
+ return m[k];
92
+ }
93
+ };
94
+ }
95
+
96
+ Object.defineProperty(o, k2, desc);
91
97
  } : function (o, m, k, k2) {
92
98
  if (k2 === undefined) k2 = k;
93
99
  o[k2] = m[k];
@@ -321,6 +327,14 @@ var Feathers = /*#__PURE__*/function (_dependencies_1$Event) {
321
327
  _this._isSetup = false;
322
328
  _this.appHooks = _defineProperty({}, dependencies_1.HOOKS, [events_1.eventHook]);
323
329
  _this.regularHooks = (0, regular_1.enableRegularHooks)(_assertThisInitialized(_this));
330
+ (0, dependencies_1.hooks)(_assertThisInitialized(_this), {
331
+ setup: (0, dependencies_1.middleware)().params('server').props({
332
+ app: _assertThisInitialized(_this)
333
+ }),
334
+ teardown: (0, dependencies_1.middleware)().params('server').props({
335
+ app: _assertThisInitialized(_this)
336
+ })
337
+ });
324
338
  return _this;
325
339
  }
326
340
 
@@ -403,14 +417,14 @@ var Feathers = /*#__PURE__*/function (_dependencies_1$Event) {
403
417
 
404
418
  this.mixins.forEach(function (fn) {
405
419
  return fn.call(_this2, protoService, location, serviceOptions);
406
- }); // If we ran setup already, set this service up explicitly, this will not `await`
420
+ });
421
+ this.services[location] = protoService; // If we ran setup already, set this service up explicitly, this will not `await`
407
422
 
408
423
  if (this._isSetup && typeof protoService.setup === 'function') {
409
424
  debug("Setting up service for `".concat(location, "`"));
410
425
  protoService.setup(this, location);
411
426
  }
412
427
 
413
- this.services[location] = protoService;
414
428
  return this;
415
429
  }
416
430
  }, {
@@ -418,13 +432,13 @@ var Feathers = /*#__PURE__*/function (_dependencies_1$Event) {
418
432
  value: function hooks(hookMap) {
419
433
  var _this3 = this;
420
434
 
421
- var regularMap = hookMap;
422
-
423
- if (regularMap.before || regularMap.after || regularMap.error) {
424
- return this.regularHooks(regularMap);
425
- }
435
+ var untypedMap = hookMap;
426
436
 
427
- if (Array.isArray(hookMap)) {
437
+ if (untypedMap.before || untypedMap.after || untypedMap.error) {
438
+ this.regularHooks(untypedMap);
439
+ } else if (untypedMap.setup || untypedMap.teardown) {
440
+ (0, dependencies_1.hooks)(this, untypedMap);
441
+ } else if (Array.isArray(hookMap)) {
428
442
  var _this$appHooks$depend;
429
443
 
430
444
  (_this$appHooks$depend = this.appHooks[dependencies_1.HOOKS]).push.apply(_this$appHooks$depend, _toConsumableArray(hookMap));
@@ -443,11 +457,9 @@ var Feathers = /*#__PURE__*/function (_dependencies_1$Event) {
443
457
  value: function setup() {
444
458
  var _this4 = this;
445
459
 
446
- var promise = Promise.resolve(); // Setup each service (pass the app so that they can look up other services etc.)
447
-
448
- var _loop = function _loop() {
449
- var path = _Object$keys[_i];
450
- promise = promise.then(function () {
460
+ this._isSetup = true;
461
+ return Object.keys(this.services).reduce(function (current, path) {
462
+ return current.then(function () {
451
463
  var service = _this4.service(path);
452
464
 
453
465
  if (typeof service.setup === 'function') {
@@ -455,17 +467,29 @@ var Feathers = /*#__PURE__*/function (_dependencies_1$Event) {
455
467
  return service.setup(_this4, path);
456
468
  }
457
469
  });
458
- };
459
-
460
- for (var _i = 0, _Object$keys = Object.keys(this.services); _i < _Object$keys.length; _i++) {
461
- _loop();
462
- }
463
-
464
- return promise.then(function () {
465
- _this4._isSetup = true;
470
+ }, Promise.resolve()).then(function () {
466
471
  return _this4;
467
472
  });
468
473
  }
474
+ }, {
475
+ key: "teardown",
476
+ value: function teardown() {
477
+ var _this5 = this;
478
+
479
+ this._isSetup = false;
480
+ return Object.keys(this.services).reduce(function (current, path) {
481
+ return current.then(function () {
482
+ var service = _this5.service(path);
483
+
484
+ if (typeof service.teardown === 'function') {
485
+ debug("Tearing down service for `".concat(path, "`"));
486
+ return service.teardown(_this5, path);
487
+ }
488
+ });
489
+ }, Promise.resolve()).then(function () {
490
+ return _this5;
491
+ });
492
+ }
469
493
  }]);
470
494
 
471
495
  return Feathers;
@@ -499,12 +523,18 @@ Object.defineProperty(exports, "__esModule", ({
499
523
 
500
524
  var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
501
525
  if (k2 === undefined) k2 = k;
502
- Object.defineProperty(o, k2, {
503
- enumerable: true,
504
- get: function get() {
505
- return m[k];
506
- }
507
- });
526
+ var desc = Object.getOwnPropertyDescriptor(m, k);
527
+
528
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
529
+ desc = {
530
+ enumerable: true,
531
+ get: function get() {
532
+ return m[k];
533
+ }
534
+ };
535
+ }
536
+
537
+ Object.defineProperty(o, k2, desc);
508
538
  } : function (o, m, k, k2) {
509
539
  if (k2 === undefined) k2 = k;
510
540
  o[k2] = m[k];
@@ -771,11 +801,11 @@ function hookMixin(service, path, options) {
771
801
  get statusCode() {
772
802
  var _a;
773
803
 
774
- return (_a = this.http) === null || _a === void 0 ? void 0 : _a.statusCode;
804
+ return (_a = this.http) === null || _a === void 0 ? void 0 : _a.status;
775
805
  },
776
806
 
777
807
  set statusCode(value) {
778
- (this.http || (this.http = {})).statusCode = value;
808
+ (this.http || (this.http = {})).status = value;
779
809
  }
780
810
 
781
811
  });
@@ -1084,12 +1114,18 @@ exports.enableRegularHooks = enableRegularHooks;
1084
1114
 
1085
1115
  var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
1086
1116
  if (k2 === undefined) k2 = k;
1087
- Object.defineProperty(o, k2, {
1088
- enumerable: true,
1089
- get: function get() {
1090
- return m[k];
1091
- }
1092
- });
1117
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1118
+
1119
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1120
+ desc = {
1121
+ enumerable: true,
1122
+ get: function get() {
1123
+ return m[k];
1124
+ }
1125
+ };
1126
+ }
1127
+
1128
+ Object.defineProperty(o, k2, desc);
1093
1129
  } : function (o, m, k, k2) {
1094
1130
  if (k2 === undefined) k2 = k;
1095
1131
  o[k2] = m[k];
@@ -1183,7 +1219,7 @@ exports.defaultEventMap = {
1183
1219
  patch: 'patched',
1184
1220
  remove: 'removed'
1185
1221
  };
1186
- exports.protectedMethods = Object.keys(Object.prototype).concat(Object.keys(dependencies_1.EventEmitter.prototype)).concat(['all', 'before', 'after', 'error', 'hooks', 'setup', 'publish']);
1222
+ exports.protectedMethods = Object.keys(Object.prototype).concat(Object.keys(dependencies_1.EventEmitter.prototype)).concat(['all', 'before', 'after', 'error', 'hooks', 'setup', 'teardown', 'publish']);
1187
1223
 
1188
1224
  function getHookMethods(service, options) {
1189
1225
  var methods = options.methods;
@@ -1773,7 +1809,11 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
1773
1809
 
1774
1810
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1775
1811
  if (k2 === undefined) k2 = k;
1776
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1812
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1813
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1814
+ desc = { enumerable: true, get: function() { return m[k]; } };
1815
+ }
1816
+ Object.defineProperty(o, k2, desc);
1777
1817
  }) : (function(o, m, k, k2) {
1778
1818
  if (k2 === undefined) k2 = k;
1779
1819
  o[k2] = m[k];