├── .gitignore ├── lib ├── y │ └── y.dart ├── protos │ └── api │ │ ├── regenerate-proto.sh │ │ ├── api.pbenum.dart │ │ ├── api.pbserver.dart │ │ ├── api.pbjson.dart │ │ └── api.pb.dart ├── x │ └── error.dart ├── api.dart ├── dgraph.dart └── txn.dart ├── .travis.yml ├── pubspec.yaml ├── CHANGELOG.md ├── test ├── mutation_test.dart ├── alter_test.dart └── query_test.dart ├── example └── example.dart ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool/ 2 | .packages 3 | .vscode/ 4 | doc/ 5 | lib/protos/api/api.proto 6 | pubspec.lock -------------------------------------------------------------------------------- /lib/y/y.dart: -------------------------------------------------------------------------------- 1 | const ErrAborted = "Transaction has been aborted. Please retry."; 2 | const ErrConflict = "Conflicts with pending transaction. Please abort."; 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: dart 2 | dart: 3 | # Install the latest stable release 4 | - stable 5 | services: 6 | - docker 7 | before_install: 8 | - docker run --rm -it -p 8000:8000 -p 8080:8080 -p 9080:9080 -d dgraph/standalone:latest 9 | notifications: 10 | email: false -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: dgraph 2 | version: 1.1.2 3 | description: >- 4 | Dgraph dart client. 5 | environment: 6 | sdk: '>=2.12.0 <3.0.0' 7 | dependencies: 8 | fixnum: ^1.0.0 9 | grpc: ^3.0.2 10 | mutex: ^3.0.0 11 | protobuf: ^2.0.0 12 | dev_dependencies: 13 | test: ^1.5.1 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.1.2 2 | 3 | * Migrate to dart sound null safety (thanks to [modeckrus](https://github.com/modeckrus)). 4 | 5 | ## 1.1.1 6 | 7 | * Fixed Dgraph 1.0.x compatible client version on README 8 | 9 | ## 1.1.0 10 | 11 | * Dgraph 1.1.x support 12 | * Added tests 13 | 14 | ## 0.5.0 15 | 16 | * Changed Commit and Discard methods to async 17 | * Added dropAttr to example 18 | 19 | ## 0.4.0 20 | 21 | * Improved README 22 | * Ran darfmt on dart file 23 | 24 | ## 0.3.0 25 | 26 | * Fixed 'Name types using UpperCamelCase' suggestion on package analysis 27 | * Changed grpc package version to 0.6.6 to make dartdoc works 28 | 29 | ## 0.2.0 30 | 31 | * Improved README 32 | * Added dropAll call to example 33 | * Ran darfmt on dart files 34 | 35 | ## 0.1.0 36 | 37 | * Initial release 38 | -------------------------------------------------------------------------------- /lib/protos/api/regenerate-proto.sh: -------------------------------------------------------------------------------- 1 | # Thanks to @domesticmouse (https://github.com/marceloneppel/rethinkdb/commit/821a84aca55188c5e5ee569a307d7847761edce2). 2 | 3 | #!/bin/sh 4 | 5 | DIR="$(dirname $BASH_SOURCE)" 6 | 7 | # Do a quick validation that we have the protoc plugin in PATH. 8 | PROTOC_PLUGIN=$(which protoc-gen-dart) 9 | if [ ! -f "$PROTOC_PLUGIN" ]; then 10 | echo -en "Could not find Dart plugin for protoc! \nMake sure \$PATH includes " 11 | echo "the protoc compiler plugin for Dart (named \"protoc-gen-dart\")!" 12 | exit 1 13 | fi 14 | 15 | function run { 16 | echo "Running $@" 17 | $@ 18 | 19 | EXITCODE=$? 20 | if [ $EXITCODE -ne 0 ]; then 21 | echo " -> Command failed with exitcode $EXITCODE. Aborting ..." 22 | exit $EXITCODE 23 | fi 24 | } 25 | 26 | 27 | # Retrieve updated protobuf for dgraph's wire protocol. 28 | run wget -O $DIR/api.proto https://raw.githubusercontent.com/dgraph-io/dgo/master/protos/api.proto 29 | 30 | # Re-generate protobuf files. 31 | # See https://developers.google.com/protocol-buffers/docs/reference/dart-generated 32 | run protoc --proto_path=$DIR --dart_out=$DIR $DIR/api.proto 33 | 34 | run dartfmt --fix -w $DIR -------------------------------------------------------------------------------- /lib/x/error.dart: -------------------------------------------------------------------------------- 1 | // Check logs fatal if err != nil. 2 | void Check(dynamic err) { 3 | if (err != null) { 4 | // TODO: log.Fatalf("%+v", errors.WithStack(err)) 5 | throw err; 6 | } 7 | } 8 | 9 | // Checkf is Check with extra info. 10 | //void Checkf(dynamic err, String format, ...dynamic args) { 11 | void Checkf(dynamic err, String format, List args) { 12 | if (err != null) { 13 | // TODO: log.Fatalf("%+v", errors.Wrapf(err, format, args...)) 14 | throw err; 15 | } 16 | } 17 | 18 | // Check2 acts as convenience wrapper around Check, using the 2nd argument as error. 19 | void Check2(dynamic _, dynamic err) { 20 | Check(err); 21 | } 22 | 23 | // AssertTrue asserts that b is true. Otherwise, it would log fatal. 24 | void AssertTrue(bool b) { 25 | if (!b) { 26 | // TODO: log.Fatalf("%+v", errors.Errorf("Assert failed")) 27 | throw "Assert failed"; 28 | } 29 | } 30 | 31 | // AssertTruef is AssertTrue with extra info. 32 | //void AssertTruef(bool b, String format, dynamic... args) { 33 | void AssertTruef(bool b, String format, List args) { 34 | if (!b) { 35 | // TODO: log.Fatalf("%+v", errors.Errorf(format, args...)) 36 | throw format; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/mutation_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:dgraph/txn.dart'; 4 | import 'package:test/test.dart'; 5 | import 'package:dgraph/api.dart'; 6 | import 'package:dgraph/dgraph.dart'; 7 | import 'package:dgraph/protos/api/api.pb.dart' as api; 8 | import 'package:grpc/grpc.dart'; 9 | import 'package:protobuf/protobuf.dart'; 10 | 11 | main() { 12 | DgraphRpcClient rpcClient; 13 | Dgraph? dgraphClient; 14 | Txn txn; 15 | late ClientContext clientContext; 16 | 17 | _setUpData() async { 18 | api.Operation operation = api.Operation(); 19 | operation.schema = """ 20 | name: string @index(exact) . 21 | """; 22 | await dgraphClient!.Alter(clientContext, operation); 23 | } 24 | 25 | setUp(() async { 26 | rpcClient = 27 | DgraphRpcClient("localhost", 9080, const ChannelCredentials.insecure()); 28 | dgraphClient = dgraph.NewDgraphClient(api.DgraphApi(rpcClient)); 29 | clientContext = ClientContext(); 30 | await _setUpData(); 31 | }); 32 | 33 | tearDown(() async { 34 | var operation = api.Operation(); 35 | operation.dropAll = true; 36 | await dgraphClient!.Alter(clientContext, operation); 37 | }); 38 | 39 | group("mutation -> ", () { 40 | test("should retrieve the uid of the inserted data", () async { 41 | Map p = { 42 | "uid": "_:alice", 43 | "name": "Alice", 44 | "age": 18, 45 | }; 46 | List pb = utf8.encode(json.encode(p)); 47 | api.Mutation mutation = api.Mutation(); 48 | mutation.setJson = pb; 49 | api.Request request = api.Request(); 50 | request.mutations.add(mutation); 51 | txn = dgraphClient!.NewTxn(); 52 | var response = 53 | await (txn.Mutate(clientContext, request) as Future); 54 | expect(response.uids.keys, equals(['alice'])); 55 | expect(response.uids.values.length, 1); 56 | expect(response.uids.values.join(','), startsWith('0x')); 57 | await txn.Commit(clientContext); 58 | }); 59 | }); 60 | } 61 | -------------------------------------------------------------------------------- /lib/protos/api/api.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: api.proto 4 | // 5 | 6 | // ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type 7 | 8 | // ignore_for_file: UNDEFINED_SHOWN_NAME,UNUSED_SHOWN_NAME 9 | import 'dart:core' as $core; 10 | import 'package:protobuf/protobuf.dart' as $pb; 11 | 12 | class Operation_DropOp extends $pb.ProtobufEnum { 13 | static const Operation_DropOp NONE = Operation_DropOp._(0, 'NONE'); 14 | static const Operation_DropOp ALL = Operation_DropOp._(1, 'ALL'); 15 | static const Operation_DropOp DATA = Operation_DropOp._(2, 'DATA'); 16 | static const Operation_DropOp ATTR = Operation_DropOp._(3, 'ATTR'); 17 | static const Operation_DropOp TYPE = Operation_DropOp._(4, 'TYPE'); 18 | 19 | static const $core.List values = [ 20 | NONE, 21 | ALL, 22 | DATA, 23 | ATTR, 24 | TYPE, 25 | ]; 26 | 27 | static final $core.Map<$core.int, Operation_DropOp> _byValue = 28 | $pb.ProtobufEnum.initByValue(values); 29 | static Operation_DropOp? valueOf($core.int value) => _byValue[value]; 30 | 31 | const Operation_DropOp._($core.int v, $core.String n) : super(v, n); 32 | } 33 | 34 | class Facet_ValType extends $pb.ProtobufEnum { 35 | static const Facet_ValType STRING = Facet_ValType._(0, 'STRING'); 36 | static const Facet_ValType INT = Facet_ValType._(1, 'INT'); 37 | static const Facet_ValType FLOAT = Facet_ValType._(2, 'FLOAT'); 38 | static const Facet_ValType BOOL = Facet_ValType._(3, 'BOOL'); 39 | static const Facet_ValType DATETIME = Facet_ValType._(4, 'DATETIME'); 40 | 41 | static const $core.List values = [ 42 | STRING, 43 | INT, 44 | FLOAT, 45 | BOOL, 46 | DATETIME, 47 | ]; 48 | 49 | static final $core.Map<$core.int, Facet_ValType> _byValue = 50 | $pb.ProtobufEnum.initByValue(values); 51 | static Facet_ValType? valueOf($core.int value) => _byValue[value]; 52 | 53 | const Facet_ValType._($core.int v, $core.String n) : super(v, n); 54 | } 55 | -------------------------------------------------------------------------------- /lib/api.dart: -------------------------------------------------------------------------------- 1 | import 'package:dgraph/protos/api/api.pb.dart' as api; 2 | import 'package:grpc/grpc.dart'; 3 | import 'package:protobuf/protobuf.dart'; 4 | import 'dart:async'; 5 | 6 | class DgraphRpcClient extends RpcClient { 7 | final String host; 8 | final int port; 9 | final ChannelCredentials channelCredentials; 10 | 11 | DgraphRpcClient(this.host, this.port, this.channelCredentials); 12 | 13 | @override 14 | Future invoke( 15 | ClientContext? ctx, 16 | String serviceName, 17 | String methodName, 18 | GeneratedMessage request, 19 | T emptyResponse) async { 20 | ClientChannel channel = ClientChannel( 21 | host, 22 | port: port, 23 | options: ChannelOptions( 24 | credentials: channelCredentials, 25 | ), 26 | ); 27 | ClientMethod clientMethod = 28 | ClientMethod( 29 | '/api.Dgraph/$methodName', 30 | (GeneratedMessage value) { 31 | List list = List.from( 32 | value.writeToBuffer(), 33 | ); 34 | return list; 35 | }, 36 | (List value) { 37 | GeneratedMessage? generatedMessage; 38 | switch (methodName) { 39 | case "Query": 40 | generatedMessage = api.Response.fromBuffer(value); 41 | break; 42 | case "Mutate": 43 | generatedMessage = api.Response.fromBuffer(value); 44 | break; 45 | case "Alter": 46 | generatedMessage = api.Payload.fromBuffer(value); 47 | break; 48 | case "CommitOrAbort": 49 | generatedMessage = api.TxnContext.fromBuffer(value); 50 | break; 51 | case "CheckVersion": 52 | generatedMessage = api.Version.fromBuffer(value); 53 | break; 54 | } 55 | return generatedMessage; 56 | }, 57 | ); 58 | StreamController streamController = 59 | StreamController(); 60 | streamController.sink.add(request); 61 | CallOptions callOptions = CallOptions(timeout: Duration(seconds: 3)); 62 | ClientCall clientCall = 63 | channel.createCall(clientMethod, streamController.stream, callOptions); 64 | GeneratedMessage? response = await clientCall.response.first; 65 | emptyResponse = response as T; 66 | return emptyResponse; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/protos/api/api.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: api.proto 4 | // 5 | 6 | // ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type 7 | 8 | import 'dart:async' as $async; 9 | 10 | import 'package:protobuf/protobuf.dart' as $pb; 11 | 12 | import 'dart:core' as $core; 13 | import 'api.pb.dart' as $0; 14 | import 'api.pbjson.dart'; 15 | 16 | export 'api.pb.dart'; 17 | 18 | abstract class DgraphServiceBase extends $pb.GeneratedService { 19 | $async.Future<$0.Response> login( 20 | $pb.ServerContext ctx, $0.LoginRequest request); 21 | $async.Future<$0.Response> query($pb.ServerContext ctx, $0.Request request); 22 | $async.Future<$0.Payload> alter($pb.ServerContext ctx, $0.Operation request); 23 | $async.Future<$0.TxnContext> commitOrAbort( 24 | $pb.ServerContext ctx, $0.TxnContext request); 25 | $async.Future<$0.Version> checkVersion( 26 | $pb.ServerContext ctx, $0.Check request); 27 | 28 | $pb.GeneratedMessage createRequest($core.String method) { 29 | switch (method) { 30 | case 'Login': 31 | return $0.LoginRequest(); 32 | case 'Query': 33 | return $0.Request(); 34 | case 'Alter': 35 | return $0.Operation(); 36 | case 'CommitOrAbort': 37 | return $0.TxnContext(); 38 | case 'CheckVersion': 39 | return $0.Check(); 40 | default: 41 | throw $core.ArgumentError('Unknown method: $method'); 42 | } 43 | } 44 | 45 | $async.Future<$pb.GeneratedMessage> handleCall($pb.ServerContext ctx, 46 | $core.String method, $pb.GeneratedMessage request) { 47 | switch (method) { 48 | case 'Login': 49 | return this.login(ctx, request as $0.LoginRequest); 50 | case 'Query': 51 | return this.query(ctx, request as $0.Request); 52 | case 'Alter': 53 | return this.alter(ctx, request as $0.Operation); 54 | case 'CommitOrAbort': 55 | return this.commitOrAbort(ctx, request as $0.TxnContext); 56 | case 'CheckVersion': 57 | return this.checkVersion(ctx, request as $0.Check); 58 | default: 59 | throw $core.ArgumentError('Unknown method: $method'); 60 | } 61 | } 62 | 63 | $core.Map<$core.String, $core.dynamic> get $json => DgraphServiceBase$json; 64 | $core.Map<$core.String, $core.Map<$core.String, $core.dynamic>> 65 | get $messageJson => DgraphServiceBase$messageJson; 66 | } 67 | -------------------------------------------------------------------------------- /example/example.dart: -------------------------------------------------------------------------------- 1 | import 'package:dgraph/api.dart'; 2 | import 'package:dgraph/dgraph.dart'; 3 | import 'package:dgraph/protos/api/api.pb.dart' as api; 4 | import 'package:dgraph/txn.dart'; 5 | import 'package:grpc/grpc.dart'; 6 | import 'package:protobuf/protobuf.dart'; 7 | import 'dart:convert'; 8 | 9 | void main(List arguments) async { 10 | // Create a client 11 | DgraphRpcClient rpcClient = 12 | DgraphRpcClient("localhost", 9080, const ChannelCredentials.insecure()); 13 | Dgraph dgraphClient = dgraph.NewDgraphClient(api.DgraphApi(rpcClient)); 14 | 15 | Txn? txn; 16 | ClientContext clientContext = ClientContext(); 17 | try { 18 | // Alter the database 19 | api.Operation operation = api.Operation(); 20 | operation.schema = """ 21 | name: string @index(exact) . 22 | """; 23 | await dgraphClient.Alter(clientContext, operation); 24 | 25 | txn = dgraphClient.NewTxn(); 26 | String query = """ 27 | schema(pred: [name]) { 28 | type 29 | index 30 | reverse 31 | tokenizer 32 | list 33 | count 34 | upsert 35 | lang 36 | } 37 | """; 38 | api.Response response = await txn.Query(clientContext, query); 39 | print("Response: ${utf8.decode(response.json)}"); 40 | txn.Discard(clientContext); 41 | 42 | // Create a transaction 43 | txn = dgraphClient.NewTxn(); 44 | 45 | // Run a mutation 46 | Map p = { 47 | "uid": "_:alice", 48 | "name": "Alice", 49 | "age": 18, 50 | }; 51 | List pb = utf8.encode(json.encode(p)); 52 | api.Mutation mutation = api.Mutation(); 53 | mutation.setJson = pb; 54 | api.Request request = api.Request(); 55 | request.mutations.add(mutation); 56 | response = 57 | await (txn.Mutate(clientContext, request) as Future); 58 | print("Response: ${response.uids}"); 59 | 60 | // Run a query 61 | query = """ 62 | query all(\$a: string) { 63 | all(func: eq(name, \$a)) { 64 | name 65 | age 66 | } 67 | } 68 | """; 69 | response = await txn.QueryWithVars(clientContext, query, {"\$a": "Alice"}); 70 | print("Response: ${utf8.decode(response.json)}"); 71 | 72 | // Commit a transaction 73 | await txn.Commit(clientContext); 74 | 75 | // Alter the database 76 | operation = api.Operation(); 77 | operation.dropAttr = "age"; 78 | await dgraphClient.Alter(clientContext, operation); 79 | 80 | // Create another transaction 81 | txn = dgraphClient.NewReadOnlyTxn(); 82 | 83 | // Run the same query again 84 | response = await txn.QueryWithVars(clientContext, query, {"\$a": "Alice"}); 85 | print("Response: ${utf8.decode(response.json)}"); 86 | 87 | // Run the same query again, but now using txn.Do 88 | request = api.Request(); 89 | request.query = query; 90 | request.vars.addAll({"\$a": "Alice"}); 91 | response = await (txn.Do(clientContext, request) as Future); 92 | print("Response: ${utf8.decode(response.json)}"); 93 | 94 | // Finish transaction without commit 95 | await txn.Discard(clientContext); 96 | 97 | // Alter the database 98 | operation = api.Operation(); 99 | operation.dropAll = true; 100 | await dgraphClient.Alter(clientContext, operation); 101 | } catch (e) { 102 | print("Error: $e"); 103 | } finally { 104 | if (txn != null) { 105 | await txn.Discard(clientContext); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /test/alter_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:dgraph/txn.dart'; 4 | import 'package:test/test.dart'; 5 | import 'package:dgraph/api.dart'; 6 | import 'package:dgraph/dgraph.dart'; 7 | import 'package:dgraph/protos/api/api.pb.dart' as api; 8 | import 'package:grpc/grpc.dart'; 9 | import 'package:protobuf/protobuf.dart'; 10 | 11 | main() { 12 | DgraphRpcClient rpcClient; 13 | Dgraph? dgraphClient; 14 | late Txn txn; 15 | late ClientContext clientContext; 16 | 17 | setUp(() async { 18 | rpcClient = 19 | DgraphRpcClient("localhost", 9080, const ChannelCredentials.insecure()); 20 | dgraphClient = dgraph.NewDgraphClient(api.DgraphApi(rpcClient)); 21 | txn = dgraphClient!.NewTxn(); 22 | clientContext = ClientContext(); 23 | }); 24 | 25 | tearDown(() async { 26 | var operation = api.Operation(); 27 | operation.dropAll = true; 28 | await dgraphClient!.Alter(clientContext, operation); 29 | }); 30 | 31 | group("dropAll -> ", () { 32 | test("should drop all attributes from the schema", () async { 33 | var operation = api.Operation(); 34 | operation.schema = """ 35 | name: string @index(exact) . 36 | nickname: string @index(exact) . 37 | """; 38 | await dgraphClient!.Alter(clientContext, operation); 39 | 40 | operation = api.Operation(); 41 | operation = api.Operation(); 42 | operation.dropAll = true; 43 | await dgraphClient!.Alter(clientContext, operation); 44 | 45 | String query = """ 46 | schema(pred: [name,nickname]) { 47 | type 48 | index 49 | reverse 50 | tokenizer 51 | list 52 | count 53 | upsert 54 | lang 55 | } 56 | """; 57 | var response = await txn.Query(clientContext, query); 58 | expect(json.decode(utf8.decode(response.json)), equals({})); 59 | }); 60 | }); 61 | 62 | group("dropAttr -> ", () { 63 | test("should drop an attribute from the schema", () async { 64 | var operation = api.Operation(); 65 | operation.schema = """ 66 | name: string @index(exact) . 67 | nickname: string @index(exact) . 68 | """; 69 | await dgraphClient!.Alter(clientContext, operation); 70 | 71 | operation = api.Operation(); 72 | operation = api.Operation(); 73 | operation.dropAttr = "name"; 74 | await dgraphClient!.Alter(clientContext, operation); 75 | 76 | String query = """ 77 | schema(pred: [name,nickname]) { 78 | type 79 | index 80 | reverse 81 | tokenizer 82 | list 83 | count 84 | upsert 85 | lang 86 | } 87 | """; 88 | var response = await txn.Query(clientContext, query); 89 | expect( 90 | json.decode(utf8.decode(response.json)), 91 | equals({ 92 | 'schema': [ 93 | { 94 | 'predicate': 'nickname', 95 | 'type': 'string', 96 | 'index': true, 97 | 'tokenizer': ['exact'] 98 | } 99 | ] 100 | })); 101 | }); 102 | }); 103 | 104 | group("schema -> ", () { 105 | test("should define the schema", () async { 106 | var operation = api.Operation(); 107 | operation.schema = """ 108 | name: string @index(exact) . 109 | """; 110 | await dgraphClient!.Alter(clientContext, operation); 111 | 112 | String query = """ 113 | schema(pred: [name]) { 114 | type 115 | index 116 | reverse 117 | tokenizer 118 | list 119 | count 120 | upsert 121 | lang 122 | } 123 | """; 124 | var response = await txn.Query(clientContext, query); 125 | expect( 126 | json.decode(utf8.decode(response.json)), 127 | equals({ 128 | 'schema': [ 129 | { 130 | 'predicate': 'name', 131 | 'type': 'string', 132 | 'index': true, 133 | 'tokenizer': ['exact'] 134 | } 135 | ] 136 | })); 137 | }); 138 | }); 139 | } 140 | -------------------------------------------------------------------------------- /test/query_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:dgraph/txn.dart'; 4 | import 'package:test/test.dart'; 5 | import 'package:dgraph/api.dart'; 6 | import 'package:dgraph/dgraph.dart'; 7 | import 'package:dgraph/protos/api/api.pb.dart' as api; 8 | import 'package:grpc/grpc.dart'; 9 | import 'package:protobuf/protobuf.dart'; 10 | 11 | main() { 12 | DgraphRpcClient rpcClient; 13 | Dgraph? dgraphClient; 14 | late Txn txn; 15 | late ClientContext clientContext; 16 | 17 | _setUpData() async { 18 | api.Operation operation = api.Operation(); 19 | operation.schema = """ 20 | name: string @index(exact) . 21 | """; 22 | await dgraphClient!.Alter(clientContext, operation); 23 | 24 | Map p = { 25 | "uid": "_:alice", 26 | "name": "Alice", 27 | "age": 18, 28 | }; 29 | List pb = utf8.encode(json.encode(p)); 30 | api.Mutation mutation = api.Mutation(); 31 | mutation.setJson = pb; 32 | api.Request request = api.Request(); 33 | request.mutations.add(mutation); 34 | txn = dgraphClient!.NewTxn(); 35 | await txn.Mutate(clientContext, request); 36 | await txn.Commit(clientContext); 37 | } 38 | 39 | setUp(() async { 40 | rpcClient = 41 | DgraphRpcClient("localhost", 9080, const ChannelCredentials.insecure()); 42 | dgraphClient = dgraph.NewDgraphClient(api.DgraphApi(rpcClient)); 43 | clientContext = ClientContext(); 44 | await _setUpData(); 45 | txn = dgraphClient!.NewTxn(); 46 | }); 47 | 48 | tearDown(() async { 49 | var operation = api.Operation(); 50 | operation.dropAll = true; 51 | await dgraphClient!.Alter(clientContext, operation); 52 | }); 53 | 54 | group("query -> ", () { 55 | test("should check if the database contains an existing data", () async { 56 | String query = """ 57 | query all() { 58 | all(func: eq(name, Alice)) { 59 | name 60 | age 61 | } 62 | } 63 | """; 64 | var response = await txn.Query(clientContext, query); 65 | expect( 66 | json.decode(utf8.decode(response.json)), 67 | equals({ 68 | 'all': [ 69 | {'name': 'Alice', 'age': 18} 70 | ] 71 | })); 72 | }); 73 | test("should check if the database contains a non existing data", () async { 74 | String query = """ 75 | query all() { 76 | all(func: eq(name, Bob)) { 77 | name 78 | age 79 | } 80 | } 81 | """; 82 | var response = await txn.Query(clientContext, query); 83 | expect(json.decode(utf8.decode(response.json)), equals({'all': []})); 84 | }); 85 | }); 86 | 87 | group("query with vars -> ", () { 88 | test("should check if the database contains an existing data", () async { 89 | String query = """ 90 | query all(\$a: string) { 91 | all(func: eq(name, \$a)) { 92 | name 93 | age 94 | } 95 | } 96 | """; 97 | var response = 98 | await txn.QueryWithVars(clientContext, query, {"\$a": "Alice"}); 99 | expect( 100 | json.decode(utf8.decode(response.json)), 101 | equals({ 102 | 'all': [ 103 | {'name': 'Alice', 'age': 18} 104 | ] 105 | })); 106 | }); 107 | test("should check if the database contains a non existing data", () async { 108 | String query = """ 109 | query all(\$a: string) { 110 | all(func: eq(name, \$a)) { 111 | name 112 | age 113 | } 114 | } 115 | """; 116 | var response = 117 | await txn.QueryWithVars(clientContext, query, {"\$a": "Bob"}); 118 | expect(json.decode(utf8.decode(response.json)), equals({'all': []})); 119 | }); 120 | }); 121 | 122 | group("query using txn.Do -> ", () { 123 | test("should check if the database contains an existing data", () async { 124 | String query = """ 125 | query all(\$a: string) { 126 | all(func: eq(name, \$a)) { 127 | name 128 | age 129 | } 130 | } 131 | """; 132 | var request = api.Request(); 133 | request.query = query; 134 | request.vars.addAll({"\$a": "Alice"}); 135 | var response = 136 | await (txn.Do(clientContext, request) as Future); 137 | expect( 138 | json.decode(utf8.decode(response.json)), 139 | equals({ 140 | 'all': [ 141 | {'name': 'Alice', 'age': 18} 142 | ] 143 | })); 144 | }); 145 | test("should check if the database contains a non existing data", () async { 146 | String query = """ 147 | query all(\$a: string) { 148 | all(func: eq(name, \$a)) { 149 | name 150 | age 151 | } 152 | } 153 | """; 154 | var request = api.Request(); 155 | request.query = query; 156 | request.vars.addAll({"\$a": "Bob"}); 157 | var response = 158 | await (txn.Do(clientContext, request) as Future); 159 | expect(json.decode(utf8.decode(response.json)), equals({'all': []})); 160 | }); 161 | }); 162 | } 163 | -------------------------------------------------------------------------------- /lib/dgraph.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:grpc/grpc.dart'; 4 | import 'package:mutex/mutex.dart'; 5 | import 'package:protobuf/protobuf.dart'; 6 | import 'protos/api/api.pb.dart' as api; 7 | import 'txn.dart'; 8 | import 'dart:async'; 9 | import 'dart:math'; 10 | 11 | // Dgraph is a transaction aware client to a set of dgraph server instances. 12 | class Dgraph { 13 | late ReadWriteMutex jwtMutex; 14 | late api.Jwt jwt; 15 | List? dc; 16 | 17 | // NewTxn creates a new transaction. 18 | Txn NewTxn() { 19 | return Txn( 20 | dg: this, 21 | dc: anyClient(), 22 | context: api.TxnContext(), 23 | ); 24 | } 25 | 26 | Txn NewReadOnlyTxn() { 27 | Txn txn = NewTxn(); 28 | txn.readOnly = true; 29 | return txn; 30 | } 31 | 32 | Dgraph({this.dc}); 33 | 34 | // Login logs in the current client using the provided credentials. 35 | // Valid for the duration the client is alive. 36 | Future Login(ClientContext ctx, String userid, String password) async { 37 | try { 38 | jwtMutex.acquireWrite(); 39 | 40 | var dc = anyClient()!; 41 | var loginRequest = api.LoginRequest(); 42 | loginRequest.userid = userid; 43 | loginRequest.password = password; 44 | var resp = await dc.login(ctx, loginRequest); 45 | 46 | jwt = api.Jwt.fromJson(utf8.decode(resp.json)); 47 | } catch (e) { 48 | throw e; 49 | } finally { 50 | jwtMutex.release(); 51 | } 52 | } 53 | 54 | // By setting various fields of api.Operation, Alter can be used to do the 55 | // following: 56 | // 57 | // 1. Modify the schema. 58 | // 59 | // 2. Drop a predicate. 60 | // 61 | // 3. Drop the database. 62 | Future Alter(ClientContext ctx, api.Operation op) async { 63 | api.DgraphApi dc = anyClient()!; 64 | await dc.alter(ctx, op); 65 | } 66 | 67 | Future retryLogin(ClientContext ctx) async { 68 | try { 69 | jwtMutex.acquireWrite(); 70 | 71 | if (jwt.refreshJwt.length == 0) { 72 | throw Exception("refresh jwt should not be empty"); 73 | } 74 | 75 | var dc = anyClient()!; 76 | var loginRequest = api.LoginRequest(); 77 | loginRequest.refreshToken = jwt.refreshJwt; 78 | var resp = await dc.login(ctx, loginRequest); 79 | 80 | jwt = api.Jwt.fromJson(utf8.decode(resp.json)); 81 | } catch (e) { 82 | throw e; 83 | } finally { 84 | jwtMutex.release(); 85 | } 86 | } 87 | 88 | ClientContext getContext(ClientContext ctx) { 89 | // TODO: implement 90 | return ctx; 91 | } 92 | 93 | // isJwtExpired returns true if the error indicates that the jwt has expired. 94 | bool isJwtExpired(Exception exception) { 95 | if (exception == null) { 96 | return false; 97 | } 98 | 99 | return exception is GrpcError && 100 | (exception as GrpcError).code == StatusCode.unauthenticated && 101 | exception.toString().contains("Token is expired"); 102 | } 103 | 104 | api.DgraphApi? anyClient() { 105 | return dc![Random().nextInt(dc!.length)]; 106 | } 107 | 108 | // DeleteEdges sets the edges corresponding to predicates on the node with the given uid 109 | // for deletion. 110 | // This helper function doesn't run the mutation on the server. It must be done by the user 111 | // after the function returns. 112 | dynamic get DeleteEdges => DeleteEdges; 113 | } 114 | 115 | _Wrapper dgraph = _Wrapper(); 116 | 117 | class DeleteEdges { 118 | void call(api.Mutation mu, String uid, String predicate) { 119 | api.NQuad nQuad = api.NQuad(); 120 | nQuad.subject = uid; 121 | nQuad.predicate = predicate; 122 | api.Value value = api.Value(); 123 | // _STAR_ALL is defined as x.Star in x package. 124 | value.defaultVal = "_STAR_ALL"; 125 | nQuad.objectValue = value; 126 | mu.del.add(nQuad); 127 | } 128 | 129 | @override 130 | dynamic noSuchMethod(Invocation invocation) { 131 | List args = invocation.positionalArguments; 132 | if (args.length < 3) { 133 | super.noSuchMethod(invocation); 134 | } 135 | api.Mutation? mu = args[0]; 136 | String? uid = args[1]; 137 | List predicates = args.sublist(2, args.length - 1) as List; 138 | predicates.forEach((predicate) { 139 | api.NQuad nQuad = api.NQuad(); 140 | nQuad.subject = uid!; 141 | nQuad.predicate = predicate!; 142 | api.Value value = api.Value(); 143 | // _STAR_ALL is defined as x.Star in x package. 144 | value.defaultVal = "_STAR_ALL"; 145 | nQuad.objectValue = value; 146 | mu!.del.add(nQuad); 147 | }); 148 | } 149 | } 150 | 151 | // NewDgraphClient creates a new Dgraph for interacting with the Dgraph store connected to in 152 | // conns. 153 | // The client can be backed by multiple connections (to the same server, or multiple servers in a 154 | // cluster). 155 | // 156 | // TODO: check "A single client is thread safe for sharing with multiple dart isolates." 157 | class NewDgraphClientFunction { 158 | Dgraph call(api.DgraphApi client) { 159 | return Dgraph( 160 | dc: [client], 161 | ); 162 | } 163 | 164 | @override 165 | dynamic noSuchMethod(Invocation invocation) { 166 | return Dgraph( 167 | dc: invocation.positionalArguments as List?, 168 | ); 169 | } 170 | } 171 | 172 | class _Wrapper { 173 | dynamic get NewDgraphClient => NewDgraphClientFunction(); 174 | } 175 | -------------------------------------------------------------------------------- /lib/txn.dart: -------------------------------------------------------------------------------- 1 | import 'package:grpc/grpc.dart'; 2 | import 'package:protobuf/protobuf.dart'; 3 | import 'dgraph.dart'; 4 | import 'protos/api/api.pb.dart' as api; 5 | import 'y/y.dart'; 6 | import 'dart:async'; 7 | 8 | // Txn is a single atomic transaction. 9 | // 10 | // A transaction lifecycle is as follows: 11 | // 12 | // 1. Created using NewTxn. 13 | // 14 | // 2. Various Query and Mutate calls made. 15 | // 16 | // 3. Commit or Discard used. If any mutations have been made, It's important 17 | // that at least one of these methods is called to clean up resources. Discard 18 | // is a no-op if Commit has already been called, so it's safe to defer a call 19 | // to Discard immediately after NewTxn. 20 | class Txn { 21 | api.TxnContext? context; 22 | 23 | bool finished = false; 24 | bool mutated = false; 25 | bool readOnly = false; 26 | 27 | Dgraph? dg; 28 | api.DgraphApi? dc; 29 | 30 | static const ErrFinished = 31 | "Transaction has already been committed or discarded"; 32 | static const ErrReadOnly = 33 | "Readonly transaction cannot run mutations or be committed"; 34 | 35 | Txn({this.dg, this.dc, this.context}); 36 | 37 | // Query sends a query to one of the connected dgraph instances. If no 38 | // mutations need to be made in the same transaction, it's convenient to chain 39 | // the method, e.g. NewTxn().Query(ctx, "..."). 40 | Future Query(ClientContext ctx, String q) async { 41 | return await QueryWithVars(ctx, q, null); 42 | } 43 | 44 | // QueryWithVars is like Query, but allows a variable map to be used. This can 45 | // provide safety against injection attacks. 46 | Future QueryWithVars( 47 | ClientContext ctx, String q, Map? vars) async { 48 | if (finished) { 49 | throw ErrFinished; 50 | } 51 | api.Request req = api.Request(); 52 | req.query = q; 53 | if (vars != null) { 54 | req.vars.addAll(vars); 55 | } 56 | req.startTs = context!.startTs; 57 | req.readOnly = readOnly; 58 | api.Response resp; 59 | resp = await dc!.query(ctx, req); 60 | mergeContext(resp.txn); 61 | return resp; 62 | } 63 | 64 | void mergeContext(api.TxnContext src) { 65 | if (src != null) { 66 | if (context!.startTs == 0) { 67 | context!.startTs = src.startTs; 68 | } 69 | if (context!.startTs != src.startTs) { 70 | throw Exception("StartTs mismatch"); 71 | } 72 | context!.keys.addAll(src.keys); 73 | context!.preds.addAll(src.preds); 74 | } 75 | } 76 | 77 | // Mutate allows data stored on dgraph instances to be modified. The fields in 78 | // api.Mutation come in pairs, set and delete. Mutations can either be 79 | // encoded as JSON or as RDFs. 80 | // 81 | // If CommitNow is set, then this call will result in the transaction 82 | // being committed. In this case, an explicit call to Commit doesn't need to 83 | // subsequently be made. 84 | // 85 | // If the mutation fails, then the transaction is discarded and all future 86 | // operations on it will fail. 87 | Future Mutate(ClientContext ctx, api.Request req) async { 88 | if (readOnly) { 89 | throw ErrReadOnly; 90 | } 91 | if (finished) { 92 | throw ErrFinished; 93 | } 94 | mutated = true; 95 | req.startTs = context!.startTs; 96 | api.Response? res; 97 | try { 98 | res = await dc!.query(ctx, req); 99 | if (req.commitNow) { 100 | finished = true; 101 | } 102 | mergeContext(res.txn); 103 | } on GrpcError catch (e) { 104 | // Since a mutation error occurred, the txn should no longer be used 105 | // (some mutations could have applied but not others, but we don't know 106 | // which ones). Discarding the transaction enforces that the user 107 | // cannot use the txn further. 108 | try { 109 | await Discard(ctx); 110 | } catch (e) { 111 | // Ignore error - user should see the original error. 112 | } 113 | // Transaction could be aborted(codes.Aborted) if CommitNow was true, or server could send a 114 | // message that this mutation conflicts(codes.FailedPrecondition) with another transaction. 115 | int s = e.code; 116 | if ((s == StatusCode.aborted) || (s == StatusCode.failedPrecondition)) { 117 | throw ErrAborted; 118 | } 119 | } finally { 120 | res ??= api.Response(); 121 | return res; 122 | } 123 | } 124 | 125 | // Do executes a query followed by one or more than one mutations. 126 | Future Do(ClientContext ctx, api.Request req) async { 127 | if (finished) { 128 | throw ErrFinished; 129 | } 130 | if (req.mutations.length > 0) { 131 | if (readOnly) { 132 | throw ErrReadOnly; 133 | } 134 | mutated = true; 135 | } 136 | 137 | ctx = dg!.getContext(ctx); 138 | req.startTs = context!.startTs; 139 | api.Response? resp; 140 | 141 | var exception; 142 | try { 143 | resp = await dc!.query(ctx, req); 144 | 145 | if (req.commitNow) { 146 | finished = true; 147 | } 148 | 149 | mergeContext(resp.txn); 150 | } catch (e) { 151 | if (e is Exception) if (dg!.isJwtExpired(e)) { 152 | try { 153 | dg!.retryLogin(ctx); 154 | } catch (e) { 155 | throw e; 156 | } 157 | 158 | ctx = dg!.getContext(ctx); 159 | try { 160 | resp = await dc!.query(ctx, req); 161 | } catch (e) { 162 | exception = e; 163 | } 164 | } 165 | } finally { 166 | if (req.mutations.length > 0) { 167 | // Ignore error, user should see the original error. 168 | Discard(ctx); 169 | 170 | // If the transaction was aborted, return the right error 171 | // so the caller can handle it. 172 | if (exception != null) { 173 | if (exception.code == StatusCode.aborted) { 174 | throw ErrAborted; 175 | } 176 | } 177 | } 178 | if (exception != null) { 179 | throw exception; 180 | } 181 | } 182 | resp ??= api.Response(); 183 | return resp; 184 | } 185 | 186 | // Commit commits any mutations that have been made in the transaction. Once 187 | // Commit has been called, the lifespan of the transaction is complete. 188 | // 189 | // Errors could be returned for various reasons. Notably, ErrAborted could be 190 | // returned if transactions that modify the same data are being run 191 | // concurrently. It's up to the user to decide if they wish to retry. In this 192 | // case, the user should create a new transaction. 193 | Future Commit(ClientContext ctx) async { 194 | if (readOnly) { 195 | throw ErrReadOnly; 196 | } else if (finished) { 197 | throw ErrFinished; 198 | } else { 199 | try { 200 | await dc!.commitOrAbort(ctx, context!); 201 | } on GrpcError catch (e) { 202 | if (e.code == StatusCode.aborted) { 203 | throw ErrAborted; 204 | } 205 | } 206 | } 207 | } 208 | 209 | // Discard cleans up the resources associated with an uncommitted transaction 210 | // that contains mutations. It is a no-op on transactions that have already 211 | // been committed or don't contain mutations. Therefore it is safe (and 212 | // recommended) to call as a deferred function immediately after a new 213 | // transaction is created. 214 | // 215 | // In some cases, the transaction can't be discarded, e.g. the grpc connection 216 | // is unavailable. In these cases, the server will eventually do the 217 | // transaction clean up. 218 | Future Discard(ClientContext ctx) async { 219 | context!.aborted = true; 220 | await dc!.commitOrAbort(ctx, context!); 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://app.travis-ci.com/marceloneppel/dgraph.svg?branch=master)](https://app.travis-ci.com/github/marceloneppel/dgraph) 2 | 3 | # dgraph 4 | [Dgraph](https://dgraph.io) Dart client which communicates with the server using [gRPC](https://grpc.io/). 5 | 6 | Before using this client, we highly recommend that you go through [tour.dgraph.io] and [docs.dgraph.io] 7 | to understand how to run and work with Dgraph. 8 | 9 | [docs.dgraph.io]:https://docs.dgraph.io 10 | [tour.dgraph.io]:https://tour.dgraph.io 11 | 12 | 13 | ## Table of contents 14 | 15 | - [Supported Versions](#supported-versions) 16 | - [Using a client](#using-a-client) 17 | - [Creating a client](#creating-a-client) 18 | - [Altering the database](#altering-the-database) 19 | - [Creating a transaction](#creating-a-transaction) 20 | - [Running a mutation](#running-a-mutation) 21 | - [Running a query](#running-a-query) 22 | - [Committing a transaction](#committing-a-transaction) 23 | - [Development](#development) 24 | - [Running tests](#running-tests) 25 | - [Updating protobuf](#updating-protobuf) 26 | 27 | ## Supported Versions 28 | 29 | Depending on the version of Dgraph that you are connecting to, you will have to 30 | use a different version of this client. 31 | 32 | | Dgraph version | dgraph client version | 33 | |:--------------:|:---------------------:| 34 | | dgraph 1.0.X | dgraph client 0.5.0 | 35 | | dgraph 1.1.X | dgraph client 1.1.X | 36 | 37 | Note: One of the most important API breakages from dgraph client v0.5.0 to v1.1.X is in 38 | the function `Txn.Mutate`. This function returns an `api.Assigned` 39 | value until v0.5.0 but an `api.Response` in v1.1.X. 40 | 41 | ## Using a client 42 | 43 | ### Create a client 44 | 45 | `dgraphClient` object can be initialised by passing it a list of `api.DgraphApi` clients as 46 | variadic arguments. Connecting to multiple Dgraph servers in the same cluster allows for better 47 | distribution of workload. 48 | 49 | The following code snippet shows just one connection. 50 | 51 | ```dart 52 | DgraphRpcClient rpcClient = 53 | DgraphRpcClient("localhost", 9080, const ChannelCredentials.insecure()); 54 | Dgraph dgraphClient = dgraph.NewDgraphClient(api.DgraphApi(rpcClient)); 55 | ``` 56 | 57 | ### Altering the database 58 | 59 | To set the schema, create an instance of `api.Operation` and use the `Alter` endpoint. 60 | 61 | ```dart 62 | api.Operation operation = api.Operation(); 63 | operation.schema = """ 64 | name: string @index(exact) . 65 | """; 66 | await dgraphClient.Alter(clientContext, operation); 67 | ``` 68 | 69 | `Operation` contains other fields as well, including `dropAttr` and `dropAll`. 70 | `dropAll` is useful if you wish to discard all the data, and start from a clean 71 | slate, without bringing the instance down. `dropAttr` is used to drop all the data 72 | related to a predicate. 73 | 74 | ### Creating a transaction 75 | 76 | To create a transaction, call `dgraphClient.NewTxn()`, which returns a `Txn` object. This 77 | operation incurs no network overhead. 78 | 79 | It is a good practice to call `txn.Discard()` on a finally block after it is initialized. 80 | Calling `txn.Discard()` after `txn.Commit()` is a no-op and you can call `txn.Discard()` multiple 81 | times with no additional side-effects. 82 | 83 | ```dart 84 | Txn txn; 85 | ClientContext clientContext = ClientContext(); 86 | try { 87 | txn = dgraphClient.NewTxn(); 88 | // Perform some queries and mutations. 89 | // Commit the transaction. 90 | } finally { 91 | txn.Discard(clientContext); 92 | } 93 | ``` 94 | 95 | Read-only transactions can be created by calling `dgraphClient.NewReadOnlyTxn()`. Read-only 96 | transactions are useful to increase read speed because they can circumvent the 97 | usual consensus protocol. Read-only transactions cannot contain mutations and 98 | trying to call `txn.Commit()` will result in an error. Calling `txn.Discard()` 99 | will be a no-op. 100 | 101 | ### Running a mutation 102 | 103 | `txn.Mutate(clientContext, mutation)` runs a mutation. It takes in a `ClientContext` and a `api.Mutation` 104 | object. You can set the data using JSON or RDF N-Quad format. 105 | 106 | To use JSON, use the fields setJson and deleteJson, which accept an encoded string 107 | representing the nodes to be added or removed respectively (either as a JSON map 108 | or a list). To use RDF, use the fields setNquads and delNquads, which accept 109 | a string representing the valid RDF triples (one per line) to added or removed 110 | respectively. This protobuf object also contains the set and del fields which 111 | accept a list of RDF triples that have already been parsed into our internal 112 | format. As such, these fields are mainly used internally and users should use 113 | the setNquads and delNquads instead if they are planning on using RDF. 114 | 115 | We define a Map to represent a Person and convert an instance of it to use with `Mutation` 116 | object. 117 | ```dart 118 | Map p = { 119 | "uid": "_:alice", 120 | "name": "Alice", 121 | }; 122 | List pb = utf8.encode(json.encode(p)); 123 | api.Mutation mutation = api.Mutation(); 124 | mutation.setJson = pb; 125 | api.Request request = api.Request(); 126 | request.mutations.add(mutation); 127 | api.Response response = await txn.Mutate(clientContext, request); 128 | print("Response: ${response.uids}"); 129 | // {alice: 0x5} 130 | ``` 131 | 132 | Sometimes, you only want to commit a mutation, without querying anything further. 133 | In such cases, you can use `mutation.commitNow = true` to indicate that the 134 | mutation must be immediately committed. 135 | 136 | ### Running a query 137 | 138 | You can run a query by calling `txn.Query(clientContext, query)`. You will need to pass in a GraphQL+- query string. If 139 | you want to pass an additional map of any variables that you might want to set in the query, call 140 | `txn.QueryWithVars(clientContext, query, vars)` with the variables map as third argument. 141 | 142 | Let's run the following query with a variable $a: 143 | ```dart 144 | String query = """ 145 | query all(\$a: string) { 146 | all(func: eq(name, \$a)) { 147 | name 148 | } 149 | } 150 | """; 151 | api.Response response = 152 | await txn.QueryWithVars(clientContext, query, {"\$a": "Alice"}); 153 | print("Response: ${utf8.decode(response.json)}"); 154 | // {"all":[{"name":"Alice"}]} 155 | ``` 156 | 157 | You can also use `txn.Do` function to run a query. 158 | 159 | ```dart 160 | request = api.Request(); 161 | request.query = query; 162 | request.vars.addAll({"\$a": "Alice"}); 163 | response = await txn.Do(clientContext, request); 164 | print("Response: ${utf8.decode(response.json)}"); 165 | // {"all":[{"name":"Alice"}]} 166 | ``` 167 | 168 | When running a schema query for predicate `name`, the schema response is found 169 | in the `json` field of `api.Response` as shown below: 170 | 171 | ```dart 172 | String query = """ 173 | schema(pred: [name]) { 174 | type 175 | index 176 | reverse 177 | tokenizer 178 | list 179 | count 180 | upsert 181 | lang 182 | } 183 | """; 184 | api.Response response = await txn.Query(clientContext, query); 185 | print("Response: ${utf8.decode(response.json)}"); 186 | // {"schema":[{"predicate":"name","type":"string","index":true,"tokenizer":["exact"]}]} 187 | ``` 188 | 189 | ### Committing a transaction 190 | 191 | A transaction can be committed using the `txn.Commit(clientContext)` method. If your transaction 192 | consisted solely of calls to `txn.Query` or `txn.QueryWithVars`, and no calls to 193 | `txn.Mutate`, then calling `txn.Commit` is not necessary. 194 | 195 | An error will be returned if other transactions running concurrently modify the same 196 | data that was modified in this transaction. It is up to the user to retry 197 | transactions when they fail. 198 | 199 | ```dart 200 | Txn txn; 201 | ClientContext clientContext = ClientContext(); 202 | try { 203 | txn = dgraphClient.NewTxn(); 204 | // Perform some queries and mutations. 205 | txn.Commit(clientContext); 206 | } catch (e) { 207 | // Retry or handle error 208 | } 209 | ``` 210 | 211 | ## Development 212 | 213 | ### Running tests 214 | 215 | Make sure you have `dgraph` installed before you run the tests. This script will run the unit tests. 216 | 217 | ```sh 218 | pub run test --concurrency=1 219 | ``` 220 | 221 | ### Updating protobuf 222 | 223 | To update protobuf execute the following command from the project root: 224 | 225 | ```sh 226 | bash lib/protos/api/regenerate-proto.sh 227 | ``` 228 | -------------------------------------------------------------------------------- /lib/protos/api/api.pbjson.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: api.proto 4 | // 5 | 6 | // ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type 7 | 8 | const Request$json = { 9 | '1': 'Request', 10 | '2': [ 11 | {'1': 'start_ts', '3': 1, '4': 1, '5': 4, '10': 'startTs'}, 12 | {'1': 'query', '3': 4, '4': 1, '5': 9, '10': 'query'}, 13 | { 14 | '1': 'vars', 15 | '3': 5, 16 | '4': 3, 17 | '5': 11, 18 | '6': '.api.Request.VarsEntry', 19 | '10': 'vars' 20 | }, 21 | {'1': 'read_only', '3': 6, '4': 1, '5': 8, '10': 'readOnly'}, 22 | {'1': 'best_effort', '3': 7, '4': 1, '5': 8, '10': 'bestEffort'}, 23 | { 24 | '1': 'mutations', 25 | '3': 12, 26 | '4': 3, 27 | '5': 11, 28 | '6': '.api.Mutation', 29 | '10': 'mutations' 30 | }, 31 | {'1': 'commit_now', '3': 13, '4': 1, '5': 8, '10': 'commitNow'}, 32 | ], 33 | '3': [Request_VarsEntry$json], 34 | }; 35 | 36 | const Request_VarsEntry$json = { 37 | '1': 'VarsEntry', 38 | '2': [ 39 | {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, 40 | {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, 41 | ], 42 | '7': {'7': true}, 43 | }; 44 | 45 | const Uids$json = { 46 | '1': 'Uids', 47 | '2': [ 48 | {'1': 'uids', '3': 1, '4': 3, '5': 9, '10': 'uids'}, 49 | ], 50 | }; 51 | 52 | const Response$json = { 53 | '1': 'Response', 54 | '2': [ 55 | {'1': 'json', '3': 1, '4': 1, '5': 12, '10': 'json'}, 56 | {'1': 'txn', '3': 2, '4': 1, '5': 11, '6': '.api.TxnContext', '10': 'txn'}, 57 | { 58 | '1': 'latency', 59 | '3': 3, 60 | '4': 1, 61 | '5': 11, 62 | '6': '.api.Latency', 63 | '10': 'latency' 64 | }, 65 | { 66 | '1': 'metrics', 67 | '3': 4, 68 | '4': 1, 69 | '5': 11, 70 | '6': '.api.Metrics', 71 | '10': 'metrics' 72 | }, 73 | { 74 | '1': 'uids', 75 | '3': 12, 76 | '4': 3, 77 | '5': 11, 78 | '6': '.api.Response.UidsEntry', 79 | '10': 'uids' 80 | }, 81 | ], 82 | '3': [Response_UidsEntry$json], 83 | }; 84 | 85 | const Response_UidsEntry$json = { 86 | '1': 'UidsEntry', 87 | '2': [ 88 | {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, 89 | {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, 90 | ], 91 | '7': {'7': true}, 92 | }; 93 | 94 | const Mutation$json = { 95 | '1': 'Mutation', 96 | '2': [ 97 | {'1': 'set_json', '3': 1, '4': 1, '5': 12, '10': 'setJson'}, 98 | {'1': 'delete_json', '3': 2, '4': 1, '5': 12, '10': 'deleteJson'}, 99 | {'1': 'set_nquads', '3': 3, '4': 1, '5': 12, '10': 'setNquads'}, 100 | {'1': 'del_nquads', '3': 4, '4': 1, '5': 12, '10': 'delNquads'}, 101 | {'1': 'set', '3': 5, '4': 3, '5': 11, '6': '.api.NQuad', '10': 'set'}, 102 | {'1': 'del', '3': 6, '4': 3, '5': 11, '6': '.api.NQuad', '10': 'del'}, 103 | {'1': 'cond', '3': 9, '4': 1, '5': 9, '10': 'cond'}, 104 | {'1': 'commit_now', '3': 14, '4': 1, '5': 8, '10': 'commitNow'}, 105 | ], 106 | }; 107 | 108 | const Operation$json = { 109 | '1': 'Operation', 110 | '2': [ 111 | {'1': 'schema', '3': 1, '4': 1, '5': 9, '10': 'schema'}, 112 | {'1': 'drop_attr', '3': 2, '4': 1, '5': 9, '10': 'dropAttr'}, 113 | {'1': 'drop_all', '3': 3, '4': 1, '5': 8, '10': 'dropAll'}, 114 | { 115 | '1': 'drop_op', 116 | '3': 4, 117 | '4': 1, 118 | '5': 14, 119 | '6': '.api.Operation.DropOp', 120 | '10': 'dropOp' 121 | }, 122 | {'1': 'drop_value', '3': 5, '4': 1, '5': 9, '10': 'dropValue'}, 123 | ], 124 | '4': [Operation_DropOp$json], 125 | }; 126 | 127 | const Operation_DropOp$json = { 128 | '1': 'DropOp', 129 | '2': [ 130 | {'1': 'NONE', '2': 0}, 131 | {'1': 'ALL', '2': 1}, 132 | {'1': 'DATA', '2': 2}, 133 | {'1': 'ATTR', '2': 3}, 134 | {'1': 'TYPE', '2': 4}, 135 | ], 136 | }; 137 | 138 | const Payload$json = { 139 | '1': 'Payload', 140 | '2': [ 141 | {'1': 'Data', '3': 1, '4': 1, '5': 12, '10': 'data'}, 142 | ], 143 | }; 144 | 145 | const TxnContext$json = { 146 | '1': 'TxnContext', 147 | '2': [ 148 | {'1': 'start_ts', '3': 1, '4': 1, '5': 4, '10': 'startTs'}, 149 | {'1': 'commit_ts', '3': 2, '4': 1, '5': 4, '10': 'commitTs'}, 150 | {'1': 'aborted', '3': 3, '4': 1, '5': 8, '10': 'aborted'}, 151 | {'1': 'keys', '3': 4, '4': 3, '5': 9, '10': 'keys'}, 152 | {'1': 'preds', '3': 5, '4': 3, '5': 9, '10': 'preds'}, 153 | ], 154 | }; 155 | 156 | const Check$json = { 157 | '1': 'Check', 158 | }; 159 | 160 | const Version$json = { 161 | '1': 'Version', 162 | '2': [ 163 | {'1': 'tag', '3': 1, '4': 1, '5': 9, '10': 'tag'}, 164 | ], 165 | }; 166 | 167 | const Latency$json = { 168 | '1': 'Latency', 169 | '2': [ 170 | {'1': 'parsing_ns', '3': 1, '4': 1, '5': 4, '10': 'parsingNs'}, 171 | {'1': 'processing_ns', '3': 2, '4': 1, '5': 4, '10': 'processingNs'}, 172 | {'1': 'encoding_ns', '3': 3, '4': 1, '5': 4, '10': 'encodingNs'}, 173 | { 174 | '1': 'assign_timestamp_ns', 175 | '3': 4, 176 | '4': 1, 177 | '5': 4, 178 | '10': 'assignTimestampNs' 179 | }, 180 | {'1': 'total_ns', '3': 5, '4': 1, '5': 4, '10': 'totalNs'}, 181 | ], 182 | }; 183 | 184 | const Metrics$json = { 185 | '1': 'Metrics', 186 | '2': [ 187 | { 188 | '1': 'num_uids', 189 | '3': 1, 190 | '4': 3, 191 | '5': 11, 192 | '6': '.api.Metrics.NumUidsEntry', 193 | '10': 'numUids' 194 | }, 195 | ], 196 | '3': [Metrics_NumUidsEntry$json], 197 | }; 198 | 199 | const Metrics_NumUidsEntry$json = { 200 | '1': 'NumUidsEntry', 201 | '2': [ 202 | {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, 203 | {'1': 'value', '3': 2, '4': 1, '5': 4, '10': 'value'}, 204 | ], 205 | '7': {'7': true}, 206 | }; 207 | 208 | const NQuad$json = { 209 | '1': 'NQuad', 210 | '2': [ 211 | {'1': 'subject', '3': 1, '4': 1, '5': 9, '10': 'subject'}, 212 | {'1': 'predicate', '3': 2, '4': 1, '5': 9, '10': 'predicate'}, 213 | {'1': 'object_id', '3': 3, '4': 1, '5': 9, '10': 'objectId'}, 214 | { 215 | '1': 'object_value', 216 | '3': 4, 217 | '4': 1, 218 | '5': 11, 219 | '6': '.api.Value', 220 | '10': 'objectValue' 221 | }, 222 | {'1': 'label', '3': 5, '4': 1, '5': 9, '10': 'label'}, 223 | {'1': 'lang', '3': 6, '4': 1, '5': 9, '10': 'lang'}, 224 | {'1': 'facets', '3': 7, '4': 3, '5': 11, '6': '.api.Facet', '10': 'facets'}, 225 | ], 226 | }; 227 | 228 | const Value$json = { 229 | '1': 'Value', 230 | '2': [ 231 | {'1': 'default_val', '3': 1, '4': 1, '5': 9, '9': 0, '10': 'defaultVal'}, 232 | {'1': 'bytes_val', '3': 2, '4': 1, '5': 12, '9': 0, '10': 'bytesVal'}, 233 | {'1': 'int_val', '3': 3, '4': 1, '5': 3, '9': 0, '10': 'intVal'}, 234 | {'1': 'bool_val', '3': 4, '4': 1, '5': 8, '9': 0, '10': 'boolVal'}, 235 | {'1': 'str_val', '3': 5, '4': 1, '5': 9, '9': 0, '10': 'strVal'}, 236 | {'1': 'double_val', '3': 6, '4': 1, '5': 1, '9': 0, '10': 'doubleVal'}, 237 | {'1': 'geo_val', '3': 7, '4': 1, '5': 12, '9': 0, '10': 'geoVal'}, 238 | {'1': 'date_val', '3': 8, '4': 1, '5': 12, '9': 0, '10': 'dateVal'}, 239 | {'1': 'datetime_val', '3': 9, '4': 1, '5': 12, '9': 0, '10': 'datetimeVal'}, 240 | {'1': 'password_val', '3': 10, '4': 1, '5': 9, '9': 0, '10': 'passwordVal'}, 241 | {'1': 'uid_val', '3': 11, '4': 1, '5': 4, '9': 0, '10': 'uidVal'}, 242 | ], 243 | '8': [ 244 | {'1': 'val'}, 245 | ], 246 | }; 247 | 248 | const Facet$json = { 249 | '1': 'Facet', 250 | '2': [ 251 | {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, 252 | {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, 253 | { 254 | '1': 'val_type', 255 | '3': 3, 256 | '4': 1, 257 | '5': 14, 258 | '6': '.api.Facet.ValType', 259 | '10': 'valType' 260 | }, 261 | {'1': 'tokens', '3': 4, '4': 3, '5': 9, '10': 'tokens'}, 262 | {'1': 'alias', '3': 5, '4': 1, '5': 9, '10': 'alias'}, 263 | ], 264 | '4': [Facet_ValType$json], 265 | }; 266 | 267 | const Facet_ValType$json = { 268 | '1': 'ValType', 269 | '2': [ 270 | {'1': 'STRING', '2': 0}, 271 | {'1': 'INT', '2': 1}, 272 | {'1': 'FLOAT', '2': 2}, 273 | {'1': 'BOOL', '2': 3}, 274 | {'1': 'DATETIME', '2': 4}, 275 | ], 276 | }; 277 | 278 | const LoginRequest$json = { 279 | '1': 'LoginRequest', 280 | '2': [ 281 | {'1': 'userid', '3': 1, '4': 1, '5': 9, '10': 'userid'}, 282 | {'1': 'password', '3': 2, '4': 1, '5': 9, '10': 'password'}, 283 | {'1': 'refresh_token', '3': 3, '4': 1, '5': 9, '10': 'refreshToken'}, 284 | ], 285 | }; 286 | 287 | const Jwt$json = { 288 | '1': 'Jwt', 289 | '2': [ 290 | {'1': 'access_jwt', '3': 1, '4': 1, '5': 9, '10': 'accessJwt'}, 291 | {'1': 'refresh_jwt', '3': 2, '4': 1, '5': 9, '10': 'refreshJwt'}, 292 | ], 293 | }; 294 | 295 | const DgraphServiceBase$json = { 296 | '1': 'Dgraph', 297 | '2': [ 298 | {'1': 'Login', '2': '.api.LoginRequest', '3': '.api.Response', '4': {}}, 299 | {'1': 'Query', '2': '.api.Request', '3': '.api.Response', '4': {}}, 300 | {'1': 'Alter', '2': '.api.Operation', '3': '.api.Payload', '4': {}}, 301 | { 302 | '1': 'CommitOrAbort', 303 | '2': '.api.TxnContext', 304 | '3': '.api.TxnContext', 305 | '4': {} 306 | }, 307 | {'1': 'CheckVersion', '2': '.api.Check', '3': '.api.Version', '4': {}}, 308 | ], 309 | }; 310 | 311 | const DgraphServiceBase$messageJson = { 312 | '.api.LoginRequest': LoginRequest$json, 313 | '.api.Response': Response$json, 314 | '.api.TxnContext': TxnContext$json, 315 | '.api.Latency': Latency$json, 316 | '.api.Metrics': Metrics$json, 317 | '.api.Metrics.NumUidsEntry': Metrics_NumUidsEntry$json, 318 | '.api.Response.UidsEntry': Response_UidsEntry$json, 319 | '.api.Request': Request$json, 320 | '.api.Request.VarsEntry': Request_VarsEntry$json, 321 | '.api.Mutation': Mutation$json, 322 | '.api.NQuad': NQuad$json, 323 | '.api.Value': Value$json, 324 | '.api.Facet': Facet$json, 325 | '.api.Operation': Operation$json, 326 | '.api.Payload': Payload$json, 327 | '.api.Check': Check$json, 328 | '.api.Version': Version$json, 329 | }; 330 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2018 Marcelo Henrique Neppel 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /lib/protos/api/api.pb.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: api.proto 4 | // 5 | 6 | // ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type 7 | 8 | import 'dart:async' as $async; 9 | import 'dart:core' as $core; 10 | 11 | import 'package:fixnum/fixnum.dart' as $fixnum; 12 | import 'package:protobuf/protobuf.dart' as $pb; 13 | 14 | import 'api.pbenum.dart'; 15 | 16 | export 'api.pbenum.dart'; 17 | 18 | class Request extends $pb.GeneratedMessage { 19 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Request', 20 | package: const $pb.PackageName('api'), createEmptyInstance: create) 21 | ..a<$fixnum.Int64>(1, 'startTs', $pb.PbFieldType.OU6, 22 | defaultOrMaker: $fixnum.Int64.ZERO) 23 | ..aOS(4, 'query') 24 | ..m<$core.String, $core.String>(5, 'vars', 25 | entryClassName: 'Request.VarsEntry', 26 | keyFieldType: $pb.PbFieldType.OS, 27 | valueFieldType: $pb.PbFieldType.OS, 28 | packageName: const $pb.PackageName('api')) 29 | ..aOB(6, 'readOnly') 30 | ..aOB(7, 'bestEffort') 31 | ..pc(12, 'mutations', $pb.PbFieldType.PM, 32 | subBuilder: Mutation.create) 33 | ..aOB(13, 'commitNow') 34 | ..hasRequiredFields = false; 35 | 36 | Request._() : super(); 37 | factory Request() => create(); 38 | factory Request.fromBuffer($core.List<$core.int> i, 39 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 40 | create()..mergeFromBuffer(i, r); 41 | factory Request.fromJson($core.String i, 42 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 43 | create()..mergeFromJson(i, r); 44 | Request clone() => Request()..mergeFromMessage(this); 45 | Request copyWith(void Function(Request) updates) => 46 | super.copyWith((message) => updates(message as Request)) as Request; 47 | $pb.BuilderInfo get info_ => _i; 48 | @$core.pragma('dart2js:noInline') 49 | static Request create() => Request._(); 50 | Request createEmptyInstance() => create(); 51 | static $pb.PbList createRepeated() => $pb.PbList(); 52 | @$core.pragma('dart2js:noInline') 53 | static Request getDefault() => 54 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 55 | static Request? _defaultInstance; 56 | 57 | @$pb.TagNumber(1) 58 | $fixnum.Int64 get startTs => $_getI64(0); 59 | @$pb.TagNumber(1) 60 | set startTs($fixnum.Int64 v) { 61 | $_setInt64(0, v); 62 | } 63 | 64 | @$pb.TagNumber(1) 65 | $core.bool hasStartTs() => $_has(0); 66 | @$pb.TagNumber(1) 67 | void clearStartTs() => clearField(1); 68 | 69 | @$pb.TagNumber(4) 70 | $core.String get query => $_getSZ(1); 71 | @$pb.TagNumber(4) 72 | set query($core.String v) { 73 | $_setString(1, v); 74 | } 75 | 76 | @$pb.TagNumber(4) 77 | $core.bool hasQuery() => $_has(1); 78 | @$pb.TagNumber(4) 79 | void clearQuery() => clearField(4); 80 | 81 | @$pb.TagNumber(5) 82 | $core.Map<$core.String, $core.String> get vars => $_getMap(2); 83 | 84 | @$pb.TagNumber(6) 85 | $core.bool get readOnly => $_getBF(3); 86 | @$pb.TagNumber(6) 87 | set readOnly($core.bool v) { 88 | $_setBool(3, v); 89 | } 90 | 91 | @$pb.TagNumber(6) 92 | $core.bool hasReadOnly() => $_has(3); 93 | @$pb.TagNumber(6) 94 | void clearReadOnly() => clearField(6); 95 | 96 | @$pb.TagNumber(7) 97 | $core.bool get bestEffort => $_getBF(4); 98 | @$pb.TagNumber(7) 99 | set bestEffort($core.bool v) { 100 | $_setBool(4, v); 101 | } 102 | 103 | @$pb.TagNumber(7) 104 | $core.bool hasBestEffort() => $_has(4); 105 | @$pb.TagNumber(7) 106 | void clearBestEffort() => clearField(7); 107 | 108 | @$pb.TagNumber(12) 109 | $core.List get mutations => $_getList(5); 110 | 111 | @$pb.TagNumber(13) 112 | $core.bool get commitNow => $_getBF(6); 113 | @$pb.TagNumber(13) 114 | set commitNow($core.bool v) { 115 | $_setBool(6, v); 116 | } 117 | 118 | @$pb.TagNumber(13) 119 | $core.bool hasCommitNow() => $_has(6); 120 | @$pb.TagNumber(13) 121 | void clearCommitNow() => clearField(13); 122 | } 123 | 124 | class Uids extends $pb.GeneratedMessage { 125 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Uids', 126 | package: const $pb.PackageName('api'), createEmptyInstance: create) 127 | ..pPS(1, 'uids') 128 | ..hasRequiredFields = false; 129 | 130 | Uids._() : super(); 131 | factory Uids() => create(); 132 | factory Uids.fromBuffer($core.List<$core.int> i, 133 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 134 | create()..mergeFromBuffer(i, r); 135 | factory Uids.fromJson($core.String i, 136 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 137 | create()..mergeFromJson(i, r); 138 | Uids clone() => Uids()..mergeFromMessage(this); 139 | Uids copyWith(void Function(Uids) updates) => 140 | super.copyWith((message) => updates(message as Uids)) as Uids; 141 | $pb.BuilderInfo get info_ => _i; 142 | @$core.pragma('dart2js:noInline') 143 | static Uids create() => Uids._(); 144 | Uids createEmptyInstance() => create(); 145 | static $pb.PbList createRepeated() => $pb.PbList(); 146 | @$core.pragma('dart2js:noInline') 147 | static Uids getDefault() => 148 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 149 | static Uids? _defaultInstance; 150 | 151 | @$pb.TagNumber(1) 152 | $core.List<$core.String> get uids => $_getList(0); 153 | } 154 | 155 | class Response extends $pb.GeneratedMessage { 156 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Response', 157 | package: const $pb.PackageName('api'), createEmptyInstance: create) 158 | ..a<$core.List<$core.int>>(1, 'json', $pb.PbFieldType.OY) 159 | ..aOM(2, 'txn', subBuilder: TxnContext.create) 160 | ..aOM(3, 'latency', subBuilder: Latency.create) 161 | ..aOM(4, 'metrics', subBuilder: Metrics.create) 162 | ..m<$core.String, $core.String>(12, 'uids', 163 | entryClassName: 'Response.UidsEntry', 164 | keyFieldType: $pb.PbFieldType.OS, 165 | valueFieldType: $pb.PbFieldType.OS, 166 | packageName: const $pb.PackageName('api')) 167 | ..hasRequiredFields = false; 168 | 169 | Response._() : super(); 170 | factory Response() => create(); 171 | factory Response.fromBuffer($core.List<$core.int> i, 172 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 173 | create()..mergeFromBuffer(i, r); 174 | factory Response.fromJson($core.String i, 175 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 176 | create()..mergeFromJson(i, r); 177 | Response clone() => Response()..mergeFromMessage(this); 178 | Response copyWith(void Function(Response) updates) => 179 | super.copyWith((message) => updates(message as Response)) as Response; 180 | $pb.BuilderInfo get info_ => _i; 181 | @$core.pragma('dart2js:noInline') 182 | static Response create() => Response._(); 183 | Response createEmptyInstance() => create(); 184 | static $pb.PbList createRepeated() => $pb.PbList(); 185 | @$core.pragma('dart2js:noInline') 186 | static Response getDefault() => 187 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 188 | static Response? _defaultInstance; 189 | 190 | @$pb.TagNumber(1) 191 | $core.List<$core.int> get json => $_getN(0); 192 | @$pb.TagNumber(1) 193 | set json($core.List<$core.int> v) { 194 | $_setBytes(0, v); 195 | } 196 | 197 | @$pb.TagNumber(1) 198 | $core.bool hasJson() => $_has(0); 199 | @$pb.TagNumber(1) 200 | void clearJson() => clearField(1); 201 | 202 | @$pb.TagNumber(2) 203 | TxnContext get txn => $_getN(1); 204 | @$pb.TagNumber(2) 205 | set txn(TxnContext v) { 206 | setField(2, v); 207 | } 208 | 209 | @$pb.TagNumber(2) 210 | $core.bool hasTxn() => $_has(1); 211 | @$pb.TagNumber(2) 212 | void clearTxn() => clearField(2); 213 | @$pb.TagNumber(2) 214 | TxnContext ensureTxn() => $_ensure(1); 215 | 216 | @$pb.TagNumber(3) 217 | Latency get latency => $_getN(2); 218 | @$pb.TagNumber(3) 219 | set latency(Latency v) { 220 | setField(3, v); 221 | } 222 | 223 | @$pb.TagNumber(3) 224 | $core.bool hasLatency() => $_has(2); 225 | @$pb.TagNumber(3) 226 | void clearLatency() => clearField(3); 227 | @$pb.TagNumber(3) 228 | Latency ensureLatency() => $_ensure(2); 229 | 230 | @$pb.TagNumber(4) 231 | Metrics get metrics => $_getN(3); 232 | @$pb.TagNumber(4) 233 | set metrics(Metrics v) { 234 | setField(4, v); 235 | } 236 | 237 | @$pb.TagNumber(4) 238 | $core.bool hasMetrics() => $_has(3); 239 | @$pb.TagNumber(4) 240 | void clearMetrics() => clearField(4); 241 | @$pb.TagNumber(4) 242 | Metrics ensureMetrics() => $_ensure(3); 243 | 244 | @$pb.TagNumber(12) 245 | $core.Map<$core.String, $core.String> get uids => $_getMap(4); 246 | } 247 | 248 | class Mutation extends $pb.GeneratedMessage { 249 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Mutation', 250 | package: const $pb.PackageName('api'), createEmptyInstance: create) 251 | ..a<$core.List<$core.int>>(1, 'setJson', $pb.PbFieldType.OY) 252 | ..a<$core.List<$core.int>>(2, 'deleteJson', $pb.PbFieldType.OY) 253 | ..a<$core.List<$core.int>>(3, 'setNquads', $pb.PbFieldType.OY) 254 | ..a<$core.List<$core.int>>(4, 'delNquads', $pb.PbFieldType.OY) 255 | ..pc(5, 'set', $pb.PbFieldType.PM, subBuilder: NQuad.create) 256 | ..pc(6, 'del', $pb.PbFieldType.PM, subBuilder: NQuad.create) 257 | ..aOS(9, 'cond') 258 | ..aOB(14, 'commitNow') 259 | ..hasRequiredFields = false; 260 | 261 | Mutation._() : super(); 262 | factory Mutation() => create(); 263 | factory Mutation.fromBuffer($core.List<$core.int> i, 264 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 265 | create()..mergeFromBuffer(i, r); 266 | factory Mutation.fromJson($core.String i, 267 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 268 | create()..mergeFromJson(i, r); 269 | Mutation clone() => Mutation()..mergeFromMessage(this); 270 | Mutation copyWith(void Function(Mutation) updates) => 271 | super.copyWith((message) => updates(message as Mutation)) as Mutation; 272 | $pb.BuilderInfo get info_ => _i; 273 | @$core.pragma('dart2js:noInline') 274 | static Mutation create() => Mutation._(); 275 | Mutation createEmptyInstance() => create(); 276 | static $pb.PbList createRepeated() => $pb.PbList(); 277 | @$core.pragma('dart2js:noInline') 278 | static Mutation getDefault() => 279 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 280 | static Mutation? _defaultInstance; 281 | 282 | @$pb.TagNumber(1) 283 | $core.List<$core.int> get setJson => $_getN(0); 284 | @$pb.TagNumber(1) 285 | set setJson($core.List<$core.int> v) { 286 | $_setBytes(0, v); 287 | } 288 | 289 | @$pb.TagNumber(1) 290 | $core.bool hasSetJson() => $_has(0); 291 | @$pb.TagNumber(1) 292 | void clearSetJson() => clearField(1); 293 | 294 | @$pb.TagNumber(2) 295 | $core.List<$core.int> get deleteJson => $_getN(1); 296 | @$pb.TagNumber(2) 297 | set deleteJson($core.List<$core.int> v) { 298 | $_setBytes(1, v); 299 | } 300 | 301 | @$pb.TagNumber(2) 302 | $core.bool hasDeleteJson() => $_has(1); 303 | @$pb.TagNumber(2) 304 | void clearDeleteJson() => clearField(2); 305 | 306 | @$pb.TagNumber(3) 307 | $core.List<$core.int> get setNquads => $_getN(2); 308 | @$pb.TagNumber(3) 309 | set setNquads($core.List<$core.int> v) { 310 | $_setBytes(2, v); 311 | } 312 | 313 | @$pb.TagNumber(3) 314 | $core.bool hasSetNquads() => $_has(2); 315 | @$pb.TagNumber(3) 316 | void clearSetNquads() => clearField(3); 317 | 318 | @$pb.TagNumber(4) 319 | $core.List<$core.int> get delNquads => $_getN(3); 320 | @$pb.TagNumber(4) 321 | set delNquads($core.List<$core.int> v) { 322 | $_setBytes(3, v); 323 | } 324 | 325 | @$pb.TagNumber(4) 326 | $core.bool hasDelNquads() => $_has(3); 327 | @$pb.TagNumber(4) 328 | void clearDelNquads() => clearField(4); 329 | 330 | @$pb.TagNumber(5) 331 | $core.List get set => $_getList(4); 332 | 333 | @$pb.TagNumber(6) 334 | $core.List get del => $_getList(5); 335 | 336 | @$pb.TagNumber(9) 337 | $core.String get cond => $_getSZ(6); 338 | @$pb.TagNumber(9) 339 | set cond($core.String v) { 340 | $_setString(6, v); 341 | } 342 | 343 | @$pb.TagNumber(9) 344 | $core.bool hasCond() => $_has(6); 345 | @$pb.TagNumber(9) 346 | void clearCond() => clearField(9); 347 | 348 | @$pb.TagNumber(14) 349 | $core.bool get commitNow => $_getBF(7); 350 | @$pb.TagNumber(14) 351 | set commitNow($core.bool v) { 352 | $_setBool(7, v); 353 | } 354 | 355 | @$pb.TagNumber(14) 356 | $core.bool hasCommitNow() => $_has(7); 357 | @$pb.TagNumber(14) 358 | void clearCommitNow() => clearField(14); 359 | } 360 | 361 | class Operation extends $pb.GeneratedMessage { 362 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Operation', 363 | package: const $pb.PackageName('api'), createEmptyInstance: create) 364 | ..aOS(1, 'schema') 365 | ..aOS(2, 'dropAttr') 366 | ..aOB(3, 'dropAll') 367 | ..e(4, 'dropOp', $pb.PbFieldType.OE, 368 | defaultOrMaker: Operation_DropOp.NONE, 369 | valueOf: Operation_DropOp.valueOf, 370 | enumValues: Operation_DropOp.values) 371 | ..aOS(5, 'dropValue') 372 | ..hasRequiredFields = false; 373 | 374 | Operation._() : super(); 375 | factory Operation() => create(); 376 | factory Operation.fromBuffer($core.List<$core.int> i, 377 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 378 | create()..mergeFromBuffer(i, r); 379 | factory Operation.fromJson($core.String i, 380 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 381 | create()..mergeFromJson(i, r); 382 | Operation clone() => Operation()..mergeFromMessage(this); 383 | Operation copyWith(void Function(Operation) updates) => 384 | super.copyWith((message) => updates(message as Operation)) as Operation; 385 | $pb.BuilderInfo get info_ => _i; 386 | @$core.pragma('dart2js:noInline') 387 | static Operation create() => Operation._(); 388 | Operation createEmptyInstance() => create(); 389 | static $pb.PbList createRepeated() => $pb.PbList(); 390 | @$core.pragma('dart2js:noInline') 391 | static Operation getDefault() => 392 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 393 | static Operation? _defaultInstance; 394 | 395 | @$pb.TagNumber(1) 396 | $core.String get schema => $_getSZ(0); 397 | @$pb.TagNumber(1) 398 | set schema($core.String v) { 399 | $_setString(0, v); 400 | } 401 | 402 | @$pb.TagNumber(1) 403 | $core.bool hasSchema() => $_has(0); 404 | @$pb.TagNumber(1) 405 | void clearSchema() => clearField(1); 406 | 407 | @$pb.TagNumber(2) 408 | $core.String get dropAttr => $_getSZ(1); 409 | @$pb.TagNumber(2) 410 | set dropAttr($core.String v) { 411 | $_setString(1, v); 412 | } 413 | 414 | @$pb.TagNumber(2) 415 | $core.bool hasDropAttr() => $_has(1); 416 | @$pb.TagNumber(2) 417 | void clearDropAttr() => clearField(2); 418 | 419 | @$pb.TagNumber(3) 420 | $core.bool get dropAll => $_getBF(2); 421 | @$pb.TagNumber(3) 422 | set dropAll($core.bool v) { 423 | $_setBool(2, v); 424 | } 425 | 426 | @$pb.TagNumber(3) 427 | $core.bool hasDropAll() => $_has(2); 428 | @$pb.TagNumber(3) 429 | void clearDropAll() => clearField(3); 430 | 431 | @$pb.TagNumber(4) 432 | Operation_DropOp get dropOp => $_getN(3); 433 | @$pb.TagNumber(4) 434 | set dropOp(Operation_DropOp v) { 435 | setField(4, v); 436 | } 437 | 438 | @$pb.TagNumber(4) 439 | $core.bool hasDropOp() => $_has(3); 440 | @$pb.TagNumber(4) 441 | void clearDropOp() => clearField(4); 442 | 443 | @$pb.TagNumber(5) 444 | $core.String get dropValue => $_getSZ(4); 445 | @$pb.TagNumber(5) 446 | set dropValue($core.String v) { 447 | $_setString(4, v); 448 | } 449 | 450 | @$pb.TagNumber(5) 451 | $core.bool hasDropValue() => $_has(4); 452 | @$pb.TagNumber(5) 453 | void clearDropValue() => clearField(5); 454 | } 455 | 456 | class Payload extends $pb.GeneratedMessage { 457 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Payload', 458 | package: const $pb.PackageName('api'), createEmptyInstance: create) 459 | ..a<$core.List<$core.int>>(1, 'data', $pb.PbFieldType.OY, protoName: 'Data') 460 | ..hasRequiredFields = false; 461 | 462 | Payload._() : super(); 463 | factory Payload() => create(); 464 | factory Payload.fromBuffer($core.List<$core.int> i, 465 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 466 | create()..mergeFromBuffer(i, r); 467 | factory Payload.fromJson($core.String i, 468 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 469 | create()..mergeFromJson(i, r); 470 | Payload clone() => Payload()..mergeFromMessage(this); 471 | Payload copyWith(void Function(Payload) updates) => 472 | super.copyWith((message) => updates(message as Payload)) as Payload; 473 | $pb.BuilderInfo get info_ => _i; 474 | @$core.pragma('dart2js:noInline') 475 | static Payload create() => Payload._(); 476 | Payload createEmptyInstance() => create(); 477 | static $pb.PbList createRepeated() => $pb.PbList(); 478 | @$core.pragma('dart2js:noInline') 479 | static Payload getDefault() => 480 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 481 | static Payload? _defaultInstance; 482 | 483 | @$pb.TagNumber(1) 484 | $core.List<$core.int> get data => $_getN(0); 485 | @$pb.TagNumber(1) 486 | set data($core.List<$core.int> v) { 487 | $_setBytes(0, v); 488 | } 489 | 490 | @$pb.TagNumber(1) 491 | $core.bool hasData() => $_has(0); 492 | @$pb.TagNumber(1) 493 | void clearData() => clearField(1); 494 | } 495 | 496 | class TxnContext extends $pb.GeneratedMessage { 497 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('TxnContext', 498 | package: const $pb.PackageName('api'), createEmptyInstance: create) 499 | ..a<$fixnum.Int64>(1, 'startTs', $pb.PbFieldType.OU6, 500 | defaultOrMaker: $fixnum.Int64.ZERO) 501 | ..a<$fixnum.Int64>(2, 'commitTs', $pb.PbFieldType.OU6, 502 | defaultOrMaker: $fixnum.Int64.ZERO) 503 | ..aOB(3, 'aborted') 504 | ..pPS(4, 'keys') 505 | ..pPS(5, 'preds') 506 | ..hasRequiredFields = false; 507 | 508 | TxnContext._() : super(); 509 | factory TxnContext() => create(); 510 | factory TxnContext.fromBuffer($core.List<$core.int> i, 511 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 512 | create()..mergeFromBuffer(i, r); 513 | factory TxnContext.fromJson($core.String i, 514 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 515 | create()..mergeFromJson(i, r); 516 | TxnContext clone() => TxnContext()..mergeFromMessage(this); 517 | TxnContext copyWith(void Function(TxnContext) updates) => 518 | super.copyWith((message) => updates(message as TxnContext)) as TxnContext; 519 | $pb.BuilderInfo get info_ => _i; 520 | @$core.pragma('dart2js:noInline') 521 | static TxnContext create() => TxnContext._(); 522 | TxnContext createEmptyInstance() => create(); 523 | static $pb.PbList createRepeated() => $pb.PbList(); 524 | @$core.pragma('dart2js:noInline') 525 | static TxnContext getDefault() => _defaultInstance ??= 526 | $pb.GeneratedMessage.$_defaultFor(create); 527 | static TxnContext? _defaultInstance; 528 | 529 | @$pb.TagNumber(1) 530 | $fixnum.Int64 get startTs => $_getI64(0); 531 | @$pb.TagNumber(1) 532 | set startTs($fixnum.Int64 v) { 533 | $_setInt64(0, v); 534 | } 535 | 536 | @$pb.TagNumber(1) 537 | $core.bool hasStartTs() => $_has(0); 538 | @$pb.TagNumber(1) 539 | void clearStartTs() => clearField(1); 540 | 541 | @$pb.TagNumber(2) 542 | $fixnum.Int64 get commitTs => $_getI64(1); 543 | @$pb.TagNumber(2) 544 | set commitTs($fixnum.Int64 v) { 545 | $_setInt64(1, v); 546 | } 547 | 548 | @$pb.TagNumber(2) 549 | $core.bool hasCommitTs() => $_has(1); 550 | @$pb.TagNumber(2) 551 | void clearCommitTs() => clearField(2); 552 | 553 | @$pb.TagNumber(3) 554 | $core.bool get aborted => $_getBF(2); 555 | @$pb.TagNumber(3) 556 | set aborted($core.bool v) { 557 | $_setBool(2, v); 558 | } 559 | 560 | @$pb.TagNumber(3) 561 | $core.bool hasAborted() => $_has(2); 562 | @$pb.TagNumber(3) 563 | void clearAborted() => clearField(3); 564 | 565 | @$pb.TagNumber(4) 566 | $core.List<$core.String> get keys => $_getList(3); 567 | 568 | @$pb.TagNumber(5) 569 | $core.List<$core.String> get preds => $_getList(4); 570 | } 571 | 572 | class Check extends $pb.GeneratedMessage { 573 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Check', 574 | package: const $pb.PackageName('api'), createEmptyInstance: create) 575 | ..hasRequiredFields = false; 576 | 577 | Check._() : super(); 578 | factory Check() => create(); 579 | factory Check.fromBuffer($core.List<$core.int> i, 580 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 581 | create()..mergeFromBuffer(i, r); 582 | factory Check.fromJson($core.String i, 583 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 584 | create()..mergeFromJson(i, r); 585 | Check clone() => Check()..mergeFromMessage(this); 586 | Check copyWith(void Function(Check) updates) => 587 | super.copyWith((message) => updates(message as Check)) as Check; 588 | $pb.BuilderInfo get info_ => _i; 589 | @$core.pragma('dart2js:noInline') 590 | static Check create() => Check._(); 591 | Check createEmptyInstance() => create(); 592 | static $pb.PbList createRepeated() => $pb.PbList(); 593 | @$core.pragma('dart2js:noInline') 594 | static Check getDefault() => 595 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 596 | static Check? _defaultInstance; 597 | } 598 | 599 | class Version extends $pb.GeneratedMessage { 600 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Version', 601 | package: const $pb.PackageName('api'), createEmptyInstance: create) 602 | ..aOS(1, 'tag') 603 | ..hasRequiredFields = false; 604 | 605 | Version._() : super(); 606 | factory Version() => create(); 607 | factory Version.fromBuffer($core.List<$core.int> i, 608 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 609 | create()..mergeFromBuffer(i, r); 610 | factory Version.fromJson($core.String i, 611 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 612 | create()..mergeFromJson(i, r); 613 | Version clone() => Version()..mergeFromMessage(this); 614 | Version copyWith(void Function(Version) updates) => 615 | super.copyWith((message) => updates(message as Version)) as Version; 616 | $pb.BuilderInfo get info_ => _i; 617 | @$core.pragma('dart2js:noInline') 618 | static Version create() => Version._(); 619 | Version createEmptyInstance() => create(); 620 | static $pb.PbList createRepeated() => $pb.PbList(); 621 | @$core.pragma('dart2js:noInline') 622 | static Version getDefault() => 623 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 624 | static Version? _defaultInstance; 625 | 626 | @$pb.TagNumber(1) 627 | $core.String get tag => $_getSZ(0); 628 | @$pb.TagNumber(1) 629 | set tag($core.String v) { 630 | $_setString(0, v); 631 | } 632 | 633 | @$pb.TagNumber(1) 634 | $core.bool hasTag() => $_has(0); 635 | @$pb.TagNumber(1) 636 | void clearTag() => clearField(1); 637 | } 638 | 639 | class Latency extends $pb.GeneratedMessage { 640 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Latency', 641 | package: const $pb.PackageName('api'), createEmptyInstance: create) 642 | ..a<$fixnum.Int64>(1, 'parsingNs', $pb.PbFieldType.OU6, 643 | defaultOrMaker: $fixnum.Int64.ZERO) 644 | ..a<$fixnum.Int64>(2, 'processingNs', $pb.PbFieldType.OU6, 645 | defaultOrMaker: $fixnum.Int64.ZERO) 646 | ..a<$fixnum.Int64>(3, 'encodingNs', $pb.PbFieldType.OU6, 647 | defaultOrMaker: $fixnum.Int64.ZERO) 648 | ..a<$fixnum.Int64>(4, 'assignTimestampNs', $pb.PbFieldType.OU6, 649 | defaultOrMaker: $fixnum.Int64.ZERO) 650 | ..a<$fixnum.Int64>(5, 'totalNs', $pb.PbFieldType.OU6, 651 | defaultOrMaker: $fixnum.Int64.ZERO) 652 | ..hasRequiredFields = false; 653 | 654 | Latency._() : super(); 655 | factory Latency() => create(); 656 | factory Latency.fromBuffer($core.List<$core.int> i, 657 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 658 | create()..mergeFromBuffer(i, r); 659 | factory Latency.fromJson($core.String i, 660 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 661 | create()..mergeFromJson(i, r); 662 | Latency clone() => Latency()..mergeFromMessage(this); 663 | Latency copyWith(void Function(Latency) updates) => 664 | super.copyWith((message) => updates(message as Latency)) as Latency; 665 | $pb.BuilderInfo get info_ => _i; 666 | @$core.pragma('dart2js:noInline') 667 | static Latency create() => Latency._(); 668 | Latency createEmptyInstance() => create(); 669 | static $pb.PbList createRepeated() => $pb.PbList(); 670 | @$core.pragma('dart2js:noInline') 671 | static Latency getDefault() => 672 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 673 | static Latency? _defaultInstance; 674 | 675 | @$pb.TagNumber(1) 676 | $fixnum.Int64 get parsingNs => $_getI64(0); 677 | @$pb.TagNumber(1) 678 | set parsingNs($fixnum.Int64 v) { 679 | $_setInt64(0, v); 680 | } 681 | 682 | @$pb.TagNumber(1) 683 | $core.bool hasParsingNs() => $_has(0); 684 | @$pb.TagNumber(1) 685 | void clearParsingNs() => clearField(1); 686 | 687 | @$pb.TagNumber(2) 688 | $fixnum.Int64 get processingNs => $_getI64(1); 689 | @$pb.TagNumber(2) 690 | set processingNs($fixnum.Int64 v) { 691 | $_setInt64(1, v); 692 | } 693 | 694 | @$pb.TagNumber(2) 695 | $core.bool hasProcessingNs() => $_has(1); 696 | @$pb.TagNumber(2) 697 | void clearProcessingNs() => clearField(2); 698 | 699 | @$pb.TagNumber(3) 700 | $fixnum.Int64 get encodingNs => $_getI64(2); 701 | @$pb.TagNumber(3) 702 | set encodingNs($fixnum.Int64 v) { 703 | $_setInt64(2, v); 704 | } 705 | 706 | @$pb.TagNumber(3) 707 | $core.bool hasEncodingNs() => $_has(2); 708 | @$pb.TagNumber(3) 709 | void clearEncodingNs() => clearField(3); 710 | 711 | @$pb.TagNumber(4) 712 | $fixnum.Int64 get assignTimestampNs => $_getI64(3); 713 | @$pb.TagNumber(4) 714 | set assignTimestampNs($fixnum.Int64 v) { 715 | $_setInt64(3, v); 716 | } 717 | 718 | @$pb.TagNumber(4) 719 | $core.bool hasAssignTimestampNs() => $_has(3); 720 | @$pb.TagNumber(4) 721 | void clearAssignTimestampNs() => clearField(4); 722 | 723 | @$pb.TagNumber(5) 724 | $fixnum.Int64 get totalNs => $_getI64(4); 725 | @$pb.TagNumber(5) 726 | set totalNs($fixnum.Int64 v) { 727 | $_setInt64(4, v); 728 | } 729 | 730 | @$pb.TagNumber(5) 731 | $core.bool hasTotalNs() => $_has(4); 732 | @$pb.TagNumber(5) 733 | void clearTotalNs() => clearField(5); 734 | } 735 | 736 | class Metrics extends $pb.GeneratedMessage { 737 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Metrics', 738 | package: const $pb.PackageName('api'), createEmptyInstance: create) 739 | ..m<$core.String, $fixnum.Int64>(1, 'numUids', 740 | entryClassName: 'Metrics.NumUidsEntry', 741 | keyFieldType: $pb.PbFieldType.OS, 742 | valueFieldType: $pb.PbFieldType.OU6, 743 | packageName: const $pb.PackageName('api')) 744 | ..hasRequiredFields = false; 745 | 746 | Metrics._() : super(); 747 | factory Metrics() => create(); 748 | factory Metrics.fromBuffer($core.List<$core.int> i, 749 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 750 | create()..mergeFromBuffer(i, r); 751 | factory Metrics.fromJson($core.String i, 752 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 753 | create()..mergeFromJson(i, r); 754 | Metrics clone() => Metrics()..mergeFromMessage(this); 755 | Metrics copyWith(void Function(Metrics) updates) => 756 | super.copyWith((message) => updates(message as Metrics)) as Metrics; 757 | $pb.BuilderInfo get info_ => _i; 758 | @$core.pragma('dart2js:noInline') 759 | static Metrics create() => Metrics._(); 760 | Metrics createEmptyInstance() => create(); 761 | static $pb.PbList createRepeated() => $pb.PbList(); 762 | @$core.pragma('dart2js:noInline') 763 | static Metrics getDefault() => 764 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 765 | static Metrics? _defaultInstance; 766 | 767 | @$pb.TagNumber(1) 768 | $core.Map<$core.String, $fixnum.Int64> get numUids => $_getMap(0); 769 | } 770 | 771 | class NQuad extends $pb.GeneratedMessage { 772 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('NQuad', 773 | package: const $pb.PackageName('api'), createEmptyInstance: create) 774 | ..aOS(1, 'subject') 775 | ..aOS(2, 'predicate') 776 | ..aOS(3, 'objectId') 777 | ..aOM(4, 'objectValue', subBuilder: Value.create) 778 | ..aOS(5, 'label') 779 | ..aOS(6, 'lang') 780 | ..pc(7, 'facets', $pb.PbFieldType.PM, subBuilder: Facet.create) 781 | ..hasRequiredFields = false; 782 | 783 | NQuad._() : super(); 784 | factory NQuad() => create(); 785 | factory NQuad.fromBuffer($core.List<$core.int> i, 786 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 787 | create()..mergeFromBuffer(i, r); 788 | factory NQuad.fromJson($core.String i, 789 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 790 | create()..mergeFromJson(i, r); 791 | NQuad clone() => NQuad()..mergeFromMessage(this); 792 | NQuad copyWith(void Function(NQuad) updates) => 793 | super.copyWith((message) => updates(message as NQuad)) as NQuad; 794 | $pb.BuilderInfo get info_ => _i; 795 | @$core.pragma('dart2js:noInline') 796 | static NQuad create() => NQuad._(); 797 | NQuad createEmptyInstance() => create(); 798 | static $pb.PbList createRepeated() => $pb.PbList(); 799 | @$core.pragma('dart2js:noInline') 800 | static NQuad getDefault() => 801 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 802 | static NQuad? _defaultInstance; 803 | 804 | @$pb.TagNumber(1) 805 | $core.String get subject => $_getSZ(0); 806 | @$pb.TagNumber(1) 807 | set subject($core.String v) { 808 | $_setString(0, v); 809 | } 810 | 811 | @$pb.TagNumber(1) 812 | $core.bool hasSubject() => $_has(0); 813 | @$pb.TagNumber(1) 814 | void clearSubject() => clearField(1); 815 | 816 | @$pb.TagNumber(2) 817 | $core.String get predicate => $_getSZ(1); 818 | @$pb.TagNumber(2) 819 | set predicate($core.String v) { 820 | $_setString(1, v); 821 | } 822 | 823 | @$pb.TagNumber(2) 824 | $core.bool hasPredicate() => $_has(1); 825 | @$pb.TagNumber(2) 826 | void clearPredicate() => clearField(2); 827 | 828 | @$pb.TagNumber(3) 829 | $core.String get objectId => $_getSZ(2); 830 | @$pb.TagNumber(3) 831 | set objectId($core.String v) { 832 | $_setString(2, v); 833 | } 834 | 835 | @$pb.TagNumber(3) 836 | $core.bool hasObjectId() => $_has(2); 837 | @$pb.TagNumber(3) 838 | void clearObjectId() => clearField(3); 839 | 840 | @$pb.TagNumber(4) 841 | Value get objectValue => $_getN(3); 842 | @$pb.TagNumber(4) 843 | set objectValue(Value v) { 844 | setField(4, v); 845 | } 846 | 847 | @$pb.TagNumber(4) 848 | $core.bool hasObjectValue() => $_has(3); 849 | @$pb.TagNumber(4) 850 | void clearObjectValue() => clearField(4); 851 | @$pb.TagNumber(4) 852 | Value ensureObjectValue() => $_ensure(3); 853 | 854 | @$pb.TagNumber(5) 855 | $core.String get label => $_getSZ(4); 856 | @$pb.TagNumber(5) 857 | set label($core.String v) { 858 | $_setString(4, v); 859 | } 860 | 861 | @$pb.TagNumber(5) 862 | $core.bool hasLabel() => $_has(4); 863 | @$pb.TagNumber(5) 864 | void clearLabel() => clearField(5); 865 | 866 | @$pb.TagNumber(6) 867 | $core.String get lang => $_getSZ(5); 868 | @$pb.TagNumber(6) 869 | set lang($core.String v) { 870 | $_setString(5, v); 871 | } 872 | 873 | @$pb.TagNumber(6) 874 | $core.bool hasLang() => $_has(5); 875 | @$pb.TagNumber(6) 876 | void clearLang() => clearField(6); 877 | 878 | @$pb.TagNumber(7) 879 | $core.List get facets => $_getList(6); 880 | } 881 | 882 | enum Value_Val { 883 | defaultVal, 884 | bytesVal, 885 | intVal, 886 | boolVal, 887 | strVal, 888 | doubleVal, 889 | geoVal, 890 | dateVal, 891 | datetimeVal, 892 | passwordVal, 893 | uidVal, 894 | notSet 895 | } 896 | 897 | class Value extends $pb.GeneratedMessage { 898 | static const $core.Map<$core.int, Value_Val> _Value_ValByTag = { 899 | 1: Value_Val.defaultVal, 900 | 2: Value_Val.bytesVal, 901 | 3: Value_Val.intVal, 902 | 4: Value_Val.boolVal, 903 | 5: Value_Val.strVal, 904 | 6: Value_Val.doubleVal, 905 | 7: Value_Val.geoVal, 906 | 8: Value_Val.dateVal, 907 | 9: Value_Val.datetimeVal, 908 | 10: Value_Val.passwordVal, 909 | 11: Value_Val.uidVal, 910 | 0: Value_Val.notSet 911 | }; 912 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Value', 913 | package: const $pb.PackageName('api'), createEmptyInstance: create) 914 | ..oo(0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) 915 | ..aOS(1, 'defaultVal') 916 | ..a<$core.List<$core.int>>(2, 'bytesVal', $pb.PbFieldType.OY) 917 | ..aInt64(3, 'intVal') 918 | ..aOB(4, 'boolVal') 919 | ..aOS(5, 'strVal') 920 | ..a<$core.double>(6, 'doubleVal', $pb.PbFieldType.OD) 921 | ..a<$core.List<$core.int>>(7, 'geoVal', $pb.PbFieldType.OY) 922 | ..a<$core.List<$core.int>>(8, 'dateVal', $pb.PbFieldType.OY) 923 | ..a<$core.List<$core.int>>(9, 'datetimeVal', $pb.PbFieldType.OY) 924 | ..aOS(10, 'passwordVal') 925 | ..a<$fixnum.Int64>(11, 'uidVal', $pb.PbFieldType.OU6, 926 | defaultOrMaker: $fixnum.Int64.ZERO) 927 | ..hasRequiredFields = false; 928 | 929 | Value._() : super(); 930 | factory Value() => create(); 931 | factory Value.fromBuffer($core.List<$core.int> i, 932 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 933 | create()..mergeFromBuffer(i, r); 934 | factory Value.fromJson($core.String i, 935 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 936 | create()..mergeFromJson(i, r); 937 | Value clone() => Value()..mergeFromMessage(this); 938 | Value copyWith(void Function(Value) updates) => 939 | super.copyWith((message) => updates(message as Value)) as Value; 940 | $pb.BuilderInfo get info_ => _i; 941 | @$core.pragma('dart2js:noInline') 942 | static Value create() => Value._(); 943 | Value createEmptyInstance() => create(); 944 | static $pb.PbList createRepeated() => $pb.PbList(); 945 | @$core.pragma('dart2js:noInline') 946 | static Value getDefault() => 947 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 948 | static Value? _defaultInstance; 949 | 950 | Value_Val? whichVal() => _Value_ValByTag[$_whichOneof(0)]; 951 | void clearVal() => clearField($_whichOneof(0)); 952 | 953 | @$pb.TagNumber(1) 954 | $core.String get defaultVal => $_getSZ(0); 955 | @$pb.TagNumber(1) 956 | set defaultVal($core.String v) { 957 | $_setString(0, v); 958 | } 959 | 960 | @$pb.TagNumber(1) 961 | $core.bool hasDefaultVal() => $_has(0); 962 | @$pb.TagNumber(1) 963 | void clearDefaultVal() => clearField(1); 964 | 965 | @$pb.TagNumber(2) 966 | $core.List<$core.int> get bytesVal => $_getN(1); 967 | @$pb.TagNumber(2) 968 | set bytesVal($core.List<$core.int> v) { 969 | $_setBytes(1, v); 970 | } 971 | 972 | @$pb.TagNumber(2) 973 | $core.bool hasBytesVal() => $_has(1); 974 | @$pb.TagNumber(2) 975 | void clearBytesVal() => clearField(2); 976 | 977 | @$pb.TagNumber(3) 978 | $fixnum.Int64 get intVal => $_getI64(2); 979 | @$pb.TagNumber(3) 980 | set intVal($fixnum.Int64 v) { 981 | $_setInt64(2, v); 982 | } 983 | 984 | @$pb.TagNumber(3) 985 | $core.bool hasIntVal() => $_has(2); 986 | @$pb.TagNumber(3) 987 | void clearIntVal() => clearField(3); 988 | 989 | @$pb.TagNumber(4) 990 | $core.bool get boolVal => $_getBF(3); 991 | @$pb.TagNumber(4) 992 | set boolVal($core.bool v) { 993 | $_setBool(3, v); 994 | } 995 | 996 | @$pb.TagNumber(4) 997 | $core.bool hasBoolVal() => $_has(3); 998 | @$pb.TagNumber(4) 999 | void clearBoolVal() => clearField(4); 1000 | 1001 | @$pb.TagNumber(5) 1002 | $core.String get strVal => $_getSZ(4); 1003 | @$pb.TagNumber(5) 1004 | set strVal($core.String v) { 1005 | $_setString(4, v); 1006 | } 1007 | 1008 | @$pb.TagNumber(5) 1009 | $core.bool hasStrVal() => $_has(4); 1010 | @$pb.TagNumber(5) 1011 | void clearStrVal() => clearField(5); 1012 | 1013 | @$pb.TagNumber(6) 1014 | $core.double get doubleVal => $_getN(5); 1015 | @$pb.TagNumber(6) 1016 | set doubleVal($core.double v) { 1017 | $_setDouble(5, v); 1018 | } 1019 | 1020 | @$pb.TagNumber(6) 1021 | $core.bool hasDoubleVal() => $_has(5); 1022 | @$pb.TagNumber(6) 1023 | void clearDoubleVal() => clearField(6); 1024 | 1025 | @$pb.TagNumber(7) 1026 | $core.List<$core.int> get geoVal => $_getN(6); 1027 | @$pb.TagNumber(7) 1028 | set geoVal($core.List<$core.int> v) { 1029 | $_setBytes(6, v); 1030 | } 1031 | 1032 | @$pb.TagNumber(7) 1033 | $core.bool hasGeoVal() => $_has(6); 1034 | @$pb.TagNumber(7) 1035 | void clearGeoVal() => clearField(7); 1036 | 1037 | @$pb.TagNumber(8) 1038 | $core.List<$core.int> get dateVal => $_getN(7); 1039 | @$pb.TagNumber(8) 1040 | set dateVal($core.List<$core.int> v) { 1041 | $_setBytes(7, v); 1042 | } 1043 | 1044 | @$pb.TagNumber(8) 1045 | $core.bool hasDateVal() => $_has(7); 1046 | @$pb.TagNumber(8) 1047 | void clearDateVal() => clearField(8); 1048 | 1049 | @$pb.TagNumber(9) 1050 | $core.List<$core.int> get datetimeVal => $_getN(8); 1051 | @$pb.TagNumber(9) 1052 | set datetimeVal($core.List<$core.int> v) { 1053 | $_setBytes(8, v); 1054 | } 1055 | 1056 | @$pb.TagNumber(9) 1057 | $core.bool hasDatetimeVal() => $_has(8); 1058 | @$pb.TagNumber(9) 1059 | void clearDatetimeVal() => clearField(9); 1060 | 1061 | @$pb.TagNumber(10) 1062 | $core.String get passwordVal => $_getSZ(9); 1063 | @$pb.TagNumber(10) 1064 | set passwordVal($core.String v) { 1065 | $_setString(9, v); 1066 | } 1067 | 1068 | @$pb.TagNumber(10) 1069 | $core.bool hasPasswordVal() => $_has(9); 1070 | @$pb.TagNumber(10) 1071 | void clearPasswordVal() => clearField(10); 1072 | 1073 | @$pb.TagNumber(11) 1074 | $fixnum.Int64 get uidVal => $_getI64(10); 1075 | @$pb.TagNumber(11) 1076 | set uidVal($fixnum.Int64 v) { 1077 | $_setInt64(10, v); 1078 | } 1079 | 1080 | @$pb.TagNumber(11) 1081 | $core.bool hasUidVal() => $_has(10); 1082 | @$pb.TagNumber(11) 1083 | void clearUidVal() => clearField(11); 1084 | } 1085 | 1086 | class Facet extends $pb.GeneratedMessage { 1087 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Facet', 1088 | package: const $pb.PackageName('api'), createEmptyInstance: create) 1089 | ..aOS(1, 'key') 1090 | ..a<$core.List<$core.int>>(2, 'value', $pb.PbFieldType.OY) 1091 | ..e(3, 'valType', $pb.PbFieldType.OE, 1092 | defaultOrMaker: Facet_ValType.STRING, 1093 | valueOf: Facet_ValType.valueOf, 1094 | enumValues: Facet_ValType.values) 1095 | ..pPS(4, 'tokens') 1096 | ..aOS(5, 'alias') 1097 | ..hasRequiredFields = false; 1098 | 1099 | Facet._() : super(); 1100 | factory Facet() => create(); 1101 | factory Facet.fromBuffer($core.List<$core.int> i, 1102 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 1103 | create()..mergeFromBuffer(i, r); 1104 | factory Facet.fromJson($core.String i, 1105 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 1106 | create()..mergeFromJson(i, r); 1107 | Facet clone() => Facet()..mergeFromMessage(this); 1108 | Facet copyWith(void Function(Facet) updates) => 1109 | super.copyWith((message) => updates(message as Facet)) as Facet; 1110 | $pb.BuilderInfo get info_ => _i; 1111 | @$core.pragma('dart2js:noInline') 1112 | static Facet create() => Facet._(); 1113 | Facet createEmptyInstance() => create(); 1114 | static $pb.PbList createRepeated() => $pb.PbList(); 1115 | @$core.pragma('dart2js:noInline') 1116 | static Facet getDefault() => 1117 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 1118 | static Facet? _defaultInstance; 1119 | 1120 | @$pb.TagNumber(1) 1121 | $core.String get key => $_getSZ(0); 1122 | @$pb.TagNumber(1) 1123 | set key($core.String v) { 1124 | $_setString(0, v); 1125 | } 1126 | 1127 | @$pb.TagNumber(1) 1128 | $core.bool hasKey() => $_has(0); 1129 | @$pb.TagNumber(1) 1130 | void clearKey() => clearField(1); 1131 | 1132 | @$pb.TagNumber(2) 1133 | $core.List<$core.int> get value => $_getN(1); 1134 | @$pb.TagNumber(2) 1135 | set value($core.List<$core.int> v) { 1136 | $_setBytes(1, v); 1137 | } 1138 | 1139 | @$pb.TagNumber(2) 1140 | $core.bool hasValue() => $_has(1); 1141 | @$pb.TagNumber(2) 1142 | void clearValue() => clearField(2); 1143 | 1144 | @$pb.TagNumber(3) 1145 | Facet_ValType get valType => $_getN(2); 1146 | @$pb.TagNumber(3) 1147 | set valType(Facet_ValType v) { 1148 | setField(3, v); 1149 | } 1150 | 1151 | @$pb.TagNumber(3) 1152 | $core.bool hasValType() => $_has(2); 1153 | @$pb.TagNumber(3) 1154 | void clearValType() => clearField(3); 1155 | 1156 | @$pb.TagNumber(4) 1157 | $core.List<$core.String> get tokens => $_getList(3); 1158 | 1159 | @$pb.TagNumber(5) 1160 | $core.String get alias => $_getSZ(4); 1161 | @$pb.TagNumber(5) 1162 | set alias($core.String v) { 1163 | $_setString(4, v); 1164 | } 1165 | 1166 | @$pb.TagNumber(5) 1167 | $core.bool hasAlias() => $_has(4); 1168 | @$pb.TagNumber(5) 1169 | void clearAlias() => clearField(5); 1170 | } 1171 | 1172 | class LoginRequest extends $pb.GeneratedMessage { 1173 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('LoginRequest', 1174 | package: const $pb.PackageName('api'), createEmptyInstance: create) 1175 | ..aOS(1, 'userid') 1176 | ..aOS(2, 'password') 1177 | ..aOS(3, 'refreshToken') 1178 | ..hasRequiredFields = false; 1179 | 1180 | LoginRequest._() : super(); 1181 | factory LoginRequest() => create(); 1182 | factory LoginRequest.fromBuffer($core.List<$core.int> i, 1183 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 1184 | create()..mergeFromBuffer(i, r); 1185 | factory LoginRequest.fromJson($core.String i, 1186 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 1187 | create()..mergeFromJson(i, r); 1188 | LoginRequest clone() => LoginRequest()..mergeFromMessage(this); 1189 | LoginRequest copyWith(void Function(LoginRequest) updates) => 1190 | super.copyWith((message) => updates(message as LoginRequest)) as LoginRequest; 1191 | $pb.BuilderInfo get info_ => _i; 1192 | @$core.pragma('dart2js:noInline') 1193 | static LoginRequest create() => LoginRequest._(); 1194 | LoginRequest createEmptyInstance() => create(); 1195 | static $pb.PbList createRepeated() => 1196 | $pb.PbList(); 1197 | @$core.pragma('dart2js:noInline') 1198 | static LoginRequest getDefault() => _defaultInstance ??= 1199 | $pb.GeneratedMessage.$_defaultFor(create); 1200 | static LoginRequest? _defaultInstance; 1201 | 1202 | @$pb.TagNumber(1) 1203 | $core.String get userid => $_getSZ(0); 1204 | @$pb.TagNumber(1) 1205 | set userid($core.String v) { 1206 | $_setString(0, v); 1207 | } 1208 | 1209 | @$pb.TagNumber(1) 1210 | $core.bool hasUserid() => $_has(0); 1211 | @$pb.TagNumber(1) 1212 | void clearUserid() => clearField(1); 1213 | 1214 | @$pb.TagNumber(2) 1215 | $core.String get password => $_getSZ(1); 1216 | @$pb.TagNumber(2) 1217 | set password($core.String v) { 1218 | $_setString(1, v); 1219 | } 1220 | 1221 | @$pb.TagNumber(2) 1222 | $core.bool hasPassword() => $_has(1); 1223 | @$pb.TagNumber(2) 1224 | void clearPassword() => clearField(2); 1225 | 1226 | @$pb.TagNumber(3) 1227 | $core.String get refreshToken => $_getSZ(2); 1228 | @$pb.TagNumber(3) 1229 | set refreshToken($core.String v) { 1230 | $_setString(2, v); 1231 | } 1232 | 1233 | @$pb.TagNumber(3) 1234 | $core.bool hasRefreshToken() => $_has(2); 1235 | @$pb.TagNumber(3) 1236 | void clearRefreshToken() => clearField(3); 1237 | } 1238 | 1239 | class Jwt extends $pb.GeneratedMessage { 1240 | static final $pb.BuilderInfo _i = $pb.BuilderInfo('Jwt', 1241 | package: const $pb.PackageName('api'), createEmptyInstance: create) 1242 | ..aOS(1, 'accessJwt') 1243 | ..aOS(2, 'refreshJwt') 1244 | ..hasRequiredFields = false; 1245 | 1246 | Jwt._() : super(); 1247 | factory Jwt() => create(); 1248 | factory Jwt.fromBuffer($core.List<$core.int> i, 1249 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 1250 | create()..mergeFromBuffer(i, r); 1251 | factory Jwt.fromJson($core.String i, 1252 | [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => 1253 | create()..mergeFromJson(i, r); 1254 | Jwt clone() => Jwt()..mergeFromMessage(this); 1255 | Jwt copyWith(void Function(Jwt) updates) => 1256 | super.copyWith((message) => updates(message as Jwt)) as Jwt; 1257 | $pb.BuilderInfo get info_ => _i; 1258 | @$core.pragma('dart2js:noInline') 1259 | static Jwt create() => Jwt._(); 1260 | Jwt createEmptyInstance() => create(); 1261 | static $pb.PbList createRepeated() => $pb.PbList(); 1262 | @$core.pragma('dart2js:noInline') 1263 | static Jwt getDefault() => 1264 | _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); 1265 | static Jwt? _defaultInstance; 1266 | 1267 | @$pb.TagNumber(1) 1268 | $core.String get accessJwt => $_getSZ(0); 1269 | @$pb.TagNumber(1) 1270 | set accessJwt($core.String v) { 1271 | $_setString(0, v); 1272 | } 1273 | 1274 | @$pb.TagNumber(1) 1275 | $core.bool hasAccessJwt() => $_has(0); 1276 | @$pb.TagNumber(1) 1277 | void clearAccessJwt() => clearField(1); 1278 | 1279 | @$pb.TagNumber(2) 1280 | $core.String get refreshJwt => $_getSZ(1); 1281 | @$pb.TagNumber(2) 1282 | set refreshJwt($core.String v) { 1283 | $_setString(1, v); 1284 | } 1285 | 1286 | @$pb.TagNumber(2) 1287 | $core.bool hasRefreshJwt() => $_has(1); 1288 | @$pb.TagNumber(2) 1289 | void clearRefreshJwt() => clearField(2); 1290 | } 1291 | 1292 | class DgraphApi { 1293 | $pb.RpcClient _client; 1294 | DgraphApi(this._client); 1295 | 1296 | $async.Future login($pb.ClientContext ctx, LoginRequest request) { 1297 | var emptyResponse = Response(); 1298 | return _client.invoke( 1299 | ctx, 'Dgraph', 'Login', request, emptyResponse); 1300 | } 1301 | 1302 | $async.Future query($pb.ClientContext ctx, Request request) { 1303 | var emptyResponse = Response(); 1304 | return _client.invoke( 1305 | ctx, 'Dgraph', 'Query', request, emptyResponse); 1306 | } 1307 | 1308 | $async.Future alter($pb.ClientContext ctx, Operation request) { 1309 | var emptyResponse = Payload(); 1310 | return _client.invoke( 1311 | ctx, 'Dgraph', 'Alter', request, emptyResponse); 1312 | } 1313 | 1314 | $async.Future commitOrAbort( 1315 | $pb.ClientContext ctx, TxnContext request) { 1316 | var emptyResponse = TxnContext(); 1317 | return _client.invoke( 1318 | ctx, 'Dgraph', 'CommitOrAbort', request, emptyResponse); 1319 | } 1320 | 1321 | $async.Future checkVersion($pb.ClientContext ctx, Check request) { 1322 | var emptyResponse = Version(); 1323 | return _client.invoke( 1324 | ctx, 'Dgraph', 'CheckVersion', request, emptyResponse); 1325 | } 1326 | } 1327 | --------------------------------------------------------------------------------