wip, immutable types

This commit is contained in:
2025-01-01 14:48:52 +00:00
parent 97fe0e69d0
commit 0ded723bb9
15 changed files with 2625 additions and 15840 deletions
File diff suppressed because it is too large Load Diff
@@ -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(),
};
}
File diff suppressed because it is too large Load Diff
+13 -13
View File
@@ -1,6 +1,6 @@
generator dartClient {
provider = "dart run orm"
output = "lib/infrastructure/persistence/db"
output = "../lib/infrastructure/persistence/db"
}
datasource db {
@@ -9,51 +9,51 @@ datasource db {
}
// User Model
model User {
model UserDbo {
id String @id @default(uuid())
name String
email String @unique
password String
projects Project[] // Beziehung zu Projekten
timeEntries TimeEntry[] // Beziehung zu Zeiteinträgen
projects ProjectDbo[] // Beziehung zu Projekten
timeEntries TimeEntryDbo[] // Beziehung zu Zeiteinträgen
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// Project Model
model Project {
model ProjectDbo {
id String @id @default(uuid())
name String
description String?
clientId String?
tasks Task[] // Beziehung zu Aufgaben
timeEntries TimeEntry[] // Beziehung zu Zeiteinträgen
user User @relation(fields: [userId], references: [id])
tasks TaskDbo[] // Beziehung zu Aufgaben
timeEntries TimeEntryDbo[] // Beziehung zu Zeiteinträgen
user UserDbo @relation(fields: [userId], references: [id])
userId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// TimeEntry Model
model TimeEntry {
model TimeEntryDbo {
id String @id @default(uuid())
startTime DateTime
endTime DateTime
description String?
user User @relation(fields: [userId], references: [id])
user UserDbo @relation(fields: [userId], references: [id])
userId String
project Project @relation(fields: [projectId], references: [id])
project ProjectDbo @relation(fields: [projectId], references: [id])
projectId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// Task Model (optional)
model Task {
model TaskDbo {
id String @id @default(uuid())
name String
description String?
project Project @relation(fields: [projectId], references: [id])
project ProjectDbo @relation(fields: [projectId], references: [id])
projectId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt