@litert/televoke 0.4.7 → 1.0.0-1
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/CHANGES.md +4 -2
- package/README.md +13 -8
- package/lib/client/Client.decl.d.ts +47 -0
- package/lib/client/Client.decl.d.ts.map +1 -0
- package/lib/client/Client.decl.js +18 -0
- package/lib/client/Client.decl.js.map +1 -0
- package/lib/client/JsonApiClient.impl.d.ts +28 -0
- package/lib/client/JsonApiClient.impl.d.ts.map +1 -0
- package/lib/client/JsonApiClient.impl.js +169 -0
- package/lib/client/JsonApiClient.impl.js.map +1 -0
- package/lib/client/LegacyHttpClient.impl.d.ts +62 -0
- package/lib/client/LegacyHttpClient.impl.d.ts.map +1 -0
- package/lib/client/LegacyHttpClient.impl.js +163 -0
- package/lib/client/LegacyHttpClient.impl.js.map +1 -0
- package/lib/client/index.d.ts +19 -0
- package/lib/client/index.d.ts.map +1 -0
- package/lib/client/index.js +35 -0
- package/lib/client/index.js.map +1 -0
- package/lib/index.d.ts +18 -20
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -20
- package/lib/index.js.map +1 -1
- package/lib/server/LegacyServerChannel.impl.d.ts +38 -0
- package/lib/server/LegacyServerChannel.impl.d.ts.map +1 -0
- package/lib/server/LegacyServerChannel.impl.js +51 -0
- package/lib/server/LegacyServerChannel.impl.js.map +1 -0
- package/lib/server/Server.decl.d.ts +81 -0
- package/lib/server/Server.decl.d.ts.map +1 -0
- package/lib/server/Server.decl.js +18 -0
- package/lib/server/Server.decl.js.map +1 -0
- package/lib/server/Server.impl.d.ts +33 -0
- package/lib/server/Server.impl.d.ts.map +1 -0
- package/lib/server/Server.impl.js +58 -0
- package/lib/server/Server.impl.js.map +1 -0
- package/lib/server/ServerChannel.d.ts +20 -0
- package/lib/server/ServerChannel.d.ts.map +1 -0
- package/lib/server/ServerChannel.js +23 -0
- package/lib/server/ServerChannel.js.map +1 -0
- package/lib/server/SimpleJsonApiRouter.d.ts +28 -0
- package/lib/server/SimpleJsonApiRouter.d.ts.map +1 -0
- package/lib/server/SimpleJsonApiRouter.js +92 -0
- package/lib/server/SimpleJsonApiRouter.js.map +1 -0
- package/lib/server/index.d.ts +19 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/server/index.js +35 -0
- package/lib/server/index.js.map +1 -0
- package/lib/shared/BinaryStream.d.ts +36 -0
- package/lib/shared/BinaryStream.d.ts.map +1 -0
- package/lib/shared/BinaryStream.js +100 -0
- package/lib/shared/BinaryStream.js.map +1 -0
- package/lib/shared/BinaryStreamManager.d.ts +52 -0
- package/lib/shared/BinaryStreamManager.d.ts.map +1 -0
- package/lib/shared/BinaryStreamManager.js +105 -0
- package/lib/shared/BinaryStreamManager.js.map +1 -0
- package/lib/shared/Channel.impl.d.ts +79 -0
- package/lib/shared/Channel.impl.d.ts.map +1 -0
- package/lib/shared/Channel.impl.js +448 -0
- package/lib/shared/Channel.impl.js.map +1 -0
- package/lib/shared/Constants.d.ts +32 -0
- package/lib/shared/Constants.d.ts.map +1 -0
- package/lib/shared/Constants.js +35 -0
- package/lib/shared/Constants.js.map +1 -0
- package/lib/shared/Encodings/index.d.ts +18 -0
- package/lib/shared/Encodings/index.d.ts.map +1 -0
- package/lib/shared/Encodings/index.js +21 -0
- package/lib/shared/Encodings/index.js.map +1 -0
- package/lib/shared/Encodings/v1/EncoderV1.d.ts +22 -0
- package/lib/shared/Encodings/v1/EncoderV1.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/EncoderV1.js +47 -0
- package/lib/shared/Encodings/v1/EncoderV1.js.map +1 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.d.ts +78 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.js +53 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.js.map +1 -0
- package/lib/shared/Encodings/v1/index.d.ts +18 -0
- package/lib/shared/Encodings/v1/index.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/index.js +34 -0
- package/lib/shared/Encodings/v1/index.js.map +1 -0
- package/lib/shared/Encodings/v2/Constants.v2.d.ts +29 -0
- package/lib/shared/Encodings/v2/Constants.v2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/Constants.v2.js +34 -0
- package/lib/shared/Encodings/v2/Constants.v2.js.map +1 -0
- package/lib/shared/Encodings/v2/DecoderV2.d.ts +27 -0
- package/lib/shared/Encodings/v2/DecoderV2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/DecoderV2.js +281 -0
- package/lib/shared/Encodings/v2/DecoderV2.js.map +1 -0
- package/lib/shared/Encodings/v2/EncoderV2.d.ts +21 -0
- package/lib/shared/Encodings/v2/EncoderV2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/EncoderV2.js +177 -0
- package/lib/shared/Encodings/v2/EncoderV2.js.map +1 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.d.ts +99 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.js +18 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.js.map +1 -0
- package/lib/shared/Encodings/v2/index.d.ts +20 -0
- package/lib/shared/Encodings/v2/index.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/index.js +35 -0
- package/lib/shared/Encodings/v2/index.js.map +1 -0
- package/lib/shared/Errors.d.ts +61 -0
- package/lib/shared/Errors.d.ts.map +1 -0
- package/lib/shared/Errors.js +76 -0
- package/lib/shared/Errors.js.map +1 -0
- package/lib/shared/Shared.decl.d.ts +313 -0
- package/lib/shared/Shared.decl.d.ts.map +1 -0
- package/lib/shared/Shared.decl.js +18 -0
- package/lib/shared/Shared.decl.js.map +1 -0
- package/lib/shared/Utils.d.ts +25 -0
- package/lib/shared/Utils.d.ts.map +1 -0
- package/lib/shared/Utils.js +46 -0
- package/lib/shared/Utils.js.map +1 -0
- package/lib/shared/index.d.ts +23 -0
- package/lib/shared/index.d.ts.map +1 -0
- package/lib/shared/index.js +39 -0
- package/lib/shared/index.js.map +1 -0
- package/lib/transporters/Transporter.decl.d.ts +90 -0
- package/lib/transporters/Transporter.decl.d.ts.map +1 -0
- package/lib/transporters/Transporter.decl.js +18 -0
- package/lib/transporters/Transporter.decl.js.map +1 -0
- package/lib/transporters/http-listener/AbstractHttpListener.d.ts +32 -0
- package/lib/transporters/http-listener/AbstractHttpListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/AbstractHttpListener.js +46 -0
- package/lib/transporters/http-listener/AbstractHttpListener.js.map +1 -0
- package/lib/transporters/http-listener/Http.Decl.d.ts +95 -0
- package/lib/transporters/http-listener/Http.Decl.d.ts.map +1 -0
- package/lib/transporters/http-listener/Http.Decl.js +52 -0
- package/lib/transporters/http-listener/Http.Decl.js.map +1 -0
- package/lib/transporters/http-listener/HttpListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpListener.js +73 -0
- package/lib/transporters/http-listener/HttpListener.js.map +1 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.js +72 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.js.map +1 -0
- package/lib/transporters/http-listener/HttpsListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpsListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpsListener.js +73 -0
- package/lib/transporters/http-listener/HttpsListener.js.map +1 -0
- package/lib/transporters/http-listener/index.d.ts +20 -0
- package/lib/transporters/http-listener/index.d.ts.map +1 -0
- package/lib/transporters/http-listener/index.js +36 -0
- package/lib/transporters/http-listener/index.js.map +1 -0
- package/lib/transporters/index.d.ts +17 -0
- package/lib/transporters/index.d.ts.map +1 -0
- package/lib/transporters/index.js +18 -0
- package/lib/transporters/index.js.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.d.ts +24 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.d.ts.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.js +167 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.js.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.d.ts +28 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.d.ts.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.js +55 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.js.map +1 -0
- package/lib/transporters/legacy-http/index.d.ts +18 -0
- package/lib/transporters/legacy-http/index.d.ts.map +1 -0
- package/lib/transporters/legacy-http/index.js +34 -0
- package/lib/transporters/legacy-http/index.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.d.ts +34 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.js +78 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.decl.d.ts +18 -0
- package/lib/transporters/lwdfx/LwDFX.decl.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.decl.js +18 -0
- package/lib/transporters/lwdfx/LwDFX.decl.js.map +1 -0
- package/lib/transporters/lwdfx/index.d.ts +23 -0
- package/lib/transporters/lwdfx/index.d.ts.map +1 -0
- package/lib/transporters/lwdfx/index.js +39 -0
- package/lib/transporters/lwdfx/index.js.map +1 -0
- package/lib/transporters/memory/Memory.Impl.d.ts +43 -0
- package/lib/transporters/memory/Memory.Impl.d.ts.map +1 -0
- package/lib/transporters/memory/Memory.Impl.js +227 -0
- package/lib/transporters/memory/Memory.Impl.js.map +1 -0
- package/lib/transporters/memory/index.d.ts +17 -0
- package/lib/transporters/memory/index.d.ts.map +1 -0
- package/lib/transporters/memory/index.js +33 -0
- package/lib/transporters/memory/index.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Client.d.ts +20 -0
- package/lib/transporters/websocket/WebSocket.Client.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Client.js +68 -0
- package/lib/transporters/websocket/WebSocket.Client.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Server.d.ts +25 -0
- package/lib/transporters/websocket/WebSocket.Server.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Server.js +87 -0
- package/lib/transporters/websocket/WebSocket.Server.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Transporter.d.ts +34 -0
- package/lib/transporters/websocket/WebSocket.Transporter.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Transporter.js +106 -0
- package/lib/transporters/websocket/WebSocket.Transporter.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.decl.d.ts +19 -0
- package/lib/transporters/websocket/WebSocket.decl.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.decl.js +22 -0
- package/lib/transporters/websocket/WebSocket.decl.js.map +1 -0
- package/lib/transporters/websocket/index.d.ts +19 -0
- package/lib/transporters/websocket/index.d.ts.map +1 -0
- package/lib/transporters/websocket/index.js +35 -0
- package/lib/transporters/websocket/index.js.map +1 -0
- package/package.json +12 -12
- package/src/lib/client/Client.decl.ts +61 -0
- package/src/lib/client/JsonApiClient.impl.ts +258 -0
- package/src/lib/client/LegacyHttpClient.impl.ts +278 -0
- package/src/lib/client/index.ts +19 -0
- package/src/lib/index.ts +18 -20
- package/src/lib/server/LegacyServerChannel.impl.ts +71 -0
- package/src/lib/server/Server.decl.ts +109 -0
- package/src/lib/server/Server.impl.ts +90 -0
- package/src/lib/server/ServerChannel.ts +20 -0
- package/src/lib/server/SimpleJsonApiRouter.ts +135 -0
- package/src/lib/server/index.ts +19 -0
- package/src/lib/shared/BinaryStream.ts +141 -0
- package/src/lib/shared/BinaryStreamManager.ts +142 -0
- package/src/lib/shared/Channel.impl.ts +658 -0
- package/src/lib/shared/Constants.ts +35 -0
- package/src/lib/shared/Encodings/index.ts +18 -0
- package/src/lib/shared/Encodings/v1/EncoderV1.ts +66 -0
- package/src/lib/shared/Encodings/v1/Protocol.v1.decls.ts +96 -0
- package/src/lib/shared/Encodings/v1/index.ts +18 -0
- package/src/lib/shared/Encodings/v2/Constants.v2.ts +31 -0
- package/src/lib/shared/Encodings/v2/DecoderV2.ts +406 -0
- package/src/lib/shared/Encodings/v2/EncoderV2.ts +284 -0
- package/src/lib/shared/Encodings/v2/Encoding.v2.decl.ts +138 -0
- package/src/lib/shared/Encodings/v2/index.ts +20 -0
- package/src/lib/shared/Errors.ts +95 -0
- package/src/lib/shared/Shared.decl.ts +366 -0
- package/src/lib/shared/Utils.ts +51 -0
- package/src/lib/shared/index.ts +23 -0
- package/src/lib/transporters/Transporter.decl.ts +117 -0
- package/src/lib/transporters/http-listener/AbstractHttpListener.ts +57 -0
- package/src/lib/transporters/http-listener/Http.Decl.ts +141 -0
- package/src/lib/transporters/http-listener/HttpListener.ts +102 -0
- package/src/lib/transporters/http-listener/HttpUnixSocketListener.ts +97 -0
- package/src/lib/transporters/http-listener/HttpsListener.ts +102 -0
- package/src/lib/transporters/http-listener/index.ts +20 -0
- package/src/lib/transporters/index.ts +17 -0
- package/src/lib/transporters/legacy-http/LegacyHttp.Server.ts +262 -0
- package/src/lib/transporters/legacy-http/LegacyHttp.Transporter.ts +66 -0
- package/src/lib/transporters/legacy-http/index.ts +18 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tcp.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tcp.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tls.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tls.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.Transporter.ts +100 -0
- package/src/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.decl.ts +19 -0
- package/src/lib/transporters/lwdfx/index.ts +23 -0
- package/src/lib/transporters/memory/Memory.Impl.ts +363 -0
- package/src/lib/transporters/memory/index.ts +17 -0
- package/src/lib/transporters/websocket/WebSocket.Client.ts +76 -0
- package/src/lib/transporters/websocket/WebSocket.Server.ts +118 -0
- package/src/lib/transporters/websocket/WebSocket.Transporter.ts +132 -0
- package/src/lib/transporters/websocket/WebSocket.decl.ts +21 -0
- package/src/lib/transporters/websocket/index.ts +19 -0
- package/lib/Client/BuiltInRIDGenerator.d.ts +0 -4
- package/lib/Client/BuiltInRIDGenerator.d.ts.map +0 -1
- package/lib/Client/BuiltInRIDGenerator.js +0 -18
- package/lib/Client/BuiltInRIDGenerator.js.map +0 -1
- package/lib/Client/Common.d.ts +0 -47
- package/lib/Client/Common.d.ts.map +0 -1
- package/lib/Client/Common.js +0 -18
- package/lib/Client/Common.js.map +0 -1
- package/lib/Client/Errors.d.ts +0 -26
- package/lib/Client/Errors.d.ts.map +0 -1
- package/lib/Client/Errors.js +0 -80
- package/lib/Client/Errors.js.map +0 -1
- package/lib/Client/HttpClient.d.ts +0 -37
- package/lib/Client/HttpClient.d.ts.map +0 -1
- package/lib/Client/HttpClient.js +0 -148
- package/lib/Client/HttpClient.js.map +0 -1
- package/lib/Client/HttpsClient.d.ts +0 -40
- package/lib/Client/HttpsClient.d.ts.map +0 -1
- package/lib/Client/HttpsClient.js +0 -144
- package/lib/Client/HttpsClient.js.map +0 -1
- package/lib/Client/TCPClient.d.ts +0 -34
- package/lib/Client/TCPClient.d.ts.map +0 -1
- package/lib/Client/TCPClient.js +0 -271
- package/lib/Client/TCPClient.js.map +0 -1
- package/lib/Client/TLSClient.d.ts +0 -34
- package/lib/Client/TLSClient.d.ts.map +0 -1
- package/lib/Client/TLSClient.js +0 -265
- package/lib/Client/TLSClient.js.map +0 -1
- package/lib/Client/index.d.ts +0 -23
- package/lib/Client/index.d.ts.map +0 -1
- package/lib/Client/index.js +0 -39
- package/lib/Client/index.js.map +0 -1
- package/lib/Common/API.d.ts +0 -19
- package/lib/Common/API.d.ts.map +0 -1
- package/lib/Common/API.js +0 -18
- package/lib/Common/API.js.map +0 -1
- package/lib/Common/Encoding.d.ts +0 -32
- package/lib/Common/Encoding.d.ts.map +0 -1
- package/lib/Common/Encoding.js +0 -20
- package/lib/Common/Encoding.js.map +0 -1
- package/lib/Common/Request.d.ts +0 -23
- package/lib/Common/Request.d.ts.map +0 -1
- package/lib/Common/Request.js +0 -18
- package/lib/Common/Request.js.map +0 -1
- package/lib/Common/Response.d.ts +0 -60
- package/lib/Common/Response.d.ts.map +0 -1
- package/lib/Common/Response.js +0 -42
- package/lib/Common/Response.js.map +0 -1
- package/lib/Common/index.d.ts +0 -20
- package/lib/Common/index.d.ts.map +0 -1
- package/lib/Common/index.js +0 -36
- package/lib/Common/index.js.map +0 -1
- package/lib/Encoder/Decoder.d.ts +0 -18
- package/lib/Encoder/Decoder.d.ts.map +0 -1
- package/lib/Encoder/Decoder.js +0 -136
- package/lib/Encoder/Decoder.js.map +0 -1
- package/lib/Encoder/Encoder.d.ts +0 -18
- package/lib/Encoder/Encoder.d.ts.map +0 -1
- package/lib/Encoder/Encoder.js +0 -35
- package/lib/Encoder/Encoder.js.map +0 -1
- package/lib/Encoder/Errors.d.ts +0 -17
- package/lib/Encoder/Errors.d.ts.map +0 -1
- package/lib/Encoder/Errors.js +0 -26
- package/lib/Encoder/Errors.js.map +0 -1
- package/lib/Errors.d.ts +0 -20
- package/lib/Errors.d.ts.map +0 -1
- package/lib/Errors.js +0 -40
- package/lib/Errors.js.map +0 -1
- package/lib/Server/Common/Gateway.d.ts +0 -26
- package/lib/Server/Common/Gateway.d.ts.map +0 -1
- package/lib/Server/Common/Gateway.js +0 -18
- package/lib/Server/Common/Gateway.js.map +0 -1
- package/lib/Server/Common/Request.d.ts +0 -21
- package/lib/Server/Common/Request.d.ts.map +0 -1
- package/lib/Server/Common/Request.js +0 -18
- package/lib/Server/Common/Request.js.map +0 -1
- package/lib/Server/Common/Router.d.ts +0 -41
- package/lib/Server/Common/Router.d.ts.map +0 -1
- package/lib/Server/Common/Router.js +0 -18
- package/lib/Server/Common/Router.js.map +0 -1
- package/lib/Server/Common/Server.d.ts +0 -57
- package/lib/Server/Common/Server.d.ts.map +0 -1
- package/lib/Server/Common/Server.js +0 -18
- package/lib/Server/Common/Server.js.map +0 -1
- package/lib/Server/Common/index.d.ts +0 -20
- package/lib/Server/Common/index.d.ts.map +0 -1
- package/lib/Server/Common/index.js +0 -36
- package/lib/Server/Common/index.js.map +0 -1
- package/lib/Server/Errors.d.ts +0 -25
- package/lib/Server/Errors.d.ts.map +0 -1
- package/lib/Server/Errors.js +0 -74
- package/lib/Server/Errors.js.map +0 -1
- package/lib/Server/Gateways/Http.d.ts +0 -18
- package/lib/Server/Gateways/Http.d.ts.map +0 -1
- package/lib/Server/Gateways/Http.js +0 -148
- package/lib/Server/Gateways/Http.js.map +0 -1
- package/lib/Server/Gateways/TCP.d.ts +0 -23
- package/lib/Server/Gateways/TCP.d.ts.map +0 -1
- package/lib/Server/Gateways/TCP.js +0 -146
- package/lib/Server/Gateways/TCP.js.map +0 -1
- package/lib/Server/Server.d.ts +0 -18
- package/lib/Server/Server.d.ts.map +0 -1
- package/lib/Server/Server.js +0 -200
- package/lib/Server/Server.js.map +0 -1
- package/lib/Server/SimpleRouter.d.ts +0 -41
- package/lib/Server/SimpleRouter.d.ts.map +0 -1
- package/lib/Server/SimpleRouter.js +0 -54
- package/lib/Server/SimpleRouter.js.map +0 -1
- package/lib/Server/index.d.ts +0 -22
- package/lib/Server/index.d.ts.map +0 -1
- package/lib/Server/index.js +0 -38
- package/lib/Server/index.js.map +0 -1
- package/src/lib/Client/BuiltInRIDGenerator.ts +0 -21
- package/src/lib/Client/Common.ts +0 -63
- package/src/lib/Client/Errors.ts +0 -87
- package/src/lib/Client/HttpClient.ts +0 -232
- package/src/lib/Client/HttpsClient.ts +0 -238
- package/src/lib/Client/TCPClient.ts +0 -420
- package/src/lib/Client/TLSClient.ts +0 -422
- package/src/lib/Client/index.ts +0 -23
- package/src/lib/Common/API.ts +0 -20
- package/src/lib/Common/Encoding.ts +0 -42
- package/src/lib/Common/Request.ts +0 -28
- package/src/lib/Common/Response.ts +0 -67
- package/src/lib/Common/index.ts +0 -20
- package/src/lib/Encoder/Decoder.ts +0 -206
- package/src/lib/Encoder/Encoder.ts +0 -41
- package/src/lib/Encoder/Errors.ts +0 -24
- package/src/lib/Errors.ts +0 -40
- package/src/lib/Server/Common/Gateway.ts +0 -37
- package/src/lib/Server/Common/Request.ts +0 -24
- package/src/lib/Server/Common/Router.ts +0 -52
- package/src/lib/Server/Common/Server.ts +0 -68
- package/src/lib/Server/Common/index.ts +0 -20
- package/src/lib/Server/Errors.ts +0 -80
- package/src/lib/Server/Gateways/Http.ts +0 -209
- package/src/lib/Server/Gateways/TCP.ts +0 -221
- package/src/lib/Server/Server.ts +0 -268
- package/src/lib/Server/SimpleRouter.ts +0 -95
- package/src/lib/Server/index.ts +0 -22
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { v2 } from '..';
|
|
18
|
+
import * as CS from './Constants.v2';
|
|
19
|
+
import type * as dEnc2 from './Encoding.v2.decl';
|
|
20
|
+
|
|
21
|
+
function writePacketHeader(ret: Buffer, command: CS.ECommand, type: CS.EPacketType, seq: number): void {
|
|
22
|
+
|
|
23
|
+
ret.writeUInt8(command, 0);
|
|
24
|
+
ret.writeUInt8(type, 1);
|
|
25
|
+
const low = seq % 0x1_0000_0000;
|
|
26
|
+
const high = (seq - low) / 0x1_0000_0000;
|
|
27
|
+
ret.writeUInt16LE(high, 2);
|
|
28
|
+
ret.writeUInt32LE(low, 4);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface IPacketEncoder {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Encode the given packet.
|
|
35
|
+
*
|
|
36
|
+
* @param packet The packet to encode.
|
|
37
|
+
*/
|
|
38
|
+
encode(packet: dEnc2.ICommandPacket): Array<string | Buffer>;
|
|
39
|
+
}
|
|
40
|
+
class ErrorResponseEncoder implements IPacketEncoder {
|
|
41
|
+
|
|
42
|
+
public encode(packet: dEnc2.IErrorResponsePacket): v2.IDataChunkArray {
|
|
43
|
+
|
|
44
|
+
const errorMsg = `${packet.ct.name}:${packet.ct.message}`;
|
|
45
|
+
|
|
46
|
+
const msgLen = Buffer.byteLength(errorMsg);
|
|
47
|
+
|
|
48
|
+
const buf = Buffer.allocUnsafe(CS.HEADER_SIZE + 2 + msgLen);
|
|
49
|
+
|
|
50
|
+
writePacketHeader(buf, packet.cmd, packet.typ, packet.seq);
|
|
51
|
+
|
|
52
|
+
buf.writeUInt16LE(msgLen, CS.HEADER_SIZE);
|
|
53
|
+
buf.write(errorMsg, CS.HEADER_SIZE + 2);
|
|
54
|
+
|
|
55
|
+
return [buf];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
class VoidResponseEncoder implements IPacketEncoder {
|
|
60
|
+
|
|
61
|
+
public encode(packet: dEnc2.ISuccessResponsePacket): v2.IDataChunkArray {
|
|
62
|
+
|
|
63
|
+
const buf = Buffer.allocUnsafe(CS.HEADER_SIZE);
|
|
64
|
+
|
|
65
|
+
writePacketHeader(buf, packet.cmd, packet.typ, packet.seq);
|
|
66
|
+
|
|
67
|
+
return [buf];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
class ApiRequestEncoder implements IPacketEncoder {
|
|
72
|
+
|
|
73
|
+
public encode(packet: dEnc2.IApiRequestPacket): v2.IDataChunkArray {
|
|
74
|
+
|
|
75
|
+
const apiNameLen = Buffer.byteLength(packet.ct.name);
|
|
76
|
+
|
|
77
|
+
const leadSeg = Buffer.allocUnsafe(CS.HEADER_SIZE + 2 + 4 + apiNameLen);
|
|
78
|
+
|
|
79
|
+
writePacketHeader(leadSeg, packet.cmd, packet.typ, packet.seq);
|
|
80
|
+
leadSeg.writeUInt16LE(apiNameLen, CS.HEADER_SIZE);
|
|
81
|
+
leadSeg.write(packet.ct.name, CS.HEADER_SIZE + 2);
|
|
82
|
+
|
|
83
|
+
if (Array.isArray(packet.ct.body)) {
|
|
84
|
+
|
|
85
|
+
let bodyLen = 0;
|
|
86
|
+
|
|
87
|
+
for (const p of packet.ct.body) {
|
|
88
|
+
|
|
89
|
+
bodyLen += Buffer.byteLength(p);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
leadSeg.writeUInt32LE(bodyLen, CS.HEADER_SIZE + 2 + apiNameLen);
|
|
93
|
+
|
|
94
|
+
return [leadSeg, ...packet.ct.body];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
leadSeg.writeUInt32LE(Buffer.byteLength(packet.ct.body), CS.HEADER_SIZE + 2 + apiNameLen);
|
|
98
|
+
|
|
99
|
+
return [leadSeg, packet.ct.body];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
class BinaryChunkRequestEncoder implements IPacketEncoder {
|
|
104
|
+
|
|
105
|
+
public encode(packet: dEnc2.IBinaryChunkRequestPacket): v2.IDataChunkArray {
|
|
106
|
+
|
|
107
|
+
const leadSeg = Buffer.allocUnsafe(CS.HEADER_SIZE + 12);
|
|
108
|
+
|
|
109
|
+
writePacketHeader(leadSeg, packet.cmd, packet.typ, packet.seq);
|
|
110
|
+
leadSeg.writeUInt32LE(packet.ct.streamId, CS.HEADER_SIZE);
|
|
111
|
+
leadSeg.writeUInt32LE(packet.ct.index, CS.HEADER_SIZE + 4);
|
|
112
|
+
|
|
113
|
+
if (Array.isArray(packet.ct.body)) {
|
|
114
|
+
|
|
115
|
+
let bodyLen = 0;
|
|
116
|
+
|
|
117
|
+
for (const p of packet.ct.body) {
|
|
118
|
+
|
|
119
|
+
bodyLen += Buffer.byteLength(p);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
leadSeg.writeUInt32LE(bodyLen, CS.HEADER_SIZE + 8);
|
|
123
|
+
|
|
124
|
+
return [leadSeg, ...packet.ct.body];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
leadSeg.writeUInt32LE(Buffer.byteLength(packet.ct.body), CS.HEADER_SIZE + 8);
|
|
128
|
+
|
|
129
|
+
return [leadSeg, packet.ct.body];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
class PingRequestEncoder implements IPacketEncoder {
|
|
134
|
+
|
|
135
|
+
public encode(packet: dEnc2.IPingRequestPacket): v2.IDataChunkArray {
|
|
136
|
+
|
|
137
|
+
const leadSeg = Buffer.allocUnsafe(CS.HEADER_SIZE + 2);
|
|
138
|
+
|
|
139
|
+
writePacketHeader(leadSeg, packet.cmd, packet.typ, packet.seq);
|
|
140
|
+
|
|
141
|
+
if (Array.isArray(packet.ct)) {
|
|
142
|
+
|
|
143
|
+
let bodyLen = 0;
|
|
144
|
+
|
|
145
|
+
for (const p of packet.ct) {
|
|
146
|
+
|
|
147
|
+
bodyLen += Buffer.byteLength(p);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
leadSeg.writeUInt16LE(bodyLen, CS.HEADER_SIZE);
|
|
151
|
+
|
|
152
|
+
return [leadSeg, ...packet.ct];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
leadSeg.writeUInt16LE(Buffer.byteLength(packet.ct), CS.HEADER_SIZE);
|
|
156
|
+
|
|
157
|
+
return [leadSeg, packet.ct];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
class CloseRequestEncoder implements IPacketEncoder {
|
|
162
|
+
|
|
163
|
+
public encode(packet: dEnc2.ICloseRequestPacket): v2.IDataChunkArray {
|
|
164
|
+
|
|
165
|
+
const leadSeg = Buffer.allocUnsafe(CS.HEADER_SIZE);
|
|
166
|
+
|
|
167
|
+
writePacketHeader(leadSeg, packet.cmd, packet.typ, packet.seq);
|
|
168
|
+
|
|
169
|
+
return [leadSeg];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
class PushMessageRequestEncoder implements IPacketEncoder {
|
|
174
|
+
|
|
175
|
+
public encode(packet: dEnc2.IPushMessageRequestPacket): v2.IDataChunkArray {
|
|
176
|
+
|
|
177
|
+
const leadSeg = Buffer.allocUnsafe(CS.HEADER_SIZE + 2);
|
|
178
|
+
|
|
179
|
+
writePacketHeader(leadSeg, packet.cmd, packet.typ, packet.seq);
|
|
180
|
+
|
|
181
|
+
if (Array.isArray(packet.ct)) {
|
|
182
|
+
|
|
183
|
+
let bodyLen = 0;
|
|
184
|
+
|
|
185
|
+
for (const p of packet.ct) {
|
|
186
|
+
|
|
187
|
+
bodyLen += Buffer.byteLength(p);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
leadSeg.writeUInt16LE(bodyLen, CS.HEADER_SIZE);
|
|
191
|
+
|
|
192
|
+
return [leadSeg, ...packet.ct];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
leadSeg.writeUInt16LE(Buffer.byteLength(packet.ct), CS.HEADER_SIZE);
|
|
196
|
+
|
|
197
|
+
return [leadSeg, packet.ct];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
class ApiResponseEncoder implements IPacketEncoder {
|
|
202
|
+
|
|
203
|
+
public encode(packet: dEnc2.IApiResponsePacket): v2.IDataChunkArray {
|
|
204
|
+
|
|
205
|
+
const leadSeg = Buffer.allocUnsafe(CS.HEADER_SIZE + 4);
|
|
206
|
+
|
|
207
|
+
writePacketHeader(leadSeg, packet.cmd, packet.typ, packet.seq);
|
|
208
|
+
|
|
209
|
+
if (Array.isArray(packet.ct)) {
|
|
210
|
+
|
|
211
|
+
let bodyLen = 0;
|
|
212
|
+
|
|
213
|
+
for (const p of packet.ct) {
|
|
214
|
+
|
|
215
|
+
bodyLen += Buffer.byteLength(p);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
leadSeg.writeUInt32LE(bodyLen, CS.HEADER_SIZE);
|
|
219
|
+
|
|
220
|
+
return [leadSeg, ...packet.ct];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
leadSeg.writeUInt32LE(Buffer.byteLength(packet.ct), CS.HEADER_SIZE);
|
|
224
|
+
|
|
225
|
+
return [leadSeg, packet.ct];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
class PingResponseEncoder implements IPacketEncoder {
|
|
230
|
+
|
|
231
|
+
public encode(packet: dEnc2.IPingResponsePacket): v2.IDataChunkArray {
|
|
232
|
+
|
|
233
|
+
const leadSeg = Buffer.allocUnsafe(CS.HEADER_SIZE + 2);
|
|
234
|
+
|
|
235
|
+
writePacketHeader(leadSeg, packet.cmd, packet.typ, packet.seq);
|
|
236
|
+
|
|
237
|
+
if (Array.isArray(packet.ct)) {
|
|
238
|
+
|
|
239
|
+
let bodyLen = 0;
|
|
240
|
+
|
|
241
|
+
for (const p of packet.ct) {
|
|
242
|
+
|
|
243
|
+
bodyLen += Buffer.byteLength(p);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
leadSeg.writeUInt16LE(bodyLen, CS.HEADER_SIZE);
|
|
247
|
+
|
|
248
|
+
return [leadSeg, ...packet.ct];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
leadSeg.writeUInt16LE(Buffer.byteLength(packet.ct), CS.HEADER_SIZE);
|
|
252
|
+
|
|
253
|
+
return [leadSeg, packet.ct];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const encoders: Record<number, IPacketEncoder> = {
|
|
258
|
+
|
|
259
|
+
[CS.EPacketType.REQUEST * 0x100 + CS.ECommand.API_CALL]: new ApiRequestEncoder(),
|
|
260
|
+
[CS.EPacketType.REQUEST * 0x100 + CS.ECommand.BINARY_CHUNK]: new BinaryChunkRequestEncoder(),
|
|
261
|
+
[CS.EPacketType.REQUEST * 0x100 + CS.ECommand.CLOSE]: new CloseRequestEncoder(),
|
|
262
|
+
[CS.EPacketType.REQUEST * 0x100 + CS.ECommand.PING]: new PingRequestEncoder(),
|
|
263
|
+
[CS.EPacketType.REQUEST * 0x100 + CS.ECommand.PUSH_MESSAGE]: new PushMessageRequestEncoder(),
|
|
264
|
+
|
|
265
|
+
[CS.EPacketType.SUCCESS_RESPONSE * 0x100 + CS.ECommand.API_CALL]: new ApiResponseEncoder(),
|
|
266
|
+
[CS.EPacketType.SUCCESS_RESPONSE * 0x100 + CS.ECommand.BINARY_CHUNK]: new VoidResponseEncoder(),
|
|
267
|
+
[CS.EPacketType.SUCCESS_RESPONSE * 0x100 + CS.ECommand.CLOSE]: new VoidResponseEncoder(),
|
|
268
|
+
[CS.EPacketType.SUCCESS_RESPONSE * 0x100 + CS.ECommand.PING]: new PingResponseEncoder(),
|
|
269
|
+
[CS.EPacketType.SUCCESS_RESPONSE * 0x100 + CS.ECommand.PUSH_MESSAGE]: new VoidResponseEncoder(),
|
|
270
|
+
|
|
271
|
+
[CS.EPacketType.ERROR_RESPONSE * 0x100 + CS.ECommand.API_CALL]: new ErrorResponseEncoder(),
|
|
272
|
+
[CS.EPacketType.ERROR_RESPONSE * 0x100 + CS.ECommand.BINARY_CHUNK]: new ErrorResponseEncoder(),
|
|
273
|
+
[CS.EPacketType.ERROR_RESPONSE * 0x100 + CS.ECommand.CLOSE]: new ErrorResponseEncoder(),
|
|
274
|
+
[CS.EPacketType.ERROR_RESPONSE * 0x100 + CS.ECommand.PING]: new ErrorResponseEncoder(),
|
|
275
|
+
[CS.EPacketType.ERROR_RESPONSE * 0x100 + CS.ECommand.PUSH_MESSAGE]: new ErrorResponseEncoder(),
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export class TvEncoderV2 {
|
|
279
|
+
|
|
280
|
+
public encode(packet: dEnc2.ICommandPacket): Array<Buffer | string> {
|
|
281
|
+
|
|
282
|
+
return encoders[packet.typ * 0x100 + packet.cmd].encode(packet);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type * as CS from './Constants.v2';
|
|
18
|
+
import type { TelevokeError } from '../../Errors';
|
|
19
|
+
|
|
20
|
+
export type IDataChunkArray = Array<string | Buffer>;
|
|
21
|
+
|
|
22
|
+
export type IDataChunkField = string | Buffer | IDataChunkArray;
|
|
23
|
+
|
|
24
|
+
export interface ICommandPacket {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The command of this packet.
|
|
28
|
+
*/
|
|
29
|
+
readonly cmd: CS.ECommand;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The type of this packet.
|
|
33
|
+
*/
|
|
34
|
+
readonly typ: CS.EPacketType;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The sequence number of this packet.
|
|
38
|
+
*/
|
|
39
|
+
readonly seq: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The content of this packet.
|
|
43
|
+
*/
|
|
44
|
+
readonly ct: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface IRequestPacket extends ICommandPacket {
|
|
48
|
+
|
|
49
|
+
readonly typ: CS.EPacketType.REQUEST;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface IErrorResponsePacket extends ICommandPacket {
|
|
53
|
+
|
|
54
|
+
readonly typ: CS.EPacketType.ERROR_RESPONSE;
|
|
55
|
+
|
|
56
|
+
readonly ct: TelevokeError;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ISuccessResponsePacket extends ICommandPacket {
|
|
60
|
+
|
|
61
|
+
readonly typ: CS.EPacketType.SUCCESS_RESPONSE;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface IApiRequestPacket extends IRequestPacket {
|
|
65
|
+
|
|
66
|
+
readonly cmd: CS.ECommand.API_CALL;
|
|
67
|
+
|
|
68
|
+
readonly ct: {
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The name of the API to be invoked.
|
|
72
|
+
*/
|
|
73
|
+
readonly name: string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The arguments of the API to be invoked.
|
|
77
|
+
*/
|
|
78
|
+
readonly body: IDataChunkField;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface IPingRequestPacket extends IRequestPacket {
|
|
83
|
+
|
|
84
|
+
readonly cmd: CS.ECommand.PING;
|
|
85
|
+
|
|
86
|
+
readonly ct: IDataChunkField;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface IPushMessageRequestPacket extends IRequestPacket {
|
|
90
|
+
|
|
91
|
+
readonly cmd: CS.ECommand.PUSH_MESSAGE;
|
|
92
|
+
|
|
93
|
+
readonly ct: IDataChunkField;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface ICloseRequestPacket extends IRequestPacket {
|
|
97
|
+
|
|
98
|
+
readonly cmd: CS.ECommand.CLOSE;
|
|
99
|
+
|
|
100
|
+
readonly ct: null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface IBinaryChunkRequestPacket extends IRequestPacket {
|
|
104
|
+
|
|
105
|
+
readonly cmd: CS.ECommand.BINARY_CHUNK;
|
|
106
|
+
|
|
107
|
+
readonly ct: {
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The stream ID of this chunk should be sent to.
|
|
111
|
+
*/
|
|
112
|
+
readonly streamId: number;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The index of this chunk in the stream.
|
|
116
|
+
*/
|
|
117
|
+
readonly index: number;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The chunk data.
|
|
121
|
+
*/
|
|
122
|
+
readonly body: IDataChunkField;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface IApiResponsePacket extends ISuccessResponsePacket {
|
|
127
|
+
|
|
128
|
+
readonly cmd: CS.ECommand.API_CALL;
|
|
129
|
+
|
|
130
|
+
readonly ct: IDataChunkField;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface IPingResponsePacket extends ISuccessResponsePacket {
|
|
134
|
+
|
|
135
|
+
readonly cmd: CS.ECommand.PING;
|
|
136
|
+
|
|
137
|
+
readonly ct: IDataChunkField;
|
|
138
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export * from './Constants.v2';
|
|
18
|
+
export * from './EncoderV2';
|
|
19
|
+
export * from './DecoderV2';
|
|
20
|
+
export type * from './Encoding.v2.decl';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as Constants from './Constants';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The base class of all Televoke errors.
|
|
21
|
+
*/
|
|
22
|
+
export abstract class TelevokeError extends Error {
|
|
23
|
+
|
|
24
|
+
public constructor(
|
|
25
|
+
name: string,
|
|
26
|
+
message: string,
|
|
27
|
+
public readonly origin: unknown = null
|
|
28
|
+
) {
|
|
29
|
+
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = name;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class ProtocolError extends TelevokeError {
|
|
36
|
+
|
|
37
|
+
public constructor(
|
|
38
|
+
message: string,
|
|
39
|
+
origin: unknown,
|
|
40
|
+
) {
|
|
41
|
+
|
|
42
|
+
super(Constants.PROTOCOL_ERROR_NAMESPACE, message, origin);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function defineProtocolError<T extends string>(name: T): Record<T, new (
|
|
47
|
+
data?: unknown,
|
|
48
|
+
origin?: unknown
|
|
49
|
+
) => ProtocolError> {
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
|
|
53
|
+
[name]: class extends ProtocolError {
|
|
54
|
+
|
|
55
|
+
public constructor(public readonly data: unknown = null, origin: unknown = null) {
|
|
56
|
+
|
|
57
|
+
super(name, origin);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
} as any;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const errorCtors = {
|
|
64
|
+
|
|
65
|
+
...defineProtocolError('incomplete_packet'),
|
|
66
|
+
...defineProtocolError('invalid_packet'),
|
|
67
|
+
...defineProtocolError('invalid_response'),
|
|
68
|
+
...defineProtocolError('channel_inactive'),
|
|
69
|
+
...defineProtocolError('channel_closed'),
|
|
70
|
+
...defineProtocolError('api_not_found'),
|
|
71
|
+
...defineProtocolError('cmd_not_impl'),
|
|
72
|
+
...defineProtocolError('network_error'),
|
|
73
|
+
...defineProtocolError('stream_not_found'),
|
|
74
|
+
...defineProtocolError('stream_aborted'),
|
|
75
|
+
...defineProtocolError('stream_closed'),
|
|
76
|
+
...defineProtocolError('stream_index_mismatch'),
|
|
77
|
+
...defineProtocolError('system_busy'),
|
|
78
|
+
...defineProtocolError('timeout'),
|
|
79
|
+
...defineProtocolError('unknown'),
|
|
80
|
+
|
|
81
|
+
['app_error']: class AppError extends TelevokeError {
|
|
82
|
+
|
|
83
|
+
public constructor(message: string, origin: unknown = null) {
|
|
84
|
+
|
|
85
|
+
super(Constants.APP_ERROR_NAMESPACE, message, origin);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export class TvErrorResponse {
|
|
91
|
+
|
|
92
|
+
public constructor(public readonly data: unknown) {}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const errors: Readonly<typeof errorCtors> = errorCtors as any;
|