Skip to content

Commit

Permalink
Merge pull request #12 from spluxx/v0.3.1
Browse files Browse the repository at this point in the history
V0.3.1
  • Loading branch information
Inchan Hwang authored Apr 20, 2020
2 parents ed61474 + cb92f82 commit 2f321f4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ A [Postman](https://www.postman.com/)-like API client for [protobuf](https://dev

### Mac

[Protoman-0.3.0.dmg](https://github.com/spluxx/Protoman/releases/download/v0.3.0/Protoman-0.3.0.dmg)
[Protoman-0.3.1.dmg](https://github.com/spluxx/Protoman/releases/download/v0.3.1/Protoman-0.3.1.dmg)

### Windows

[Protoman Setup 0.3.0.exe](https://github.com/spluxx/Protoman/releases/download/v0.3.0/Protoman.Setup.0.3.0.exe) - Unlike mac, I don't currently own a license to sign the app. So it might give you some security warnings!
[Protoman Setup 0.3.1.exe](https://github.com/spluxx/Protoman/releases/download/v0.3.1/Protoman.Setup.0.3.1.exe) - Unlike mac, I don't currently own a license to sign the app. So it might give you some security warnings!

### Linux

[Protoman-0.3.0.AppImage](https://github.com/spluxx/Protoman/releases/download/v0.3.0/Protoman-0.3.0.AppImage)
[Protoman-0.3.1.AppImage](https://github.com/spluxx/Protoman/releases/download/v0.3.1/Protoman-0.3.1.AppImage)

As a fallback, you can clone the repo and run npm install && npm run build to build, and npm run start to launch the app. Or, you can actually find configurations on [electron builder](https://www.electron.build/) to get the right distribution version yourself!

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Protoman",
"version": "0.3.0",
"version": "0.3.1",
"description": "Basic Postman clone with protobuf functionalities",
"author": "Inchan Hwang, Louis Lee",
"license": "MIT",
Expand Down
28 changes: 15 additions & 13 deletions src/core/protobuf/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ export function createMessageValue(messageProto: ProtobufType, messageJson: Prot
switch (messageProto.tag) {
case 'message':
const messageType = messageProto as MessageType;
assertType(messageJson, ['object']);
return handleMessage(messageType, messageJson as JsonObject, ctx);
const obj = messageJson ?? {};
assertType(obj, ['object']);
return handleMessage(messageType, obj as JsonObject, ctx);
case 'primitive':
const primitiveType = messageProto as PrimitiveType;
assertType(messageJson, ['string', 'number', 'boolean']);
return handlePrimitive(primitiveType, messageJson as string | number | boolean);
const prim = messageJson ?? primitiveType.defaultValue;
assertType(prim, ['string', 'number', 'boolean']);
return handlePrimitive(primitiveType, prim as string | number | boolean);
case 'enum':
const enumType = messageProto as EnumType;
assertType(messageJson, ['number']);
return handleEnum(enumType, messageJson as number);
const e = messageJson ?? 0;
assertType(e, ['number']);
return handleEnum(enumType, e as number);
}
}

Expand Down Expand Up @@ -68,11 +71,9 @@ function handleMessage(messageType: MessageType, messageJson: JsonObject, ctx: P
});

const repeatedFields = messageType.repeatedFields.map(([fieldName, typeName]): [string, ProtobufValue[]] => {
assertType(messageJson[fieldName], ['array']);
return [
fieldName,
(messageJson[fieldName] as JsonArray).map(value => createMessageValue(typeNameToType(typeName, ctx), value, ctx)),
];
const arr = messageJson[fieldName] ?? [];
assertType(arr, ['array']);
return [fieldName, (arr as JsonArray).map(value => createMessageValue(typeNameToType(typeName, ctx), value, ctx))];
});

const oneOfFields = messageType.oneOfFields
Expand All @@ -93,8 +94,9 @@ function handleMessage(messageType: MessageType, messageJson: JsonObject, ctx: P
.filter(a => !!a);

const mapFields = messageType.mapFields.map(([fieldName, [valueTypeName]]): [string, [string, ProtobufValue][]] => {
assertType(messageJson[fieldName], ['object']);
const entries: [string, ProtoJson][] = Object.entries(messageJson[fieldName]);
const obj = messageJson[fieldName] ?? {};
assertType(obj, ['object']);
const entries: [string, ProtoJson][] = Object.entries(obj);
const temp: [string, ProtobufValue][] = entries.map(([key, value]) => {
const valueType: ProtobufType = typeNameToType(valueTypeName, ctx);
return [key, createMessageValue(valueType, value, ctx)];
Expand Down
4 changes: 1 addition & 3 deletions src/renderer/components/Flow/body/MessageValueView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ const OneOfFieldView: FunctionComponent<OFVProps> = ({
<Block>
<FieldName>{fieldName}</FieldName>
<span>: </span>
{editable ? (
{editable && (
<Select
value={name}
size="small"
Expand All @@ -295,8 +295,6 @@ const OneOfFieldView: FunctionComponent<OFVProps> = ({
</Select.Option>
))}
</Select>
) : (
<span>{`${name} (${value.type.name})`}</span>
)}
<IndentationBlock>
<SingleFieldView editable={editable} fieldName={name} value={value} handlers={prefix(name, handlers)} />
Expand Down

0 comments on commit 2f321f4

Please sign in to comment.