@feathersjs/feathers 5.0.0-pre.14 → 5.0.0-pre.15

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,24 @@
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.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
12
+
13
+
14
+ ### Features
15
+
16
+ * **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b))
17
+ * **core:** Improve legacy hooks integration ([08c8b40](https://github.com/feathersjs/feathers/commit/08c8b40999bf3889c61a4d4fad97a2c4f78bafc9))
18
+ * **transport-commons:** Ability to register routes with custom params ([#2482](https://github.com/feathersjs/feathers/issues/2482)) ([497990a](https://github.com/feathersjs/feathers/commit/497990ae4a980e5a52a1f0f932db12cd0e6e254a))
19
+
20
+
21
+
22
+
23
+
6
24
  # [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
7
25
 
8
26
  **Note:** Version bump only for package @feathersjs/feathers
@@ -1,21 +1,21 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from './dependencies';
3
3
  import { FeathersApplication, ServiceMixin, Service, ServiceOptions, ServiceInterface, Application, HookOptions, FeathersService, HookMap } from './declarations';
4
- export declare class Feathers<ServiceTypes, AppSettings> extends EventEmitter implements FeathersApplication<ServiceTypes, AppSettings> {
5
- services: ServiceTypes;
6
- settings: AppSettings;
7
- mixins: ServiceMixin<Application<ServiceTypes, AppSettings>>[];
4
+ export declare class Feathers<Services, Settings> extends EventEmitter implements FeathersApplication<Services, Settings> {
5
+ services: Services;
6
+ settings: Settings;
7
+ mixins: ServiceMixin<Application<Services, Settings>>[];
8
8
  version: string;
9
9
  _isSetup: boolean;
10
- appHooks: HookMap<Application<ServiceTypes, AppSettings>, any>;
11
- private legacyHooks;
10
+ appHooks: HookMap<Application<Services, Settings>, any>;
11
+ private regularHooks;
12
12
  constructor();
13
- get<L extends keyof AppSettings & string>(name: L): AppSettings[L];
14
- set<L extends keyof AppSettings & string>(name: L, value: AppSettings[L]): this;
13
+ get<L extends keyof Settings & string>(name: L): Settings[L];
14
+ set<L extends keyof Settings & string>(name: L, value: Settings[L]): this;
15
15
  configure(callback: (this: this, app: this) => void): this;
16
- defaultService(location: string): ServiceInterface<any>;
17
- service<L extends keyof ServiceTypes & string>(location: L): FeathersService<this, keyof any extends keyof ServiceTypes ? Service<any> : ServiceTypes[L]>;
18
- use<L extends keyof ServiceTypes & string>(path: L, service: keyof any extends keyof ServiceTypes ? ServiceInterface<any> | Application : ServiceTypes[L], options?: ServiceOptions): this;
16
+ defaultService(location: string): ServiceInterface;
17
+ service<L extends keyof Services & string>(location: L): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>;
18
+ use<L extends keyof Services & string>(path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions): this;
19
19
  hooks(hookMap: HookOptions<this, any>): any;
20
20
  setup(): Promise<this>;
21
21
  }
@@ -9,7 +9,7 @@ const dependencies_1 = require("./dependencies");
9
9
  const events_1 = require("./events");
10
10
  const index_1 = require("./hooks/index");
11
11
  const service_1 = require("./service");
12
- const legacy_1 = require("./hooks/legacy");
12
+ const regular_1 = require("./hooks/regular");
13
13
  const debug = (0, dependencies_1.createDebug)('@feathersjs/feathers');
14
14
  class Feathers extends dependencies_1.EventEmitter {
15
15
  constructor() {
@@ -22,7 +22,7 @@ class Feathers extends dependencies_1.EventEmitter {
22
22
  this.appHooks = {
23
23
  [dependencies_1.HOOKS]: [events_1.eventHook]
24
24
  };
25
- this.legacyHooks = (0, legacy_1.enableLegacyHooks)(this);
25
+ this.regularHooks = (0, regular_1.enableRegularHooks)(this);
26
26
  }
27
27
  get(name) {
28
28
  return this.settings[name];
@@ -77,9 +77,9 @@ class Feathers extends dependencies_1.EventEmitter {
77
77
  return this;
78
78
  }
79
79
  hooks(hookMap) {
80
- const legacyMap = hookMap;
81
- if (legacyMap.before || legacyMap.after || legacyMap.error) {
82
- return this.legacyHooks(legacyMap);
80
+ const regularMap = hookMap;
81
+ if (regularMap.before || regularMap.after || regularMap.error) {
82
+ return this.regularHooks(regularMap);
83
83
  }
84
84
  if (Array.isArray(hookMap)) {
85
85
  this.appHooks[dependencies_1.HOOKS].push(...hookMap);
@@ -1 +1 @@
1
- {"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,iDAEwB;AACxB,qCAAiD;AACjD,yCAA0C;AAC1C,uCAA6E;AAa7E,2CAAmD;AAEnD,MAAM,KAAK,GAAG,IAAA,0BAAW,EAAC,sBAAsB,CAAC,CAAC;AAElD,MAAa,QAAoC,SAAQ,2BAAY;IAYnE;QACE,KAAK,EAAE,CAAC;QAZV,aAAQ,GAAkB,EAAmB,CAAC;QAC9C,aAAQ,GAAiB,EAAkB,CAAC;QAC5C,WAAM,GAA2D,CAAE,iBAAS,EAAE,mBAAU,CAAE,CAAC;QAC3F,YAAO,GAAW,iBAAO,CAAC;QAC1B,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAyD;YAC/D,CAAC,oBAAK,CAAC,EAAE,CAAG,kBAAiB,CAAE;SAChC,CAAC;QAMA,IAAI,CAAC,WAAW,GAAG,IAAA,0BAAiB,EAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,GAAG,CAAwC,IAA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AAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAEhC,iFAAiF;QACjF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC7C,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;gBAC1B,MAAM,OAAO,GAAQ,IAAI,CAAC,OAAO,CAAC,IAAW,CAAC,CAAC;gBAE/C,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU,EAAE;oBACvC,KAAK,CAAC,4BAA4B,IAAI,IAAI,CAAC,CAAC;oBAE5C,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAClC;YACH,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3ID,4BA2IC"}
@@ -13,8 +13,11 @@ export interface ServiceOptions {
13
13
  events?: string[];
14
14
  methods?: string[];
15
15
  serviceEvents?: string[];
16
+ routeParams?: {
17
+ [key: string]: any;
18
+ };
16
19
  }
17
- export interface ServiceMethods<T, D = Partial<T>> {
20
+ export interface ServiceMethods<T = any, D = Partial<T>> {
18
21
  find(params?: Params): Promise<T | T[]>;
19
22
  get(id: Id, params?: Params): Promise<T>;
20
23
  create(data: D, params?: Params): Promise<T>;
@@ -23,7 +26,7 @@ export interface ServiceMethods<T, D = Partial<T>> {
23
26
  remove(id: NullableId, params?: Params): Promise<T | T[]>;
24
27
  setup(app: Application, path: string): Promise<void>;
25
28
  }
26
- export interface ServiceOverloads<T, D> {
29
+ export interface ServiceOverloads<T = any, D = Partial<T>> {
27
30
  create?(data: D[], params?: Params): Promise<T[]>;
28
31
  update?(id: Id, data: D, params?: Params): Promise<T>;
29
32
  update?(id: null, data: D, params?: Params): Promise<T[]>;
@@ -32,9 +35,9 @@ export interface ServiceOverloads<T, D> {
32
35
  remove?(id: Id, params?: Params): Promise<T>;
33
36
  remove?(id: null, params?: Params): Promise<T[]>;
34
37
  }
35
- export declare type Service<T, D = Partial<T>> = ServiceMethods<T, D> & ServiceOverloads<T, D>;
36
- export declare type ServiceInterface<T, D = Partial<T>> = Partial<ServiceMethods<T, D>>;
37
- export interface ServiceAddons<A = Application, S = Service<any, any>> extends EventEmitter {
38
+ export declare type Service<T = any, D = Partial<T>> = ServiceMethods<T, D> & ServiceOverloads<T, D>;
39
+ export declare type ServiceInterface<T = any, D = Partial<T>> = Partial<ServiceMethods<T, D>>;
40
+ export interface ServiceAddons<A = Application, S = Service> extends EventEmitter {
38
41
  id?: string;
39
42
  hooks(options: HookOptions<A, S>): this;
40
43
  }
@@ -46,14 +49,16 @@ export interface ServiceHookOverloads<S> {
46
49
  patch(id: NullableId, data: ServiceGenericData<S>, params: Params, context: HookContext): Promise<HookContext>;
47
50
  remove(id: NullableId, params: Params, context: HookContext): Promise<HookContext>;
48
51
  }
49
- export declare type FeathersService<A = FeathersApplication, S = Service<any>> = S & ServiceAddons<A, S> & OptionalPick<ServiceHookOverloads<S>, keyof S>;
50
- export declare type CustomMethod<Methods extends string> = {
51
- [k in Methods]: <X = any>(data: any, params?: Params) => Promise<X>;
52
+ export declare type FeathersService<A = FeathersApplication, S = Service> = S & ServiceAddons<A, S> & OptionalPick<ServiceHookOverloads<S>, keyof S>;
53
+ export declare type CustomMethods<T extends {
54
+ [key: string]: [any, any];
55
+ }> = {
56
+ [K in keyof T]: (data: T[K][0], params?: Params) => Promise<T[K][1]>;
52
57
  };
53
- export declare type ServiceMixin<A> = (service: FeathersService<A>, path: string, options?: ServiceOptions) => void;
58
+ export declare type ServiceMixin<A> = (service: FeathersService<A>, path: string, options: ServiceOptions) => void;
54
59
  export declare type ServiceGenericType<S> = S extends ServiceInterface<infer T> ? T : any;
55
60
  export declare type ServiceGenericData<S> = S extends ServiceInterface<infer _T, infer D> ? D : any;
56
- export interface FeathersApplication<ServiceTypes = any, AppSettings = any> {
61
+ export interface FeathersApplication<Services = any, Settings = any> {
57
62
  /**
58
63
  * The Feathers application version
59
64
  */
@@ -61,19 +66,19 @@ export interface FeathersApplication<ServiceTypes = any, AppSettings = any> {
61
66
  /**
62
67
  * A list of callbacks that run when a new service is registered
63
68
  */
64
- mixins: ServiceMixin<Application<ServiceTypes, AppSettings>>[];
69
+ mixins: ServiceMixin<Application<Services, Settings>>[];
65
70
  /**
66
71
  * The index of all services keyed by their path.
67
72
  *
68
73
  * __Important:__ Services should always be retrieved via `app.service('name')`
69
74
  * not via `app.services`.
70
75
  */
71
- services: ServiceTypes;
76
+ services: Services;
72
77
  /**
73
78
  * The application settings that can be used via
74
79
  * `app.get` and `app.set`
75
80
  */
76
- settings: AppSettings;
81
+ settings: Settings;
77
82
  /**
78
83
  * A private-ish indicator if `app.setup()` has been called already
79
84
  */
@@ -81,20 +86,20 @@ export interface FeathersApplication<ServiceTypes = any, AppSettings = any> {
81
86
  /**
82
87
  * Contains all registered application level hooks.
83
88
  */
84
- appHooks: HookMap<Application<ServiceTypes, AppSettings>, any>;
89
+ appHooks: HookMap<Application<Services, Settings>, any>;
85
90
  /**
86
91
  * Retrieve an application setting by name
87
92
  *
88
93
  * @param name The setting name
89
94
  */
90
- get<L extends keyof AppSettings & string>(name: L): AppSettings[L];
95
+ get<L extends keyof Settings & string>(name: L): Settings[L];
91
96
  /**
92
97
  * Set an application setting
93
98
  *
94
99
  * @param name The setting name
95
100
  * @param value The setting value
96
101
  */
97
- set<L extends keyof AppSettings & string>(name: L, value: AppSettings[L]): this;
102
+ set<L extends keyof Settings & string>(name: L, value: Settings[L]): this;
98
103
  /**
99
104
  * Runs a callback configure function with the current application instance.
100
105
  *
@@ -108,7 +113,7 @@ export interface FeathersApplication<ServiceTypes = any, AppSettings = any> {
108
113
  *
109
114
  * @param location The path of the service
110
115
  */
111
- defaultService(location: string): ServiceInterface<any>;
116
+ defaultService(location: string): ServiceInterface;
112
117
  /**
113
118
  * Register a new service or a sub-app. When passed another
114
119
  * Feathers application, all its services will be re-registered
@@ -119,7 +124,7 @@ export interface FeathersApplication<ServiceTypes = any, AppSettings = any> {
119
124
  * Feathers application to use a sub-app under the `path` prefix.
120
125
  * @param options The options for this service
121
126
  */
122
- use<L extends keyof ServiceTypes & string>(path: L, service: keyof any extends keyof ServiceTypes ? ServiceInterface<any> | Application : ServiceTypes[L], options?: ServiceOptions): this;
127
+ use<L extends keyof Services & string>(path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions): this;
123
128
  /**
124
129
  * Get the Feathers service instance for a path. This will
125
130
  * be the service originally registered with Feathers functionality
@@ -127,7 +132,7 @@ export interface FeathersApplication<ServiceTypes = any, AppSettings = any> {
127
132
  *
128
133
  * @param path The name of the service.
129
134
  */
130
- service<L extends keyof ServiceTypes & string>(path: L): FeathersService<this, keyof any extends keyof ServiceTypes ? Service<any> : ServiceTypes[L]>;
135
+ service<L extends keyof Services & string>(path: L): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>;
131
136
  setup(server?: any): Promise<this>;
132
137
  /**
133
138
  * Register application level hooks.
@@ -136,7 +141,7 @@ export interface FeathersApplication<ServiceTypes = any, AppSettings = any> {
136
141
  */
137
142
  hooks(map: HookOptions<this, any>): this;
138
143
  }
139
- export interface Application<ServiceTypes = any, AppSettings = any> extends FeathersApplication<ServiceTypes, AppSettings>, EventEmitter {
144
+ export interface Application<Services = any, Settings = any> extends FeathersApplication<Services, Settings>, EventEmitter {
140
145
  }
141
146
  export declare type Id = number | string;
142
147
  export declare type NullableId = Id | null;
@@ -147,13 +152,20 @@ export interface Params {
147
152
  query?: Query;
148
153
  provider?: string;
149
154
  route?: {
150
- [key: string]: string;
155
+ [key: string]: any;
151
156
  };
152
157
  headers?: {
153
158
  [key: string]: any;
154
159
  };
155
160
  [key: string]: any;
156
161
  }
162
+ export interface Http {
163
+ /**
164
+ * A writeable, optional property that allows to override the standard HTTP status
165
+ * code that should be returned.
166
+ */
167
+ statusCode?: number;
168
+ }
157
169
  export interface HookContext<A = Application, S = any> extends BaseHookContext<ServiceGenericType<S>> {
158
170
  /**
159
171
  * A read only property that contains the Feathers application object. This can be used to
@@ -224,28 +236,34 @@ export interface HookContext<A = Application, S = any> extends BaseHookContext<S
224
236
  /**
225
237
  * A writeable, optional property that allows to override the standard HTTP status
226
238
  * code that should be returned.
239
+ *
240
+ * @deprecated Use `http.statusCode` instead.
227
241
  */
228
242
  statusCode?: number;
243
+ /**
244
+ * A writeable, optional property that contains options specific to HTTP transports.
245
+ */
246
+ http?: Http;
229
247
  /**
230
248
  * The event emitted by this method. Can be set to `null` to skip event emitting.
231
249
  */
232
250
  event: string | null;
233
251
  }
234
- export declare type LegacyHookFunction<A = Application, S = Service<any, any>> = (this: S, context: HookContext<A, S>) => (Promise<HookContext<Application, S> | void> | HookContext<Application, S> | void);
235
- export declare type Hook<A = Application, S = Service<any, any>> = LegacyHookFunction<A, S>;
236
- declare type LegacyHookMethodMap<A, S> = {
237
- [L in keyof S]?: SelfOrArray<LegacyHookFunction<A, S>>;
252
+ export declare type RegularHookFunction<A = Application, S = Service> = (this: S, context: HookContext<A, S>) => (Promise<HookContext<Application, S> | void> | HookContext<Application, S> | void);
253
+ export declare type Hook<A = Application, S = Service> = RegularHookFunction<A, S>;
254
+ declare type RegularHookMethodMap<A, S> = {
255
+ [L in keyof S]?: SelfOrArray<RegularHookFunction<A, S>>;
238
256
  } & {
239
- all?: SelfOrArray<LegacyHookFunction<A, S>>;
257
+ all?: SelfOrArray<RegularHookFunction<A, S>>;
240
258
  };
241
- declare type LegacyHookTypeMap<A, S> = SelfOrArray<LegacyHookFunction<A, S>> | LegacyHookMethodMap<A, S>;
242
- export declare type LegacyHookMap<A, S> = {
243
- before?: LegacyHookTypeMap<A, S>;
244
- after?: LegacyHookTypeMap<A, S>;
245
- error?: LegacyHookTypeMap<A, S>;
259
+ declare type RegularHookTypeMap<A, S> = SelfOrArray<RegularHookFunction<A, S>> | RegularHookMethodMap<A, S>;
260
+ export declare type RegularHookMap<A, S> = {
261
+ before?: RegularHookTypeMap<A, S>;
262
+ after?: RegularHookTypeMap<A, S>;
263
+ error?: RegularHookTypeMap<A, S>;
246
264
  };
247
- export declare type HookFunction<A = Application, S = Service<any, any>> = (context: HookContext<A, S>, next: NextFunction) => Promise<void>;
265
+ export declare type HookFunction<A = Application, S = Service> = (context: HookContext<A, S>, next: NextFunction) => Promise<void>;
248
266
  export declare type HookMap<A, S> = {
249
267
  [L in keyof S]?: HookFunction<A, S>[];
250
268
  };
251
- export declare type HookOptions<A, S> = HookMap<A, S> | HookFunction<A, S>[] | LegacyHookMap<A, S>;
269
+ export declare type HookOptions<A, S> = HookMap<A, S> | HookFunction<A, S>[] | RegularHookMap<A, S>;
@@ -1,8 +1,7 @@
1
1
  import { HookContextData, HookManager, Middleware } from '../dependencies';
2
2
  import { Service, ServiceOptions, HookContext, FeathersService, Application } from '../declarations';
3
- import { fromAfterHook, fromBeforeHook, fromErrorHooks } from './legacy';
4
- export { fromAfterHook, fromBeforeHook, fromErrorHooks };
5
- export declare function createContext(service: Service<any>, method: string, data?: HookContextData): HookContext<Application<any, any>, any>;
3
+ export { fromBeforeHook, fromBeforeHooks, fromAfterHook, fromAfterHooks, fromErrorHook, fromErrorHooks } from './regular';
4
+ export declare function createContext(service: Service, method: string, data?: HookContextData): HookContext<Application<any, any>, any>;
6
5
  export declare class FeathersHookManager<A> extends HookManager {
7
6
  app: A;
8
7
  method: string;
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hookMixin = exports.FeathersHookManager = exports.createContext = exports.fromErrorHooks = exports.fromBeforeHook = exports.fromAfterHook = void 0;
3
+ exports.hookMixin = exports.FeathersHookManager = exports.createContext = exports.fromErrorHooks = exports.fromErrorHook = exports.fromAfterHooks = exports.fromAfterHook = exports.fromBeforeHooks = exports.fromBeforeHook = void 0;
4
4
  const dependencies_1 = require("../dependencies");
5
5
  const service_1 = require("../service");
6
- const legacy_1 = require("./legacy");
7
- Object.defineProperty(exports, "fromAfterHook", { enumerable: true, get: function () { return legacy_1.fromAfterHook; } });
8
- Object.defineProperty(exports, "fromBeforeHook", { enumerable: true, get: function () { return legacy_1.fromBeforeHook; } });
9
- Object.defineProperty(exports, "fromErrorHooks", { enumerable: true, get: function () { return legacy_1.fromErrorHooks; } });
6
+ const regular_1 = require("./regular");
7
+ var regular_2 = require("./regular");
8
+ Object.defineProperty(exports, "fromBeforeHook", { enumerable: true, get: function () { return regular_2.fromBeforeHook; } });
9
+ Object.defineProperty(exports, "fromBeforeHooks", { enumerable: true, get: function () { return regular_2.fromBeforeHooks; } });
10
+ Object.defineProperty(exports, "fromAfterHook", { enumerable: true, get: function () { return regular_2.fromAfterHook; } });
11
+ Object.defineProperty(exports, "fromAfterHooks", { enumerable: true, get: function () { return regular_2.fromAfterHooks; } });
12
+ Object.defineProperty(exports, "fromErrorHook", { enumerable: true, get: function () { return regular_2.fromErrorHook; } });
13
+ Object.defineProperty(exports, "fromErrorHooks", { enumerable: true, get: function () { return regular_2.fromErrorHooks; } });
10
14
  function createContext(service, method, data = {}) {
11
15
  const createContext = service[method].createContext;
12
16
  if (typeof createContext !== 'function') {
@@ -25,10 +29,10 @@ class FeathersHookManager extends dependencies_1.HookManager {
25
29
  collectMiddleware(self, args) {
26
30
  const app = this.app;
27
31
  const appHooks = app.appHooks[dependencies_1.HOOKS].concat(app.appHooks[this.method] || []);
28
- const legacyAppHooks = (0, legacy_1.collectLegacyHooks)(this.app, this.method);
32
+ const regularAppHooks = (0, regular_1.collectRegularHooks)(this.app, this.method);
29
33
  const middleware = super.collectMiddleware(self, args);
30
- const legacyHooks = (0, legacy_1.collectLegacyHooks)(self, this.method);
31
- return [...appHooks, ...legacyAppHooks, ...middleware, ...legacyHooks];
34
+ const regularHooks = (0, regular_1.collectRegularHooks)(self, this.method);
35
+ return [...appHooks, ...regularAppHooks, ...middleware, ...regularHooks];
32
36
  }
33
37
  initializeContext(self, args, context) {
34
38
  const ctx = super.initializeContext(self, args, context);
@@ -46,7 +50,8 @@ function hookMixin(service, path, options) {
46
50
  return service;
47
51
  }
48
52
  const app = this;
49
- const serviceMethodHooks = (0, service_1.getHookMethods)(service, options).reduce((res, method) => {
53
+ const hookMethods = (0, service_1.getHookMethods)(service, options);
54
+ const serviceMethodHooks = hookMethods.reduce((res, method) => {
50
55
  const params = service_1.defaultServiceArguments[method] || ['data', 'params'];
51
56
  res[method] = new FeathersHookManager(app, method)
52
57
  .params(...params)
@@ -56,15 +61,22 @@ function hookMixin(service, path, options) {
56
61
  method,
57
62
  service,
58
63
  event: null,
59
- type: null
64
+ type: null,
65
+ get statusCode() {
66
+ var _a;
67
+ return (_a = this.http) === null || _a === void 0 ? void 0 : _a.statusCode;
68
+ },
69
+ set statusCode(value) {
70
+ (this.http || (this.http = {})).statusCode = value;
71
+ }
60
72
  });
61
73
  return res;
62
74
  }, {});
63
- const handleLegacyHooks = (0, legacy_1.enableLegacyHooks)(service);
75
+ const handleRegularHooks = (0, regular_1.enableRegularHooks)(service, hookMethods);
64
76
  (0, dependencies_1.hooks)(service, serviceMethodHooks);
65
77
  service.hooks = function (hookOptions) {
66
78
  if (hookOptions.before || hookOptions.after || hookOptions.error) {
67
- return handleLegacyHooks.call(this, hookOptions);
79
+ return handleRegularHooks.call(this, hookOptions);
68
80
  }
69
81
  if (Array.isArray(hookOptions)) {
70
82
  return (0, dependencies_1.hooks)(this, hookOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"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,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAEnC,OAAO,CAAC,KAAK,GAAG,UAAqB,WAAgB;QACnD,IAAI,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;YAChE,OAAO,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SACnD;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YAC9B,OAAO,IAAA,oBAAK,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SACjC;QAED,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACxC,MAAM,OAAO,GAAG,IAAA,yBAAU,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAEzC,IAAI,CAAC,CAAC,OAAO,YAAY,mBAAmB,CAAC,EAAE;gBAC7C,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,iDAAiD,CAAC,CAAC;aACpF;YAED,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC,CAAA;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AA5DD,8BA4DC"}
@@ -0,0 +1,12 @@
1
+ import { HookFunction, RegularHookFunction, RegularHookMap } from '../declarations';
2
+ export declare function fromBeforeHook<A, S>(hook: RegularHookFunction<A, S>): HookFunction<A, S>;
3
+ export declare function fromAfterHook<A, S>(hook: RegularHookFunction<A, S>): HookFunction<A, S>;
4
+ export declare function fromErrorHook<A, S>(hook: RegularHookFunction<A, S>): HookFunction<A, S>;
5
+ export declare function fromBeforeHooks<A, S>(hooks: RegularHookFunction<A, S>[]): HookFunction<unknown, unknown>;
6
+ export declare function fromAfterHooks<A, S>(hooks: RegularHookFunction<A, S>[]): HookFunction<unknown, unknown>;
7
+ export declare function fromErrorHooks<A, S>(hooks: RegularHookFunction<A, S>[]): HookFunction<unknown, unknown>;
8
+ export declare function collectRegularHooks(target: any, method: string): any;
9
+ export declare function convertHookData(input: any): {
10
+ [method: string]: RegularHookFunction<import("../declarations").Application<any, any>, import("../declarations").Service<any, Partial<any>>>[];
11
+ };
12
+ export declare function enableRegularHooks(object: any, methods?: string[]): (this: any, input: RegularHookMap<any, any>) => any;
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enableRegularHooks = exports.convertHookData = exports.collectRegularHooks = exports.fromErrorHooks = exports.fromAfterHooks = exports.fromBeforeHooks = exports.fromErrorHook = exports.fromAfterHook = exports.fromBeforeHook = void 0;
4
+ const service_1 = require("../service");
5
+ const runHook = (hook, context, type) => {
6
+ if (type)
7
+ context.type = type;
8
+ return Promise.resolve(hook.call(context.self, context))
9
+ .then((res) => {
10
+ if (type)
11
+ context.type = null;
12
+ if (res && res !== context) {
13
+ Object.assign(context, res);
14
+ }
15
+ });
16
+ };
17
+ function fromBeforeHook(hook) {
18
+ return (context, next) => {
19
+ return runHook(hook, context, 'before').then(next);
20
+ };
21
+ }
22
+ exports.fromBeforeHook = fromBeforeHook;
23
+ function fromAfterHook(hook) {
24
+ return (context, next) => {
25
+ return next().then(() => runHook(hook, context, 'after'));
26
+ };
27
+ }
28
+ exports.fromAfterHook = fromAfterHook;
29
+ function fromErrorHook(hook) {
30
+ return (context, next) => {
31
+ return next().catch((error) => {
32
+ if (context.error !== error || context.result !== undefined) {
33
+ context.original = { ...context };
34
+ context.error = error;
35
+ delete context.result;
36
+ }
37
+ return runHook(hook, context, 'error').then(() => {
38
+ if (context.result === undefined && context.error !== undefined) {
39
+ throw context.error;
40
+ }
41
+ });
42
+ });
43
+ };
44
+ }
45
+ exports.fromErrorHook = fromErrorHook;
46
+ const RunHooks = (hooks) => (context) => {
47
+ return hooks.reduce((promise, hook) => {
48
+ return promise.then(() => runHook(hook, context));
49
+ }, Promise.resolve(undefined));
50
+ };
51
+ function fromBeforeHooks(hooks) {
52
+ return fromBeforeHook(RunHooks(hooks));
53
+ }
54
+ exports.fromBeforeHooks = fromBeforeHooks;
55
+ function fromAfterHooks(hooks) {
56
+ return fromAfterHook(RunHooks(hooks));
57
+ }
58
+ exports.fromAfterHooks = fromAfterHooks;
59
+ function fromErrorHooks(hooks) {
60
+ return fromErrorHook(RunHooks(hooks));
61
+ }
62
+ exports.fromErrorHooks = fromErrorHooks;
63
+ function collectRegularHooks(target, method) {
64
+ return target.__hooks.hooks[method] || [];
65
+ }
66
+ exports.collectRegularHooks = collectRegularHooks;
67
+ // Converts different hook registration formats into the
68
+ // same internal format
69
+ function convertHookData(input) {
70
+ const result = {};
71
+ if (Array.isArray(input)) {
72
+ result.all = input;
73
+ }
74
+ else if (typeof input !== 'object') {
75
+ result.all = [input];
76
+ }
77
+ else {
78
+ for (const key of Object.keys(input)) {
79
+ const value = input[key];
80
+ result[key] = Array.isArray(value) ? value : [value];
81
+ }
82
+ }
83
+ return result;
84
+ }
85
+ exports.convertHookData = convertHookData;
86
+ const types = ['before', 'after', 'error'];
87
+ const isType = (value) => types.includes(value);
88
+ const wrappers = {
89
+ before: fromBeforeHooks,
90
+ after: fromAfterHooks,
91
+ error: fromErrorHooks
92
+ };
93
+ const createStore = (methods) => {
94
+ const store = {
95
+ before: {},
96
+ after: {},
97
+ error: {},
98
+ hooks: {}
99
+ };
100
+ for (const method of methods) {
101
+ store.hooks[method] = [];
102
+ }
103
+ return store;
104
+ };
105
+ const setStore = (object, store) => {
106
+ Object.defineProperty(object, '__hooks', {
107
+ configurable: true,
108
+ value: store,
109
+ writable: true
110
+ });
111
+ };
112
+ const getStore = (object) => object.__hooks;
113
+ const createMap = (input, methods) => {
114
+ const map = {};
115
+ Object.keys(input).forEach((type) => {
116
+ if (!isType(type)) {
117
+ throw new Error(`'${type}' is not a valid hook type`);
118
+ }
119
+ const data = convertHookData(input[type]);
120
+ Object.keys(data).forEach((method) => {
121
+ if (method !== 'all' && !methods.includes(method)) {
122
+ throw new Error(`'${method}' is not a valid hook method`);
123
+ }
124
+ });
125
+ map[type] = data;
126
+ });
127
+ return map;
128
+ };
129
+ const createAdapter = (type) => {
130
+ const hooks = [];
131
+ const hook = wrappers[type](hooks);
132
+ const adapter = Object.assign(hook, { hooks });
133
+ return adapter;
134
+ };
135
+ const updateStore = (store, map) => {
136
+ Object.keys(store.hooks).forEach((method) => {
137
+ let adapted = false;
138
+ Object.keys(map).forEach((key) => {
139
+ var _a;
140
+ const type = key;
141
+ const allHooks = map[type].all || [];
142
+ const methodHooks = map[type][method] || [];
143
+ if (allHooks.length || methodHooks.length) {
144
+ const adapter = (_a = store[type])[method] || (_a[method] = (adapted = true, createAdapter(type)));
145
+ adapter.hooks.push(...allHooks, ...methodHooks);
146
+ }
147
+ });
148
+ if (adapted) {
149
+ store.hooks[method] = [
150
+ store.error[method],
151
+ store.before[method],
152
+ store.after[method]
153
+ ].filter(hook => hook);
154
+ }
155
+ });
156
+ };
157
+ // Add `.hooks` functionality to an object
158
+ function enableRegularHooks(object, methods = service_1.defaultServiceMethods) {
159
+ const store = createStore(methods);
160
+ setStore(object, store);
161
+ return function regularHooks(input) {
162
+ const store = getStore(this);
163
+ const map = createMap(input, methods);
164
+ updateStore(store, map);
165
+ return this;
166
+ };
167
+ }
168
+ exports.enableRegularHooks = enableRegularHooks;
169
+ //# sourceMappingURL=regular.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regular.js","sourceRoot":"","sources":["../../src/hooks/regular.ts"],"names":[],"mappings":";;;AACA,wCAAmD;AAEnD,MAAM,OAAO,GAAG,CAAQ,IAA+B,EAAE,OAAY,EAAE,IAAa,EAAE,EAAE;IACtF,IAAI,IAAI;QAAE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SACrD,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AAO,SAAS,YAAY,CAAa,KAA+B;QACtE,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEtC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAExB,OAAO,IAAI,CAAC;IACd,CAAC,CAAA;AACH,CAAC;AAhBD,gDAgBC"}
package/lib/service.js CHANGED
@@ -21,6 +21,7 @@ exports.defaultEventMap = {
21
21
  exports.protectedMethods = Object.keys(Object.prototype)
22
22
  .concat(Object.keys(dependencies_1.EventEmitter.prototype))
23
23
  .concat([
24
+ 'all',
24
25
  'before',
25
26
  'after',
26
27
  'error',
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;AAAA,iDAA4D;AAG/C,QAAA,OAAO,GAAG,IAAA,2BAAY,EAAC,qBAAqB,CAAC,CAAC;AAE9C,QAAA,uBAAuB,GAAG;IACrC,IAAI,EAAE,CAAE,QAAQ,CAAE;IAClB,GAAG,EAAE,CAAE,IAAI,EAAE,QAAQ,CAAE;IACvB,MAAM,EAAE,CAAE,MAAM,EAAE,QAAQ,CAAE;IAC5B,MAAM,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAE;IAClC,KAAK,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAE;IACjC,MAAM,EAAE,CAAE,IAAI,EAAE,QAAQ,CAAE;CAC3B,CAAA;AAEY,QAAA,qBAAqB,GAAG,MAAM,CAAC,IAAI,CAAC,+BAAuB,CAAC,CAAC;AAE7D,QAAA,eAAe,GAAG;IAC7B,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;CAClB,CAAA;AAEY,QAAA,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SA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