mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 19:39:11 +00:00
feat(rpc): add rpcs
This commit is contained in:
parent
cdafaa90db
commit
f31b32c54a
15 changed files with 516 additions and 0 deletions
29
src/rpc/auth/BUILD.bazel
Normal file
29
src/rpc/auth/BUILD.bazel
Normal file
|
@ -0,0 +1,29 @@
|
|||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
load("@rules_typescript_proto//:index.bzl", "typescript_proto_library")
|
||||
|
||||
proto_library(
|
||||
name = "auth_proto",
|
||||
srcs = ["shared.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
name = "auth_go_proto",
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/auth",
|
||||
proto = ":auth_proto",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "auth",
|
||||
embed = [":auth_go_proto"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/auth",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
typescript_proto_library(
|
||||
name = "ts",
|
||||
proto = ":auth_proto",
|
||||
)
|
38
src/rpc/auth/backend/BUILD.bazel
Normal file
38
src/rpc/auth/backend/BUILD.bazel
Normal file
|
@ -0,0 +1,38 @@
|
|||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
load("@rules_typescript_proto//:index.bzl", "typescript_proto_library")
|
||||
|
||||
proto_library(
|
||||
name = "backend_proto",
|
||||
srcs = ["auth-backend.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/rpc/auth:auth_proto",
|
||||
"//src/rpc/shared:shared_proto",
|
||||
],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
name = "backend_go_proto",
|
||||
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/auth/backend",
|
||||
proto = ":backend_proto",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/rpc/auth",
|
||||
"//src/rpc/shared",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "backend",
|
||||
embed = [":backend_go_proto"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/auth/backend",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
typescript_proto_library(
|
||||
name = "ts",
|
||||
proto = ":backend_proto",
|
||||
)
|
13
src/rpc/auth/backend/auth-backend.proto
Normal file
13
src/rpc/auth/backend/auth-backend.proto
Normal file
|
@ -0,0 +1,13 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package roleypoly.auth.backend;
|
||||
option go_package = "github.com/roleypoly/roleypoly/src/rpc/auth/backend";
|
||||
|
||||
import "src/rpc/shared/internal.proto";
|
||||
import "src/rpc/shared/shared.proto";
|
||||
import "src/rpc/auth/shared.proto";
|
||||
|
||||
service AuthBackend {
|
||||
rpc GetNewAuthChallenge(roleypoly.IDQuery) returns (roleypoly.auth.AuthChallenge) {}
|
||||
rpc GetSession(roleypoly.auth.Token) returns (roleypoly.RoleypolySession) {}
|
||||
}
|
39
src/rpc/auth/client/BUILD.bazel
Normal file
39
src/rpc/auth/client/BUILD.bazel
Normal file
|
@ -0,0 +1,39 @@
|
|||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
load("@rules_typescript_proto//:index.bzl", "typescript_proto_library")
|
||||
|
||||
proto_library(
|
||||
name = "client_proto",
|
||||
srcs = ["auth-client.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/rpc/auth:auth_proto",
|
||||
"//src/rpc/shared:shared_proto",
|
||||
"@com_google_protobuf//:empty_proto",
|
||||
],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
name = "client_go_proto",
|
||||
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/auth/client",
|
||||
proto = ":client_proto",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/rpc/auth",
|
||||
"//src/rpc/shared",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "client",
|
||||
embed = [":client_go_proto"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/auth/client",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
typescript_proto_library(
|
||||
name = "ts",
|
||||
proto = ":client_proto",
|
||||
)
|
15
src/rpc/auth/client/auth-client.proto
Normal file
15
src/rpc/auth/client/auth-client.proto
Normal file
|
@ -0,0 +1,15 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package roleypoly.auth.client;
|
||||
option go_package = "github.com/roleypoly/roleypoly/src/auth/client";
|
||||
|
||||
import "src/rpc/shared/internal.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "src/rpc/auth/shared.proto";
|
||||
|
||||
service AuthClient {
|
||||
rpc GetClientToken(google.protobuf.Empty) returns (roleypoly.auth.Token) {}
|
||||
rpc GetUserSession(google.protobuf.Empty) returns (roleypoly.RoleypolySession) {}
|
||||
rpc ResolveSessionKey(roleypoly.auth.Token) returns (roleypoly.auth.Token) {}
|
||||
rpc AuthorizeChallenge(roleypoly.auth.AuthChallenge) returns (roleypoly.auth.Token) {}
|
||||
}
|
22
src/rpc/auth/shared.proto
Normal file
22
src/rpc/auth/shared.proto
Normal file
|
@ -0,0 +1,22 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package roleypoly.auth;
|
||||
option go_package = "github.com/roleypoly/roleypoly/src/rpc/auth";
|
||||
|
||||
message Token {
|
||||
string token = 1;
|
||||
Type type = 2;
|
||||
string state = 3;
|
||||
|
||||
enum Type {
|
||||
unknown = 0;
|
||||
sessionKey = 1;
|
||||
clientToken = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message AuthChallenge {
|
||||
string userID = 1;
|
||||
string magicUrl = 2;
|
||||
string magicWords = 3;
|
||||
}
|
31
src/rpc/ctf/BUILD.bazel
Normal file
31
src/rpc/ctf/BUILD.bazel
Normal file
|
@ -0,0 +1,31 @@
|
|||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
load("@rules_typescript_proto//:index.bzl", "typescript_proto_library")
|
||||
|
||||
proto_library(
|
||||
name = "ctf_proto",
|
||||
srcs = ["ctf.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@com_google_protobuf//:empty_proto"],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
name = "ctf_go_proto",
|
||||
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/ctf",
|
||||
proto = ":ctf_proto",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "ctf",
|
||||
embed = [":ctf_go_proto"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/ctf",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
typescript_proto_library(
|
||||
name = "ts",
|
||||
proto = ":ctf_proto",
|
||||
)
|
26
src/rpc/ctf/ctf.proto
Normal file
26
src/rpc/ctf/ctf.proto
Normal file
|
@ -0,0 +1,26 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package roleypoly.ctf;
|
||||
option go_package = "github.com/roleypoly/roleypoly/src/rpc/ctf";
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
service CTF {
|
||||
rpc GetRingFlags (Ring) returns (Flags) {}
|
||||
rpc CreateFlag (Flag) returns (Flag) {}
|
||||
rpc PromoteFlag (Flag) returns (Flag) {}
|
||||
rpc RemoveFlag (Flag) returns (google.protobuf.Empty) {}
|
||||
}
|
||||
|
||||
message Flags {
|
||||
repeated Flag flags = 1;
|
||||
}
|
||||
|
||||
message Flag {
|
||||
string name = 1;
|
||||
int32 ring = 2;
|
||||
}
|
||||
|
||||
message Ring {
|
||||
int32 ring = 1;
|
||||
}
|
35
src/rpc/discord/BUILD.bazel
Normal file
35
src/rpc/discord/BUILD.bazel
Normal file
|
@ -0,0 +1,35 @@
|
|||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
load("@rules_typescript_proto//:index.bzl", "typescript_proto_library")
|
||||
|
||||
proto_library(
|
||||
name = "discord_proto",
|
||||
srcs = ["discord.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/rpc/shared:shared_proto",
|
||||
"@com_google_protobuf//:empty_proto",
|
||||
],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
name = "discord_go_proto",
|
||||
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/discord",
|
||||
proto = ":discord_proto",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//src/rpc/shared"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "discord",
|
||||
embed = [":discord_go_proto"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/discord",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
typescript_proto_library(
|
||||
name = "ts",
|
||||
proto = ":discord_proto",
|
||||
)
|
67
src/rpc/discord/discord.proto
Normal file
67
src/rpc/discord/discord.proto
Normal file
|
@ -0,0 +1,67 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package roleypoly.discord;
|
||||
option go_package = "github.com/roleypoly/roleypoly/src/rpc/discord";
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
import "src/rpc/shared/shared.proto";
|
||||
|
||||
service Discord {
|
||||
rpc ListGuilds(google.protobuf.Empty) returns (GuildList) {}
|
||||
rpc GetGuild(roleypoly.IDQuery) returns (Guild) {}
|
||||
rpc GetGuildRoles(roleypoly.IDQuery) returns (GuildRoles) {}
|
||||
rpc GetGuildsByMember(roleypoly.IDQuery) returns (GuildList) {}
|
||||
|
||||
rpc GetMember(roleypoly.IDQuery) returns (Member) {}
|
||||
rpc GetUser(roleypoly.IDQuery) returns (roleypoly.DiscordUser) {}
|
||||
rpc UpdateMember(Member) returns (Member) {} // deprecated 4 MAR 2020
|
||||
rpc UpdateMemberRoles(RoleTransaction) returns (RoleTransactionResult) {}
|
||||
|
||||
rpc OwnUser(google.protobuf.Empty) returns (roleypoly.DiscordUser) {}
|
||||
}
|
||||
|
||||
message GuildMembers {
|
||||
string ID = 1;
|
||||
repeated Member members = 2;
|
||||
}
|
||||
|
||||
message Member {
|
||||
string guildID = 1;
|
||||
repeated string roles = 3;
|
||||
string nick = 4;
|
||||
roleypoly.DiscordUser user = 5;
|
||||
}
|
||||
|
||||
message RoleTransaction {
|
||||
roleypoly.IDQuery member = 1;
|
||||
repeated TxDelta delta = 2;
|
||||
}
|
||||
|
||||
message TxDelta {
|
||||
string role = 1;
|
||||
Action action = 2;
|
||||
|
||||
enum Action {
|
||||
UNKNOWN = 0;
|
||||
ADD = 1;
|
||||
REMOVE = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message RoleTransactionResult {
|
||||
Member member = 1;
|
||||
Status status = 2;
|
||||
|
||||
enum Status {
|
||||
DONE = 0;
|
||||
QUEUED = 1;
|
||||
FAILED = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message ShardInfo {
|
||||
int32 shards = 1;
|
||||
int32 servers = 2;
|
||||
int32 users = 3;
|
||||
int32 roles = 4;
|
||||
}
|
39
src/rpc/platform/BUILD.bazel
Normal file
39
src/rpc/platform/BUILD.bazel
Normal file
|
@ -0,0 +1,39 @@
|
|||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
load("@rules_typescript_proto//:index.bzl", "typescript_proto_library")
|
||||
|
||||
proto_library(
|
||||
name = "platform_proto",
|
||||
srcs = ["platform.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/rpc/discord:discord_proto",
|
||||
"//src/rpc/shared:shared_proto",
|
||||
"@com_google_protobuf//:empty_proto",
|
||||
],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
name = "platform_go_proto",
|
||||
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/platform",
|
||||
proto = ":platform_proto",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//src/rpc/discord",
|
||||
"//src/rpc/shared",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "platform",
|
||||
embed = [":platform_go_proto"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/platform",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
typescript_proto_library(
|
||||
name = "ts",
|
||||
proto = ":platform_proto",
|
||||
)
|
61
src/rpc/platform/platform.proto
Normal file
61
src/rpc/platform/platform.proto
Normal file
|
@ -0,0 +1,61 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package roleypoly.platform;
|
||||
option go_package = "github.com/roleypoly/roleypoly/src/rpc/platform";
|
||||
|
||||
import "src/rpc/shared/shared.proto";
|
||||
import "src/rpc/discord/discord.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
|
||||
service Platform {
|
||||
rpc EnumerateMyGuilds(google.protobuf.Empty) returns (GuildEnumeration) {}
|
||||
rpc GetGuildSlug(roleypoly.IDQuery) returns (roleypoly.Guild) {}
|
||||
rpc GetGuild(roleypoly.IDQuery) returns (PresentableGuild) {}
|
||||
|
||||
rpc UpdateMyRoles(UpdateRoles) returns (google.protobuf.Empty) {}
|
||||
rpc UpdateGuildData(GuildData) returns (google.protobuf.Empty) {}
|
||||
}
|
||||
|
||||
message GuildEnumeration { repeated PresentableGuild guilds = 1; }
|
||||
|
||||
message PresentableGuild {
|
||||
string ID = 1;
|
||||
roleypoly.Guild guild = 2;
|
||||
GuildData data = 3;
|
||||
roleypoly.discord.Member member = 4;
|
||||
roleypoly.GuildRoles roles = 5;
|
||||
}
|
||||
|
||||
message GuildData {
|
||||
string ID = 1;
|
||||
string message = 2;
|
||||
repeated Category categories = 3;
|
||||
repeated string entitlements = 4;
|
||||
}
|
||||
|
||||
message UpdateRoles {
|
||||
string guildID = 1;
|
||||
Roles roles = 2;
|
||||
}
|
||||
|
||||
message Roles { repeated string roles = 1; }
|
||||
|
||||
message Category {
|
||||
string ID = 1;
|
||||
string name = 2;
|
||||
repeated string roles = 3;
|
||||
bool hidden = 4;
|
||||
CategoryType type = 5;
|
||||
int32 position = 6;
|
||||
|
||||
enum CategoryType {
|
||||
multi = 0;
|
||||
single = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message UpdateEntitlement {
|
||||
roleypoly.IDQuery query = 1;
|
||||
string name = 2;
|
||||
bool state = 3;
|
||||
}
|
32
src/rpc/shared/BUILD.bazel
Normal file
32
src/rpc/shared/BUILD.bazel
Normal file
|
@ -0,0 +1,32 @@
|
|||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
load("@rules_typescript_proto//:index.bzl", "typescript_proto_library")
|
||||
|
||||
proto_library(
|
||||
name = "shared_proto",
|
||||
srcs = [
|
||||
"internal.proto",
|
||||
"shared.proto",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
name = "shared_go_proto",
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/shared",
|
||||
proto = ":shared_proto",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "shared",
|
||||
embed = [":shared_go_proto"],
|
||||
importpath = "github.com/roleypoly/roleypoly/src/rpc/shared",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
typescript_proto_library(
|
||||
name = "ts",
|
||||
proto = ":shared_proto",
|
||||
)
|
22
src/rpc/shared/internal.proto
Normal file
22
src/rpc/shared/internal.proto
Normal file
|
@ -0,0 +1,22 @@
|
|||
syntax = "proto3";
|
||||
package roleypoly;
|
||||
import "src/rpc/shared/shared.proto";
|
||||
option go_package = "github.com/roleypoly/roleypoly/src/rpc/shared";
|
||||
|
||||
message RoleypolyUser {
|
||||
roleypoly.DiscordUser discordUser = 1;
|
||||
}
|
||||
|
||||
message RoleypolySession {
|
||||
string ID = 1;
|
||||
RoleypolyUser user = 2;
|
||||
enum SessionSource {
|
||||
UNKNOWN = 0;
|
||||
OAUTH = 1;
|
||||
DM = 2;
|
||||
}
|
||||
SessionSource source = 3;
|
||||
int64 created_at = 4;
|
||||
int64 expires_in = 5;
|
||||
map<string, string> extra = 6;
|
||||
}
|
47
src/rpc/shared/shared.proto
Normal file
47
src/rpc/shared/shared.proto
Normal file
|
@ -0,0 +1,47 @@
|
|||
syntax = "proto3";
|
||||
package roleypoly;
|
||||
option go_package = "github.com/roleypoly/roleypoly/src/rpc/shared";
|
||||
|
||||
message IDQuery {
|
||||
string MemberID = 1;
|
||||
string GuildID = 2;
|
||||
}
|
||||
|
||||
message GuildList { repeated Guild guilds = 1; }
|
||||
|
||||
message Guild {
|
||||
string ID = 1;
|
||||
string name = 2;
|
||||
string icon = 3;
|
||||
string ownerID = 4;
|
||||
int32 memberCount = 5;
|
||||
string splash = 6;
|
||||
}
|
||||
|
||||
message GuildRoles {
|
||||
string ID = 1;
|
||||
repeated Role roles = 2;
|
||||
}
|
||||
|
||||
message Role {
|
||||
string ID = 1;
|
||||
string name = 2;
|
||||
int64 permissions = 3;
|
||||
int32 color = 4;
|
||||
int32 position = 5;
|
||||
bool managed = 6;
|
||||
RoleSafety safety = 7;
|
||||
enum RoleSafety {
|
||||
safe = 0;
|
||||
higherThanBot = 1;
|
||||
dangerousPermissions = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message DiscordUser {
|
||||
string ID = 1;
|
||||
string username = 2;
|
||||
string discriminator = 3;
|
||||
string avatar = 4;
|
||||
bool bot = 5;
|
||||
}
|
Loading…
Add table
Reference in a new issue