Enhance deployment script and update package dependencies
- Added detailed labels to the deployment script for IndeedHub, including title, version, description, license, icon, and repository URL. - Updated package dependencies in package.json and package-lock.json, including upgrading 'nostr-tools' to version 2.23.0 and adding 'axios' and '@tanstack/vue-query'. - Improved README with a modern description of the platform and updated project structure details. This commit enhances the clarity of the deployment process and ensures the project is using the latest dependencies for better performance and features.
This commit is contained in:
97
src/utils/mappers.ts
Normal file
97
src/utils/mappers.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import type { ApiProject, ApiContent } from '../types/api'
|
||||
import type { Content } from '../types/content'
|
||||
import { apiService } from '../services/api.service'
|
||||
|
||||
/**
|
||||
* Data Mappers
|
||||
* Transform API models to frontend models
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extract year from date string
|
||||
*/
|
||||
function extractYear(dateString?: string): number | undefined {
|
||||
if (!dateString) return undefined
|
||||
const year = new Date(dateString).getFullYear()
|
||||
return isNaN(year) ? undefined : year
|
||||
}
|
||||
|
||||
/**
|
||||
* Map API Project to Frontend Content
|
||||
*/
|
||||
export function mapApiProjectToContent(project: ApiProject): Content {
|
||||
return {
|
||||
id: project.id,
|
||||
title: project.title,
|
||||
description: project.synopsis || '',
|
||||
thumbnail: apiService.getCdnUrl(project.poster),
|
||||
backdrop: apiService.getCdnUrl(project.poster),
|
||||
type: project.type === 'episodic' ? 'series' : 'film',
|
||||
rating: project.format || undefined,
|
||||
releaseYear: extractYear(project.releaseDate),
|
||||
duration: undefined, // Requires content metadata
|
||||
categories: project.genres?.map((g) => g.name) || [],
|
||||
|
||||
// Additional API fields
|
||||
slug: project.slug,
|
||||
rentalPrice: project.rentalPrice,
|
||||
status: project.status,
|
||||
apiData: project, // Store full API data for reference
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map array of API Projects to Frontend Contents
|
||||
*/
|
||||
export function mapApiProjectsToContents(projects: ApiProject[]): Content[] {
|
||||
return projects.map(mapApiProjectToContent)
|
||||
}
|
||||
|
||||
/**
|
||||
* Map API Content to Frontend Content
|
||||
*/
|
||||
export function mapApiContentToContent(content: ApiContent, project?: ApiProject): Content {
|
||||
return {
|
||||
id: content.id,
|
||||
title: content.title || project?.title || '',
|
||||
description: content.synopsis || project?.synopsis || '',
|
||||
thumbnail: apiService.getCdnUrl(content.poster || project?.poster || ''),
|
||||
backdrop: apiService.getCdnUrl(content.poster || project?.poster || ''),
|
||||
type: project?.type === 'episodic' ? 'series' : 'film',
|
||||
rating: project?.format,
|
||||
releaseYear: extractYear(content.releaseDate || project?.releaseDate),
|
||||
duration: content.metadata?.duration as number | undefined,
|
||||
categories: project?.genres?.map((g) => g.name) || [],
|
||||
|
||||
// Additional fields
|
||||
slug: project?.slug || '',
|
||||
rentalPrice: content.rentalPrice,
|
||||
status: content.status,
|
||||
drmEnabled: !!content.drmContentId,
|
||||
apiData: content,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map array of API Contents to Frontend Contents
|
||||
*/
|
||||
export function mapApiContentsToContents(contents: ApiContent[], project?: ApiProject): Content[] {
|
||||
return contents.map((content) => mapApiContentToContent(content, project))
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content identifier for Nostr events
|
||||
* Creates a unique identifier for external content references
|
||||
*/
|
||||
export function getNostrContentIdentifier(contentId: string): string {
|
||||
const baseUrl = import.meta.env.VITE_APP_URL || window.location.origin
|
||||
return `${baseUrl}/content/${contentId}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Nostr content identifier to get content ID
|
||||
*/
|
||||
export function parseNostrContentIdentifier(identifier: string): string | null {
|
||||
const match = identifier.match(/\/content\/([^/]+)$/)
|
||||
return match ? match[1] : null
|
||||
}
|
||||
Reference in New Issue
Block a user