Skip to content

Commit a0fb50f

Browse files
committed
added automatic protobuf recompilation with import path patching; code not refactored for typeDB renaming
1 parent 686c327 commit a0fb50f

14 files changed

+180
-141
lines changed

lib/Concept.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4645,7 +4645,7 @@ instance HsJSONPB.ToSchema Relation_GetPlayersByRoleType_Req where
46454645
newtype Relation_GetPlayersByRoleType_ResPart = Relation_GetPlayersByRoleType_ResPart{relation_GetPlayersByRoleType_ResPartRoleTypesWithPlayers
46464646
::
46474647
Hs.Vector
4648-
Concept.Relation_GetPlayersByRoleType_RoleTypeWithPlayer}
4648+
Concept.GetPlayersByRoleType_RoleTypeWithPlayer}
46494649
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic,
46504650
Hs.NFData)
46514651

@@ -4665,14 +4665,14 @@ instance HsProtobuf.Message Relation_GetPlayersByRoleType_ResPart
46654665
= (Hs.mconcat
46664666
[(HsProtobuf.encodeMessageField (HsProtobuf.FieldNumber 1)
46674667
(Hs.coerce
4668-
@(Hs.Vector Concept.Relation_GetPlayersByRoleType_RoleTypeWithPlayer)
4669-
@(HsProtobuf.NestedVec Concept.Relation_GetPlayersByRoleType_RoleTypeWithPlayer)
4668+
@(Hs.Vector Concept.GetPlayersByRoleType_RoleTypeWithPlayer)
4669+
@(HsProtobuf.NestedVec Concept.GetPlayersByRoleType_RoleTypeWithPlayer)
46704670
relation_GetPlayersByRoleType_ResPartRoleTypesWithPlayers))])
46714671
decodeMessage _
46724672
= (Hs.pure Relation_GetPlayersByRoleType_ResPart) <*>
46734673
(Hs.coerce
4674-
@(_ (HsProtobuf.NestedVec Concept.Relation_GetPlayersByRoleType_RoleTypeWithPlayer))
4675-
@(_ (Hs.Vector Concept.Relation_GetPlayersByRoleType_RoleTypeWithPlayer))
4674+
@(_ (HsProtobuf.NestedVec Concept.GetPlayersByRoleType_RoleTypeWithPlayer))
4675+
@(_ (Hs.Vector Concept.GetPlayersByRoleType_RoleTypeWithPlayer))
46764676
(HsProtobuf.at HsProtobuf.decodeMessageField
46774677
(HsProtobuf.FieldNumber 1)))
46784678
dotProto _
@@ -13012,4 +13012,4 @@ instance HsJSONPB.ToSchema AttributeType_GetInstances_ResPart where
1301213012
HsJSONPB._schemaProperties =
1301313013
HsJSONPB.insOrdFromList
1301413014
[("things",
13015-
attributeType_GetInstances_ResPartThings)]}})
13015+
attributeType_GetInstances_ResPartThings)]}})

lib/CoreService.hs

Lines changed: 105 additions & 101 deletions
Large diffs are not rendered by default.

lib/Transaction.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ instance HsJSONPB.ToSchema Transaction_Stream_Req where
16151615
newtype Transaction_Stream_ResPart = Transaction_Stream_ResPart{transaction_Stream_ResPartState
16161616
::
16171617
HsProtobuf.Enumerated
1618-
Transaction_Stream_State}
1618+
Transaction.Stream_State}
16191619
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic, Hs.NFData)
16201620

16211621
instance HsProtobuf.Named Transaction_Stream_ResPart where
@@ -1921,4 +1921,4 @@ instance HsJSONPB.ToSchema Transaction_Rollback_Res where
19211921
Hs.mempty{HsJSONPB._paramSchemaType =
19221922
Hs.Just HsJSONPB.SwaggerObject},
19231923
HsJSONPB._schemaProperties =
1924-
HsJSONPB.insOrdFromList []}})
1924+
HsJSONPB.insOrdFromList []}})

lib/fixedProtobuf/answer.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2021 Grakn Labs
2+
// Copyright (C) 2021 Vaticle
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as
@@ -17,12 +17,12 @@
1717

1818
syntax = "proto3";
1919

20-
option java_package = "grakn.protocol";
20+
option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "AnswerProto";
2222

2323
import "concept.proto";
2424

25-
package grakn.protocol;
25+
package typedb.protocol;
2626

2727
message ConceptMap {
2828
map<string, Concept> map = 1;

lib/fixedProtobuf/concept.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2021 Grakn Labs
2+
// Copyright (C) 2021 Vaticle
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as
@@ -17,10 +17,10 @@
1717

1818
syntax = "proto3";
1919

20-
option java_package = "grakn.protocol";
20+
option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "ConceptProto";
2222

23-
package grakn.protocol;
23+
package typedb.protocol;
2424

2525
message ConceptManager {
2626

lib/fixedProtobuf/core_database.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2021 Grakn Labs
2+
// Copyright (C) 2021 Vaticle
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as
@@ -17,10 +17,10 @@
1717

1818
syntax = "proto3";
1919

20-
option java_package = "grakn.protocol";
20+
option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "CoreDatabaseProto";
2222

23-
package grakn.protocol;
23+
package typedb.protocol;
2424

2525
message CoreDatabaseManager {
2626

lib/fixedProtobuf/core_service.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2021 Grakn Labs
2+
// Copyright (C) 2021 Vaticle
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as
@@ -17,17 +17,17 @@
1717

1818
syntax = "proto3";
1919

20-
option java_package = "grakn.protocol";
20+
option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "CoreServiceProto";
2222
option java_generic_services = true;
2323

2424
import "core_database.proto";
2525
import "session.proto";
2626
import "transaction.proto";
2727

28-
package grakn.protocol;
28+
package typedb.protocol;
2929

30-
service GraknCore {
30+
service TypeDB {
3131

3232
// Database Manager API
3333
rpc databases_contains (CoreDatabaseManager.Contains.Req) returns (CoreDatabaseManager.Contains.Res);

lib/fixedProtobuf/logic.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2021 Grakn Labs
2+
// Copyright (C) 2021 Vaticle
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as
@@ -17,13 +17,13 @@
1717

1818
syntax = "proto3";
1919

20-
option java_package = "grakn.protocol";
20+
option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "LogicProto";
2222

2323
import "answer.proto";
2424

2525

26-
package grakn.protocol;
26+
package typedb.protocol;
2727

2828
message LogicManager {
2929

lib/fixedProtobuf/options.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2021 Grakn Labs
2+
// Copyright (C) 2021 Vaticle
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as
@@ -17,10 +17,10 @@
1717

1818
syntax = "proto3";
1919

20-
option java_package = "grakn.protocol";
20+
option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "OptionsProto";
2222

23-
package grakn.protocol;
23+
package typedb.protocol;
2424

2525
// TODO: Replace 'oneof' with 'optional' when upgraded to Protobuf 3.13 everywhere
2626
// https://github.com/protocolbuffers/protobuf/issues/1606#issuecomment-618687169

lib/fixedProtobuf/query.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2021 Grakn Labs
2+
// Copyright (C) 2021 Vaticle
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as
@@ -17,14 +17,14 @@
1717

1818
syntax = "proto3";
1919

20-
option java_package = "grakn.protocol";
20+
option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "QueryProto";
2222

2323
import "answer.proto";
2424
import "logic.proto";
2525
import "options.proto";
2626

27-
package grakn.protocol;
27+
package typedb.protocol;
2828

2929
message QueryManager {
3030

lib/fixedProtobuf/session.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2021 Grakn Labs
2+
// Copyright (C) 2021 Vaticle
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as
@@ -17,12 +17,12 @@
1717

1818
syntax = "proto3";
1919

20-
option java_package = "grakn.protocol";
20+
option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "SessionProto";
2222

2323
import "options.proto";
2424

25-
package grakn.protocol;
25+
package typedb.protocol;
2626

2727
message Session {
2828

lib/fixedProtobuf/transaction.proto

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (C) 2021 Grakn Labs
2+
// Copyright (C) 2021 Vaticle
33
//
44
// This program is free software: you can redistribute it and/or modify
55
// it under the terms of the GNU Affero General Public License as
@@ -17,15 +17,15 @@
1717

1818
syntax = "proto3";
1919

20-
option java_package = "grakn.protocol";
20+
option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "TransactionProto";
2222

2323
import "concept.proto";
2424
import "logic.proto";
2525
import "options.proto";
2626
import "query.proto";
2727

28-
package grakn.protocol;
28+
package typedb.protocol;
2929

3030
message Transaction {
3131

@@ -52,7 +52,7 @@ message Transaction {
5252
ConceptManager.Req concept_manager_req = 8;
5353
LogicManager.Req logic_manager_req = 9;
5454
Rule.Req rule_req = 10;
55-
grakn.protocol.Type.Req type_req = 11;
55+
typedb.protocol.Type.Req type_req = 11;
5656
Thing.Req thing_req = 12;
5757
}
5858
}
@@ -67,7 +67,7 @@ message Transaction {
6767
ConceptManager.Res concept_manager_res = 6;
6868
LogicManager.Res logic_manager_res = 7;
6969
Rule.Res rule_res = 8;
70-
grakn.protocol.Type.Res type_res = 9;
70+
typedb.protocol.Type.Res type_res = 9;
7171
Thing.Res thing_res = 10;
7272
}
7373
}
@@ -78,7 +78,7 @@ message Transaction {
7878
Stream.ResPart stream_res_part = 2;
7979
QueryManager.ResPart query_manager_res_part = 3;
8080
LogicManager.ResPart logic_manager_res_part = 4;
81-
grakn.protocol.Type.ResPart type_res_part = 5;
81+
typedb.protocol.Type.ResPart type_res_part = 5;
8282
Thing.ResPart thing_res_part = 6;
8383
}
8484
}

lib/protocol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit efac95a542c5f23b0ee881f7bd618224b0aa7d6c
1+
Subproject commit 49c586ee981ecd34484b66155d21bf63b0e53e48

recompile-protocol.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# create directory for old protofiles
2+
backupDirName="./lib/fixedProtobuf/backup_$(date +"%d-%m-%Y-%H-%M-%S")"
3+
4+
# move old files to backup dir if they exist
5+
[ -f "./lib/fixedProtobuf/session.proto" ] \
6+
&& mkdir $backupDirName \
7+
&& mv ./lib/fixedProtobuf/*.proto "$backupDirName/"
8+
9+
# get proto files
10+
protoFiles=$(find ./lib/protocol/ -name "*.proto" \
11+
| grep -v "cluster")
12+
13+
# first move and patch all files; imports are needed for compilation
14+
for e in $protoFiles; do
15+
# move file
16+
cp $e ./lib/fixedProtobuf/
17+
18+
# patch import statements
19+
sed -Ei 's%import "[a-z_]+/([a-z_]+.proto)"%import "\1"%g' \
20+
"./lib/fixedProtobuf/$(basename $e)"
21+
22+
done
23+
24+
# now compile all proto files
25+
protoFiles=$(find ./lib/fixedProtobuf/ -name "*.proto" \
26+
| grep -v "cluster")
27+
28+
for e in ./lib/fixedProtobuf/*.proto; do
29+
echo "compiling $e"
30+
# compile proto file
31+
compile-proto-file \
32+
--includeDir $(dirname $e) \
33+
--proto $(basename $e) \
34+
--out ./lib/
35+
done

0 commit comments

Comments
 (0)