chore: remove the greetings demo
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
a4fcd98e4a
commit
059f33ef80
14 changed files with 12 additions and 606 deletions
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||||
import 'dart:async' as _ida;
|
import 'dart:async' as _ida;
|
||||||
import 'package:halkyon_learn_client/src/protocol/greetings/greeting.dart'
|
|
||||||
as _ili0bmg9;
|
|
||||||
import 'package:http/http.dart' as _i85jenna;
|
import 'package:http/http.dart' as _i85jenna;
|
||||||
import 'package:serverpod_auth_core_client/serverpod_auth_core_client.dart'
|
import 'package:serverpod_auth_core_client/serverpod_auth_core_client.dart'
|
||||||
as _iacc;
|
as _iacc;
|
||||||
|
|
@ -246,24 +244,6 @@ class EndpointJwtRefresh extends _iacc.EndpointRefreshJwtTokens {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is an example endpoint that returns a greeting message through
|
|
||||||
/// its [hello] method.
|
|
||||||
/// {@category Endpoint}
|
|
||||||
class EndpointGreeting extends _isc.EndpointRef {
|
|
||||||
EndpointGreeting(_isc.EndpointCaller caller) : super(caller);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get name => 'greeting';
|
|
||||||
|
|
||||||
/// Returns a personalized greeting message: "Hello {name}".
|
|
||||||
_ida.Future<_ili0bmg9.Greeting> hello(String name) =>
|
|
||||||
caller.callServerEndpoint<_ili0bmg9.Greeting>(
|
|
||||||
'greeting',
|
|
||||||
'hello',
|
|
||||||
{'name': name},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class Modules {
|
class Modules {
|
||||||
Modules(Client client) {
|
Modules(Client client) {
|
||||||
serverpod_auth_idp = _iaic.Caller(client);
|
serverpod_auth_idp = _iaic.Caller(client);
|
||||||
|
|
@ -304,7 +284,6 @@ class Client extends _isc.ServerpodClientShared {
|
||||||
) {
|
) {
|
||||||
emailIdp = EndpointEmailIdp(this);
|
emailIdp = EndpointEmailIdp(this);
|
||||||
jwtRefresh = EndpointJwtRefresh(this);
|
jwtRefresh = EndpointJwtRefresh(this);
|
||||||
greeting = EndpointGreeting(this);
|
|
||||||
modules = Modules(this);
|
modules = Modules(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,15 +291,12 @@ class Client extends _isc.ServerpodClientShared {
|
||||||
|
|
||||||
late final EndpointJwtRefresh jwtRefresh;
|
late final EndpointJwtRefresh jwtRefresh;
|
||||||
|
|
||||||
late final EndpointGreeting greeting;
|
|
||||||
|
|
||||||
late final Modules modules;
|
late final Modules modules;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, _isc.EndpointRef> get endpointRefLookup => {
|
Map<String, _isc.EndpointRef> get endpointRefLookup => {
|
||||||
'emailIdp': emailIdp,
|
'emailIdp': emailIdp,
|
||||||
'jwtRefresh': jwtRefresh,
|
'jwtRefresh': jwtRefresh,
|
||||||
'greeting': greeting,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
|
|
||||||
/* To generate run: "serverpod generate" */
|
|
||||||
|
|
||||||
// ignore_for_file: implementation_imports
|
|
||||||
// ignore_for_file: library_private_types_in_public_api
|
|
||||||
// ignore_for_file: non_constant_identifier_names
|
|
||||||
// ignore_for_file: public_member_api_docs
|
|
||||||
// ignore_for_file: type_literal_in_constant_pattern
|
|
||||||
// ignore_for_file: use_super_parameters
|
|
||||||
// ignore_for_file: invalid_use_of_internal_member
|
|
||||||
|
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
|
||||||
import 'package:serverpod_client/serverpod_client.dart' as _isc;
|
|
||||||
|
|
||||||
/// A greeting message which can be sent to or from the server.
|
|
||||||
abstract class Greeting
|
|
||||||
implements _isc.SerializableModel, _isc.ProtocolSerialization {
|
|
||||||
Greeting._({
|
|
||||||
required this.message,
|
|
||||||
required this.author,
|
|
||||||
required this.timestamp,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Greeting({
|
|
||||||
required String message,
|
|
||||||
required String author,
|
|
||||||
required DateTime timestamp,
|
|
||||||
}) = _GreetingImpl;
|
|
||||||
|
|
||||||
factory Greeting.fromJson(Map<String, dynamic> jsonSerialization) {
|
|
||||||
return Greeting(
|
|
||||||
message: jsonSerialization['message'] as String,
|
|
||||||
author: jsonSerialization['author'] as String,
|
|
||||||
timestamp: _isc.DateTimeJsonExtension.fromJson(
|
|
||||||
jsonSerialization['timestamp'],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The greeting message.
|
|
||||||
String message;
|
|
||||||
|
|
||||||
/// The author of the greeting message.
|
|
||||||
String author;
|
|
||||||
|
|
||||||
/// The time when the message was created.
|
|
||||||
DateTime timestamp;
|
|
||||||
|
|
||||||
/// Returns a shallow copy of this [Greeting]
|
|
||||||
/// with some or all fields replaced by the given arguments.
|
|
||||||
@_isc.useResult
|
|
||||||
Greeting copyWith({
|
|
||||||
String? message,
|
|
||||||
String? author,
|
|
||||||
DateTime? timestamp,
|
|
||||||
});
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'__className__': 'Greeting',
|
|
||||||
'message': message,
|
|
||||||
'author': author,
|
|
||||||
'timestamp': timestamp.toJson(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJsonForProtocol() {
|
|
||||||
return {
|
|
||||||
'__className__': 'Greeting',
|
|
||||||
'message': message,
|
|
||||||
'author': author,
|
|
||||||
'timestamp': timestamp.toJson(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return _isc.SerializationManager.encode(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GreetingImpl extends Greeting {
|
|
||||||
_GreetingImpl({
|
|
||||||
required String message,
|
|
||||||
required String author,
|
|
||||||
required DateTime timestamp,
|
|
||||||
}) : super._(
|
|
||||||
message: message,
|
|
||||||
author: author,
|
|
||||||
timestamp: timestamp,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Returns a shallow copy of this [Greeting]
|
|
||||||
/// with some or all fields replaced by the given arguments.
|
|
||||||
@_isc.useResult
|
|
||||||
@override
|
|
||||||
Greeting copyWith({
|
|
||||||
String? message,
|
|
||||||
String? author,
|
|
||||||
DateTime? timestamp,
|
|
||||||
}) {
|
|
||||||
return Greeting(
|
|
||||||
message: message ?? this.message,
|
|
||||||
author: author ?? this.author,
|
|
||||||
timestamp: timestamp ?? this.timestamp,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -16,8 +16,6 @@ import 'package:serverpod_auth_core_client/serverpod_auth_core_client.dart'
|
||||||
import 'package:serverpod_auth_idp_client/serverpod_auth_idp_client.dart'
|
import 'package:serverpod_auth_idp_client/serverpod_auth_idp_client.dart'
|
||||||
as _iaic;
|
as _iaic;
|
||||||
import 'package:serverpod_client/serverpod_client.dart' as _isc;
|
import 'package:serverpod_client/serverpod_client.dart' as _isc;
|
||||||
import 'greetings/greeting.dart' as _izw8z7ou;
|
|
||||||
export 'greetings/greeting.dart';
|
|
||||||
export 'client.dart';
|
export 'client.dart';
|
||||||
|
|
||||||
class Protocol extends _isc.SerializationManager {
|
class Protocol extends _isc.SerializationManager {
|
||||||
|
|
@ -54,12 +52,6 @@ class Protocol extends _isc.SerializationManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t == _izw8z7ou.Greeting) {
|
|
||||||
return _izw8z7ou.Greeting.fromJson(data) as T;
|
|
||||||
}
|
|
||||||
if (t == _isc.getType<_izw8z7ou.Greeting?>()) {
|
|
||||||
return (data != null ? _izw8z7ou.Greeting.fromJson(data) : null) as T;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return _iaic.Protocol().deserialize<T>(data, t);
|
return _iaic.Protocol().deserialize<T>(data, t);
|
||||||
} on _isc.DeserializationTypeNotFoundException catch (_) {}
|
} on _isc.DeserializationTypeNotFoundException catch (_) {}
|
||||||
|
|
@ -71,7 +63,6 @@ class Protocol extends _isc.SerializationManager {
|
||||||
|
|
||||||
static String? getClassNameForType(Type type) {
|
static String? getClassNameForType(Type type) {
|
||||||
return switch (type) {
|
return switch (type) {
|
||||||
_izw8z7ou.Greeting => 'Greeting',
|
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -88,10 +79,6 @@ class Protocol extends _isc.SerializationManager {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (data) {
|
|
||||||
case _izw8z7ou.Greeting():
|
|
||||||
return 'Greeting';
|
|
||||||
}
|
|
||||||
className = _iaic.Protocol().getClassNameForObject(data);
|
className = _iaic.Protocol().getClassNameForObject(data);
|
||||||
if (className != null) {
|
if (className != null) {
|
||||||
return className.contains('.')
|
return className.contains('.')
|
||||||
|
|
@ -113,9 +100,6 @@ class Protocol extends _isc.SerializationManager {
|
||||||
if (dataClassName is! String) {
|
if (dataClassName is! String) {
|
||||||
return super.deserializeByClassName(data);
|
return super.deserializeByClassName(data);
|
||||||
}
|
}
|
||||||
if (dataClassName == 'Greeting') {
|
|
||||||
return deserialize<_izw8z7ou.Greeting>(data['data']);
|
|
||||||
}
|
|
||||||
if (dataClassName.startsWith('serverpod_auth_idp.')) {
|
if (dataClassName.startsWith('serverpod_auth_idp.')) {
|
||||||
data['className'] = dataClassName.substring(19);
|
data['className'] = dataClassName.substring(19);
|
||||||
return _iaic.Protocol().deserializeByClassName(data);
|
return _iaic.Protocol().deserializeByClassName(data);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'client.dart';
|
import 'client.dart';
|
||||||
import 'screens/greetings_screen.dart';
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await initializeClient();
|
await initializeClient();
|
||||||
runApp(const MyApp());
|
runApp(const HalkyonLearnApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a theme for the given [brightness].
|
/// Builds a theme for the given [brightness].
|
||||||
|
|
@ -19,43 +18,17 @@ ThemeData _buildTheme(Brightness brightness) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class HalkyonLearnApp extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const HalkyonLearnApp({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Serverpod Demo',
|
title: 'Halkyon Learn',
|
||||||
theme: _buildTheme(Brightness.light),
|
theme: _buildTheme(Brightness.light),
|
||||||
darkTheme: _buildTheme(Brightness.dark),
|
darkTheme: _buildTheme(Brightness.dark),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
home: const MyHomePage(title: 'Serverpod Example'),
|
home: Scaffold(appBar: AppBar(title: Text('Halkyon Learn'))),
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyHomePage extends StatelessWidget {
|
|
||||||
const MyHomePage({super.key, required this.title});
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(title: Text(title)),
|
|
||||||
body: const GreetingsScreen(),
|
|
||||||
// To test authentication in this example app, uncomment the line below
|
|
||||||
// and comment out the line above. This wraps the GreetingsScreen with a
|
|
||||||
// SignInScreen, which automatically shows a sign-in UI when the user is
|
|
||||||
// not authenticated and displays the GreetingsScreen once they sign in.
|
|
||||||
//
|
|
||||||
// body: SignInScreen(
|
|
||||||
// child: GreetingsScreen(
|
|
||||||
// onSignOut: () async {
|
|
||||||
// await client.auth.signOutDevice();
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import '../client.dart';
|
|
||||||
|
|
||||||
class GreetingsScreen extends StatefulWidget {
|
|
||||||
final Future<void> Function()? onSignOut;
|
|
||||||
const GreetingsScreen({super.key, this.onSignOut});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<GreetingsScreen> createState() => _GreetingsScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GreetingsScreenState extends State<GreetingsScreen> {
|
|
||||||
/// Holds the last result or null if no result exists yet.
|
|
||||||
String? _resultMessage;
|
|
||||||
|
|
||||||
/// Holds the last error message that we've received from the server or null
|
|
||||||
/// if no error exists yet.
|
|
||||||
String? _errorMessage;
|
|
||||||
|
|
||||||
final _textEditingController = TextEditingController();
|
|
||||||
|
|
||||||
/// Calls the `hello` method of the `greeting` endpoint. Will set either the
|
|
||||||
/// `_resultMessage` or `_errorMessage` field, depending on if the call
|
|
||||||
/// is successful.
|
|
||||||
void _callHello() async {
|
|
||||||
try {
|
|
||||||
final result = await client.greeting.hello(_textEditingController.text);
|
|
||||||
setState(() {
|
|
||||||
_errorMessage = null;
|
|
||||||
_resultMessage = result.message;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
_errorMessage = '$e';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
if (widget.onSignOut != null) ...[
|
|
||||||
const Text('You are connected'),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: widget.onSignOut,
|
|
||||||
child: const Text('Sign out'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
TextField(
|
|
||||||
controller: _textEditingController,
|
|
||||||
onSubmitted: (_) => _callHello(),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: 'Enter your name',
|
|
||||||
border: const OutlineInputBorder(),
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
onPressed: _callHello,
|
|
||||||
icon: const Icon(Icons.send),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
ResultDisplay(
|
|
||||||
resultMessage: _resultMessage,
|
|
||||||
errorMessage: _errorMessage,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ResultDisplays shows the result of the call. Either the returned result
|
|
||||||
/// from the `example.greeting` endpoint method or an error message.
|
|
||||||
class ResultDisplay extends StatelessWidget {
|
|
||||||
final String? resultMessage;
|
|
||||||
final String? errorMessage;
|
|
||||||
|
|
||||||
const ResultDisplay({super.key, this.resultMessage, this.errorMessage});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final colors = Theme.of(context).colorScheme;
|
|
||||||
|
|
||||||
String text;
|
|
||||||
Color backgroundColor;
|
|
||||||
Color foregroundColor;
|
|
||||||
if (errorMessage != null) {
|
|
||||||
backgroundColor = colors.errorContainer;
|
|
||||||
foregroundColor = colors.onErrorContainer;
|
|
||||||
text = errorMessage!;
|
|
||||||
} else if (resultMessage != null) {
|
|
||||||
backgroundColor = colors.primaryContainer;
|
|
||||||
foregroundColor = colors.onPrimaryContainer;
|
|
||||||
text = resultMessage!;
|
|
||||||
} else {
|
|
||||||
backgroundColor = colors.surfaceContainerHighest;
|
|
||||||
foregroundColor = colors.onSurfaceVariant;
|
|
||||||
text = 'No server response yet.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
constraints: const BoxConstraints(minHeight: 60),
|
|
||||||
width: double.infinity,
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
// Reuses the text field's border so the shape and width always match.
|
|
||||||
decoration: ShapeDecoration(
|
|
||||||
color: backgroundColor,
|
|
||||||
shape: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: foregroundColor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: Text(text, style: TextStyle(color: foregroundColor)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +1,10 @@
|
||||||
// This is a basic Flutter widget test.
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
//
|
import 'package:halkyon_learn_flutter/main.dart';
|
||||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
|
||||||
// utility that Flutter provides. For example, you can send tap and scroll
|
|
||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
|
||||||
|
|
||||||
// import 'package:flutter/material.dart';
|
|
||||||
// import 'package:flutter_test/flutter_test.dart';
|
|
||||||
//
|
|
||||||
// import 'package:PROJECTNAME_flutter/main.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// Add your app tests here
|
testWidgets('shows the app name', (tester) async {
|
||||||
|
await tester.pumpWidget(const HalkyonLearnApp());
|
||||||
|
|
||||||
|
expect(find.text('Halkyon Learn'), findsOneWidget);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ import 'package:serverpod_auth_idp_server/serverpod_auth_idp_server.dart'
|
||||||
as _iais;
|
as _iais;
|
||||||
import '../auth/email_idp_endpoint.dart' as _iuc1hd5t;
|
import '../auth/email_idp_endpoint.dart' as _iuc1hd5t;
|
||||||
import '../auth/jwt_refresh_endpoint.dart' as _inwq3ztq;
|
import '../auth/jwt_refresh_endpoint.dart' as _inwq3ztq;
|
||||||
import '../greetings/greeting_endpoint.dart' as _il624ik7;
|
|
||||||
|
|
||||||
class Endpoints extends _is.EndpointDispatch {
|
class Endpoints extends _is.EndpointDispatch {
|
||||||
@override
|
@override
|
||||||
|
|
@ -35,12 +34,6 @@ class Endpoints extends _is.EndpointDispatch {
|
||||||
'jwtRefresh',
|
'jwtRefresh',
|
||||||
null,
|
null,
|
||||||
),
|
),
|
||||||
'greeting': _il624ik7.GreetingEndpoint()
|
|
||||||
..initialize(
|
|
||||||
server,
|
|
||||||
'greeting',
|
|
||||||
null,
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
connectors['emailIdp'] = _is.EndpointConnector(
|
connectors['emailIdp'] = _is.EndpointConnector(
|
||||||
name: 'emailIdp',
|
name: 'emailIdp',
|
||||||
|
|
@ -248,31 +241,6 @@ class Endpoints extends _is.EndpointDispatch {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
connectors['greeting'] = _is.EndpointConnector(
|
|
||||||
name: 'greeting',
|
|
||||||
endpoint: endpoints['greeting']!,
|
|
||||||
methodConnectors: {
|
|
||||||
'hello': _is.MethodConnector(
|
|
||||||
name: 'hello',
|
|
||||||
params: {
|
|
||||||
'name': _is.ParameterDescription(
|
|
||||||
name: 'name',
|
|
||||||
type: _is.getType<String>(),
|
|
||||||
nullable: false,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
call:
|
|
||||||
(
|
|
||||||
_is.Session session,
|
|
||||||
Map<String, dynamic> params,
|
|
||||||
) async =>
|
|
||||||
(endpoints['greeting'] as _il624ik7.GreetingEndpoint).hello(
|
|
||||||
session,
|
|
||||||
params['name'],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
modules['serverpod_auth_idp'] = _iais.Endpoints()
|
modules['serverpod_auth_idp'] = _iais.Endpoints()
|
||||||
..initializeEndpoints(server);
|
..initializeEndpoints(server);
|
||||||
modules['serverpod_auth_core'] = _iacs.Endpoints()
|
modules['serverpod_auth_core'] = _iacs.Endpoints()
|
||||||
|
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
|
|
||||||
/* To generate run: "serverpod generate" */
|
|
||||||
|
|
||||||
// ignore_for_file: implementation_imports
|
|
||||||
// ignore_for_file: library_private_types_in_public_api
|
|
||||||
// ignore_for_file: non_constant_identifier_names
|
|
||||||
// ignore_for_file: public_member_api_docs
|
|
||||||
// ignore_for_file: type_literal_in_constant_pattern
|
|
||||||
// ignore_for_file: use_super_parameters
|
|
||||||
// ignore_for_file: invalid_use_of_internal_member
|
|
||||||
|
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
|
||||||
import 'package:serverpod/serverpod.dart' as _is;
|
|
||||||
|
|
||||||
/// A greeting message which can be sent to or from the server.
|
|
||||||
abstract class Greeting
|
|
||||||
implements _is.SerializableModel, _is.ProtocolSerialization {
|
|
||||||
Greeting._({
|
|
||||||
required this.message,
|
|
||||||
required this.author,
|
|
||||||
required this.timestamp,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Greeting({
|
|
||||||
required String message,
|
|
||||||
required String author,
|
|
||||||
required DateTime timestamp,
|
|
||||||
}) = _GreetingImpl;
|
|
||||||
|
|
||||||
factory Greeting.fromJson(Map<String, dynamic> jsonSerialization) {
|
|
||||||
return Greeting(
|
|
||||||
message: jsonSerialization['message'] as String,
|
|
||||||
author: jsonSerialization['author'] as String,
|
|
||||||
timestamp: _is.DateTimeJsonExtension.fromJson(
|
|
||||||
jsonSerialization['timestamp'],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The greeting message.
|
|
||||||
String message;
|
|
||||||
|
|
||||||
/// The author of the greeting message.
|
|
||||||
String author;
|
|
||||||
|
|
||||||
/// The time when the message was created.
|
|
||||||
DateTime timestamp;
|
|
||||||
|
|
||||||
/// Returns a shallow copy of this [Greeting]
|
|
||||||
/// with some or all fields replaced by the given arguments.
|
|
||||||
@_is.useResult
|
|
||||||
Greeting copyWith({
|
|
||||||
String? message,
|
|
||||||
String? author,
|
|
||||||
DateTime? timestamp,
|
|
||||||
});
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'__className__': 'Greeting',
|
|
||||||
'message': message,
|
|
||||||
'author': author,
|
|
||||||
'timestamp': timestamp.toJson(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, dynamic> toJsonForProtocol() {
|
|
||||||
return {
|
|
||||||
'__className__': 'Greeting',
|
|
||||||
'message': message,
|
|
||||||
'author': author,
|
|
||||||
'timestamp': timestamp.toJson(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return _is.SerializationManager.encode(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GreetingImpl extends Greeting {
|
|
||||||
_GreetingImpl({
|
|
||||||
required String message,
|
|
||||||
required String author,
|
|
||||||
required DateTime timestamp,
|
|
||||||
}) : super._(
|
|
||||||
message: message,
|
|
||||||
author: author,
|
|
||||||
timestamp: timestamp,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Returns a shallow copy of this [Greeting]
|
|
||||||
/// with some or all fields replaced by the given arguments.
|
|
||||||
@_is.useResult
|
|
||||||
@override
|
|
||||||
Greeting copyWith({
|
|
||||||
String? message,
|
|
||||||
String? author,
|
|
||||||
DateTime? timestamp,
|
|
||||||
}) {
|
|
||||||
return Greeting(
|
|
||||||
message: message ?? this.message,
|
|
||||||
author: author ?? this.author,
|
|
||||||
timestamp: timestamp ?? this.timestamp,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -17,8 +17,6 @@ import 'package:serverpod_auth_core_server/serverpod_auth_core_server.dart'
|
||||||
as _iacs;
|
as _iacs;
|
||||||
import 'package:serverpod_auth_idp_server/serverpod_auth_idp_server.dart'
|
import 'package:serverpod_auth_idp_server/serverpod_auth_idp_server.dart'
|
||||||
as _iais;
|
as _iais;
|
||||||
import 'greetings/greeting.dart' as _izw8z7ou;
|
|
||||||
export 'greetings/greeting.dart';
|
|
||||||
|
|
||||||
class Protocol extends _is.DatabaseSerializationManager {
|
class Protocol extends _is.DatabaseSerializationManager {
|
||||||
Protocol._();
|
Protocol._();
|
||||||
|
|
@ -60,12 +58,6 @@ class Protocol extends _is.DatabaseSerializationManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t == _izw8z7ou.Greeting) {
|
|
||||||
return _izw8z7ou.Greeting.fromJson(data) as T;
|
|
||||||
}
|
|
||||||
if (t == _is.getType<_izw8z7ou.Greeting?>()) {
|
|
||||||
return (data != null ? _izw8z7ou.Greeting.fromJson(data) : null) as T;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
return _iais.Protocol().deserialize<T>(data, t);
|
return _iais.Protocol().deserialize<T>(data, t);
|
||||||
} on _is.DeserializationTypeNotFoundException catch (_) {}
|
} on _is.DeserializationTypeNotFoundException catch (_) {}
|
||||||
|
|
@ -80,7 +72,6 @@ class Protocol extends _is.DatabaseSerializationManager {
|
||||||
|
|
||||||
static String? getClassNameForType(Type type) {
|
static String? getClassNameForType(Type type) {
|
||||||
return switch (type) {
|
return switch (type) {
|
||||||
_izw8z7ou.Greeting => 'Greeting',
|
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -97,10 +88,6 @@ class Protocol extends _is.DatabaseSerializationManager {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (data) {
|
|
||||||
case _izw8z7ou.Greeting():
|
|
||||||
return 'Greeting';
|
|
||||||
}
|
|
||||||
className = _iais.Protocol().getClassNameForObject(data);
|
className = _iais.Protocol().getClassNameForObject(data);
|
||||||
if (className != null) {
|
if (className != null) {
|
||||||
return className.contains('.')
|
return className.contains('.')
|
||||||
|
|
@ -126,9 +113,6 @@ class Protocol extends _is.DatabaseSerializationManager {
|
||||||
if (dataClassName is! String) {
|
if (dataClassName is! String) {
|
||||||
return super.deserializeByClassName(data);
|
return super.deserializeByClassName(data);
|
||||||
}
|
}
|
||||||
if (dataClassName == 'Greeting') {
|
|
||||||
return deserialize<_izw8z7ou.Greeting>(data['data']);
|
|
||||||
}
|
|
||||||
if (dataClassName.startsWith('serverpod_auth_idp.')) {
|
if (dataClassName.startsWith('serverpod_auth_idp.')) {
|
||||||
data['className'] = dataClassName.substring(19);
|
data['className'] = dataClassName.substring(19);
|
||||||
return _iais.Protocol().deserializeByClassName(data);
|
return _iais.Protocol().deserializeByClassName(data);
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,3 @@ emailIdp:
|
||||||
- hasAccount:
|
- hasAccount:
|
||||||
jwtRefresh:
|
jwtRefresh:
|
||||||
- refreshAccessToken:
|
- refreshAccessToken:
|
||||||
greeting:
|
|
||||||
- hello:
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
# Yaml-files in the `models` directory specify which serializable objects
|
|
||||||
# should be generated. When you add or modify a file, you will need to run
|
|
||||||
# `serverpod generate` to make the generated classes available in the server and
|
|
||||||
# client.
|
|
||||||
#
|
|
||||||
# Please consult the documentation for more information on what you can add to
|
|
||||||
# your yaml-files.
|
|
||||||
|
|
||||||
### A greeting message which can be sent to or from the server.
|
|
||||||
class: Greeting
|
|
||||||
|
|
||||||
# Add the table key, if this class represents a row in the database.
|
|
||||||
#table: greeting
|
|
||||||
|
|
||||||
# The fields (and columns if connected to the database) of the class.
|
|
||||||
# For a list of supported types, please see the documentation.
|
|
||||||
# https://docs.serverpod.dev/concepts/working-with-endpoints
|
|
||||||
fields:
|
|
||||||
### The greeting message.
|
|
||||||
message: String
|
|
||||||
### The author of the greeting message.
|
|
||||||
author: String
|
|
||||||
### The time when the message was created.
|
|
||||||
timestamp: DateTime
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import '../generated/protocol.dart';
|
|
||||||
import 'package:serverpod/serverpod.dart';
|
|
||||||
|
|
||||||
// This is an example endpoint of your server. It's best practice to use the
|
|
||||||
// `Endpoint` ending of the class name, but it will be removed when accessing
|
|
||||||
// the endpoint from the client. I.e., this endpoint can be accessed through
|
|
||||||
// `client.greeting` on the client side.
|
|
||||||
|
|
||||||
// After adding or modifying an endpoint, you will need to run
|
|
||||||
// `serverpod generate` to update the server and client code.
|
|
||||||
|
|
||||||
/// This is an example endpoint that returns a greeting message through
|
|
||||||
/// its [hello] method.
|
|
||||||
class GreetingEndpoint extends Endpoint {
|
|
||||||
// This method is called when the client calls the `hello` method on the
|
|
||||||
// `greeting` endpoint.
|
|
||||||
//
|
|
||||||
// The `Session` parameter contains the context of the client request.
|
|
||||||
// It provides access to the database and other server-side resources like
|
|
||||||
// secrets from your password file, the cache, storage, and server-event
|
|
||||||
// messaging.
|
|
||||||
//
|
|
||||||
// You can use any serializable type as a parameter or return type, read more
|
|
||||||
// in the [docs](https://docs.serverpod.dev/concepts/working-with-endpoints).
|
|
||||||
|
|
||||||
/// Returns a personalized greeting message: "Hello {name}".
|
|
||||||
Future<Greeting> hello(Session session, String name) async {
|
|
||||||
return Greeting(
|
|
||||||
message: 'Hello $name',
|
|
||||||
author: 'Serverpod',
|
|
||||||
timestamp: DateTime.now(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
import 'package:test/test.dart';
|
|
||||||
|
|
||||||
// Import the generated test helper file, it contains everything you need.
|
|
||||||
import 'test_tools/serverpod_test_tools.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
// This is an example test that uses the `withServerpod` test helper.
|
|
||||||
// `withServerpod` enables you to call your endpoints directly from the test like regular functions.
|
|
||||||
// Note that after adding or modifying an endpoint, you will need to run
|
|
||||||
// `serverpod generate` to update the test tools code.
|
|
||||||
// Refer to the docs for more information on how to use the test helper.
|
|
||||||
withServerpod('Given Greeting endpoint', (sessionBuilder, endpoints) {
|
|
||||||
test(
|
|
||||||
'when calling `hello` with name then returned greeting includes name',
|
|
||||||
() async {
|
|
||||||
// Call the endpoint method by using the `endpoints` parameter and
|
|
||||||
// pass `sessionBuilder` as a first argument. Refer to the docs on
|
|
||||||
// how to use the `sessionBuilder` to set up different test scenarios.
|
|
||||||
final greeting = await endpoints.greeting.hello(sessionBuilder, 'Bob');
|
|
||||||
expect(greeting.message, 'Hello Bob');
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -13,8 +13,6 @@
|
||||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||||
import 'dart:async' as _ida;
|
import 'dart:async' as _ida;
|
||||||
import 'dart:io' as _idi;
|
import 'dart:io' as _idi;
|
||||||
import 'package:halkyon_learn_server/src/generated/greetings/greeting.dart'
|
|
||||||
as _if4yg514;
|
|
||||||
import 'package:serverpod/serverpod.dart' as _is;
|
import 'package:serverpod/serverpod.dart' as _is;
|
||||||
import 'package:serverpod_auth_core_server/serverpod_auth_core_server.dart'
|
import 'package:serverpod_auth_core_server/serverpod_auth_core_server.dart'
|
||||||
as _iacs;
|
as _iacs;
|
||||||
|
|
@ -150,8 +148,6 @@ class TestEndpoints {
|
||||||
late final _EmailIdpEndpoint emailIdp;
|
late final _EmailIdpEndpoint emailIdp;
|
||||||
|
|
||||||
late final _JwtRefreshEndpoint jwtRefresh;
|
late final _JwtRefreshEndpoint jwtRefresh;
|
||||||
|
|
||||||
late final _GreetingEndpoint greeting;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _InternalTestEndpoints extends TestEndpoints
|
class _InternalTestEndpoints extends TestEndpoints
|
||||||
|
|
@ -169,10 +165,6 @@ class _InternalTestEndpoints extends TestEndpoints
|
||||||
endpoints,
|
endpoints,
|
||||||
serializationManager,
|
serializationManager,
|
||||||
);
|
);
|
||||||
greeting = _GreetingEndpoint(
|
|
||||||
endpoints,
|
|
||||||
serializationManager,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -493,45 +485,3 @@ class _JwtRefreshEndpoint {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _GreetingEndpoint {
|
|
||||||
_GreetingEndpoint(
|
|
||||||
this._endpointDispatch,
|
|
||||||
this._serializationManager,
|
|
||||||
);
|
|
||||||
|
|
||||||
final _is.EndpointDispatch _endpointDispatch;
|
|
||||||
|
|
||||||
final _is.SerializationManager _serializationManager;
|
|
||||||
|
|
||||||
_ida.Future<_if4yg514.Greeting> hello(
|
|
||||||
_ist.TestSessionBuilder sessionBuilder,
|
|
||||||
String name,
|
|
||||||
) async {
|
|
||||||
return _ist.callAwaitableFunctionAndHandleExceptions(() async {
|
|
||||||
var _localUniqueSession =
|
|
||||||
(sessionBuilder as _ist.InternalTestSessionBuilder).internalBuild(
|
|
||||||
endpoint: 'greeting',
|
|
||||||
method: 'hello',
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
var _localCallContext = await _endpointDispatch.getMethodCallContext(
|
|
||||||
createSessionCallback: (_) => _localUniqueSession,
|
|
||||||
endpointPath: 'greeting',
|
|
||||||
methodName: 'hello',
|
|
||||||
parameters: _ist.testObjectToJson({'name': name}),
|
|
||||||
serializationManager: _serializationManager,
|
|
||||||
);
|
|
||||||
var _localReturnValue =
|
|
||||||
await (_localCallContext.method.call(
|
|
||||||
_localUniqueSession,
|
|
||||||
_localCallContext.arguments,
|
|
||||||
)
|
|
||||||
as _ida.Future<_if4yg514.Greeting>);
|
|
||||||
return _localReturnValue;
|
|
||||||
} finally {
|
|
||||||
await _localUniqueSession.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue