Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
chore(release): 1.0.0-alpha.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerntannern committed Nov 19, 2018
1 parent f679fee commit 2fdf865
Show file tree
Hide file tree
Showing 29 changed files with 983 additions and 255 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="1.0.0-alpha.0"></a>
# [1.0.0-alpha.0](https://github.com/tannerntannern/table-talk/compare/v0.2.0...v1.0.0-alpha.0) (2018-11-19)


### Features

* BREAKING CHANGE: extracted the shapes of socket and express servers as interfaces and exposed them ([f679fee](https://github.com/tannerntannern/table-talk/commit/f679fee))



<a name="0.2.0"></a>
# [0.2.0](https://github.com/tannerntannern/table-talk/compare/v0.1.0...v0.2.0) (2018-11-18)

Expand Down
6 changes: 3 additions & 3 deletions dist/index.d.ts
Expand Up @@ -5,6 +5,6 @@ import { SocketServer, SocketServerConfig, HandlerCtx as SocketHandlerCtx } from
import { SocketClient } from './client/socket-client';
import { SocketExpressServer, SocketExpressServerConfig } from './server/socket-express-server';
import { SocketExpressClient } from './client/socket-express-client';
import { HttpHandlers } from './interface/http-interface';
import { SocketHandlers } from './interface/socket-interface';
export { HttpHandlers, SocketHandlers, HttpServer, HttpServerConfig, ExpressServer, ExpressServerConfig, ExpressHandlerCtx, ExpressClient, SocketServer, SocketServerConfig, SocketHandlerCtx, SocketClient, SocketExpressServer, SocketExpressServerConfig, SocketExpressClient };
import { HttpHandlers, ExpressServerInterface } from './interface/http-interface';
import { SocketHandlers, SocketServerInterface } from './interface/socket-interface';
export { HttpHandlers, SocketHandlers, ExpressServerInterface, SocketServerInterface, HttpServer, HttpServerConfig, ExpressServer, ExpressServerConfig, ExpressHandlerCtx, ExpressClient, SocketServer, SocketServerConfig, SocketHandlerCtx, SocketClient, SocketExpressServer, SocketExpressServerConfig, SocketExpressClient };
7 changes: 7 additions & 0 deletions dist/interface/http-interface.d.ts
@@ -1,6 +1,7 @@
/**
* Describes the components of an endpoint.
*/
import { HandlerCtx } from '../server/express-server';
declare type Endpoint = {
return: any;
args?: {
Expand Down Expand Up @@ -35,4 +36,10 @@ export declare type HttpHandlers<API extends HttpInterface, HandlerCtx> = {
}) => any;
};
};
/**
* TODO: ...
*/
export interface ExpressServerInterface<API extends HttpInterface> {
httpHandlers: HttpHandlers<API, HandlerCtx<API>>;
}
export {};
22 changes: 15 additions & 7 deletions dist/interface/socket-interface.d.ts
@@ -1,11 +1,13 @@
import { HandlerCtx } from '../server/socket-server';
import * as socketio from 'socket.io';
/**
* Where socket handlers can reside -- either on the server or the client.
*/
export declare type SocketLocation = 'server' | 'client';
/**
* Given a SocketLocation, generates the opposite SocketLocation.
*/
export declare type OtherLocation<L extends SocketLocation> = L extends 'server' ? 'client' : 'server';
declare type OpLoc<L extends SocketLocation> = L extends 'server' ? 'client' : 'server';
/**
* Describes a transmittable event on either the client or the server. Each one may specify its argument types with a
* tuple, the name of the event it expects to receive as a response, and optionally the name of the event for which the
Expand Down Expand Up @@ -89,15 +91,21 @@ declare type RemoteTransmitterResponse<RT extends EventTransmitter, T extends Tr
* remote transmitter. Furthermore, if that remote transmitter expects a response from a local transmitter called
* 'give-data', then the event handler must respond with that transmitter and the arguments specified by it.
*/
declare type EventHandlers<T extends TransmitterMap, RT extends TransmitterMap, L extends SocketLocation, CTX> = {
[E in keyof RT]: (this: CTX, ...args: RT[E]['args']) => RemoteTransmitterResponse<RT[E], T, L>;
export declare type SocketHandlers<I extends SocketInterface, L extends SocketLocation, CTX> = {
[E in keyof I[OpLoc<L>]]: (this: CTX, ...args: I[OpLoc<L>][E]['args']) => RemoteTransmitterResponse<I[OpLoc<L>][E], I[L], L>;
} & {
[E in ResponseTos<T>]: (this: CTX, ...args: any[]) => Response<TransmitterWithResponseTo<T, E>, T, L>;
[E in ResponseTos<I[L]>]: (this: CTX, ...args: any[]) => Response<TransmitterWithResponseTo<I[L], E>, I[L], L>;
} & {
[extraHandler: string]: (this: CTX, ...args: any[]) => GenericTransmitterResponse<T, L>;
[extraHandler: string]: (this: CTX, ...args: any[]) => GenericTransmitterResponse<I[L], L>;
};
/**
* Utility type for generating EventHandlers given a SocketInterface and a SocketLocation.
* TODO: ...
*/
export declare type SocketHandlers<TS extends SocketInterface, SL extends SocketLocation, HandlerContext> = EventHandlers<TS[SL], TS[OtherLocation<SL>], SL, HandlerContext>;
export interface SocketServerInterface<API extends SocketInterface> {
socketHandlers: SocketHandlers<API, 'server', HandlerCtx<API>>;
emit<Event extends keyof API['server']>(target: socketio.Namespace | socketio.Socket, event: Event, ...args: API['server'][Event]['args']): this;
getNamespaces(): string[];
addNamespace(name: string): this;
removeNamespace(name: string): this;
}
export {};
6 changes: 3 additions & 3 deletions dist/server/express-server.d.ts
Expand Up @@ -2,7 +2,7 @@
import * as http from 'http';
import * as core from 'express-serve-static-core';
import { HttpServer, HttpServerConfig } from './http-server';
import { HttpHandlers, HttpInterface } from '../interface/http-interface';
import { ExpressServerInterface, HttpHandlers, HttpInterface } from '../interface/http-interface';
/**
* Defines how an ExpressServer may be configured.
*/
Expand All @@ -26,11 +26,11 @@ export declare type HandlerCtx<API extends HttpInterface> = {
* and to implement an interface that can also be implemented by an ExpressClient to ensure that both communicate with
* each other properly.
*/
export declare abstract class ExpressServer<API extends HttpInterface> extends HttpServer {
export declare abstract class ExpressServer<API extends HttpInterface> extends HttpServer implements ExpressServerInterface<API> {
/**
* Defines how the server should react to each request.
*/
protected abstract httpHandlers: HttpHandlers<API, HandlerCtx<API>>;
abstract httpHandlers: HttpHandlers<API, HandlerCtx<API>>;
/**
* Constructs a new ExpressServer.
*/
Expand Down
12 changes: 6 additions & 6 deletions dist/server/socket-server.d.ts
Expand Up @@ -2,7 +2,7 @@
import * as http from 'http';
import * as socketio from 'socket.io';
import { HttpServer, HttpServerConfig } from './http-server';
import { SocketHandlers, SocketInterface } from '../interface/socket-interface';
import { SocketHandlers, SocketInterface, SocketServerInterface } from '../interface/socket-interface';
import { SocketMixin } from '../lib/socket-mixin';
/**
* Defines how SocketServer may be configured.
Expand Down Expand Up @@ -31,7 +31,7 @@ declare abstract class SocketServer<API extends SocketInterface> extends HttpSer
* Contains implementations for the events described by the API. This guarantees compatibility with any
* SocketClient that implements the same API.
*/
protected abstract socketHandlers: SocketHandlers<API, 'server', HandlerCtx<API>>;
abstract socketHandlers: SocketHandlers<API, 'server', HandlerCtx<API>>;
/**
* Constructs a new SocketServer.
*/
Expand All @@ -47,7 +47,7 @@ declare abstract class SocketServer<API extends SocketInterface> extends HttpSer
/**
* Emits an event to the given target. The typings ensure that only events defined in the API can be emitted.
*/
emit<Event extends keyof API['server']>(target: socketio.Namespace | socketio.Socket, event: Event, ...args: API['server'][Event]['args']): void;
emit<Event extends keyof API['server']>(target: socketio.Namespace | socketio.Socket, event: Event, ...args: API['server'][Event]['args']): this;
/**
* Handles a Response that requires a reply.
*/
Expand All @@ -63,11 +63,11 @@ declare abstract class SocketServer<API extends SocketInterface> extends HttpSer
/**
* Adds a namespace to the socket server. Throws an error if the namespace already exists.
*/
addNamespace(name: string): void;
addNamespace(name: string): this;
/**
* Removes a namespace from the socket server.
*/
removeNamespace(name: string): void;
removeNamespace(name: string): this;
/**
* Attaches a socket.io server to the internal Node http server.
*/
Expand All @@ -77,6 +77,6 @@ declare abstract class SocketServer<API extends SocketInterface> extends HttpSer
*/
protected takedown(): void;
}
interface SocketServer<API extends SocketInterface> extends HttpServer, SocketMixin<API, 'server'> {
interface SocketServer<API extends SocketInterface> extends HttpServer, SocketMixin<API, 'server'>, SocketServerInterface<API> {
}
export { SocketServer };
3 changes: 3 additions & 0 deletions dist/server/socket-server.js
Expand Up @@ -65,6 +65,7 @@ var SocketServer = /** @class */ (function (_super) {
args[_i - 2] = arguments[_i];
}
target.emit.apply(target, [event].concat(args));
return this;
};
/**
* Handles a Response that requires a reply.
Expand Down Expand Up @@ -130,6 +131,7 @@ var SocketServer = /** @class */ (function (_super) {
var nsp = this.io.of(namespaceName);
this.config.namespaceConfig(nsp, this);
this.attachSocketHandlers(nsp);
return this;
};
/**
* Removes a namespace from the socket server.
Expand All @@ -147,6 +149,7 @@ var SocketServer = /** @class */ (function (_super) {
});
nsp.removeAllListeners();
delete this.io.nsps[namespaceName];
return this;
};
/**
* Attaches a socket.io server to the internal Node http server.
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/classes/_client_express_client_.expressclient.html
Expand Up @@ -140,7 +140,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/837a8ac/src/client/express-client.ts#L12">client/express-client.ts:12</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/f679fee/src/client/express-client.ts#L12">client/express-client.ts:12</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -167,7 +167,7 @@ <h3>host</h3>
<div class="tsd-signature tsd-kind-icon">host<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/837a8ac/src/client/express-client.ts#L12">client/express-client.ts:12</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/f679fee/src/client/express-client.ts#L12">client/express-client.ts:12</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -189,7 +189,7 @@ <h3>delete</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/837a8ac/src/client/express-client.ts#L50">client/express-client.ts:50</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/f679fee/src/client/express-client.ts#L50">client/express-client.ts:50</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -230,7 +230,7 @@ <h3>get</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/837a8ac/src/client/express-client.ts#L39">client/express-client.ts:39</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/f679fee/src/client/express-client.ts#L39">client/express-client.ts:39</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -271,7 +271,7 @@ <h3>patch</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/837a8ac/src/client/express-client.ts#L74">client/express-client.ts:74</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/f679fee/src/client/express-client.ts#L74">client/express-client.ts:74</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -311,7 +311,7 @@ <h3>post</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/837a8ac/src/client/express-client.ts#L60">client/express-client.ts:60</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/f679fee/src/client/express-client.ts#L60">client/express-client.ts:60</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -351,7 +351,7 @@ <h3>put</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/837a8ac/src/client/express-client.ts#L67">client/express-client.ts:67</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/f679fee/src/client/express-client.ts#L67">client/express-client.ts:67</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -391,7 +391,7 @@ <h3>request</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/837a8ac/src/client/express-client.ts#L24">client/express-client.ts:24</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/f679fee/src/client/express-client.ts#L24">client/express-client.ts:24</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down

0 comments on commit 2fdf865

Please sign in to comment.