diff --git a/package-lock.json b/package-lock.json index ff5dec5b..2b78f9c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dapr/dapr", - "version": "3.3.0", + "version": "3.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@dapr/dapr", - "version": "3.3.0", + "version": "3.3.1", "license": "ISC", "dependencies": { "@grpc/grpc-js": "^1.9.3", diff --git a/package.json b/package.json index b2807e28..0c3b2f10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dapr/dapr", - "version": "3.3.0", + "version": "3.3.1", "description": "The official Dapr (https://dapr.io) SDK for Node.js", "types": "./build/index.d.ts", "scripts": { @@ -8,7 +8,7 @@ "test:load": "jest --runInBand --detectOpenHandles", "test:load:http": "TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol http --app-port 50001 --dapr-http-port 50000 --components-path ./test/components -- npm run test:load 'test/load'", "test:e2e": "jest --runInBand --detectOpenHandles", - "test:e2e:all": "npm run test:e2e:http; npm run test:e2e:grpc; npm run test:e2e:common; npm run test:e2e:workflow", + "test:e2e:all": "npm run test:e2e:http && npm run test:e2e:grpc && npm run test:e2e:common && npm run test:e2e:workflow", "test:e2e:grpc": "npm run test:e2e:grpc:client && npm run test:e2e:grpc:server && npm run test:e2e:grpc:clientWithApiToken", "test:e2e:grpc:client": "npm run prebuild && TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 dapr run --app-id test-suite --app-protocol grpc --app-port 50001 --dapr-grpc-port 50000 --components-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/grpc/*client.test.ts' ]", "test:e2e:grpc:clientWithApiToken": "npm run prebuild && TEST_SECRET_1=secret_val_1 TEST_SECRET_2=secret_val_2 DAPR_API_TOKEN=test dapr run --app-id test-suite --app-protocol grpc --app-port 50001 --dapr-grpc-port 50000 --components-path ./test/components -- jest --runInBand --detectOpenHandles --testMatch [ '**/test/e2e/grpc/clientWithApiToken.test.ts' ]", diff --git a/src/actors/client/ActorClient/ActorClientGRPC.ts b/src/actors/client/ActorClient/ActorClientGRPC.ts index 854b06e2..84e20d9c 100644 --- a/src/actors/client/ActorClient/ActorClientGRPC.ts +++ b/src/actors/client/ActorClient/ActorClientGRPC.ts @@ -11,12 +11,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { Empty } from "google-protobuf/google/protobuf/empty_pb"; import { Any } from "google-protobuf/google/protobuf/any_pb"; import { ExecuteActorStateTransactionRequest, GetActorStateRequest, GetActorStateResponse, + GetMetadataRequest, GetMetadataResponse, InvokeActorRequest, InvokeActorResponse, @@ -279,7 +279,7 @@ export default class ActorClientGRPC implements IClientActor { const client = await this.client.getClient(); return new Promise((resolve, reject) => { - client.getMetadata(new Empty(), (err, res: GetMetadataResponse) => { + client.getMetadata(new GetMetadataRequest(), (err, res: GetMetadataResponse) => { if (err) { return reject(err); } diff --git a/src/implementation/Client/GRPCClient/health.ts b/src/implementation/Client/GRPCClient/health.ts index 3bd9c77f..33096e58 100644 --- a/src/implementation/Client/GRPCClient/health.ts +++ b/src/implementation/Client/GRPCClient/health.ts @@ -13,8 +13,7 @@ limitations under the License. import GRPCClient from "./GRPCClient"; import IClientHealth from "../../../interfaces/Client/IClientHealth"; -import { GetMetadataResponse } from "../../../proto/dapr/proto/runtime/v1/dapr_pb"; -import { Empty } from "google-protobuf/google/protobuf/empty_pb"; +import { GetMetadataRequest, GetMetadataResponse } from "../../../proto/dapr/proto/runtime/v1/dapr_pb"; // https://docs.dapr.io/reference/api/health_api/ export default class GRPCClientHealth implements IClientHealth { @@ -30,7 +29,7 @@ export default class GRPCClientHealth implements IClientHealth { return new Promise((resolve, _reject) => { try { - client.getMetadata(new Empty(), (err, _res: GetMetadataResponse) => { + client.getMetadata(new GetMetadataRequest(), (err, _res: GetMetadataResponse) => { if (err) { return resolve(false); } diff --git a/src/implementation/Client/GRPCClient/metadata.ts b/src/implementation/Client/GRPCClient/metadata.ts index 0920447c..65723cb9 100644 --- a/src/implementation/Client/GRPCClient/metadata.ts +++ b/src/implementation/Client/GRPCClient/metadata.ts @@ -12,7 +12,11 @@ limitations under the License. */ import GRPCClient from "./GRPCClient"; -import { GetMetadataResponse, SetMetadataRequest } from "../../../proto/dapr/proto/runtime/v1/dapr_pb"; +import { + GetMetadataRequest, + GetMetadataResponse, + SetMetadataRequest, +} from "../../../proto/dapr/proto/runtime/v1/dapr_pb"; import { Empty } from "google-protobuf/google/protobuf/empty_pb"; import IClientMetadata from "../../../interfaces/Client/IClientMetadata"; import { GetMetadataResponse as GetMetadataResponseResult } from "../../../types/metadata/GetMetadataResponse"; @@ -30,7 +34,7 @@ export default class GRPCClientMetadata implements IClientMetadata { const client = await this.client.getClient(); return new Promise((resolve, reject) => { - client.getMetadata(new Empty(), (err, res: GetMetadataResponse) => { + client.getMetadata(new GetMetadataRequest(), (err, res: GetMetadataResponse) => { if (err) { return reject(err); } diff --git a/src/implementation/Client/GRPCClient/sidecar.ts b/src/implementation/Client/GRPCClient/sidecar.ts index ffd3d30f..61777df2 100644 --- a/src/implementation/Client/GRPCClient/sidecar.ts +++ b/src/implementation/Client/GRPCClient/sidecar.ts @@ -13,7 +13,7 @@ limitations under the License. import GRPCClient from "./GRPCClient"; import IClientSidecar from "../../../interfaces/Client/IClientSidecar"; -import { GetMetadataResponse } from "../../../proto/dapr/proto/runtime/v1/dapr_pb"; +import { GetMetadataRequest, GetMetadataResponse, ShutdownRequest } from "../../../proto/dapr/proto/runtime/v1/dapr_pb"; import { Empty } from "google-protobuf/google/protobuf/empty_pb"; // https://docs.dapr.io/reference/api/secrets_api/ @@ -28,7 +28,7 @@ export default class GRPCClientSidecar implements IClientSidecar { const client = await this.client.getClient(); return new Promise((resolve, reject) => { - client.shutdown(new Empty(), (err, _res: Empty) => { + client.shutdown(new ShutdownRequest(), (err, _res: Empty) => { if (err) { return reject(err); } @@ -43,7 +43,7 @@ export default class GRPCClientSidecar implements IClientSidecar { return new Promise((resolve, _reject) => { try { - callClient.getMetadata(new Empty(), (err, _res: GetMetadataResponse) => { + callClient.getMetadata(new GetMetadataRequest(), (err, _res: GetMetadataResponse) => { if (err) { return resolve(false); } diff --git a/test/e2e/grpc/client.test.ts b/test/e2e/grpc/client.test.ts index c5eb7ae7..842b733e 100644 --- a/test/e2e/grpc/client.test.ts +++ b/test/e2e/grpc/client.test.ts @@ -20,8 +20,8 @@ import { CommunicationProtocolEnum, DaprClient, LogLevel } from "../../../src"; import { SubscribeConfigurationResponse } from "../../../src/types/configuration/SubscribeConfigurationResponse"; import * as DockerUtils from "../../utils/DockerUtil"; import { DaprClient as DaprClientGrpc } from "../../../src/proto/dapr/proto/runtime/v1/dapr_grpc_pb"; -import { Empty } from "google-protobuf/google/protobuf/empty_pb"; import { NextCall } from "@grpc/grpc-js/build/src/client-interceptors"; +import { GetMetadataRequest } from "../../../src/proto/dapr/proto/runtime/v1/dapr_pb"; const daprHost = "localhost"; const daprPort = "50000"; // Dapr Sidecar Port of this Example Server @@ -76,7 +76,7 @@ describe("grpc/client", () => { interceptors: [mockInterceptor], }); - await new Promise((resolve) => clientProxy.getMetadata(new Empty(), resolve)); + await new Promise((resolve) => clientProxy.getMetadata(new GetMetadataRequest(), resolve)); expect(mockInterceptor.mock.calls.length).toBe(1); expect(mockMetadataRes.get("dapr-app-id")[0]).toBe("test-suite"); @@ -104,7 +104,7 @@ describe("grpc/client", () => { interceptors: [mockInterceptor], }); - await new Promise((resolve) => clientProxy.getMetadata(new Empty(), resolve)); + await new Promise((resolve) => clientProxy.getMetadata(new GetMetadataRequest(), resolve)); expect(mockInterceptor.mock.calls.length).toBe(1); expect(mockMetadataRes.get("dapr-app-id")[0]).toBe(process.env.APP_ID); @@ -362,13 +362,13 @@ describe("grpc/client", () => { expect(config.items["myconfigkey3"].value == "key3_initialvalue"); }); - it("should be able to get the configuration items with metadata", async () => { - const conf = await client.configuration.get("config-redis", ["myconfigkey1"], { - hello: "world", - }); - - expect(conf.items["myconfigkey1"].metadata).toHaveProperty("hello"); - }); + // todo: enable this once we have a component to test this with. + // Redis does not support metadata, PG and Azure App Config do. + // it("should be able to get the configuration items with metadata", async () => { + // const conf = await client.configuration.get("config-redis", ["myconfigkey1"], { + // hello: "world", + // }); + // }); it("should be able to subscribe to configuration item changes on all keys", async () => { const m = jest.fn(async (_res: SubscribeConfigurationResponse) => { diff --git a/test/e2e/grpc/clientWithApiToken.test.ts b/test/e2e/grpc/clientWithApiToken.test.ts index 2747a571..eac82765 100644 --- a/test/e2e/grpc/clientWithApiToken.test.ts +++ b/test/e2e/grpc/clientWithApiToken.test.ts @@ -14,8 +14,8 @@ limitations under the License. import * as grpc from "@grpc/grpc-js"; import { CommunicationProtocolEnum, DaprClient, LogLevel } from "../../../src"; import { DaprClient as DaprClientGrpc } from "../../../src/proto/dapr/proto/runtime/v1/dapr_grpc_pb"; -import { Empty } from "google-protobuf/google/protobuf/empty_pb"; import { NextCall } from "@grpc/grpc-js/build/src/client-interceptors"; +import { GetMetadataRequest } from "../../../src/proto/dapr/proto/runtime/v1/dapr_pb"; const daprHost = "localhost"; const daprPort = "50000"; // Dapr Sidecar Port of this Example Server @@ -50,7 +50,7 @@ describe("grpc/client with api token", () => { interceptors: [mockInterceptor], }); - await new Promise((resolve) => clientProxy.getMetadata(new Empty(), resolve)); + await new Promise((resolve) => clientProxy.getMetadata(new GetMetadataRequest(), resolve)); expect(mockMetadataRes.get("dapr-api-token")[0]).toBe("test"); }); });