@feathersjs/feathers 5.0.0-pre.32 → 5.0.0-pre.34
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 +16 -0
- package/lib/application.d.ts +1 -1
- package/lib/application.js.map +1 -1
- package/lib/declarations.d.ts +66 -46
- package/lib/events.d.ts +1 -1
- package/lib/hooks.d.ts +5 -5
- package/lib/hooks.js +1 -1
- package/lib/hooks.js.map +1 -1
- package/lib/service.d.ts +3 -1
- package/lib/service.js +13 -11
- package/lib/service.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +8 -8
- package/src/application.ts +2 -2
- package/src/declarations.ts +64 -23
- package/src/hooks.ts +3 -4
- package/src/service.ts +12 -9
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **core:** `context.type` for around hooks ([#2890](https://github.com/feathersjs/feathers/issues/2890)) ([d606ac6](https://github.com/feathersjs/feathers/commit/d606ac660fd5335c95206784fea36530dd2e851a))
|
|
11
|
+
- **core:** Allow services with no external methods ([#2921](https://github.com/feathersjs/feathers/issues/2921)) ([df56918](https://github.com/feathersjs/feathers/commit/df569183d1a9ed0a9e0ea5bf8d7dab52d326a33d))
|
|
12
|
+
- **core:** Improve service option usage and method option typings ([#2902](https://github.com/feathersjs/feathers/issues/2902)) ([164d75c](https://github.com/feathersjs/feathers/commit/164d75c0f11139a316baa91f1762de8f8eb7da2d))
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **adapter:** Add patch data type to adapters and refactor AdapterBase usage ([#2906](https://github.com/feathersjs/feathers/issues/2906)) ([9ddc2e6](https://github.com/feathersjs/feathers/commit/9ddc2e6b028f026f939d6af68125847e5c6734b4))
|
|
17
|
+
|
|
18
|
+
# [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @feathersjs/feathers
|
|
21
|
+
|
|
6
22
|
# [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26)
|
|
7
23
|
|
|
8
24
|
### Bug Fixes
|
package/lib/application.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class Feathers<Services, Settings> extends EventEmitter implement
|
|
|
20
20
|
protected _teardown(): Promise<this>;
|
|
21
21
|
get teardown(): () => Promise<this>;
|
|
22
22
|
set teardown(value: () => Promise<this>);
|
|
23
|
-
use<L extends keyof Services & string>(path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions): this;
|
|
23
|
+
use<L extends keyof Services & string>(path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions<keyof any extends keyof Services ? string : keyof Services[L]>): this;
|
|
24
24
|
unuse<L extends keyof Services & string>(location: L): Promise<FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>>;
|
|
25
25
|
hooks(hookMap: ApplicationHookOptions<this>): this;
|
|
26
26
|
}
|
package/lib/application.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+B;AAC/B,mCAAqC;AACrC,iDAA+D;AAC/D,6CAA4D;AAC5D,qCAAgD;AAChD,mCAAmC;AACnC,uCAA4E;AAW5E,mCAAqC;AAErC,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,s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AK,IAAI,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,MAAM,EAAE;YAClF,wCAAwC;YACxC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;SAC/B;aAAM,IAAI,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,QAAQ,EAAE;YAClD,yCAAyC;YACzC,IAAA,aAAK,EAAC,IAAI,EAAE,UAAU,CAAC,CAAA;SACxB;aAAM;YACL,qDAAqD;YACrD,IAAI,CAAC,aAAa,CAAC;gBACjB,MAAM,EAAE,UAAU;aACnB,CAAC,CAAA;SACH;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA1MD,4BA0MC"}
|
package/lib/declarations.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { NextFunction, HookContext as BaseHookContext } from '@feathersjs/hooks';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type SelfOrArray<S> = S | S[];
|
|
5
|
+
type OptionalPick<T, K extends PropertyKey> = Pick<T, Extract<keyof T, K>>;
|
|
6
6
|
export type { NextFunction };
|
|
7
7
|
/**
|
|
8
8
|
* The object returned from `.find` call by standard database adapters
|
|
@@ -16,10 +16,23 @@ export interface Paginated<T> {
|
|
|
16
16
|
/**
|
|
17
17
|
* Options that can be passed when registering a service via `app.use(name, service, options)`
|
|
18
18
|
*/
|
|
19
|
-
export interface ServiceOptions {
|
|
19
|
+
export interface ServiceOptions<MethodTypes = string> {
|
|
20
|
+
/**
|
|
21
|
+
* A list of custom events that this service emits to clients
|
|
22
|
+
*/
|
|
20
23
|
events?: string[] | readonly string[];
|
|
21
|
-
|
|
24
|
+
/**
|
|
25
|
+
* A list of service methods that should be available __externally__ to clients
|
|
26
|
+
*/
|
|
27
|
+
methods?: MethodTypes[] | readonly MethodTypes[];
|
|
28
|
+
/**
|
|
29
|
+
* Provide a full list of events that this service should emit to clients.
|
|
30
|
+
* Unlike the `events` option, this will not be merged with the default events.
|
|
31
|
+
*/
|
|
22
32
|
serviceEvents?: string[] | readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* Initial data to always add as route params to this service.
|
|
35
|
+
*/
|
|
23
36
|
routeParams?: {
|
|
24
37
|
[key: string]: any;
|
|
25
38
|
};
|
|
@@ -39,27 +52,34 @@ export interface ClientService<Result = any, Data = Partial<Result>, PatchData =
|
|
|
39
52
|
remove(id: Id, params?: P): Promise<Result>;
|
|
40
53
|
remove(id: null, params?: P): Promise<Result[]>;
|
|
41
54
|
}
|
|
42
|
-
export interface ServiceMethods<
|
|
43
|
-
find(params?:
|
|
44
|
-
get(id: Id, params?:
|
|
45
|
-
create(data:
|
|
46
|
-
update(id: NullableId, data:
|
|
47
|
-
patch(id: NullableId, data:
|
|
48
|
-
remove(id: NullableId, params?:
|
|
55
|
+
export interface ServiceMethods<Result = any, Data = Partial<Result>, ServiceParams = Params, PatchData = Partial<Data>> {
|
|
56
|
+
find(params?: ServiceParams): Promise<Result | Result[]>;
|
|
57
|
+
get(id: Id, params?: ServiceParams): Promise<Result>;
|
|
58
|
+
create(data: Data, params?: ServiceParams): Promise<Result>;
|
|
59
|
+
update(id: NullableId, data: Data, params?: ServiceParams): Promise<Result | Result[]>;
|
|
60
|
+
patch(id: NullableId, data: PatchData, params?: ServiceParams): Promise<Result | Result[]>;
|
|
61
|
+
remove(id: NullableId, params?: ServiceParams): Promise<Result | Result[]>;
|
|
49
62
|
setup?(app: Application, path: string): Promise<void>;
|
|
50
63
|
teardown?(app: Application, path: string): Promise<void>;
|
|
51
64
|
}
|
|
52
|
-
export interface ServiceOverloads<
|
|
53
|
-
create?(data:
|
|
54
|
-
update?(id: Id, data:
|
|
55
|
-
update?(id: null, data:
|
|
56
|
-
patch?(id: Id, data:
|
|
57
|
-
patch?(id: null, data:
|
|
58
|
-
remove?(id: Id, params?:
|
|
59
|
-
remove?(id: null, params?:
|
|
65
|
+
export interface ServiceOverloads<Result = any, Data = Partial<Result>, ServiceParams = Params, PatchData = Partial<Data>> {
|
|
66
|
+
create?(data: Data[], params?: ServiceParams): Promise<Result[]>;
|
|
67
|
+
update?(id: Id, data: Data, params?: ServiceParams): Promise<Result>;
|
|
68
|
+
update?(id: null, data: Data, params?: ServiceParams): Promise<Result[]>;
|
|
69
|
+
patch?(id: Id, data: PatchData, params?: ServiceParams): Promise<Result>;
|
|
70
|
+
patch?(id: null, data: PatchData, params?: ServiceParams): Promise<Result[]>;
|
|
71
|
+
remove?(id: Id, params?: ServiceParams): Promise<Result>;
|
|
72
|
+
remove?(id: null, params?: ServiceParams): Promise<Result[]>;
|
|
60
73
|
}
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
/**
|
|
75
|
+
* A complete service interface. The `ServiceInterface` type should be preferred for customs service
|
|
76
|
+
* implementations
|
|
77
|
+
*/
|
|
78
|
+
export type Service<Result = any, Data = Partial<Result>, ServiceParams = Params, PatchData = Partial<Data>> = ServiceMethods<Result, Data, ServiceParams> & ServiceOverloads<Result, Data, ServiceParams, PatchData>;
|
|
79
|
+
/**
|
|
80
|
+
* The `Service` service interface but with none of the methods required.
|
|
81
|
+
*/
|
|
82
|
+
export type ServiceInterface<Result = any, Data = Partial<Result>, ServiceParams = Params, PatchData = Partial<Data>> = Partial<ServiceMethods<Result, Data, ServiceParams, PatchData>>;
|
|
63
83
|
export interface ServiceAddons<A = Application, S = Service> extends EventEmitter {
|
|
64
84
|
id?: string;
|
|
65
85
|
hooks(options: HookOptions<A, S>): this;
|
|
@@ -72,8 +92,8 @@ export interface ServiceHookOverloads<S, P = Params> {
|
|
|
72
92
|
patch(id: NullableId, data: ServiceGenericData<S>, params: P, context: HookContext): Promise<HookContext>;
|
|
73
93
|
remove(id: NullableId, params: P, context: HookContext): Promise<HookContext>;
|
|
74
94
|
}
|
|
75
|
-
export
|
|
76
|
-
export
|
|
95
|
+
export type FeathersService<A = FeathersApplication, S = Service> = S & ServiceAddons<A, S> & OptionalPick<ServiceHookOverloads<S>, keyof S>;
|
|
96
|
+
export type CustomMethods<T extends {
|
|
77
97
|
[key: string]: [any, any];
|
|
78
98
|
}> = {
|
|
79
99
|
[K in keyof T]: (data: T[K][0], params?: Params) => Promise<T[K][1]>;
|
|
@@ -82,7 +102,7 @@ export declare type CustomMethods<T extends {
|
|
|
82
102
|
* An interface usually use by transport clients that represents a e.g. HTTP or websocket
|
|
83
103
|
* connection that can be configured on the application.
|
|
84
104
|
*/
|
|
85
|
-
export
|
|
105
|
+
export type TransportConnection<Services = any> = {
|
|
86
106
|
(app: Application<Services>): void;
|
|
87
107
|
Service: any;
|
|
88
108
|
service: <L extends keyof Services & string>(name: L) => keyof any extends keyof Services ? ServiceInterface : Services[L];
|
|
@@ -96,11 +116,11 @@ export interface RealTimeConnection {
|
|
|
96
116
|
/**
|
|
97
117
|
* The interface for a custom service method. Can e.g. be used to type client side services.
|
|
98
118
|
*/
|
|
99
|
-
export
|
|
100
|
-
export
|
|
101
|
-
export
|
|
102
|
-
export
|
|
103
|
-
export
|
|
119
|
+
export type CustomMethod<T = any, R = T, P extends Params = Params> = (data: T, params?: P) => Promise<R>;
|
|
120
|
+
export type ServiceMixin<A> = (service: FeathersService<A>, path: string, options: ServiceOptions) => void;
|
|
121
|
+
export type ServiceGenericType<S> = S extends ServiceInterface<infer T> ? T : any;
|
|
122
|
+
export type ServiceGenericData<S> = S extends ServiceInterface<infer _T, infer D> ? D : any;
|
|
123
|
+
export type ServiceGenericParams<S> = S extends ServiceInterface<infer _T, infer _D, infer P> ? P : any;
|
|
104
124
|
export interface FeathersApplication<Services = any, Settings = any> {
|
|
105
125
|
/**
|
|
106
126
|
* The Feathers application version
|
|
@@ -163,7 +183,7 @@ export interface FeathersApplication<Services = any, Settings = any> {
|
|
|
163
183
|
* Feathers application to use a sub-app under the `path` prefix.
|
|
164
184
|
* @param options The options for this service
|
|
165
185
|
*/
|
|
166
|
-
use<L extends keyof Services & string>(path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions): this;
|
|
186
|
+
use<L extends keyof Services & string>(path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions<keyof any extends keyof Services ? string : keyof Services[L]>): this;
|
|
167
187
|
/**
|
|
168
188
|
* Unregister an existing service.
|
|
169
189
|
*
|
|
@@ -199,8 +219,8 @@ export interface FeathersApplication<Services = any, Settings = any> {
|
|
|
199
219
|
}
|
|
200
220
|
export interface Application<Services = any, Settings = any> extends FeathersApplication<Services, Settings>, EventEmitter {
|
|
201
221
|
}
|
|
202
|
-
export
|
|
203
|
-
export
|
|
222
|
+
export type Id = number | string;
|
|
223
|
+
export type NullableId = Id | null;
|
|
204
224
|
export interface Query {
|
|
205
225
|
[key: string]: any;
|
|
206
226
|
}
|
|
@@ -230,6 +250,7 @@ export interface Http {
|
|
|
230
250
|
*/
|
|
231
251
|
location?: string;
|
|
232
252
|
}
|
|
253
|
+
export type HookType = 'before' | 'after' | 'error' | 'around';
|
|
233
254
|
export interface HookContext<A = Application, S = any> extends BaseHookContext<ServiceGenericType<S>> {
|
|
234
255
|
/**
|
|
235
256
|
* A read only property that contains the Feathers application object. This can be used to
|
|
@@ -251,10 +272,9 @@ export interface HookContext<A = Application, S = any> extends BaseHookContext<S
|
|
|
251
272
|
*/
|
|
252
273
|
readonly service: S;
|
|
253
274
|
/**
|
|
254
|
-
* A read only property with the hook type (one of before, after or error).
|
|
255
|
-
* Will be `null` for asynchronous hooks.
|
|
275
|
+
* A read only property with the hook type (one of 'around', 'before', 'after' or 'error').
|
|
256
276
|
*/
|
|
257
|
-
readonly type:
|
|
277
|
+
readonly type: HookType;
|
|
258
278
|
/**
|
|
259
279
|
* The list of method arguments. Should not be modified, modify the
|
|
260
280
|
* `params`, `data` and `id` properties instead.
|
|
@@ -313,34 +333,34 @@ export interface HookContext<A = Application, S = any> extends BaseHookContext<S
|
|
|
313
333
|
*/
|
|
314
334
|
event: string | null;
|
|
315
335
|
}
|
|
316
|
-
export
|
|
317
|
-
export
|
|
318
|
-
|
|
336
|
+
export type HookFunction<A = Application, S = Service> = (this: S, context: HookContext<A, S>) => Promise<HookContext<Application, S> | void> | HookContext<Application, S> | void;
|
|
337
|
+
export type Hook<A = Application, S = Service> = HookFunction<A, S>;
|
|
338
|
+
type HookMethodMap<A, S> = {
|
|
319
339
|
[L in keyof S]?: SelfOrArray<HookFunction<A, S>>;
|
|
320
340
|
} & {
|
|
321
341
|
all?: SelfOrArray<HookFunction<A, S>>;
|
|
322
342
|
};
|
|
323
|
-
|
|
324
|
-
export
|
|
325
|
-
export
|
|
343
|
+
type HookTypeMap<A, S> = SelfOrArray<HookFunction<A, S>> | HookMethodMap<A, S>;
|
|
344
|
+
export type AroundHookFunction<A = Application, S = Service> = (context: HookContext<A, S>, next: NextFunction) => Promise<void>;
|
|
345
|
+
export type AroundHookMap<A, S> = {
|
|
326
346
|
[L in keyof S]?: AroundHookFunction<A, S>[];
|
|
327
347
|
} & {
|
|
328
348
|
all?: AroundHookFunction<A, S>[];
|
|
329
349
|
};
|
|
330
|
-
export
|
|
350
|
+
export type HookMap<A, S> = {
|
|
331
351
|
around?: AroundHookMap<A, S>;
|
|
332
352
|
before?: HookTypeMap<A, S>;
|
|
333
353
|
after?: HookTypeMap<A, S>;
|
|
334
354
|
error?: HookTypeMap<A, S>;
|
|
335
355
|
};
|
|
336
|
-
export
|
|
356
|
+
export type HookOptions<A, S> = AroundHookMap<A, S> | AroundHookFunction<A, S>[] | HookMap<A, S>;
|
|
337
357
|
export interface ApplicationHookContext<A = Application> extends BaseHookContext {
|
|
338
358
|
app: A;
|
|
339
359
|
server: any;
|
|
340
360
|
}
|
|
341
|
-
export
|
|
342
|
-
export
|
|
361
|
+
export type ApplicationHookFunction<A> = (context: ApplicationHookContext<A>, next: NextFunction) => Promise<void>;
|
|
362
|
+
export type ApplicationHookMap<A> = {
|
|
343
363
|
setup?: ApplicationHookFunction<A>[];
|
|
344
364
|
teardown?: ApplicationHookFunction<A>[];
|
|
345
365
|
};
|
|
346
|
-
export
|
|
366
|
+
export type ApplicationHookOptions<A> = HookOptions<A, any> | ApplicationHookMap<A>;
|
package/lib/events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { NextFunction } from '@feathersjs/hooks';
|
|
2
2
|
import { HookContext, FeathersService } from './declarations';
|
|
3
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>, import("./declarations").Params<import("./declarations").Query
|
|
4
|
+
export declare function eventMixin<A>(service: FeathersService<A>): FeathersService<A, import("./declarations").Service<any, Partial<any>, import("./declarations").Params<import("./declarations").Query>, Partial<Partial<any>>>>;
|
package/lib/hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HookContextData, HookManager, Middleware } from '@feathersjs/hooks';
|
|
2
2
|
import { Service, ServiceOptions, HookContext, FeathersService, HookMap, AroundHookFunction, HookFunction } from './declarations';
|
|
3
|
-
|
|
3
|
+
type HookStore = {
|
|
4
4
|
around: {
|
|
5
5
|
[method: string]: AroundHookFunction[];
|
|
6
6
|
};
|
|
@@ -17,13 +17,13 @@ declare type HookStore = {
|
|
|
17
17
|
[method: string]: AroundHookFunction[];
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type HookEnabled = {
|
|
21
21
|
__hooks: HookStore;
|
|
22
22
|
};
|
|
23
23
|
export declare function convertHookData(input: any): {
|
|
24
|
-
[method: string]: AroundHookFunction<import("./declarations").Application<any, any>, Service<any, Partial<any>, import("./declarations").Params<import("./declarations").Query
|
|
24
|
+
[method: string]: AroundHookFunction<import("./declarations").Application<any, any>, Service<any, Partial<any>, import("./declarations").Params<import("./declarations").Query>, Partial<Partial<any>>>>[] | HookFunction<import("./declarations").Application<any, any>, Service<any, Partial<any>, import("./declarations").Params<import("./declarations").Query>, Partial<Partial<any>>>>[];
|
|
25
25
|
};
|
|
26
|
-
export declare function collectHooks(target: HookEnabled, method: string): AroundHookFunction<import("./declarations").Application<any, any>, Service<any, Partial<any>, import("./declarations").Params<import("./declarations").Query
|
|
26
|
+
export declare function collectHooks(target: HookEnabled, method: string): AroundHookFunction<import("./declarations").Application<any, any>, Service<any, Partial<any>, import("./declarations").Params<import("./declarations").Query>, Partial<Partial<any>>>>[];
|
|
27
27
|
export declare function enableHooks(object: any): (this: HookEnabled, input: HookMap<any, any>) => HookEnabled;
|
|
28
28
|
export declare function createContext(service: Service, method: string, data?: HookContextData): HookContext<import("./declarations").Application<any, any>, any>;
|
|
29
29
|
export declare class FeathersHookManager<A> extends HookManager {
|
|
@@ -34,5 +34,5 @@ export declare class FeathersHookManager<A> extends HookManager {
|
|
|
34
34
|
initializeContext(self: any, args: any[], context: HookContext): import("@feathersjs/hooks").HookContext<any, any>;
|
|
35
35
|
middleware(mw: Middleware[]): this;
|
|
36
36
|
}
|
|
37
|
-
export declare function hookMixin<A>(this: A, service: FeathersService<A>, path: string, options: ServiceOptions): FeathersService<A, Service<any, Partial<any>, import("./declarations").Params<import("./declarations").Query
|
|
37
|
+
export declare function hookMixin<A>(this: A, service: FeathersService<A>, path: string, options: ServiceOptions): FeathersService<A, Service<any, Partial<any>, import("./declarations").Params<import("./declarations").Query>, Partial<Partial<any>>>>;
|
|
38
38
|
export {};
|
package/lib/hooks.js
CHANGED
package/lib/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;AAAA,6CAQ0B;
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":";;;AAAA,6CAQ0B;AAW1B,uCAAmE;AAcnE,MAAM,KAAK,GAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;AAEhE,MAAM,MAAM,GAAG,CAAC,KAAU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,9 @@ export declare const defaultEventMap: {
|
|
|
15
15
|
patch: string;
|
|
16
16
|
remove: string;
|
|
17
17
|
};
|
|
18
|
+
export declare const defaultServiceEvents: string[];
|
|
18
19
|
export declare const protectedMethods: string[];
|
|
19
20
|
export declare function getHookMethods(service: any, options: ServiceOptions): string[];
|
|
20
|
-
export declare function getServiceOptions(service: any
|
|
21
|
+
export declare function getServiceOptions(service: any): ServiceOptions;
|
|
22
|
+
export declare const normalizeServiceOptions: (service: any, options?: ServiceOptions) => ServiceOptions;
|
|
21
23
|
export declare function wrapService(location: string, service: any, options: ServiceOptions): any;
|
package/lib/service.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapService = exports.getServiceOptions = exports.getHookMethods = exports.protectedMethods = exports.defaultEventMap = exports.defaultServiceMethods = exports.defaultServiceArguments = exports.SERVICE = void 0;
|
|
3
|
+
exports.wrapService = exports.normalizeServiceOptions = exports.getServiceOptions = exports.getHookMethods = exports.protectedMethods = exports.defaultServiceEvents = exports.defaultEventMap = exports.defaultServiceMethods = exports.defaultServiceArguments = exports.SERVICE = void 0;
|
|
4
4
|
const events_1 = require("events");
|
|
5
5
|
const commons_1 = require("@feathersjs/commons");
|
|
6
6
|
exports.SERVICE = (0, commons_1.createSymbol)('@feathersjs/service');
|
|
@@ -19,6 +19,7 @@ exports.defaultEventMap = {
|
|
|
19
19
|
patch: 'patched',
|
|
20
20
|
remove: 'removed'
|
|
21
21
|
};
|
|
22
|
+
exports.defaultServiceEvents = Object.values(exports.defaultEventMap);
|
|
22
23
|
exports.protectedMethods = Object.keys(Object.prototype)
|
|
23
24
|
.concat(Object.keys(events_1.EventEmitter.prototype))
|
|
24
25
|
.concat(['all', 'around', 'before', 'after', 'error', 'hooks', 'setup', 'teardown', 'publish']);
|
|
@@ -29,29 +30,30 @@ function getHookMethods(service, options) {
|
|
|
29
30
|
.concat(methods);
|
|
30
31
|
}
|
|
31
32
|
exports.getHookMethods = getHookMethods;
|
|
32
|
-
function getServiceOptions(service
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
function getServiceOptions(service) {
|
|
34
|
+
return service[exports.SERVICE];
|
|
35
|
+
}
|
|
36
|
+
exports.getServiceOptions = getServiceOptions;
|
|
37
|
+
const normalizeServiceOptions = (service, options = {}) => {
|
|
37
38
|
const { methods = exports.defaultServiceMethods.filter((method) => typeof service[method] === 'function'), events = service.events || [] } = options;
|
|
38
|
-
const
|
|
39
|
+
const serviceEvents = options.serviceEvents || exports.defaultServiceEvents.concat(events);
|
|
39
40
|
return {
|
|
40
41
|
...options,
|
|
41
42
|
events,
|
|
42
43
|
methods,
|
|
43
44
|
serviceEvents
|
|
44
45
|
};
|
|
45
|
-
}
|
|
46
|
-
exports.
|
|
46
|
+
};
|
|
47
|
+
exports.normalizeServiceOptions = normalizeServiceOptions;
|
|
47
48
|
function wrapService(location, service, options) {
|
|
48
49
|
// Do nothing if this is already an initialized
|
|
49
50
|
if (service[exports.SERVICE]) {
|
|
50
51
|
return service;
|
|
51
52
|
}
|
|
52
53
|
const protoService = Object.create(service);
|
|
53
|
-
const serviceOptions =
|
|
54
|
-
if (Object.keys(serviceOptions.methods).length === 0 &&
|
|
54
|
+
const serviceOptions = (0, exports.normalizeServiceOptions)(service, options);
|
|
55
|
+
if (Object.keys(serviceOptions.methods).length === 0 &&
|
|
56
|
+
![...exports.defaultServiceMethods, 'setup', 'teardown'].some((method) => typeof service[method] === 'function')) {
|
|
55
57
|
throw new Error(`Invalid service object passed for path \`${location}\``);
|
|
56
58
|
}
|
|
57
59
|
Object.defineProperty(protoService, exports.SERVICE, {
|
package/lib/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AACrC,iDAAkD;AAGrC,QAAA,OA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M,KAAK,CAAC;QAChD,CAAC,CAAC,GAAG,6BAAqB,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,EACxG;QACA,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,IAAI,CAAC,CAAA;KAC1E;IAED,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,eAAO,EAAE;QAC3C,KAAK,EAAE,cAAc;KACtB,CAAC,CAAA;IAEF,OAAO,YAAY,CAAA;AACrB,CAAC;AArBD,kCAqBC"}
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "5.0.0-pre.
|
|
1
|
+
declare const _default: "5.0.0-pre.34";
|
|
2
2
|
export default _default;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/feathers",
|
|
3
3
|
"description": "A framework for real-time applications and REST API with JavaScript and TypeScript",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.34",
|
|
5
5
|
"homepage": "http://feathersjs.com",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -58,17 +58,17 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
62
|
-
"@feathersjs/hooks": "^0.7.
|
|
61
|
+
"@feathersjs/commons": "^5.0.0-pre.34",
|
|
62
|
+
"@feathersjs/hooks": "^0.7.6",
|
|
63
63
|
"events": "^3.3.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@types/mocha": "^10.0.
|
|
67
|
-
"@types/node": "^18.
|
|
68
|
-
"mocha": "^10.
|
|
66
|
+
"@types/mocha": "^10.0.1",
|
|
67
|
+
"@types/node": "^18.11.10",
|
|
68
|
+
"mocha": "^10.1.0",
|
|
69
69
|
"shx": "^0.3.4",
|
|
70
70
|
"ts-node": "^10.9.1",
|
|
71
|
-
"typescript": "^4.
|
|
71
|
+
"typescript": "^4.9.3"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "42cca600d00f0b3b9d89fa79be30fcd46bc50132"
|
|
74
74
|
}
|
package/src/application.ts
CHANGED
|
@@ -145,7 +145,7 @@ export class Feathers<Services, Settings>
|
|
|
145
145
|
use<L extends keyof Services & string>(
|
|
146
146
|
path: L,
|
|
147
147
|
service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L],
|
|
148
|
-
options?: ServiceOptions
|
|
148
|
+
options?: ServiceOptions<keyof any extends keyof Services ? string : keyof Services[L]>
|
|
149
149
|
): this {
|
|
150
150
|
if (typeof path !== 'string') {
|
|
151
151
|
throw new Error(`'${path}' is not a valid service path.`)
|
|
@@ -163,7 +163,7 @@ export class Feathers<Services, Settings>
|
|
|
163
163
|
return this
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
const protoService = wrapService(location, service, options)
|
|
166
|
+
const protoService = wrapService(location, service, options as ServiceOptions)
|
|
167
167
|
const serviceOptions = getServiceOptions(protoService)
|
|
168
168
|
|
|
169
169
|
for (const name of protectedMethods) {
|
package/src/declarations.ts
CHANGED
|
@@ -19,10 +19,23 @@ export interface Paginated<T> {
|
|
|
19
19
|
/**
|
|
20
20
|
* Options that can be passed when registering a service via `app.use(name, service, options)`
|
|
21
21
|
*/
|
|
22
|
-
export interface ServiceOptions {
|
|
22
|
+
export interface ServiceOptions<MethodTypes = string> {
|
|
23
|
+
/**
|
|
24
|
+
* A list of custom events that this service emits to clients
|
|
25
|
+
*/
|
|
23
26
|
events?: string[] | readonly string[]
|
|
24
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A list of service methods that should be available __externally__ to clients
|
|
29
|
+
*/
|
|
30
|
+
methods?: MethodTypes[] | readonly MethodTypes[]
|
|
31
|
+
/**
|
|
32
|
+
* Provide a full list of events that this service should emit to clients.
|
|
33
|
+
* Unlike the `events` option, this will not be merged with the default events.
|
|
34
|
+
*/
|
|
25
35
|
serviceEvents?: string[] | readonly string[]
|
|
36
|
+
/**
|
|
37
|
+
* Initial data to always add as route params to this service.
|
|
38
|
+
*/
|
|
26
39
|
routeParams?: { [key: string]: any }
|
|
27
40
|
}
|
|
28
41
|
|
|
@@ -53,43 +66,70 @@ export interface ClientService<
|
|
|
53
66
|
remove(id: null, params?: P): Promise<Result[]>
|
|
54
67
|
}
|
|
55
68
|
|
|
56
|
-
export interface ServiceMethods<
|
|
57
|
-
|
|
69
|
+
export interface ServiceMethods<
|
|
70
|
+
Result = any,
|
|
71
|
+
Data = Partial<Result>,
|
|
72
|
+
ServiceParams = Params,
|
|
73
|
+
PatchData = Partial<Data>
|
|
74
|
+
> {
|
|
75
|
+
find(params?: ServiceParams): Promise<Result | Result[]>
|
|
58
76
|
|
|
59
|
-
get(id: Id, params?:
|
|
77
|
+
get(id: Id, params?: ServiceParams): Promise<Result>
|
|
60
78
|
|
|
61
|
-
create(data:
|
|
79
|
+
create(data: Data, params?: ServiceParams): Promise<Result>
|
|
62
80
|
|
|
63
|
-
update(id: NullableId, data:
|
|
81
|
+
update(id: NullableId, data: Data, params?: ServiceParams): Promise<Result | Result[]>
|
|
64
82
|
|
|
65
|
-
patch(id: NullableId, data:
|
|
83
|
+
patch(id: NullableId, data: PatchData, params?: ServiceParams): Promise<Result | Result[]>
|
|
66
84
|
|
|
67
|
-
remove(id: NullableId, params?:
|
|
85
|
+
remove(id: NullableId, params?: ServiceParams): Promise<Result | Result[]>
|
|
68
86
|
|
|
69
87
|
setup?(app: Application, path: string): Promise<void>
|
|
70
88
|
|
|
71
89
|
teardown?(app: Application, path: string): Promise<void>
|
|
72
90
|
}
|
|
73
91
|
|
|
74
|
-
export interface ServiceOverloads<
|
|
75
|
-
|
|
92
|
+
export interface ServiceOverloads<
|
|
93
|
+
Result = any,
|
|
94
|
+
Data = Partial<Result>,
|
|
95
|
+
ServiceParams = Params,
|
|
96
|
+
PatchData = Partial<Data>
|
|
97
|
+
> {
|
|
98
|
+
create?(data: Data[], params?: ServiceParams): Promise<Result[]>
|
|
76
99
|
|
|
77
|
-
update?(id: Id, data:
|
|
100
|
+
update?(id: Id, data: Data, params?: ServiceParams): Promise<Result>
|
|
78
101
|
|
|
79
|
-
update?(id: null, data:
|
|
102
|
+
update?(id: null, data: Data, params?: ServiceParams): Promise<Result[]>
|
|
80
103
|
|
|
81
|
-
patch?(id: Id, data:
|
|
104
|
+
patch?(id: Id, data: PatchData, params?: ServiceParams): Promise<Result>
|
|
82
105
|
|
|
83
|
-
patch?(id: null, data:
|
|
106
|
+
patch?(id: null, data: PatchData, params?: ServiceParams): Promise<Result[]>
|
|
84
107
|
|
|
85
|
-
remove?(id: Id, params?:
|
|
108
|
+
remove?(id: Id, params?: ServiceParams): Promise<Result>
|
|
86
109
|
|
|
87
|
-
remove?(id: null, params?:
|
|
110
|
+
remove?(id: null, params?: ServiceParams): Promise<Result[]>
|
|
88
111
|
}
|
|
89
112
|
|
|
90
|
-
|
|
113
|
+
/**
|
|
114
|
+
* A complete service interface. The `ServiceInterface` type should be preferred for customs service
|
|
115
|
+
* implementations
|
|
116
|
+
*/
|
|
117
|
+
export type Service<
|
|
118
|
+
Result = any,
|
|
119
|
+
Data = Partial<Result>,
|
|
120
|
+
ServiceParams = Params,
|
|
121
|
+
PatchData = Partial<Data>
|
|
122
|
+
> = ServiceMethods<Result, Data, ServiceParams> & ServiceOverloads<Result, Data, ServiceParams, PatchData>
|
|
91
123
|
|
|
92
|
-
|
|
124
|
+
/**
|
|
125
|
+
* The `Service` service interface but with none of the methods required.
|
|
126
|
+
*/
|
|
127
|
+
export type ServiceInterface<
|
|
128
|
+
Result = any,
|
|
129
|
+
Data = Partial<Result>,
|
|
130
|
+
ServiceParams = Params,
|
|
131
|
+
PatchData = Partial<Data>
|
|
132
|
+
> = Partial<ServiceMethods<Result, Data, ServiceParams, PatchData>>
|
|
93
133
|
|
|
94
134
|
export interface ServiceAddons<A = Application, S = Service> extends EventEmitter {
|
|
95
135
|
id?: string
|
|
@@ -226,7 +266,7 @@ export interface FeathersApplication<Services = any, Settings = any> {
|
|
|
226
266
|
use<L extends keyof Services & string>(
|
|
227
267
|
path: L,
|
|
228
268
|
service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L],
|
|
229
|
-
options?: ServiceOptions
|
|
269
|
+
options?: ServiceOptions<keyof any extends keyof Services ? string : keyof Services[L]>
|
|
230
270
|
): this
|
|
231
271
|
|
|
232
272
|
/**
|
|
@@ -306,6 +346,8 @@ export interface Http {
|
|
|
306
346
|
location?: string
|
|
307
347
|
}
|
|
308
348
|
|
|
349
|
+
export type HookType = 'before' | 'after' | 'error' | 'around'
|
|
350
|
+
|
|
309
351
|
export interface HookContext<A = Application, S = any> extends BaseHookContext<ServiceGenericType<S>> {
|
|
310
352
|
/**
|
|
311
353
|
* A read only property that contains the Feathers application object. This can be used to
|
|
@@ -327,10 +369,9 @@ export interface HookContext<A = Application, S = any> extends BaseHookContext<S
|
|
|
327
369
|
*/
|
|
328
370
|
readonly service: S
|
|
329
371
|
/**
|
|
330
|
-
* A read only property with the hook type (one of before, after or error).
|
|
331
|
-
* Will be `null` for asynchronous hooks.
|
|
372
|
+
* A read only property with the hook type (one of 'around', 'before', 'after' or 'error').
|
|
332
373
|
*/
|
|
333
|
-
readonly type:
|
|
374
|
+
readonly type: HookType
|
|
334
375
|
/**
|
|
335
376
|
* The list of method arguments. Should not be modified, modify the
|
|
336
377
|
* `params`, `data` and `id` properties instead.
|
package/src/hooks.ts
CHANGED
|
@@ -14,12 +14,11 @@ import {
|
|
|
14
14
|
FeathersService,
|
|
15
15
|
HookMap,
|
|
16
16
|
AroundHookFunction,
|
|
17
|
-
HookFunction
|
|
17
|
+
HookFunction,
|
|
18
|
+
HookType
|
|
18
19
|
} from './declarations'
|
|
19
20
|
import { defaultServiceArguments, getHookMethods } from './service'
|
|
20
21
|
|
|
21
|
-
type HookType = 'before' | 'after' | 'error' | 'around'
|
|
22
|
-
|
|
23
22
|
type ConvertedMap = { [type in HookType]: ReturnType<typeof convertHookData> }
|
|
24
23
|
|
|
25
24
|
type HookStore = {
|
|
@@ -172,7 +171,7 @@ export function hookMixin<A>(this: A, service: FeathersService<A>, path: string,
|
|
|
172
171
|
method,
|
|
173
172
|
service,
|
|
174
173
|
event: null,
|
|
175
|
-
type:
|
|
174
|
+
type: 'around',
|
|
176
175
|
get statusCode() {
|
|
177
176
|
return this.http?.status
|
|
178
177
|
},
|
package/src/service.ts
CHANGED
|
@@ -21,6 +21,8 @@ export const defaultEventMap = {
|
|
|
21
21
|
remove: 'removed'
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export const defaultServiceEvents = Object.values(defaultEventMap)
|
|
25
|
+
|
|
24
26
|
export const protectedMethods = Object.keys(Object.prototype)
|
|
25
27
|
.concat(Object.keys(EventEmitter.prototype))
|
|
26
28
|
.concat(['all', 'around', 'before', 'after', 'error', 'hooks', 'setup', 'teardown', 'publish'])
|
|
@@ -33,18 +35,16 @@ export function getHookMethods(service: any, options: ServiceOptions) {
|
|
|
33
35
|
.concat(methods)
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
export function getServiceOptions(service: any
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (existingOptions) {
|
|
40
|
-
return existingOptions
|
|
41
|
-
}
|
|
38
|
+
export function getServiceOptions(service: any): ServiceOptions {
|
|
39
|
+
return service[SERVICE]
|
|
40
|
+
}
|
|
42
41
|
|
|
42
|
+
export const normalizeServiceOptions = (service: any, options: ServiceOptions = {}): ServiceOptions => {
|
|
43
43
|
const {
|
|
44
44
|
methods = defaultServiceMethods.filter((method) => typeof service[method] === 'function'),
|
|
45
45
|
events = service.events || []
|
|
46
46
|
} = options
|
|
47
|
-
const
|
|
47
|
+
const serviceEvents = options.serviceEvents || defaultServiceEvents.concat(events)
|
|
48
48
|
|
|
49
49
|
return {
|
|
50
50
|
...options,
|
|
@@ -61,9 +61,12 @@ export function wrapService(location: string, service: any, options: ServiceOpti
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const protoService = Object.create(service)
|
|
64
|
-
const serviceOptions =
|
|
64
|
+
const serviceOptions = normalizeServiceOptions(service, options)
|
|
65
65
|
|
|
66
|
-
if (
|
|
66
|
+
if (
|
|
67
|
+
Object.keys(serviceOptions.methods).length === 0 &&
|
|
68
|
+
![...defaultServiceMethods, 'setup', 'teardown'].some((method) => typeof service[method] === 'function')
|
|
69
|
+
) {
|
|
67
70
|
throw new Error(`Invalid service object passed for path \`${location}\``)
|
|
68
71
|
}
|
|
69
72
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '5.0.0-pre.
|
|
1
|
+
export default '5.0.0-pre.34'
|