refactor user repo with helpers. better api validation etc.

This commit is contained in:
2025-01-01 19:58:19 +00:00
parent 8559b1c44e
commit 4d52186d21
23 changed files with 1802 additions and 237 deletions
@@ -1,7 +1,6 @@
import 'package:backend_dart/domain/data/user_data_source.dart';
import 'package:backend_dart/domain/entities/user.dart';
abstract class IDatabase {
UserDataSource<User> get users;
UserDataSource get users;
Future<void> close();
}
@@ -0,0 +1,34 @@
import 'package:backend_dart/domain/entities/project.dart';
/// Interface for managing project data interactions.
abstract class ProjectDataSource {
/// Creates a new project in the data source.
///
/// Throws an error if the creation fails.
Future<void> createProject(NewProject project);
/// Retrieves a project by its unique ID.
///
/// Returns `null` if no project is found.
Future<Project?> findProjectById(String id);
/// Retrieves all projects associated with a specific user.
///
/// Returns an empty list if no projects are found.
Future<List<Project>> findProjectsByUserId(String userId);
/// Updates an existing project in the data source.
///
/// Throws an error if the update fails.
Future<void> updateProject(ProjectUpdate project);
/// Deletes a project by its unique ID.
///
/// Throws an error if the deletion fails.
Future<void> deleteProject(String id);
/// Retrieves all projects in the data source.
///
/// Returns an empty list if no projects exist.
Future<List<Project>> findAllProjects();
}
@@ -1,18 +1,19 @@
import 'package:backend_dart/domain/entities/user.dart';
import 'package:backend_dart/domain/interface/error.dart';
import 'package:fpdart/fpdart.dart';
abstract class UserDataSource<T> {
TaskEither<IError, T> create(T user);
abstract class UserDataSource {
TaskEither<IError, User> create(UserCreate user);
TaskEither<IError, T> findByEmail(String email);
TaskEither<IError, User> findByEmail(String email);
TaskEither<IError, T> findById(String id);
TaskEither<IError, User> findById(String id);
TaskEither<IError, T> update(T user);
TaskEither<IError, User> update(UserUpdate user);
TaskEither<IError, void> delete(String id);
TaskEither<IError, List<T>> findAll();
TaskEither<IError, List<User>> findAll();
TaskEither<IError,String> generateId();
TaskEither<IError, String> generateId();
}
@@ -0,0 +1,36 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'project.freezed.dart';
@freezed
class NewProject with _$NewProject {
const factory NewProject({
required String name,
String? description,
String? clientId,
required String userId,
}) = _NewProject;
}
@freezed
class Project with _$Project {
const factory Project({
required String id,
required String name,
String? description,
String? clientId,
required String userId,
required DateTime createdAt,
required DateTime updatedAt,
}) = _Project;
}
@freezed
class ProjectUpdate with _$ProjectUpdate {
const factory ProjectUpdate({
String? name,
String? description,
String? clientId,
String? userId,
}) = _ProjectUpdate;
}
@@ -0,0 +1,644 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'project.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
/// @nodoc
mixin _$NewProject {
String get name => throw _privateConstructorUsedError;
String? get description => throw _privateConstructorUsedError;
String? get clientId => throw _privateConstructorUsedError;
String get userId => throw _privateConstructorUsedError;
/// Create a copy of NewProject
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$NewProjectCopyWith<NewProject> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $NewProjectCopyWith<$Res> {
factory $NewProjectCopyWith(
NewProject value, $Res Function(NewProject) then) =
_$NewProjectCopyWithImpl<$Res, NewProject>;
@useResult
$Res call(
{String name, String? description, String? clientId, String userId});
}
/// @nodoc
class _$NewProjectCopyWithImpl<$Res, $Val extends NewProject>
implements $NewProjectCopyWith<$Res> {
_$NewProjectCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of NewProject
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? description = freezed,
Object? clientId = freezed,
Object? userId = null,
}) {
return _then(_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: freezed == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String?,
clientId: freezed == clientId
? _value.clientId
: clientId // ignore: cast_nullable_to_non_nullable
as String?,
userId: null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$NewProjectImplCopyWith<$Res>
implements $NewProjectCopyWith<$Res> {
factory _$$NewProjectImplCopyWith(
_$NewProjectImpl value, $Res Function(_$NewProjectImpl) then) =
__$$NewProjectImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String name, String? description, String? clientId, String userId});
}
/// @nodoc
class __$$NewProjectImplCopyWithImpl<$Res>
extends _$NewProjectCopyWithImpl<$Res, _$NewProjectImpl>
implements _$$NewProjectImplCopyWith<$Res> {
__$$NewProjectImplCopyWithImpl(
_$NewProjectImpl _value, $Res Function(_$NewProjectImpl) _then)
: super(_value, _then);
/// Create a copy of NewProject
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? description = freezed,
Object? clientId = freezed,
Object? userId = null,
}) {
return _then(_$NewProjectImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: freezed == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String?,
clientId: freezed == clientId
? _value.clientId
: clientId // ignore: cast_nullable_to_non_nullable
as String?,
userId: null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$NewProjectImpl implements _NewProject {
const _$NewProjectImpl(
{required this.name,
this.description,
this.clientId,
required this.userId});
@override
final String name;
@override
final String? description;
@override
final String? clientId;
@override
final String userId;
@override
String toString() {
return 'NewProject(name: $name, description: $description, clientId: $clientId, userId: $userId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$NewProjectImpl &&
(identical(other.name, name) || other.name == name) &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.clientId, clientId) ||
other.clientId == clientId) &&
(identical(other.userId, userId) || other.userId == userId));
}
@override
int get hashCode =>
Object.hash(runtimeType, name, description, clientId, userId);
/// Create a copy of NewProject
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$NewProjectImplCopyWith<_$NewProjectImpl> get copyWith =>
__$$NewProjectImplCopyWithImpl<_$NewProjectImpl>(this, _$identity);
}
abstract class _NewProject implements NewProject {
const factory _NewProject(
{required final String name,
final String? description,
final String? clientId,
required final String userId}) = _$NewProjectImpl;
@override
String get name;
@override
String? get description;
@override
String? get clientId;
@override
String get userId;
/// Create a copy of NewProject
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$NewProjectImplCopyWith<_$NewProjectImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$Project {
String get id => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String? get description => throw _privateConstructorUsedError;
String? get clientId => throw _privateConstructorUsedError;
String get userId => throw _privateConstructorUsedError;
DateTime get createdAt => throw _privateConstructorUsedError;
DateTime get updatedAt => throw _privateConstructorUsedError;
/// Create a copy of Project
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ProjectCopyWith<Project> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProjectCopyWith<$Res> {
factory $ProjectCopyWith(Project value, $Res Function(Project) then) =
_$ProjectCopyWithImpl<$Res, Project>;
@useResult
$Res call(
{String id,
String name,
String? description,
String? clientId,
String userId,
DateTime createdAt,
DateTime updatedAt});
}
/// @nodoc
class _$ProjectCopyWithImpl<$Res, $Val extends Project>
implements $ProjectCopyWith<$Res> {
_$ProjectCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Project
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? description = freezed,
Object? clientId = freezed,
Object? userId = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: freezed == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String?,
clientId: freezed == clientId
? _value.clientId
: clientId // ignore: cast_nullable_to_non_nullable
as String?,
userId: null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
) as $Val);
}
}
/// @nodoc
abstract class _$$ProjectImplCopyWith<$Res> implements $ProjectCopyWith<$Res> {
factory _$$ProjectImplCopyWith(
_$ProjectImpl value, $Res Function(_$ProjectImpl) then) =
__$$ProjectImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String id,
String name,
String? description,
String? clientId,
String userId,
DateTime createdAt,
DateTime updatedAt});
}
/// @nodoc
class __$$ProjectImplCopyWithImpl<$Res>
extends _$ProjectCopyWithImpl<$Res, _$ProjectImpl>
implements _$$ProjectImplCopyWith<$Res> {
__$$ProjectImplCopyWithImpl(
_$ProjectImpl _value, $Res Function(_$ProjectImpl) _then)
: super(_value, _then);
/// Create a copy of Project
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? description = freezed,
Object? clientId = freezed,
Object? userId = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(_$ProjectImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: freezed == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String?,
clientId: freezed == clientId
? _value.clientId
: clientId // ignore: cast_nullable_to_non_nullable
as String?,
userId: null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
));
}
}
/// @nodoc
class _$ProjectImpl implements _Project {
const _$ProjectImpl(
{required this.id,
required this.name,
this.description,
this.clientId,
required this.userId,
required this.createdAt,
required this.updatedAt});
@override
final String id;
@override
final String name;
@override
final String? description;
@override
final String? clientId;
@override
final String userId;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
@override
String toString() {
return 'Project(id: $id, name: $name, description: $description, clientId: $clientId, userId: $userId, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProjectImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.clientId, clientId) ||
other.clientId == clientId) &&
(identical(other.userId, userId) || other.userId == userId) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt));
}
@override
int get hashCode => Object.hash(runtimeType, id, name, description, clientId,
userId, createdAt, updatedAt);
/// Create a copy of Project
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ProjectImplCopyWith<_$ProjectImpl> get copyWith =>
__$$ProjectImplCopyWithImpl<_$ProjectImpl>(this, _$identity);
}
abstract class _Project implements Project {
const factory _Project(
{required final String id,
required final String name,
final String? description,
final String? clientId,
required final String userId,
required final DateTime createdAt,
required final DateTime updatedAt}) = _$ProjectImpl;
@override
String get id;
@override
String get name;
@override
String? get description;
@override
String? get clientId;
@override
String get userId;
@override
DateTime get createdAt;
@override
DateTime get updatedAt;
/// Create a copy of Project
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ProjectImplCopyWith<_$ProjectImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$ProjectUpdate {
String? get name => throw _privateConstructorUsedError;
String? get description => throw _privateConstructorUsedError;
String? get clientId => throw _privateConstructorUsedError;
String? get userId => throw _privateConstructorUsedError;
/// Create a copy of ProjectUpdate
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ProjectUpdateCopyWith<ProjectUpdate> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ProjectUpdateCopyWith<$Res> {
factory $ProjectUpdateCopyWith(
ProjectUpdate value, $Res Function(ProjectUpdate) then) =
_$ProjectUpdateCopyWithImpl<$Res, ProjectUpdate>;
@useResult
$Res call(
{String? name, String? description, String? clientId, String? userId});
}
/// @nodoc
class _$ProjectUpdateCopyWithImpl<$Res, $Val extends ProjectUpdate>
implements $ProjectUpdateCopyWith<$Res> {
_$ProjectUpdateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ProjectUpdate
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = freezed,
Object? description = freezed,
Object? clientId = freezed,
Object? userId = freezed,
}) {
return _then(_value.copyWith(
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
description: freezed == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String?,
clientId: freezed == clientId
? _value.clientId
: clientId // ignore: cast_nullable_to_non_nullable
as String?,
userId: freezed == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val);
}
}
/// @nodoc
abstract class _$$ProjectUpdateImplCopyWith<$Res>
implements $ProjectUpdateCopyWith<$Res> {
factory _$$ProjectUpdateImplCopyWith(
_$ProjectUpdateImpl value, $Res Function(_$ProjectUpdateImpl) then) =
__$$ProjectUpdateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String? name, String? description, String? clientId, String? userId});
}
/// @nodoc
class __$$ProjectUpdateImplCopyWithImpl<$Res>
extends _$ProjectUpdateCopyWithImpl<$Res, _$ProjectUpdateImpl>
implements _$$ProjectUpdateImplCopyWith<$Res> {
__$$ProjectUpdateImplCopyWithImpl(
_$ProjectUpdateImpl _value, $Res Function(_$ProjectUpdateImpl) _then)
: super(_value, _then);
/// Create a copy of ProjectUpdate
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = freezed,
Object? description = freezed,
Object? clientId = freezed,
Object? userId = freezed,
}) {
return _then(_$ProjectUpdateImpl(
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
description: freezed == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String?,
clientId: freezed == clientId
? _value.clientId
: clientId // ignore: cast_nullable_to_non_nullable
as String?,
userId: freezed == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
class _$ProjectUpdateImpl implements _ProjectUpdate {
const _$ProjectUpdateImpl(
{this.name, this.description, this.clientId, this.userId});
@override
final String? name;
@override
final String? description;
@override
final String? clientId;
@override
final String? userId;
@override
String toString() {
return 'ProjectUpdate(name: $name, description: $description, clientId: $clientId, userId: $userId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ProjectUpdateImpl &&
(identical(other.name, name) || other.name == name) &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.clientId, clientId) ||
other.clientId == clientId) &&
(identical(other.userId, userId) || other.userId == userId));
}
@override
int get hashCode =>
Object.hash(runtimeType, name, description, clientId, userId);
/// Create a copy of ProjectUpdate
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ProjectUpdateImplCopyWith<_$ProjectUpdateImpl> get copyWith =>
__$$ProjectUpdateImplCopyWithImpl<_$ProjectUpdateImpl>(this, _$identity);
}
abstract class _ProjectUpdate implements ProjectUpdate {
const factory _ProjectUpdate(
{final String? name,
final String? description,
final String? clientId,
final String? userId}) = _$ProjectUpdateImpl;
@override
String? get name;
@override
String? get description;
@override
String? get clientId;
@override
String? get userId;
/// Create a copy of ProjectUpdate
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ProjectUpdateImplCopyWith<_$ProjectUpdateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
+24 -4
View File
@@ -5,11 +5,31 @@ part 'user.freezed.dart';
@freezed
class User with _$User {
const factory User({
String? id,
String? name,
String? email,
String? password,
required String id,
required String name,
required String email,
String? passwordHash,
DateTime? createdAt,
DateTime? updatedAt,
}) = _User;
}
@freezed
class UserCreate with _$UserCreate {
const factory UserCreate({
String? id,
required String name,
required String email,
required String password,
}) = _UserCreate;
}
@freezed
class UserUpdate with _$UserUpdate {
const factory UserUpdate({
required String id,
String? name,
String? email,
String? password,
}) = _UserUpdate;
}
@@ -16,10 +16,10 @@ final _privateConstructorUsedError = UnsupportedError(
/// @nodoc
mixin _$User {
String? get id => throw _privateConstructorUsedError;
String? get name => throw _privateConstructorUsedError;
String? get email => throw _privateConstructorUsedError;
String? get password => throw _privateConstructorUsedError;
String get id => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String get email => throw _privateConstructorUsedError;
String? get passwordHash => throw _privateConstructorUsedError;
DateTime? get createdAt => throw _privateConstructorUsedError;
DateTime? get updatedAt => throw _privateConstructorUsedError;
@@ -35,10 +35,10 @@ abstract class $UserCopyWith<$Res> {
_$UserCopyWithImpl<$Res, User>;
@useResult
$Res call(
{String? id,
String? name,
String? email,
String? password,
{String id,
String name,
String email,
String? passwordHash,
DateTime? createdAt,
DateTime? updatedAt});
}
@@ -58,29 +58,29 @@ class _$UserCopyWithImpl<$Res, $Val extends User>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? name = freezed,
Object? email = freezed,
Object? password = freezed,
Object? id = null,
Object? name = null,
Object? email = null,
Object? passwordHash = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(_value.copyWith(
id: freezed == id
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
email: freezed == email
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
password: freezed == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
passwordHash: freezed == passwordHash
? _value.passwordHash
: passwordHash // ignore: cast_nullable_to_non_nullable
as String?,
createdAt: freezed == createdAt
? _value.createdAt
@@ -102,10 +102,10 @@ abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> {
@override
@useResult
$Res call(
{String? id,
String? name,
String? email,
String? password,
{String id,
String name,
String email,
String? passwordHash,
DateTime? createdAt,
DateTime? updatedAt});
}
@@ -122,29 +122,29 @@ class __$$UserImplCopyWithImpl<$Res>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? name = freezed,
Object? email = freezed,
Object? password = freezed,
Object? id = null,
Object? name = null,
Object? email = null,
Object? passwordHash = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(_$UserImpl(
id: freezed == id
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
email: freezed == email
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
password: freezed == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
passwordHash: freezed == passwordHash
? _value.passwordHash
: passwordHash // ignore: cast_nullable_to_non_nullable
as String?,
createdAt: freezed == createdAt
? _value.createdAt
@@ -162,21 +162,21 @@ class __$$UserImplCopyWithImpl<$Res>
class _$UserImpl implements _User {
const _$UserImpl(
{this.id,
this.name,
this.email,
this.password,
{required this.id,
required this.name,
required this.email,
this.passwordHash,
this.createdAt,
this.updatedAt});
@override
final String? id;
final String id;
@override
final String? name;
final String name;
@override
final String? email;
final String email;
@override
final String? password;
final String? passwordHash;
@override
final DateTime? createdAt;
@override
@@ -184,7 +184,7 @@ class _$UserImpl implements _User {
@override
String toString() {
return 'User(id: $id, name: $name, email: $email, password: $password, createdAt: $createdAt, updatedAt: $updatedAt)';
return 'User(id: $id, name: $name, email: $email, passwordHash: $passwordHash, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
@@ -195,8 +195,8 @@ class _$UserImpl implements _User {
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.email, email) || other.email == email) &&
(identical(other.password, password) ||
other.password == password) &&
(identical(other.passwordHash, passwordHash) ||
other.passwordHash == passwordHash) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
@@ -204,8 +204,8 @@ class _$UserImpl implements _User {
}
@override
int get hashCode =>
Object.hash(runtimeType, id, name, email, password, createdAt, updatedAt);
int get hashCode => Object.hash(
runtimeType, id, name, email, passwordHash, createdAt, updatedAt);
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@@ -218,21 +218,21 @@ class _$UserImpl implements _User {
abstract class _User implements User {
const factory _User(
{final String? id,
final String? name,
final String? email,
final String? password,
{required final String id,
required final String name,
required final String email,
final String? passwordHash,
final DateTime? createdAt,
final DateTime? updatedAt}) = _$UserImpl;
@override
String? get id;
String get id;
@override
String? get name;
String get name;
@override
String? get email;
String get email;
@override
String? get password;
String? get passwordHash;
@override
DateTime? get createdAt;
@override
@@ -245,3 +245,370 @@ abstract class _User implements User {
_$$UserImplCopyWith<_$UserImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$UserCreate {
String? get id => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String get email => throw _privateConstructorUsedError;
String get password => throw _privateConstructorUsedError;
/// Create a copy of UserCreate
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$UserCreateCopyWith<UserCreate> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserCreateCopyWith<$Res> {
factory $UserCreateCopyWith(
UserCreate value, $Res Function(UserCreate) then) =
_$UserCreateCopyWithImpl<$Res, UserCreate>;
@useResult
$Res call({String? id, String name, String email, String password});
}
/// @nodoc
class _$UserCreateCopyWithImpl<$Res, $Val extends UserCreate>
implements $UserCreateCopyWith<$Res> {
_$UserCreateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of UserCreate
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? name = null,
Object? email = null,
Object? password = null,
}) {
return _then(_value.copyWith(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$UserCreateImplCopyWith<$Res>
implements $UserCreateCopyWith<$Res> {
factory _$$UserCreateImplCopyWith(
_$UserCreateImpl value, $Res Function(_$UserCreateImpl) then) =
__$$UserCreateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String? id, String name, String email, String password});
}
/// @nodoc
class __$$UserCreateImplCopyWithImpl<$Res>
extends _$UserCreateCopyWithImpl<$Res, _$UserCreateImpl>
implements _$$UserCreateImplCopyWith<$Res> {
__$$UserCreateImplCopyWithImpl(
_$UserCreateImpl _value, $Res Function(_$UserCreateImpl) _then)
: super(_value, _then);
/// Create a copy of UserCreate
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? name = null,
Object? email = null,
Object? password = null,
}) {
return _then(_$UserCreateImpl(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$UserCreateImpl implements _UserCreate {
const _$UserCreateImpl(
{this.id,
required this.name,
required this.email,
required this.password});
@override
final String? id;
@override
final String name;
@override
final String email;
@override
final String password;
@override
String toString() {
return 'UserCreate(id: $id, name: $name, email: $email, password: $password)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserCreateImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.email, email) || other.email == email) &&
(identical(other.password, password) ||
other.password == password));
}
@override
int get hashCode => Object.hash(runtimeType, id, name, email, password);
/// Create a copy of UserCreate
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$UserCreateImplCopyWith<_$UserCreateImpl> get copyWith =>
__$$UserCreateImplCopyWithImpl<_$UserCreateImpl>(this, _$identity);
}
abstract class _UserCreate implements UserCreate {
const factory _UserCreate(
{final String? id,
required final String name,
required final String email,
required final String password}) = _$UserCreateImpl;
@override
String? get id;
@override
String get name;
@override
String get email;
@override
String get password;
/// Create a copy of UserCreate
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UserCreateImplCopyWith<_$UserCreateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$UserUpdate {
String get id => throw _privateConstructorUsedError;
String? get name => throw _privateConstructorUsedError;
String? get email => throw _privateConstructorUsedError;
String? get password => throw _privateConstructorUsedError;
/// Create a copy of UserUpdate
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$UserUpdateCopyWith<UserUpdate> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserUpdateCopyWith<$Res> {
factory $UserUpdateCopyWith(
UserUpdate value, $Res Function(UserUpdate) then) =
_$UserUpdateCopyWithImpl<$Res, UserUpdate>;
@useResult
$Res call({String id, String? name, String? email, String? password});
}
/// @nodoc
class _$UserUpdateCopyWithImpl<$Res, $Val extends UserUpdate>
implements $UserUpdateCopyWith<$Res> {
_$UserUpdateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of UserUpdate
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = freezed,
Object? email = freezed,
Object? password = freezed,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
email: freezed == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
password: freezed == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val);
}
}
/// @nodoc
abstract class _$$UserUpdateImplCopyWith<$Res>
implements $UserUpdateCopyWith<$Res> {
factory _$$UserUpdateImplCopyWith(
_$UserUpdateImpl value, $Res Function(_$UserUpdateImpl) then) =
__$$UserUpdateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String id, String? name, String? email, String? password});
}
/// @nodoc
class __$$UserUpdateImplCopyWithImpl<$Res>
extends _$UserUpdateCopyWithImpl<$Res, _$UserUpdateImpl>
implements _$$UserUpdateImplCopyWith<$Res> {
__$$UserUpdateImplCopyWithImpl(
_$UserUpdateImpl _value, $Res Function(_$UserUpdateImpl) _then)
: super(_value, _then);
/// Create a copy of UserUpdate
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = freezed,
Object? email = freezed,
Object? password = freezed,
}) {
return _then(_$UserUpdateImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
email: freezed == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String?,
password: freezed == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
class _$UserUpdateImpl implements _UserUpdate {
const _$UserUpdateImpl(
{required this.id, this.name, this.email, this.password});
@override
final String id;
@override
final String? name;
@override
final String? email;
@override
final String? password;
@override
String toString() {
return 'UserUpdate(id: $id, name: $name, email: $email, password: $password)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserUpdateImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.email, email) || other.email == email) &&
(identical(other.password, password) ||
other.password == password));
}
@override
int get hashCode => Object.hash(runtimeType, id, name, email, password);
/// Create a copy of UserUpdate
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$UserUpdateImplCopyWith<_$UserUpdateImpl> get copyWith =>
__$$UserUpdateImplCopyWithImpl<_$UserUpdateImpl>(this, _$identity);
}
abstract class _UserUpdate implements UserUpdate {
const factory _UserUpdate(
{required final String id,
final String? name,
final String? email,
final String? password}) = _$UserUpdateImpl;
@override
String get id;
@override
String? get name;
@override
String? get email;
@override
String? get password;
/// Create a copy of UserUpdate
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UserUpdateImplCopyWith<_$UserUpdateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
@@ -3,13 +3,13 @@ import 'package:backend_dart/domain/interface/error.dart';
import 'package:fpdart/fpdart.dart';
abstract class UserRepository {
TaskEither<IError, User> create(User user);
TaskEither<IError, User> create(UserCreate user);
TaskEither<IError, User> findByEmail(String email);
TaskEither<IError, User> findById(String id);
TaskEither<IError, User> update(User user);
TaskEither<IError, User> update(UserUpdate user);
TaskEither<IError, void> delete(String id);