From acadc527136f44ce597289a68c6dc2a01cd1dff7 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 15 May 2019 20:05:07 +0200 Subject: [PATCH] add first task and generate authentication service --- .vscode/tasks.json | 20 +++++++ app/README.md | 16 ------ common/generated_io/.gitignore | 11 ++++ common/generated_io/analysis_options.yaml | 14 +++++ common/generated_io/lib/generated_io.dart | 10 ++++ .../lib/src/google/protobuf/empty.pb.dart | 32 ++++++++++++ .../lib/src/google/protobuf/empty.pbenum.dart | 6 +++ .../lib/src/google/protobuf/empty.pbjson.dart | 10 ++++ .../services/authentication_service.pb.dart | 44 ++++++++++++++++ .../authentication_service.pbenum.dart | 6 +++ .../authentication_service.pbgrpc.dart | 52 +++++++++++++++++++ .../authentication_service.pbjson.dart | 14 +++++ common/generated_io/pubspec.yaml | 16 ++++++ {proto => protos}/models/.gitkeep | 0 .../services/authentication_service.proto | 0 15 files changed, 235 insertions(+), 16 deletions(-) create mode 100644 .vscode/tasks.json delete mode 100644 app/README.md create mode 100644 common/generated_io/.gitignore create mode 100644 common/generated_io/analysis_options.yaml create mode 100644 common/generated_io/lib/generated_io.dart create mode 100644 common/generated_io/lib/src/google/protobuf/empty.pb.dart create mode 100644 common/generated_io/lib/src/google/protobuf/empty.pbenum.dart create mode 100644 common/generated_io/lib/src/google/protobuf/empty.pbjson.dart create mode 100644 common/generated_io/lib/src/services/authentication_service.pb.dart create mode 100644 common/generated_io/lib/src/services/authentication_service.pbenum.dart create mode 100644 common/generated_io/lib/src/services/authentication_service.pbgrpc.dart create mode 100644 common/generated_io/lib/src/services/authentication_service.pbjson.dart create mode 100644 common/generated_io/pubspec.yaml rename {proto => protos}/models/.gitkeep (100%) rename {proto => protos}/services/authentication_service.proto (100%) diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..3a71866 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,20 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "generate code from protos", + "type": "shell", + "command": "protoc", + "args": [ + "--dart_out=grpc:common/generated_io/lib/src", + "-Iprotos", + "-Ithird_party/protobuf/src", + "-Ithird_party/googleapis", + "google/protobuf/empty.proto", + "services/authentication_service.proto" + ], + } + ] +} \ No newline at end of file diff --git a/app/README.md b/app/README.md deleted file mode 100644 index c4256cf..0000000 --- a/app/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# stashall - -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/common/generated_io/.gitignore b/common/generated_io/.gitignore new file mode 100644 index 0000000..50602ac --- /dev/null +++ b/common/generated_io/.gitignore @@ -0,0 +1,11 @@ +# Files and directories created by pub +.dart_tool/ +.packages +# Remove the following pattern if you wish to check in your lock file +pubspec.lock + +# Conventional directory for build outputs +build/ + +# Directory created by dartdoc +doc/api/ diff --git a/common/generated_io/analysis_options.yaml b/common/generated_io/analysis_options.yaml new file mode 100644 index 0000000..a686c1b --- /dev/null +++ b/common/generated_io/analysis_options.yaml @@ -0,0 +1,14 @@ +# Defines a default set of lint rules enforced for +# projects at Google. For details and rationale, +# see https://github.com/dart-lang/pedantic#enabled-lints. +include: package:pedantic/analysis_options.yaml + +# For lint rules and documentation, see http://dart-lang.github.io/linter/lints. +# Uncomment to specify additional rules. +# linter: +# rules: +# - camel_case_types + +analyzer: +# exclude: +# - path/to/excluded/files/** diff --git a/common/generated_io/lib/generated_io.dart b/common/generated_io/lib/generated_io.dart new file mode 100644 index 0000000..36ce892 --- /dev/null +++ b/common/generated_io/lib/generated_io.dart @@ -0,0 +1,10 @@ +// from third party +export 'package:generated_io/src/google/protobuf/empty.pb.dart'; +export 'package:generated_io/src/google/protobuf/empty.pbenum.dart'; +export 'package:generated_io/src/google/protobuf/empty.pbjson.dart'; + +// authentication service +export 'package:generated_io/src/services/authentication_service.pb.dart'; +export 'package:generated_io/src/services/authentication_service.pbenum.dart'; +export 'package:generated_io/src/services/authentication_service.pbgrpc.dart'; +export 'package:generated_io/src/services/authentication_service.pbjson.dart'; diff --git a/common/generated_io/lib/src/google/protobuf/empty.pb.dart b/common/generated_io/lib/src/google/protobuf/empty.pb.dart new file mode 100644 index 0000000..b95717b --- /dev/null +++ b/common/generated_io/lib/src/google/protobuf/empty.pb.dart @@ -0,0 +1,32 @@ +/// +// Generated code. Do not modify. +// source: google/protobuf/empty.proto +/// +// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import + +// ignore: UNUSED_SHOWN_NAME +import 'dart:core' show int, bool, double, String, List, Map, override; + +import 'package:protobuf/protobuf.dart' as $pb; + +class Empty extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = new $pb.BuilderInfo('Empty', package: const $pb.PackageName('google.protobuf')) + ..hasRequiredFields = false + ; + + Empty() : super(); + Empty.fromBuffer(List i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) : super.fromBuffer(i, r); + Empty.fromJson(String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) : super.fromJson(i, r); + Empty clone() => new Empty()..mergeFromMessage(this); + Empty copyWith(void Function(Empty) updates) => super.copyWith((message) => updates(message as Empty)); + $pb.BuilderInfo get info_ => _i; + static Empty create() => new Empty(); + Empty createEmptyInstance() => create(); + static $pb.PbList createRepeated() => new $pb.PbList(); + static Empty getDefault() => _defaultInstance ??= create()..freeze(); + static Empty _defaultInstance; + static void $checkItem(Empty v) { + if (v is! Empty) $pb.checkItemFailed(v, _i.qualifiedMessageName); + } +} + diff --git a/common/generated_io/lib/src/google/protobuf/empty.pbenum.dart b/common/generated_io/lib/src/google/protobuf/empty.pbenum.dart new file mode 100644 index 0000000..41d9f53 --- /dev/null +++ b/common/generated_io/lib/src/google/protobuf/empty.pbenum.dart @@ -0,0 +1,6 @@ +/// +// Generated code. Do not modify. +// source: google/protobuf/empty.proto +/// +// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import + diff --git a/common/generated_io/lib/src/google/protobuf/empty.pbjson.dart b/common/generated_io/lib/src/google/protobuf/empty.pbjson.dart new file mode 100644 index 0000000..a5d2f03 --- /dev/null +++ b/common/generated_io/lib/src/google/protobuf/empty.pbjson.dart @@ -0,0 +1,10 @@ +/// +// Generated code. Do not modify. +// source: google/protobuf/empty.proto +/// +// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import + +const Empty$json = const { + '1': 'Empty', +}; + diff --git a/common/generated_io/lib/src/services/authentication_service.pb.dart b/common/generated_io/lib/src/services/authentication_service.pb.dart new file mode 100644 index 0000000..b0fc347 --- /dev/null +++ b/common/generated_io/lib/src/services/authentication_service.pb.dart @@ -0,0 +1,44 @@ +/// +// Generated code. Do not modify. +// source: services/authentication_service.proto +/// +// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import + +// ignore: UNUSED_SHOWN_NAME +import 'dart:core' show int, bool, double, String, List, Map, override; + +import 'package:protobuf/protobuf.dart' as $pb; + +class SigninRequest extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = new $pb.BuilderInfo('SigninRequest', package: const $pb.PackageName('stashall')) + ..aOS(1, 'email') + ..aOS(2, 'password') + ..hasRequiredFields = false + ; + + SigninRequest() : super(); + SigninRequest.fromBuffer(List i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) : super.fromBuffer(i, r); + SigninRequest.fromJson(String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) : super.fromJson(i, r); + SigninRequest clone() => new SigninRequest()..mergeFromMessage(this); + SigninRequest copyWith(void Function(SigninRequest) updates) => super.copyWith((message) => updates(message as SigninRequest)); + $pb.BuilderInfo get info_ => _i; + static SigninRequest create() => new SigninRequest(); + SigninRequest createEmptyInstance() => create(); + static $pb.PbList createRepeated() => new $pb.PbList(); + static SigninRequest getDefault() => _defaultInstance ??= create()..freeze(); + static SigninRequest _defaultInstance; + static void $checkItem(SigninRequest v) { + if (v is! SigninRequest) $pb.checkItemFailed(v, _i.qualifiedMessageName); + } + + String get email => $_getS(0, ''); + set email(String v) { $_setString(0, v); } + bool hasEmail() => $_has(0); + void clearEmail() => clearField(1); + + String get password => $_getS(1, ''); + set password(String v) { $_setString(1, v); } + bool hasPassword() => $_has(1); + void clearPassword() => clearField(2); +} + diff --git a/common/generated_io/lib/src/services/authentication_service.pbenum.dart b/common/generated_io/lib/src/services/authentication_service.pbenum.dart new file mode 100644 index 0000000..37b424a --- /dev/null +++ b/common/generated_io/lib/src/services/authentication_service.pbenum.dart @@ -0,0 +1,6 @@ +/// +// Generated code. Do not modify. +// source: services/authentication_service.proto +/// +// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import + diff --git a/common/generated_io/lib/src/services/authentication_service.pbgrpc.dart b/common/generated_io/lib/src/services/authentication_service.pbgrpc.dart new file mode 100644 index 0000000..efc7bab --- /dev/null +++ b/common/generated_io/lib/src/services/authentication_service.pbgrpc.dart @@ -0,0 +1,52 @@ +/// +// Generated code. Do not modify. +// source: services/authentication_service.proto +/// +// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import + +import 'dart:async' as $async; + +import 'package:grpc/grpc.dart'; + +import 'authentication_service.pb.dart'; +import '../google/protobuf/empty.pb.dart' as $0; +export 'authentication_service.pb.dart'; + +class AuthenticationServiceClient extends Client { + static final _$signin = new ClientMethod( + '/stashall.AuthenticationService/signin', + (SigninRequest value) => value.writeToBuffer(), + (List value) => new $0.Empty.fromBuffer(value)); + + AuthenticationServiceClient(ClientChannel channel, {CallOptions options}) + : super(channel, options: options); + + ResponseFuture<$0.Empty> signin(SigninRequest request, + {CallOptions options}) { + final call = $createCall( + _$signin, new $async.Stream.fromIterable([request]), + options: options); + return new ResponseFuture(call); + } +} + +abstract class AuthenticationServiceBase extends Service { + String get $name => 'stashall.AuthenticationService'; + + AuthenticationServiceBase() { + $addMethod(new ServiceMethod( + 'signin', + signin_Pre, + false, + false, + (List value) => new SigninRequest.fromBuffer(value), + ($0.Empty value) => value.writeToBuffer())); + } + + $async.Future<$0.Empty> signin_Pre( + ServiceCall call, $async.Future request) async { + return signin(call, await request); + } + + $async.Future<$0.Empty> signin(ServiceCall call, SigninRequest request); +} diff --git a/common/generated_io/lib/src/services/authentication_service.pbjson.dart b/common/generated_io/lib/src/services/authentication_service.pbjson.dart new file mode 100644 index 0000000..daea928 --- /dev/null +++ b/common/generated_io/lib/src/services/authentication_service.pbjson.dart @@ -0,0 +1,14 @@ +/// +// Generated code. Do not modify. +// source: services/authentication_service.proto +/// +// ignore_for_file: non_constant_identifier_names,library_prefixes,unused_import + +const SigninRequest$json = const { + '1': 'SigninRequest', + '2': const [ + const {'1': 'email', '3': 1, '4': 1, '5': 9, '10': 'email'}, + const {'1': 'password', '3': 2, '4': 1, '5': 9, '10': 'password'}, + ], +}; + diff --git a/common/generated_io/pubspec.yaml b/common/generated_io/pubspec.yaml new file mode 100644 index 0000000..f826fbb --- /dev/null +++ b/common/generated_io/pubspec.yaml @@ -0,0 +1,16 @@ +name: generated_io +description: A sample command-line application. +# version: 1.0.0 +# homepage: https://www.example.com +# author: kevin + +environment: + sdk: '>=2.1.0 <3.0.0' + +dependencies: + grpc: ^1.0.2 + protobuf: ^0.13.11 + +dev_dependencies: + pedantic: ^1.0.0 + test: ^1.0.0 diff --git a/proto/models/.gitkeep b/protos/models/.gitkeep similarity index 100% rename from proto/models/.gitkeep rename to protos/models/.gitkeep diff --git a/proto/services/authentication_service.proto b/protos/services/authentication_service.proto similarity index 100% rename from proto/services/authentication_service.proto rename to protos/services/authentication_service.proto