@feathersjs/transport-commons 5.0.0-pre.6 → 5.0.0
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 +198 -208
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/client.d.ts +1 -1
- package/lib/channels/channel/base.d.ts +1 -3
- package/lib/channels/channel/base.js +2 -2
- package/lib/channels/channel/base.js.map +1 -1
- package/lib/channels/channel/combined.d.ts +2 -1
- package/lib/channels/channel/combined.js +2 -2
- package/lib/channels/channel/combined.js.map +1 -1
- package/lib/channels/index.d.ts +14 -12
- package/lib/channels/index.js +15 -10
- package/lib/channels/index.js.map +1 -1
- package/lib/channels/mixins.d.ts +3 -3
- package/lib/channels/mixins.js +3 -3
- package/lib/channels/mixins.js.map +1 -1
- package/lib/client.d.ts +2 -2
- package/lib/client.js +10 -12
- package/lib/client.js.map +1 -1
- package/lib/http.d.ts +14 -9
- package/lib/http.js +30 -20
- package/lib/http.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.js +8 -2
- package/lib/index.js.map +1 -1
- package/lib/routing/index.d.ts +9 -4
- package/lib/routing/index.js +26 -16
- package/lib/routing/index.js.map +1 -1
- package/lib/routing/router.d.ts +4 -1
- package/lib/routing/router.js +37 -4
- package/lib/routing/router.js.map +1 -1
- package/lib/socket/index.d.ts +1 -2
- package/lib/socket/index.js +10 -10
- package/lib/socket/index.js.map +1 -1
- package/lib/socket/utils.d.ts +1 -2
- package/lib/socket/utils.js +43 -53
- package/lib/socket/utils.js.map +1 -1
- package/package.json +19 -14
- package/src/channels/channel/base.ts +28 -31
- package/src/channels/channel/combined.ts +32 -31
- package/src/channels/index.ts +67 -61
- package/src/channels/mixins.ts +49 -46
- package/src/client.ts +70 -70
- package/src/http.ts +55 -43
- package/src/index.ts +6 -5
- package/src/routing/index.ts +45 -28
- package/src/routing/router.ts +80 -42
- package/src/socket/index.ts +43 -44
- package/src/socket/utils.ts +71 -59
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) 2023 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
|
|
12
12
|
|
|
13
13
|
Licensed under the [MIT license](LICENSE).
|
package/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './lib/client'
|
|
1
|
+
export * from './lib/client'
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}
|
|
3
|
+
import { RealTimeConnection } from '@feathersjs/feathers';
|
|
6
4
|
export declare class Channel extends EventEmitter {
|
|
7
5
|
connections: RealTimeConnection[];
|
|
8
6
|
data: any;
|
|
@@ -12,7 +12,7 @@ class Channel extends events_1.EventEmitter {
|
|
|
12
12
|
return this.connections.length;
|
|
13
13
|
}
|
|
14
14
|
leave(...connections) {
|
|
15
|
-
connections.forEach(current => {
|
|
15
|
+
connections.forEach((current) => {
|
|
16
16
|
if (typeof current === 'function') {
|
|
17
17
|
const callback = current;
|
|
18
18
|
this.leave(...this.connections.filter(callback));
|
|
@@ -30,7 +30,7 @@ class Channel extends events_1.EventEmitter {
|
|
|
30
30
|
return this;
|
|
31
31
|
}
|
|
32
32
|
join(...connections) {
|
|
33
|
-
connections.forEach(connection => {
|
|
33
|
+
connections.forEach((connection) => {
|
|
34
34
|
if (connection && this.connections.indexOf(connection) === -1) {
|
|
35
35
|
this.connections.push(connection);
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/channels/channel/base.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/channels/channel/base.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAGrC,MAAa,OAAQ,SAAQ,qBAAY;IAIvC,YAAY,cAAoC,EAAE,EAAE,OAAY,IAAI;QAClE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAA;IAChC,CAAC;IAED,KAAK,CAAC,GAAG,WAAiC;QACxC,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;gBACjC,MAAM,QAAQ,GAAG,OAAsD,CAAA;gBAEvE,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA;aACjD;iBAAM;gBACL,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;gBAE/C,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;oBAChB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;iBAClC;aACF;QACH,CAAC,CAAC,CAAA;QAEF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACnB;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,CAAC,GAAG,WAAiC;QACvC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,IAAI,UAAU,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC7D,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;aAClC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,EAA+C;QACpD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5D,CAAC;IAED,IAAI,CAAC,IAAS;QACZ,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IAC5C,CAAC;CACF;AAtDD,0BAsDC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RealTimeConnection } from '@feathersjs/feathers';
|
|
2
|
+
import { Channel } from './base';
|
|
2
3
|
export declare class CombinedChannel extends Channel {
|
|
3
4
|
children: Channel[];
|
|
4
5
|
mappings: WeakMap<RealTimeConnection, any>;
|
|
@@ -5,8 +5,8 @@ const base_1 = require("./base");
|
|
|
5
5
|
function collectConnections(children) {
|
|
6
6
|
const mappings = new WeakMap();
|
|
7
7
|
const connections = [];
|
|
8
|
-
children.forEach(channel => {
|
|
9
|
-
channel.connections.forEach(connection => {
|
|
8
|
+
children.forEach((channel) => {
|
|
9
|
+
channel.connections.forEach((connection) => {
|
|
10
10
|
if (!mappings.has(connection)) {
|
|
11
11
|
connections.push(connection);
|
|
12
12
|
mappings.set(connection, channel.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combined.js","sourceRoot":"","sources":["../../../src/channels/channel/combined.ts"],"names":[],"mappings":";;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CAAC,GAAG,WAAiC;QACvC,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IAC/C,CAAC;IAED,OAAO,CAAC,UAA8B;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACtC,CAAC;IAEO,YAAY,CAAC,MAAc,EAAE,WAAiC;QACpE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAA;QACpE,IAAI,CAAC,OAAO,EAAE,CAAA;QAEd,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AArCD,0CAqCC"}
|
package/lib/channels/index.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Application } from '@feathersjs/feathers';
|
|
3
|
-
import { Channel
|
|
2
|
+
import { Application, RealTimeConnection } from '@feathersjs/feathers';
|
|
3
|
+
import { Channel } from './channel/base';
|
|
4
|
+
import { CombinedChannel } from './channel/combined';
|
|
4
5
|
import { keys, Event, Publisher } from './mixins';
|
|
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,31 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.channels = exports.keys = void 0;
|
|
3
|
+
exports.CombinedChannel = exports.Channel = exports.channels = exports.keys = void 0;
|
|
4
4
|
const feathers_1 = require("@feathersjs/feathers");
|
|
5
5
|
const commons_1 = require("@feathersjs/commons");
|
|
6
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; } });
|
|
7
9
|
const combined_1 = require("./channel/combined");
|
|
10
|
+
Object.defineProperty(exports, "CombinedChannel", { enumerable: true, get: function () { return combined_1.CombinedChannel; } });
|
|
8
11
|
const mixins_1 = require("./mixins");
|
|
9
12
|
Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return mixins_1.keys; } });
|
|
10
|
-
const debug = commons_1.createDebug('@feathersjs/transport-commons/channels');
|
|
13
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons/channels');
|
|
11
14
|
const { CHANNELS } = mixins_1.keys;
|
|
12
15
|
function channels() {
|
|
13
16
|
return (app) => {
|
|
14
17
|
if (typeof app.channel === 'function' && typeof app.publish === 'function') {
|
|
15
18
|
return;
|
|
16
19
|
}
|
|
17
|
-
Object.assign(app, mixins_1.channelMixin(), mixins_1.publishMixin());
|
|
20
|
+
Object.assign(app, (0, mixins_1.channelMixin)(), (0, mixins_1.publishMixin)());
|
|
18
21
|
Object.defineProperty(app, 'channels', {
|
|
19
22
|
get() {
|
|
20
23
|
return Object.keys(this[CHANNELS]);
|
|
21
24
|
}
|
|
22
25
|
});
|
|
23
26
|
app.mixins.push((service, path) => {
|
|
24
|
-
const { serviceEvents } = feathers_1.getServiceOptions(service);
|
|
27
|
+
const { serviceEvents } = (0, feathers_1.getServiceOptions)(service);
|
|
25
28
|
if (typeof service.publish === 'function') {
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
|
-
Object.assign(service, mixins_1.publishMixin());
|
|
31
|
+
Object.assign(service, (0, mixins_1.publishMixin)());
|
|
29
32
|
serviceEvents.forEach((event) => {
|
|
30
33
|
service.on(event, function (data, hook) {
|
|
31
34
|
if (!hook) {
|
|
@@ -38,7 +41,7 @@ function channels() {
|
|
|
38
41
|
const appPublishers = app[mixins_1.keys.PUBLISHERS];
|
|
39
42
|
// This will return the first publisher list that is not empty
|
|
40
43
|
// In the following precedence
|
|
41
|
-
const publisher =
|
|
44
|
+
const publisher =
|
|
42
45
|
// 1. Service publisher for a specific event
|
|
43
46
|
servicePublishers[event] ||
|
|
44
47
|
// 2. Service publisher for all events
|
|
@@ -48,13 +51,14 @@ function channels() {
|
|
|
48
51
|
// 4. App publisher for all events
|
|
49
52
|
appPublishers[mixins_1.keys.ALL_EVENTS] ||
|
|
50
53
|
// 5. No publisher
|
|
51
|
-
lodash_1.noop
|
|
54
|
+
lodash_1.noop;
|
|
52
55
|
try {
|
|
53
|
-
Promise.resolve(publisher(data, hook))
|
|
56
|
+
Promise.resolve(publisher(data, hook))
|
|
57
|
+
.then((result) => {
|
|
54
58
|
if (!result) {
|
|
55
59
|
return;
|
|
56
60
|
}
|
|
57
|
-
const results =
|
|
61
|
+
const results = Array.isArray(result) ? (0, lodash_1.compact)((0, lodash_1.flattenDeep)(result)) : [result];
|
|
58
62
|
const channel = new combined_1.CombinedChannel(results);
|
|
59
63
|
if (channel && channel.length > 0) {
|
|
60
64
|
app.emit('publish', event, channel, hook, data);
|
|
@@ -62,7 +66,8 @@ function channels() {
|
|
|
62
66
|
else {
|
|
63
67
|
debug('No connections to publish to');
|
|
64
68
|
}
|
|
65
|
-
})
|
|
69
|
+
})
|
|
70
|
+
.catch(logError);
|
|
66
71
|
}
|
|
67
72
|
catch (error) {
|
|
68
73
|
logError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":";;;AAAA,mDAA0G;AAC1G,iDAAiD;AACjD,mCAAmD;AACnD,yCAAwC;AAkH/B,wFAlHA,cAAO,OAkHA;AAjHhB,iDAAoD;AAiHlC,gGAjHT,0BAAe,OAiHS;AAhHjC,qCAA2F;AAoClF,qFApC4B,aAAI,OAoC5B;AAjCb,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,wCAAwC,CAAC,CAAA;AACnE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAI,CAAA;AAkCzB,SAAgB,QAAQ;IACtB,OAAO,CAAC,GAA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AAA;IACJ,CAAC,CAAA;AACH,CAAC;AAxED,4BAwEC"}
|
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;
|
|
@@ -15,8 +15,8 @@ export interface ChannelMixin {
|
|
|
15
15
|
channel(...names: string[]): Channel;
|
|
16
16
|
}
|
|
17
17
|
export declare function channelMixin(): ChannelMixin;
|
|
18
|
-
export
|
|
19
|
-
export
|
|
18
|
+
export type Event = string | typeof ALL_EVENTS;
|
|
19
|
+
export 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 = 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');
|
|
@@ -38,7 +38,7 @@ function channelMixin() {
|
|
|
38
38
|
}
|
|
39
39
|
return this[CHANNELS][name];
|
|
40
40
|
}
|
|
41
|
-
const channels = names.map(name => this.channel(name));
|
|
41
|
+
const channels = names.map((name) => this.channel(name));
|
|
42
42
|
return new combined_1.CombinedChannel(channels);
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -57,7 +57,7 @@ function publishMixin() {
|
|
|
57
57
|
publisher = event;
|
|
58
58
|
event = ALL_EVENTS;
|
|
59
59
|
}
|
|
60
|
-
const { serviceEvents } = feathers_1.getServiceOptions(this);
|
|
60
|
+
const { serviceEvents = feathers_1.defaultServiceEvents } = (0, feathers_1.getServiceOptions)(this) || {};
|
|
61
61
|
if (event !== ALL_EVENTS && !serviceEvents.includes(event)) {
|
|
62
62
|
throw new Error(`'${event.toString()}' is not a valid service event`);
|
|
63
63
|
}
|
|
@@ -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,mDAAwG;AACxG,iDAAiD;AACjD,yCAAwC;AACxC,iDAAoD;AAEpD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,+CAA+C,CAAC,CAAA;AAC1E,MAAM,UAAU,GAAG,MAAM,CAAC,0CAA0C,CAAC,CAAA;AACrE,MAAM,QAAQ,GAAG,MAAM,CAAC,wCAAwC,CAAC,CAAA;AACjE,MAAM,UAAU,GAAG,MAAM,CAAC,0CAA0C,CAAC,CAAA;AAExD,QAAA,IAAI,GAAG;IAClB,UAAU,EAAE,UAA+B;IAC3C,QAAQ,EAAE,QAA2B;IACrC,UAAU,EAAE,UAA+B;CAC5C,CAAA;AAOD,SAAgB,YAAY;IAC1B,MAAM,KAAK,GAAiB;QAC1B,CAAC,QAAQ,CAAC,EAAE,EAAE;QAEd,OAAO,CAAC,GAAG,KAAe;YACxB,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAA;YAElC,IAAI,KAAK,CAAC,MAAM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AK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAA;YAErC,IAAI,CAAC,SAAS,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;gBAC7C,SAAS,GAAG,KAAK,CAAA;gBACjB,KAAK,GAAG,UAAU,CAAA;aACnB;YAED,MAAM,EAAE,aAAa,GAAG,+BAAoB,EAAE,GAAG,IAAA,4BAAiB,EAAC,IAAI,CAAC,IAAI,EAAE,CAAA;YAE9E,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,CAAA;aACtE;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAA;YAEnC,UAAU,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;YAE7B,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AA/BD,oCA+BC"}
|
package/lib/client.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ interface ServiceOptions {
|
|
|
5
5
|
method: string;
|
|
6
6
|
events?: string[];
|
|
7
7
|
}
|
|
8
|
-
export
|
|
9
|
-
export declare class Service<T = any, D = Partial<T
|
|
8
|
+
export type SocketService<T = any, D = Partial<any>, P extends Params = Params> = Service<T, D, P>;
|
|
9
|
+
export declare class Service<T = any, D = Partial<T>, P extends Params = Params> implements ServiceInterface<T, D, P> {
|
|
10
10
|
events: string[];
|
|
11
11
|
path: string;
|
|
12
12
|
connection: any;
|
package/lib/client.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Service = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
4
5
|
const errors_1 = require("@feathersjs/errors");
|
|
5
6
|
const commons_1 = require("@feathersjs/commons");
|
|
6
|
-
const debug = commons_1.createDebug('@feathersjs/transport-commons/client');
|
|
7
|
+
const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons/client');
|
|
7
8
|
const namespacedEmitterMethods = [
|
|
8
9
|
'addListener',
|
|
10
|
+
'addEventListener',
|
|
9
11
|
'emit',
|
|
10
12
|
'listenerCount',
|
|
11
13
|
'listeners',
|
|
@@ -14,15 +16,12 @@ const namespacedEmitterMethods = [
|
|
|
14
16
|
'prependListener',
|
|
15
17
|
'prependOnceListener',
|
|
16
18
|
'removeAllListeners',
|
|
19
|
+
'removeEventListener',
|
|
17
20
|
'removeListener'
|
|
18
21
|
];
|
|
19
|
-
const otherEmitterMethods = [
|
|
20
|
-
'eventNames',
|
|
21
|
-
'getMaxListeners',
|
|
22
|
-
'setMaxListeners'
|
|
23
|
-
];
|
|
22
|
+
const otherEmitterMethods = ['eventNames', 'getMaxListeners', 'setMaxListeners'];
|
|
24
23
|
const addEmitterMethods = (service) => {
|
|
25
|
-
otherEmitterMethods.forEach(method => {
|
|
24
|
+
otherEmitterMethods.forEach((method) => {
|
|
26
25
|
service[method] = function (...args) {
|
|
27
26
|
if (typeof this.connection[method] !== 'function') {
|
|
28
27
|
throw new Error(`Can not call '${method}' on the client service connection`);
|
|
@@ -31,14 +30,13 @@ const addEmitterMethods = (service) => {
|
|
|
31
30
|
};
|
|
32
31
|
});
|
|
33
32
|
// Methods that should add the namespace (service path)
|
|
34
|
-
namespacedEmitterMethods.forEach(method => {
|
|
33
|
+
namespacedEmitterMethods.forEach((method) => {
|
|
35
34
|
service[method] = function (name, ...args) {
|
|
36
35
|
if (typeof this.connection[method] !== 'function') {
|
|
37
36
|
throw new Error(`Can not call '${method}' on the client service connection`);
|
|
38
37
|
}
|
|
39
38
|
const eventName = `${this.path} ${name}`;
|
|
40
|
-
debug(`Calling emitter method ${method} with ` +
|
|
41
|
-
`namespaced event '${eventName}'`);
|
|
39
|
+
debug(`Calling emitter method ${method} with ` + `namespaced event '${eventName}'`);
|
|
42
40
|
const result = this.connection[method](eventName, ...args);
|
|
43
41
|
return result === this.connection ? this : result;
|
|
44
42
|
};
|
|
@@ -56,14 +54,14 @@ class Service {
|
|
|
56
54
|
return new Promise((resolve, reject) => {
|
|
57
55
|
args.unshift(method, this.path);
|
|
58
56
|
args.push(function (error, data) {
|
|
59
|
-
return error ? reject(errors_1.convert(error)) : resolve(data);
|
|
57
|
+
return error ? reject((0, errors_1.convert)(error)) : resolve(data);
|
|
60
58
|
});
|
|
61
59
|
debug(`Sending socket.${this.method}`, args);
|
|
62
60
|
this.connection[this.method](...args);
|
|
63
61
|
});
|
|
64
62
|
}
|
|
65
63
|
methods(...names) {
|
|
66
|
-
names.forEach(name => {
|
|
64
|
+
names.forEach((name) => {
|
|
67
65
|
this[name] = function (data, params = {}) {
|
|
68
66
|
return this.send(name, data, params.query || {});
|
|
69
67
|
};
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,+CAA4C;AAC5C,iDAAiD;AAGjD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,sCAAsC,CAAC,CAAA;AAEjE,MAAM,wBAAwB,GAAG;IAC/B,aAAa;IACb,kBAAkB;IAClB,MAAM;IACN,eAAe;IACf,WAAW;IACX,IAAI;IACJ,MAAM;IACN,iBAAiB;IACjB,qBAAqB;IACrB,oBAAoB;IACpB,qBAAqB;IACrB,gBAAgB;CACjB,CAAA;AACD,MAAM,mBAAmB,GAAG,CAAC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAA;AAEhF,MAAM,iBAAiB,GAAG,CAAC,OAAY,EAAE,EAAE;IACzC,mBAAmB,CAAC,OAAO,CAAC,CAAC,MAAM,EAA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AAkB,CAAC,IAAI,CAAC,CAAA;SACrC;QAED,aAAa;QACb,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAA;IAC3C,CAAC;CACF;AA/ED,0BA+EC"}
|
package/lib/http.d.ts
CHANGED
|
@@ -10,21 +10,26 @@ export declare const statusCodes: {
|
|
|
10
10
|
noContent: number;
|
|
11
11
|
methodNotAllowed: number;
|
|
12
12
|
success: number;
|
|
13
|
+
seeOther: number;
|
|
13
14
|
};
|
|
14
15
|
export declare const knownMethods: {
|
|
15
|
-
[key: string]:
|
|
16
|
+
[key: string]: string;
|
|
16
17
|
};
|
|
17
|
-
export declare function getServiceMethod(_httpMethod: string, id: unknown, headerOverride?: string):
|
|
18
|
+
export declare function getServiceMethod(_httpMethod: string, id: unknown, headerOverride?: string): string;
|
|
18
19
|
export declare const argumentsFor: {
|
|
19
|
-
get: ({ id, params }: ServiceParams) => (Params | NullableId)[];
|
|
20
|
-
find: ({ params }: ServiceParams) => Params[];
|
|
20
|
+
get: ({ id, params }: ServiceParams) => (Params<import("@feathersjs/feathers").Query> | NullableId)[];
|
|
21
|
+
find: ({ params }: ServiceParams) => Params<import("@feathersjs/feathers").Query>[];
|
|
21
22
|
create: ({ data, params }: ServiceParams) => any[];
|
|
22
23
|
update: ({ id, data, params }: ServiceParams) => any[];
|
|
23
24
|
patch: ({ id, data, params }: ServiceParams) => any[];
|
|
24
|
-
remove: ({ id, params }: ServiceParams) => (Params | NullableId)[];
|
|
25
|
+
remove: ({ id, params }: ServiceParams) => (Params<import("@feathersjs/feathers").Query> | NullableId)[];
|
|
25
26
|
default: ({ data, params }: ServiceParams) => any[];
|
|
26
27
|
};
|
|
27
|
-
export declare function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
6
|
+
exports.getResponse = exports.getStatusCode = exports.argumentsFor = exports.getServiceMethod = exports.knownMethods = exports.statusCodes = exports.METHOD_HEADER = void 0;
|
|
4
7
|
const lib_1 = require("@feathersjs/errors/lib");
|
|
5
|
-
const
|
|
8
|
+
const encodeurl_1 = __importDefault(require("encodeurl"));
|
|
6
9
|
exports.METHOD_HEADER = 'x-service-method';
|
|
7
10
|
exports.statusCodes = {
|
|
8
11
|
created: 201,
|
|
9
12
|
noContent: 204,
|
|
10
13
|
methodNotAllowed: 405,
|
|
11
|
-
success: 200
|
|
14
|
+
success: 200,
|
|
15
|
+
seeOther: 303
|
|
12
16
|
};
|
|
13
17
|
exports.knownMethods = {
|
|
14
18
|
post: 'create',
|
|
@@ -40,28 +44,34 @@ exports.argumentsFor = {
|
|
|
40
44
|
remove: ({ id, params }) => [id, params],
|
|
41
45
|
default: ({ data, params }) => [data, params]
|
|
42
46
|
};
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
function getStatusCode(context, body, location) {
|
|
48
|
+
const { http = {} } = context;
|
|
49
|
+
if (http.status) {
|
|
50
|
+
return http.status;
|
|
46
51
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
exports.
|
|
52
|
-
function getStatusCode(context, data) {
|
|
53
|
-
if (context instanceof hooks_1.BaseHookContext) {
|
|
54
|
-
if (context.statusCode) {
|
|
55
|
-
return context.statusCode;
|
|
56
|
-
}
|
|
57
|
-
if (context.method === 'create') {
|
|
58
|
-
return exports.statusCodes.created;
|
|
59
|
-
}
|
|
52
|
+
if (context.method === 'create') {
|
|
53
|
+
return exports.statusCodes.created;
|
|
54
|
+
}
|
|
55
|
+
if (location !== undefined) {
|
|
56
|
+
return exports.statusCodes.seeOther;
|
|
60
57
|
}
|
|
61
|
-
if (!
|
|
58
|
+
if (!body) {
|
|
62
59
|
return exports.statusCodes.noContent;
|
|
63
60
|
}
|
|
64
61
|
return exports.statusCodes.success;
|
|
65
62
|
}
|
|
66
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;
|
|
67
77
|
//# sourceMappingURL=http.js.map
|
package/lib/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAyD;AAEzD,0DAAiC;AAEpB,QAAA,aAAa,GAAG,kBAAkB,CAAA;AAQlC,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,GAAG;IACd,gBAAgB,EAAE,GAAG;IACrB,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;CACd,CAAA;AAEY,QAAA,YAAY,GAA8B;IACrD,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,OAAO;IACd,GAAG,EA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QAAQ,CAAC,CAAA;IAErD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AAClC,CAAC;AAfD,kCAeC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { socket } from './socket';
|
|
2
2
|
import { routing } from './routing';
|
|
3
|
-
import { channels } from './channels';
|
|
3
|
+
import { channels, Channel, CombinedChannel } from './channels';
|
|
4
|
+
import { RealTimeConnection } from '@feathersjs/feathers';
|
|
4
5
|
export * as http from './http';
|
|
5
|
-
export { socket, routing, channels };
|
|
6
|
+
export { socket, routing, channels, Channel, CombinedChannel, RealTimeConnection };
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -19,12 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.channels = exports.routing = exports.socket = exports.http = void 0;
|
|
26
|
+
exports.CombinedChannel = exports.Channel = exports.channels = exports.routing = exports.socket = exports.http = void 0;
|
|
23
27
|
const socket_1 = require("./socket");
|
|
24
28
|
Object.defineProperty(exports, "socket", { enumerable: true, get: function () { return socket_1.socket; } });
|
|
25
29
|
const routing_1 = require("./routing");
|
|
26
30
|
Object.defineProperty(exports, "routing", { enumerable: true, get: function () { return routing_1.routing; } });
|
|
27
31
|
const channels_1 = require("./channels");
|
|
28
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; } });
|
|
29
35
|
exports.http = __importStar(require("./http"));
|
|
30
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,qCAAiC;AAMxB,uFANA,eAAM,OAMA;AALf,uCAAmC;AAKlB,wFALR,iBAAO,OAKQ;AAJxB,yCAA+D;AAIrC,yFAJjB,mBAAQ,OAIiB;AAAE,wFAJjB,kBAAO,OAIiB;AAAE,gGAJjB,0BAAe,OAIiB;AAD5D,+CAA8B"}
|
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
|
}
|