Skip to content

Commit

Permalink
Release 0.1.0 (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Jul 29, 2022
1 parent 72174e1 commit 6eeb81a
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 42 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TMP = .tmp
BIN = .tmp/bin
BUILD = .tmp/build
GEN = .tmp/gen
CROSSTEST_VERSION := e982fb10e5f9c3e74061b50716317003e3e736b3
CROSSTEST_VERSION := 4f4e96d8fea3ed9473b90a964a5ba429e7ea5649
LICENSE_HEADER_YEAR_RANGE := 2021-2022
LICENSE_HEADER_IGNORES := .tmp\/ node_module\/ packages\/connect-web-bench\/src\/gen\/ packages\/connect-web\/dist\/ scripts\/ packages\/connect-web-test\/src\/gen
NODE18_VERSION ?= v18.2.0
Expand Down Expand Up @@ -142,7 +142,6 @@ setversion: ## Set a new version in for the project, i.e. make setversion SET_VE
release: all ## Release @bufbuild/connect-web
@[ -z "$(shell git status --short)" ] || (echo "Uncommitted changes found." && exit 1);
npm publish \
--access restricted \
--workspace packages/connect-web \
--workspace packages/protoc-gen-connect-web

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/connect-web-bench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"clean": "rm -rf README.md src/gen"
},
"dependencies": {
"@bufbuild/connect-web": "0.0.10",
"@bufbuild/connect-web": "0.1.0",
"@bufbuild/protobuf": "0.0.10",
"@bufbuild/protoc-gen-es": "0.0.10",
"esbuild": "^0.14.50",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/connect-web-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bufbuild/connect-web-test",
"version": "0.0.10",
"version": "0.1.0",
"private": true,
"scripts": {
"clean": "rm -rf ./dist/esm/*",
Expand All @@ -16,7 +16,7 @@
"default": "./dist/esm/index.js"
},
"dependencies": {
"@bufbuild/connect-web": "0.0.10",
"@bufbuild/connect-web": "0.1.0",
"@grpc/grpc-js": "^1.6.7",
"@types/jasmine": "^4.0.3",
"@types/long": "^4.0.2",
Expand Down
37 changes: 16 additions & 21 deletions packages/connect-web-test/src/connect-error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ import {
connectErrorFromJson,
connectErrorFromReason,
} from "@bufbuild/connect-web";
import { Any, TypeRegistry, Struct, BoolValue, protoBase64 } from "@bufbuild/protobuf";
import {
Any,
TypeRegistry,
Struct,
BoolValue,
protoBase64,
} from "@bufbuild/protobuf";
import { ErrorDetail } from "./gen/grpc/testing/messages_pb.js";

describe("ConnectError", () => {
Expand Down Expand Up @@ -164,39 +170,28 @@ describe("connectErrorFromJson()", () => {
})
).toThrowError("[internal] cannot decode ConnectError from JSON: object");
});
it("ignores old protocol version details", () => {
const json = {
code: "permission_denied",
message: "Not permitted",
details: [
{
reason: "soirée 🎉",
domain: "example.com",
"@type": "type.googleapis.com/grpc.testing.ErrorDetail",
},
],
};
const error = connectErrorFromJson(json);
expect(error.details.length).toBe(0);
});
describe("with details", () => {
const json = {
code: "permission_denied",
message: "Not permitted",
details: [
{
type: "grpc.testing.ErrorDetail",
value: protoBase64.enc(new ErrorDetail({
reason: "soirée 🎉",
domain: "example.com",
}).toBinary()),
value: protoBase64.enc(
new ErrorDetail({
reason: "soirée 🎉",
domain: "example.com",
}).toBinary()
),
},
],
};
it("adds to raw detail", () => {
const error = connectErrorFromJson(json);
expect(error.details.length).toBe(1);
expect(error.details[0]?.typeUrl).toBe("type.googleapis.com/grpc.testing.ErrorDetail");
expect(error.details[0]?.typeUrl).toBe(
"type.googleapis.com/grpc.testing.ErrorDetail"
);
});
it("works with connectErrorDetails()", () => {
const error = connectErrorFromJson(json);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/connect-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bufbuild/connect-web",
"version": "0.0.10",
"version": "0.1.0",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand Down
10 changes: 8 additions & 2 deletions packages/connect-web/src/connect-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
MessageType,
proto3,
protoBase64,
TypeRegistry
TypeRegistry,
} from "@bufbuild/protobuf";

/**
Expand Down Expand Up @@ -167,7 +167,13 @@ export function connectErrorFromJson(
const error = new ConnectError(message ?? "", code, undefined, metadata);
if ("details" in jsonValue && Array.isArray(jsonValue.details)) {
for (const detail of jsonValue.details) {
if (detail === null || typeof detail != "object" || Array.isArray(detail) || typeof detail.type != "string" || typeof detail.value != "string") {
if (
detail === null ||
typeof detail != "object" ||
Array.isArray(detail) ||
typeof detail.type != "string" ||
typeof detail.value != "string"
) {
throw newParseError(detail, `.details`);
}
try {
Expand Down
5 changes: 4 additions & 1 deletion packages/connect-web/src/connect-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ function endStreamFromJson(data: Uint8Array): EndStreamResponse {
}
}
}
const error = "error" in jsonValue ? connectErrorFromJson(jsonValue.error, metadata) : undefined;
const error =
"error" in jsonValue
? connectErrorFromJson(jsonValue.error, metadata)
: undefined;
return { metadata, error };
}
4 changes: 2 additions & 2 deletions packages/protoc-gen-connect-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bufbuild/protoc-gen-connect-web",
"version": "0.0.10",
"version": "0.1.0",
"description": "Code generator for connect-web",
"license": "Apache-2.0",
"repository": {
Expand All @@ -23,7 +23,7 @@
"@bufbuild/protoplugin": "0.0.10"
},
"peerDependencies": {
"@bufbuild/connect-web": "0.0.10",
"@bufbuild/connect-web": "0.1.0",
"@bufbuild/protoc-gen-es": "0.0.10"
},
"peerDependenciesMeta": {
Expand Down

0 comments on commit 6eeb81a

Please sign in to comment.