@feathersjs/transport-commons 5.0.0-pre.11 → 5.0.0-pre.17
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 +60 -0
- package/LICENSE +1 -1
- package/README.md +1 -2
- package/lib/channels/index.d.ts +10 -10
- package/lib/channels/index.js.map +1 -1
- package/lib/channels/mixins.d.ts +2 -2
- package/lib/channels/mixins.js +1 -1
- package/lib/channels/mixins.js.map +1 -1
- package/lib/http.d.ts +3 -5
- package/lib/http.js +6 -11
- package/lib/http.js.map +1 -1
- package/lib/routing/index.d.ts +9 -4
- package/lib/routing/index.js +15 -15
- package/lib/routing/index.js.map +1 -1
- package/lib/routing/router.d.ts +1 -1
- package/package.json +12 -11
- package/src/channels/index.ts +11 -11
- package/src/channels/mixins.ts +3 -3
- package/src/http.ts +7 -14
- package/src/routing/index.ts +28 -23
- package/src/routing/router.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,66 @@
|
|
|
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.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b))
|
|
36
|
+
* **transport-commons:** Ability to register routes with custom params ([#2482](https://github.com/feathersjs/feathers/issues/2482)) ([497990a](https://github.com/feathersjs/feathers/commit/497990ae4a980e5a52a1f0f932db12cd0e6e254a))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13)
|
|
51
|
+
|
|
52
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12)
|
|
59
|
+
|
|
60
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
6
66
|
# [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06)
|
|
7
67
|
|
|
8
68
|
**Note:** Version bump only for package @feathersjs/transport-commons
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# @feathersjs/transport-commons
|
|
2
2
|
|
|
3
3
|
[](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
|
|
4
|
-
[](https://david-dm.org/feathersjs/feathers?path=packages/transport-commons)
|
|
5
4
|
[](https://www.npmjs.com/package/@feathersjs/transport-commons)
|
|
6
5
|
|
|
7
6
|
> Shared functionality for Feathers API transports like `@feathers/socketio` and `@feathersjs/primus`. Only intended to be used internally.
|
|
8
7
|
|
|
9
8
|
## License
|
|
10
9
|
|
|
11
|
-
Copyright (c)
|
|
10
|
+
Copyright (c) 2022 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
|
|
12
11
|
|
|
13
12
|
Licensed under the [MIT license](LICENSE).
|
package/lib/channels/index.d.ts
CHANGED
|
@@ -5,19 +5,19 @@ import { keys, Event, Publisher } from './mixins';
|
|
|
5
5
|
import EventEmitter from 'events';
|
|
6
6
|
declare module '@feathersjs/feathers/lib/declarations' {
|
|
7
7
|
interface ServiceAddons<A, S> extends EventEmitter {
|
|
8
|
-
publish(publisher: Publisher<ServiceGenericType<S
|
|
9
|
-
publish(event: Event, publisher: Publisher<ServiceGenericType<S
|
|
10
|
-
registerPublisher(publisher: Publisher<ServiceGenericType<S
|
|
11
|
-
registerPublisher(event: Event, publisher: Publisher<ServiceGenericType<S
|
|
8
|
+
publish(publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
9
|
+
publish(event: Event, publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
10
|
+
registerPublisher(publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
11
|
+
registerPublisher(event: Event, publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
12
12
|
}
|
|
13
|
-
interface Application<
|
|
13
|
+
interface Application<Services, Settings> {
|
|
14
14
|
channels: string[];
|
|
15
|
-
channel(name: string[]): Channel;
|
|
15
|
+
channel(name: string | string[]): Channel;
|
|
16
16
|
channel(...names: string[]): Channel;
|
|
17
|
-
publish<T>(publisher: Publisher<T>): this;
|
|
18
|
-
publish<T>(event: Event, publisher: Publisher<T>): this;
|
|
19
|
-
registerPublisher<T>(publisher: Publisher<T>): this;
|
|
20
|
-
registerPublisher<T>(event: Event, publisher: Publisher<T>): this;
|
|
17
|
+
publish<T>(publisher: Publisher<T, this>): this;
|
|
18
|
+
publish<T>(event: Event, publisher: Publisher<T, this>): this;
|
|
19
|
+
registerPublisher<T>(publisher: Publisher<T, this>): this;
|
|
20
|
+
registerPublisher<T>(event: Event, publisher: Publisher<T, this>): this;
|
|
21
21
|
}
|
|
22
22
|
interface Params {
|
|
23
23
|
connection?: RealTimeConnection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":";;;AAAA,mDAAuF;AACvF,iDAAkD;AAClD,mCAAoD;AAEpD,iDAAqD;AACrD,qCAA4F;AAiCnF,qFAjC4B,aAAI,OAiC5B;AA9Bb,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,wCAAwC,CAAC,CAAC;AACpE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAI,CAAC;AA+B1B,SAAgB,QAAQ;IACtB,OAAO,CAAC,GAAgB,EAAE,EAAE;QAC1B,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,EAAE;YAC1E,OAAO;SACR;QAED,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAA,qBAAY,GAAE,EAA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,CAAC,CAAC,CAAC,CAAC,IAAA,gBAAO,EAAC,IAAA,oBAAW,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAc,CAAC,CAAC;4BAC/F,MAAM,OAAO,GAAG,IAAI,0BAAe,CAAC,OAAO,CAAC,CAAC;4BAE7C,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gCACjC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;6BACjD;iCAAM;gCACL,KAAK,CAAC,8BAA8B,CAAC,CAAC;6BACvC;wBACH,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;qBACpB;oBAAC,OAAO,KAAU,EAAE;wBACnB,QAAQ,CAAC,KAAK,CAAC,CAAC;qBACjB;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAvED,4BAuEC"}
|
package/lib/channels/mixins.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HookContext } from '@feathersjs/feathers';
|
|
1
|
+
import { Application, HookContext } from '@feathersjs/feathers';
|
|
2
2
|
import { Channel } from './channel/base';
|
|
3
3
|
declare const PUBLISHERS: unique symbol;
|
|
4
4
|
declare const CHANNELS: unique symbol;
|
|
@@ -16,7 +16,7 @@ export interface ChannelMixin {
|
|
|
16
16
|
}
|
|
17
17
|
export declare function channelMixin(): ChannelMixin;
|
|
18
18
|
export declare type Event = string | (typeof ALL_EVENTS);
|
|
19
|
-
export declare type Publisher<T = any> = (data: T, context: HookContext<
|
|
19
|
+
export declare type Publisher<T = any, A = Application, S = any> = (data: T, context: HookContext<A, S>) => Channel | Channel[] | void | Promise<Channel | Channel[] | void>;
|
|
20
20
|
export interface PublishMixin<T = any> {
|
|
21
21
|
[PUBLISHERS]: {
|
|
22
22
|
[ALL_EVENTS]?: Publisher<T>;
|
package/lib/channels/mixins.js
CHANGED
|
@@ -6,7 +6,7 @@ const feathers_1 = require("@feathersjs/feathers");
|
|
|
6
6
|
const commons_1 = require("@feathersjs/commons");
|
|
7
7
|
const base_1 = require("./channel/base");
|
|
8
8
|
const combined_1 = require("./channel/combined");
|
|
9
|
-
const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons
|
|
9
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons/channels/mixins');
|
|
10
10
|
const PUBLISHERS = Symbol('@feathersjs/transport-commons/publishers');
|
|
11
11
|
const CHANNELS = Symbol('@feathersjs/transport-commons/channels');
|
|
12
12
|
const ALL_EVENTS = Symbol('@feathersjs/transport-commons/all-events');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixins.js","sourceRoot":"","sources":["../../src/channels/mixins.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"mixins.js","sourceRoot":"","sources":["../../src/channels/mixins.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,mDAAmF;AACnF,iDAAkD;AAClD,yCAAyC;AACzC,iDAAqD;AAErD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,+CAA+C,CAAC,CAAC;AAC3E,MAAM,UAAU,GAAG,MAAM,CAAC,0CAA0C,CAAC,CAAC;AACtE,MAAM,QAAQ,GAAG,MAAM,CAAC,wCAAwC,CAAC,CAAC;AAClE,MAAM,UAAU,GAAG,MAAM,CAAC,0CAA0C,CAAC,CAAC;AAEzD,QAAA,IAAI,GAAG;IAClB,UAAU,EAAE,UAA+B;IAC3C,QAAQ,EAAE,QAA2B;IACrC,UAAU,EAAE,UAA+B;CAC5C,CAAC;AAOF,SAAgB,YAAY;IAC1B,MAAM,KAAK,GAAiB;QAC1B,CAAC,QAAQ,CAAC,EAAE,EAAE;QAEd,OAAO,CAAE,GAAG,KAAe;YACzB,KAAK,CAAC,oB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C,CAAC;QAED,iBAAiB,CAAE,KAAK,EAAE,SAAS;YACjC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;YAEtC,IAAI,CAAC,SAAS,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;gBAC7C,SAAS,GAAG,KAAK,CAAC;gBAClB,KAAK,GAAG,UAAU,CAAC;aACpB;YAED,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,4BAAiB,EAAC,IAAI,CAAC,CAAC;YAElD,IAAI,KAAK,KAAK,UAAU,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBAC1D,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,gCAAgC,CAAC,CAAC;aACvE;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;YAEpC,UAAU,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;YAE9B,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AA/BD,oCA+BC"}
|
package/lib/http.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ export declare const statusCodes: {
|
|
|
12
12
|
success: number;
|
|
13
13
|
};
|
|
14
14
|
export declare const knownMethods: {
|
|
15
|
-
[key: string]:
|
|
15
|
+
[key: string]: string;
|
|
16
16
|
};
|
|
17
|
-
export declare function getServiceMethod(_httpMethod: string, id: unknown, headerOverride?: string):
|
|
17
|
+
export declare function getServiceMethod(_httpMethod: string, id: unknown, headerOverride?: string): string;
|
|
18
18
|
export declare const argumentsFor: {
|
|
19
19
|
get: ({ id, params }: ServiceParams) => (Params | NullableId)[];
|
|
20
20
|
find: ({ params }: ServiceParams) => Params[];
|
|
@@ -24,7 +24,5 @@ export declare const argumentsFor: {
|
|
|
24
24
|
remove: ({ id, params }: ServiceParams) => (Params | NullableId)[];
|
|
25
25
|
default: ({ data, params }: ServiceParams) => any[];
|
|
26
26
|
};
|
|
27
|
-
export declare function getData(context: HookContext
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
}): any;
|
|
27
|
+
export declare function getData(context: HookContext): any;
|
|
30
28
|
export declare function getStatusCode(context: HookContext, data?: any): number;
|
package/lib/http.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getStatusCode = exports.getData = exports.argumentsFor = exports.getServiceMethod = exports.knownMethods = exports.statusCodes = exports.METHOD_HEADER = void 0;
|
|
4
4
|
const lib_1 = require("@feathersjs/errors/lib");
|
|
5
|
-
const hooks_1 = require("@feathersjs/hooks");
|
|
6
5
|
exports.METHOD_HEADER = 'x-service-method';
|
|
7
6
|
exports.statusCodes = {
|
|
8
7
|
created: 201,
|
|
@@ -41,22 +40,18 @@ exports.argumentsFor = {
|
|
|
41
40
|
default: ({ data, params }) => [data, params]
|
|
42
41
|
};
|
|
43
42
|
function getData(context) {
|
|
44
|
-
if (!(context instanceof hooks_1.BaseHookContext)) {
|
|
45
|
-
return context;
|
|
46
|
-
}
|
|
47
43
|
return context.dispatch !== undefined
|
|
48
44
|
? context.dispatch
|
|
49
45
|
: context.result;
|
|
50
46
|
}
|
|
51
47
|
exports.getData = getData;
|
|
52
48
|
function getStatusCode(context, data) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
49
|
+
var _a;
|
|
50
|
+
if ((_a = context.http) === null || _a === void 0 ? void 0 : _a.statusCode) {
|
|
51
|
+
return context.http.statusCode;
|
|
52
|
+
}
|
|
53
|
+
if (context.method === 'create') {
|
|
54
|
+
return exports.statusCodes.created;
|
|
60
55
|
}
|
|
61
56
|
if (!data) {
|
|
62
57
|
return exports.statusCodes.noContent;
|
package/lib/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names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I,EAAE,MAAM,CAAE;IAC7D,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAiB,EAAE,EAAE,CAAC,CAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAE;IACrE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAiB,EAAE,EAAE,CAAC,CAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAE;IACpE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAiB,EAAE,EAAE,CAAC,CAAE,EAAE,EAAE,MAAM,CAAE;IACzD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAiB,EAAE,EAAE,CAAC,CAAE,IAAI,EAAE,MAAM,CAAE;CAC/D,CAAA;AAED,SAAgB,OAAO,CAAE,OAAoB;IAC3C,OAAO,OAAO,CAAC,QAAQ,KAAK,SAAS;QACnC,CAAC,CAAC,OAAO,CAAC,QAAQ;QAClB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;AACrB,CAAC;AAJD,0BAIC;AAED,SAAgB,aAAa,CAAE,OAAoB,EAAE,IAAU;;IAC7D,IAAI,MAAA,OAAO,CAAC,IAAI,0CAAE,UAAU,EAAE;QAC5B,OAAO,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;KAChC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE;QAC/B,OAAO,mBAAW,CAAC,OAAO,CAAC;KAC5B;IAED,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,mBAAW,CAAC,SAAS,CAAC;KAC9B;IAED,OAAO,mBAAW,CAAC,OAAO,CAAC;AAC7B,CAAC;AAdD,sCAcC"}
|
package/lib/routing/index.d.ts
CHANGED
|
@@ -2,13 +2,18 @@ import { Application } from '@feathersjs/feathers';
|
|
|
2
2
|
import { Router } from './router';
|
|
3
3
|
declare module '@feathersjs/feathers/lib/declarations' {
|
|
4
4
|
interface RouteLookup {
|
|
5
|
-
service: Service
|
|
5
|
+
service: Service;
|
|
6
6
|
params: {
|
|
7
|
-
[key: string]:
|
|
7
|
+
[key: string]: any;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
interface Application<
|
|
11
|
-
routes: Router<
|
|
10
|
+
interface Application<Services, Settings> {
|
|
11
|
+
routes: Router<{
|
|
12
|
+
service: Service;
|
|
13
|
+
params?: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
12
17
|
lookup(path: string): RouteLookup;
|
|
13
18
|
}
|
|
14
19
|
}
|
package/lib/routing/index.js
CHANGED
|
@@ -13,26 +13,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.routing = void 0;
|
|
14
14
|
const router_1 = require("./router");
|
|
15
15
|
__exportStar(require("./router"), exports);
|
|
16
|
+
const lookup = function (path) {
|
|
17
|
+
const result = this.routes.lookup(path);
|
|
18
|
+
if (result === null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const { params: colonParams, data: { service, params: dataParams } } = result;
|
|
22
|
+
const params = dataParams ? { ...dataParams, ...colonParams } : colonParams;
|
|
23
|
+
return { service, params };
|
|
24
|
+
};
|
|
16
25
|
const routing = () => (app) => {
|
|
17
26
|
if (typeof app.lookup === 'function') {
|
|
18
27
|
return;
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
routes,
|
|
23
|
-
lookup(path) {
|
|
24
|
-
const result = this.routes.lookup(path);
|
|
25
|
-
if (result !== null) {
|
|
26
|
-
const { params, data: service } = result;
|
|
27
|
-
return { params, service };
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
29
|
+
app.routes = new router_1.Router();
|
|
30
|
+
app.lookup = lookup;
|
|
32
31
|
// Add a mixin that registers a service on the router
|
|
33
|
-
app.mixins.push((service, path) => {
|
|
34
|
-
|
|
35
|
-
app.routes.insert(
|
|
32
|
+
app.mixins.push((service, path, options) => {
|
|
33
|
+
const { routeParams: params = {} } = options;
|
|
34
|
+
app.routes.insert(path, { service, params });
|
|
35
|
+
app.routes.insert(`${path}/:__id`, { service, params });
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
exports.routing = routing;
|
package/lib/routing/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,qCAAkC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,qCAAkC;AAiBlC,2CAAyB;AAEzB,MAAM,MAAM,GAAG,UAA6B,IAAY;IACtD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAExC,IAAI,MAAM,KAAK,IAAI,EAAE;QACnB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,MAAM,CAAC;IAE9E,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IAE5E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC,CAAC;AAEK,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,GAAgB,EAAE,EAAE;IAChD,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,EAAE;QACpC,OAAO;KACR;IAED,GAAG,CAAC,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;IAC1B,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;IAEpB,qDAAqD;IACrD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAgB,EAAE,IAAY,EAAE,OAAuB,EAAE,EAAE;QAC1E,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;QAE7C,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7C,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAfW,QAAA,OAAO,WAelB"}
|
package/lib/routing/router.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class RouteNode<T = any> {
|
|
|
18
18
|
insert(path: string[], data: T): RouteNode<T>;
|
|
19
19
|
lookup(path: string[], info: LookupData): LookupResult<T> | null;
|
|
20
20
|
}
|
|
21
|
-
export declare class Router<T> {
|
|
21
|
+
export declare class Router<T = any> {
|
|
22
22
|
root: RouteNode<T>;
|
|
23
23
|
constructor(root?: RouteNode<T>);
|
|
24
24
|
getPath(path: string): string[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/transport-commons",
|
|
3
3
|
"description": "Shared functionality for websocket providers",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.17",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"types": "lib/",
|
|
@@ -52,18 +52,19 @@
|
|
|
52
52
|
"*.js"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
56
|
-
"@feathersjs/errors": "^5.0.0-pre.
|
|
55
|
+
"@feathersjs/commons": "^5.0.0-pre.17",
|
|
56
|
+
"@feathersjs/errors": "^5.0.0-pre.17",
|
|
57
|
+
"@feathersjs/feathers": "^5.0.0-pre.17",
|
|
57
58
|
"lodash": "^4.17.21"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@
|
|
61
|
-
"@types/mocha": "^9.
|
|
62
|
-
"@types/node": "^
|
|
63
|
-
"mocha": "^9.
|
|
64
|
-
"shx": "^0.3.
|
|
65
|
-
"ts-node": "^10.
|
|
66
|
-
"typescript": "^4.
|
|
61
|
+
"@types/lodash": "^4.14.178",
|
|
62
|
+
"@types/mocha": "^9.1.0",
|
|
63
|
+
"@types/node": "^17.0.15",
|
|
64
|
+
"mocha": "^9.2.0",
|
|
65
|
+
"shx": "^0.3.4",
|
|
66
|
+
"ts-node": "^10.4.0",
|
|
67
|
+
"typescript": "^4.5.5"
|
|
67
68
|
},
|
|
68
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "d828748e57b40abfaa15710663afed417de14a1d"
|
|
69
70
|
}
|
package/src/channels/index.ts
CHANGED
|
@@ -11,24 +11,24 @@ const { CHANNELS } = keys;
|
|
|
11
11
|
|
|
12
12
|
declare module '@feathersjs/feathers/lib/declarations' {
|
|
13
13
|
interface ServiceAddons<A, S> extends EventEmitter { // eslint-disable-line
|
|
14
|
-
publish (publisher: Publisher<ServiceGenericType<S
|
|
15
|
-
publish (event: Event, publisher: Publisher<ServiceGenericType<S
|
|
14
|
+
publish (publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
15
|
+
publish (event: Event, publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
16
16
|
|
|
17
|
-
registerPublisher (publisher: Publisher<ServiceGenericType<S
|
|
18
|
-
registerPublisher (event: Event, publisher: Publisher<ServiceGenericType<S
|
|
17
|
+
registerPublisher (publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
18
|
+
registerPublisher (event: Event, publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
interface Application<
|
|
21
|
+
interface Application<Services, Settings> { // eslint-disable-line
|
|
22
22
|
channels: string[];
|
|
23
23
|
|
|
24
|
-
channel (name: string[]): Channel;
|
|
24
|
+
channel (name: string | string[]): Channel;
|
|
25
25
|
channel (...names: string[]): Channel;
|
|
26
26
|
|
|
27
|
-
publish<T> (publisher: Publisher<T>): this;
|
|
28
|
-
publish<T> (event: Event, publisher: Publisher<T>): this;
|
|
27
|
+
publish<T> (publisher: Publisher<T, this>): this;
|
|
28
|
+
publish<T> (event: Event, publisher: Publisher<T, this>): this;
|
|
29
29
|
|
|
30
|
-
registerPublisher<T> (publisher: Publisher<T>): this;
|
|
31
|
-
registerPublisher<T> (event: Event, publisher: Publisher<T>): this;
|
|
30
|
+
registerPublisher<T> (publisher: Publisher<T, this>): this;
|
|
31
|
+
registerPublisher<T> (event: Event, publisher: Publisher<T, this>): this;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
interface Params {
|
|
@@ -51,7 +51,7 @@ export function channels () {
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
app.mixins.push((service: FeathersService
|
|
54
|
+
app.mixins.push((service: FeathersService, path: string) => {
|
|
55
55
|
const { serviceEvents } = getServiceOptions(service);
|
|
56
56
|
|
|
57
57
|
if (typeof service.publish === 'function') {
|
package/src/channels/mixins.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
|
|
2
|
-
import { HookContext, getServiceOptions } from '@feathersjs/feathers';
|
|
2
|
+
import { Application, HookContext, getServiceOptions } from '@feathersjs/feathers';
|
|
3
3
|
import { createDebug } from '@feathersjs/commons';
|
|
4
4
|
import { Channel } from './channel/base';
|
|
5
5
|
import { CombinedChannel } from './channel/combined';
|
|
6
6
|
|
|
7
|
-
const debug = createDebug('@feathersjs/transport-commons
|
|
7
|
+
const debug = createDebug('@feathersjs/transport-commons/channels/mixins');
|
|
8
8
|
const PUBLISHERS = Symbol('@feathersjs/transport-commons/publishers');
|
|
9
9
|
const CHANNELS = Symbol('@feathersjs/transport-commons/channels');
|
|
10
10
|
const ALL_EVENTS = Symbol('@feathersjs/transport-commons/all-events');
|
|
@@ -63,7 +63,7 @@ export function channelMixin () {
|
|
|
63
63
|
|
|
64
64
|
export type Event = string|(typeof ALL_EVENTS);
|
|
65
65
|
|
|
66
|
-
export type Publisher<T = any> = (data: T, context: HookContext<
|
|
66
|
+
export type Publisher<T = any, A = Application, S = any> = (data: T, context: HookContext<A, S>) => Channel | Channel[] | void | Promise<Channel | Channel[] | void>;
|
|
67
67
|
|
|
68
68
|
export interface PublishMixin<T = any> {
|
|
69
69
|
[PUBLISHERS]: { [ALL_EVENTS]?: Publisher<T>, [key: string]: Publisher<T> };
|
package/src/http.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MethodNotAllowed } from '@feathersjs/errors/lib';
|
|
2
2
|
import { HookContext, NullableId, Params } from '@feathersjs/feathers';
|
|
3
|
-
import { BaseHookContext } from '@feathersjs/hooks';
|
|
4
3
|
|
|
5
4
|
export const METHOD_HEADER = 'x-service-method';
|
|
6
5
|
|
|
@@ -17,7 +16,7 @@ export const statusCodes = {
|
|
|
17
16
|
success: 200
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
export const knownMethods: { [key: string]:
|
|
19
|
+
export const knownMethods: { [key: string]: string } = {
|
|
21
20
|
post: 'create',
|
|
22
21
|
patch: 'patch',
|
|
23
22
|
put: 'update',
|
|
@@ -54,25 +53,19 @@ export const argumentsFor = {
|
|
|
54
53
|
default: ({ data, params }: ServiceParams) => [ data, params ]
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
export function getData (context: HookContext
|
|
58
|
-
if (!(context instanceof BaseHookContext)) {
|
|
59
|
-
return context;
|
|
60
|
-
}
|
|
61
|
-
|
|
56
|
+
export function getData (context: HookContext) {
|
|
62
57
|
return context.dispatch !== undefined
|
|
63
58
|
? context.dispatch
|
|
64
59
|
: context.result;
|
|
65
60
|
}
|
|
66
61
|
|
|
67
62
|
export function getStatusCode (context: HookContext, data?: any) {
|
|
68
|
-
if (context
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
63
|
+
if (context.http?.statusCode) {
|
|
64
|
+
return context.http.statusCode;
|
|
65
|
+
}
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
67
|
+
if (context.method === 'create') {
|
|
68
|
+
return statusCodes.created;
|
|
76
69
|
}
|
|
77
70
|
|
|
78
71
|
if (!data) {
|
package/src/routing/index.ts
CHANGED
|
@@ -1,45 +1,50 @@
|
|
|
1
|
-
import { Application, Service } from '@feathersjs/feathers';
|
|
1
|
+
import { Application, Service, ServiceOptions } from '@feathersjs/feathers';
|
|
2
2
|
import { Router } from './router';
|
|
3
3
|
|
|
4
4
|
declare module '@feathersjs/feathers/lib/declarations' {
|
|
5
5
|
interface RouteLookup {
|
|
6
|
-
service: Service
|
|
7
|
-
params: { [key: string]:
|
|
6
|
+
service: Service,
|
|
7
|
+
params: { [key: string]: any }
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
interface Application<
|
|
11
|
-
routes: Router<
|
|
10
|
+
interface Application<Services, Settings> { // eslint-disable-line
|
|
11
|
+
routes: Router<{
|
|
12
|
+
service: Service,
|
|
13
|
+
params?: { [key: string]: any }
|
|
14
|
+
}>;
|
|
12
15
|
lookup (path: string): RouteLookup;
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
export * from './router';
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const lookup = function (this: Application, path: string) {
|
|
22
|
+
const result = this.routes.lookup(path);
|
|
23
|
+
|
|
24
|
+
if (result === null) {
|
|
25
|
+
return null;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
const
|
|
28
|
+
const { params: colonParams, data: { service, params: dataParams } } = result;
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
routes,
|
|
27
|
-
lookup (this: Application, path: string) {
|
|
28
|
-
const result = this.routes.lookup(path);
|
|
30
|
+
const params = dataParams ? { ...dataParams, ...colonParams } : colonParams;
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
return { service, params };
|
|
33
|
+
};
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
export const routing = () => (app: Application) => {
|
|
36
|
+
if (typeof app.lookup === 'function') {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
40
|
+
app.routes = new Router();
|
|
41
|
+
app.lookup = lookup;
|
|
39
42
|
|
|
40
43
|
// Add a mixin that registers a service on the router
|
|
41
|
-
app.mixins.push((service: Service
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
app.mixins.push((service: Service, path: string, options: ServiceOptions) => {
|
|
45
|
+
const { routeParams: params = {} } = options;
|
|
46
|
+
|
|
47
|
+
app.routes.insert(path, { service, params });
|
|
48
|
+
app.routes.insert(`${path}/:__id`, { service, params });
|
|
44
49
|
});
|
|
45
50
|
};
|