feat: implicitly declare typesense fields (#1195)

This commit is contained in:
Kyrch
2026-05-07 17:20:42 -03:00
committed by GitHub
parent effdcecd79
commit 333a519611
13 changed files with 48 additions and 37 deletions
@@ -14,8 +14,9 @@ class ExternalProfileTypesenseModel
public static function toSearchableArray(ExternalProfile $profile): array
{
return [
...$profile->attributesToArray(),
'id' => (string) $profile->getKey(),
'name' => $profile->name,
'site' => $profile->site->value,
];
}
}
@@ -14,8 +14,9 @@ class PlaylistTypesenseModel
public static function toSearchableArray(Playlist $playlist): array
{
return [
...$playlist->attributesToArray(),
'id' => (string) $playlist->getKey(),
'name' => $playlist->name,
'created_at' => $playlist->created_at?->timestamp,
];
}
}
@@ -14,11 +14,8 @@ class AnimeSynonymTypesenseModel
public static function toSearchableArray(AnimeSynonym $synonym): array
{
return [
...$synonym->attributesToArray(),
'id' => (string) $synonym->getKey(),
'created_at' => $synonym->created_at?->timestamp,
'updated_at' => $synonym->updated_at?->timestamp,
'deleted_at' => $synonym->deleted_at?->timestamp,
'text' => $synonym->text,
];
}
}
@@ -18,7 +18,7 @@ class AnimeThemeTypesenseModel
'created_at' => $theme->created_at?->timestamp,
'type_sequence' => $theme->type->localize().($theme->sequence ?? 1),
'type' => $theme->type->localize(),
'type' => $theme->type->value,
'sequence' => (string) ($theme->sequence ?? 1),
'anime' => $theme->anime->toSearchableArray(),
@@ -15,9 +15,7 @@ class AnimeThemeEntryTypesenseModel
public static function toSearchableArray(AnimeThemeEntry $entry): array
{
return [
...$entry->attributesToArray(),
'id' => (string) $entry->getKey(),
'created_at' => $entry->created_at?->timestamp,
'animetheme' => $entry->animetheme->toSearchableArray(),
'version' => $version = Str::of(strval($entry->version))->prepend('v')->__toString(),
'type_sequence_version' => $entry->animetheme->type->localize().(($entry->animetheme->sequence ?? 1)).$version,
@@ -15,12 +15,13 @@ class AnimeTypesenseModel
public static function toSearchableArray(Anime $anime): array
{
return [
...$anime->attributesToArray(),
'id' => (string) $anime->getKey(),
'season' => $anime->season?->localize(),
'format' => $anime->format?->value,
'name' => $anime->name,
'season' => $anime->season?->value,
'year' => $anime->year,
'created_at' => $anime->created_at?->timestamp,
'updated_at' => $anime->updated_at?->timestamp,
'deleted_at' => $anime->deleted_at?->timestamp,
'synonyms' => $anime->synonyms->map(fn (Synonym $synonym) => $synonym->text)->all(),
];
}
@@ -20,7 +20,6 @@ class ArtistTypesenseModel
'name' => $artist->name,
'created_at' => $artist->created_at?->timestamp,
'updated_at' => $artist->updated_at?->timestamp,
'deleted_at' => $artist->deleted_at?->timestamp,
'synonyms' => $synonyms = $artist->synonyms->map(fn (Synonym $synonym) => $synonym->text)->all(),
'as' => $as = $artist->performances->map(fn (Performance $performance) => $performance->as)
->toBase()
@@ -15,9 +15,10 @@ class SeriesTypesenseModel
public static function toSearchableArray(Series $series): array
{
return [
...$series->attributesToArray(),
'id' => (string) $series->getKey(),
'name' => $series->name,
'created_at' => $series->created_at?->timestamp,
'updated_at' => $series->updated_at?->timestamp,
'anime' => $series->anime->map(
fn (Anime $anime): array => $anime->toSearchableArray()
)->all(),
@@ -14,11 +14,11 @@ class SongTypesenseModel
public static function toSearchableArray(Song $song): array
{
return [
...$song->attributesToArray(),
'id' => (string) $song->getKey(),
'title' => $song->title,
'title_native' => $song->title_native,
'created_at' => $song->created_at?->timestamp,
'updated_at' => $song->updated_at?->timestamp,
'deleted_at' => $song->deleted_at?->timestamp,
];
}
}
@@ -14,9 +14,10 @@ class StudioTypesenseModel
public static function toSearchableArray(Studio $studio): array
{
return [
...$studio->attributesToArray(),
'id' => (string) $studio->getKey(),
'name' => $studio->name,
'created_at' => $studio->created_at?->timestamp,
'updated_at' => $studio->updated_at?->timestamp,
];
}
}
@@ -14,9 +14,9 @@ class SynonymTypesenseModel
public static function toSearchableArray(Synonym $synonym): array
{
return [
...$synonym->attributesToArray(),
'id' => (string) $synonym->getKey(),
'created_at' => $synonym->created_at?->timestamp,
'text' => $synonym->text,
'type' => $synonym->type->value,
];
}
}
@@ -15,11 +15,10 @@ class VideoTypesenseModel
public static function toSearchableArray(Video $video): array
{
return [
...$video->attributesToArray(),
'id' => (string) $video->getKey(),
'filename' => $video->filename,
'tags' => $video->tags,
'created_at' => $video->created_at?->timestamp,
'updated_at' => $video->updated_at?->timestamp,
'deleted_at' => $video->deleted_at?->timestamp,
'entries' => $video->animethemeentries->map(
fn (AnimeThemeEntry $entry): array => $entry->toSearchableArray()
)->all(),