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(),
+28 -15
View File
@@ -199,6 +199,10 @@ return [
'name' => 'name',
'type' => 'string',
],
[
'name' => 'site',
'type' => 'int32',
],
],
],
'search-parameters' => [
@@ -216,6 +220,11 @@ return [
'name' => 'name',
'type' => 'string',
],
[
'name' => 'created_at',
'type' => 'int64',
'optional' => true,
],
],
],
'search-parameters' => [
@@ -229,13 +238,18 @@ return [
'name' => 'id',
'type' => 'string',
],
[
'name' => 'format',
'type' => 'int32',
'optional' => true,
],
[
'name' => 'name',
'type' => 'string',
],
[
'name' => 'season',
'type' => 'string',
'type' => 'int32',
'optional' => true,
],
[
@@ -252,11 +266,6 @@ return [
'type' => 'int64',
'optional' => true,
],
[
'name' => '__soft_deleted',
'type' => 'int32',
'optional' => true,
],
[
'name' => 'synonyms',
'type' => 'string[]',
@@ -282,7 +291,7 @@ return [
],
[
'name' => 'type',
'type' => 'string',
'type' => 'int32',
],
[
'name' => 'sequence',
@@ -323,11 +332,6 @@ return [
'name' => 'id',
'type' => 'string',
],
[
'name' => 'created_at',
'type' => 'int64',
'optional' => true,
],
[
'name' => 'version',
'type' => 'string',
@@ -413,6 +417,11 @@ return [
'type' => 'int64',
'optional' => true,
],
[
'name' => 'updated_at',
'type' => 'int64',
'optional' => true,
],
[
'name' => 'anime',
'type' => 'object[]',
@@ -473,6 +482,11 @@ return [
'type' => 'int64',
'optional' => true,
],
[
'name' => 'updated_at',
'type' => 'int64',
'optional' => true,
],
],
],
'search-parameters' => [
@@ -509,9 +523,8 @@ return [
'type' => 'string',
],
[
'name' => 'created_at',
'type' => 'int64',
'optional' => true,
'name' => 'type',
'type' => 'int32',
],
],
],