@feathersjs/transport-commons 5.0.0-pre.2 → 5.0.0-pre.22
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 +200 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/lib/channels/index.d.ts +13 -11
- package/lib/channels/index.js +11 -11
- package/lib/channels/index.js.map +1 -1
- package/lib/channels/mixins.d.ts +2 -2
- package/lib/channels/mixins.js +4 -7
- package/lib/channels/mixins.js.map +1 -1
- package/lib/client.js +3 -6
- package/lib/client.js.map +1 -1
- package/lib/http.d.ts +35 -0
- package/lib/http.js +77 -0
- package/lib/http.js.map +1 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +27 -1
- package/lib/index.js.map +1 -1
- package/lib/routing/index.d.ts +9 -4
- package/lib/routing/index.js +20 -16
- package/lib/routing/index.js.map +1 -1
- package/lib/routing/router.d.ts +5 -3
- package/lib/routing/router.js +35 -23
- package/lib/routing/router.js.map +1 -1
- package/lib/socket/index.js +7 -10
- package/lib/socket/index.js.map +1 -1
- package/lib/socket/utils.js +43 -54
- package/lib/socket/utils.js.map +1 -1
- package/package.json +17 -15
- package/src/channels/index.ts +17 -15
- package/src/channels/mixins.ts +4 -4
- package/src/client.ts +2 -2
- package/src/http.ts +95 -0
- package/src/index.ts +10 -2
- package/src/routing/index.ts +28 -23
- package/src/routing/router.ts +33 -22
- package/src/socket/index.ts +2 -2
- package/src/socket/utils.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,206 @@
|
|
|
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.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **transport-commons:** Ensure socket queries are always plain objects ([#2597](https://github.com/feathersjs/feathers/issues/2597)) ([97313e1](https://github.com/feathersjs/feathers/commit/97313e121cfee4199f10012e95b8507557aa507e))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Features
|
|
48
|
+
|
|
49
|
+
* **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
|
|
56
|
+
|
|
57
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
* **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### Bug Fixes
|
|
78
|
+
|
|
79
|
+
* **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
### Features
|
|
83
|
+
|
|
84
|
+
* **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b))
|
|
85
|
+
* **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))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
|
|
92
|
+
|
|
93
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13)
|
|
100
|
+
|
|
101
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12)
|
|
108
|
+
|
|
109
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
# [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06)
|
|
116
|
+
|
|
117
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
# [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19)
|
|
124
|
+
|
|
125
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09)
|
|
132
|
+
|
|
133
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09)
|
|
140
|
+
|
|
141
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
# [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09)
|
|
148
|
+
|
|
149
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
# [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08)
|
|
156
|
+
|
|
157
|
+
**Note:** Version bump only for package @feathersjs/transport-commons
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
### Bug Fixes
|
|
167
|
+
|
|
168
|
+
* **koa:** Use extended query parser for compatibility ([#2397](https://github.com/feathersjs/feathers/issues/2397)) ([b2944ba](https://github.com/feathersjs/feathers/commit/b2944bac3ec6d5ecc80dc518cd4e58093692db74))
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
### Bug Fixes
|
|
178
|
+
|
|
179
|
+
* **transport-commons:** Fix route placeholder registration and improve radix router performance ([#2336](https://github.com/feathersjs/feathers/issues/2336)) ([4d84dfd](https://github.com/feathersjs/feathers/commit/4d84dfd092ce0510312e975d5cd57e04973fb311))
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
### Features
|
|
183
|
+
|
|
184
|
+
* **koa:** KoaJS transport adapter ([#2315](https://github.com/feathersjs/feathers/issues/2315)) ([2554b57](https://github.com/feathersjs/feathers/commit/2554b57cf05731df58feeba9c12faab18e442107))
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
# [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
### Bug Fixes
|
|
194
|
+
|
|
195
|
+
* **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897))
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
### Features
|
|
199
|
+
|
|
200
|
+
* **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a))
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
6
206
|
# [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06)
|
|
7
207
|
|
|
8
208
|
**Note:** Version bump only for package @feathersjs/transport-commons
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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)
|
|
5
|
+
[](https://discord.gg/qa8kez8QBx)
|
|
6
6
|
|
|
7
7
|
> Shared functionality for Feathers API transports like `@feathers/socketio` and `@feathersjs/primus`. Only intended to be used internally.
|
|
8
8
|
|
|
9
9
|
## License
|
|
10
10
|
|
|
11
|
-
Copyright (c)
|
|
11
|
+
Copyright (c) 2022 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
|
|
12
12
|
|
|
13
13
|
Licensed under the [MIT license](LICENSE).
|
package/lib/channels/index.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { Application } from '@feathersjs/feathers';
|
|
2
3
|
import { Channel, RealTimeConnection } from './channel/base';
|
|
4
|
+
import { CombinedChannel } from './channel/combined';
|
|
3
5
|
import { keys, Event, Publisher } from './mixins';
|
|
4
|
-
import { Application } from '@feathersjs/feathers';
|
|
5
6
|
import EventEmitter from 'events';
|
|
6
7
|
declare module '@feathersjs/feathers/lib/declarations' {
|
|
7
8
|
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
|
|
9
|
+
publish(publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
10
|
+
publish(event: Event, publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
11
|
+
registerPublisher(publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
12
|
+
registerPublisher(event: Event, publisher: Publisher<ServiceGenericType<S>, A, this>): this;
|
|
12
13
|
}
|
|
13
|
-
interface Application<
|
|
14
|
+
interface Application<Services, Settings> {
|
|
14
15
|
channels: string[];
|
|
15
|
-
channel(name: string[]): Channel;
|
|
16
|
+
channel(name: string | string[]): Channel;
|
|
16
17
|
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;
|
|
18
|
+
publish<T>(publisher: Publisher<T, this>): this;
|
|
19
|
+
publish<T>(event: Event, publisher: Publisher<T, this>): this;
|
|
20
|
+
registerPublisher<T>(publisher: Publisher<T, this>): this;
|
|
21
|
+
registerPublisher<T>(event: Event, publisher: Publisher<T, this>): this;
|
|
21
22
|
}
|
|
22
23
|
interface Params {
|
|
23
24
|
connection?: RealTimeConnection;
|
|
@@ -25,3 +26,4 @@ declare module '@feathersjs/feathers/lib/declarations' {
|
|
|
25
26
|
}
|
|
26
27
|
export { keys };
|
|
27
28
|
export declare function channels(): (app: Application) => void;
|
|
29
|
+
export { Channel, CombinedChannel, RealTimeConnection };
|
package/lib/channels/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.channels = exports.keys = void 0;
|
|
7
|
-
const
|
|
3
|
+
exports.CombinedChannel = exports.Channel = exports.channels = exports.keys = void 0;
|
|
4
|
+
const feathers_1 = require("@feathersjs/feathers");
|
|
5
|
+
const commons_1 = require("@feathersjs/commons");
|
|
8
6
|
const lodash_1 = require("lodash");
|
|
7
|
+
const base_1 = require("./channel/base");
|
|
8
|
+
Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return base_1.Channel; } });
|
|
9
9
|
const combined_1 = require("./channel/combined");
|
|
10
|
+
Object.defineProperty(exports, "CombinedChannel", { enumerable: true, get: function () { return combined_1.CombinedChannel; } });
|
|
10
11
|
const mixins_1 = require("./mixins");
|
|
11
12
|
Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return mixins_1.keys; } });
|
|
12
|
-
const
|
|
13
|
-
const debug = debug_1.default('@feathersjs/transport-commons/channels');
|
|
13
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons/channels');
|
|
14
14
|
const { CHANNELS } = mixins_1.keys;
|
|
15
15
|
function channels() {
|
|
16
16
|
return (app) => {
|
|
17
17
|
if (typeof app.channel === 'function' && typeof app.publish === 'function') {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
Object.assign(app, mixins_1.channelMixin(), mixins_1.publishMixin());
|
|
20
|
+
Object.assign(app, (0, mixins_1.channelMixin)(), (0, mixins_1.publishMixin)());
|
|
21
21
|
Object.defineProperty(app, 'channels', {
|
|
22
22
|
get() {
|
|
23
23
|
return Object.keys(this[CHANNELS]);
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
app.mixins.push((service, path) => {
|
|
27
|
-
const { serviceEvents } = feathers_1.getServiceOptions(service);
|
|
27
|
+
const { serviceEvents } = (0, feathers_1.getServiceOptions)(service);
|
|
28
28
|
if (typeof service.publish === 'function') {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
Object.assign(service, mixins_1.publishMixin());
|
|
31
|
+
Object.assign(service, (0, mixins_1.publishMixin)());
|
|
32
32
|
serviceEvents.forEach((event) => {
|
|
33
33
|
service.on(event, function (data, hook) {
|
|
34
34
|
if (!hook) {
|
|
@@ -57,7 +57,7 @@ function channels() {
|
|
|
57
57
|
if (!result) {
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
const results = (Array.isArray(result) ? lodash_1.compact(lodash_1.flattenDeep(result)) : [result]);
|
|
60
|
+
const results = (Array.isArray(result) ? (0, lodash_1.compact)((0, lodash_1.flattenDeep)(result)) : [result]);
|
|
61
61
|
const channel = new combined_1.CombinedChannel(results);
|
|
62
62
|
if (channel && channel.length > 0) {
|
|
63
63
|
app.emit('publish', event, channel, hook, data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":";;;AAAA,mDAAuF;AACvF,iDAAkD;AAClD,mCAAoD;AACpD,yCAA6D;AA8GpD,wFA9GA,cAAO,OA8GA;AA7GhB,iDAAqD;AA6GnC,gGA7GT,0BAAe,OA6GS;AA5GjC,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,EAAE,IAAA,qBAAY,GAAE,CAAC,CAAC;QACnD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YACrC,GAAG;gBACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrC,CAAC;SACF,CAAC,CAAC;QAEH,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAwB,EAAE,IAAY,EAAE,EAAE;YACzD,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,4BAAiB,EAAC,OAAO,CAAC,CAAC;YAErD,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE;gBACzC,OAAO;aACR;YAED,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAA,qBAAY,GAAE,CAAC,CAAC;YAEvC,aAAa,CAAC,OAAO,CAAC,CAAC,KAAa,EAAE,EAAE;gBACtC,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AAC,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,5 +1,5 @@
|
|
|
1
|
+
import { Application, HookContext } from '@feathersjs/feathers';
|
|
1
2
|
import { Channel } from './channel/base';
|
|
2
|
-
import { HookContext } from '@feathersjs/feathers';
|
|
3
3
|
declare const PUBLISHERS: unique symbol;
|
|
4
4
|
declare const CHANNELS: unique symbol;
|
|
5
5
|
declare const ALL_EVENTS: 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
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.publishMixin = exports.channelMixin = exports.keys = void 0;
|
|
7
4
|
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
|
|
8
|
-
const
|
|
5
|
+
const feathers_1 = require("@feathersjs/feathers");
|
|
6
|
+
const commons_1 = require("@feathersjs/commons");
|
|
9
7
|
const base_1 = require("./channel/base");
|
|
10
8
|
const combined_1 = require("./channel/combined");
|
|
11
|
-
const
|
|
12
|
-
const debug = debug_1.default('@feathersjs/transport-commons:channels/mixins');
|
|
9
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons/channels/mixins');
|
|
13
10
|
const PUBLISHERS = Symbol('@feathersjs/transport-commons/publishers');
|
|
14
11
|
const CHANNELS = Symbol('@feathersjs/transport-commons/channels');
|
|
15
12
|
const ALL_EVENTS = Symbol('@feathersjs/transport-commons/all-events');
|
|
@@ -60,7 +57,7 @@ function publishMixin() {
|
|
|
60
57
|
publisher = event;
|
|
61
58
|
event = ALL_EVENTS;
|
|
62
59
|
}
|
|
63
|
-
const { serviceEvents } = feathers_1.getServiceOptions(this);
|
|
60
|
+
const { serviceEvents } = (0, feathers_1.getServiceOptions)(this);
|
|
64
61
|
if (event !== ALL_EVENTS && !serviceEvents.includes(event)) {
|
|
65
62
|
throw new Error(`'${event.toString()}' is not a valid service event`);
|
|
66
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixins.js","sourceRoot":"","sources":["../../src/channels/mixins.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mixins.js","sourceRoot":"","sources":["../../src/channels/mixins.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,mDAAmF;AACnF,iDAAkD;AAClD,yCAAyC;AACzC,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"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.Service = void 0;
|
|
7
|
-
const debug_1 = __importDefault(require("debug"));
|
|
8
4
|
const errors_1 = require("@feathersjs/errors");
|
|
9
|
-
const
|
|
5
|
+
const commons_1 = require("@feathersjs/commons");
|
|
6
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons/client');
|
|
10
7
|
const namespacedEmitterMethods = [
|
|
11
8
|
'addListener',
|
|
12
9
|
'emit',
|
|
@@ -59,7 +56,7 @@ class Service {
|
|
|
59
56
|
return new Promise((resolve, reject) => {
|
|
60
57
|
args.unshift(method, this.path);
|
|
61
58
|
args.push(function (error, data) {
|
|
62
|
-
return error ? reject(errors_1.convert(error)) : resolve(data);
|
|
59
|
+
return error ? reject((0, errors_1.convert)(error)) : resolve(data);
|
|
63
60
|
});
|
|
64
61
|
debug(`Sending socket.${this.method}`, args);
|
|
65
62
|
this.connection[this.method](...args);
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAC7C,iDAAkD;AAGlD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,sCAAsC,CAAC,CAAC;AAElE,MAAM,wBAAwB,GAAG;IAC/B,aAAa;IACb,MAAM;IACN,eAAe;IACf,WAAW;IACX,IAAI;IACJ,MAAM;IACN,iBAAiB;IACjB,qBAAqB;IACrB,oBAAoB;IACpB,gBAAgB;CACjB,CAAC;AACF,MAAM,mBAAmB,GAAG;IAC1B,YAAY;IACZ,iBAAiB;IACjB,iBAAiB;CAClB,CAAC;AAEF,M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AI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,aAAa;YACb,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;SACtC;QAED,aAAa;QACb,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF;AA7ED,0BA6EC"}
|
package/lib/http.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { HookContext, NullableId, Params } from '@feathersjs/feathers';
|
|
2
|
+
export declare const METHOD_HEADER = "x-service-method";
|
|
3
|
+
export interface ServiceParams {
|
|
4
|
+
id: NullableId;
|
|
5
|
+
data: any;
|
|
6
|
+
params: Params;
|
|
7
|
+
}
|
|
8
|
+
export declare const statusCodes: {
|
|
9
|
+
created: number;
|
|
10
|
+
noContent: number;
|
|
11
|
+
methodNotAllowed: number;
|
|
12
|
+
success: number;
|
|
13
|
+
seeOther: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const knownMethods: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function getServiceMethod(_httpMethod: string, id: unknown, headerOverride?: string): string;
|
|
19
|
+
export declare const argumentsFor: {
|
|
20
|
+
get: ({ id, params }: ServiceParams) => (Params<import("@feathersjs/feathers").Query> | NullableId)[];
|
|
21
|
+
find: ({ params }: ServiceParams) => Params<import("@feathersjs/feathers").Query>[];
|
|
22
|
+
create: ({ data, params }: ServiceParams) => any[];
|
|
23
|
+
update: ({ id, data, params }: ServiceParams) => any[];
|
|
24
|
+
patch: ({ id, data, params }: ServiceParams) => any[];
|
|
25
|
+
remove: ({ id, params }: ServiceParams) => (Params<import("@feathersjs/feathers").Query> | NullableId)[];
|
|
26
|
+
default: ({ data, params }: ServiceParams) => any[];
|
|
27
|
+
};
|
|
28
|
+
export declare function getStatusCode(context: HookContext, body: any, location: string | string[]): number;
|
|
29
|
+
export declare function getResponse(context: HookContext): {
|
|
30
|
+
status: number;
|
|
31
|
+
headers: {
|
|
32
|
+
[key: string]: string | string[];
|
|
33
|
+
};
|
|
34
|
+
body: any;
|
|
35
|
+
};
|
package/lib/http.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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.getResponse = exports.getStatusCode = exports.argumentsFor = exports.getServiceMethod = exports.knownMethods = exports.statusCodes = exports.METHOD_HEADER = void 0;
|
|
7
|
+
const lib_1 = require("@feathersjs/errors/lib");
|
|
8
|
+
const encodeurl_1 = __importDefault(require("encodeurl"));
|
|
9
|
+
exports.METHOD_HEADER = 'x-service-method';
|
|
10
|
+
exports.statusCodes = {
|
|
11
|
+
created: 201,
|
|
12
|
+
noContent: 204,
|
|
13
|
+
methodNotAllowed: 405,
|
|
14
|
+
success: 200,
|
|
15
|
+
seeOther: 303
|
|
16
|
+
};
|
|
17
|
+
exports.knownMethods = {
|
|
18
|
+
post: 'create',
|
|
19
|
+
patch: 'patch',
|
|
20
|
+
put: 'update',
|
|
21
|
+
delete: 'remove'
|
|
22
|
+
};
|
|
23
|
+
function getServiceMethod(_httpMethod, id, headerOverride) {
|
|
24
|
+
const httpMethod = _httpMethod.toLowerCase();
|
|
25
|
+
if (httpMethod === 'post' && headerOverride) {
|
|
26
|
+
return headerOverride;
|
|
27
|
+
}
|
|
28
|
+
const mappedMethod = exports.knownMethods[httpMethod];
|
|
29
|
+
if (mappedMethod) {
|
|
30
|
+
return mappedMethod;
|
|
31
|
+
}
|
|
32
|
+
if (httpMethod === 'get') {
|
|
33
|
+
return id === null ? 'find' : 'get';
|
|
34
|
+
}
|
|
35
|
+
throw new lib_1.MethodNotAllowed(`Method ${_httpMethod} not allowed`);
|
|
36
|
+
}
|
|
37
|
+
exports.getServiceMethod = getServiceMethod;
|
|
38
|
+
exports.argumentsFor = {
|
|
39
|
+
get: ({ id, params }) => [id, params],
|
|
40
|
+
find: ({ params }) => [params],
|
|
41
|
+
create: ({ data, params }) => [data, params],
|
|
42
|
+
update: ({ id, data, params }) => [id, data, params],
|
|
43
|
+
patch: ({ id, data, params }) => [id, data, params],
|
|
44
|
+
remove: ({ id, params }) => [id, params],
|
|
45
|
+
default: ({ data, params }) => [data, params]
|
|
46
|
+
};
|
|
47
|
+
function getStatusCode(context, body, location) {
|
|
48
|
+
const { http = {} } = context;
|
|
49
|
+
if (http.status) {
|
|
50
|
+
return http.status;
|
|
51
|
+
}
|
|
52
|
+
if (context.method === 'create') {
|
|
53
|
+
return exports.statusCodes.created;
|
|
54
|
+
}
|
|
55
|
+
if (location !== undefined) {
|
|
56
|
+
return exports.statusCodes.seeOther;
|
|
57
|
+
}
|
|
58
|
+
if (!body) {
|
|
59
|
+
return exports.statusCodes.noContent;
|
|
60
|
+
}
|
|
61
|
+
return exports.statusCodes.success;
|
|
62
|
+
}
|
|
63
|
+
exports.getStatusCode = getStatusCode;
|
|
64
|
+
function getResponse(context) {
|
|
65
|
+
const { http = {} } = context;
|
|
66
|
+
const body = context.dispatch !== undefined ? context.dispatch : context.result;
|
|
67
|
+
let headers = http.headers || {};
|
|
68
|
+
let location = headers.Location;
|
|
69
|
+
if (http.location !== undefined) {
|
|
70
|
+
location = (0, encodeurl_1.default)(http.location);
|
|
71
|
+
headers = { ...headers, Location: location };
|
|
72
|
+
}
|
|
73
|
+
const status = getStatusCode(context, body, location);
|
|
74
|
+
return { status, headers, body };
|
|
75
|
+
}
|
|
76
|
+
exports.getResponse = getResponse;
|
|
77
|
+
//# sourceMappingURL=http.js.map
|
package/lib/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA0D;AAE1D,0DAAkC;AAErB,QAAA,aAAa,GAAG,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AEhC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;QAC/B,QAAQ,GAAG,IAAA,mBAAS,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;KAC9C;IAED,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEtD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACnC,CAAC;AAfD,kCAeC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { socket } from './socket';
|
|
2
2
|
import { routing } from './routing';
|
|
3
|
-
import { channels } from './channels';
|
|
4
|
-
export
|
|
3
|
+
import { channels, Channel, CombinedChannel, RealTimeConnection } from './channels';
|
|
4
|
+
export * as http from './http';
|
|
5
|
+
export { socket, routing, channels, Channel, CombinedChannel, RealTimeConnection };
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.channels = exports.routing = exports.socket = void 0;
|
|
26
|
+
exports.CombinedChannel = exports.Channel = exports.channels = exports.routing = exports.socket = exports.http = void 0;
|
|
4
27
|
const socket_1 = require("./socket");
|
|
5
28
|
Object.defineProperty(exports, "socket", { enumerable: true, get: function () { return socket_1.socket; } });
|
|
6
29
|
const routing_1 = require("./routing");
|
|
7
30
|
Object.defineProperty(exports, "routing", { enumerable: true, get: function () { return routing_1.routing; } });
|
|
8
31
|
const channels_1 = require("./channels");
|
|
9
32
|
Object.defineProperty(exports, "channels", { enumerable: true, get: function () { return channels_1.channels; } });
|
|
33
|
+
Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return channels_1.Channel; } });
|
|
34
|
+
Object.defineProperty(exports, "CombinedChannel", { enumerable: true, get: function () { return channels_1.CombinedChannel; } });
|
|
35
|
+
exports.http = __importStar(require("./http"));
|
|
10
36
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAkC;AAMhC,uFANO,eAAM,OAMP;AALR,uCAAoC;AAMlC,wFANO,iBAAO,OAMP;AALT,yCAAoF;AAMlF,yFANO,mBAAQ,OAMP;AACR,wFAPiB,kBAAO,OAOjB;AACP,gGAR0B,0BAAe,OAQ1B;AANjB,+CAA+B"}
|
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
|
}
|