@feathersjs/feathers 5.0.0-pre.10
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 +1035 -0
- package/LICENSE +22 -0
- package/lib/application.d.ts +21 -0
- package/lib/application.js +115 -0
- package/lib/application.js.map +1 -0
- package/lib/declarations.d.ts +251 -0
- package/lib/declarations.js +3 -0
- package/lib/declarations.js.map +1 -0
- package/lib/dependencies.d.ts +4 -0
- package/lib/dependencies.js +18 -0
- package/lib/dependencies.js.map +1 -0
- package/lib/events.d.ts +4 -0
- package/lib/events.js +29 -0
- package/lib/events.js.map +1 -0
- package/lib/hooks/index.d.ts +14 -0
- package/lib/hooks/index.js +84 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/legacy.d.ts +7 -0
- package/lib/hooks/legacy.js +114 -0
- package/lib/hooks/legacy.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +33 -0
- package/lib/index.js.map +1 -0
- package/lib/service.d.ts +21 -0
- package/lib/service.js +67 -0
- package/lib/service.js.map +1 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.js +4 -0
- package/lib/version.js.map +1 -0
- package/package.json +73 -0
- package/readme.md +36 -0
- package/src/application.ts +163 -0
- package/src/declarations.ts +348 -0
- package/src/dependencies.ts +5 -0
- package/src/events.ts +31 -0
- package/src/hooks/index.ts +109 -0
- package/src/hooks/legacy.ts +138 -0
- package/src/index.ts +19 -0
- package/src/service.ts +90 -0
- package/src/version.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Feathers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from './dependencies';
|
|
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>>[];
|
|
8
|
+
version: string;
|
|
9
|
+
_isSetup: boolean;
|
|
10
|
+
appHooks: HookMap<Application<ServiceTypes, AppSettings>, any>;
|
|
11
|
+
private legacyHooks;
|
|
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;
|
|
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;
|
|
19
|
+
hooks(hookMap: HookOptions<this, any>): any;
|
|
20
|
+
setup(): Promise<this>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Feathers = void 0;
|
|
7
|
+
const version_1 = __importDefault(require("./version"));
|
|
8
|
+
const dependencies_1 = require("./dependencies");
|
|
9
|
+
const events_1 = require("./events");
|
|
10
|
+
const index_1 = require("./hooks/index");
|
|
11
|
+
const service_1 = require("./service");
|
|
12
|
+
const legacy_1 = require("./hooks/legacy");
|
|
13
|
+
const debug = (0, dependencies_1.createDebug)('@feathersjs/feathers');
|
|
14
|
+
class Feathers extends dependencies_1.EventEmitter {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.services = {};
|
|
18
|
+
this.settings = {};
|
|
19
|
+
this.mixins = [index_1.hookMixin, events_1.eventMixin];
|
|
20
|
+
this.version = version_1.default;
|
|
21
|
+
this._isSetup = false;
|
|
22
|
+
this.appHooks = {
|
|
23
|
+
[dependencies_1.HOOKS]: [events_1.eventHook]
|
|
24
|
+
};
|
|
25
|
+
this.legacyHooks = (0, legacy_1.enableLegacyHooks)(this);
|
|
26
|
+
}
|
|
27
|
+
get(name) {
|
|
28
|
+
return this.settings[name];
|
|
29
|
+
}
|
|
30
|
+
set(name, value) {
|
|
31
|
+
this.settings[name] = value;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
configure(callback) {
|
|
35
|
+
callback.call(this, this);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
defaultService(location) {
|
|
39
|
+
throw new Error(`Can not find service '${location}'`);
|
|
40
|
+
}
|
|
41
|
+
service(location) {
|
|
42
|
+
const path = ((0, dependencies_1.stripSlashes)(location) || '/');
|
|
43
|
+
const current = this.services[path];
|
|
44
|
+
if (typeof current === 'undefined') {
|
|
45
|
+
this.use(path, this.defaultService(path));
|
|
46
|
+
return this.service(path);
|
|
47
|
+
}
|
|
48
|
+
return current;
|
|
49
|
+
}
|
|
50
|
+
use(path, service, options) {
|
|
51
|
+
if (typeof path !== 'string') {
|
|
52
|
+
throw new Error(`'${path}' is not a valid service path.`);
|
|
53
|
+
}
|
|
54
|
+
const location = ((0, dependencies_1.stripSlashes)(path) || '/');
|
|
55
|
+
const subApp = service;
|
|
56
|
+
const isSubApp = typeof subApp.service === 'function' && subApp.services;
|
|
57
|
+
if (isSubApp) {
|
|
58
|
+
Object.keys(subApp.services).forEach(subPath => this.use(`${location}/${subPath}`, subApp.service(subPath)));
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
const protoService = (0, service_1.wrapService)(location, service, options);
|
|
62
|
+
const serviceOptions = (0, service_1.getServiceOptions)(service, options);
|
|
63
|
+
for (const name of service_1.protectedMethods) {
|
|
64
|
+
if (serviceOptions.methods.includes(name)) {
|
|
65
|
+
throw new Error(`'${name}' on service '${location}' is not allowed as a custom method name`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
debug(`Registering new service at \`${location}\``);
|
|
69
|
+
// Add all the mixins
|
|
70
|
+
this.mixins.forEach(fn => fn.call(this, protoService, location, serviceOptions));
|
|
71
|
+
// If we ran setup already, set this service up explicitly, this will not `await`
|
|
72
|
+
if (this._isSetup && typeof protoService.setup === 'function') {
|
|
73
|
+
debug(`Setting up service for \`${location}\``);
|
|
74
|
+
protoService.setup(this, location);
|
|
75
|
+
}
|
|
76
|
+
this.services[location] = protoService;
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
hooks(hookMap) {
|
|
80
|
+
const legacyMap = hookMap;
|
|
81
|
+
if (legacyMap.before || legacyMap.after || legacyMap.error) {
|
|
82
|
+
return this.legacyHooks(legacyMap);
|
|
83
|
+
}
|
|
84
|
+
if (Array.isArray(hookMap)) {
|
|
85
|
+
this.appHooks[dependencies_1.HOOKS].push(...hookMap);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const methodHookMap = hookMap;
|
|
89
|
+
Object.keys(methodHookMap).forEach(key => {
|
|
90
|
+
const methodHooks = this.appHooks[key] || [];
|
|
91
|
+
this.appHooks[key] = methodHooks.concat(methodHookMap[key]);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
setup() {
|
|
97
|
+
let promise = Promise.resolve();
|
|
98
|
+
// Setup each service (pass the app so that they can look up other services etc.)
|
|
99
|
+
for (const path of Object.keys(this.services)) {
|
|
100
|
+
promise = promise.then(() => {
|
|
101
|
+
const service = this.service(path);
|
|
102
|
+
if (typeof service.setup === 'function') {
|
|
103
|
+
debug(`Setting up service for \`${path}\``);
|
|
104
|
+
return service.setup(this, path);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return promise.then(() => {
|
|
109
|
+
this._isSetup = true;
|
|
110
|
+
return this;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.Feathers = Feathers;
|
|
115
|
+
//# sourceMappingURL=application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,iDAEwB;AACxB,qCAAiD;AACjD,yCAA0C;AAC1C,u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AO,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"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter, NextFunction, HookContext as BaseHookContext } from './dependencies';
|
|
3
|
+
declare type SelfOrArray<S> = S | S[];
|
|
4
|
+
declare type OptionalPick<T, K extends PropertyKey> = Pick<T, Extract<keyof T, K>>;
|
|
5
|
+
export type { NextFunction };
|
|
6
|
+
export interface Paginated<T> {
|
|
7
|
+
total: number;
|
|
8
|
+
limit: number;
|
|
9
|
+
skip: number;
|
|
10
|
+
data: T[];
|
|
11
|
+
}
|
|
12
|
+
export interface ServiceOptions {
|
|
13
|
+
events?: string[];
|
|
14
|
+
methods?: string[];
|
|
15
|
+
serviceEvents?: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface ServiceMethods<T, D = Partial<T>> {
|
|
18
|
+
find(params?: Params): Promise<T | T[]>;
|
|
19
|
+
get(id: Id, params?: Params): Promise<T>;
|
|
20
|
+
create(data: D, params?: Params): Promise<T>;
|
|
21
|
+
update(id: NullableId, data: D, params?: Params): Promise<T | T[]>;
|
|
22
|
+
patch(id: NullableId, data: D, params?: Params): Promise<T | T[]>;
|
|
23
|
+
remove(id: NullableId, params?: Params): Promise<T | T[]>;
|
|
24
|
+
setup(app: Application, path: string): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export interface ServiceOverloads<T, D> {
|
|
27
|
+
create?(data: D[], params?: Params): Promise<T[]>;
|
|
28
|
+
update?(id: Id, data: D, params?: Params): Promise<T>;
|
|
29
|
+
update?(id: null, data: D, params?: Params): Promise<T[]>;
|
|
30
|
+
patch?(id: Id, data: D, params?: Params): Promise<T>;
|
|
31
|
+
patch?(id: null, data: D, params?: Params): Promise<T[]>;
|
|
32
|
+
remove?(id: Id, params?: Params): Promise<T>;
|
|
33
|
+
remove?(id: null, params?: Params): Promise<T[]>;
|
|
34
|
+
}
|
|
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
|
+
id?: string;
|
|
39
|
+
hooks(options: HookOptions<A, S>): this;
|
|
40
|
+
}
|
|
41
|
+
export interface ServiceHookOverloads<S> {
|
|
42
|
+
find(params: Params, context: HookContext): Promise<HookContext>;
|
|
43
|
+
get(id: Id, params: Params, context: HookContext): Promise<HookContext>;
|
|
44
|
+
create(data: ServiceGenericData<S> | ServiceGenericData<S>[], params: Params, context: HookContext): Promise<HookContext>;
|
|
45
|
+
update(id: NullableId, data: ServiceGenericData<S>, params: Params, context: HookContext): Promise<HookContext>;
|
|
46
|
+
patch(id: NullableId, data: ServiceGenericData<S>, params: Params, context: HookContext): Promise<HookContext>;
|
|
47
|
+
remove(id: NullableId, params: Params, context: HookContext): Promise<HookContext>;
|
|
48
|
+
}
|
|
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
|
+
};
|
|
53
|
+
export declare type ServiceMixin<A> = (service: FeathersService<A>, path: string, options?: ServiceOptions) => void;
|
|
54
|
+
export declare type ServiceGenericType<S> = S extends ServiceInterface<infer T> ? T : any;
|
|
55
|
+
export declare type ServiceGenericData<S> = S extends ServiceInterface<infer _T, infer D> ? D : any;
|
|
56
|
+
export interface FeathersApplication<ServiceTypes = any, AppSettings = any> {
|
|
57
|
+
/**
|
|
58
|
+
* The Feathers application version
|
|
59
|
+
*/
|
|
60
|
+
version: string;
|
|
61
|
+
/**
|
|
62
|
+
* A list of callbacks that run when a new service is registered
|
|
63
|
+
*/
|
|
64
|
+
mixins: ServiceMixin<Application<ServiceTypes, AppSettings>>[];
|
|
65
|
+
/**
|
|
66
|
+
* The index of all services keyed by their path.
|
|
67
|
+
*
|
|
68
|
+
* __Important:__ Services should always be retrieved via `app.service('name')`
|
|
69
|
+
* not via `app.services`.
|
|
70
|
+
*/
|
|
71
|
+
services: ServiceTypes;
|
|
72
|
+
/**
|
|
73
|
+
* The application settings that can be used via
|
|
74
|
+
* `app.get` and `app.set`
|
|
75
|
+
*/
|
|
76
|
+
settings: AppSettings;
|
|
77
|
+
/**
|
|
78
|
+
* A private-ish indicator if `app.setup()` has been called already
|
|
79
|
+
*/
|
|
80
|
+
_isSetup: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Contains all registered application level hooks.
|
|
83
|
+
*/
|
|
84
|
+
appHooks: HookMap<Application<ServiceTypes, AppSettings>, any>;
|
|
85
|
+
/**
|
|
86
|
+
* Retrieve an application setting by name
|
|
87
|
+
*
|
|
88
|
+
* @param name The setting name
|
|
89
|
+
*/
|
|
90
|
+
get<L extends keyof AppSettings & string>(name: L): AppSettings[L];
|
|
91
|
+
/**
|
|
92
|
+
* Set an application setting
|
|
93
|
+
*
|
|
94
|
+
* @param name The setting name
|
|
95
|
+
* @param value The setting value
|
|
96
|
+
*/
|
|
97
|
+
set<L extends keyof AppSettings & string>(name: L, value: AppSettings[L]): this;
|
|
98
|
+
/**
|
|
99
|
+
* Runs a callback configure function with the current application instance.
|
|
100
|
+
*
|
|
101
|
+
* @param callback The callback `(app: Application) => {}` to run
|
|
102
|
+
*/
|
|
103
|
+
configure(callback: (this: this, app: this) => void): this;
|
|
104
|
+
/**
|
|
105
|
+
* Returns a fallback service instance that will be registered
|
|
106
|
+
* when no service was found. Usually throws a `NotFound` error
|
|
107
|
+
* but also used to instantiate client side services.
|
|
108
|
+
*
|
|
109
|
+
* @param location The path of the service
|
|
110
|
+
*/
|
|
111
|
+
defaultService(location: string): ServiceInterface<any>;
|
|
112
|
+
/**
|
|
113
|
+
* Register a new service or a sub-app. When passed another
|
|
114
|
+
* Feathers application, all its services will be re-registered
|
|
115
|
+
* with the `path` prefix.
|
|
116
|
+
*
|
|
117
|
+
* @param path The path for the service to register
|
|
118
|
+
* @param service The service object to register or another
|
|
119
|
+
* Feathers application to use a sub-app under the `path` prefix.
|
|
120
|
+
* @param options The options for this service
|
|
121
|
+
*/
|
|
122
|
+
use<L extends keyof ServiceTypes & string>(path: L, service: keyof any extends keyof ServiceTypes ? ServiceInterface<any> | Application : ServiceTypes[L], options?: ServiceOptions): this;
|
|
123
|
+
/**
|
|
124
|
+
* Get the Feathers service instance for a path. This will
|
|
125
|
+
* be the service originally registered with Feathers functionality
|
|
126
|
+
* like hooks and events added.
|
|
127
|
+
*
|
|
128
|
+
* @param path The name of the service.
|
|
129
|
+
*/
|
|
130
|
+
service<L extends keyof ServiceTypes & string>(path: L): FeathersService<this, keyof any extends keyof ServiceTypes ? Service<any> : ServiceTypes[L]>;
|
|
131
|
+
setup(server?: any): Promise<this>;
|
|
132
|
+
/**
|
|
133
|
+
* Register application level hooks.
|
|
134
|
+
*
|
|
135
|
+
* @param map The application hook settings.
|
|
136
|
+
*/
|
|
137
|
+
hooks(map: HookOptions<this, any>): this;
|
|
138
|
+
}
|
|
139
|
+
export interface Application<ServiceTypes = any, AppSettings = any> extends FeathersApplication<ServiceTypes, AppSettings>, EventEmitter {
|
|
140
|
+
}
|
|
141
|
+
export declare type Id = number | string;
|
|
142
|
+
export declare type NullableId = Id | null;
|
|
143
|
+
export interface Query {
|
|
144
|
+
[key: string]: any;
|
|
145
|
+
}
|
|
146
|
+
export interface Params {
|
|
147
|
+
query?: Query;
|
|
148
|
+
provider?: string;
|
|
149
|
+
route?: {
|
|
150
|
+
[key: string]: string;
|
|
151
|
+
};
|
|
152
|
+
headers?: {
|
|
153
|
+
[key: string]: any;
|
|
154
|
+
};
|
|
155
|
+
[key: string]: any;
|
|
156
|
+
}
|
|
157
|
+
export interface HookContext<A = Application, S = any> extends BaseHookContext<ServiceGenericType<S>> {
|
|
158
|
+
/**
|
|
159
|
+
* A read only property that contains the Feathers application object. This can be used to
|
|
160
|
+
* retrieve other services (via context.app.service('name')) or configuration values.
|
|
161
|
+
*/
|
|
162
|
+
readonly app: A;
|
|
163
|
+
/**
|
|
164
|
+
* A read only property with the name of the service method (one of find, get,
|
|
165
|
+
* create, update, patch, remove).
|
|
166
|
+
*/
|
|
167
|
+
readonly method: string;
|
|
168
|
+
/**
|
|
169
|
+
* A read only property and contains the service name (or path) without leading or
|
|
170
|
+
* trailing slashes.
|
|
171
|
+
*/
|
|
172
|
+
readonly path: string;
|
|
173
|
+
/**
|
|
174
|
+
* A read only property and contains the service this hook currently runs on.
|
|
175
|
+
*/
|
|
176
|
+
readonly service: S;
|
|
177
|
+
/**
|
|
178
|
+
* A read only property with the hook type (one of before, after or error).
|
|
179
|
+
* Will be `null` for asynchronous hooks.
|
|
180
|
+
*/
|
|
181
|
+
readonly type: null | 'before' | 'after' | 'error';
|
|
182
|
+
/**
|
|
183
|
+
* The list of method arguments. Should not be modified, modify the
|
|
184
|
+
* `params`, `data` and `id` properties instead.
|
|
185
|
+
*/
|
|
186
|
+
readonly arguments: any[];
|
|
187
|
+
/**
|
|
188
|
+
* A writeable property containing the data of a create, update and patch service
|
|
189
|
+
* method call.
|
|
190
|
+
*/
|
|
191
|
+
data?: ServiceGenericData<S>;
|
|
192
|
+
/**
|
|
193
|
+
* A writeable property with the error object that was thrown in a failed method call.
|
|
194
|
+
* It is only available in error hooks.
|
|
195
|
+
*/
|
|
196
|
+
error?: any;
|
|
197
|
+
/**
|
|
198
|
+
* A writeable property and the id for a get, remove, update and patch service
|
|
199
|
+
* method call. For remove, update and patch context.id can also be null when
|
|
200
|
+
* modifying multiple entries. In all other cases it will be undefined.
|
|
201
|
+
*/
|
|
202
|
+
id?: Id;
|
|
203
|
+
/**
|
|
204
|
+
* A writeable property that contains the service method parameters (including
|
|
205
|
+
* params.query).
|
|
206
|
+
*/
|
|
207
|
+
params: Params;
|
|
208
|
+
/**
|
|
209
|
+
* A writeable property containing the result of the successful service method call.
|
|
210
|
+
* It is only available in after hooks.
|
|
211
|
+
*
|
|
212
|
+
* `context.result` can also be set in
|
|
213
|
+
*
|
|
214
|
+
* - A before hook to skip the actual service method (database) call
|
|
215
|
+
* - An error hook to swallow the error and return a result instead
|
|
216
|
+
*/
|
|
217
|
+
result?: ServiceGenericType<S>;
|
|
218
|
+
/**
|
|
219
|
+
* A writeable, optional property and contains a 'safe' version of the data that
|
|
220
|
+
* should be sent to any client. If context.dispatch has not been set context.result
|
|
221
|
+
* will be sent to the client instead.
|
|
222
|
+
*/
|
|
223
|
+
dispatch?: ServiceGenericType<S>;
|
|
224
|
+
/**
|
|
225
|
+
* A writeable, optional property that allows to override the standard HTTP status
|
|
226
|
+
* code that should be returned.
|
|
227
|
+
*/
|
|
228
|
+
statusCode?: number;
|
|
229
|
+
/**
|
|
230
|
+
* The event emitted by this method. Can be set to `null` to skip event emitting.
|
|
231
|
+
*/
|
|
232
|
+
event: string | null;
|
|
233
|
+
}
|
|
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>>;
|
|
238
|
+
} & {
|
|
239
|
+
all?: SelfOrArray<LegacyHookFunction<A, S>>;
|
|
240
|
+
};
|
|
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>;
|
|
246
|
+
};
|
|
247
|
+
export declare type HookFunction<A = Application, S = Service<any, any>> = (context: HookContext<A, S>, next: NextFunction) => Promise<void>;
|
|
248
|
+
export declare type HookMap<A, S> = {
|
|
249
|
+
[L in keyof S]?: HookFunction<A, S>[];
|
|
250
|
+
};
|
|
251
|
+
export declare type HookOptions<A, S> = HookMap<A, S> | HookFunction<A, S>[] | LegacyHookMap<A, S>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.js","sourceRoot":"","sources":["../src/declarations.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.EventEmitter = void 0;
|
|
14
|
+
const events_1 = require("events");
|
|
15
|
+
Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return events_1.EventEmitter; } });
|
|
16
|
+
__exportStar(require("@feathersjs/commons"), exports);
|
|
17
|
+
__exportStar(require("@feathersjs/hooks"), exports);
|
|
18
|
+
//# sourceMappingURL=dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mCAAsC;AAI7B,6FAJA,qBAAY,OAIA;AAHrB,sDAAoC;AACpC,oDAAkC"}
|
package/lib/events.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NextFunction } from './dependencies';
|
|
2
|
+
import { HookContext, FeathersService } from './declarations';
|
|
3
|
+
export declare function eventHook(context: HookContext, next: NextFunction): Promise<void>;
|
|
4
|
+
export declare function eventMixin<A>(service: FeathersService<A>): FeathersService<A, import("./declarations").Service<any, Partial<any>>>;
|
package/lib/events.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eventMixin = exports.eventHook = void 0;
|
|
4
|
+
const dependencies_1 = require("./dependencies");
|
|
5
|
+
const service_1 = require("./service");
|
|
6
|
+
function eventHook(context, next) {
|
|
7
|
+
const { events } = (0, service_1.getServiceOptions)(context.self);
|
|
8
|
+
const defaultEvent = service_1.defaultEventMap[context.method] || null;
|
|
9
|
+
context.event = defaultEvent;
|
|
10
|
+
return next().then(() => {
|
|
11
|
+
// Send the event only if the service does not do so already (indicated in the `events` option)
|
|
12
|
+
// This is used for custom events and for client services receiving event from the server
|
|
13
|
+
if (typeof context.event === 'string' && !events.includes(context.event)) {
|
|
14
|
+
const results = Array.isArray(context.result) ? context.result : [context.result];
|
|
15
|
+
results.forEach(element => context.self.emit(context.event, element, context));
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.eventHook = eventHook;
|
|
20
|
+
function eventMixin(service) {
|
|
21
|
+
const isEmitter = typeof service.on === 'function' &&
|
|
22
|
+
typeof service.emit === 'function';
|
|
23
|
+
if (!isEmitter) {
|
|
24
|
+
Object.assign(service, dependencies_1.EventEmitter.prototype);
|
|
25
|
+
}
|
|
26
|
+
return service;
|
|
27
|
+
}
|
|
28
|
+
exports.eventMixin = eventMixin;
|
|
29
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAAA,iDAA4D;AAE5D,uCAA+D;AAE/D,SAAgB,SAAS,CAAE,OAAoB,EAAE,IAAkB;IACjE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,2BAAiB,EAAE,OAAe,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,YAAY,GAAI,yBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IAEtE,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC;IAE7B,OAAO,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QACtB,+FAA+F;QAC/F,yFAAyF;QACzF,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxE,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,OAAO,CAAC,MAAM,CAAE,CAAC;YAEpF,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAE,OAAe,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;SACzF;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAfD,8BAeC;AAED,SAAgB,UAAU,CAAK,OAA2B;IACxD,MAAM,SAAS,GAAG,OAAO,OAAO,CAAC,EAAE,KAAK,UAAU;QAChD,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC;IAErC,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,2BAAY,CAAC,SAAS,CAAC,CAAC;KAChD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AATD,gCASC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HookContextData, HookManager, Middleware } from '../dependencies';
|
|
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>;
|
|
6
|
+
export declare class FeathersHookManager<A> extends HookManager {
|
|
7
|
+
app: A;
|
|
8
|
+
method: string;
|
|
9
|
+
constructor(app: A, method: string);
|
|
10
|
+
collectMiddleware(self: any, args: any[]): Middleware[];
|
|
11
|
+
initializeContext(self: any, args: any[], context: HookContext): import("@feathersjs/hooks/lib/base").HookContext<any, any>;
|
|
12
|
+
middleware(mw: Middleware[]): this;
|
|
13
|
+
}
|
|
14
|
+
export declare function hookMixin<A>(this: A, service: FeathersService<A>, path: string, options: ServiceOptions): FeathersService<A, Service<any, Partial<any>>>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hookMixin = exports.FeathersHookManager = exports.createContext = exports.fromErrorHooks = exports.fromBeforeHook = exports.fromAfterHook = void 0;
|
|
4
|
+
const dependencies_1 = require("../dependencies");
|
|
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; } });
|
|
10
|
+
function createContext(service, method, data = {}) {
|
|
11
|
+
const createContext = service[method].createContext;
|
|
12
|
+
if (typeof createContext !== 'function') {
|
|
13
|
+
throw new Error(`Can not create context for method ${method}`);
|
|
14
|
+
}
|
|
15
|
+
return createContext(data);
|
|
16
|
+
}
|
|
17
|
+
exports.createContext = createContext;
|
|
18
|
+
class FeathersHookManager extends dependencies_1.HookManager {
|
|
19
|
+
constructor(app, method) {
|
|
20
|
+
super();
|
|
21
|
+
this.app = app;
|
|
22
|
+
this.method = method;
|
|
23
|
+
this._middleware = [];
|
|
24
|
+
}
|
|
25
|
+
collectMiddleware(self, args) {
|
|
26
|
+
const app = this.app;
|
|
27
|
+
const appHooks = app.appHooks[dependencies_1.HOOKS].concat(app.appHooks[this.method] || []);
|
|
28
|
+
const legacyAppHooks = (0, legacy_1.collectLegacyHooks)(this.app, this.method);
|
|
29
|
+
const middleware = super.collectMiddleware(self, args);
|
|
30
|
+
const legacyHooks = (0, legacy_1.collectLegacyHooks)(self, this.method);
|
|
31
|
+
return [...appHooks, ...legacyAppHooks, ...middleware, ...legacyHooks];
|
|
32
|
+
}
|
|
33
|
+
initializeContext(self, args, context) {
|
|
34
|
+
const ctx = super.initializeContext(self, args, context);
|
|
35
|
+
ctx.params = ctx.params || {};
|
|
36
|
+
return ctx;
|
|
37
|
+
}
|
|
38
|
+
middleware(mw) {
|
|
39
|
+
this._middleware.push(...mw);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.FeathersHookManager = FeathersHookManager;
|
|
44
|
+
function hookMixin(service, path, options) {
|
|
45
|
+
if (typeof service.hooks === 'function') {
|
|
46
|
+
return service;
|
|
47
|
+
}
|
|
48
|
+
const app = this;
|
|
49
|
+
const serviceMethodHooks = (0, service_1.getHookMethods)(service, options).reduce((res, method) => {
|
|
50
|
+
const params = service_1.defaultServiceArguments[method] || ['data', 'params'];
|
|
51
|
+
res[method] = new FeathersHookManager(app, method)
|
|
52
|
+
.params(...params)
|
|
53
|
+
.props({
|
|
54
|
+
app,
|
|
55
|
+
path,
|
|
56
|
+
method,
|
|
57
|
+
service,
|
|
58
|
+
event: null,
|
|
59
|
+
type: null
|
|
60
|
+
});
|
|
61
|
+
return res;
|
|
62
|
+
}, {});
|
|
63
|
+
const handleLegacyHooks = (0, legacy_1.enableLegacyHooks)(service);
|
|
64
|
+
(0, dependencies_1.hooks)(service, serviceMethodHooks);
|
|
65
|
+
service.hooks = function (hookOptions) {
|
|
66
|
+
if (hookOptions.before || hookOptions.after || hookOptions.error) {
|
|
67
|
+
return handleLegacyHooks.call(this, hookOptions);
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(hookOptions)) {
|
|
70
|
+
return (0, dependencies_1.hooks)(this, hookOptions);
|
|
71
|
+
}
|
|
72
|
+
Object.keys(hookOptions).forEach(method => {
|
|
73
|
+
const manager = (0, dependencies_1.getManager)(this[method]);
|
|
74
|
+
if (!(manager instanceof FeathersHookManager)) {
|
|
75
|
+
throw new Error(`Method ${method} is not a Feathers hooks enabled service method`);
|
|
76
|
+
}
|
|
77
|
+
manager.middleware(hookOptions[method]);
|
|
78
|
+
});
|
|
79
|
+
return this;
|
|
80
|
+
};
|
|
81
|
+
return service;
|
|
82
|
+
}
|
|
83
|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,GAAG,CAAC;IACb,CAAC,EAAE,EAAa,CAAC,CAAC;IAClB,MAAM,iBAAiB,GAAG,IAAA,0BAAiB,EAAC,OAAO,CAAC,CAAC;IAErD,IAAA,oBAAK,EAAC,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,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SAClD;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;AAnDD,8BAmDC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LegacyHookFunction } from '../declarations';
|
|
2
|
+
export declare function fromBeforeHook(hook: LegacyHookFunction): (context: any, next: any) => Promise<any>;
|
|
3
|
+
export declare function fromAfterHook(hook: LegacyHookFunction): (context: any, next: any) => any;
|
|
4
|
+
export declare function fromErrorHooks(hooks: LegacyHookFunction[]): (context: any, next: any) => any;
|
|
5
|
+
export declare function collectLegacyHooks(target: any, method: string): any[];
|
|
6
|
+
export declare function convertHookData(obj: any): any;
|
|
7
|
+
export declare function enableLegacyHooks(obj: any, methods?: string[], types?: string[]): (this: any, allHooks: any) => any;
|