Releases: tatethurston/TwirpScript
v0.0.61
What's Changed
- Fix JSON deserialization. #181 introduced a regression that caused TwirpScript servers' JSON serialization to fail.
- Distribute strict ESM. A CommonJS is runtime is included for legacy node clients. Code generation uses ESM and requires Node.js v14 or later. If you're using a compiler other than TypeScript such as
webpack
, please see [these instructions].(https://github.com/tatethurston/TwirpScript#webpack-setup) - Use ProtoScript code generation. This will result in some generated imports coming from
protoscript
instead oftwirpscript
, but this is a non breaking change. These imports were previously delegated to ProtoScript via reexports inside TwirpScript, and that indirection has now been removed.
Full Changelog: v0.0.60...v0.0.61
v0.0.60
What's Changed
- Removes
@types/node
dependency.@types/node
is no longer necessary when using a TwirpScript generated client.
Full Changelog: v0.0.59...v0.0.60
v0.0.59
What's Changed
- Fixes generated JSON client when using nested messages. The generated JSON serialization names were invalid for nested messages. See #176 for more context.
Full Changelog: v0.0.58...v0.0.59
v0.0.58
What's Changed
This release brings better insight into errors thrown inside service handlers or middleware. TwirpScript catches any errors thrown internally. Errors that aren't created with the TwirpError
constructor are caught and replaced with a generic Twirp internal_error
for security so that internal details don't leak to end users. This can hurt the developer experience when trying to identify issues during development, and also can hide important debugging information when relying on error reporting using hooks
.
TwirpScript now includes the thrown error as an error
property in the TwirpError
that is passed to the error hook, but continues not to leak any information in the user facing response.
Example:
If we have code that does the following in service or middleware code:
throw new Error("uh oh.");
The error hook will be invoked with:
TwirpError {
code: 'internal',
msg: 'server error',
meta: {
// this is new, and is kept private to the error hook and not exposed to end users
error: Error("uh oh")
}
}
And the response will be:
TwirpError {
code: 'internal',
msg: 'server error',
// note the error from above is missing, it is not exposed to end users
meta: undefined,
}
As before, any errors that should be surfaced to end users should be created by throwing TwirpError
:
throw new TwirpError({ code: "code", msg: "msg" });
Full Changelog: v0.0.57...v0.0.58
v0.0.57
What's Changed
- Generated
.pb
files now opt out of eslint viaeslint-disable
comments - TwirpScript now uses ProtoScript as the serialization runtime instead of
google-protobuf
. ProtoScript's runtime is 37KB (7.2KB gzipped) compared to google-protobuf's 231KB (46KB gzipped).
Full Changelog: v0.0.56...v0.0.57
v0.0.56
What's Changed
Users will need to yarn twirpscript
to regenerate their .pb.ts
/ .pb.js
files when adopting this version.
- The generated message serializer/deserializer objects have been split into two separate objects: one for JSON and one for Protobuf. This enables smaller client bundles when using a bundler that supports tree shaking / dead code elimination. Many users will be unaffected by this change, but this is a breaking change for users that use message encode/decode methods directly in their source code.
Previously this proto
:
// A Hat is a piece of headwear made by a Haberdasher.
message Hat {
int32 inches = 1;
// anything but "invisible"
string color = 2;
// i.e. "bowler"
string name = 3;
}
would generate an object like this in the generated pb.ts
or pb.js
file:
export const Hat = {
encode: ...
decode: ...
encodeJSON: ...
decodeJSON: ...
}
now two objects are generated, one for Protobuf and one for JSON (with a JSON
suffix appended to the message name):
export const Hat = {
encode: ...
decode: ...
}
export const HatJSON = {
encode: ...
decode: ...
}
-
TwirpScript client code is now isomorphic: Node.js clients no longer require extra configuration (using the
client
rpcTransport
attribute). TwirpScript now uses Node's conditional exports internally.import { client } from "twirpscript"; -import { nodeHttpTransport } from "twirpscript/node"; import { MakeHat } from "../protos/haberdasher.pb"; client.baseURL = "http://localhost:8080"; -// This is provided as a convenience for Node.js clients. If you provide `fetch` globally, this isn't necessary and your client can look identical to the browser client above. -client.rpcTransport = nodeHttpTransport; const hat = await MakeHat({ inches: 12 }); console.log(hat);
Full Changelog: v0.0.55...v0.0.56
v0.0.55
What's Changed
- Protobuf messages now always pack packable repeated fields when serializing and can read packed or unpacked when deserializing. This will slightly decrease the size of some protobuf messages over the wire, and enable better interop with messages encoded by other protobuf serializers.
Full Changelog: v0.0.54...v0.0.55
v0.0.54
What's Changed
- Fixes a regression introduced in v0.0.53 that caused JSON.parse to be invoked twice for JSON clients.
- Fixes a message deserialization bug when processing
optional
fields of typemessage
where the default message value was always being supplied. This has been fixed. Now if the server omits or supplies anoptional
field with a null/nil/undefined value TwirpScript clients will receiveundefined
when reading the field.
Full Changelog: v0.0.53...v0.0.54
v0.0.53
What's Changed
- client JSON request methods now use
encodeJSON
anddecodeJSON
helpers. This ensures correct behavior when communicating with other Twirp backend implementations #163
Full Changelog: v0.0.52...v0.0.53
v0.0.52
What's Changed
- Fixes a regression where nested types were not consumable:
[tsserver 2702] [E] 'Foo' only refers to a type, but is being used as a namespace here.
- Removes
dist
from public import paths. This impacts users that importtwirpscript/dist/node
and users that make direct invocations of the compiler instead of usingnpx twirpscript
, likebuf
users. The following changes are necessary for those users to migrate:// some node client -import { nodeHttpTransport } from "twirpscript/dist/node"; +import { nodeHttpTransport } from "twirpscript/node";
// buf.gen.yaml -path: ./node_modules/twirpscript/dist/compiler.js +path: ./node_modules/twirpscript/compiler.js
Full Changelog: v0.0.51...v0.0.52