Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
refactor(posts): streamline media item handling and improve type definitions
Paulo Castellanoa008555589f2
diff --git a/app/Jobs/Ai/RegeneratePostMediaImage.php b/app/Jobs/Ai/RegeneratePostMediaImage.phpindex 23be16790..397f1cac1 100644--- a/app/Jobs/Ai/RegeneratePostMediaImage.php+++ b/app/Jobs/Ai/RegeneratePostMediaImage.php@@ -22,6 +22,8 @@ use Illuminate\Queue\SerializesModels;use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Storage;+use Illuminate\Support\Str;+use RuntimeException;use Throwable;class RegeneratePostMediaImage implements ShouldQueue@@ -60,29 +62,68 @@ class RegeneratePostMediaImage implements ShouldQueuepublic function handle(): void{$workspace = Workspace::query()->findOrFail($this->workspaceId);- $post = Post::query()+ $post = $this->loadPost($workspace);+ $target = $this->resolveAiMediaTarget($post);++ $baseContext = $this->buildSourceContext(+ sourceMeta: is_array(data_get($target, 'source_meta')) ? data_get($target, 'source_meta') : [],+ post: $post,+ workspace: $workspace,+ );++ $copy = $this->regenerateSlideCopy($workspace, $post, $baseContext);+ $rendered = $this->renderRegeneratedImage($workspace, $post, $copy, $baseContext);+ $newMediaItem = $this->replaceMediaOnPost($post, $target, $workspace, $rendered);++ PostMediaRegenerated::dispatch(+ userId: $this->userId,+ regenerationId: $this->regenerationId,+ postId: $post->id,+ media: $newMediaItem,+ error: null,+ );+ }++ private function loadPost(Workspace $workspace): Post+ {+ return Post::query()->where('workspace_id', $workspace->id)->with(['postPlatforms.socialAccount', 'workspace'])->findOrFail($this->postId);+ }++ /**+ * @return array<string, mixed>+ */+ private function resolveAiMediaTarget(Post $post): array+ {+ $target = collect($post->media ?? [])+ ->first(fn ($item) => data_get($item, 'id') === $this->mediaId);- $mediaItems = collect($post->media ?? []);- $targetIndex = $mediaItems->search(fn ($item) => data_get($item, 'id') === $this->mediaId);- if ($targetIndex === false) {- throw new \RuntimeException('Media item no longer exists in post.');+ if (! is_array($target)) {+ throw new RuntimeException('Media item no longer exists in post.');}- $target = $mediaItems->get($targetIndex);if (data_get($target, 'source') !== Source::Ai->value) {- throw new \RuntimeException('Only AI media can be regenerated.');+ throw new RuntimeException('Only AI media can be regenerated.');}- $sourceMeta = data_get($target, 'source_meta');- $baseContext = $this->buildSourceContext(- sourceMeta: is_array($sourceMeta) ? $sourceMeta : [],- post: $post,- workspace: $workspace,- );+ return $target;+ }+ /**+ * @param array{+ * title: string,+ * body: string,+ * keywords: array<int, string>,+ * language: string,+ * width: int,+ * height: int+ * } $baseContext+ * @return array{title: string, body: string, keywords: array<int, string>}+ */+ private function regenerateSlideCopy(Workspace $workspace, Post $post, array $baseContext): array+ {/** @var PostImageRegenerator $agent */$agent = app(PostImageRegenerator::class, ['workspace' => $workspace]);@@ -105,44 +146,88 @@ class RegeneratePostMediaImage implements ShouldQueuemetadata: ['agent' => 'post_image_regenerator'],);- $structured = $response->structured ?? [];+ return $this->mergeStructuredCopy($baseContext, $response->structured ?? []);+ }- $title = trim((string) data_get($structured, 'title', $baseContext['title']));- $body = trim((string) data_get($structured, 'body', $baseContext['body']));- $keywords = collect(data_get($structured, 'keywords', $baseContext['keywords']))- ->filter(fn ($keyword) => is_string($keyword) && trim($keyword) !== '')- ->map(fn (string $keyword) => trim($keyword))- ->values()- ->all();+ /**+ * @param array{+ * title: string,+ * body: string,+ * keywords: array<int, string>,+ * language: string,+ * width: int,+ * height: int+ * } $baseContext+ * @param array<string, mixed> $structured+ * @return array{title: string, body: string, keywords: array<int, string>}+ */+ private function mergeStructuredCopy(array $baseContext, array $structured): array+ {+ $keywords = $this->normalizeKeywords(data_get($structured, 'keywords', $baseContext['keywords']));- if ($keywords === []) {- $keywords = $baseContext['keywords'];- }+ return [+ 'title' => trim((string) data_get($structured, 'title', $baseContext['title'])),+ 'body' => trim((string) data_get($structured, 'body', $baseContext['body'])),+ 'keywords' => $keywords !== [] ? $keywords : $baseContext['keywords'],+ ];+ }+ /**+ * @param array{title: string, body: string, keywords: array<int, string>} $copy+ * @param array{+ * title: string,+ * body: string,+ * keywords: array<int, string>,+ * language: string,+ * width: int,+ * height: int+ * } $baseContext+ * @return array{path: string, source_meta: array<string, mixed>}+ */+ private function renderRegeneratedImage(+ Workspace $workspace,+ Post $post,+ array $copy,+ array $baseContext,+ ): array {$socialAccount = $this->resolveSocialAccount($post, $workspace);+if (! $socialAccount) {- throw new \RuntimeException('No social account available for image footer rendering.');+ throw new RuntimeException('No social account available for image footer rendering.');}- $generator = app(TemplateImageGenerator::class);- $rendered = $generator->render(+ $rendered = app(TemplateImageGenerator::class)->render(workspace: $workspace,socialAccount: $socialAccount,- title: $title,- body: $body,- imageKeywords: $keywords,+ title: $copy['title'],+ body: $copy['body'],+ imageKeywords: $copy['keywords'],width: $baseContext['width'],height: $baseContext['height'],);if (! $rendered) {- throw new \RuntimeException('Image generator failed to produce media.');+ throw new RuntimeException('Image generator failed to produce media.');}- $renderedPath = (string) data_get($rendered, 'path');+ return $rendered;+ }++ /**+ * @param array<string, mixed> $target+ * @param array{path: string, source_meta: array<string, mixed>} $rendered+ * @return array<string, mixed>+ */+ private function replaceMediaOnPost(+ Post $post,+ array $target,+ Workspace $workspace,+ array $rendered,+ ): array {+ $renderedPath = $rendered['path'];try {- $newMediaItem = DB::transaction(function () use ($post, $rendered, $target, $workspace) {+ return DB::transaction(function () use ($post, $rendered, $target, $workspace) {$newMediaItem = $this->buildAiMediaItem($workspace, $rendered);$fresh = Post::query()->whereKey($post->id)->lockForUpdate()->firstOrFail();@@ -150,15 +235,13 @@ class RegeneratePostMediaImage implements ShouldQueue$currentIndex = $items->search(fn ($item) => data_get($item, 'id') === $this->mediaId);if ($currentIndex === false) {- throw new \RuntimeException('Media item changed before regeneration completed.');+ throw new RuntimeException('Media item changed before regeneration completed.');}$items->put($currentIndex, $newMediaItem);-$fresh->update(['media' => $items->values()->all()]);- $oldMediaId = data_get($target, 'id');- Media::query()->where('id', $oldMediaId)->first()?->delete();+ Media::query()->where('id', data_get($target, 'id'))->first()?->delete();return $newMediaItem;});@@ -167,14 +250,6 @@ class RegeneratePostMediaImage implements ShouldQueuethrow $exception;}-- PostMediaRegenerated::dispatch(- userId: $this->userId,- regenerationId: $this->regenerationId,- postId: $post->id,- media: $newMediaItem,- error: null,- );}private function discardRenderedFile(string $path): void@@ -199,20 +274,10 @@ class RegeneratePostMediaImage implements ShouldQueue{$title = trim((string) data_get($sourceMeta, 'title', ''));$body = trim((string) data_get($sourceMeta, 'body', ''));- $keywords = collect(data_get($sourceMeta, 'keywords', []))- ->filter(fn ($keyword) => is_string($keyword) && trim($keyword) !== '')- ->map(fn (string $keyword) => trim($keyword))- ->values()- ->all();+ $keywords = $this->normalizeKeywords(data_get($sourceMeta, 'keywords', []));- // Fallback path for older AI media without source metadata.if ($title === '' && $body === '') {- $derived = trim((string) $post->content);- if ($derived !== '') {- $lines = preg_split('/\R+/', $derived) ?: [];- $title = trim((string) data_get($lines, 0, ''));- $body = trim(collect($lines)->slice(1)->implode(' '));- }+ [$title, $body] = $this->titleAndBodyFromPostContent($post);}if ($title === '') {@@ -220,13 +285,7 @@ class RegeneratePostMediaImage implements ShouldQueue}if ($keywords === []) {- $keywords = collect(preg_split('/\s+/', "{$title} {$body}") ?: [])- ->filter(fn ($word) => is_string($word) && mb_strlen(trim($word)) >= 4)- ->map(fn (string $word) => trim($word, ".,!?;:\"'()[]{}"))- ->filter()- ->take(8)- ->values()- ->all();+ $keywords = $this->keywordsFromCopy($title, $body);}if ($keywords === []) {@@ -243,6 +302,56 @@ class RegeneratePostMediaImage implements ShouldQueue];}+ /**+ * @return array{0: string, 1: string}+ */+ private function titleAndBodyFromPostContent(Post $post): array+ {+ $lines = Str::of((string) $post->content)+ ->replace(["\r\n", "\r"], "\n")+ ->trim()+ ->explode("\n")+ ->map(fn (string $line) => trim($line))+ ->filter()+ ->values();++ if ($lines->isEmpty()) {+ return ['', ''];+ }++ return [+ (string) $lines->first(),+ $lines->slice(1)->implode(' '),+ ];+ }++ /**+ * @return array<int, string>+ */+ private function keywordsFromCopy(string $title, string $body): array+ {+ return Str::of("{$title} {$body}")+ ->squish()+ ->explode(' ')+ ->map(fn (string $word) => (string) Str::of($word)->trim(".,!?;:\"'()[]{}"))+ ->filter(fn (string $word) => mb_strlen($word) >= 4)+ ->take(8)+ ->values()+ ->all();+ }++ /**+ * @return array<int, string>+ */+ private function normalizeKeywords(mixed $keywords): array+ {+ return collect($keywords)+ ->filter(fn ($keyword) => is_string($keyword) && trim($keyword) !== '')+ ->map(fn (string $keyword) => trim($keyword))+ ->values()+ ->all();+ }+private function resolveSocialAccount(Post $post, Workspace $workspace): ?SocialAccount{$enabledAccount = $post->postPlatformsdiff --git a/resources/js/components/MediaDropzone.vue b/resources/js/components/MediaDropzone.vueindex e7ff4cb12..853bdc4a0 100644--- a/resources/js/components/MediaDropzone.vue+++ b/resources/js/components/MediaDropzone.vue@@ -2,12 +2,7 @@import { IconCloudUpload, IconPhoto, IconVideo, IconX, IconLoader2, IconPlus } from '@tabler/icons-vue';import { computed, ref } from 'vue';-interface MediaItem {- id: string;- url: string;- type: string;- original_filename: string;-}+import type { MediaItem } from '@/types/media';interface Props {media: MediaItem[];diff --git a/resources/js/components/posts/ai/AiRegenerateImageDialog.vue b/resources/js/components/posts/ai/AiRegenerateImageDialog.vueindex 1bef5bdcb..6df91b6ce 100644--- a/resources/js/components/posts/ai/AiRegenerateImageDialog.vue+++ b/resources/js/components/posts/ai/AiRegenerateImageDialog.vue@@ -9,21 +9,9 @@ import { Button } from '@/components/ui/button';import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';import { Label } from '@/components/ui/label';import { Textarea } from '@/components/ui/textarea';+import type { MediaItem } from '@/types/media';import { regenerateMedia as regeneratePostAiMedia } from '@/routes/app/posts/ai';-interface MediaItem {- id: string;- path: string;- url: string;- type?: string;- mime_type?: string;- original_filename?: string;- size?: number;- source?: 'ai' | 'unsplash' | 'giphy';- source_meta?: Record<string, unknown>;- meta?: { width?: number; height?: number; duration?: number };-}-interface RegenerationPayload {media: MediaItem;targetMediaId: string;diff --git a/resources/js/components/posts/editor/FacebookSettings.vue b/resources/js/components/posts/editor/FacebookSettings.vueindex a961361da..09ebfeea2 100644--- a/resources/js/components/posts/editor/FacebookSettings.vue+++ b/resources/js/components/posts/editor/FacebookSettings.vue@@ -3,7 +3,8 @@ import { IconAlertTriangle, IconChevronDown, IconChevronUp } from '@tabler/iconsimport { computed, ref } from 'vue';import { Avatar } from '@/components/ui/avatar';-import { getMediaValidationWarning, type MediaItem } from '@/composables/useMedia';+import { getMediaValidationWarning } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';import { getPlatformLogo } from '@/composables/usePlatformLogo';interface SocialAccount {diff --git a/resources/js/components/posts/editor/InstagramSettings.vue b/resources/js/components/posts/editor/InstagramSettings.vueindex f8dd975fd..d214a009d 100644--- a/resources/js/components/posts/editor/InstagramSettings.vue+++ b/resources/js/components/posts/editor/InstagramSettings.vue@@ -3,7 +3,8 @@ import { IconAlertTriangle, IconChevronDown, IconChevronUp } from '@tabler/iconsimport { computed, ref } from 'vue';import { Avatar } from '@/components/ui/avatar';-import { getMediaValidationWarning, type MediaItem } from '@/composables/useMedia';+import { getMediaValidationWarning } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';import { getPlatformLogo } from '@/composables/usePlatformLogo';import { ContentType } from '@/enums/content-type';diff --git a/resources/js/components/posts/editor/LinkedInSettings.vue b/resources/js/components/posts/editor/LinkedInSettings.vueindex 7d6410204..3d8014025 100644--- a/resources/js/components/posts/editor/LinkedInSettings.vue+++ b/resources/js/components/posts/editor/LinkedInSettings.vue@@ -3,7 +3,8 @@ import { IconAlertTriangle, IconChevronDown, IconChevronUp } from '@tabler/iconsimport { computed, ref } from 'vue';import { Avatar } from '@/components/ui/avatar';-import { getMediaValidationWarning, type MediaItem } from '@/composables/useMedia';+import { getMediaValidationWarning } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';import { getPlatformLogo } from '@/composables/usePlatformLogo';import { ContentType } from '@/enums/content-type';diff --git a/resources/js/components/posts/editor/PinterestSettings.vue b/resources/js/components/posts/editor/PinterestSettings.vueindex 3ec207bf8..6bc56d059 100644--- a/resources/js/components/posts/editor/PinterestSettings.vue+++ b/resources/js/components/posts/editor/PinterestSettings.vue@@ -14,7 +14,8 @@ import {ComboboxList,ComboboxTrigger,} from '@/components/ui/combobox';-import { getMediaValidationWarning, type MediaItem } from '@/composables/useMedia';+import { getMediaValidationWarning } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';import { usePageErrors } from '@/composables/usePageErrors';import { getPlatformLogo } from '@/composables/usePlatformLogo';import { ContentType } from '@/enums/content-type';diff --git a/resources/js/components/posts/editor/PostEditorComposer.vue b/resources/js/components/posts/editor/PostEditorComposer.vueindex 7964d9ba0..d26e6edbe 100644--- a/resources/js/components/posts/editor/PostEditorComposer.vue+++ b/resources/js/components/posts/editor/PostEditorComposer.vue@@ -22,19 +22,7 @@ import { Popover, PopoverAnchor, PopoverContent } from '@/components/ui/popover'import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';import { formatBytes } from '@/composables/useMedia';import { getPlatformLabel, getPlatformLogo } from '@/composables/usePlatformLogo';--interface MediaItem {- id: string;- path: string;- url: string;- type?: string;- mime_type?: string;- original_filename?: string;- size?: number;- source?: 'ai' | 'unsplash' | 'giphy';- source_meta?: Record<string, unknown>;- meta?: { width?: number; height?: number; duration?: number };-}+import type { MediaItem } from '@/types/media';interface Signature {id: string;diff --git a/resources/js/components/posts/editor/PostEditorSidebar.vue b/resources/js/components/posts/editor/PostEditorSidebar.vueindex 53bcb4949..6938ecb28 100644--- a/resources/js/components/posts/editor/PostEditorSidebar.vue+++ b/resources/js/components/posts/editor/PostEditorSidebar.vue@@ -6,17 +6,7 @@ import PreviewTab from '@/components/posts/editor/PreviewTab.vue';import ScheduleTab from '@/components/posts/editor/ScheduleTab.vue';import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';import type { PinterestBoard } from '@/types';--interface MediaItem {- id: string;- path: string;- url: string;- type?: string;- mime_type?: string;- original_filename?: string;- size?: number;- meta?: { width?: number; height?: number; duration?: number };-}+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/components/posts/editor/PreviewTab.vue b/resources/js/components/posts/editor/PreviewTab.vueindex f240873bb..37feafa8b 100644--- a/resources/js/components/posts/editor/PreviewTab.vue+++ b/resources/js/components/posts/editor/PreviewTab.vue@@ -6,7 +6,7 @@ import PhoneMockup from '@/components/PhoneMockup.vue';import { PlatformPreview } from '@/components/posts/previews';import { Avatar } from '@/components/ui/avatar';import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';-import type { MediaItem } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';import { getPlatformLabel, getPlatformLogo } from '@/composables/usePlatformLogo';interface SocialAccount {diff --git a/resources/js/components/posts/editor/ScheduleTab.vue b/resources/js/components/posts/editor/ScheduleTab.vueindex 15a8a5973..e7e46d0c9 100644--- a/resources/js/components/posts/editor/ScheduleTab.vue+++ b/resources/js/components/posts/editor/ScheduleTab.vue@@ -15,6 +15,7 @@ import { usePageErrors } from '@/composables/usePageErrors';import { getPlatformLabel, getPlatformLogo } from '@/composables/usePlatformLogo';import { Platform } from '@/enums/platform';import type { PinterestBoard } from '@/types';+import type { MediaItem } from '@/types/media';import { PostPlatformStatus } from '@/types/post';interface SocialAccount {@@ -70,14 +71,6 @@ interface TikTokCreatorInfo {max_video_post_duration_sec: number | null;}-interface MediaItem {- id: string;- url: string;- type?: string;- mime_type?: string;- meta?: Record<string, any>;-}-const props = defineProps<{postPlatforms: PostPlatform[];selectedPlatformIds: string[];diff --git a/resources/js/components/posts/previews/BlueskyPreview.vue b/resources/js/components/posts/previews/BlueskyPreview.vueindex 586929c51..f9c2a5b87 100644--- a/resources/js/components/posts/previews/BlueskyPreview.vue+++ b/resources/js/components/posts/previews/BlueskyPreview.vue@@ -1,6 +1,7 @@<script setup lang="ts">import VideoPreview from "@/components/posts/previews/VideoPreview.vue";-import { isVideoMedia, type MediaItem } from '@/composables/useMedia';+import { isVideoMedia } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/components/posts/previews/FacebookPreview.vue b/resources/js/components/posts/previews/FacebookPreview.vueindex a9e85872e..bb5c4422a 100644--- a/resources/js/components/posts/previews/FacebookPreview.vue+++ b/resources/js/components/posts/previews/FacebookPreview.vue@@ -3,7 +3,7 @@ import { IconDots, IconPhoto } from '@tabler/icons-vue';import { computed } from 'vue';import PostMediaPreview from '@/components/posts/previews/PostMediaPreview.vue';-import type { MediaItem } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/components/posts/previews/InstagramPreview.vue b/resources/js/components/posts/previews/InstagramPreview.vueindex f3e045bbe..866fa780c 100644--- a/resources/js/components/posts/previews/InstagramPreview.vue+++ b/resources/js/components/posts/previews/InstagramPreview.vue@@ -14,7 +14,7 @@ import {import { computed } from 'vue';import PostMediaPreview from '@/components/posts/previews/PostMediaPreview.vue';-import type { MediaItem } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';import { ContentType } from '@/enums/content-type';interface SocialAccount {diff --git a/resources/js/components/posts/previews/LinkedInPreview.vue b/resources/js/components/posts/previews/LinkedInPreview.vueindex b719c1f73..e92d1ed77 100644--- a/resources/js/components/posts/previews/LinkedInPreview.vue+++ b/resources/js/components/posts/previews/LinkedInPreview.vue@@ -1,6 +1,7 @@<script setup lang="ts">import VideoPreview from "@/components/posts/previews/VideoPreview.vue";-import { isVideoMedia, type MediaItem } from '@/composables/useMedia';+import { isVideoMedia } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/components/posts/previews/MastodonPreview.vue b/resources/js/components/posts/previews/MastodonPreview.vueindex 24d4b0d71..9c3080620 100644--- a/resources/js/components/posts/previews/MastodonPreview.vue+++ b/resources/js/components/posts/previews/MastodonPreview.vue@@ -1,6 +1,7 @@<script setup lang="ts">import VideoPreview from "@/components/posts/previews/VideoPreview.vue";-import { isVideoMedia, type MediaItem } from '@/composables/useMedia';+import { isVideoMedia } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/components/posts/previews/PinterestPreview.vue b/resources/js/components/posts/previews/PinterestPreview.vueindex 2e43caf4b..badc3fccd 100644--- a/resources/js/components/posts/previews/PinterestPreview.vue+++ b/resources/js/components/posts/previews/PinterestPreview.vue@@ -3,7 +3,8 @@ import { IconPhoto, IconStack2 } from '@tabler/icons-vue';import { computed } from 'vue';import VideoPreview from "@/components/posts/previews/VideoPreview.vue";-import { isVideoMedia, type MediaItem } from '@/composables/useMedia';+import { isVideoMedia } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/components/posts/previews/PlatformPreview.vue b/resources/js/components/posts/previews/PlatformPreview.vueindex b95350a2e..ce18edd23 100644--- a/resources/js/components/posts/previews/PlatformPreview.vue+++ b/resources/js/components/posts/previews/PlatformPreview.vue@@ -20,13 +20,7 @@ interface SocialAccount {avatar_url: string | null;}-interface MediaItem {- id: string;- url: string;- type?: string;- mime_type?: string;- original_filename?: string;-}+import type { MediaItem } from '@/types/media';interface Props {platform: string;diff --git a/resources/js/components/posts/previews/PostMediaPreview.vue b/resources/js/components/posts/previews/PostMediaPreview.vueindex fff55dc8e..dcf088499 100644--- a/resources/js/components/posts/previews/PostMediaPreview.vue+++ b/resources/js/components/posts/previews/PostMediaPreview.vue@@ -3,7 +3,8 @@ import { IconChevronLeft, IconChevronRight, IconPhoto } from '@tabler/icons-vue'import { computed, ref, watch, type Component } from 'vue';import VideoPreview from '@/components/posts/previews/VideoPreview.vue';-import { isVideoMedia, type MediaItem } from '@/composables/useMedia';+import { isVideoMedia } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface Props {media: MediaItem[];diff --git a/resources/js/components/posts/previews/ThreadsPreview.vue b/resources/js/components/posts/previews/ThreadsPreview.vueindex 72d1542d5..c2fab739f 100644--- a/resources/js/components/posts/previews/ThreadsPreview.vue+++ b/resources/js/components/posts/previews/ThreadsPreview.vue@@ -2,7 +2,8 @@import { computed } from 'vue';import VideoPreview from "@/components/posts/previews/VideoPreview.vue";-import { isVideoMedia, type MediaItem } from '@/composables/useMedia';+import { isVideoMedia } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/components/posts/previews/TikTokPreview.vue b/resources/js/components/posts/previews/TikTokPreview.vueindex 23e38e3ef..ee91a4b8c 100644--- a/resources/js/components/posts/previews/TikTokPreview.vue+++ b/resources/js/components/posts/previews/TikTokPreview.vue@@ -3,7 +3,8 @@ import { IconPlus } from '@tabler/icons-vue';import { computed } from 'vue';import VideoPreview from "@/components/posts/previews/VideoPreview.vue";-import { isVideoMedia, type MediaItem } from '@/composables/useMedia';+import { isVideoMedia } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/components/posts/previews/XPreview.vue b/resources/js/components/posts/previews/XPreview.vueindex f16cbe1f5..db9b1225e 100644--- a/resources/js/components/posts/previews/XPreview.vue+++ b/resources/js/components/posts/previews/XPreview.vue@@ -2,7 +2,8 @@import { computed } from 'vue';import VideoPreview from "@/components/posts/previews/VideoPreview.vue";-import { isVideoMedia, type MediaItem } from '@/composables/useMedia';+import { isVideoMedia } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/components/posts/previews/YouTubePreview.vue b/resources/js/components/posts/previews/YouTubePreview.vueindex d9f39148f..9882b3b24 100644--- a/resources/js/components/posts/previews/YouTubePreview.vue+++ b/resources/js/components/posts/previews/YouTubePreview.vue@@ -2,7 +2,8 @@import { computed } from 'vue';import VideoPreview from "@/components/posts/previews/VideoPreview.vue";-import { isVideoMedia, type MediaItem } from '@/composables/useMedia';+import { isVideoMedia } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';interface SocialAccount {id: string;diff --git a/resources/js/composables/useMedia.ts b/resources/js/composables/useMedia.tsindex 95506d0ab..4fa37c6b8 100644--- a/resources/js/composables/useMedia.ts+++ b/resources/js/composables/useMedia.ts@@ -1,21 +1,7 @@import { getMediaRulesForContentType } from '@/composables/useMediaRules';+import type { MediaItem } from '@/types/media';-export interface MediaItem {- id: string;- url: string;- path?: string;- type?: string;- mime_type?: string;- original_filename?: string;- size?: number;- source?: 'ai' | 'unsplash' | 'giphy';- source_meta?: Record<string, unknown>;- meta?: {- width?: number;- height?: number;- duration?: number;- };-}+export type { MediaItem } from '@/types/media';export interface MediaValidationWarning {key: string; // short key, e.g. 'gif_not_allowed'diff --git a/resources/js/composables/usePostCompliance.ts b/resources/js/composables/usePostCompliance.tsindex 5bfd6f579..abd3614b1 100644--- a/resources/js/composables/usePostCompliance.ts+++ b/resources/js/composables/usePostCompliance.ts@@ -1,7 +1,8 @@import { trans } from 'laravel-vue-i18n';import { computed, type ComputedRef, type Ref } from 'vue';-import { getMediaItemIssue, type MediaItem } from '@/composables/useMedia';+import { getMediaItemIssue } from '@/composables/useMedia';+import type { MediaItem } from '@/types/media';import { getMediaRulesForContentType } from '@/composables/useMediaRules';import { getPlatformLabel } from '@/composables/usePlatformLogo';import { ContentType } from '@/enums/content-type';diff --git a/resources/js/pages/posts/Edit.vue b/resources/js/pages/posts/Edit.vueindex 0b1aa30c5..d2c28a1ba 100644--- a/resources/js/pages/posts/Edit.vue+++ b/resources/js/pages/posts/Edit.vue@@ -23,21 +23,9 @@ import debounce from '@/debounce';import AppLayout from '@/layouts/AppLayout.vue';import { destroy as destroyPost, update as updatePost } from '@/routes/app/posts';import type { PinterestBoard } from '@/types';+import type { MediaItem } from '@/types/media';import { PostStatus } from '@/types/post';-interface MediaItem {- id: string;- path: string;- url: string;- type?: string;- mime_type?: string;- original_filename?: string;- size?: number;- source?: 'ai' | 'unsplash' | 'giphy';- source_meta?: Record<string, unknown>;- meta?: { width?: number; height?: number; duration?: number };-}-interface SocialAccount {id: string;platform: string;diff --git a/resources/js/pages/posts/Show.vue b/resources/js/pages/posts/Show.vueindex eaffc2767..3ef05f5bf 100644--- a/resources/js/pages/posts/Show.vue+++ b/resources/js/pages/posts/Show.vue@@ -18,16 +18,9 @@ import { getPlatformStatusConfig, getPostStatusConfig } from '@/composables/usePimport dayjs from '@/dayjs';import AppLayout from '@/layouts/AppLayout.vue';import { index as postsIndex } from '@/routes/app/posts';+import type { MediaItem } from '@/types/media';import { PostPlatformStatus, PostStatus } from '@/types/post';-interface MediaItem {- id: string;- url: string;- type?: string;- mime_type?: string;- original_filename?: string;-}-interface SocialAccount {id: string;platform: string;diff --git a/resources/js/types/media.ts b/resources/js/types/media.tsnew file mode 100644index 000000000..0f5309863--- /dev/null+++ b/resources/js/types/media.ts@@ -0,0 +1,18 @@+export type MediaSource = 'ai' | 'unsplash' | 'giphy';++export interface MediaItem {+ id: string;+ url: string;+ path?: string;+ type?: string;+ mime_type?: string;+ original_filename?: string;+ size?: number;+ source?: MediaSource;+ source_meta?: Record<string, unknown>;+ meta?: {+ width?: number;+ height?: number;+ duration?: number;+ };+}