Skip to content

Commit

Permalink
fix: handle root enums correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Dec 15, 2020
1 parent 2ebc680 commit c765e3c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1583,19 +1583,25 @@ function processProtoDescriptor(
) {
const statements = [];


// Process enums
for (const enumDescriptor of descriptor.getEnumTypeList()) {
statements.push(createEnum(enumDescriptor));
}


// Process messages
if (descriptor.getMessageTypeList) {
for (messageDescriptor of descriptor.getMessageTypeList()) {
statements.push(
...processMessageDescriptor(
rootDescriptor,
messageDescriptor,
pbIdentifier,
getNamedImport
)
);
}
for (messageDescriptor of descriptor.getMessageTypeList()) {
statements.push(
...processMessageDescriptor(
rootDescriptor,
messageDescriptor,
pbIdentifier,
getNamedImport
)
);
}


return statements;
}
Expand Down
57 changes: 57 additions & 0 deletions test/protos/complex.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// taken from https://github.com/spica-engine/spica/blob/master/stacks/api/function/queue/proto/event.proto
syntax = "proto3";

package event;

message SchedulingContext {
repeated Env env = 2;
int32 timeout = 3;
Batch batch = 4;
message Env {
string key = 1;
string value = 2;
}

message Batch {
uint64 limit = 1;
uint64 deadline = 2;
}
}

message Target {
string id = 1;
string cwd = 2;
string handler = 3;
SchedulingContext context = 4;
}

enum Type {
HTTP = 0;
DATABASE = 1;
SCHEDULE = 3;
FIREHOSE = 4;
SYSTEM = 5;
BUCKET = 6;
}

message Event {
string id = 1;
Type type = 2;
Target target = 3;
}

message Pop {
string id = 1;
}

message Complete {
string id = 1;
message Result {}
}



service Queue {
rpc pop(Pop) returns (Event);
rpc complete(Complete) returns (Complete.Result);
}

0 comments on commit c765e3c

Please sign in to comment.