@feathersjs/transport-commons 5.0.39 → 6.0.0-pre.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/LICENSE +1 -2
  3. package/README.md +1 -1
  4. package/client.d.ts +1 -1
  5. package/client.js +1 -1
  6. package/lib/client.d.ts +1 -1
  7. package/lib/client.js +6 -10
  8. package/lib/client.js.map +1 -1
  9. package/lib/index.d.ts +3 -6
  10. package/lib/index.js +3 -45
  11. package/lib/index.js.map +1 -1
  12. package/lib/socket/index.d.ts +1 -1
  13. package/lib/socket/index.js +6 -13
  14. package/lib/socket/index.js.map +1 -1
  15. package/lib/socket/utils.d.ts +2 -2
  16. package/lib/socket/utils.js +17 -26
  17. package/lib/socket/utils.js.map +1 -1
  18. package/package.json +9 -9
  19. package/src/client.ts +1 -2
  20. package/src/index.ts +3 -7
  21. package/src/socket/index.ts +3 -7
  22. package/src/socket/utils.ts +3 -9
  23. package/lib/channels/channel/base.d.ts +0 -12
  24. package/lib/channels/channel/base.js +0 -48
  25. package/lib/channels/channel/base.js.map +0 -1
  26. package/lib/channels/channel/combined.d.ts +0 -15
  27. package/lib/channels/channel/combined.js +0 -45
  28. package/lib/channels/channel/combined.js.map +0 -1
  29. package/lib/channels/index.d.ts +0 -28
  30. package/lib/channels/index.js +0 -86
  31. package/lib/channels/index.js.map +0 -1
  32. package/lib/channels/mixins.d.ts +0 -29
  33. package/lib/channels/mixins.js +0 -72
  34. package/lib/channels/mixins.js.map +0 -1
  35. package/lib/http.d.ts +0 -35
  36. package/lib/http.js +0 -77
  37. package/lib/http.js.map +0 -1
  38. package/lib/routing/index.d.ts +0 -21
  39. package/lib/routing/index.js +0 -49
  40. package/lib/routing/index.js.map +0 -1
  41. package/lib/routing/router.d.ts +0 -31
  42. package/lib/routing/router.js +0 -114
  43. package/lib/routing/router.js.map +0 -1
  44. package/src/channels/channel/base.ts +0 -58
  45. package/src/channels/channel/combined.ts +0 -57
  46. package/src/channels/index.ts +0 -120
  47. package/src/channels/mixins.ts +0 -108
  48. package/src/http.ts +0 -95
  49. package/src/routing/index.ts +0 -62
  50. package/src/routing/router.ts +0 -148
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Channel = void 0;
4
- const events_1 = require("events");
5
- class Channel extends events_1.EventEmitter {
6
- constructor(connections = [], data = null) {
7
- super();
8
- this.connections = connections;
9
- this.data = data;
10
- }
11
- get length() {
12
- return this.connections.length;
13
- }
14
- leave(...connections) {
15
- connections.forEach((current) => {
16
- if (typeof current === 'function') {
17
- const callback = current;
18
- this.leave(...this.connections.filter(callback));
19
- }
20
- else {
21
- const index = this.connections.indexOf(current);
22
- if (index !== -1) {
23
- this.connections.splice(index, 1);
24
- }
25
- }
26
- });
27
- if (this.length === 0) {
28
- this.emit('empty');
29
- }
30
- return this;
31
- }
32
- join(...connections) {
33
- connections.forEach((connection) => {
34
- if (connection && this.connections.indexOf(connection) === -1) {
35
- this.connections.push(connection);
36
- }
37
- });
38
- return this;
39
- }
40
- filter(fn) {
41
- return new Channel(this.connections.filter(fn), this.data);
42
- }
43
- send(data) {
44
- return new Channel(this.connections, data);
45
- }
46
- }
47
- exports.Channel = Channel;
48
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
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,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CAAC,CAAA;IAC5C,CAAC;CACF;AAtDD,0BAsDC"}
@@ -1,15 +0,0 @@
1
- import { RealTimeConnection } from '@feathersjs/feathers';
2
- import { Channel } from './base';
3
- export declare class CombinedChannel extends Channel {
4
- children: Channel[];
5
- mappings: WeakMap<RealTimeConnection, any>;
6
- constructor(children: Channel[], data?: any);
7
- refresh(): this & {
8
- connections: RealTimeConnection[];
9
- mappings: WeakMap<RealTimeConnection, any>;
10
- };
11
- leave(...connections: RealTimeConnection[]): this;
12
- join(...connections: RealTimeConnection[]): this;
13
- dataFor(connection: RealTimeConnection): any;
14
- private callChildren;
15
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CombinedChannel = void 0;
4
- const base_1 = require("./base");
5
- function collectConnections(children) {
6
- const mappings = new WeakMap();
7
- const connections = [];
8
- children.forEach((channel) => {
9
- channel.connections.forEach((connection) => {
10
- if (!mappings.has(connection)) {
11
- connections.push(connection);
12
- mappings.set(connection, channel.data);
13
- }
14
- });
15
- });
16
- return { connections, mappings };
17
- }
18
- class CombinedChannel extends base_1.Channel {
19
- constructor(children, data = null) {
20
- const { mappings, connections } = collectConnections(children);
21
- super(connections, data);
22
- this.children = children;
23
- this.mappings = mappings;
24
- }
25
- refresh() {
26
- const collected = collectConnections(this.children);
27
- return Object.assign(this, collected);
28
- }
29
- leave(...connections) {
30
- return this.callChildren('leave', connections);
31
- }
32
- join(...connections) {
33
- return this.callChildren('join', connections);
34
- }
35
- dataFor(connection) {
36
- return this.mappings.get(connection);
37
- }
38
- callChildren(method, connections) {
39
- this.children.forEach((child) => child[method](...connections));
40
- this.refresh();
41
- return this;
42
- }
43
- }
44
- exports.CombinedChannel = CombinedChannel;
45
- //# sourceMappingURL=combined.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"combined.js","sourceRoot":"","sources":["../../../src/channels/channel/combined.ts"],"names":[],"mappings":";;;AACA,iCAAgC;AAEhC,SAAS,kBAAkB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O,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"}
@@ -1,28 +0,0 @@
1
- import { Application, RealTimeConnection } from '@feathersjs/feathers';
2
- import { Channel } from './channel/base';
3
- import { CombinedChannel } from './channel/combined';
4
- import { keys, Event, Publisher } from './mixins';
5
- import EventEmitter from 'events';
6
- declare module '@feathersjs/feathers/lib/declarations' {
7
- interface ServiceAddons<A, S> extends EventEmitter {
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
- }
13
- interface Application<Services, Settings> {
14
- channels: string[];
15
- channel(name: string | string[]): Channel;
16
- channel(...names: string[]): Channel;
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
- }
22
- interface Params {
23
- connection?: RealTimeConnection;
24
- }
25
- }
26
- export { keys };
27
- export declare function channels(): (app: Application) => void;
28
- export { Channel, CombinedChannel, RealTimeConnection };
@@ -1,86 +0,0 @@
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.CombinedChannel = exports.Channel = exports.keys = void 0;
7
- exports.channels = channels;
8
- const feathers_1 = require("@feathersjs/feathers");
9
- const commons_1 = require("@feathersjs/commons");
10
- const flattenDeep_1 = __importDefault(require("lodash/flattenDeep"));
11
- const base_1 = require("./channel/base");
12
- Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return base_1.Channel; } });
13
- const combined_1 = require("./channel/combined");
14
- Object.defineProperty(exports, "CombinedChannel", { enumerable: true, get: function () { return combined_1.CombinedChannel; } });
15
- const mixins_1 = require("./mixins");
16
- Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return mixins_1.keys; } });
17
- const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons/channels');
18
- const { CHANNELS } = mixins_1.keys;
19
- function channels() {
20
- return (app) => {
21
- if (typeof app.channel === 'function' && typeof app.publish === 'function') {
22
- return;
23
- }
24
- Object.assign(app, (0, mixins_1.channelMixin)(), (0, mixins_1.publishMixin)());
25
- Object.defineProperty(app, 'channels', {
26
- get() {
27
- return Object.keys(this[CHANNELS]);
28
- }
29
- });
30
- app.mixins.push((service, path) => {
31
- const { serviceEvents } = (0, feathers_1.getServiceOptions)(service);
32
- if (typeof service.publish === 'function') {
33
- return;
34
- }
35
- Object.assign(service, (0, mixins_1.publishMixin)());
36
- serviceEvents.forEach((event) => {
37
- service.on(event, function (data, hook) {
38
- if (!hook) {
39
- // Fake hook for custom events
40
- hook = { path, service, app, result: data };
41
- }
42
- debug('Publishing event', event, hook.path);
43
- const logError = (error) => debug(`Error in '${hook.path} ${event}' publisher`, error);
44
- const servicePublishers = service[mixins_1.keys.PUBLISHERS];
45
- const appPublishers = app[mixins_1.keys.PUBLISHERS];
46
- // This will return the first publisher list that is not empty
47
- // In the following precedence
48
- const publisher =
49
- // 1. Service publisher for a specific event
50
- servicePublishers[event] ||
51
- // 2. Service publisher for all events
52
- servicePublishers[mixins_1.keys.ALL_EVENTS] ||
53
- // 3. App publisher for a specific event
54
- appPublishers[event] ||
55
- // 4. App publisher for all events
56
- appPublishers[mixins_1.keys.ALL_EVENTS] ||
57
- // 5. No publisher
58
- (() => { });
59
- try {
60
- Promise.resolve(publisher(data, hook))
61
- .then((result) => {
62
- if (!result) {
63
- return;
64
- }
65
- const results = Array.isArray(result)
66
- ? (0, flattenDeep_1.default)(result).filter(Boolean)
67
- : [result];
68
- const channel = new combined_1.CombinedChannel(results);
69
- if (channel && channel.length > 0) {
70
- app.emit('publish', event, channel, hook, data);
71
- }
72
- else {
73
- debug('No connections to publish to');
74
- }
75
- })
76
- .catch(logError);
77
- }
78
- catch (error) {
79
- logError(error);
80
- }
81
- });
82
- });
83
- });
84
- };
85
- }
86
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":";;;;;;AA2CA,4BA0EC;AArHD,mDAA0G;AAC1G,iDAAiD;AACjD,qEAA4C;AAC5C,yCAAwC;AAoH/B,wFApHA,cAAO,OAoHA;AAnHhB,iDAAoD;AAmHlC,gGAnHT,0BAAe,OAmHS;AAlHjC,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,GAAgB,EAAE,EAAE;QAC1B,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YAC3E,OAAM;QACR,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAA,qBAAY,GAAE,EAAE,IAAA,qBAAY,GAAE,CAAC,CAAA;QAClD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YACrC,GAAG;gBACD,OAAO,MAAM,CAA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CAAC;wBACpB,kCAAkC;wBAClC,aAAa,CAAC,aAAI,CAAC,UAAU,CAAC;wBAC9B,kBAAkB;wBAClB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;oBAEZ,IAAI,CAAC;wBACH,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;6BACnC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;4BACpB,IAAI,CAAC,MAAM,EAAE,CAAC;gCACZ,OAAM;4BACR,CAAC;4BAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gCACnC,CAAC,CAAC,IAAA,qBAAW,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;gCACrC,CAAC,CAAE,CAAC,MAAM,CAAe,CAAA;4BAC3B,MAAM,OAAO,GAAG,IAAI,0BAAe,CAAC,OAAO,CAAC,CAAA;4BAE5C,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gCAClC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;4BACjD,CAAC;iCAAM,CAAC;gCACN,KAAK,CAAC,8BAA8B,CAAC,CAAA;4BACvC,CAAC;wBACH,CAAC,CAAC;6BACD,KAAK,CAAC,QAAQ,CAAC,CAAA;oBACpB,CAAC;oBAAC,OAAO,KAAU,EAAE,CAAC;wBACpB,QAAQ,CAAC,KAAK,CAAC,CAAA;oBACjB,CAAC;gBACH,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
@@ -1,29 +0,0 @@
1
- import { Application, HookContext } from '@feathersjs/feathers';
2
- import { Channel } from './channel/base';
3
- declare const PUBLISHERS: unique symbol;
4
- declare const CHANNELS: unique symbol;
5
- declare const ALL_EVENTS: unique symbol;
6
- export declare const keys: {
7
- PUBLISHERS: typeof PUBLISHERS;
8
- CHANNELS: typeof CHANNELS;
9
- ALL_EVENTS: typeof ALL_EVENTS;
10
- };
11
- export interface ChannelMixin {
12
- [CHANNELS]: {
13
- [key: string]: Channel;
14
- };
15
- channel(...names: string[]): Channel;
16
- }
17
- export declare function channelMixin(): ChannelMixin;
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
- export interface PublishMixin<T = any> {
21
- [PUBLISHERS]: {
22
- [ALL_EVENTS]?: Publisher<T>;
23
- [key: string]: Publisher<T>;
24
- };
25
- publish(event: Event, publisher: Publisher<T>): this;
26
- registerPublisher(event: Event, publisher: Publisher<T>): this;
27
- }
28
- export declare function publishMixin(): PublishMixin<any>;
29
- export {};
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.keys = void 0;
4
- exports.channelMixin = channelMixin;
5
- exports.publishMixin = publishMixin;
6
- /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
7
- const feathers_1 = require("@feathersjs/feathers");
8
- const commons_1 = require("@feathersjs/commons");
9
- const base_1 = require("./channel/base");
10
- const combined_1 = require("./channel/combined");
11
- const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons/channels/mixins');
12
- const PUBLISHERS = Symbol.for('@feathersjs/transport-commons/publishers');
13
- const CHANNELS = Symbol.for('@feathersjs/transport-commons/channels');
14
- const ALL_EVENTS = Symbol.for('@feathersjs/transport-commons/all-events');
15
- exports.keys = {
16
- PUBLISHERS: PUBLISHERS,
17
- CHANNELS: CHANNELS,
18
- ALL_EVENTS: ALL_EVENTS
19
- };
20
- function channelMixin() {
21
- const mixin = {
22
- [CHANNELS]: {},
23
- channel(...names) {
24
- debug('Returning channels', names);
25
- if (names.length === 0) {
26
- throw new Error('app.channel needs at least one channel name');
27
- }
28
- if (names.length === 1) {
29
- const [name] = names;
30
- if (Array.isArray(name)) {
31
- return this.channel(...name);
32
- }
33
- if (!this[CHANNELS][name]) {
34
- const channel = new base_1.Channel();
35
- channel.once('empty', () => {
36
- channel.removeAllListeners();
37
- delete this[CHANNELS][name];
38
- });
39
- this[CHANNELS][name] = channel;
40
- }
41
- return this[CHANNELS][name];
42
- }
43
- const channels = names.map((name) => this.channel(name));
44
- return new combined_1.CombinedChannel(channels);
45
- }
46
- };
47
- return mixin;
48
- }
49
- function publishMixin() {
50
- const result = {
51
- [PUBLISHERS]: {},
52
- publish(...args) {
53
- return this.registerPublisher(...args);
54
- },
55
- registerPublisher(event, publisher) {
56
- debug('Registering publisher', event);
57
- if (!publisher && typeof event === 'function') {
58
- publisher = event;
59
- event = ALL_EVENTS;
60
- }
61
- const { serviceEvents = feathers_1.defaultServiceEvents } = (0, feathers_1.getServiceOptions)(this) || {};
62
- if (event !== ALL_EVENTS && !serviceEvents.includes(event)) {
63
- throw new Error(`'${event.toString()}' is not a valid service event`);
64
- }
65
- const publishers = this[PUBLISHERS];
66
- publishers[event] = publisher;
67
- return this;
68
- }
69
- };
70
- return result;
71
- }
72
- //# sourceMappingURL=mixins.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mixins.js","sourceRoot":"","sources":["../../src/channels/mixins.ts"],"names":[],"mappings":";;;AAsBA,oCAuCC;AAeD,oCA+BC;AA3GD,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,GAAG,CAAC,0CAA0C,CAAC,CAAA;AACzE,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAA;AACrE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAA;AAE5D,QAAA,IAAI,GAAG;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,CAAC,QAAQ,CAAC,CAAA;QACtC,CAAC;KACF,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAeD,SAAgB,YAAY;IAC1B,MAAM,MAAM,GAAiB;QAC3B,CAAC,UAAU,CAAC,EAAE,EAAE;QAEhB,OAAO,CAAC,GAAG,IAAI;YACb,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC,CAAA;QACxC,CAAC;QAED,iBAAiB,CAAC,KAAK,EAAE,SAAS;YAChC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAA;YAErC,IAAI,CAAC,SAAS,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAC9C,SAAS,GAAG,KAAK,CAAA;gBACjB,KAAK,GAAG,UAAU,CAAA;YACpB,CAAC;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,CAAC;gBAC3D,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,gCAAgC,CAAC,CAAA;YACvE,CAAC;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"}
package/lib/http.d.ts DELETED
@@ -1,35 +0,0 @@
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 DELETED
@@ -1,77 +0,0 @@
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.argumentsFor = exports.knownMethods = exports.statusCodes = exports.METHOD_HEADER = void 0;
7
- exports.getServiceMethod = getServiceMethod;
8
- exports.getStatusCode = getStatusCode;
9
- exports.getResponse = getResponse;
10
- const lib_1 = require("@feathersjs/errors/lib");
11
- const encodeurl_1 = __importDefault(require("encodeurl"));
12
- exports.METHOD_HEADER = 'x-service-method';
13
- exports.statusCodes = {
14
- created: 201,
15
- noContent: 204,
16
- methodNotAllowed: 405,
17
- success: 200,
18
- seeOther: 303
19
- };
20
- exports.knownMethods = {
21
- post: 'create',
22
- patch: 'patch',
23
- put: 'update',
24
- delete: 'remove'
25
- };
26
- function getServiceMethod(_httpMethod, id, headerOverride) {
27
- const httpMethod = _httpMethod.toLowerCase();
28
- if (httpMethod === 'post' && headerOverride) {
29
- return headerOverride;
30
- }
31
- const mappedMethod = exports.knownMethods[httpMethod];
32
- if (mappedMethod) {
33
- return mappedMethod;
34
- }
35
- if (httpMethod === 'get') {
36
- return id === null ? 'find' : 'get';
37
- }
38
- throw new lib_1.MethodNotAllowed(`Method ${_httpMethod} not allowed`);
39
- }
40
- exports.argumentsFor = {
41
- get: ({ id, params }) => [id, params],
42
- find: ({ params }) => [params],
43
- create: ({ data, params }) => [data, params],
44
- update: ({ id, data, params }) => [id, data, params],
45
- patch: ({ id, data, params }) => [id, data, params],
46
- remove: ({ id, params }) => [id, params],
47
- default: ({ data, params }) => [data, params]
48
- };
49
- function getStatusCode(context, body, location) {
50
- const { http = {} } = context;
51
- if (http.status) {
52
- return http.status;
53
- }
54
- if (location !== undefined) {
55
- return exports.statusCodes.seeOther;
56
- }
57
- if (!body) {
58
- return exports.statusCodes.noContent;
59
- }
60
- if (context.method === 'create') {
61
- return exports.statusCodes.created;
62
- }
63
- return exports.statusCodes.success;
64
- }
65
- function getResponse(context) {
66
- const { http = {} } = context;
67
- const body = context.dispatch !== undefined ? context.dispatch : context.result;
68
- let headers = http.headers || {};
69
- let location = headers.Location;
70
- if (http.location !== undefined) {
71
- location = (0, encodeurl_1.default)(http.location);
72
- headers = { ...headers, Location: location };
73
- }
74
- const status = getStatusCode(context, body, location);
75
- return { status, headers, body };
76
- }
77
- //# sourceMappingURL=http.js.map
package/lib/http.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;;;;AA2BA,4CAkBC;AAYD,sCAoBC;AAED,kCAeC;AA9FD,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;I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,EAAE,QAAQ,EAAE,CAAA;IAC9C,CAAC;IAED,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;IAErD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AAClC,CAAC"}
@@ -1,21 +0,0 @@
1
- import { Application } from '@feathersjs/feathers';
2
- import { Router } from './router';
3
- declare module '@feathersjs/feathers/lib/declarations' {
4
- interface RouteLookup {
5
- service: Service;
6
- params: {
7
- [key: string]: any;
8
- };
9
- }
10
- interface Application<Services, Settings> {
11
- routes: Router<{
12
- service: Service;
13
- params?: {
14
- [key: string]: any;
15
- };
16
- }>;
17
- lookup(path: string): RouteLookup;
18
- }
19
- }
20
- export * from './router';
21
- export declare const routing: () => (app: Application) => void;
@@ -1,49 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.routing = void 0;
18
- const router_1 = require("./router");
19
- __exportStar(require("./router"), exports);
20
- const lookup = function (path) {
21
- const result = this.routes.lookup(path);
22
- if (result === null) {
23
- return null;
24
- }
25
- const { params: colonParams, data: { service, params: dataParams } } = result;
26
- const params = dataParams ? { ...dataParams, ...colonParams } : colonParams;
27
- return { service, params };
28
- };
29
- const routing = () => (app) => {
30
- if (typeof app.lookup === 'function') {
31
- return;
32
- }
33
- const { unuse } = app;
34
- app.routes = new router_1.Router();
35
- app.lookup = lookup;
36
- app.unuse = function (path) {
37
- app.routes.remove(path);
38
- app.routes.remove(`${path}/:__id`);
39
- return unuse.call(this, path);
40
- };
41
- // Add a mixin that registers a service on the router
42
- app.mixins.push((service, path, options) => {
43
- const { routeParams: params = {} } = options;
44
- app.routes.insert(path, { service, params });
45
- app.routes.insert(`${path}/:__id`, { service, params });
46
- });
47
- };
48
- exports.routing = routing;
49
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,qCAAiC;AAmBjC,2CAAwB;AAExB,MAAM,MAAM,GAAG,UAA6B,IAAY;IACtD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAEvC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,EACJ,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EACtC,GAAG,MAAM,CAAA;IAEV,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAA;IAE3E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA;AAC5B,CAAC,CAAA;AAEM,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,GAAgB,EAAE,EAAE;IAChD,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACrC,OAAM;IACR,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;IAErB,GAAG,CAAC,MAAM,GAAG,IAAI,eAAM,EAAE,CAAA;IACzB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAA;IACnB,GAAG,CAAC,KAAK,GAAG,UAAU,IAAY;QAChC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACvB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAA;QAClC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC/B,CAAC,CAAA;IAED,qDAAqD;IACrD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAwB,EAAE,IAAY,EAAE,OAAuB,EAAE,EAAE;QAClF,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,OAAO,CAAA;QAE5C,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;QAC5C,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAtBY,QAAA,OAAO,WAsBnB"}
@@ -1,31 +0,0 @@
1
- export interface LookupData {
2
- params: {
3
- [key: string]: string;
4
- };
5
- }
6
- export interface LookupResult<T> extends LookupData {
7
- data?: T;
8
- }
9
- export declare class RouteNode<T = any> {
10
- name: string;
11
- depth: number;
12
- data?: T;
13
- children: {
14
- [key: string]: RouteNode;
15
- };
16
- placeholders: RouteNode[];
17
- constructor(name: string, depth: number);
18
- get hasChildren(): boolean;
19
- insert(path: string[], data: T): RouteNode<T>;
20
- remove(path: string[]): void;
21
- lookup(path: string[], info: LookupData): LookupResult<T> | null;
22
- }
23
- export declare class Router<T = any> {
24
- root: RouteNode<T>;
25
- caseSensitive: boolean;
26
- constructor(root?: RouteNode<T>);
27
- getPath(path: string): string[];
28
- insert(path: string, data: T): RouteNode<T>;
29
- remove(path: string): void;
30
- lookup(path: string): LookupResult<T>;
31
- }