-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
syntax = "proto3"; | ||
package decentraland.quests; | ||
|
||
import "google/protobuf/empty.proto"; | ||
|
||
// Errors | ||
message InvalidQuest {} | ||
|
||
message NotUUID {} | ||
|
||
message InternalServerError {} | ||
|
||
message NotFoundQuestInstance {} | ||
|
||
message QuestAlreadyStarted {} | ||
|
||
message NotOwner {} | ||
|
||
message IgnoredEvent {} | ||
|
||
message StartQuestRequest { | ||
string quest_id = 1; | ||
} | ||
|
||
message StartQuestResponse { | ||
/* There are a few valid reasons to not be accepted: | ||
* - Quest is not found | ||
* - Quest is deactivated (the owner deleted it) | ||
* - User already started the quest | ||
* - Internal errors (DB connection failed or something like that) */ | ||
message Accepted {} | ||
oneof response { | ||
Accepted accepted = 1; | ||
InvalidQuest invalid_quest = 2; | ||
NotUUID not_uuid_error = 3; | ||
InternalServerError internal_server_error = 4; | ||
QuestAlreadyStarted quest_already_started = 5; | ||
} | ||
} | ||
|
||
message AbortQuestRequest { | ||
string quest_instance_id = 1; | ||
} | ||
|
||
message AbortQuestResponse { | ||
/* There are a few valid reasons to not be accepted: | ||
* - Quest instance is not found | ||
* - Quest instance is from another user | ||
* - Quest instance already aborted | ||
* - Internal errors (DB connection failed or something like that) */ | ||
message Accepted {} | ||
oneof response { | ||
Accepted accepted = 1; | ||
NotFoundQuestInstance not_found_quest_instance = 2; | ||
NotUUID not_uuid_error = 3; | ||
NotOwner not_owner = 4; | ||
InternalServerError internal_server_error = 5; | ||
} | ||
} | ||
|
||
message Event { | ||
string id = 1; | ||
string address = 2; | ||
Action action = 3; | ||
} | ||
|
||
message EventRequest { | ||
Action action = 1; | ||
} | ||
|
||
message EventResponse { | ||
oneof response { | ||
string accepted_event_id = 1; | ||
IgnoredEvent ignored_event = 2; | ||
InternalServerError internal_server_error = 3; | ||
} | ||
} | ||
|
||
message QuestDefinition { | ||
repeated Step steps = 1; | ||
repeated Connection connections = 2; | ||
} | ||
|
||
message Connection { | ||
string step_from = 1; | ||
string step_to = 2; | ||
} | ||
|
||
message Step { | ||
string id = 1; | ||
string description = 2; | ||
repeated Task tasks = 3; | ||
} | ||
|
||
message Action { | ||
string type = 1; | ||
map<string, string> parameters = 2; | ||
} | ||
|
||
message Task { | ||
string id = 1; | ||
string description = 2; | ||
repeated Action action_items = 3; | ||
} | ||
|
||
message StepContent { | ||
repeated Task to_dos = 1; | ||
repeated Task tasks_completed = 2; | ||
} | ||
|
||
message QuestState { | ||
map<string, StepContent> current_steps = 2; | ||
fixed32 steps_left = 3; | ||
repeated string steps_completed = 4; | ||
repeated string required_steps = 5; | ||
} | ||
|
||
message Quest { | ||
string id = 1; | ||
string name = 2; | ||
string description = 3; | ||
QuestDefinition definition = 4; | ||
string creator_address = 5; | ||
string image_url = 6; | ||
bool active = 7; | ||
fixed32 created_at = 8; | ||
} | ||
|
||
message QuestInstance { | ||
string id = 1; | ||
Quest quest = 2; | ||
QuestState state = 3; | ||
} | ||
|
||
message QuestStateUpdate { | ||
string instance_id = 1; | ||
QuestState quest_state = 2; | ||
string event_id = 3; | ||
} | ||
|
||
message UserUpdate { | ||
oneof message { | ||
bool subscribed = 1; | ||
QuestStateUpdate quest_state_update = 2; | ||
QuestInstance new_quest_started = 3; | ||
string event_ignored = 4; | ||
} | ||
string user_address = 5; | ||
} | ||
|
||
message Quests { | ||
repeated QuestInstance instances = 1; | ||
} | ||
|
||
message GetAllQuestsResponse { | ||
oneof response { | ||
Quests quests = 1; | ||
InternalServerError internal_server_error = 2; | ||
} | ||
} | ||
|
||
message GetQuestDefinitionRequest { | ||
string quest_id = 1; | ||
} | ||
|
||
message GetQuestDefinitionResponse { | ||
oneof response { | ||
Quest quest = 1; | ||
InternalServerError internal_server_error = 2; | ||
} | ||
} | ||
|
||
service QuestsService { | ||
// User actions | ||
rpc StartQuest(StartQuestRequest) returns (StartQuestResponse) {} | ||
rpc AbortQuest(AbortQuestRequest) returns (AbortQuestResponse) {} | ||
rpc SendEvent(EventRequest) returns (EventResponse) {} | ||
|
||
// Listen to changes in quest states and event processing updates | ||
rpc Subscribe(google.protobuf.Empty) returns (stream UserUpdate) {} | ||
|
||
// Query quest information | ||
rpc GetAllQuests(google.protobuf.Empty) returns (GetAllQuestsResponse) {} | ||
rpc GetQuestDefinition(GetQuestDefinitionRequest) returns (GetQuestDefinitionResponse) {} | ||
} |