From 9f0803b9c7d165ba19aff22934bc930a23eb1640 Mon Sep 17 00:00:00 2001 From: Aditya <38064122+bettercallav@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:08:02 +1000 Subject: [PATCH 1/6] fix: meta changed to pojo --- src/types.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/types.ts b/src/types.ts index 4cb941e..4ef00d7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -200,11 +200,8 @@ type ContainerType = Record; * mainly used as the return type for the `StreamFactory`. But the interface * can be propagated across the RPC system. */ -interface RPCStream< - R, - W, - M extends Record = Record, -> extends ReadableWritablePair { +interface RPCStream + extends ReadableWritablePair { cancel: (reason?: any) => void; meta?: M; } From 0245772e7ec0f9e7375b95c11def6acf0273efdd Mon Sep 17 00:00:00 2001 From: Aditya <38064122+bettercallav@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:08:15 +1000 Subject: [PATCH 2/6] 0.1.3 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8218031..3cc669a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@matrixai/rpc", - "version": "0.1.2", + "version": "0.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@matrixai/rpc", - "version": "0.1.2", + "version": "0.1.3", "license": "Apache-2.0", "dependencies": { "@matrixai/async-init": "^1.9.4", diff --git a/package.json b/package.json index e34b1b4..760aec1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matrixai/rpc", - "version": "0.1.2", + "version": "0.1.3", "author": "Matrix AI", "contributors": [ { From fabeb5f7137857dddea84c7a7afbd734a8a17b33 Mon Sep 17 00:00:00 2001 From: Aditya <38064122+bettercallav@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:17:57 +1000 Subject: [PATCH 3/6] 0.1.4 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3cc669a..90289b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@matrixai/rpc", - "version": "0.1.3", + "version": "0.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@matrixai/rpc", - "version": "0.1.3", + "version": "0.1.4", "license": "Apache-2.0", "dependencies": { "@matrixai/async-init": "^1.9.4", diff --git a/package.json b/package.json index 760aec1..0d8467e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matrixai/rpc", - "version": "0.1.3", + "version": "0.1.4", "author": "Matrix AI", "contributors": [ { From 57bc63f0560ab3ad1bc3a7828cf75c19aace71ce Mon Sep 17 00:00:00 2001 From: Aditya <38064122+bettercallav@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:38:39 +1000 Subject: [PATCH 4/6] fix: change method signature of handlers --- src/handlers/ClientHandler.ts | 4 ++-- src/handlers/RawHandler.ts | 11 +++++++---- src/handlers/UnaryHandler.ts | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/handlers/ClientHandler.ts b/src/handlers/ClientHandler.ts index 0aea354..6a3c93f 100644 --- a/src/handlers/ClientHandler.ts +++ b/src/handlers/ClientHandler.ts @@ -8,12 +8,12 @@ abstract class ClientHandler< Input extends JSONValue = JSONValue, Output extends JSONValue = JSONValue, > extends Handler { - public handle = async ( + public handle = async function* ( input: AsyncIterableIterator, cancel: (reason?: any) => void, meta: Record | undefined, ctx: ContextTimed, - ): Promise => { + ): AsyncIterableIterator { throw new ErrorRPCMethodNotImplemented(); }; } diff --git a/src/handlers/RawHandler.ts b/src/handlers/RawHandler.ts index 01fd1d7..629b9f1 100644 --- a/src/handlers/RawHandler.ts +++ b/src/handlers/RawHandler.ts @@ -6,13 +6,16 @@ import { ErrorRPCMethodNotImplemented } from '../errors'; abstract class RawHandler< Container extends ContainerType = ContainerType, + Input extends JSONValue = JSONValue, // Define Input type if needed + Output extends JSONValue = JSONValue // Define Output type if needed > extends Handler { - public handle = async ( - input: [JSONRPCRequest, ReadableStream], + public handle = async function* ( + input: AsyncIterableIterator, // Change this based on your specific needs cancel: (reason?: any) => void, meta: Record | undefined, - ctx: ContextTimed, - ): Promise<[JSONValue, ReadableStream]> => { + ctx: ContextTimed + ): AsyncIterableIterator { + // Change return type to AsyncIterableIterator throw new ErrorRPCMethodNotImplemented('This method must be overridden'); }; } diff --git a/src/handlers/UnaryHandler.ts b/src/handlers/UnaryHandler.ts index 0a1e37b..22ee1e2 100644 --- a/src/handlers/UnaryHandler.ts +++ b/src/handlers/UnaryHandler.ts @@ -8,12 +8,12 @@ abstract class UnaryHandler< Input extends JSONValue = JSONValue, Output extends JSONValue = JSONValue, > extends Handler { - public handle = async ( + public handle = async function* ( input: Input, cancel: (reason?: any) => void, meta: Record | undefined, ctx: ContextTimed, - ): Promise => { + ): AsyncIterableIterator { throw new ErrorRPCMethodNotImplemented('This method must be overridden'); }; } From 1f53261ec4f0690c42ea8bfb3c17598d0323058f Mon Sep 17 00:00:00 2001 From: Aditya <38064122+bettercallav@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:39:28 +1000 Subject: [PATCH 5/6] fix: change method signature of handlers --- src/handlers/RawHandler.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/handlers/RawHandler.ts b/src/handlers/RawHandler.ts index 629b9f1..500ce99 100644 --- a/src/handlers/RawHandler.ts +++ b/src/handlers/RawHandler.ts @@ -6,14 +6,14 @@ import { ErrorRPCMethodNotImplemented } from '../errors'; abstract class RawHandler< Container extends ContainerType = ContainerType, - Input extends JSONValue = JSONValue, // Define Input type if needed - Output extends JSONValue = JSONValue // Define Output type if needed + Input extends JSONValue = JSONValue, // Define Input type if needed + Output extends JSONValue = JSONValue, // Define Output type if needed > extends Handler { public handle = async function* ( input: AsyncIterableIterator, // Change this based on your specific needs cancel: (reason?: any) => void, meta: Record | undefined, - ctx: ContextTimed + ctx: ContextTimed, ): AsyncIterableIterator { // Change return type to AsyncIterableIterator throw new ErrorRPCMethodNotImplemented('This method must be overridden'); From beafe242484f781b962735809cbcff5c8aefff66 Mon Sep 17 00:00:00 2001 From: Aditya <38064122+bettercallav@users.noreply.github.com> Date: Wed, 27 Sep 2023 15:39:32 +1000 Subject: [PATCH 6/6] 0.1.5 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 90289b8..2e87d4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@matrixai/rpc", - "version": "0.1.4", + "version": "0.1.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@matrixai/rpc", - "version": "0.1.4", + "version": "0.1.5", "license": "Apache-2.0", "dependencies": { "@matrixai/async-init": "^1.9.4", diff --git a/package.json b/package.json index 0d8467e..c63d3c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matrixai/rpc", - "version": "0.1.4", + "version": "0.1.5", "author": "Matrix AI", "contributors": [ {