@feathersjs/feathers 5.0.0-pre.1 → 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.
Files changed (46) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/LICENSE +1 -1
  3. package/lib/application.d.ts +19 -8
  4. package/lib/application.js +80 -78
  5. package/lib/application.js.map +1 -1
  6. package/lib/declarations.d.ts +207 -106
  7. package/lib/dependencies.d.ts +4 -0
  8. package/lib/dependencies.js +18 -0
  9. package/lib/dependencies.js.map +1 -0
  10. package/lib/events.d.ts +4 -4
  11. package/lib/events.js +16 -69
  12. package/lib/events.js.map +1 -1
  13. package/lib/hooks/index.d.ts +13 -2
  14. package/lib/hooks/index.js +84 -146
  15. package/lib/hooks/index.js.map +1 -1
  16. package/lib/hooks/regular.d.ts +12 -0
  17. package/lib/hooks/regular.js +169 -0
  18. package/lib/hooks/regular.js.map +1 -0
  19. package/lib/index.d.ts +9 -4
  20. package/lib/index.js +9 -12
  21. package/lib/index.js.map +1 -1
  22. package/lib/service.d.ts +21 -0
  23. package/lib/service.js +68 -0
  24. package/lib/service.js.map +1 -0
  25. package/lib/version.d.ts +1 -1
  26. package/lib/version.js +1 -1
  27. package/lib/version.js.map +1 -1
  28. package/package.json +12 -13
  29. package/readme.md +1 -77
  30. package/src/application.ts +115 -105
  31. package/src/declarations.ts +274 -121
  32. package/src/dependencies.ts +5 -0
  33. package/src/events.ts +18 -75
  34. package/src/hooks/index.ts +95 -150
  35. package/src/hooks/regular.ts +207 -0
  36. package/src/index.ts +10 -17
  37. package/src/service.ts +91 -0
  38. package/src/version.ts +1 -1
  39. package/lib/hooks/base.d.ts +0 -3
  40. package/lib/hooks/base.js +0 -29
  41. package/lib/hooks/base.js.map +0 -1
  42. package/lib/hooks/commons.d.ts +0 -20
  43. package/lib/hooks/commons.js +0 -298
  44. package/lib/hooks/commons.js.map +0 -1
  45. package/src/hooks/base.ts +0 -32
  46. package/src/hooks/commons.ts +0 -336
@@ -1,177 +1,122 @@
1
- import * as hookCommons from './commons';
2
1
  import {
3
- hooks as hooksDecorator,
4
- HookManager,
5
- HookContext,
6
- HookMap,
7
- Middleware,
8
- middleware
9
- } from '@feathersjs/hooks';
10
- import { assignArguments, validate } from './base';
11
- import { Application, Service } from '../declarations';
12
- const baseHooks = [ assignArguments, validate ];
13
- const {
14
- getHooks,
15
- enableHooks,
16
- ACTIVATE_HOOKS,
17
- finallyWrapper,
18
- errorWrapper,
19
- wrap
20
- } = hookCommons;
21
-
22
- function getMiddlewareOptions (app: Application, service: Service<any>, method: string) {
23
- const params: string[] = service.methods[method];
24
- const defaults = params.find(v => v === 'params') ? { params: {} } : null;
25
-
26
- return {
27
- params,
28
- defaults,
29
- props: {
30
- app,
31
- service,
32
- type: 'before',
33
- get path () {
34
- if (!service || !app || !app.services) {
35
- return null;
36
- }
37
-
38
- return Object.keys(app.services)
39
- .find(path => app.services[path] === service);
40
- }
41
- }
42
- };
43
- }
44
-
45
- function getCollector (app: Application, service: Service<any>, method: string) {
46
- return function (this: HookManager): Middleware[] {
47
- const previous = this._parent && this._parent.getMiddleware();
48
- let result;
49
-
50
- if (previous && this._middleware) {
51
- result = previous.concat(this._middleware);
52
- } else {
53
- result = previous || this._middleware || [];
54
- }
2
+ getManager, HookContextData, HookManager, HookMap, HOOKS, hooks, Middleware
3
+ } from '../dependencies';
4
+ import {
5
+ Service, ServiceOptions, HookContext, FeathersService, Application
6
+ } from '../declarations';
7
+ import { defaultServiceArguments, getHookMethods } from '../service';
8
+ import {
9
+ collectRegularHooks,
10
+ enableRegularHooks
11
+ } from './regular';
12
+
13
+ export {
14
+ fromBeforeHook,
15
+ fromBeforeHooks,
16
+ fromAfterHook,
17
+ fromAfterHooks,
18
+ fromErrorHook,
19
+ fromErrorHooks
20
+ } from './regular';
21
+
22
+ export function createContext (service: Service, method: string, data: HookContextData = {}) {
23
+ const createContext = (service as any)[method].createContext;
24
+
25
+ if (typeof createContext !== 'function') {
26
+ throw new Error(`Can not create context for method ${method}`);
27
+ }
55
28
 
56
- const hooks = {
57
- async: getHooks(app, service, 'async', method),
58
- before: getHooks(app, service, 'before', method),
59
- after: getHooks(app, service, 'after', method, true),
60
- error: getHooks(app, service, 'error', method, true),
61
- finally: getHooks(app, service, 'finally', method, true)
62
- };
63
-
64
- return [
65
- ...finallyWrapper(hooks.finally),
66
- ...errorWrapper(hooks.error),
67
- ...baseHooks,
68
- ...result,
69
- ...wrap(hooks)
70
- ];
71
- };
29
+ return createContext(data) as HookContext;
72
30
  }
73
31
 
74
- function withHooks (app: Application, service: Service<any>, methods: string[]) {
75
- const hookMap = methods.reduce((accu, method) => {
76
- if (typeof service[method] !== 'function') {
77
- return accu;
78
- }
79
-
80
- const hookManager = middleware([], getMiddlewareOptions(app, service, method));
81
-
82
- hookManager.getMiddleware = getCollector(app, service, method);
83
-
84
- accu[method] = hookManager;
32
+ export class FeathersHookManager<A> extends HookManager {
33
+ constructor (public app: A, public method: string) {
34
+ super();
35
+ this._middleware = [];
36
+ }
85
37
 
86
- return accu;
87
- }, {} as HookMap);
38
+ collectMiddleware (self: any, args: any[]): Middleware[] {
39
+ const app = this.app as any as Application;
40
+ const appHooks = app.appHooks[HOOKS].concat(app.appHooks[this.method] || []);
41
+ const regularAppHooks = collectRegularHooks(this.app, this.method);
42
+ const middleware = super.collectMiddleware(self, args);
43
+ const regularHooks = collectRegularHooks(self, this.method);
88
44
 
89
- hooksDecorator(service, hookMap);
90
- }
45
+ return [...appHooks, ...regularAppHooks, ...middleware, ...regularHooks];
46
+ }
91
47
 
92
- function mixinMethod (this: any) {
93
- const service = this;
94
- const args = Array.from(arguments);
48
+ initializeContext (self: any, args: any[], context: HookContext) {
49
+ const ctx = super.initializeContext(self, args, context);
95
50
 
96
- const returnHook = args[args.length - 1] === true || args[args.length - 1] instanceof HookContext
97
- ? args.pop() : false;
51
+ ctx.params = ctx.params || {};
98
52
 
99
- const hookContext = returnHook instanceof HookContext ? returnHook : this._super.createContext();
53
+ return ctx;
54
+ }
100
55
 
101
- return this._super.call(service, ...args, hookContext)
102
- .then(() => returnHook ? hookContext : hookContext.result)
103
- // Handle errors
104
- .catch(() => {
105
- if (typeof hookContext.error !== 'undefined' && typeof hookContext.result === 'undefined') {
106
- return Promise.reject(returnHook ? hookContext : hookContext.error);
107
- } else {
108
- return returnHook ? hookContext : hookContext.result;
109
- }
110
- });
56
+ middleware (mw: Middleware[]) {
57
+ this._middleware.push(...mw);
58
+ return this;
59
+ }
111
60
  }
112
61
 
113
- // A service mixin that adds `service.hooks()` method and functionality
114
- const hookMixin = exports.hookMixin = function hookMixin (service: any) {
62
+ export function hookMixin<A> (
63
+ this: A, service: FeathersService<A>, path: string, options: ServiceOptions
64
+ ) {
115
65
  if (typeof service.hooks === 'function') {
116
- return;
66
+ return service;
117
67
  }
118
68
 
119
- service.methods = Object.getOwnPropertyNames(service)
120
- .filter(key => typeof service[key] === 'function' && service[key][ACTIVATE_HOOKS])
121
- .reduce((result, methodName) => {
122
- result[methodName] = service[methodName][ACTIVATE_HOOKS];
123
- return result;
124
- }, service.methods || {});
125
-
126
- Object.assign(service.methods, {
127
- find: ['params'],
128
- get: ['id', 'params'],
129
- create: ['data', 'params'],
130
- update: ['id', 'data', 'params'],
131
- patch: ['id', 'data', 'params'],
132
- remove: ['id', 'params']
133
- });
134
-
135
69
  const app = this;
136
- const methodNames = Object.keys(service.methods);
70
+ const hookMethods = getHookMethods(service, options);
71
+
72
+ const serviceMethodHooks = hookMethods.reduce((res, method) => {
73
+ const params = (defaultServiceArguments as any)[method] || [ 'data', 'params' ];
74
+
75
+ res[method] = new FeathersHookManager<A>(app, method)
76
+ .params(...params)
77
+ .props({
78
+ app,
79
+ path,
80
+ method,
81
+ service,
82
+ event: null,
83
+ type: null,
84
+ get statusCode() {
85
+ return this.http?.statusCode;
86
+ },
87
+ set statusCode(value: number) {
88
+ (this.http ||= {}).statusCode = value;
89
+ }
90
+ });
137
91
 
138
- withHooks(app, service, methodNames);
92
+ return res;
93
+ }, {} as HookMap);
139
94
 
140
- // Usefull only for the `returnHook` backwards compatibility with `true`
141
- const mixin = methodNames.reduce((mixin, method) => {
142
- if (typeof service[method] !== 'function') {
143
- return mixin;
144
- }
95
+ const handleRegularHooks = enableRegularHooks(service, hookMethods);
145
96
 
146
- mixin[method] = mixinMethod;
97
+ hooks(service, serviceMethodHooks);
147
98
 
148
- return mixin;
149
- }, {} as any);
99
+ service.hooks = function (this: any, hookOptions: any) {
100
+ if (hookOptions.before || hookOptions.after || hookOptions.error) {
101
+ return handleRegularHooks.call(this, hookOptions);
102
+ }
150
103
 
151
- // Add .hooks method and properties to the service
152
- enableHooks(service, methodNames, app.hookTypes);
104
+ if (Array.isArray(hookOptions)) {
105
+ return hooks(this, hookOptions);
106
+ }
153
107
 
154
- service.mixin(mixin);
155
- };
108
+ Object.keys(hookOptions).forEach(method => {
109
+ const manager = getManager(this[method]);
156
110
 
157
- export default function () {
158
- return function (app: any) {
159
- // We store a reference of all supported hook types on the app
160
- // in case someone needs it
161
- Object.assign(app, {
162
- hookTypes: ['async', 'before', 'after', 'error', 'finally']
163
- });
111
+ if (!(manager instanceof FeathersHookManager)) {
112
+ throw new Error(`Method ${method} is not a Feathers hooks enabled service method`);
113
+ }
164
114
 
165
- // Add functionality for hooks to be registered as app.hooks
166
- enableHooks(app, app.methods, app.hookTypes);
115
+ manager.middleware(hookOptions[method]);
116
+ });
167
117
 
168
- app.mixins.push(hookMixin);
169
- };
170
- }
118
+ return this;
119
+ }
171
120
 
172
- export function activateHooks (args: any[]) {
173
- return (fn: any) => {
174
- Object.defineProperty(fn, ACTIVATE_HOOKS, { value: args });
175
- return fn;
176
- };
121
+ return service;
177
122
  }
@@ -0,0 +1,207 @@
1
+ import { HookFunction, RegularHookFunction, RegularHookMap } from '../declarations';
2
+ import { defaultServiceMethods } from '../service';
3
+
4
+ const runHook = <A, S> (hook: RegularHookFunction<A, S>, context: any, type?: string) => {
5
+ if (type) context.type = type;
6
+ return Promise.resolve(hook.call(context.self, context))
7
+ .then((res: any) => {
8
+ if (type) context.type = null;
9
+ if (res && res !== context) {
10
+ Object.assign(context, res);
11
+ }
12
+ });
13
+ };
14
+
15
+ export function fromBeforeHook<A, S> (hook: RegularHookFunction<A, S>): HookFunction<A, S> {
16
+ return (context, next) => {
17
+ return runHook(hook, context, 'before').then(next);
18
+ };
19
+ }
20
+
21
+ export function fromAfterHook<A, S> (hook: RegularHookFunction<A, S>): HookFunction<A, S> {
22
+ return (context, next) => {
23
+ return next().then(() => runHook(hook, context, 'after'));
24
+ }
25
+ }
26
+
27
+ export function fromErrorHook<A, S> (hook: RegularHookFunction<A, S>): HookFunction<A, S> {
28
+ return (context, next) => {
29
+ return next().catch((error: any) => {
30
+ if (context.error !== error || context.result !== undefined) {
31
+ (context as any).original = { ...context };
32
+ context.error = error;
33
+ delete context.result;
34
+ }
35
+
36
+ return runHook(hook, context, 'error').then(() => {
37
+ if (context.result === undefined && context.error !== undefined) {
38
+ throw context.error;
39
+ }
40
+ });
41
+ });
42
+ }
43
+ }
44
+
45
+ const RunHooks = <A, S> (hooks: RegularHookFunction<A, S>[]) => (context: any) => {
46
+ return hooks.reduce((promise, hook) => {
47
+ return promise.then(() => runHook(hook, context))
48
+ }, Promise.resolve(undefined));
49
+ };
50
+
51
+ export function fromBeforeHooks<A, S> (hooks: RegularHookFunction<A, S>[]) {
52
+ return fromBeforeHook(RunHooks(hooks));
53
+ }
54
+
55
+ export function fromAfterHooks<A, S> (hooks: RegularHookFunction<A, S>[]) {
56
+ return fromAfterHook(RunHooks(hooks));
57
+ }
58
+
59
+ export function fromErrorHooks<A, S> (hooks: RegularHookFunction<A, S>[]) {
60
+ return fromErrorHook(RunHooks(hooks));
61
+ }
62
+
63
+ export function collectRegularHooks (target: any, method: string) {
64
+ return target.__hooks.hooks[method] || [];
65
+ }
66
+
67
+ // Converts different hook registration formats into the
68
+ // same internal format
69
+ export function convertHookData (input: any) {
70
+ const result: { [ method: string ]: RegularHookFunction[] } = {};
71
+
72
+ if (Array.isArray(input)) {
73
+ result.all = input;
74
+ } else if (typeof input !== 'object') {
75
+ result.all = [ input ];
76
+ } else {
77
+ for (const key of Object.keys(input)) {
78
+ const value = input[key];
79
+ result[key] = Array.isArray(value) ? value : [ value ];
80
+ }
81
+ }
82
+
83
+ return result;
84
+ }
85
+
86
+ type RegularType = 'before' | 'after' | 'error';
87
+
88
+ type RegularMap = { [ type in RegularType ]: ReturnType< typeof convertHookData > };
89
+
90
+ type RegularAdapter = HookFunction & { hooks: RegularHookFunction[] };
91
+
92
+ type RegularStore = {
93
+ before: { [ method: string ]: RegularAdapter },
94
+ after: { [ method: string ]: RegularAdapter },
95
+ error: { [ method: string ]: RegularAdapter },
96
+ hooks: { [ method: string ]: HookFunction[] }
97
+ };
98
+
99
+ const types: RegularType[] = ['before', 'after', 'error'];
100
+
101
+ const isType = (value: any): value is RegularType => types.includes(value);
102
+
103
+ const wrappers = {
104
+ before: fromBeforeHooks,
105
+ after: fromAfterHooks,
106
+ error: fromErrorHooks
107
+ };
108
+
109
+ const createStore = (methods: string[]) => {
110
+ const store: RegularStore = {
111
+ before: {},
112
+ after: {},
113
+ error: {},
114
+ hooks: {}
115
+ };
116
+
117
+ for (const method of methods) {
118
+ store.hooks[method] = [];
119
+ }
120
+
121
+ return store;
122
+ };
123
+
124
+ const setStore = (object: any, store: RegularStore) => {
125
+ Object.defineProperty(object, '__hooks', {
126
+ configurable: true,
127
+ value: store,
128
+ writable: true
129
+ });
130
+ };
131
+
132
+ const getStore = (object: any): RegularStore => object.__hooks;
133
+
134
+ const createMap = (input: RegularHookMap<any, any>, methods: string[]) => {
135
+ const map = {} as RegularMap;
136
+
137
+ Object.keys(input).forEach((type) => {
138
+ if (!isType(type)) {
139
+ throw new Error(`'${type}' is not a valid hook type`);
140
+ }
141
+
142
+ const data = convertHookData(input[type]);
143
+
144
+ Object.keys(data).forEach((method) => {
145
+ if (method !== 'all' && !methods.includes(method)) {
146
+ throw new Error(`'${method}' is not a valid hook method`);
147
+ }
148
+ });
149
+
150
+ map[type] = data;
151
+ });
152
+
153
+ return map;
154
+ };
155
+
156
+ const createAdapter = (type: RegularType) => {
157
+ const hooks: RegularHookFunction[] = [];
158
+ const hook = wrappers[type](hooks);
159
+ const adapter = Object.assign(hook, { hooks });
160
+
161
+ return adapter;
162
+ };
163
+
164
+ const updateStore = (store: RegularStore, map: RegularMap) => {
165
+ Object.keys(store.hooks).forEach((method) => {
166
+ let adapted = false;
167
+
168
+ Object.keys(map).forEach((key) => {
169
+ const type = key as RegularType;
170
+ const allHooks = map[type].all || [];
171
+ const methodHooks = map[type][method] || [];
172
+
173
+ if (allHooks.length || methodHooks.length) {
174
+ const adapter = store[type][method] ||= (adapted = true, createAdapter(type));
175
+
176
+ adapter.hooks.push(...allHooks, ...methodHooks);
177
+ }
178
+ });
179
+
180
+ if (adapted) {
181
+ store.hooks[method] = [
182
+ store.error[method],
183
+ store.before[method],
184
+ store.after[method]
185
+ ].filter(hook => hook);
186
+ }
187
+ });
188
+ };
189
+
190
+ // Add `.hooks` functionality to an object
191
+ export function enableRegularHooks (
192
+ object: any,
193
+ methods: string[] = defaultServiceMethods
194
+ ) {
195
+ const store = createStore(methods);
196
+
197
+ setStore(object, store);
198
+
199
+ return function regularHooks (this: any, input: RegularHookMap<any, any>) {
200
+ const store = getStore(this);
201
+ const map = createMap(input, methods);
202
+
203
+ updateStore(store, map);
204
+
205
+ return this;
206
+ }
207
+ }
package/src/index.ts CHANGED
@@ -1,25 +1,18 @@
1
- // @ts-ignore
2
- import Proto from 'uberproto';
3
- import Application from './application';
1
+ import { setDebug } from './dependencies';
4
2
  import version from './version';
5
- import { Application as ApplicationType } from './declarations'
3
+ import { Feathers } from './application';
4
+ import { Application } from './declarations';
6
5
 
7
- const baseObject = Object.create(null);
8
-
9
- export default function feathers<ServiceTypes = {}> (): ApplicationType<ServiceTypes> {
10
- const app = Object.create(baseObject);
11
-
12
- // Mix in the base application
13
- Proto.mixin(Application, app);
14
-
15
- app.init();
16
-
17
- return app;
6
+ export function feathers<T = any, S = any> () {
7
+ return new Feathers<T, S>() as Application<T, S>;
18
8
  }
19
9
 
20
- export { version };
21
- export * from './declarations';
10
+ feathers.setDebug = setDebug;
11
+
12
+ export { version, Feathers };
22
13
  export * from './hooks/index';
14
+ export * from './declarations';
15
+ export * from './service';
23
16
 
24
17
  if (typeof module !== 'undefined') {
25
18
  module.exports = Object.assign(feathers, module.exports);
package/src/service.ts ADDED
@@ -0,0 +1,91 @@
1
+ import { createSymbol, EventEmitter } from './dependencies';
2
+ import { ServiceOptions } from './declarations';
3
+
4
+ export const SERVICE = createSymbol('@feathersjs/service');
5
+
6
+ export const defaultServiceArguments = {
7
+ find: [ 'params' ],
8
+ get: [ 'id', 'params' ],
9
+ create: [ 'data', 'params' ],
10
+ update: [ 'id', 'data', 'params' ],
11
+ patch: [ 'id', 'data', 'params' ],
12
+ remove: [ 'id', 'params' ]
13
+ }
14
+
15
+ export const defaultServiceMethods = Object.keys(defaultServiceArguments);
16
+
17
+ export const defaultEventMap = {
18
+ create: 'created',
19
+ update: 'updated',
20
+ patch: 'patched',
21
+ remove: 'removed'
22
+ }
23
+
24
+ export const protectedMethods = Object.keys(Object.prototype)
25
+ .concat(Object.keys(EventEmitter.prototype))
26
+ .concat([
27
+ 'all',
28
+ 'before',
29
+ 'after',
30
+ 'error',
31
+ 'hooks',
32
+ 'setup',
33
+ 'publish'
34
+ ]);
35
+
36
+ export function getHookMethods (service: any, options: ServiceOptions) {
37
+ const { methods } = options;
38
+
39
+ return defaultServiceMethods.filter(m =>
40
+ typeof service[m] === 'function' && !methods.includes(m)
41
+ ).concat(methods);
42
+ }
43
+
44
+ export function getServiceOptions (
45
+ service: any, options: ServiceOptions = {}
46
+ ): ServiceOptions {
47
+ const existingOptions = service[SERVICE];
48
+
49
+ if (existingOptions) {
50
+ return existingOptions;
51
+ }
52
+
53
+ const {
54
+ methods = defaultServiceMethods.filter(method =>
55
+ typeof service[method] === 'function'
56
+ ),
57
+ events = service.events || []
58
+ } = options;
59
+ const {
60
+ serviceEvents = Object.values(defaultEventMap).concat(events)
61
+ } = options;
62
+
63
+ return {
64
+ ...options,
65
+ events,
66
+ methods,
67
+ serviceEvents
68
+ };
69
+ }
70
+
71
+ export function wrapService (
72
+ location: string, service: any, options: ServiceOptions
73
+ ) {
74
+ // Do nothing if this is already an initialized
75
+ if (service[SERVICE]) {
76
+ return service;
77
+ }
78
+
79
+ const protoService = Object.create(service);
80
+ const serviceOptions = getServiceOptions(service, options);
81
+
82
+ if (Object.keys(serviceOptions.methods).length === 0 && typeof service.setup !== 'function') {
83
+ throw new Error(`Invalid service object passed for path \`${location}\``);
84
+ }
85
+
86
+ Object.defineProperty(protoService, SERVICE, {
87
+ value: serviceOptions
88
+ });
89
+
90
+ return protoService;
91
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '5.0.0-pre.1';
1
+ export default '5.0.0-pre.15';
@@ -1,3 +0,0 @@
1
- import { HookContext } from '../declarations';
2
- export declare const assignArguments: (context: HookContext, next: any) => any;
3
- export declare const validate: (context: HookContext, next: any) => any;
package/lib/hooks/base.js DELETED
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validate = exports.assignArguments = void 0;
4
- const commons_1 = require("@feathersjs/commons");
5
- const assignArguments = (context, next) => {
6
- const { service, method } = context;
7
- const parameters = service.methods[method];
8
- context.arguments.forEach((value, index) => {
9
- context[parameters[index]] = value;
10
- });
11
- if (!context.params) {
12
- context.params = {};
13
- }
14
- return next();
15
- };
16
- exports.assignArguments = assignArguments;
17
- const validate = (context, next) => {
18
- const { service, method, path } = context;
19
- const parameters = service.methods[method];
20
- if (parameters.includes('id') && context.id === undefined) {
21
- throw new Error(`An id must be provided to the '${path}.${method}' method`);
22
- }
23
- if (parameters.includes('data') && !commons_1._.isObjectOrArray(context.data)) {
24
- throw new Error(`A data object must be provided to the '${path}.${method}' method`);
25
- }
26
- return next();
27
- };
28
- exports.validate = validate;
29
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/hooks/base.ts"],"names":[],"mappings":";;;AAAA,iDAAwC;AAGjC,MAAM,eAAe,GAAG,CAAC,OAAoB,EAAE,IAAS,EAAE,EAAE;IACjE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACpC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACxC,OAAe,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;KACrB;IAED,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC,CAAC;AAbW,QAAA,eAAe,mBAa1B;AAEK,MAAM,QAAQ,GAAG,CAAC,OAAoB,EAAE,IAAS,EAAE,EAAE;IAC1D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3C,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,EAAE,KAAK,SAAS,EAAE;QACzD,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,IAAI,MAAM,UAAU,CAAC,CAAC;KAC7E;IAED,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAC,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnE,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,IAAI,MAAM,UAAU,CAAC,CAAC;KACrF;IAED,OAAO,IAAI,EAAE,CAAC;AAChB,CAAC,CAAC;AAbW,QAAA,QAAQ,YAanB"}
@@ -1,20 +0,0 @@
1
- export declare const ACTIVATE_HOOKS: string | symbol;
2
- export declare function createHookObject(method: string, data?: any): any;
3
- export declare function defaultMakeArguments(hook: any): any[];
4
- export declare function makeArguments(hook: any): any[];
5
- export declare function convertHookData(obj: any): any;
6
- export declare function isHookObject(hookObject: any): boolean;
7
- export declare function getHooks(app: any, service: any, type: string, method: string, appLast?: boolean): any;
8
- export declare function processHooks(hooks: any[], initialHookObject: any): Promise<any>;
9
- export declare function enableHooks(obj: any, methods: string[], types: string[]): any;
10
- export declare function firstHook(context: any, next: any): any;
11
- export declare function lastHook(context: any, next: any): any;
12
- export declare function toBeforeHook(hook: any): (context: any, next: any) => Promise<any>;
13
- export declare function toAfterHook(hook: any): (context: any, next: any) => any;
14
- export declare function toErrorHook(hook: any, onError: any, control: any): (context: any, next: any) => any;
15
- export declare function toFinallyHook(hook: any, onError: any, control: any): (context: any, next: any) => any;
16
- export declare function beforeWrapper(hooks: any): (typeof firstHook)[];
17
- export declare function afterWrapper(hooks: any): ((context: any, next: any) => any)[];
18
- export declare function finallyWrapper(hooks: any): ((context: any, next: any) => any)[];
19
- export declare function errorWrapper(hooks: any): ((context: any, next: any) => any)[];
20
- export declare function wrap({ async, before, after }?: any): any[];