wip, immutable types

This commit is contained in:
Jean Jacques Avril 2025-01-01 14:48:52 +00:00
parent 97fe0e69d0
commit 0ded723bb9
No known key found for this signature in database
15 changed files with 2625 additions and 15840 deletions

View File

@ -14,11 +14,11 @@
}, },
"extensions": [ "extensions": [
"ms-azuretools.vscode-docker", "ms-azuretools.vscode-docker",
"ms-vscode.vscode-typescript-next", "ms-vscode.vscode-typescript-next",
"dart-code.dart-code", "dart-code.dart-code",
"golang.go", "golang.go",
"denoland.vscode-deno" "denoland.vscode-deno",
"Prisma.prisma"
], ],
"features": { "features": {
//"docker-in-docker": "latest", //"docker-in-docker": "latest",

View File

@ -112,6 +112,9 @@ After deployment, data can be accessed via a webui:
bunx prisma studio bunx prisma studio
``` ```
### Codegen
Inside the corresponding backend run: ```bunx prisma generate```
# Known Issues # Known Issues
## Hydration issue caused by browser extensions ## Hydration issue caused by browser extensions

View File

@ -0,0 +1,29 @@
import 'package:json_annotation/json_annotation.dart';
part 'user_dto.g.dart';
@JsonSerializable()
class UserDto {
final String id;
final String name;
final String email;
// Optional: Füge zusätzliche Felder wie Timestamps hinzu
final DateTime? createdAt;
final DateTime? updatedAt;
UserDto({
required this.id,
required this.name,
required this.email,
this.createdAt,
this.updatedAt,
});
/// Factory-Methode zur Deserialisierung von JSON
factory UserDto.fromJson(Map<String, dynamic> json) =>
_$UserDtoFromJson(json);
/// Methode zur Serialisierung nach JSON
Map<String, dynamic> toJson() => _$UserDtoToJson(this);
}

View File

@ -0,0 +1,27 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'user_dto.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
UserDto _$UserDtoFromJson(Map<String, dynamic> json) => UserDto(
id: json['id'] as String,
name: json['name'] as String,
email: json['email'] as String,
createdAt: json['createdAt'] == null
? null
: DateTime.parse(json['createdAt'] as String),
updatedAt: json['updatedAt'] == null
? null
: DateTime.parse(json['updatedAt'] as String),
);
Map<String, dynamic> _$UserDtoToJson(UserDto instance) => <String, dynamic>{
'id': instance.id,
'name': instance.name,
'email': instance.email,
'createdAt': instance.createdAt?.toIso8601String(),
'updatedAt': instance.updatedAt?.toIso8601String(),
};

View File

@ -1,13 +1,16 @@
class User { import 'package:freezed_annotation/freezed_annotation.dart';
final String id;
final String name;
final String email;
final String? password;
User({ part 'user.freezed.dart';
required this.id, part 'user.g.dart';
required this.name,
required this.email, @freezed
required this.password, class User with _$User {
}); const factory User({
required String id,
required String name,
required String email,
String? password,
DateTime? createdAt,
DateTime? updatedAt,
}) = _User;
} }

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,8 @@
import 'model.dart' as _i1; import 'model.dart' as _i1;
import 'prisma.dart' as _i2; import 'prisma.dart' as _i2;
class Task { class TaskDbo {
const Task({ const TaskDbo({
this.id, this.id,
this.name, this.name,
this.description, this.description,
@ -13,7 +13,7 @@ class Task {
this.project, this.project,
}); });
factory Task.fromJson(Map json) => Task( factory TaskDbo.fromJson(Map json) => TaskDbo(
id: json['id'], id: json['id'],
name: json['name'], name: json['name'],
description: json['description'], description: json['description'],
@ -29,7 +29,7 @@ class Task {
_ => json['updatedAt'] _ => json['updatedAt']
}, },
project: json['project'] is Map project: json['project'] is Map
? _i1.Project.fromJson(json['project']) ? _i1.ProjectDbo.fromJson(json['project'])
: null, : null,
); );
@ -45,7 +45,7 @@ class Task {
final DateTime? updatedAt; final DateTime? updatedAt;
final _i1.Project? project; final _i1.ProjectDbo? project;
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
@ -58,8 +58,8 @@ class Task {
}; };
} }
class TimeEntry { class TimeEntryDbo {
const TimeEntry({ const TimeEntryDbo({
this.id, this.id,
this.startTime, this.startTime,
this.endTime, this.endTime,
@ -72,7 +72,7 @@ class TimeEntry {
this.project, this.project,
}); });
factory TimeEntry.fromJson(Map json) => TimeEntry( factory TimeEntryDbo.fromJson(Map json) => TimeEntryDbo(
id: json['id'], id: json['id'],
startTime: switch (json['startTime']) { startTime: switch (json['startTime']) {
DateTime value => value, DateTime value => value,
@ -97,9 +97,9 @@ class TimeEntry {
String value => DateTime.parse(value), String value => DateTime.parse(value),
_ => json['updatedAt'] _ => json['updatedAt']
}, },
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null, user: json['user'] is Map ? _i1.UserDbo.fromJson(json['user']) : null,
project: json['project'] is Map project: json['project'] is Map
? _i1.Project.fromJson(json['project']) ? _i1.ProjectDbo.fromJson(json['project'])
: null, : null,
); );
@ -119,9 +119,9 @@ class TimeEntry {
final DateTime? updatedAt; final DateTime? updatedAt;
final _i1.User? user; final _i1.UserDbo? user;
final _i1.Project? project; final _i1.ProjectDbo? project;
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
@ -137,8 +137,8 @@ class TimeEntry {
}; };
} }
class Project { class ProjectDbo {
const Project({ const ProjectDbo({
this.id, this.id,
this.name, this.name,
this.description, this.description,
@ -152,7 +152,7 @@ class Project {
this.$count, this.$count,
}); });
factory Project.fromJson(Map json) => Project( factory ProjectDbo.fromJson(Map json) => ProjectDbo(
id: json['id'], id: json['id'],
name: json['name'], name: json['name'],
description: json['description'], description: json['description'],
@ -169,12 +169,12 @@ class Project {
_ => json['updatedAt'] _ => json['updatedAt']
}, },
tasks: (json['tasks'] as Iterable?) tasks: (json['tasks'] as Iterable?)
?.map((json) => _i1.Task.fromJson(json)), ?.map((json) => _i1.TaskDbo.fromJson(json)),
timeEntries: (json['timeEntries'] as Iterable?) timeEntries: (json['timeEntries'] as Iterable?)
?.map((json) => _i1.TimeEntry.fromJson(json)), ?.map((json) => _i1.TimeEntryDbo.fromJson(json)),
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null, user: json['user'] is Map ? _i1.UserDbo.fromJson(json['user']) : null,
$count: json['_count'] is Map $count: json['_count'] is Map
? _i2.ProjectCountOutputType.fromJson(json['_count']) ? _i2.ProjectDboCountOutputType.fromJson(json['_count'])
: null, : null,
); );
@ -192,13 +192,13 @@ class Project {
final DateTime? updatedAt; final DateTime? updatedAt;
final Iterable<_i1.Task>? tasks; final Iterable<_i1.TaskDbo>? tasks;
final Iterable<_i1.TimeEntry>? timeEntries; final Iterable<_i1.TimeEntryDbo>? timeEntries;
final _i1.User? user; final _i1.UserDbo? user;
final _i2.ProjectCountOutputType? $count; final _i2.ProjectDboCountOutputType? $count;
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
@ -215,8 +215,8 @@ class Project {
}; };
} }
class User { class UserDbo {
const User({ const UserDbo({
this.id, this.id,
this.name, this.name,
this.email, this.email,
@ -228,7 +228,7 @@ class User {
this.$count, this.$count,
}); });
factory User.fromJson(Map json) => User( factory UserDbo.fromJson(Map json) => UserDbo(
id: json['id'], id: json['id'],
name: json['name'], name: json['name'],
email: json['email'], email: json['email'],
@ -244,11 +244,11 @@ class User {
_ => json['updatedAt'] _ => json['updatedAt']
}, },
projects: (json['projects'] as Iterable?) projects: (json['projects'] as Iterable?)
?.map((json) => _i1.Project.fromJson(json)), ?.map((json) => _i1.ProjectDbo.fromJson(json)),
timeEntries: (json['timeEntries'] as Iterable?) timeEntries: (json['timeEntries'] as Iterable?)
?.map((json) => _i1.TimeEntry.fromJson(json)), ?.map((json) => _i1.TimeEntryDbo.fromJson(json)),
$count: json['_count'] is Map $count: json['_count'] is Map
? _i2.UserCountOutputType.fromJson(json['_count']) ? _i2.UserDboCountOutputType.fromJson(json['_count'])
: null, : null,
); );
@ -264,11 +264,11 @@ class User {
final DateTime? updatedAt; final DateTime? updatedAt;
final Iterable<_i1.Project>? projects; final Iterable<_i1.ProjectDbo>? projects;
final Iterable<_i1.TimeEntry>? timeEntries; final Iterable<_i1.TimeEntryDbo>? timeEntries;
final _i2.UserCountOutputType? $count; final _i2.UserDboCountOutputType? $count;
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
@ -283,8 +283,8 @@ class User {
}; };
} }
class CreateManyUserAndReturnOutputType { class CreateManyUserDboAndReturnOutputType {
const CreateManyUserAndReturnOutputType({ const CreateManyUserDboAndReturnOutputType({
this.id, this.id,
this.name, this.name,
this.email, this.email,
@ -293,8 +293,8 @@ class CreateManyUserAndReturnOutputType {
this.updatedAt, this.updatedAt,
}); });
factory CreateManyUserAndReturnOutputType.fromJson(Map json) => factory CreateManyUserDboAndReturnOutputType.fromJson(Map json) =>
CreateManyUserAndReturnOutputType( CreateManyUserDboAndReturnOutputType(
id: json['id'], id: json['id'],
name: json['name'], name: json['name'],
email: json['email'], email: json['email'],
@ -333,8 +333,8 @@ class CreateManyUserAndReturnOutputType {
}; };
} }
class CreateManyProjectAndReturnOutputType { class CreateManyProjectDboAndReturnOutputType {
const CreateManyProjectAndReturnOutputType({ const CreateManyProjectDboAndReturnOutputType({
this.id, this.id,
this.name, this.name,
this.description, this.description,
@ -345,8 +345,8 @@ class CreateManyProjectAndReturnOutputType {
this.user, this.user,
}); });
factory CreateManyProjectAndReturnOutputType.fromJson(Map json) => factory CreateManyProjectDboAndReturnOutputType.fromJson(Map json) =>
CreateManyProjectAndReturnOutputType( CreateManyProjectDboAndReturnOutputType(
id: json['id'], id: json['id'],
name: json['name'], name: json['name'],
description: json['description'], description: json['description'],
@ -362,7 +362,7 @@ class CreateManyProjectAndReturnOutputType {
String value => DateTime.parse(value), String value => DateTime.parse(value),
_ => json['updatedAt'] _ => json['updatedAt']
}, },
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null, user: json['user'] is Map ? _i1.UserDbo.fromJson(json['user']) : null,
); );
final String? id; final String? id;
@ -379,7 +379,7 @@ class CreateManyProjectAndReturnOutputType {
final DateTime? updatedAt; final DateTime? updatedAt;
final _i1.User? user; final _i1.UserDbo? user;
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
@ -393,8 +393,8 @@ class CreateManyProjectAndReturnOutputType {
}; };
} }
class CreateManyTimeEntryAndReturnOutputType { class CreateManyTimeEntryDboAndReturnOutputType {
const CreateManyTimeEntryAndReturnOutputType({ const CreateManyTimeEntryDboAndReturnOutputType({
this.id, this.id,
this.startTime, this.startTime,
this.endTime, this.endTime,
@ -407,8 +407,8 @@ class CreateManyTimeEntryAndReturnOutputType {
this.project, this.project,
}); });
factory CreateManyTimeEntryAndReturnOutputType.fromJson(Map json) => factory CreateManyTimeEntryDboAndReturnOutputType.fromJson(Map json) =>
CreateManyTimeEntryAndReturnOutputType( CreateManyTimeEntryDboAndReturnOutputType(
id: json['id'], id: json['id'],
startTime: switch (json['startTime']) { startTime: switch (json['startTime']) {
DateTime value => value, DateTime value => value,
@ -433,9 +433,9 @@ class CreateManyTimeEntryAndReturnOutputType {
String value => DateTime.parse(value), String value => DateTime.parse(value),
_ => json['updatedAt'] _ => json['updatedAt']
}, },
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null, user: json['user'] is Map ? _i1.UserDbo.fromJson(json['user']) : null,
project: json['project'] is Map project: json['project'] is Map
? _i1.Project.fromJson(json['project']) ? _i1.ProjectDbo.fromJson(json['project'])
: null, : null,
); );
@ -455,9 +455,9 @@ class CreateManyTimeEntryAndReturnOutputType {
final DateTime? updatedAt; final DateTime? updatedAt;
final _i1.User? user; final _i1.UserDbo? user;
final _i1.Project? project; final _i1.ProjectDbo? project;
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
@ -473,8 +473,8 @@ class CreateManyTimeEntryAndReturnOutputType {
}; };
} }
class CreateManyTaskAndReturnOutputType { class CreateManyTaskDboAndReturnOutputType {
const CreateManyTaskAndReturnOutputType({ const CreateManyTaskDboAndReturnOutputType({
this.id, this.id,
this.name, this.name,
this.description, this.description,
@ -484,8 +484,8 @@ class CreateManyTaskAndReturnOutputType {
this.project, this.project,
}); });
factory CreateManyTaskAndReturnOutputType.fromJson(Map json) => factory CreateManyTaskDboAndReturnOutputType.fromJson(Map json) =>
CreateManyTaskAndReturnOutputType( CreateManyTaskDboAndReturnOutputType(
id: json['id'], id: json['id'],
name: json['name'], name: json['name'],
description: json['description'], description: json['description'],
@ -501,7 +501,7 @@ class CreateManyTaskAndReturnOutputType {
_ => json['updatedAt'] _ => json['updatedAt']
}, },
project: json['project'] is Map project: json['project'] is Map
? _i1.Project.fromJson(json['project']) ? _i1.ProjectDbo.fromJson(json['project'])
: null, : null,
); );
@ -517,7 +517,7 @@ class CreateManyTaskAndReturnOutputType {
final DateTime? updatedAt; final DateTime? updatedAt;
final _i1.Project? project; final _i1.ProjectDbo? project;
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,8 @@ class PrismaUserRepository implements UserRepository {
if (user.password == null) { if (user.password == null) {
throw Exception('Password is required'); throw Exception('Password is required');
} }
prisma.user.create( prisma.userDbo.create(
data: PrismaUnion.$1(UserCreateInput( data: PrismaUnion.$1(UserDboCreateInput(
id: user.id, id: user.id,
name: user.name, name: user.name,
email: user.email, email: user.email,
@ -25,8 +25,8 @@ class PrismaUserRepository implements UserRepository {
@override @override
Future<User?> findByEmail(String email) async { Future<User?> findByEmail(String email) async {
final user = final user = await prisma.userDbo
await prisma.user.findUnique(where: UserWhereUniqueInput(email: email)); .findUnique(where: UserDboWhereUniqueInput(email: email));
if (user == null) { if (user == null) {
return null; return null;
} }
@ -42,7 +42,7 @@ class PrismaUserRepository implements UserRepository {
@override @override
Future<User?> findById(String id) async { Future<User?> findById(String id) async {
final user = final user =
await prisma.user.findUnique(where: UserWhereUniqueInput(id: id)); await prisma.userDbo.findUnique(where: UserDboWhereUniqueInput(id: id));
if (user == null) { if (user == null) {
return null; return null;
} }

View File

@ -1,531 +0,0 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'model.dart' as _i1;
import 'prisma.dart' as _i2;
class Task {
const Task({
this.id,
this.name,
this.description,
this.projectId,
this.createdAt,
this.updatedAt,
this.project,
});
factory Task.fromJson(Map json) => Task(
id: json['id'],
name: json['name'],
description: json['description'],
projectId: json['projectId'],
createdAt: switch (json['createdAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['createdAt']
},
updatedAt: switch (json['updatedAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['updatedAt']
},
project: json['project'] is Map
? _i1.Project.fromJson(json['project'])
: null,
);
final String? id;
final String? name;
final String? description;
final String? projectId;
final DateTime? createdAt;
final DateTime? updatedAt;
final _i1.Project? project;
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'description': description,
'projectId': projectId,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'project': project?.toJson(),
};
}
class TimeEntry {
const TimeEntry({
this.id,
this.startTime,
this.endTime,
this.description,
this.userId,
this.projectId,
this.createdAt,
this.updatedAt,
this.user,
this.project,
});
factory TimeEntry.fromJson(Map json) => TimeEntry(
id: json['id'],
startTime: switch (json['startTime']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['startTime']
},
endTime: switch (json['endTime']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['endTime']
},
description: json['description'],
userId: json['userId'],
projectId: json['projectId'],
createdAt: switch (json['createdAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['createdAt']
},
updatedAt: switch (json['updatedAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['updatedAt']
},
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null,
project: json['project'] is Map
? _i1.Project.fromJson(json['project'])
: null,
);
final String? id;
final DateTime? startTime;
final DateTime? endTime;
final String? description;
final String? userId;
final String? projectId;
final DateTime? createdAt;
final DateTime? updatedAt;
final _i1.User? user;
final _i1.Project? project;
Map<String, dynamic> toJson() => {
'id': id,
'startTime': startTime?.toIso8601String(),
'endTime': endTime?.toIso8601String(),
'description': description,
'userId': userId,
'projectId': projectId,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'user': user?.toJson(),
'project': project?.toJson(),
};
}
class Project {
const Project({
this.id,
this.name,
this.description,
this.clientId,
this.userId,
this.createdAt,
this.updatedAt,
this.tasks,
this.timeEntries,
this.user,
this.$count,
});
factory Project.fromJson(Map json) => Project(
id: json['id'],
name: json['name'],
description: json['description'],
clientId: json['clientId'],
userId: json['userId'],
createdAt: switch (json['createdAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['createdAt']
},
updatedAt: switch (json['updatedAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['updatedAt']
},
tasks: (json['tasks'] as Iterable?)
?.map((json) => _i1.Task.fromJson(json)),
timeEntries: (json['timeEntries'] as Iterable?)
?.map((json) => _i1.TimeEntry.fromJson(json)),
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null,
$count: json['_count'] is Map
? _i2.ProjectCountOutputType.fromJson(json['_count'])
: null,
);
final String? id;
final String? name;
final String? description;
final String? clientId;
final String? userId;
final DateTime? createdAt;
final DateTime? updatedAt;
final Iterable<_i1.Task>? tasks;
final Iterable<_i1.TimeEntry>? timeEntries;
final _i1.User? user;
final _i2.ProjectCountOutputType? $count;
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'description': description,
'clientId': clientId,
'userId': userId,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'tasks': tasks?.map((e) => e.toJson()),
'timeEntries': timeEntries?.map((e) => e.toJson()),
'user': user?.toJson(),
'_count': $count?.toJson(),
};
}
class User {
const User({
this.id,
this.name,
this.email,
this.password,
this.createdAt,
this.updatedAt,
this.projects,
this.timeEntries,
this.$count,
});
factory User.fromJson(Map json) => User(
id: json['id'],
name: json['name'],
email: json['email'],
password: json['password'],
createdAt: switch (json['createdAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['createdAt']
},
updatedAt: switch (json['updatedAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['updatedAt']
},
projects: (json['projects'] as Iterable?)
?.map((json) => _i1.Project.fromJson(json)),
timeEntries: (json['timeEntries'] as Iterable?)
?.map((json) => _i1.TimeEntry.fromJson(json)),
$count: json['_count'] is Map
? _i2.UserCountOutputType.fromJson(json['_count'])
: null,
);
final String? id;
final String? name;
final String? email;
final String? password;
final DateTime? createdAt;
final DateTime? updatedAt;
final Iterable<_i1.Project>? projects;
final Iterable<_i1.TimeEntry>? timeEntries;
final _i2.UserCountOutputType? $count;
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'email': email,
'password': password,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'projects': projects?.map((e) => e.toJson()),
'timeEntries': timeEntries?.map((e) => e.toJson()),
'_count': $count?.toJson(),
};
}
class CreateManyUserAndReturnOutputType {
const CreateManyUserAndReturnOutputType({
this.id,
this.name,
this.email,
this.password,
this.createdAt,
this.updatedAt,
});
factory CreateManyUserAndReturnOutputType.fromJson(Map json) =>
CreateManyUserAndReturnOutputType(
id: json['id'],
name: json['name'],
email: json['email'],
password: json['password'],
createdAt: switch (json['createdAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['createdAt']
},
updatedAt: switch (json['updatedAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['updatedAt']
},
);
final String? id;
final String? name;
final String? email;
final String? password;
final DateTime? createdAt;
final DateTime? updatedAt;
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'email': email,
'password': password,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
};
}
class CreateManyProjectAndReturnOutputType {
const CreateManyProjectAndReturnOutputType({
this.id,
this.name,
this.description,
this.clientId,
this.userId,
this.createdAt,
this.updatedAt,
this.user,
});
factory CreateManyProjectAndReturnOutputType.fromJson(Map json) =>
CreateManyProjectAndReturnOutputType(
id: json['id'],
name: json['name'],
description: json['description'],
clientId: json['clientId'],
userId: json['userId'],
createdAt: switch (json['createdAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['createdAt']
},
updatedAt: switch (json['updatedAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['updatedAt']
},
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null,
);
final String? id;
final String? name;
final String? description;
final String? clientId;
final String? userId;
final DateTime? createdAt;
final DateTime? updatedAt;
final _i1.User? user;
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'description': description,
'clientId': clientId,
'userId': userId,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'user': user?.toJson(),
};
}
class CreateManyTimeEntryAndReturnOutputType {
const CreateManyTimeEntryAndReturnOutputType({
this.id,
this.startTime,
this.endTime,
this.description,
this.userId,
this.projectId,
this.createdAt,
this.updatedAt,
this.user,
this.project,
});
factory CreateManyTimeEntryAndReturnOutputType.fromJson(Map json) =>
CreateManyTimeEntryAndReturnOutputType(
id: json['id'],
startTime: switch (json['startTime']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['startTime']
},
endTime: switch (json['endTime']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['endTime']
},
description: json['description'],
userId: json['userId'],
projectId: json['projectId'],
createdAt: switch (json['createdAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['createdAt']
},
updatedAt: switch (json['updatedAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['updatedAt']
},
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null,
project: json['project'] is Map
? _i1.Project.fromJson(json['project'])
: null,
);
final String? id;
final DateTime? startTime;
final DateTime? endTime;
final String? description;
final String? userId;
final String? projectId;
final DateTime? createdAt;
final DateTime? updatedAt;
final _i1.User? user;
final _i1.Project? project;
Map<String, dynamic> toJson() => {
'id': id,
'startTime': startTime?.toIso8601String(),
'endTime': endTime?.toIso8601String(),
'description': description,
'userId': userId,
'projectId': projectId,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'user': user?.toJson(),
'project': project?.toJson(),
};
}
class CreateManyTaskAndReturnOutputType {
const CreateManyTaskAndReturnOutputType({
this.id,
this.name,
this.description,
this.projectId,
this.createdAt,
this.updatedAt,
this.project,
});
factory CreateManyTaskAndReturnOutputType.fromJson(Map json) =>
CreateManyTaskAndReturnOutputType(
id: json['id'],
name: json['name'],
description: json['description'],
projectId: json['projectId'],
createdAt: switch (json['createdAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['createdAt']
},
updatedAt: switch (json['updatedAt']) {
DateTime value => value,
String value => DateTime.parse(value),
_ => json['updatedAt']
},
project: json['project'] is Map
? _i1.Project.fromJson(json['project'])
: null,
);
final String? id;
final String? name;
final String? description;
final String? projectId;
final DateTime? createdAt;
final DateTime? updatedAt;
final _i1.Project? project;
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'description': description,
'projectId': projectId,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'project': project?.toJson(),
};
}

View File

@ -1,6 +1,6 @@
generator dartClient { generator dartClient {
provider = "dart run orm" provider = "dart run orm"
output = "lib/infrastructure/persistence/db" output = "../lib/infrastructure/persistence/db"
} }
datasource db { datasource db {
@ -9,51 +9,51 @@ datasource db {
} }
// User Model // User Model
model User { model UserDbo {
id String @id @default(uuid()) id String @id @default(uuid())
name String name String
email String @unique email String @unique
password String password String
projects Project[] // Beziehung zu Projekten projects ProjectDbo[] // Beziehung zu Projekten
timeEntries TimeEntry[] // Beziehung zu Zeiteinträgen timeEntries TimeEntryDbo[] // Beziehung zu Zeiteinträgen
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
} }
// Project Model // Project Model
model Project { model ProjectDbo {
id String @id @default(uuid()) id String @id @default(uuid())
name String name String
description String? description String?
clientId String? clientId String?
tasks Task[] // Beziehung zu Aufgaben tasks TaskDbo[] // Beziehung zu Aufgaben
timeEntries TimeEntry[] // Beziehung zu Zeiteinträgen timeEntries TimeEntryDbo[] // Beziehung zu Zeiteinträgen
user User @relation(fields: [userId], references: [id]) user UserDbo @relation(fields: [userId], references: [id])
userId String userId String
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
} }
// TimeEntry Model // TimeEntry Model
model TimeEntry { model TimeEntryDbo {
id String @id @default(uuid()) id String @id @default(uuid())
startTime DateTime startTime DateTime
endTime DateTime endTime DateTime
description String? description String?
user User @relation(fields: [userId], references: [id]) user UserDbo @relation(fields: [userId], references: [id])
userId String userId String
project Project @relation(fields: [projectId], references: [id]) project ProjectDbo @relation(fields: [projectId], references: [id])
projectId String projectId String
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
} }
// Task Model (optional) // Task Model (optional)
model Task { model TaskDbo {
id String @id @default(uuid()) id String @id @default(uuid())
name String name String
description String? description String?
project Project @relation(fields: [projectId], references: [id]) project ProjectDbo @relation(fields: [projectId], references: [id])
projectId String projectId String
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt

View File

@ -278,8 +278,16 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
freezed:
dependency: "direct dev"
description:
name: freezed
sha256: "44c19278dd9d89292cf46e97dc0c1e52ce03275f40a97c5a348e802a924bf40e"
url: "https://pub.dev"
source: hosted
version: "2.5.7"
freezed_annotation: freezed_annotation:
dependency: transitive dependency: "direct main"
description: description:
name: freezed_annotation name: freezed_annotation
sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2
@ -367,7 +375,7 @@ packages:
source: hosted source: hosted
version: "0.7.1" version: "0.7.1"
json_annotation: json_annotation:
dependency: transitive dependency: "direct main"
description: description:
name: json_annotation name: json_annotation
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
@ -382,6 +390,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.3" version: "3.0.3"
json_serializable:
dependency: "direct dev"
description:
name: json_serializable
sha256: c2fcb3920cf2b6ae6845954186420fca40bc0a8abcc84903b7801f17d7050d7c
url: "https://pub.dev"
source: hosted
version: "6.9.0"
lints: lints:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -646,6 +662,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.5.0" version: "1.5.0"
source_helper:
dependency: transitive
description:
name: source_helper
sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c"
url: "https://pub.dev"
source: hosted
version: "1.3.5"
source_map_stack_trace: source_map_stack_trace:
dependency: transitive dependency: transitive
description: description:

View File

@ -18,6 +18,9 @@ dependencies:
yaml: ^3.1.0 yaml: ^3.1.0
riverpod: ^2.6.1 riverpod: ^2.6.1
riverpod_annotation: ^2.6.1 riverpod_annotation: ^2.6.1
json_annotation: ^4.9.0
freezed_annotation: ^2.4.4
dev_dependencies: dev_dependencies:
lints: ^3.0.0 lints: ^3.0.0
test: ^1.24.0 test: ^1.24.0
@ -25,4 +28,6 @@ dev_dependencies:
build_runner: ^2.4.14 build_runner: ^2.4.14
riverpod_generator: ^2.6.3 riverpod_generator: ^2.6.3
riverpod_lint: ^2.6.3 riverpod_lint: ^2.6.3
json_serializable: ^6.9.0
freezed: ^2.5.7